0
0

Hi everyone.
I wrote this code but when I try to compile it, it says “invalid conversion from void*(*)(void*, void*, int, void*)' to void()(void*, void*, int, void*)'” and I can’t figure out how to fix it.

I’m using dev-c++ with mingw32 and the latest fmod api under windows xp.

include <stdio.h>

include <stdlib.h>

if defined(WIN32) || defined(WATCOMC) || defined(_WIN32) || defined(WIN32)

include <conio.h>

include <windows.h>

define __PACKED

else

include “fmod/wincompat.h”

include <string.h>

define PACKED __attribute((packed))

endif

include “fmod/fmod.h”

include “fmod/fmod_errors.h”

define RECORDRATE 44100

define RECORDLEN (RECORDRATE * 5)

define OUTPUTRATE 44100

void *my_dsp_callback(void *originalbuffer, void *newbuffer, int length, void *userdata)
{
return newbuffer;
}

int main(int argc, char *argv[])
{
FSOUND_SAMPLE *samp1;
FSOUND_DSPUNIT *unit;
int handle;
signed char key;
int driver, i, channel, originalfreq;

if (!FSOUND_Init(OUTPUTRATE, 64, FSOUND_INIT_ACCURATEVULEVELS))
{
printf(“Error!\n”);
printf(“%s\n”, FMOD_ErrorString(FSOUND_GetError()));
return 0;
}

samp1 = FSOUND_Sample_Alloc(FSOUND_UNMANAGED, RECORDLEN, FSOUND_STEREO | FSOUND_16BITS | FSOUND_LOOP_NORMAL , RECORDRATE, 255, 128, 255);

FSOUND_Record_StartSample(samp1, TRUE);

define RECORD_DELAY_MS 8

define RECORD_DELAY_SAMPLES (RECORDRATE * RECORD_DELAY_MS / 1000)

unit=FSOUND_DSP_Create(my_dsp_callback,999,0);//The error should be here
FSOUND_DSP_SetActive(unit, TRUE);

channel = FSOUND_PlaySound(FSOUND_FREE, samp1);

originalfreq = FSOUND_GetFrequency(channel);

do
{
int playpos, recordpos, diff;
static int oldrecordpos = 0, oldplaypos = 0;

playpos = FSOUND_GetCurrentPosition(channel);
recordpos = FSOUND_Record_GetPosition();

if (playpos > oldplaypos && recordpos > oldrecordpos)
{
diff = playpos – recordpos;

if (diff > -RECORD_DELAY_SAMPLES)
{
FSOUND_SetFrequency(channel, originalfreq – 1000);
}
else if (diff < -(RECORD_DELAY_SAMPLES * 2))
{
FSOUND_SetFrequency(channel, originalfreq + 1000);
}
else
{
FSOUND_SetFrequency(channel, originalfreq);
}
}

oldplaypos = playpos;
oldrecordpos = recordpos;

Sleep(10);
} while (!kbhit());

getch();

FSOUND_StopSound(channel);
FSOUND_Record_Stop();
FSOUND_Sample_Free(samp1);
FSOUND_Close();
return 0;
}

Thanks

Paolo Brasolin

  • You must to post comments
0
0

[code:brwyjjgo]
void* F_CALLBACKAPI my_dsp_callback(void *originalbuffer, void *newbuffer, int length, void *userdata)
{
return newbuffer;
}
[/code:brwyjjgo]

  • You must to post comments
0
0

It continues to give me the same error…

This is the compile log:

Compilatore: Default compiler
Building Makefile: “D:\Dev-Cpp\Jack\Makefile.win”
Esecuzione di make…
make.exe -f “D:\Dev-Cpp\Jack\Makefile.win” all
g++.exe -c test.cpp -o test.o -I”D:/Dev-Cpp/include/c++” -I”D:/Dev-Cpp/include/c++/mingw32″ -I”D:/Dev-Cpp/include/c++/backward” -I”D:/Dev-Cpp/include”

test.cpp: In function `int main(int, char**)’:

test.cpp:48: invalid conversion from void*(*)(void*, void*, int, void*)' to

void()(void*, void*, int, void*)’

make.exe: *** [test.o] Error 1

Esecuzione terminata

  • You must to post comments
0
0

I tried using _stdcall and __stdcall instead of F_CALLBACKAPI, but nothing seems to change.

I have the same problem with the example files (I used the same syntax as the one used in them): it’s strange…

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.