Playing Midi from TDesC8...

Login to reply to this topic.
Mon, 2004-01-12 16:46
Joined: 2004-01-12
Forum posts: 3
Hi all gurus.

I am successfully using CMdaAudioPlayerUtility and its NewFilePlayerL method, to play a Midi file.
I tried to play that Midi file directly from the buffer containing the data (using NewDesPlayerL or NewDesPlayerReadOnlyL), but it does not work... The MapcInitComplete completion routine is never called, either with error or not. Series60 or UIQ.

My first (and only) thought is that CMdaAudioPlayerUtility is not able to recognize that the data are Midi (even if it's not so complicated), and that it's only because a file is named with the ".mid" extension that it assumes that the data are Midi - but is there a way to make it recognize the data given in a buffer as Midi ones? Or at least to call the callback with an error?

The reason why I want to do that is that the user will be offered to download a Midi file and play it - and then purchase it (or not). But if the file lies on the disk, it's too easy to duplicate it! Or is there a way to "hide" a file on the disk?

Thanks for your attention,
Daniel.

Tue, 2004-01-13 00:19
NewLC AdministratorSymbian AccreditedForum Nokia Champion
Joined: 2003-01-14
Forum posts: 2006
Playing Midi from TDesC8...
Salut Daniel,

I think - but I am not 100% sure - that there is a bug in the Media Server which prevent to play Midi data from a descriptor and that you will need to play it from a file.

Cheers,
Eric

Eric Bustarret
NewLC Founder & CEO / Professional Symbian OS Consultant

Tue, 2004-01-13 09:58
Joined: 2004-01-12
Forum posts: 3
Playing Midi from TDesC8...
Quote from: eric
Salut Daniel,

I think - but I am not 100% sure - that there is a bug in the Media Server which prevent to play Midi data from a descriptor and that you will need to play it from a file.

Cheers,
Eric
Merci...

I was afraid of hearing such answer. I'll deal with it, then!

Regards,
Daniel.
Tue, 2004-01-13 17:03
Joined: 2004-01-13
Forum posts: 1
Playing Midi from TDesC8...
The bug is with playing MIDI data only?
I can't make NewDesPlayerL play WAV data too.

Thanks
Nikos.
Mon, 2004-10-04 12:32
Joined: 2004-09-08
Forum posts: 63
Playing Midi from TDesC8...
Anyone solved that?
Tue, 2004-10-19 13:17
Joined: 2004-09-08
Forum posts: 63
Playing Midi from TDesC8...
Anyone trying to play ota-sounds with series 60 v2.0 phones? I try, but it doesnt work. Same code works fine with v1.0.

I also try play midi with v2.0 and it works fine, but with v1.0 doesnt work.

Are there any solution to convert midi or ota to other type and play it then? I don't want save sound to file and play it then. Can someone give me example code how to do it.
Tue, 2004-11-16 17:47
Joined: 2004-11-09
Forum posts: 23
Playing Midi from TDesC8...
HELP!!! I ran into the same problem playing a wav file on the emulator. I am using symbian 1.2 and here is the strange thing: The same code runs fine and calls the callback properly on my Laptop, but on my desktop, when I compile and run the same example, the callback never gets called!!
Any ideas?
Thanks, Alex
Thu, 2005-01-20 14:12
Joined: 2005-01-20
Forum posts: 2
Playing MIDI descriptors
Hi,

just joined up. Smiley

I've got a problem playing a MIDI TDesC8 too. When I call:

iMidiPlayer=CMidiClientUtility::NewL(*this)

it leaves with a KErrNotSupported error.

After reading this thread, I thought it might be possible to pass it to save it into a file using:

_LIT(KSoundStorageFile, "C:\\System\\Apps\\MyApp\\temp.mid");
TFileName fileName(KSoundStorageFile);

RFs& fs=CEikonEnv::Static()->FsSession();
RFile file;
TInt err = file.Replace(fs,fileName,EFileWrite);
if (err==KErrNone)
   {
   file.Close();
   RFileWriteStream writer;
   err = writer.Replace(fs,fileName,EFileWrite);
   if (err==KErrNone)
      {
      writer<<soundBuf;
      writer.PushL();
      writer.CommitL();
      writer.Close();
      CleanupStack::Pop();   // writer
      }
   }

and then call:

CMdaAudioPlayerUtility::NewFilePlayerL(filename, *this);

but again I get the KErrNotSupported error in the callback:

MapcInitComplete(TInt aError, const TTimeIntervalMicroSeconds& aIntv)

Comparing the contents of a WAV file (which does work) with CMdaAudioPlayerUtility and the MIDI file (which doesn't), I see that the WAV file header info is:

"RIFFÐEWAVEfmt..."

whereas the MIDI file header is much longer:

"<MThd`MTrkuÿXÿQ©€Ã¿The Music in the Numbersÿ-Created with MusiNum 2.08 (C) Lars Kindermannÿ..."

This leads me to believe that only WAV files and not MIDI files cannot be passed into CMdaAudioPlayerUtility::NewFilePlayerL. Can anyone confirm this or tell me what I'm doing wrong?

Cheers
Rob Smiley
Fri, 2005-01-21 07:01
Joined: 2004-11-09
Forum posts: 23
Playing Midi from TDesC8...
I never got MID files to work properly on the PC emulator. On the target they seem to play fine though. I always add something like this:
#if WINS
// Play dummy wav file
#else
// Play real mid file
#endif

to my game code. Seems to work well.
Hope this helps.
Alex
Fri, 2005-01-21 07:46
Joined: 2005-01-20
Forum posts: 2
Playing Midi from TDesC8...
Thanks Alex - I suspected as much. Will build for target and try it.

Cheers
Rob Smiley
  • Login to reply to this topic.