Skip to content

Commit

Permalink
FMOD: Setting up the Music and CD interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Dec 1, 2011
1 parent 9f645ba commit 2e61263
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 20 deletions.
2 changes: 1 addition & 1 deletion doomsday/engine/api/sys_audiod_mus.h
Expand Up @@ -50,7 +50,7 @@ typedef struct audiointerface_music_generic_s {
// Driver interface for playing music.
typedef struct audiointerface_music_s {
audiointerface_music_generic_t gen;
void* (*SongBuffer) (size_t length);
void* (*SongBuffer) (unsigned int length);
int (*Play) (int looped);
int (*PlayFile) (const char *filename, int looped);
} audiointerface_music_t;
Expand Down
13 changes: 12 additions & 1 deletion doomsday/plugins/fmod/include/fmod_cd.h
Expand Up @@ -24,10 +24,21 @@
#ifndef __FMOD_CD_H__
#define __FMOD_CD_H__

#include "sys_audiod_mus.h"

#ifdef __cplusplus
extern "C" {
#endif


int DM_CDAudio_Init(void);
void DM_CDAudio_Shutdown(void);
void DM_CDAudio_Update(void);
void DM_CDAudio_Set(int prop, float value);
int DM_CDAudio_Get(int prop, void* value);
int DM_CDAudio_Play(int track, int looped);
void DM_CDAudio_Pause(int pause);
void DM_CDAudio_Stop(void);

#ifdef __cplusplus
}
#endif
Expand Down
10 changes: 10 additions & 0 deletions doomsday/plugins/fmod/include/fmod_music.h
Expand Up @@ -24,12 +24,22 @@
#ifndef __DSFMOD_MUS_H__
#define __DSFMOD_MUS_H__

#include "sys_audiod_mus.h"

#ifdef __cplusplus
extern "C" {
#endif

int DM_Music_Init(void);
void DM_Music_Shutdown(void);
void DM_Music_Set(int prop, float value);
int DM_Music_Get(int prop, void* ptr);
void DM_Music_Update(void);
void* DM_Music_SongBuffer(unsigned int length); // buffered play supported
void DM_Music_Stop(void);
int DM_Music_Play(int looped);
void DM_Music_Pause(int setPause);
int DM_Music_PlayFile(const char *filename, int looped);

#ifdef __cplusplus
}
Expand Down
46 changes: 40 additions & 6 deletions doomsday/plugins/fmod/src/fmod_cd.cpp
Expand Up @@ -23,10 +23,44 @@

#include "driver_fmod.h"

// DM_CDAudio_Init
// DM_CDAudio_Update
// DM_CDAudio_Set
// DM_CDAudio_Get
// DM_CDAudio_Pause
// DM_CDAudio_Stop
// DM_CDAudio_Play

int DM_CDAudio_Init(void)
{
return fmodSystem != 0;
}

void DM_CDAudio_Shutdown(void)
{

}

void DM_CDAudio_Update(void)
{

}

void DM_CDAudio_Set(int prop, float value)
{

}

int DM_CDAudio_Get(int prop, void* value)
{

}

int DM_CDAudio_Play(int track, int looped)
{

}

void DM_CDAudio_Pause(int pause)
{

}

void DM_CDAudio_Stop(void)
{

}
23 changes: 13 additions & 10 deletions doomsday/plugins/fmod/src/fmod_music.cpp
Expand Up @@ -23,8 +23,6 @@

#include "driver_fmod.h"

// DM_Music_Play

int DM_Music_Init(void)
{
return fmodSystem != 0;
Expand All @@ -44,12 +42,14 @@ void DM_Music_Set(int prop, float value)
{
case MUSIP_VOLUME:
{
/*
int val = MINMAX_OF(0, (byte) (value * 255 + .5f), 255);
// Straighten the volume curve.
val <<= 8; // Make it a word.
val = (int) (255.9980469 * sqrt(value));
mixer4i(MIX_MIDI, MIX_SET, MIX_VOLUME, val);
*/
break;
}

Expand All @@ -65,14 +65,15 @@ int DM_Music_Get(int prop, void* ptr)
case MUSIP_ID:
if(ptr)
{
strcpy((char*) ptr, "Win/Mus");
strcpy((char*) ptr, "FMOD/Mus");
return true;
}
break;

case MUSIP_PLAYING:
/*
if(midiAvail && MIDIStreamer)
return (MIDIStreamer->IsPlaying()? true : false);
return (MIDIStreamer->IsPlaying()? true : false);*/
return false;

default:
Expand All @@ -91,35 +92,37 @@ void DM_Music_Stop(void)
{
if(midiAvail)
{
MIDIStreamer->Stop();
//MIDIStreamer->Stop();
}
}

int DM_Music_Play(int looped)
{
if(midiAvail)
{
MIDIStreamer->Play(looped);
return true;
}

return false;
}

void DM_Music_Pause(int setPause)
{
if(midiAvail)
{
MIDIStreamer->Pause(setPause);
}
}

void* DM_Music_SongBuffer(size_t length)
void* DM_Music_SongBuffer(unsigned int length)
{
if(midiAvail)
{
return MIDIStreamer->SongBuffer(length);
// return MIDIStreamer->SongBuffer(length);
}

return NULL;
}

int DM_Music_PlayFile(const char *filename, int looped)
{

}
2 changes: 1 addition & 1 deletion doomsday/plugins/winmm/include/dswinmm.h
Expand Up @@ -71,7 +71,7 @@ void DM_Music_Set(int prop, float value);
int DM_Music_Get(int prop, void* ptr);
void DM_Music_Pause(int pause);
void DM_Music_Stop(void);
void* DM_Music_SongBuffer(size_t length);
void* DM_Music_SongBuffer(unsigned int length);
int DM_Music_Play(int looped);

// CD Audio interface:
Expand Down
2 changes: 1 addition & 1 deletion doomsday/plugins/winmm/src/dswinmm.cpp
Expand Up @@ -429,7 +429,7 @@ void DM_Music_Pause(int setPause)
}
}

void* DM_Music_SongBuffer(size_t length)
void* DM_Music_SongBuffer(unsigned int length)
{
if(midiAvail)
{
Expand Down

0 comments on commit 2e61263

Please sign in to comment.