Making and playing MIDI?

Visuals, audio, animation. Blended, not stirred. If LiveCode is part of your rich media production toolbox, this is the forum for you.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
thatkeith
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 346
Joined: Mon Mar 01, 2010 7:13 pm
Location: London, UK
Contact:

Making and playing MIDI?

Post by thatkeith » Sun Oct 31, 2021 6:06 pm

Years ago I made an experimental SuperCard stack that played the midi note equivalents of words where the letters were from A to G, using the no-longer available midi support in QuickTime. Yes, it was somewhat bizarre, but it was a fun exercise – and thanks to that old QuickTime MIDI support it was pretty easy. :-/

Now I'm trying out an experiment which maps notes in a chord to RGB colours and builds up a soft wash-style overlay of colours, like multiple coloured spotlights shining on a wall, that are derived from the chord. Yeah, another oddball thing! (Don't worry, the notes are set manually by clicking different objects, not by attempting to have the stack listen to the notes themselves being played; I may be crazy but I'm not actually insane.) One end goal is to use these as colourising overlays in a music video, so there is a point to this – although yes, it's still odd. 8)

What I really want to do is be able to play a simulation of whatever chord is being picked out, and I presume midi would be the best way to do that. I've looked at PaulDaMacMan's rather excellent LCB midi tools and got the sample .mid files to play in the demo stack. But what I'd really like to do is play specific notes on the fly, based on what's clicked.

I'd like to have one note play for the first click, then another note play as well with the second click, and so on, building up the chord. I've looked at the midi file format and all I've achieved is to wear a bald spot on my head from all the puzzled scratching!

Is there any resource anyone knows of that helps explain in simple terms how to write a midi file? Am I just going to make my head explode doing it like this? :lol:

Keith
Technical Writer, Meta
University Lecturer
Technical Editor, MacUser (1996-2015)
360 VR media specialist

richmond62
Livecode Opensource Backer
Livecode Opensource Backer
Posts: 9287
Joined: Fri Feb 19, 2010 10:17 am
Location: Bulgaria

Re: Making and playing MIDI?

Post by richmond62 » Sun Oct 31, 2021 6:39 pm


bn
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 3991
Joined: Sun Jan 07, 2007 9:12 pm
Location: Bochum, Germany

Re: Making and playing MIDI?

Post by bn » Sun Oct 31, 2021 7:16 pm

Hi Keith,

Paul also made a keyboard where you can actually play. It is also in his GitHub repository.
You can also send notes to the keyboard.
Maybe Paul will chime in or you could send him a private message.

Kind regards
Bernd

PaulDaMacMan
Posts: 617
Joined: Wed Apr 24, 2013 4:53 pm
Contact:

Re: Making and playing MIDI?

Post by PaulDaMacMan » Thu Nov 02, 2023 1:12 am

thatkeith wrote:
Sun Oct 31, 2021 6:06 pm
What I really want to do is be able to play a simulation of whatever chord is being picked out, and I presume midi would be the best way to do that. I've looked at PaulDaMacMan's rather excellent LCB midi tools and got the sample .mid files to play in the demo stack. But what I'd really like to do is play specific notes on the fly, based on what's clicked.
Sorry I missed this (two years ago).

Kieth, if you're still around, there's a few of different way to go about doing this:
Use the excellent public-domain library MakeSMF / PlayPMD from UDI, which was written originally for SuperCard, MetaCard, HyperCard. It can generate a standard MIDI file from an extended form of a 'playSentence' (HyperTalk 'abc' music notation) string.
You can then pass that file to whatever MIDI player you'd like. PlayPMD was originally setup to use QuickTime's 'Music Instruments' playback, but you can use one of the MIDI extension modules in my repo or other methods:

1. The FluidSynth wrapper library, can play MIDI files or real-time note messages that you pass directly to it. This is the only cross platform solution I've worked on.
2. Apple's AVMIDIPlayer (available for Mac or iOS) which uses a Software Synth much like QuickTime's built in player and by default will use the same (1990s, low quality) Roland SoundCanvas sample bank that was included with QT v2.5 which is now buried Innside CoreAudio.framework. You can pass the path of your own sound font file to use instead. This one only plays MIDI files, no real-time messages (although in most cases MakeSMF is fast enough to generate MIDI files at near-realtime speed). This is the most simple of these Extensions.
3. Apple's AVAUSamplerInstrument wrapper lib (available for Mac or iOS) which uses a Soft Synth similar to AVMIDPlayer above, but can NOT play MIDI files, it can only respond to realtime messages.
4. On macOS you could also use my CoreMIDI wrapper library to send MIDI out from your stack scripts to your DAW (GarageBand, Ableton Live, etc.) to do the Playback/Recording.
5. On macOS you could also use my AVMIDIInstrument wrapper, this only responds to realtime messages, but can use most AudioUnit Plugins for playback (like Analog Synth emulations instead of using sampler instruments).
6. On Windows you can use MCI (Media Control Interface) to playback MIDI with Windows built in player. Which by default uses a simple Roland sound bank very similar to Apple's.
7. On Android I've used the mobile player to play MIDI files IF your Android device included MIDI/soundbank (most do, even my Sony Android TV does).
8. On desktop platforms you could also pass the MIDI file to a command-line app for playback, something like WildMIDI for example.
My GitHub Repos: https://github.com/PaulMcClernan/
Related YouTube Videos: PlayList

Post Reply

Return to “Multimedia”