×

Discussion Board

Results 1 to 4 of 4
  1. #1
    Registered User
    Join Date
    Dec 2008
    Posts
    4

    Question soundstream to RAW PCM sound buffer

    Hello.
    I try to make programme which record sound from microfone to buffer. I need RAW PCM sound or something like it. Not compressed one. Then i need to detect its (sound) energy and find if there is silence in room or not. I have speed limit on it (about 1-2seconds). I try http://wiki.forum.nokia.com/index.ph...io_with_stream this example to receive sound stream, but I think that contents of iSoundData is not PCM data. Then i use http://wiki.forum.nokia.com/index.php/FFT_algorithm to obtain sound energy from FFT.

    But how to get RAW PCM data from that buffer? I think it doesnt return PCM data. Am I right?

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,674

    Re: soundstream to RAW PCM sound buffer

    Actually it is PCM, just you get 16-bit data in an array of bytes (8-bit descriptor). So you have to combine the bytes. The alignment of 8-bit descriptor types ensure that the data starts on a 4-byte boundary, so you can use a cast-hack:
    Code:
    HBufC8 *something=... // as I see, you get HBufC8-s from that code
    const TUint16 *samples=reinterpret_cast<const TUint16*>(&( (*something)[0]) ));
    then samples[0], samples[1]... is your 16-bit sample data. I do not remember if it is signed or not (TUint16 treats it as signed).

  3. #3
    Registered User
    Join Date
    Dec 2008
    Posts
    4

    Re: soundstream to RAW PCM sound buffer

    Thx for your reply. It is good that it returns PCM data. And thanks for your "hack". It seems i have error in something else. My FFT returns still same data. I will look at it next week.

  4. #4
    Registered User
    Join Date
    Dec 2008
    Posts
    4

    Re: soundstream to RAW PCM sound buffer

    So, I updated my programme. If someone need something like me. I have some remarks.

    Thx wizard_hu_ for his cast-hack, but FFT needs TInt16 (signed) numbers.

    HBufC8 *something=... // as I see, you get HBufC8-s from that code
    const TInt16 *samples=reinterpret_cast<const TInt16*>(&( (*something)[0]) );
    It is better to use only second half of sound data, if you are using this sound example.

Similar Threads

  1. CMdaAudioOutputStream unexpected playback pauses on Nokia E51
    By pkolaczk in forum Symbian Media (Closed)
    Replies: 1
    Last Post: 2009-07-29, 15:13
  2. Replies: 6
    Last Post: 2005-10-03, 05:51
  3. Dialog's clipping area (again). Nokia experts, please help
    By synov in forum Symbian User Interface
    Replies: 0
    Last Post: 2004-06-26, 14:35
  4. Playing Sound From a Buffer
    By nutter420 in forum Symbian Networking & Messaging (Closed)
    Replies: 1
    Last Post: 2003-08-01, 03:43
  5. Playing Sound From a Buffer
    By nutter420 in forum Symbian User Interface
    Replies: 0
    Last Post: 2003-07-31, 14:20

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×