0
0

THis compiles but I get no sound. it is adapted from generate tone and is reworked to work with a borland c++builder form. I was wanting to get a sine tone when I click on the button.

[code:16j7w38f]
//—————————————————————————

include <vcl.h>

pragma hdrstop

include "simple_app.h"

//—————————————————————————

pragma package(smart_init)

pragma resource "*.dfm"

include <fmod.h>

include <fmod_errors.h>

include <windows.h>

include <stdio.h>

include <conio.h>

FMOD_SYSTEM *system;
FMOD_CHANNEL *channel = 0;
FMOD_DSP *dsp = 0;
FMOD_RESULT result;
int key;
unsigned int version;
int x = 2;

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

int dspinit(int argc, char *argv[])
{

/*
    Create a System object and initialize.
*/
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_Init(system, 32, FMOD_INIT_NORMAL, NULL);
ERRCHECK(result);

/*
    Create an oscillator DSP unit for the tone.
*/
result = FMOD_System_CreateDSPByType(system, FMOD_DSP_TYPE_OSCILLATOR, &amp;dsp);
ERRCHECK(result);
result = FMOD_DSP_SetParameter(dsp, FMOD_DSP_OSCILLATOR_RATE, 440.0f);       /* musical note 'A' */
ERRCHECK(result);

}
int sinewave(void)
{
//int x = 2;
//while (x = 0 ) {
result = FMOD_System_PlayDSP(system, FMOD_CHANNEL_REUSE, dsp, TRUE, &channel);
FMOD_Channel_SetVolume(channel, 0.5f);
result = FMOD_DSP_SetParameter(dsp, FMOD_DSP_OSCILLATOR_TYPE, 0);
ERRCHECK(result);
FMOD_Channel_SetPaused(channel, FALSE); //}
}
int sysup(void) {
FMOD_System_Update(system);

    {
        float frequency = 0, volume = 0, pan = 0;
        int playing = FALSE;

        if (channel)
        {
            FMOD_Channel_GetFrequency(channel, &amp;frequency);
            FMOD_Channel_GetVolume(channel, &amp;volume);
            FMOD_Channel_GetPan(channel, &amp;pan);
            FMOD_Channel_IsPlaying(channel, &amp;playing);
        }

        printf(&quot;Channel %s : Frequency %.1f Volume %.1f Pan %.1f  \r&quot;, playing ? &quot;playing&quot; : &quot;stopped&quot;, frequency, volume, pan);
    }

    Sleep(10);

   printf(&quot;\n&quot;);

/*
    Shut down
*/
result = FMOD_DSP_Release(dsp);
ERRCHECK(result);
result = FMOD_System_Close(system);
ERRCHECK(result);
result = FMOD_System_Release(system);
ERRCHECK(result);

return 0;

}

TForm1 *Form1;
//—————————————————————————
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//—————————————————————————

void __fastcall TForm1::BitBtn1Click(TObject *Sender)

{
dspinit;
while (x = 0){
// dspinit;
sinewave;
sysup; }
}
//—————————————————————————

void __fastcall TForm1::FormCreate(TObject *Sender)
{
dspinit;
}
//—————————————————————————
[/code:16j7w38f]

http://www.dexrow.com

  • You must to post comments
0
0

you’re calling playDSP every frame? (every 10ms). You only play it once, not repeatedly.

  • You must to post comments
0
0

it doesn’t seem to matter if it is in the init or if it is called over and over. compile is fine but no sound comes out of the computer when I press the button.

http://www.dexrow.com

  • You must to post comments
0
0

You are shutting down the FMOD system in your sysup function…

  • You must to post comments
0
0

[quote="FireStorm":26e4jygt]You are shutting down the FMOD system in your sysup function…[/quote:26e4jygt]

Good catch I missed that, I could barely read the code without proper formatting, so I edited the OP’s post to make it more readable :)

  • You must to post comments
0
0

That doesn’t seem to work either.. is there a simplier example??? I have to modify it to get it to work with borland c++ so I can build quick programs with the forms. It would even be better as components were I could drag and drop them. <br><br>
Shut down
*/
//// result = FMOD_DSP_Release(dsp);
// ERRCHECK(result);
// result = FMOD_System_Close(system);
// ERRCHECK(result);
// result = FMOD_System_Release(system);
// ERRCHECK(result);

return 0;

also in

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

I am not sure I am using the right versions because the exit(-1) doesn’t complile. should I be using fmod instead of fmodex??

  • You must to post comments
0
0

have you looked at the examples directory where there are about 33 examples? This stuff is already done, just look at playsound or playstream it couldnt be simpler.

  • You must to post comments
0
0

This is an attempt to modify the generate tone example that came with fmodex for use with borland c++ builder 4.0 . It makes simple graphic programming simple because The buttons are dragged onto the form and then when you press the button you are supposed to get the sound. The only part I am trying to get to work is just the sin wave.. If the library won’t work like that I would also be satisfied that it would start playing when the form is created. One of the lines that erred out was an entire subroutine taken from the example. I noticed on some of the old articles on fmod that there was different .dll’s for different compilers so I am hopeing that is not the problem. THe compiled version of generate tone that came with fmodex works fine so there must be a way to do it.

http://www.dexrow.com

  • You must to post comments
Showing 7 results
Your Answer

Please first to submit.