Video: skSynth playing MIDI files. Source code released.

I started making a synthesizer, which would take a single instrument sample, and change its pitch via the undocumented audio api. 

After I got that wired up, I found a MIDI.lua file that would take a .mid file and load it into a ‘score’ or ‘opus’ table.

Here, I just winged it. I started by looping through all the song’s track data , and started to build code to split channels into different instruments, etc. This is definitely not ‘by the book’ by any means, as I couldn’t find a book… (lots of good references in the main.lua though)

I went through many stages and phases where the sound was popping terribly, notes were being missed, tempo was completely off, etc.  

Video:

http://www.youtube.com/watch?v=wTu0HN7yby0&feature=youtube_gdata_player

Source Code: (try it yourself!  I’ve only tried it in the Mac Simulator, let me know how it works for you)

https://github.com/SK-Ray/skSynth

Neat!

Thanks! :slight_smile:

Kinda trippy.   :slight_smile:

Neat!

Thanks! :slight_smile:

Kinda trippy.   :slight_smile:

That is just fun - thanks for sharing!

That is just fun - thanks for sharing!

Hi r.delia - just had a question I posted here - be interested in you happen to know based on the experiance you have?

http://forums.coronalabs.com/topic/48807-is-corona-as-good-as-a-native-objective-c-app-for-game-sound-controls-eg-midi-guitar-hero/

just having a play 

Does MIDI.lua or SKCoronaSynth require there to be a META event at the start?   Just noting if you remove the channel that just has the upfront meta event that then the song won’t play?

Hi all! I just updated Github with a new feature that lets you get and set the base BPM of the loaded song. 

[lua]

local BPM = skCoronaSynth:getTempo()

skCoronaSynth:setTempo(88)

[/lua]

@greg886 - The biggest issue to me, is that it makes the songs sound ‘wobbly’. MIDI has a time resolution of microseconds… and corona’s ‘clock’ doesn’t.  . I was observing up to 15ms of variance between delta times in my enter frame event, even on my mac.  It was a fun project, and ‘close enough’ so I didn’t really dig much deeper.

for your 2nd question, I’m not sure if any events are required other than on/off for notes.  basically the listener function looks at each track, and tries to play any notes that should have already started :slight_smile:

Hi r.delia - just had a question I posted here - be interested in you happen to know based on the experiance you have?

http://forums.coronalabs.com/topic/48807-is-corona-as-good-as-a-native-objective-c-app-for-game-sound-controls-eg-midi-guitar-hero/

just having a play 

Does MIDI.lua or SKCoronaSynth require there to be a META event at the start?   Just noting if you remove the channel that just has the upfront meta event that then the song won’t play?

Hi all! I just updated Github with a new feature that lets you get and set the base BPM of the loaded song. 

[lua]

local BPM = skCoronaSynth:getTempo()

skCoronaSynth:setTempo(88)

[/lua]

@greg886 - The biggest issue to me, is that it makes the songs sound ‘wobbly’. MIDI has a time resolution of microseconds… and corona’s ‘clock’ doesn’t.  . I was observing up to 15ms of variance between delta times in my enter frame event, even on my mac.  It was a fun project, and ‘close enough’ so I didn’t really dig much deeper.

for your 2nd question, I’m not sure if any events are required other than on/off for notes.  basically the listener function looks at each track, and tries to play any notes that should have already started :slight_smile: