#143932 - kiwicode - Sat Oct 27, 2007 2:42 pm
Hi all,
This week I've been trying to play wav files on a my nds application.
As I've already done with images I don't want to link my data using headers generated by bin2o rule ( #include "blaster_raw.h" ).
For that reason I created a wave structure able to hold all the data inside my wav file.
and then I was hoping to play the sound effect with a couple of lines...
This is not working since I can just hear a strange buzzing sound from the speakers.
I read somewere that NDS wants signed sound data instead of unsigned but nothing seems to change.
I would like to control sound through arm9 with these provided functions ( playSound etc. etc. ) that seem to work with "header-like" raw data.
Maybe I'm not handling wave data the right way, missing something somewhere..
Any ideas?
Thank you in advance,
kiwicode
This week I've been trying to play wav files on a my nds application.
As I've already done with images I don't want to link my data using headers generated by bin2o rule ( #include "blaster_raw.h" ).
For that reason I created a wave structure able to hold all the data inside my wav file.
Code: |
#ifndef __WAV_H__
#define __WAV_H__ #include <gbfs.h> typedef struct { char chunkId[ 4 ]; uint32 chunkDataSize; char riffType[ 4 ]; }__attribute__ ((packed)) wav_header; typedef struct { char subChunkID[ 4 ]; uint32 subChunkSize; uint16 audioFormat; uint16 numChannels; uint32 sampleRate; uint32 byteRate; uint16 blockAlign; uint16 bitsPerSample; }__attribute__ ((packed)) wav_file_info; typedef struct { char data[ 4 ]; uint32 dataLength; uint16 *wav_data; }__attribute__ ((packed)) data; typedef struct { wav_header *pHeader; wav_file_info *pFileInfo; data *pData; }__attribute__ ((packed)) wav_file; extern wav_file *loadWav(const GBFS_FILE *file, const char *name); extern void displayWavInfo( wav_file* pFile ); #endif |
and then I was hoping to play the sound effect with a couple of lines...
Code: |
wav_file *pWav = loadWav( &data_gbfs, "alien.wav" ); setGenericSound( 44100, 127, 64, 0 ); // let's set our sound format TransferSoundData alienSound = { ( u16 * )pWav->pData->wav_data, // data pointer pWav->pData->dataLength, // data length 44100, // sample rate 127, // volume 64, // pan 0 // 16 bit }; playSound( &alienSound ); |
This is not working since I can just hear a strange buzzing sound from the speakers.
I read somewere that NDS wants signed sound data instead of unsigned but nothing seems to change.
I would like to control sound through arm9 with these provided functions ( playSound etc. etc. ) that seem to work with "header-like" raw data.
Maybe I'm not handling wave data the right way, missing something somewhere..
Any ideas?
Thank you in advance,
kiwicode