Skip to content

Instantly share code, notes, and snippets.

@fredbogg
fredbogg / PlayMusic.lua
Created November 3, 2011 10:48
Play music in Codea / Codify
-- Play Music.  This plays polyphonically, using the draw function and a frame counter for timing.
-- By Fred.
-- Use this function to perform your initial setup
function setup()
    
    -- initialise variables and clear screen
    frame = 0
    measure = 1
    tuneLength = 0
@fredbogg
fredbogg / Scale
Created November 6, 2011 16:48
A polyphonic diatonic keyboard for Codea / Codify
-- Scale.  This script makes a diatonic keyboard that plays polyphonically
-- By Fred.
-- v1.0
-- Use this function to perform your initial setup
function setup()
    
    notes={c3=85,d3=321,e3=48,f3=63,g3=60,a3=68,b3=11,c4=84}
    
    scale={"c3","d3","e3","f3","g3","a3","b3","c4"}
@fredbogg
fredbogg / ABCplayerCodea.lua
Created November 28, 2011 17:36
Plays ABC musical notation format tunes on the Codea/Codify iPad platform.
-- ABCplayerCodea version 0.1.4
-- 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.4
-- added fromTheTop() (a rewind)
-- added demo touched function to demo fromTheTop()
@fredbogg
fredbogg / ABCplayerCodea.lua
Created December 1, 2011 16:36
Plays ABC musical notation format tunes on the Codea/Codify iPad platform.
-- ABCplayerCodea version 0.1.3
-- 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.3
-- Added sharps to central octave.
-- Amended pattern to detect notes with sharps.
@fredbogg
fredbogg / ABCMusic.lua
Created January 4, 2012 16:12
ABCplayerCodea v0.1.9
ABCMusic = class()
      
function ABCMusic:init(_ABCTune,LOOP,DEBUG,DUMP)
    self.DEBUG = DEBUG
    if self.DEBUG == nil then self.DEBUG = false end
    if DUMP == nil then DUMP = false end
    if _ABCTune == nil then
        print("No tune provided. Use ABCMusic(tunename)")
    end    
    self.LOOP = LOOP
@fredbogg
fredbogg / ABCMusicData.lua
Created January 4, 2012 16:13
ABCplayerCodea v0.1.9
function sampleMusic()
    -- An ABC tune is a string with newline characters to denote new lines.
    -- See the many web pages on ABC musical notation to get a tune or an understanding of
    -- this allegedly human- and machine-readable format.  
    -- You could even write your own by hand or use another program to convert a MIDI file.
   
     ABCtune =
     'X:1\n'
    ..'T:Bogg Blues\n'
    ..'C:Fred Bogg\n'
@fredbogg
fredbogg / Main.lua
Created January 4, 2012 16:14
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
@fredbogg
fredbogg / ABCMusic.lua
Created January 27, 2012 01:21
ABCplayerCodea v0.2.2
ABCMusic = class()
      
function ABCMusic:init(_ABCTune,LOOP,DEBUG,DUMP)
    self.DEBUG = DEBUG
    if self.DEBUG == nil then self.DEBUG = false end
    if DUMP == nil then DUMP = false end
    if _ABCTune == nil then
        print("No tune provided. Use ABCMusic(tunename)")
    end    
    self.LOOP = LOOP
@fredbogg
fredbogg / Main.lua
Created January 27, 2012 01:22
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
@fredbogg
fredbogg / ABCMusicData.lua
Created January 27, 2012 01:23
ABCplayerCodea v0.2.1
function sampleMusic()
    -- An ABC tune is a string with newline characters to denote new lines.
    -- See the many web pages on ABC musical notation to get a tune or an understanding of
    -- this allegedly human- and machine-readable format.  
    -- You could even write your own by hand or use another program to convert a MIDI file.
   
     ABCtune =
     'X:1\n'
    ..'T:Bogg Blues\n'
    ..'C:Fred Bogg\n'