0
0

Hi to all,
I’m developing a simple ( not so simple for me ) audio editor to cut an audio file and store every cutted part as new audio file.
I would show the umplitude of the uncutted ( original ) audio file ( something as audacity does ). The user should see that and cut the audio at some points.

I hope to get help.

Best Regards,
Franco

  • You must to post comments
0
0

[quote="peter":36jaf8rr]Hi Franco,

Sorry that was a typo, it should not have FMOD_COMPRESSEDSAMPLE, it should just be FMOD_CREATESAMPLE.

I don’t think accurate time flag is meaningful in this context because FMOD is decompressing the sound when it’s loaded.

-Pete[/quote:36jaf8rr]

Hi Peter,
which is the difference between using sound lock/unlock or using sound::readData to get the uncompressend samples to do audio editing?

Reards

  • You must to post comments
0
0

I’m not aware of such a function, but I’m not particularly familiar with that side of FMOD, so hopefully someone from Firelight can give you additional info if there is another way.

  • You must to post comments
0
0

[quote="peter":7p87oclk][code:7p87oclk] //// raw PCM from compressed file test

FMOD::Sound *sound = NULL;
ERRCHECK(system->createSound("C:/media/song.mp3", FMOD_CREATESAMPLE, 0, &sound));

unsigned int len = 0;
ERRCHECK(sound->getLength(&len, FMOD_TIMEUNIT_PCMBYTES));

FMOD_SOUND_FORMAT format;
ERRCHECK(sound->getFormat(NULL, &format, 0, 0));

void *ptr1 = NULL, *ptr2 = NULL;
unsigned int len1 = 0, len2 = 0;
ERRCHECK(sound->lock(0, len, &ptr1, &ptr2, &len1, &len2));[/code:7p87oclk]

Edit: changed FMOD_CREATECOMPRESSEDSAMPLE to FMOD_CREATESAMPLE

Now ptr1 is pointing at raw uncompressed data decoded from "song.mp3". The format of the data can be determined using getFormat. You can cast the (void) to a type based on the format. I had format=FMOD_SOUND_FORMAT_PCM16 so I cast ptr1 to a (short).

-Pete[/quote:7p87oclk]

Peter if you got FMOD_SOUND_FORMAT_PCM16 this means every sample is = 2 bytes right? So if with sound->getLength I get a length of X this mean I have X/2 samples with that format? As the documentation says sound->getLength returns the num of bytes with the FMOD_TIMEUNIT_PCMBYTES flag.
Can you explain it as is not so clear for me please?
Best Regards

  • You must to post comments
0
0

The amplitude is the maximum wave data value minus the minumum wave data value of the data set…

  • You must to post comments
0
0

[quote="audiodev":y8txfwte]I’m not aware of such a function, but I’m not particularly familiar with that side of FMOD, so hopefully someone from Firelight can give you additional info if there is another way.[/quote:y8txfwte]

Yes I’m impatiently waiting for such reply 😉
In the time I’m giving a look at ffmpeg.

  • You must to post comments
0
0

[quote:2mw368c0]So if with sound->getLength I get a length of X this mean I have X/2 samples with that format?[/quote:2mw368c0]
That is correct.

  • You must to post comments
0
0

[quote="icuurd12b42":a6q7i0an]The amplitude is the maximum wave data value minus the minumum wave data value of the data set…[/quote:a6q7i0an]

Hi, thank you for the reply.
I think there was a misunderstand. What I need to calculate and show
in the gui I’m developing is what you can see in the image that you can see in the following link:

[url:a6q7i0an]http://www.guidesandtutorials.com/audacity-tracks.html[/url:a6q7i0an]

I hope you can help me.
Best Regards,
Franco

  • You must to post comments
0
0

System::createSound will load the whole file as uncompressed pcm when using FMOD_CREATESAMPLE (the default).

-Pete

  • You must to post comments
0
0

That is the wave data ::getWaveData.

  • You must to post comments
0
0

[quote="peter":iqb1zao0]System::createSound will load the whole file as uncompressed pcm when using FMOD_CREATESAMPLE (the default).

-Pete[/quote:iqb1zao0]

Thank you Peter. How can I access to the pcm samples in that case?
The documentation doesn’t specify it.
It says: [quote:iqb1zao0]By default (FMOD_CREATESAMPLE) FMOD will try to load and decompress the whole sound into memory![/quote:iqb1zao0]
but it doesn’t specify how to access to every pcm sample or I’m wrong?.

Best Regards,
Franco

  • You must to post comments
0
0

[quote="icuurd12b42":2cgdeytx]That is the wave data ::getWaveData.[/quote:2cgdeytx]

Thank you. There is something I don’t understand.
I would display the wavedatas after loading the file, NOT during playing it.
So I firstly have to know how many pcm samples it contains right? How can I do it?
The steps are this:
1) load the file
2) get number of pcm samples
3) display wavedata
4) edit (optionally) the data

Can I have a help with some code?

Regards,
Franco

  • You must to post comments
0
0

[quote="franco":3c665zxk][quote="peter":3c665zxk]System::createSound will load the whole file as uncompressed pcm when using FMOD_CREATESAMPLE (the default).

-Pete[/quote:3c665zxk]

Thank you Peter. How can I access to the pcm samples in that case?
The documentation doesn’t specify it.
It says: [quote:3c665zxk]By default (FMOD_CREATESAMPLE) FMOD will try to load and decompress the whole sound into memory![/quote:3c665zxk]
but it doesn’t specify how to access to every pcm sample or I’m wrong?.

Best Regards,
Franco[/quote:3c665zxk]

What’s happened to your post?

  • You must to post comments
0
0

If you know that the file you are opening is always PCM data, you can use sound::lock() which will give you access to the raw guts of the sound. If you support compressed sounds, then you need to decode the sound, and the easiest way to do that is playback. You can always play a sound silently or in a separate instance of FMOD that you update as rapidly as possible.

  • You must to post comments
0
0

[code:1791ya9c] //// raw PCM from compressed file test

FMOD::Sound *sound = NULL;
ERRCHECK(system->createSound("C:/media/song.mp3", FMOD_CREATESAMPLE, 0, &sound));

unsigned int len = 0;
ERRCHECK(sound->getLength(&len, FMOD_TIMEUNIT_PCMBYTES));

FMOD_SOUND_FORMAT format;
ERRCHECK(sound->getFormat(NULL, &format, 0, 0));

void *ptr1 = NULL, *ptr2 = NULL;
unsigned int len1 = 0, len2 = 0;
ERRCHECK(sound->lock(0, len, &ptr1, &ptr2, &len1, &len2));[/code:1791ya9c]

Edit: changed FMOD_CREATECOMPRESSEDSAMPLE to FMOD_CREATESAMPLE

Now ptr1 is pointing at raw uncompressed data decoded from "song.mp3". The format of the data can be determined using getFormat. You can cast the (void) to a type based on the format. I had format=FMOD_SOUND_FORMAT_PCM16 so I cast ptr1 to a (short).

-Pete

  • You must to post comments
0
0

[quote="audiodev":27bdm0gn]If you know that the file you are opening is always PCM data, you can use sound::lock() which will give you access to the raw guts of the sound. If you support compressed sounds, then you need to decode the sound, and the easiest way to do that is playback. You can always play a sound silently or in a separate instance of FMOD that you update as rapidly as possible.[/quote:27bdm0gn]

Hi,
wow seems very complex. But how audacity can do that without play the sound? Simply loading the audio file it shows the wave form of pcm samples. I always load mp3 or wav files.

  • You must to post comments
0
0

[quote="peter":1r29bxlf][code:1r29bxlf] //// raw PCM from compressed file test

FMOD::Sound *sound = NULL;
ERRCHECK(system->createSound("C:/media/song.mp3", FMOD_CREATECOMPRESSEDSAMPLE, 0, &sound));

unsigned int len = 0;
ERRCHECK(sound->getLength(&len, FMOD_TIMEUNIT_PCMBYTES));

FMOD_SOUND_FORMAT format;
ERRCHECK(sound->getFormat(NULL, &format, 0, 0));

void *ptr1 = NULL, *ptr2 = NULL;
unsigned int len1 = 0, len2 = 0;
ERRCHECK(sound->lock(0, len, &ptr1, &ptr2, &len1, &len2));[/code:1r29bxlf]

Now ptr1 is pointing at raw uncompressed data decoded from "song.mp3". The format of the data can be determined using getFormat. You can cast the (void) to a type based on the format. I had format=FMOD_SOUND_FORMAT_PCM16 so I cast ptr1 to a (short).

-Pete[/quote:1r29bxlf]

Thank you Pter.
In my case I have to develop an audio editor so I don’t have to use FMOD_ACCURATETIME? And what about FMOD_CREATESAMPLE you said in a former post?

  • You must to post comments
0
0

I’m sure that they run a decoder on the sound when they open it. In fact, given that they are a program focused on audio authoring, they probably store all sounds in memory as linear PCM and convert into that format when they load. FMOD is targeted at game middleware, so while you can use it to build editing software, it’s not architected with that as the focus.

  • You must to post comments
0
0

[quote="peter":3p5hrb1h][code:3p5hrb1h] //// raw PCM from compressed file test

FMOD::Sound *sound = NULL;
ERRCHECK(system->createSound("C:/media/song.mp3", FMOD_CREATECOMPRESSEDSAMPLE, 0, &sound));

unsigned int len = 0;
ERRCHECK(sound->getLength(&len, FMOD_TIMEUNIT_PCMBYTES));

FMOD_SOUND_FORMAT format;
ERRCHECK(sound->getFormat(NULL, &format, 0, 0));

void *ptr1 = NULL, *ptr2 = NULL;
unsigned int len1 = 0, len2 = 0;
ERRCHECK(sound->lock(0, len, &ptr1, &ptr2, &len1, &len2));[/code:3p5hrb1h]

Now ptr1 is pointing at raw uncompressed data decoded from "song.mp3". The format of the data can be determined using getFormat. You can cast the (void) to a type based on the format. I had format=FMOD_SOUND_FORMAT_PCM16 so I cast ptr1 to a (short).

-Pete[/quote:3p5hrb1h]

Peter I got an error from FMOD at the line
[code:3p5hrb1h]ERRCHECK(sound->lock(0, len, &ptr1, &ptr2, &len1, &len2));[/code:3p5hrb1h].
The error is:
FMOD error! (37) An invalid parameter was passed to this function.
Can you explain me better where I have to cast the pointer please?
Thank you very much

  • You must to post comments
0
0

Also note that FMOD supports some formats (GMADPCM, XMA, etc) that are decoded in hardware, which means the only way you can get the PCM audio is by "playing" it.

  • You must to post comments
0
0

[quote="peter":xq1ko0wv][code:xq1ko0wv] //// raw PCM from compressed file test

FMOD::Sound *sound = NULL;
ERRCHECK(system->createSound("C:/media/song.mp3", FMOD_CREATECOMPRESSEDSAMPLE, 0, &sound));

unsigned int len = 0;
ERRCHECK(sound->getLength(&len, FMOD_TIMEUNIT_PCMBYTES));

FMOD_SOUND_FORMAT format;
ERRCHECK(sound->getFormat(NULL, &format, 0, 0));

void *ptr1 = NULL, *ptr2 = NULL;
unsigned int len1 = 0, len2 = 0;
ERRCHECK(sound->lock(0, len, &ptr1, &ptr2, &len1, &len2));[/code:xq1ko0wv]

Now ptr1 is pointing at raw uncompressed data decoded from "song.mp3". The format of the data can be determined using getFormat. You can cast the (void) to a type based on the format. I had format=FMOD_SOUND_FORMAT_PCM16 so I cast ptr1 to a (short).

-Pete[/quote:xq1ko0wv]

Peter I tried your example and I got FMOD_ERR_INVALID_HANDLE from FMOD::Sound::lock. I don’t understand which can be the problem
:(

  • You must to post comments
Showing 1 - 20 of 23 results
Your Answer

Please first to submit.