//
// Midi BN 11-Juni-98
//
// -> winmm.lib
//
//
#include <stdlib.h>
#include <malloc.h>
#include <string.h>

#include "WinMain.h"
#include "GlobalData.h"
#include "Midi.h"


// *****************************************************************
Midi::Init (void)
{
int nRet=TRUE;


memset(&pMidi, 0, sizeof(Midi));
nAutoWert++; // dient als eindeutiger Schlüssel
return(nRet);
}

// *****************************************************************
Midi::DeInit (void)
{
int nRet=TRUE;


DoStopMidi("DoStopMidi");
return(nRet);
}

// *****************************************************************
Midi::DoPlayMidi (char *acBefehl_ID)
{
int nRet=FALSE;
char acText[512];
char acFilename[512];


if(mciSendString("close all", NULL, 0, NULL)!=0){
return(nRet);
}
GetName(acFilename);
sprintf(acText, "open %s type sequencer alias MUSIC", acFilename);
if(mciSendString(acText, NULL, 0, NULL)!=0){
return(nRet);
}
if(mciSendString("play MUSIC from 0", NULL, 0, g_hWnd)!=0){
return(nRet);
}
nRet = TRUE;
return(nRet);
}

// *****************************************************************
Midi::DoPauseMidi (char *acBefehl_ID)
{
int nRet=FALSE;


if(mciSendString("stop MUSIC", NULL, 0, NULL)!=0){
return(nRet);
}
nRet = TRUE;
return(nRet);
}

// *****************************************************************
Midi::DoResumeMidi (char *acBefehl_ID)
{
int nRet=FALSE;


if(mciSendString("play MUSIC notify", NULL, 0, g_hWnd)!=0){
return(nRet);
}
nRet = TRUE;
return(nRet);
}

// *****************************************************************
Midi::DoStopMidi (char *acBefehl_ID)
{
int nRet=FALSE;


if(mciSendString("close all", NULL, 0, NULL)!=0){
return(nRet);
}
nRet = TRUE;
return(nRet);
}

// *****************************************************************
Midi::DoReplayMidi (char *acBefehl_ID)
{
int nRet=FALSE;


if(mciSendString("play MUSIC from 0 notify", NULL, 0, g_hWnd)!=0){
return(nRet);
}
nRet = TRUE;
return(nRet);
}

// *****************************************************************
Midi::GetName (char *GetName)
{
int nRet=TRUE;


memcpy(GetName, pMidi.acName, sizeof(pMidi.acName));
return(nRet);
}

// *****************************************************************
Midi::GetIsPlayed (int *GetIsPlayed)
{
int nRet=TRUE;


*GetIsPlayed = pMidi.nIsPlayed;
return(nRet);
}

// *****************************************************************
Midi::SetName (char *SetName)
{
int nRet=TRUE;


memset(pMidi.acName, 0, sizeof(pMidi.acName));
memcpy(pMidi.acName, SetName, strlen(SetName));
return(nRet);
}

// *****************************************************************
Midi::SetIsPlayed (int *SetIsPlayed)
{
int nRet=TRUE;


pMidi.nIsPlayed = *SetIsPlayed;
return(nRet);
}