mIRC Homepage
Posted By: Riamus2 Playing music notes "on the fly" - 02/02/11 01:03 PM
I've been in the process of creating a full ANSI telnet script and I have it completed for most features. I started looking at a variety of possible features to add support for and came across ANSI music. Now, this would be very easy for me to handle.... if I can find a way to play a music note from mIRC. Any ideas?

I considered the possibility of generating a temporary MIDI file and playing that, but the problem there is that there will always be a delay before it starts playing and between any subsequent "lines" of music. That may not be a big problem, but I'd rather find a way to send the notes directly to the sound card. I am open to a DLL option, but would rather use just a scripted method or COM method.

I have a feeling this won't work well enough to bother with, but maybe there is something I can't think of.

Any suggestions would be helpful.
Posted By: DJ_Sol Re: Playing music notes "on the fly" - 04/02/11 05:13 AM
Well there are 12 notes in a western scale. That is one octave, you may want to have more than one. Anyways, why not have a file for each note? Yeah you probably would have difficulty playing specific quarter notes, eighth notes, dotted quarter, etc. But hey, it's a start.

If you think about, every instrument has each note standing by as well.
Posted By: Riamus2 Re: Playing music notes "on the fly" - 04/02/11 12:23 PM
That did cross my mind, but I rejected it. With ANSI music, instruments aren't the problem because it doesn't use multiple instruments. But handling different note lengths as well as tempos would be pretty much impossible unless I wanted hundreds of files.

If I decide to go forward with this, I'll probably have to do it via DLL. That or at least try doing it by generating a midi file as the notes arrive. I doubt that will work well, but I might consider trying it.
Posted By: hixxy Re: Playing music notes "on the fly" - 04/02/11 12:33 PM
With a little bit of $com() magic you can control windows media player from mIRC, so you could use windows media player to play files at different speeds, etc.

I've used the wmp object model extensively so let me know if you want help with this. I'm not a musician and don't fully understand what you're trying to do so I'd have to let you organise the sound files yourself, but I can tell you how to do stuff using wmp smile
Posted By: Riamus2 Re: Playing music notes "on the fly" - 04/02/11 03:48 PM
Would that be any different from just playing a MIDI that has the speed entered already? Or are you referring to having each note as an individual file and playing those files at different speeds?

Basically, what I'm considering doing is adding support for ANSI music. That music is sent as notes, octaves, and durations as well as possibly tempo. It might be something as simple as CDEFGAB (a scale). Or it may contain other information. I can manipulate that to whatever I need it to be. For example, if I need to provide the note's frequency instead of a letter note, I can do so. I receive the notes and additional music information through a socket in ASCII format. Then, I need to find a way to play those notes. For example, if this were BASIC, I'd just use PLAY CDEFGAB. mIRC doesn't offer that option, but I know it's possible to send notes to the default MIDI output (typically your soundcard) using C, VB, Java, etc. There is even a form of SendMessage API for MIDI, but I am not entirely sure how to access that from mIRC.

COM would be ideal because it won't require additional files to make it work. I just can't find a way to send notes to the sound card using it. If you know a way, I'd definitely be interested.

Additionally, the notes are sent one at a time, but in a "line" just like a sentence would be sent. I have the option of waiting for the end of the line before playing anything. That could allow for smoother playback, but it also means a slight delay before starting (waiting for the entire line to arrive). And, in some cases, telnet "lines" are very long because the use the client's ability to wrap long lines instead of providing line breaks. The other option is to play each note as it arrives. This provides the least delay, but may cause a stutter effect between notes. That is especially true if I have to generate a MIDI file and the /splay it. Even just changing a single character in the MIDI file when each note is received would cause enough delay between notes (I assume) to be noticeable.

If I can send notes directly to the sound card, then note by note is the best option. If I have to generate some kind of file, then line by line is the best option. I can test each method, of course.
Posted By: DJ_Sol Re: Playing music notes "on the fly" - 04/02/11 04:20 PM
Sounds to me like you need to access a midi type program that will play the notes for you.
Posted By: hixxy Re: Playing music notes "on the fly" - 04/02/11 04:53 PM
I meant having a file for each note and playing them at different speeds, but I've tried it out and it seems impossible to get gapless playback with wmp, so you'd be better off using a dll I think.
Posted By: RusselB Re: Playing music notes "on the fly" - 05/02/11 12:07 AM
To the best of my knowledge, seamless playback between multiple files using WMP (and most other media players that I've tried) is impossible due to the fact that the player loads the first file, plays it, unloads it, then loads the second file.
Thus you have a gap during the unloading and loading times for each file.
Posted By: Riamus2 Re: Playing music notes "on the fly" - 06/02/11 08:28 PM
Yeah, I was kind of expecting that. Thanks for trying, though. I'll have to decide if I care enough about adding it to use a DLL or not. I appreciate the ideas.
Posted By: FroggieDaFrog Re: Playing music notes "on the fly" - 07/02/11 03:52 AM
Not sure if will help, but u could PROBABLY use winmm.dll
This might be of some help smile
Posted By: Riamus2 Re: Playing music notes "on the fly" - 07/02/11 11:08 AM
Thanks. Yeah, the midi short message API was what I was mentioning before. I'll see if it's possible using that DLL rather than making my own.
Posted By: hixxy Re: Playing music notes "on the fly" - 07/02/11 06:14 PM
You'll still need to write a small dll to use that dll, as you cannot call dlls from mIRC unless they're written specifically with mIRC in mind.
Posted By: Riamus2 Re: Playing music notes "on the fly" - 07/02/11 09:23 PM
Ok, thanks.
© mIRC Discussion Forums