Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
51 lines (40 sloc) 4.98 KB
(ns jmusic
(:use [clojure.contrib.import-static :only (import-static)])
(:use [game-of-life])
(:import jm.JMC)
(:import (jm.util Write))
(:import (jm.music.data Note Score Part Phrase)))
(import-static jm.JMC
CROTCHET)
(def *instruments*
(list (JMC/AAH), (JMC/ABASS), (JMC/AC_GUITAR), (JMC/ACCORDION), (JMC/ACOUSTIC_BASS), (JMC/ACOUSTIC_GRAND), (JMC/ACOUSTIC_GUITAR), (JMC/AGOGO), (JMC/AHHS), (JMC/ALTO), (JMC/ALTO_SAX), (JMC/ALTO_SAXOPHONE), (JMC/APPLAUSE), (JMC/ATMOSPHERE), (JMC/BAG_PIPES), (JMC/BAGPIPE), (JMC/BAGPIPES), (JMC/BANDNEON), (JMC/BANJO), (JMC/BARI), (JMC/BARI_SAX), (JMC/BARITONE), (JMC/BARITONE_SAX), (JMC/BARITONE_SAXOPHONE), (JMC/BASS), (JMC/BASSOON), (JMC/BELL), (JMC/BELLS), (JMC/BIRD), (JMC/BOTTLE), (JMC/BOTTLE_BLOW), (JMC/BOWED_GLASS), (JMC/BRASS), (JMC/BREATH), (JMC/BREATHNOISE), (JMC/BRIGHT_ACOUSTIC), (JMC/BRIGHTNESS), (JMC/CALLOPE), (JMC/CELESTA), (JMC/CELESTE), (JMC/CELLO), (JMC/CGUITAR), (JMC/CHARANG), (JMC/CHIFFER), (JMC/CHIFFER_LEAD), (JMC/CHOIR), (JMC/CHURCH_ORGAN), (JMC/CLAR), (JMC/CLARINET), (JMC/CLAV), (JMC/CLAVINET), (JMC/CLEAN_GUITAR), (JMC/CONCERTINA), (JMC/CONTRA_BASS), (JMC/CONTRABASS), (JMC/CRYSTAL), (JMC/CYMBAL), (JMC/DGUITAR), (JMC/DIST_GUITAR), (JMC/DISTORTED_GUITAR), (JMC/DOUBLE_BASS), (JMC/DROPS), (JMC/DRUM), (JMC/DX_EPIANO), (JMC/EBASS), (JMC/ECHO), (JMC/ECHO_DROP), (JMC/ECHO_DROPS), (JMC/ECHOS), (JMC/EL_BASS), (JMC/EL_GUITAR), (JMC/ELECTRIC_BASS), (JMC/ELECTRIC_GRAND), (JMC/ELECTRIC_GUITAR), (JMC/ELECTRIC_ORGAN), (JMC/ELECTRIC_PIANO), (JMC/ELPIANO), (JMC/ENGLISH_HORN), (JMC/EPIANO), (JMC/EPIANO2), (JMC/FANTASIA), (JMC/FBASS), (JMC/FIDDLE), (JMC/FINGERED_BASS), (JMC/FLUTE), (JMC/FRENCH_HORN), (JMC/FRET), (JMC/FRET_NOISE), (JMC/FRETLESS), (JMC/FRETLESS_BASS), (JMC/FRETNOISE), (JMC/FRETS), (JMC/GLOCK), (JMC/GLOCKENSPIEL), (JMC/GMSAW_WAVE), (JMC/GMSQUARE_WAVE), (JMC/GOBLIN), (JMC/GT_HARMONICS), (JMC/GUITAR), (JMC/GUITAR_HARMONICS), (JMC/HALO), (JMC/HALO_PAD), (JMC/HAMMOND_ORGAN), (JMC/HARMONICA), (JMC/HARMONICS), (JMC/HARP), (JMC/HARPSICHORD), (JMC/HELICOPTER), (JMC/HONKYTONK), (JMC/HONKYTONK_PIANO), (JMC/HORN), (JMC/ICE_RAIN), (JMC/ICERAIN), (JMC/JAZZ_GUITAR), (JMC/JAZZ_ORGAN), (JMC/JGUITAR), (JMC/KALIMBA), (JMC/KOTO), (JMC/MARIMBA), (JMC/METAL_PAD), (JMC/MGUITAR), (JMC/MUSIC_BOX), (JMC/MUTED_GUITAR), (JMC/MUTED_TRUMPET), (JMC/NGUITAR), (JMC/NYLON_GUITAR), (JMC/OBOE), (JMC/OCARINA), (JMC/OGUITAR), (JMC/OOH), (JMC/OOHS), (JMC/ORCHESTRA_HIT), (JMC/ORGAN), (JMC/ORGAN2), (JMC/ORGAN3), (JMC/OVERDRIVE_GUITAR), (JMC/PAD), (JMC/PAN_FLUTE), (JMC/PANFLUTE), (JMC/PBASS), (JMC/PHONE), (JMC/PIANO), (JMC/PIANO_ACCORDION), (JMC/PIC), (JMC/PICC), (JMC/PICCOLO), (JMC/PICKED_BASS), (JMC/PIPE_ORGAN), (JMC/PIPES), (JMC/PITZ), (JMC/PIZZ), (JMC/PIZZICATO_STRINGS), (JMC/POLY_SYNTH), (JMC/POLYSYNTH), (JMC/PSTRINGS), (JMC/RAIN), (JMC/RECORDER), (JMC/REED_ORGAN), (JMC/REVERSE_CYMBAL), (JMC/RHODES), (JMC/SAW), (JMC/SAWTOOTH), (JMC/SAX), (JMC/SAXOPHONE), (JMC/SBASS), (JMC/SEA), (JMC/SEASHORE), (JMC/SFX), (JMC/SGUITAR), (JMC/SHAKUHACHI), (JMC/SHAMISEN), (JMC/SHANNAI), (JMC/SITAR), (JMC/SLAP), (JMC/SLAP_BASS), (JMC/SLOW_STRINGS), (JMC/SOLO_VOX), (JMC/SOP), (JMC/SOPRANO), (JMC/SOPRANO_SAX), (JMC/SOPRANO_SAXOPHONE), (JMC/SOUNDEFFECTS), (JMC/SOUNDFX), (JMC/SOUNDTRACK), (JMC/SPACE_VOICE), (JMC/SQUARE), (JMC/STAR_THEME), (JMC/STEEL_DRUM), (JMC/STEEL_DRUMS), (JMC/STEEL_GUITAR), (JMC/STEELDRUM), (JMC/STEELDRUMS), (JMC/STR), (JMC/STREAM), (JMC/STRINGS), (JMC/SWEEP), (JMC/SWEEP_PAD), (JMC/SYN_CALLIOPE), (JMC/SYN_STRINGS), (JMC/SYNTH_BASS), (JMC/SYNTH_BRASS), (JMC/SYNTH_CALLIOPE), (JMC/SYNTH_DRUM), (JMC/SYNTH_DRUMS), (JMC/SYNTH_STRINGS), (JMC/SYNVOX), (JMC/TAIKO), (JMC/TELEPHONE), (JMC/TENOR), (JMC/TENOR_SAX), (JMC/TENOR_SAXOPHONE), (JMC/THUMB_PIANO), (JMC/THUNDER), (JMC/TIMP), (JMC/TIMPANI), (JMC/TINKLE_BELL), (JMC/TOM), (JMC/TOM_TOM), (JMC/TOM_TOMS), (JMC/TOMS), (JMC/TREMOLO), (JMC/TREMOLO_STRINGS), (JMC/TROMBONE), (JMC/TRUMPET), (JMC/TUBA), (JMC/TUBULAR_BELL), (JMC/TUBULAR_BELLS), (JMC/VIBES), (JMC/VIBRAPHONE), (JMC/VIOLA), (JMC/VIOLIN), (JMC/VIOLIN_CELLO), (JMC/VOICE), (JMC/VOX), (JMC/WARM_PAD), (JMC/WHISTLE), (JMC/WIND), (JMC/WOODBLOCK), (JMC/WOODBLOCKS), (JMC/XYLOPHONE)))
(defmacro jm-add-children
[m obj parts]
`(let [obj# ~obj]
(doseq [p# ~parts]
(doto obj#
(~m p#)))
obj#))
(defn make-score
[name parts]
(let [sc (Score. name)]
(jm-add-children .addPart sc parts)))
(defn make-phrase
[name notes]
(let [p (Phrase. name)]
(jm-add-children .addNote p notes)))
(defn make-part
[name instrument channel phrases]
(let [part (Part. name instrument channel)]
(jm-add-children .addPhrase part phrases)))
(defn make-note
[freq rhythm]
(Note. freq rhythm))
(defn save [score output]
(Write/midi score output))
(defn make-noise []
(let [notes (map (fn [y] (make-note (+ C4 y) CROTCHET)) (range 0 12))
phrase (make-phrase "Phrase1" notes)
parts (map (fn [instrument channel] (make-part "Part" instrument channel (list phrase))) *instruments* (range 0 10000000))
score (make-score "Score" parts)]
(save score "chromatic-scale.mid")))