Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Fmod.dll + DarkGDK ?

Author
Message
Unkof
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: France
Posted: 12th Dec 2007 23:26
Hi guys,

I search an simple example for use fmod.dll in an DarkGDK project.

Someone test it ?

Specs: P4 1800 Mhz, 512 Mb, Gforce 4 - 64 Mb Ddr, W98
Sorry for my poor english
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 13th Dec 2007 00:18
It will work fine - the Shadow Of Th Beast (or Bouncing Lines demo) on my website (in the DBPro section) uses either FMOD or BASS.

Both work fine.

Visit my web site for real bangin' stuff at http://www.nicholaskingsley.co.uk
dbGamerX
16
Years of Service
User Offline
Joined: 23rd Nov 2007
Location:
Posted: 13th Dec 2007 00:20
I used to use FMOD with Ogre before I moved to Dark GDK... I'm not really sure how to implement it into Dark GDK, but I'll experiment tonight and let you know tomorrow

dbPrint ( "Sig" );
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 13th Dec 2007 11:03
Its quite simple - you have two ways :

A) Include the .lib file and copy the DLL to where the executable is
B) Use LoadLibrary to load the DLL and directly access the functions.

Visit my web site for real bangin' stuff at http://www.nicholaskingsley.co.uk
Unkof
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: France
Posted: 13th Dec 2007 13:53 Edited at: 13th Dec 2007 13:54
I know c language, but not Vc++ 2008.

How can include .lib file ? I add fmodapi375winapilib in the VC++ Directories for library files and fmodapi375winapiinc in the VC++ Dir for Include Files.

After, i wrote this code :



I have this error :

Quote: "1>Compiling...
1>Main.cpp
1>Linking...
1>Main.obj : error LNK2019: unresolved external symbol _FSOUND_Init@12 referenced in function "void __cdecl DarkGDK(void)" (?DarkGDK@@YAXXZ)
1>DebugTry Fmod Use.exe : fatal error LNK1120: 1 unresolved externals"


i forget something it's sure ... but what ?... someone help please ?

Specs: Core2Duo E7300, 2 Gb, Nvidia Gforce 8400 GS 256 Mo, Vista Premium
Sorry for my poor english
OSX Using Happy Dude
21
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 13th Dec 2007 15:17
FMOD comes in two styles - an interface for C and one for C++

Here is an example of how to call the routines using the C system (taken from my FightTune game) :

/*
* BASS.c
* BASS
*
* Created by Nicholas Kingsley on 20/07/2007.
* Copyright 2007 __MyCompanyName__. All rights reserved.
*
*/

//#define WIN32
#define MACOS
//#define LINUX

#include "stdio.h"
#include "stdlib.h"
#include "string.h"
#include "math.h"

#define FFT_SIZE 1024
#define LEFT_BIT 1
#define UP_BIT 2
#define RIGHT_BIT 4
#define DOWN_BIT 8

#ifdef WIN32
// Windows
#include "windows.h"
#include "C:\Program Files\FMOD SoundSystem\FMOD Programmers API Win32\api\inc\fmod.h"
#endif

#ifdef MACOS
// OSX Version
#include "/Developer/FMOD Programmers API/api/inc/fmod.h"
#endif

#ifdef LINUX
// Linx
#include "/home/nicholas/Desktop/fmodapi40623linux/api/inc/fmod.h"
#endif

FMOD_SYSTEM *FMODSystem=NULL;
FMOD_CREATESOUNDEXINFO extraInfo;

char diff[4];

//----------System
void FMOD_ClearDiff(void)
{
memset(&diff,(char) 0,sizeof(diff));
srand((unsigned)time(0));
}

char FMOD_Initialise(void)
{
FMOD_RESULT result;

result = FMOD_System_Create(&FMODSystem);
if (result==FMOD_OK)
{
result = FMOD_System_Init(FMODSystem,1024, FMOD_INIT_NORMAL, 0);
if (result==FMOD_OK)
{
}
}

return (result==FMOD_OK ? (char) 1 : (char) 0);
}

void FMOD_Close(void)
{
FMOD_System_Close(FMODSystem);
FMODSystem=NULL;
}

void FMOD_Release(void)
{
FMOD_System_Release(FMODSystem);
FMODSystem=NULL;
}

int FMOD_CreateStream(char *fileName,int mode)
{
FMOD_SOUND *FMODSound;

if (FMOD_System_CreateStream(FMODSystem,fileName,mode,NULL,&FMODSound)==FMOD_OK) // For some reason, getting the extra information generates a 37 error
{
return (int) FMODSound;
}

return 0;
}

int FMOD_PlaySound(int channelID,int handle,char paused)
{
FMOD_CHANNEL *FMODChannel;

if (FMOD_System_PlaySound(FMODSystem,channelID,(FMOD_SOUND *) handle,paused,&FMODChannel)==FMOD_OK)
{
return (int) FMODChannel;
}

return 0;
}

int FMOD_GetChannelPosition(int channel,int type)
{
unsigned int pos;

if (FMOD_Channel_GetPosition((FMOD_CHANNEL *) channel,&pos,type)==FMOD_OK)
{
return pos;
}

return 0;
}

char FMOD_ChannelSetPosition(int channel,int position,int type)
{
return FMOD_Channel_SetPosition((FMOD_CHANNEL *) channel,position,type);
}

char FMOD_ChannelIsPlaying(int channel)
{
int playing;

if (FMOD_Channel_IsPlaying(channel,&playing)==FMOD_OK)
{
return (playing ? 1 : 0);
}

return 0;
}

char FMOD_SetVolume(int channel,int volume)
{
return FMOD_Channel_SetVolume(channel,(float) ((float) volume/(float) 100.0));
}

int FMOD_CreateSound(char *fileName,int mode)
{
FMOD_SOUND *sound;
int error;

error=FMOD_System_CreateSound(FMODSystem,fileName,mode,NULL,&sound);
if (error==FMOD_OK)
{
return (int) sound;
}

return 0;
}

char FMOD_Stop(int channel)
{
return FMOD_Channel_Stop(channel);
}

char FMOD_Pause(int channel,char paused)
{
return FMOD_Channel_SetPaused(channel,paused);
}

int FMOD_GetLength(int sound,int timeLength)
{
unsigned int length;

if (FMOD_Sound_GetLength((FMOD_SOUND *) sound,&length,timeLength)==FMOD_OK)
{
return (int) length;
}

return 0;
}

char FMOD_SetStreamBufferSize(int bufferSize,int sizeType)
{
return FMOD_System_SetStreamBufferSize(FMODSystem,bufferSize,sizeType);
}

char FMOD_Update()
{
return FMOD_System_Update(FMODSystem);
}

int FMOD_GetFrequency(int channel)
{
float freq;

if (FMOD_Channel_GetFrequency((FMOD_CHANNEL *) channel,&freq)!=FMOD_OK)
{
freq=(float) 0.0;
}

return (int) freq;
}

int FMOD_SetFrequency(int channel,int freq)
{
return FMOD_Channel_SetFrequency((FMOD_CHANNEL *) channel,(float) freq);
}

int FMOD_Spectrograph5(int channel,int difficultyLevel,char *storeSpec,int SPECHEIGHT,int BANDS,
int NIGHTMARE)
{
register int b0,x,sc,b1,loop;
register char y;
float fft[3][FFT_SIZE];
float sum;
int result;

result=0;
if (FMOD_Channel_GetSpectrum((FMOD_CHANNEL *) channel,&fft[0][0],FFT_SIZE,0,FMOD_DSP_FFT_WINDOW_TRIANGLE)==FMOD_OK &&
FMOD_Channel_GetSpectrum((FMOD_CHANNEL *) channel,&fft[1][0],FFT_SIZE,1,FMOD_DSP_FFT_WINDOW_TRIANGLE)==FMOD_OK)
{
for (x=0; x<FFT_SIZE; x++)
{
fft[2][x]=(fft[0][x]+fft[1][x])/2.0;
}

b0=0;
for (x=0;x<BANDS;x++)
{
sum=0.0;

b1=pow(2,x*10.0/(BANDS-1));
if (b1>=FFT_SIZE)
{
b1=FFT_SIZE-1;
}

if (b1<=b0)
{
b1=b0+1; // make sure it uses at least 1 FFT bin
}

sc=10+b1-b0;
for (;b0<b1;b0++)
{
sum+=fft[2][1+b0];
}

y=(char) ((sqrt(sum/log10(sc))*1.7*SPECHEIGHT)-4.0); // scale it
y=(y>SPECHEIGHT ? SPECHEIGHT : \
y<0 ? 0 : y);

*(storeSpec+x)=(char) y;

if (diff[x]!=y)
{
diff[x]=y;
result=(x==0 ? result | LEFT_BIT : \
x==1 ? result | UP_BIT : \
x==2 ? result | RIGHT_BIT : result | DOWN_BIT);
}
}

if (difficultyLevel!=NIGHTMARE)
{
int tempResult;

tempResult=0;
if (result & (LEFT_BIT | RIGHT_BIT))
{
if ((rand() % 15)<=7)
{
tempResult|=LEFT_BIT;
}
else
{
tempResult|=RIGHT_BIT;
}
}

if (result & (UP_BIT | DOWN_BIT))
{
if ((rand() % 15)<=7)
{
tempResult|=UP_BIT;
}
else
{
tempResult|=DOWN_BIT;
}
}

result=tempResult;
}

}

return result;
}


void FMOD_Spectrograph1(int channel,int SPECWIDTH,int SPECHEIGHT,char *specBuff)
{
register int c,x,v,y,loop;
int channels;
float *buf;
float fft[FFT_SIZE];

if (specBuff==NULL) return;

memset(specBuff,(char) 0,SPECWIDTH*SPECHEIGHT);
if (FMOD_System_GetSoftwareFormat(FMODSystem,NULL,NULL,&channels,NULL,NULL,NULL)==FMOD_OK)
{
for (loop=0; loop<2; loop++)
{
if (FMOD_System_GetWaveData(FMODSystem,&fft,FFT_SIZE,loop)==FMOD_OK)
{
for (x=0; x<SPECWIDTH; x++)
{
v=(1-fft[x])*SPECHEIGHT/2;

if (v<0)
{
v=0;
}
else
if (v>SPECHEIGHT)
{
v=SPECHEIGHT;
}

if (!x)
{
y=v;
}

do { // draw line from previous sample...
if (y<v)
{
y++;
}
else
if (y>v)
{
y--;
}

specBuff[y*SPECWIDTH+x]=(loop==0 ? 127 : 1);
} while (y!=v);
}
}
}
}
}

Visit my web site for real bangin' stuff at http://www.nicholaskingsley.co.uk
Unkof
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: France
Posted: 13th Dec 2007 23:50
Thx for this ...

Before, i would like to know why my source doesn't work ... i have a problem with the lib i think ...

Someone can help me for this ??

Osx:I'm sure your source help me after .. when i solve my lib problem.

Specs: Core2Duo E7300, 2 Gb, Nvidia Gforce 8400 GS 256 Mo, Vista Premium
Sorry for my poor english
Sephnroth
22
Years of Service
User Offline
Joined: 10th Oct 2002
Location: United Kingdom
Posted: 14th Dec 2007 00:35
fmod works fine with dgdk, just as it does with anything else. its a seperate system and doesnt need "implementing with" gdk or anything, just use it as you would in any other app.

download FMOD Ex as usual. Install it. Open vc2008. open your project. goto the Tools menu then click Options. On the expandable list on the left of the options expand Projects and Solutions and then select VC++ Directories.

On the drop down box under the text "Show directories for:" change it to show "Include files". Then add a new folder by pressing the icon with a picture of a yellow folder. Click the "..." button on the right of the new entry that has appeared in the list and browse to where the fmod header is. If you have installed to the default path that is:

C:\Program Files\FMOD SoundSystem\FMOD Programmers API Win32\api\inc

Then, again on the drop down box that is under "Show directories for:" change it now to "Library files". Add a new entry as before and set it to the library directory. If you installed in the default place then that will be:

C:\Program Files\FMOD SoundSystem\FMOD Programmers API Win32\api\lib

Now press ok to set these options. Now open up your PROJECT options by right clicking on the name of your project in the solution explorer and then clicking Properties. Expand the Linker options and then click on "Input". In the box to the right of "Additional Dependencies" add "fmodex_vc.lib" WITHOUT the quotes.

Finally, browse to the Api folder of the fmod install using windows explorer which by default if you installed to the default place will be:

C:\Program Files\FMOD SoundSystem\FMOD Programmers API Win32\api

and copy fmodex.dll into the folder on your hard drive that contains your project source files and hopefully you should now be able to use the fmod api fully and without error!

See the fmod documentations for getting started tutorials on actually coding with fmod

Hope that helps.

Unkof
22
Years of Service
User Offline
Joined: 4th Sep 2002
Location: France
Posted: 14th Dec 2007 13:06 Edited at: 14th Dec 2007 13:07
Works fine now !... thx a lot ...

I can play with fmod .. ^^ ... i'm going to make an old school demo with this ... ^^

Thx for your good explain Sephnroth ...

Specs: Core2Duo E7300, 2 Gb, Nvidia Gforce 8400 GS 256 Mo, Vista Premium
Sorry for my poor english

Login to post a reply

Server time is: 2024-11-17 00:16:07
Your offset time is: 2024-11-17 00:16:07