0
0

In my audio editor I create sound from my mp3 files ( 1 hour duration, 16bits, mono ) using createSound.
This is the code:
I create the sound:
[code:1omrdizz]result = AudioDevice::getInstance()->getSystem()->createSound(
soundName_.toAscii().data(),
FMOD_CREATESAMPLE | FMOD_SOFTWARE,
0,
&m_sound );

if(!m_sound )
{
    return false;
}[/code:1omrdizz]

I get the length in pcm
[code:1omrdizz]
result = m_sound->getLength( &m_samples, FMOD_TIMEUNIT_PCM );//pcm samples[/code:1omrdizz]
I determine the amount of bytes
[code:1omrdizz]m_bytes = ((float)m_samples * (float)m_bits * (float)m_channels) / 8.0f;[/code:1omrdizz]
And finally I lock it to access raw samples ( to draw waveform )
[code:1omrdizz]result = m_sound->lock( 0, m_bytes, &ptr1, &ptr2, &len1, &len2 );
[/code:1omrdizz]

The createSound is very slow with my mp3 files so I changed ( as a user suggested to me ) createSoud with createStream so:

[code:1omrdizz]result = AudioDevice::getInstance()->getSystem()->createStream(
soundName_.toAscii().data(),
FMOD_CREATESAMPLE | FMOD_SOFTWARE,
0,
&m_sound );

if(!m_sound )
{
    return false;
}

[/code:1omrdizz]

Again I get the lenggth in samples
[code:1omrdizz] result = m_sound->getLength( &m_samples, FMOD_TIMEUNIT_PCM );//pcm samples[/code:1omrdizz]

Again I determine the amount of bytes to call the lock
[code:1omrdizz]m_bytes = ((float)m_samples * (float)m_bits * (float)m_channels) / 8.0f;[/code:1omrdizz]

[code:1omrdizz]result = m_sound->lock( 0, m_bytes, &ptr1, &ptr2, &len1, &len2 );[/code:1omrdizz]

Now the lock returns a null pointer of the samples buffer (ptr1) and I don’t undertand why.
Where I’m wrong?

Best Regards,
Franco

  • You must to post comments
0
0

Any reply? How can I load the raw samples in memory using createStream?
Best Regards,
Franco

  • You must to post comments
0
0

Have you tried using getWaveData()?

The best way though is to use the DSP API and insert your own data capture unit into the DSP chain.

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.