Skip to content

Instantly share code, notes, and snippets.

@fredbogg

fredbogg/Main.lua

Created Jan 4, 2012
Embed
What would you like to do?
ABCplayerCodea 0.1.9
-- ABCplayerCodea version 0.1.9
-- Plays ABC musical notation format tunes on the Codea/Codify iPad platform. 
-- By Fred Bogg, November 2011.  Improvements welcome. Thanks to ipda41001 for coding assistance.
-- This program defines musical notes and chords, parses an ABC format tune, creates a table
-- of notes to be played with their durations, and then plays it.  With the parsing done 
-- first, playback is possible without slowing down draw frames (psuedo-background).
-- 0.1.9
-- bug fixes and stuff
-- 0.1.7
-- Added flats
-- Implemented key signatures
-- Improved parsing of rendered MIDI files
-- 0.1.6
-- New sharps
-- Starting to implement key signatures
-- Improvements to pattern matching
-- 0.1.5
-- Put class functions in separate tab, data in separate table.
-- Crazily moved tempo iparameter to createSoundTable() to set default to the tune tempo. 
-- Added loop argument to ABCMusic. 
-- 0.1.4
-- added fromTheTop() (a rewind)
-- added demo touched function to demo fromTheTop()
-- 0.1.3
-- Added sharps to central octave.
-- Use this function to perform your initial setup
function setup()
    
    -- loads data into ABCtune string variable
    sampleMusic()
    -- Instantiates the class using the tune. arg 1 for loop, arg 2 for debug, arg 3 dumps
    myTune = ABCMusic(ABCtune)
    
end   
-- This function gets called once every frame
function draw()    
    
    -- Just a test draw; insert our game here... :)
    ellipse(CurrentTouch.x,CurrentTouch.y,100)
    
    -- Play the next bit of music, not the whole lot 
    myTune:play()
    
end
function touched(touch)
    if touch.state == BEGAN then
        myTune:fromTheTop()
    end 
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.