back to bmidilib

(Note: this is an old college project written during my sophomore year in 2008)

See the code on GitHub

Tunescript - A music toy

Tunescript

Sections:

Overview

tunescript, a music toy
Copyright (C) Ben Fisher, 2009. GPLv3.
Tunescript is a musical toy, and a fun way to enter in some music.
It can be helpful for expressing rhythms, say to quickly record some rhythm you came up with.

Getting Started

Open "main.py" with Python.

An example song will be automatically loaded.
Press "Play". You should hear some music..

If you don't hear anything,
check your volume settings, in particular the volume for "SW Synth."
Make sure that it is turned up and try again.

If you are using Linux and you do not hear music, it is possible that you do not have the program Timidity installed.
Open a terminal, type "timidity", and press Enter. If it cannot find the file, you'll have to install timdity.
Run something along the lines of
sudo apt-get install timidity
or
sudo yum install timidity
in the terminal to install it.
(This program also depends on "python-tk", which you may need to apt-get as well.)

There are two modes, "tunescript" mode and "Code" mode.
The tunescript mode is the interesting and fun one
Code mode simply evaluates the Python code you provide.
See the Examples menu.

Follow the examples! Play around with them, and make your own songs!

Examples

================
simple
----------------
c d e f g ...
g f e d c ...

================
tune
----------------
--this is a comment. it won't affect the music
--use comments to make notes to yourself

c,cde,efg,age,..
g,fed,,,f,edc,..
c,cde,efg,age,..
g,fed,edc,,

================
pitches
----------------
c d e f g a b c'

c__ c_ c c' c'' ...
c'' c' c c_ c__ ...

c c# d d# e f f# g g# a a# b c'
================
rhythms
----------------
c c c c
--make it slower
c, c, c, c, 
c,, c,, c,, c,,
c,,, c,,, c,,, c,,,
--make it faster
c c c c 
/c/ /c/ /c/ /c/ /c/ /c/ /c/ /c/ 

--put a funky rhythm together
g,,g..gg..g..g..
g,,g..gg..g..g..

================
note mods
----------------
--legato (more smooth)
c, c, c, c,

--staccatto (short silence in-between notes)
c. c. c. c.

-- accents
g!! e! c e? g??
================
instruments
----------------
(voice 'bass')
c2,, d2,, e2,, f2,,
(voice 'flute')
c5,, b4,, a4,, g4,,
================
percussion
----------------
o. o. o. o.
o = s = o = s =
o = s = o = s =

@O0oXxMmWw

================
chords
----------------
c, e, g,
[c|e|g],
d, f, a,
[d|f|a],

g,,g,,
[c#|d|e|f],,

================
chord&perc
----------------

[c|e|g|o] [d|f|a] [o|*]
X,,,.
[c|e|g|o] [d|f|a] [o|*]
X,,,.
================
tracks!
----------------
--they play at the same time
>> c, d, e, f, g,
>> e, f, g, a, b,

================
track voices
----------------
(voice 1 'fretless bass')
(voice 2 'ocarina')
(balance 1 left 100)
(balance 2 right 100)

>> v c, d, e, f, g,,,,
>> ^ e, f, g, a, b,
================
drum break
----------------
(tempo 240)
>> +.+.+.+. +.+.+.+. +.+.+.+.+.+.+.+.
>> ....*... ....*... o.o.s..s.soos...

>> +.+.+.+.+.+.+.+. +.+.+.+.+.+.+.+.
>> o.o.s..s.soos..s o...s..Ooos..s.s

>> +.+.+.+.+.+.+.+. +.+.+.+.+.+.+.+.
>> X...s..s.s..s... o.o.s..s.soos...

================
swing
----------------

c,c e,e f,f f#,f# g,Eb e, c,,

>> {},,,,,,,,
>> [Bb_|c|e],,,,,,,,,,,

================
row
----------------
--here are the parts:
--c,   ,c,,c,de,,
--e,   de,fg,,,,,
--c'c'c'gggeeeccc
--g,   fe,dc,,,,,

>> c,   ,c,,c,de,,e,   de,fg,,,,,c'c'c'gggeeecccg,   fe,dc,,,,,
>> ..   ..........c,   ,c,,c,de,,e,   de,fg,,,,,c'c'c'gggeeecccg,   fe,dc,,,,,

-- try adding more voices!
================
bend
----------------
(voice "sitar")
--bend up:
c3,,,,,~>100~ c3,,,, ...

--bend down:
c5,,,,,~>-100~ c5,,,, ...

--bend chord:
[c3|g3],,,~>100~ [c3|g3]!,,,, ...
================
mary
----------------
edcdeee,ddd,egg,
edcdeeeeddedc,,,

--now make it off tune
>>c~>60~
>>

--one track is tuned upwards...
>>edcdeee,ddd,egg,edcdeeeeddedc,,,
>>edcdeee,ddd,egg,edcdeeeeddedc,,,

================
still rock
----------------
(voice 1 'rock organ')
(voice 2 "bass")
(tempo 210)

>> ^
>> v c,c c,c c,c c,c c,c c,c c,c c,c

>> ... c,c c,c c,dvb,, a,, a,g g,g
>> c,c c,c c,c c,cve,e e,e e,e e,e

>> a#,,  a#,a# a#,,  c', /a//g/f,, 
>> a#,a# a#,a# a#,a# a#,a# f,f f,f f,f f,f

>> ^... c,c c,c c,dvb,, a,, a,g g,g
>> ^c,c c,c c,c c,cve,e e,e e,e e,e

>> a#,,  a#,a# a#,,  c', /a//g/f,, 
>> a#,a# a#,a# a#,a# a#,a# f,f f,f f,f f,f

>> ... e,e g,g b,b c',, a,e g,a ,,e
>> e,e e,e e,e e,e a,a  a,a a,a a,a

>> e,, e,e g,g b,b c',g a,e g,a,
>> e,e e,e e,e e,e d,d d,d g,g g,g

Instrument List

To set an instrument, use code like (voice "piano") or, equivalently (voice "Acoustic Grand Piano"). The search is not case-sensitive. The following instruments are available:
Acoustic Grand Piano
Bright Piano
Electric Grand Piano
Honky-Tonk Piano
Electric piano 1
Electric Piano 2
Harpsichord
Clavinet
Celesta
Glockenspiel
Music Box
Vibraphone
Marimba
Xylophone
Tubular bells
Dulcimer
Drawbar Organ
Percussive Organ
Rock Organ
Church Organ
Reed Organ
Accordion
Harmonica
Tango Accordion
Nylon String Guitar
Steel String Guitar
Jazz Guitar
Clean Electric Guitar
Muted Electric Guitar
Overdrive Guitar
Distortion Guitar
Guitar Harmonics
Acoustic Bass
Fingered Bass
Picked Bass
Fretless Bass
Slap Bass 1
Slap Bass 2
Synth Bass 1
Synth Bass 2
Violin
Viola
Cello
Contrabass
Tremolo Strings
Pizzicato Strings
Orchestral Harp
Timpani
String Ensemble 1
String Ensemble 2
Synth Strings 1
Synth Strings 2
Choir Ahh
Choir Oohh
Synth Voice
Orchestral Hit
Trumpet
Trombone
Tuba
Muted Trumpet
French Horn
Brass Section
Synth Brass 1
Synth Brass 2
Soprano Sax
Alto Sax
Tenor Sax
Baritone Sax
Oboe
English Horn
Bassoon
Clarinet
Piccolo
Flute
Recorder
Pan flute
Blown Bottle
Shakuhachi
Whistle
Ocarina
Square Wave
Sawtooth Wave
Caliope
Chiff
Charang
Voice
Fifths
Bass & Lead
New Age
Warm
PolySynth
Choir
Bowed
Metallic
Halo
Sweep
FX: Rain
FX: Soundtrack
FX: Crystal
FX: Atmosphere
FX: Brightness
FX: Goblins
FX: Echo Drops
FX: Star Theme
Sitar
Banjo
Shamisen
Koto
Kalimba
Bagpipe
Fiddle
Shanai
Tinkle bell
Agogo
Steel Drums
Woodblock
Taiko Drum
Melodic Tom
Synth Drum
Reverse Cymbal
Guitar Fret Noise
Breath Noise
Seashore
Bird Tweet
Telephone Ring
Helicopter
Applause
Gunshot

Syntax

Directives. These must occur on their own line.
================
(tempo 300)		Sets tempo. Must occur before any notes.
(voice "flute")		Set instrument
(voice 'flute')
(voice "73")			Set instrument by number
(voice 2 "flute")		Set instrument of a certain track

(volume 100)		Set volume, from 0 to 100.
(volume 2 100)		Set volume of a certain track

(balance right 100)	Make all of the way to the right speaker (0-100)
(balance left 100)	Make all of the way to the left speaker
(balance right 0)		Centered
(balance 2 right 100)	Set balance of a certain track


Pitches
================

c			The pitch c. uses the last octave specified.
c#
A
Ab			Note that "Ab" means "a flat". "ab" means "pitch a, then pitch b".

c3			Use a specific octave.

c'			An octave higher
c''			
c'''
c_			An octave lower
c__
c___

^ 			raises current octave
v			lowers current octave


Rhythm
=================
,		increases the length of the note, by one unit. "c,," is 3 times longer than "c"
.		rest for one unit
/c/		a pitch within forward slashes is played twice as quickly. 
		These can't have other modifications; /c/! or /c/, are not allowed. 
		Percussion, like /o/ is supported.
//c//		played 4 times as quickly

Currently unsupported:
	/c/!
	chords like /[c|e]/ 
	[.|c] is illegal

Note modifications
=================
c!		accented
c!!
c?		quieter
c??

c~>100		pitch bend all of the way. typically this bends up 2 semitones.
			bending occurs from the previous "bend amount" to the new amount. 
c,,,~>100		same as previous, but slower bending

a!,,		example of multiple modifications

Harmony
================
[c|e|g]	play the notes c e and g at the same time.
		can be modified with duration, accent and pitch bend

>> e f g
>> c d e
The above lines will set up two tracks to play simultaneously. 
Each "track" is separate, and settings like the last octave used are distinct.
The instruments set with (voice 2 'flute') 

The longest of the two lines will be used, in other words
>> c d e f g f e d c d e
>> c_
will become like
>> c  d e f g f e d c d e
>> c_.  . . . . . . . . . 
so that the lengths are even.

Percussion
===============
Also, certain notes are percussion and sound like percussion regardless of track/voice setting. These are:
o		Bass Drum 1
s		Snare Drum 1
*		Hand Clap
=		Closed Hi-hat
O		Low Tom 1
+		Open Hi-hat
0		Mid Tom 1
x		Crash Cymbal 1
{}		Chinese Cymbal
@		Cowbell
X		Crash Cymbal 2
M		High Agogo
m		Low Agogo
W		Short Whistle
w		Long Whistle

For cymbals that may be long, duration can be used, as in
{},,,
s!

back to bmidilib



Ben Fisher, 2009
GPLv3.