English 中文(简体)
其他声音,然后原始.wav文件
原标题:other sound then the original .wav file

我使用的是微芯片v8.63中的pic18F4550:我为picdem使用了C程序语言:我们创建了以下程序:我们检索转换为8bit 8000Hz的.wav文件的二进制数据(声音是:有人说s“red”),我们将数据写入picdem的rom。每个值将被写入端口=>;有一个盒子连接到。

问题是:我不能在这里,原来的声音(有人说s:“红色”)而不是听到一个响亮的其他声音(没有噪音或噼啪声),而是一个巨大的其他声音。

这就是代码:

unsigned int b = 0;
unsigned int i = 0;
unsigned int j= 0;

#pragma romdata const_table  = 0x1200

const rom char my_const_array[] = "0b01010101
,0b10101010
,0b10101010
,0b10101010
,0b10101001
,0b01010101
,0b01010110
,0b10100101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010100
,0b10110101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01001010
,0b10101010
,0b11010101
,0b00101010
,0b10101011
,0b01010101
,0b01010101
,0b01010101
,0b01001010
,0b10101010
,0b11010100
,0b10101010
,0b10101010
,0b10110101
,0b01010101
,0b01010101
,0b01001010
,0b10101010
,0b10101010
,0b10101010
,0b10101010
,0b10101010
,0b10101101
,0b01010100
,0b10101010
,0b10011010
,0b10101010
,0b10101010
,0b10101010
,0b10101010
,0b10101010
,0b10110010
,0b10100101
,0b01010110
,0b10101010
,0b10100101
,0b01011010
,0b10101010
,0b10101010
,0b11001010
,0b10010101
,0b01011010
,0b10101001
,0b01010101
,0b01101010
,0b10101010
,0b10101101
,0b00101001
,0b01010101
,0b10101010
,0b10010101
,0b01010101
,0b10101010
,0b10101010
,0b11010010
,0b10010101
,0b01011010
,0b10101001
,0b01010101
,0b01011010
,0b10010101
,0b10101101
,0b00101001
,0b01010101
,0b10101010
,0b01010100
,0b11010101
,0b10100101
,0b01011010
,0b11001010
,0b01010101
,0b01011010
,0b10100101
,0b00101101
,0b01010101
,0b01010110
,0b10110010
,0b10010011
,0b01010110
,0b10010101
,0b00101011
,0b01010101
,0b01010101
,0b01101010
,0b01010100
,0b10101011
,0b01100101
,0b00101010
,0b10110101
,0b01010101
,0b01011010
,0b10010101
,0b00101011
,0b01010101
,0b00101010
,0b10110101
,0b01010011
,0b00110101
,0b10100100
,0b10101010
,0b11010101
,0b01001010
,0b10101010
,0b11010010
,0b10101101
,0b01100100
,0b10101010
,0b11010101
,0b01001010
,0b10101010
,0b10101010
,0b10101011
,0b01101001
,0b00101010
,0b10110101
,0b01001010
,0b10101010
,0b11001010
,0b10101011
,0b01010101
,0b00101010
,0b10101101
,0b01010010
,0b10101010
,0b10110010
,0b10101010
,0b11010101
,0b00101010
,0b10101011
,0b00101010
,0b10101010
,0b10101010
,0b10101010
,0b10110101
,0b00100101
,0b01011010
,0b10101010
,0b10010101
,0b01101010
,0b10011010
,0b10101101
,0b00100101
,0b01010110
,0b10101010
,0b10010101
,0b01010110
,0b10100101
,0b10101011
,0b01001001
,0b01010101
,0b10101010
,0b10010101
,0b01010110
,0b10100101
,0b01101010
,0b10101001
,0b01010101
,0b01101010
,0b10100101
,0b01010101
,0b01100101
,0b01010110
,0b10101010
,0b01010101
,0b01010110
,0b10010101
,0b01010101
,0b01010101
,0b01010101
,0b01101010
,0b10010101
,0b01001101
,0b01010101
,0b01001011
,0b01010101
,0b01010101
,0b01010101
,0b10100100
,0b10101010
,0b11010101
,0b01010010
,0b10101011
,0b01010100
,0b10110101
,0b01010101
,0b01001010
,0b10101011
,0b01010101
,0b00101010
,0b10101010
,0b10101010
,0b10101011
,0b01010100
,0b10101010
,0b10101010
,0b10101010
,0b10101010
,0b10101010
,0b10101010
,0b10101101
,0b01010010
,0b10100101
,0b10101010
,0b10101010
,0b01011010
,0b10101010
,0b10101010
,0b10110101
,0b01001010
,0b10010101
,0b10101010
,0b10101001
,0b01010110
,0b10101010
,0b10101010
,0b10101010
,0b10101010
,0b01010101
,0b01011010
,0b10101010
,0b10101010
,0b01010110
,0b10101010
,0b10101010
,0b10101010
,0b10101010
,0b01010101
,0b01010110
,0b10101010
,0b10101010
,0b10100101
,0b01011010
,0b10101010
,0b10101010
,0b10010101
,0b01010101
,0b10010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b01010101
,0b00000000";

#pragma romdata

//void Delay(unsigned int);
void main (void)
{   

    TRISD = 0x00;               // PORTD  als uitgang
    TRISB = 0b00110000;         // RB4 en RB5 als ingang
    TRISA = 0x00;               // RA output

    RCONbits.IPEN = 0;          // prioriteit uit
    INTCONbits.GIE = 1;         // enable interrupt
    INTCONbits.RBIE = 1;        // interrupt portB aan

    while(1)
    {   
        _asm sleep _endasm  
    }
}

#pragma interrupt ISR
void ISR (void)
{

    if (INTCONbits.RBIF==1)
    {
        if(PORTBbits.RB5==0) 
        {
            TBLPTR = (short long) 0x1200;

            for(i = 0 ; i<sizeof(my_const_array); i++) {
                _asm TBLRDPOSTINC _endasm
                LATAbits.LATA2=TABLAT;

                b = 0;

                do{
                    b++;
                }while(b < 200);



            }
        }
    }   
    INTCONbits.RBIF = 0;

}
问题回答

这是一个开放式的问题,我不能给你绝对的答案,但我可以给你一些尝试的想法。

  1. 你确定数据是正确的吗?取数组my_const_array[],编写一个小程序将其转换回8bit的wav,并确保您听到正确的声音。对我来说,你列出的波形数据看起来很短,只有大约430个样本,所以在8000Hz时,声音需要大约50ms才能播放。这是正确的吗?此外,您的样本中约有一半(200+)的值为0b01010101。

  2. 尝试切换每个字节的比特顺序,因此翻转每个二进制值。IE 0b01010101变为0b10101010

  3. 你以正确的速度完成了吗?

我建议您将录制的语音样本替换为更可测量的东西,如方波,然后录制输出以进行比较。

你的程序可能错了!

我想您使用的是单比特DAC,因此:

线

LATAbits.LATA2=TABLAT;

将仅将第一个(零)位复制到CPU引脚RA2,其余7个丢失。





相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签