0
0

hi! i am new to fmod abut i want to make my simple console music player. here is my code:
[code:1u9rcyl0]
/* test.cpp */

include <windows.h>

include <stdio.h>

include <conio.h>

include "../../api/inc/fmod.h"

include "../../api/inc/fmod_errors.h"

void ERRCHECK(FMOD_RESULT result)
{
if (result != FMOD_OK)
{
printf("FMOD error! (%d) %s\n", result, FMOD_ErrorString(result));
exit(-1);
}
}

int main(int argc, char *argv[])
{
FMOD_SYSTEM *system;
FMOD_SOUND *sound;
FMOD_CHANNEL *channel = 0;
FMOD_RESULT result;
int key;
unsigned int version;

/*
    Create a System object and initialize.
*/
result = FMOD_System_Init(system, 32, FMOD_INIT_NORMAL, NULL);
ERRCHECK(result);

result = FMOD_System_Create(&amp;system);
ERRCHECK(result);

result = FMOD_System_GetVersion(system, &amp;version);
ERRCHECK(result);

if (version &lt; FMOD_VERSION)
{
    printf(&quot;Error!  You are using an old version of FMOD %08x.  This program requires %08x\n&quot;, version, FMOD_VERSION);
    return 0;
}

result = FMOD_System_CreateSound(system, argv[1], FMOD_SOFTWARE, 0, &amp;sound);
ERRCHECK(result);

/*
    Main loop.
*/

for(;;)
{
result = FMOD_System_PlaySound(system, FMOD_CHANNEL_FREE, sound, 0, &channel);
ERRCHECK(result);
}

result = FMOD_Sound_Release(sound);
ERRCHECK(result);
result = FMOD_System_Close(system);
ERRCHECK(result);
result = FMOD_System_Release(system);
ERRCHECK(result);

return 0;

}
[/code:1u9rcyl0]

it compiles but does not work ( i wanted to set the name of file as argument in console)
it says me:

PS C:\fmod\my\test> ./test bleed.mp3
FMOD error! (37) An invalid parameter was passed to this function.

i think the problem is here

[code:1u9rcyl0]
result = FMOD_System_CreateSound(system, argv[1], FMOD_SOFTWARE, 0, &sound);
ERRCHECK(result);
[/code:1u9rcyl0]

any sujjestions? please help!

  • You must to post comments
0
0

Hello!

I’ve only briefly worked with consoles, so sorry for my lack of knowledge, but try this out:

Include "<iostream>" into your code and use (optional) "cout << "What track would you like to play?" << endl;" To ask for a certain track. ("endl" moves a line down in the console. I don’t know how much of this you already know.)
Then "cin >> your std::string variable for the name of the song;" and use your variable as the directory to create a sound.

That’s all I have to offer but I’ll try to answer questions if you have them.
(and sorry if I have just provided useless knowledge!)

Best of luck!

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.