Answered
0
0

Hello,

I’m new at FMOD c++ version.

I’m looking for a way to get the sound signal (f(t)).

I’ve tried this code :
But, it never returns any data….
Could you help me ?
Thanks.
F.

include

using namespace FMOD;

int main()
{

System *system;
unsigned int version;
Sound *sound;

System_Create(&system);

system->getVersion(&version);

std::cout << version ;

system->init(2, FMOD_INIT_NORMAL, NULL);

system->createSound(“essai.mp3”, FMOD_DEFAULT, 0, &sound);

FMOD_RESULT res;
do{
int val = -1;
unsigned int read;
res = sound->readData(&val, 1,&read);

std::cout << val << std::endl;
}while(res != FMOD_ERR_FILE_EOF);
return 0;
}

  • You must to post comments
Best Answer
0
0

Checking the result of readData should help you if there is an issue.

When you create the sound using the FMOD_DEFAULT flag, the file is closed after createSound is finished which will stop readData from working. Using some thing like FMOD_OPENONLY will keep the file open for you to access.
http://www.fmod.org/documentation/#content/generated/FMOD_Sound_ReadData.html

  • Flow

    OK, thanks,
    But, a question if so, where the data is read when playing sound with the FMOD_DEFAULT flag ?

  • Cameron Baron

    ReadData is used to decode files into data that you can then use and/or store.
    When you create a sound using FMOD_DEFAULT, we open the file and read it into a buffer using readData and then close the file when done.
    If you want you can access this buffer using Sound::lock https://fmod.com/resources/documentation-api?page=content/generated/FMOD_Sound_Lock.html#/

    Otherwise, use FMOD_CREATESTREAM with FMOD_OPENONLY to be able to access the file with readData yourself.

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.