Where can I download an example for Fmod- MFC project?
When I compile my project - it's all OK, but then I take a message "Unhandled exception in 1.exe (FMOD.DLL): 0xC0000005: Access Violation.
Here is my small module
#include <stdio.h><br />
#include <stdlib.h><br />
#include "fmod.h"<br />
#include "fmod_errors.h" <br />
#define ENABLEREVERB TRUE<br />
#define RECORDRATE /*22050*/11025<br />
#define RECORDLEN (RECORDRATE *1 ) /* seconds at RECORDRATE khz */<br />
#define OUTPUTRATE /*22050*/11025<br />
#define REVERB_NUMTAPS 7<br />
typedef struct<br />
{<br />
FSOUND_DSPUNIT *Unit;<br />
char *historybuff; <br />
char *workarea; <br />
int delayms; <br />
int volume; <br />
int pan; <br />
int historyoffset; <br />
int historylen; <br />
} REVERBTAP;<br />
<br />
<br />
<br />
REVERBTAP DSP_ReverbTap[REVERB_NUMTAPS];<br />
<br />
<br />
int umain()<br />
{signed char key;<br />
<br />
FILE *fp;<br />
<br />
<br />
<br />
char *tptr;<br />
char *the_my_transfer;<br />
FSOUND_SAMPLE *samp1;<br />
signed char key0;<br />
int driver, i, channel, originalfreq;<br />
int bits = 8;<br />
int channels = 1;<br />
int lenbytes = FSOUND_Sample_GetLength(samp1) * channels * bits / 8;<br />
int lenytes = FSOUND_Sample_GetLength(samp1) * 1 * bits / 8;<br />
void *ptr1, *ptr2;<br />
unsigned int len1, len2;<br />
<br />
<br />
<br />
<br />
if (FSOUND_GetVersion() < FMOD_VERSION){printf("Error : You are using the wrong DLL version! You should be using FMOD %.02f\n", FMOD_VERSION);return 0;}<br />
FSOUND_SetOutput(FSOUND_OUTPUT_DSOUND);<br />
printf("Direct Sound");<br />
printf(" Driver list\n"); <br />
printf("---------------------------------------------------------\n"); <br />
<br />
for (i=0; i < FSOUND_GetNumDrivers(); i++) <br />
{printf("%d - %s\n", i+1, FSOUND_GetDriverName(i));}<br />
<br />
printf("---------------------------------------------------------\n"); <br />
printf("Press a corresponding number or ESC to quit\n");<br />
<br />
do<br />
{
if (key == 27) {FSOUND_Close();return 0;}<br />
driver = key - '1';}<br />
while (driver < 0 || driver >= FSOUND_GetNumDrivers());<br />
<br />
FSOUND_SetDriver(driver); <br />
FSOUND_SetMixer(FSOUND_MIXER_QUALITY_AUTODETECT);<br />
if (!FSOUND_Init(OUTPUTRATE, 64, FSOUND_INIT_ACCURATEVULEVELS))<br />
{printf("Error!\n");printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));return 0;}<br />
<br />
printf(" Recording device driver list\n"); <br />
printf("---------------------------------------------------------\n"); <br />
for (i=0; i < FSOUND_Record_GetNumDrivers(); i++) <br />
{printf("%d - %s\n", i+1, FSOUND_Record_GetDriverName(i)); }<br />
printf("---------------------------------------------------------\n"); <br />
printf("Press a corresponding number or ESC to quit\n");<br />
<br />
do<br />
{
if (key == 27) return 0;<br />
driver = key - '1';} <br />
while (driver < 0 || driver >= FSOUND_Record_GetNumDrivers());<br />
<br />
<br />
<br />
<br />
printf("SERVER OR CILENT?\n");
<br />
if (FSOUND_GetOutput() == FSOUND_OUTPUT_OSS)<br />
{samp1 = FSOUND_Sample_Alloc(FSOUND_UNMANAGED, RECORDLEN, FSOUND_IMAADPCM|FSOUND_MONO | FSOUND_8BITS | FSOUND_UNSIGNED, RECORDRATE, 255, 128, 255);}<br />
else<br />
{samp1 = FSOUND_Sample_Alloc(FSOUND_UNMANAGED, RECORDLEN, FSOUND_IMAADPCM|FSOUND_STEREO | FSOUND_16BITS , RECORDRATE, 255, 128, 255);}<br />
printf("\n");<br />
<br />
if(key0=='1')<br />
{ <br />
printf("=========================================================================\n");<br />
printf("Press a key to start recording 10 seconds worth of data\n");<br />
printf("=========================================================================\n");<br />
if (!FSOUND_Record_StartSample(samp1, FALSE)) <br />
{<br />
printf("Error!\n");<br />
printf("%s\n", FMOD_ErrorString(FSOUND_GetError()));<br />
<br />
FSOUND_Close();<br />
return 0;<br />
}<br />
<br />
do<br />
{<br />
printf("Recording position = %d\r", FSOUND_Record_GetPosition());<br />
Sleep(50);<br />
} while (FSOUND_Record_GetPosition() < RECORDLEN );
<br />
FSOUND_Record_Stop(); <br />
<br />
printf("\n=========================================================================\n");<br />
printf("Press a key to play back recorded data\n");<br />
printf("=========================================================================\n");<br />
<br />
FSOUND_Sample_Lock(samp1, 0, lenbytes, &ptr1, &ptr2, &len1, &len2);<br />
<br />
fp = fopen("temp.wws", "wb");<br />
fwrite(ptr1, len1, 1, fp);<br />
the_my_transfer=new char[len1];<br />
for(int zz=0;zz<len1;zz++)<br />
{<br />
}<br />
delete[]the_my_transfer;<br />
fclose(fp);<br />
FSOUND_Sample_Unlock(samp1, ptr1, ptr2, len1, len2);<br />
<br />
}<br />
else<br />
{<br />
printf("CILENT!! Press a key to play back recorded data\n");<br />
<br />
FSOUND_Sample_Lock(samp1, 0, lenbytes, &ptr1, &ptr2, &len1, &len2);<br />
<br />
fp = fopen("temp.wws", "rb");fread(ptr1, len1, 1, fp);fclose(fp);<br />
<br />
FSOUND_Sample_Upload(samp1,ptr1,FSOUND_NORMAL);<br />
channel = FSOUND_PlaySound(FSOUND_FREE, samp1);printf("Playing back sound...\n");<br />
FSOUND_Sample_Unlock(samp1, ptr1, ptr2, len1, len2);<br />
channel = FSOUND_PlaySound(FSOUND_FREE, samp1);printf("Playing back sound...\n");<br />
<br />
<br />
}<br />
printf("END!!\n");<br />
if (FSOUND_GetOutput() == FSOUND_OUTPUT_OSS)<br />
{ FSOUND_Sample_Free(samp1); FSOUND_Close(); return 0; }<br />
<br />
<br />
FSOUND_StopSound(channel);<br />
FSOUND_Record_Stop();<br />
FSOUND_Sample_Free(samp1);<br />
FSOUND_Close();<br />
return 0;<br />
}<br />
|