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
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