Converted .wav file to C code not outputting sound in ARM processor

0

I'm currently coding a project using the ARM processor. The code is written in C, and I want to play a sound. I have this bit of code here:

#include <stdbool.h>


    void sound(int buffer[], int BUF_SIZE){
    volatile int * audio_ptr = (int *) 0xFF203040; // audio port address
int fifospace; 
    int buffer_index = 0;
int left_buffer[BUF_SIZE];
int right_buffer[BUF_SIZE];

fifospace = *(audio_ptr + 1); // read the audio port fifospace register
if ( (fifospace & 0x000000FF) > 96) // check RARC, for > 75% full
{
/* store data until the audio-in FIFO is empty or the memory buffer is full */
while ( (fifospace & 0x000000FF) && (buffer_index < BUF_SIZE) )
{
 *(audio_ptr + 2)= buffer[buffer_index]; //Leftdata
 *(audio_ptr + 3) = buffer[buffer_index]; //Rightdata
++buffer_index;
fifospace = *(audio_ptr + 1); // read the audio port fifospace register
}
}
}

int main(void){
int die_buffer[26112] = {...}; 

int die_buf_size = 26112;    
 sound(die_buffer,die_buf_size);

}

I have used a sample die_buffer array that works and can output sound. I tried converting my own .wav file to C code by using a program called Wav2Code. I uploaded my .wav file (it plays a G note) and selected 16 bits, 1 channel, mix to mono and saved it as a C code. I took the array it outputted in the form of:

#define NUM_ELEMENTS 48651

unsigned char data0[NUM_ELEMENTS] = {
128, 128, 128, 128, 128, 128, 128, 128, ...}

And set it equal to my die_bufferarray. However, when I ran the code, no sound came out. Please help! I have no idea how to convert a .wav file correct to C so that it can work with the processor.

Edit: I got my .wav file using Audacity. I recorded a sound, and I exported it as a .wav and saved it as a "signed 16-bit PCM" (since saving it as a 32-bit float PCM didn't work on WaveToCode). I set the project rate to 48000Hz, mono and I exported with those parameters. Image of my Audacity export parameters

Then, I use WaveToCode to change it to C code. Here are the parameters I used (mixed it to mono).

Image of my WaveToCode export parameters

I also talked to someone and they said that the processor expects a 32-bit signed integer samples at a 48kHz sampling rate, and I'm not sure if I managed to convert to that correctly. Hopefully this edit helped clarified what I'm trying to do. Thanks.

c
assembly
audio
arm
asked on Stack Overflow Apr 10, 2019 by Ruby • edited Apr 11, 2019 by Ruby

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0