Author Topic: how get raw samples of a mp3 file a a float array?  (Read 1253 times)

p30pro

  • Guest
hi ! 

i want to get pcm data from a mp3 file whit modifying sample per rate ! how can i do this ?

p30pro

  • Guest
Additional information
« Reply #1 on: 2 May '13 - 15:34 »
i am using bass.net in C#

Ian @ un4seen

  • Administrator
  • Posts: 20433
You need to create a "decoding channel" by using the BASS_STREAM_DECODE flag, and then use BASS_ChannelGetData to get the decoded data from it. I don't use .Net myself, so I'm afraid I can't advise on that, but in C++ it could look like this...

Code: [Select]
HSTREAM decoder=BASS_StreamCreateFile(FALSE, filename, 0, 0, BASS_SAMPLE_FLOAT|BASS_STREAM_DECODE|BASS_STREAM_PRESCAN); // create a floating-point decoding channel for an audio file
DWORD datalen=BASS_ChannelGetData(decoder, BASS_POS_BYTE); // get its length
float *data=new float[datalen/4]; // allocate array for data
datalen=BASS_ChannelGetData(decoder, data, datalen); // get the data