diff options
author | Richard Shann <rshann@debianrts.home> | 2011-02-13 09:11:28 +0000 |
---|---|---|
committer | Richard Shann <rshann@debianrts.home> | 2011-02-13 09:11:28 +0000 |
commit | 9cb51b1a298540b9f03252d14597402eded883ec (patch) | |
tree | bf40b39e6f596c634b48cca7eac0c683c194a973 | |
parent | 410e756cac3165f746c4afa1480f365d8dcc4432 (diff) | |
parent | 51a38e6bf8183276ef6e98773625eee56fe254b0 (diff) |
Merge branch 'master' of ssh://rshann@git.sv.gnu.org/srv/git/denemo
9 files changed, 222 insertions, 37 deletions
diff --git a/actions/Default.commands b/actions/Default.commands index 250c77ce..04b26953 100644 --- a/actions/Default.commands +++ b/actions/Default.commands @@ -4371,6 +4371,37 @@ for second and subsequent systems</tooltip> <menupath>/MainMenu/EditMenu/Select</menupath> <label>Select Left</label> <tooltip>Create a selection, move cursor left.</tooltip> + </row> + <row> + <action>NotationMagick-InsertStringAsBinaryRhythm</action> + <scheme></scheme> + <menupath>/ObjectMenu/NotationMagick/GenerateRhythmFromString</menupath> + <label>Insert string as binary rhythm</label> + <tooltip>Give a string to generate a rhythm out of its ascii chars in binary encoding</tooltip> + </row> + <row> + <action>NotationMagick-InsertReversedStringAsBinaryRhythm</action> + <after>NotationMagick-InsertStringAsBinaryRhythm</after> + <scheme></scheme> + <menupath>/ObjectMenu/NotationMagick/GenerateRhythmFromString</menupath> + <label>Insert reversed string as binary rhythm</label> + <tooltip>Give a string to generate a rhythm out of its ascii chars in binary encoding. The string gets reversed before converting.</tooltip> + </row> + <row> + <action>NotationMagick-InsertStringAsReversedBinaryRhythm</action> + <after>NotationMagick-InsertReversedStringAsBinaryRhythm</after> + <scheme></scheme> + <menupath>/ObjectMenu/NotationMagick/GenerateRhythmFromString</menupath> + <label>Insert string as reversed binary rhythm</label> + <tooltip>Give a string to generate a rhythm out of its ascii chars in binary encoding. The rhythm for each letter gets reversed before inserting.</tooltip> + </row> + <row> + <action>NotationMagick-InsertReversedStringAsReversedBinaryRhythm</action> + <after>NotationMagick-InsertStringAsReversedBinaryRhythm</after> + <scheme></scheme> + <menupath>/ObjectMenu/NotationMagick/GenerateRhythmFromString</menupath> + <label>Insert reversed string as reversed binary rhythm</label> + <tooltip>Give a string to generate a rhythm out of its ascii chars in binary encoding. The string gets reversed before converting. The rhythm for each letter gets reversed before inserting.</tooltip> </row> </map> </merge> diff --git a/actions/menus/ObjectMenu/NotationMagick/GenerateRhythmFromString/NotationMagick-InsertReversedStringAsBinaryRhythm b/actions/menus/ObjectMenu/NotationMagick/GenerateRhythmFromString/NotationMagick-InsertReversedStringAsBinaryRhythm new file mode 100644 index 00000000..2b4854e5 --- /dev/null +++ b/actions/menus/ObjectMenu/NotationMagick/GenerateRhythmFromString/NotationMagick-InsertReversedStringAsBinaryRhythm @@ -0,0 +1,19 @@ +<?xml version="1.0"?> +<Denemo> + <merge> + <title>A Denemo Keymap</title> + <author>AT, JRR, RTS</author> + <map> + <row> + <after>NotationMagick-InsertStringAsBinaryRhythm</after> + <action>NotationMagick-InsertReversedStringAsBinaryRhythm</action> + <scheme>(let ((return (NotationMagick::AskNewAsciistring))) + (if return + (NotationMagick::PutBinaryStringList (reverse (NotationMagick::String->CharsAsBinary return))) + #f))</scheme> + <label>Insert reversed string as binary rhythm</label> + <tooltip>Give a string to generate a rhythm out of its ascii chars in binary encoding. The string gets reversed before converting.</tooltip> + </row> + </map> + </merge> +</Denemo> diff --git a/actions/menus/ObjectMenu/NotationMagick/GenerateRhythmFromString/NotationMagick-InsertReversedStringAsReversedBinaryRhythm b/actions/menus/ObjectMenu/NotationMagick/GenerateRhythmFromString/NotationMagick-InsertReversedStringAsReversedBinaryRhythm new file mode 100644 index 00000000..1c65228e --- /dev/null +++ b/actions/menus/ObjectMenu/NotationMagick/GenerateRhythmFromString/NotationMagick-InsertReversedStringAsReversedBinaryRhythm @@ -0,0 +1,19 @@ +<?xml version="1.0"?> +<Denemo> + <merge> + <title>A Denemo Keymap</title> + <author>AT, JRR, RTS</author> + <map> + <row> + <after>NotationMagick-InsertStringAsReversedBinaryRhythm</after> + <action>NotationMagick-InsertReversedStringAsReversedBinaryRhythm</action> + <scheme>(let ((return (NotationMagick::AskNewAsciistring))) + (if return + (NotationMagick::PutBinaryStringList (reverse (NotationMagick::ReverseStringsInList (NotationMagick::String->CharsAsBinary return)))) + #f))</scheme> + <label>Insert reversed string as reversed binary rhythm</label> + <tooltip>Give a string to generate a rhythm out of its ascii chars in binary encoding. The string gets reversed before converting. The rhythm for each letter gets reversed before inserting.</tooltip> + </row> + </map> + </merge> +</Denemo> diff --git a/actions/menus/ObjectMenu/NotationMagick/GenerateRhythmFromString/NotationMagick-InsertStringAsBinaryRhythm b/actions/menus/ObjectMenu/NotationMagick/GenerateRhythmFromString/NotationMagick-InsertStringAsBinaryRhythm new file mode 100644 index 00000000..8eb966f3 --- /dev/null +++ b/actions/menus/ObjectMenu/NotationMagick/GenerateRhythmFromString/NotationMagick-InsertStringAsBinaryRhythm @@ -0,0 +1,18 @@ +<?xml version="1.0"?> +<Denemo> + <merge> + <title>A Denemo Keymap</title> + <author>AT, JRR, RTS</author> + <map> + <row> + <action>NotationMagick-InsertStringAsBinaryRhythm</action> + <scheme>(let ((return (NotationMagick::AskNewAsciistring))) + (if return + (NotationMagick::PutBinaryStringList (NotationMagick::String->CharsAsBinary return)) + #f))</scheme> + <label>Insert string as binary rhythm</label> + <tooltip>Give a string to generate a rhythm out of its ascii chars in binary encoding</tooltip> + </row> + </map> + </merge> +</Denemo> diff --git a/actions/menus/ObjectMenu/NotationMagick/GenerateRhythmFromString/NotationMagick-InsertStringAsReversedBinaryRhythm b/actions/menus/ObjectMenu/NotationMagick/GenerateRhythmFromString/NotationMagick-InsertStringAsReversedBinaryRhythm new file mode 100644 index 00000000..bc2dc61a --- /dev/null +++ b/actions/menus/ObjectMenu/NotationMagick/GenerateRhythmFromString/NotationMagick-InsertStringAsReversedBinaryRhythm @@ -0,0 +1,19 @@ +<?xml version="1.0"?> +<Denemo> + <merge> + <title>A Denemo Keymap</title> + <author>AT, JRR, RTS</author> + <map> + <row> + <after>NotationMagick-InsertReversedStringAsBinaryRhythm</after> + <action>NotationMagick-InsertStringAsReversedBinaryRhythm</action> + <scheme>(let ((return (NotationMagick::AskNewAsciistring))) + (if return + (NotationMagick::PutBinaryStringList (NotationMagick::ReverseStringsInList (NotationMagick::String->CharsAsBinary return))) + #f))</scheme> + <label>Insert string as reversed binary rhythm</label> + <tooltip>Give a string to generate a rhythm out of its ascii chars in binary encoding. The rhythm for each letter gets reversed before inserting.</tooltip> + </row> + </map> + </merge> +</Denemo> diff --git a/actions/menus/ObjectMenu/NotationMagick/NotationMagick-InsertNoteFromPool b/actions/menus/ObjectMenu/NotationMagick/NotationMagick-InsertNoteFromPool deleted file mode 100644 index 7b6d054d..00000000 --- a/actions/menus/ObjectMenu/NotationMagick/NotationMagick-InsertNoteFromPool +++ /dev/null @@ -1,16 +0,0 @@ -<?xml version="1.0"?> -<Denemo> - <merge> - <title>A Denemo Keymap</title> - <author>AT, JRR, RTS</author> - <map> - <row> - <action>NotationMagick-InsertNoteFromPool</action> - <scheme>;;; Part of NotationMagick - (NotationMagick::InsertMemberRandomlyLy (NotationMagick::AskNewNotationstring))</scheme> - <label>Note from pool</label> - <tooltip>Inserts one note from a user-specified pool of notes in Lilypond syntax</tooltip> - </row> - </map> - </merge> -</Denemo> diff --git a/actions/menus/ObjectMenu/NotationMagick/NotationMagick-InsertPoolShuffled b/actions/menus/ObjectMenu/NotationMagick/NotationMagick-InsertPoolShuffled index 5de103fb..83b2889d 100644 --- a/actions/menus/ObjectMenu/NotationMagick/NotationMagick-InsertPoolShuffled +++ b/actions/menus/ObjectMenu/NotationMagick/NotationMagick-InsertPoolShuffled @@ -6,8 +6,12 @@ <map> <row> <action>NotationMagick-InsertPoolShuffled</action> - <scheme>;;; Part of NotationMagick - (NotationMagick::InsertListRandomlyLy (NotationMagick::AskNewNotationstring))</scheme> + <scheme>;;; Part of NotationMagick + (let ((return (NotationMagick::AskNewNotationstring))) + (if return + (NotationMagick::InsertListRandomlyLy return) + #f)) + </scheme> <label>Insert shuffled pool</label> <tooltip>Inserts all notes, shuffled, from a user-specified pool of notes in Lilypond syntax</tooltip> </row> diff --git a/actions/menus/ObjectMenu/NotationMagick/SingleRandomNote/NotationMagick-InsertNoteFromPool b/actions/menus/ObjectMenu/NotationMagick/SingleRandomNote/NotationMagick-InsertNoteFromPool index 7b6d054d..27d10d8f 100644 --- a/actions/menus/ObjectMenu/NotationMagick/SingleRandomNote/NotationMagick-InsertNoteFromPool +++ b/actions/menus/ObjectMenu/NotationMagick/SingleRandomNote/NotationMagick-InsertNoteFromPool @@ -7,7 +7,11 @@ <row> <action>NotationMagick-InsertNoteFromPool</action> <scheme>;;; Part of NotationMagick - (NotationMagick::InsertMemberRandomlyLy (NotationMagick::AskNewNotationstring))</scheme> + (let ((return (NotationMagick::AskNewNotationstring))) + (if return + (NotationMagick::InsertMemberRandomlyLy return) + #f)) + </scheme> <label>Note from pool</label> <tooltip>Inserts one note from a user-specified pool of notes in Lilypond syntax</tooltip> </row> diff --git a/actions/notationmagick.scm b/actions/notationmagick.scm index 02fb2ffc..d8ecc118 100644 --- a/actions/notationmagick.scm +++ b/actions/notationmagick.scm @@ -1,13 +1,28 @@ -;;;; Various scripts and variables for Denemos note-generation and filter section: NotationMagick -;;; By Nils Gey 2010 -;;; Needs loaded ans.scm +; Various scripts and variables for Denemos note-generation and filter section: NotationMagick +;; By Nils Gey 2010 +;; Needs loaded ans.scm -;; A global var, used by several NotationMagick functions to remember the last value used +;; Global vars, used by several NotationMagick functions to remember the last value used (define NotationMagick::NOTATIONSTRING "c' e' g'") +(define NotationMagick::ASCIISTRING "bach") -;;;; Lilypond wrappers for ANS functions -;;;;;;;;;;;;;;;;;;;;;; +;; Ask for a new NOTATIONSTRING with an input-window, remember the value and return it as list of symbols for ANS +(define (NotationMagick::AskNewNotationstring) + (define new (d-GetUserInput "Enter Lilypond notes" "Please insert a list of lilypond notes, separated by Space." NotationMagick::NOTATIONSTRING)) + (if new + (begin (set! NotationMagick::NOTATIONSTRING new) (map string->symbol (string-tokenize NotationMagick::NOTATIONSTRING))) + #f)) + +(define (NotationMagick::AskNewAsciistring) + (define new (d-GetUserInput "Enter ASCII chars" "Please insert any kind and number of ASCII chars " NotationMagick::ASCIISTRING)) + (if new + (begin (set! NotationMagick::ASCIISTRING new) NotationMagick::ASCIISTRING) + #f)) + + +; Lilypond wrappers for ANS functions +;;;;; ;Random Diatonic: Wrapper for Lilypond syntax (define* (NotationMagick::RandomDiatonicLy #:optional (from 'c,,,) (to 'b'''')) @@ -19,20 +34,12 @@ ;Shuffled List Insert for Lilypond syntax (define (NotationMagick::InsertListRandomlyLy lylist) - (ANS::InsertListRandomly (map ANS::Ly2Ans lylist)) -) + (ANS::InsertListRandomly (map ANS::Ly2Ans lylist))) ;Insert a random member of a list for Lilypond syntax (define (NotationMagick::InsertMemberRandomlyLy lylist) - (ANS::InsertMemberRandomly (map ANS::Ly2Ans lylist)) -) + (ANS::InsertMemberRandomly (map ANS::Ly2Ans lylist))) -;; Ask for a new NOTATIONSTRING with an input-window, remember the value and return it as list of symbols for ANS -(define (NotationMagick::AskNewNotationstring) -(define new (d-GetUserInput "Enter Lilypond notes" "Please insert a list of lilypond notes, separated by Space." NotationMagick::NOTATIONSTRING)) -(set! NotationMagick::NOTATIONSTRING new) -(map string->symbol (string-tokenize NotationMagick::NOTATIONSTRING)) -) ;; Insert a random note which is in a reasonable range according to the prevailing clef. Up to one step above/under the first Ledger line. ;; First the prototype, then one derived version for chromatic, one for diatonic. @@ -49,9 +56,89 @@ ((string-ci=? currentclef "Tenor") (proc 'a, 'a')) ((string-ci=? currentclef "Soprano") (proc 'g 'g'')) ((string-ci=? currentclef "French") (proc 'd' 'd''')) - )) -) + ))) + ;; Usable versions for diatonic and chromatic (define (NotationMagick::RandomWithinClefRangeDiatonic) (NotationMagick::RandomWithinClefRange NotationMagick::RandomDiatonicLy)) (define (NotationMagick::RandomWithinClefRangeChromatic) (NotationMagick::RandomWithinClefRange NotationMagick::RandomChromaticLy)) +; Generators and Cryptographic Functions +;;;;; + +;Binary Rhythm Creation - Based on "Using Binary Numbers in Music" from Vi Hart. http://vihart.com +;Implementation by Nils Gey - Feb. 2011 +#! From her paper: "Binary numbers used as rhythms (not to be confused with binary rhythms) can be used in music to create +a mathematical aspect to a piece which can be heard and appreciated by mathematicians, yet still be +pleasant to the ears of the uninitiated. Even someone who has never heard of binary numbers can still +understand the patterns on an intuitive level. Binary numbers, especially those affiliated with computer +science, have a structure which goes very well with the standard forms of music." + +"Binary Numbers as Rhythm. Let 1 be a note and 0 be a rest. Thus a number becomes a rhythm! +In computer science, binary numbers are usually seen in groups of eight bits (a byte), which +happens to fit perfectly into a 4/4 measure if we assign bits to eighth notes. Powers of two are involved in +the usual form of western music, where four or eight bar phrases might make up a 16 measure section of a +64 measure song. This creates a constraint on the rhythm, but leaves the composer free to choose the +melody." + +ASCII Code. 8bit. One 4/4 measure = one letter. The code for each lowercase letter used begins +with 011, and the following five digits are the position of the letter in the alphabet. Lowercase “a,” then, +is 01100001. +You can reverse the ascii/binary digits to get more variation in the measure beginning. +!# + +(define (NotationMagick::LeadingZerosFiller stringy digits) + (define needed (- digits (string-length stringy))) + (if (> (string-length stringy) digits) + stringy + (string-append (make-string needed #\0) stringy))) + +(define (NotationMagick::Char->binary char digits) + (NotationMagick::LeadingZerosFiller (number->string (char->integer char) 2) digits)) + +(define (NotationMagick::String->CharsAsBinary stringy) + (map (lambda (x) (NotationMagick::Char->binary x 8)) (string->list stringy))) + +;Digit->binary is basically (number->string n 2) which fills with leading zeros to 4 digits. +(define (NotationMagick::Digit->binary numbery) + (define numberstring (number->string numbery 2)) + (NotationMagick::LeadingZerosFiller numberstring 4)) + +(define (NotationMagick::ListOfNumbers->NumbersAsBinary listy digits) + (map (lambda (x) (NotationMagick::LeadingZerosFiller (number->string x 2) digits)) listy)) + +;This is of limited use because you can't access all 4-digit variations. 10-15 (decimal) are out of range. +;If you want those create your own list of numbers and use +(define (NotationMagick::Number->DigitsAsBinary numbery) + ; this is really awkward + (define digitstringlist (map (lambda (x) (make-string 1 x)) (string->list (number->string numbery)))) + (set! digitstringlist (map string->number digitstringlist)) + (map NotationMagick::Digit->binary digitstringlist)) + +(define (NotationMagick::ReverseStringsInList listy) + (map string-reverse listy)) + +; Denemo connection +(define (NotationMagick::PutBinaryString stringy) + (define (PutBinary digit) + (if (equal? digit #\0) + (d-EnterRest)) + (if (equal? digit #\1) + (d-Enter) ; TODO: Replace this with a built-in version. + #f)) + (for-each PutBinary (string->list stringy))) + +(define (NotationMagick::PutBinaryStringList listy) + (for-each NotationMagick::PutBinaryString listy)) + +;TODO: Put binary as lyrics + +#! examples +(d-Set3) +(NotationMagick::PutBinaryStringList (NotationMagick::String->CharsAsBinary "bach")) ; bach +(d-AddAfter) +(NotationMagick::PutBinaryStringList (reverse (NotationMagick::String->CharsAsBinary "bach"))) ;hcab +(d-AddAfter) +(NotationMagick::PutBinaryStringList (NotationMagick::ReverseStringsInList (NotationMagick::String->CharsAsBinary "bach"))) ; bach, each ascii is reverted +(d-AddAfter) +(NotationMagick::PutBinaryStringList (reverse (NotationMagick::ReverseStringsInList (NotationMagick::String->CharsAsBinary "bach")))) ; hcab, each ascii is reverted +!# |