PDA

View Full Version : Playing MIDI files


madanr
08-01-2002, 07:11 PM
Hello there, I'm having some problems playing a MIDI file on a Sharp800. My code successfully compiles and there aren't any problems transferring it to the phone. When I run it, however, nothing happens (a snippet of the code is below -- for this first test, all I want to do is successfully hear the MIDI file on the phone). What's really weird is the phone begins playing the MIDI file after I *exit* the application! Any ideas and help would be greatly appreciated.

Here's the code:

// here's a function I use to stop the music (API docs said to
// make sure I called ISOUNDPLAYER_Stop() before exitting
static void stopMusic(TestApp *pMe) {
ISOUNDPLAYER_Stop(pMe->m_pISoundPlayer);
}

// This is all in my handleevent function; obvious stuff has been omitted
// for the sake of clarity

IFile* musicFile;
byte* musicFileData;
FileInfo musicFileInfo;

case EVT_APP_START:
...
ISOUNDPLAYER_RegisterNotify(pMe->m_pISoundPlayer, NULL, NULL);

musicFile = IFILEMGR_OpenFile(pMe->m_pIFileMgr, "omriver.mid", _OFM_READ);
IFILE_GetInfo(musicFile, &musicFileInfo);
musicFileData = (byte*) MALLOC(musicFileInfo.dwSize * sizeof(byte));
IFILE_Read(musicFile, musicFileData, musicFileInfo.dwSize);

ISOUNDPLAYER_Set(pMe->m_pISoundPlayer, SDT_BUFFER, musicFileData);
ISOUNDPLAYER_Play(pMe->m_pISoundPlayer);

ISHELL_SetTimer(pMe->a.m_pIShell, 25000, (PFNNOTIFY) stopMusic, pMe);
...
case EVT_APP_STOP:
...
ISOUNDPLAYER_Release(pMe->m_pISoundPlayer);
IFILEMGR_Release(pMe->m_pIFileMgr);
...

One other thing; I do have the BREW 2.0 emulator, and I did successfully get the MIDI file to play there using ISOUNDPLAYER_SetInfo(). However, my phone isn't 2.0 ready. I don't think it's a memory problem, because the program does exit gracefully, although you never can tell with memory problems. Again, I'd greatly appreciated any insights into my problem!

Thanks,
Madan Ramakrishnan

arunbangari
08-09-2002, 08:40 AM
Hi,
Why dont you use IRINGERMGR_PlayFile, instead of reading the file using IFILEMGR interface? This may not be relevant to the problem you mentioned, but its easier if you use the above said API.

Regards
Arun Bangari

mardij
08-15-2002, 01:25 PM
Hi,

This won't help with your code but... We were struggling with getting our player code up and needed to test song files (.mid & .pmd) on the phone so, we loaded the midi player example app on the phone. The other thing you might want to check is that you are using the 1.0 SDK (unless you've had your phone flashed) and have downloaded the latest 1.0 SDK version - a couple of weeks ago a new 1.0 SDK was posted.

Good luck,
m

zetryu
08-20-2002, 05:49 PM
Did you add following code ?

ISOUNDPLAYER_SetVolume( pMe->SoundPlayer, AEE_MAX_VOLUME );


Your code is almost same that of mine but above code.

Good luck.

:)