Skip to content

Instantly share code, notes, and snippets.



Created Jan 27, 2012
What would you like to do?
ABCplayerCodea v0.2.1
-- ABCplayerCodea version 0.2.0
-- 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.2.0
-- Uses new sound() API based on sfxr
-- Tunes can play independently
-- made tempo independent for each tune
-- parses comments
-- 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
    -- Instantiates the class using the tune. arg 1 for loop, arg 2 for debug, arg 3 dumps
    myTune = ABCMusic(ABCtune)
  --[[ secondTune = ABCMusic('X:1\n'
    ..'T:Pac Man Theme\n'
    ..'C:Toshio Kai arr. Fred Bogg Copyright NAMCO\n'
    ..'[B,B]b^f[B^d] b/2^f3/2^dB [C,C]c\'g[Ce] c\'/2g3/2[Ce]C|\n'
    ..'[B,B]b^f[B^d] b/2^f3/2^dB ^d/2e/2[^gf]f/2^f/2[^ag]g/2^g/2ab2')
-- This function gets called once every frame
function draw()    
    -- Just a test draw; insert our game here... :)
    -- Play the next bit of music, not the whole lot 
 --  secondTune:play()
function touched(touch)
    if touch.state == BEGAN then
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment