Skip to content

Instantly share code, notes, and snippets.

@alandipert
Created July 13, 2012 19:36
Show Gist options
  • Select an option

  • Save alandipert/3106909 to your computer and use it in GitHub Desktop.

Select an option

Save alandipert/3106909 to your computer and use it in GitHub Desktop.

Revisions

  1. alandipert revised this gist Jul 13, 2012. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion midirepl.clj
    Original file line number Diff line number Diff line change
    @@ -33,7 +33,7 @@
    (if (= 1 (count (str form)))
    (.noteOn channel (get layout form 60) 127)
    (doseq [note (map (comp symbol str) (str form))]
    (.noteOn channel (get keymap note 60) 127)))
    (.noteOn channel (get layout note 60) 127)))
    (recur)))))))

    (midi-rpl (:qwerty keymaps))
  2. alandipert revised this gist Jul 13, 2012. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions midirepl.clj
    Original file line number Diff line number Diff line change
    @@ -21,7 +21,7 @@
    k 69
    l 70}})

    (defn midi-repl [layout]
    (defn midi-rpl [layout]
    (with-open [synth (doto (MidiSystem/getSynthesizer) .open)]
    (let [channel (aget (.getChannels synth) 0)]
    (prn "Type " :q " to quit.")
    @@ -36,4 +36,4 @@
    (.noteOn channel (get keymap note 60) 127)))
    (recur)))))))

    (midi-repl (:qwerty keymaps))
    (midi-rpl (:qwerty keymaps))
  3. alandipert revised this gist Jul 13, 2012. 1 changed file with 1 addition and 2 deletions.
    3 changes: 1 addition & 2 deletions midirepl.clj
    Original file line number Diff line number Diff line change
    @@ -19,8 +19,7 @@
    h 67
    j 68
    k 69
    l 70
    #=(symbol ";") 71}})
    l 70}})

    (defn midi-repl [layout]
    (with-open [synth (doto (MidiSystem/getSynthesizer) .open)]
  4. alandipert created this gist Jul 13, 2012.
    40 changes: 40 additions & 0 deletions midirepl.clj
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    (import '(javax.sound.midi MidiSystem Synthesizer))

    (def keymaps
    '{:colemak {a 60
    r 62
    s 64
    t 65
    d 66
    h 67
    n 68
    e 69
    i 70
    o 71}
    :qwerty {a 60
    s 62
    d 64
    f 65
    g 66
    h 67
    j 68
    k 69
    l 70
    #=(symbol ";") 71}})

    (defn midi-repl [layout]
    (with-open [synth (doto (MidiSystem/getSynthesizer) .open)]
    (let [channel (aget (.getChannels synth) 0)]
    (prn "Type " :q " to quit.")
    (loop []
    (print "midi: ")
    (flush)
    (when-let [form (read)]
    (when (not= form :q)
    (if (= 1 (count (str form)))
    (.noteOn channel (get layout form 60) 127)
    (doseq [note (map (comp symbol str) (str form))]
    (.noteOn channel (get keymap note 60) 127)))
    (recur)))))))

    (midi-repl (:qwerty keymaps))