其他声音,然后是原始.wav文件。

| 我正在使用来自微芯片v8.63的pic18F4550:我为picdem使用了C程序语言:我们创建了以下程序:我们检索了.wav文件的二进制数据,该文件转换为8bit 8000Hz(声音是:有人说\“ \” \“ red \”),我们将数据写入picdem的\'rom \'。每个值将被写入端口=>连接有一个盒子。 问题:我不能在这里显示原始声音(有人说:“红色”),而不是听到其他声音很大(没有噪音或crack啪声)但听到其他声音。 那是代码:
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;

}
    
已邀请:
        这是一个开放性问题,我无法给您绝对的答案,但是我可以给您一些想法。 您确定数据正确吗?使用数组my_const_array []并编写一个小程序,将其转换回8bit wav,并确保您听到正确的声音。对我来说,您列出的波形数据看起来很短,只有约430个样本,因此在8000Hz频率下播放声音大约需要50ms。那是对的吗?同样,您的样本中大约有一半(200+)的值是'0b01010101'。 尝试切换每个字节的位顺序,因此翻转每个二进制值。 IE 0b01010101变为0b10101010 您是否以适当的速度计时? 我建议您将录制的语音样本替换为更可测量的方波,然后记录输出以进行比较。     
        您的程序可能是错误的! 我想您正在使用一位DAC,所以: 线..
LATAbits.LATA2=TABLAT;
只会将第一个(零)位复制到CPU引脚RA2,其余7位将丢失。     

要回复问题请先登录注册