Thanks to everyone who responded with helpful suggestions. I got the "Cybernetic Music" book and am really enjoying it because it has working APL that I can translate to J - though Thomas McGuire may have already done the work on this - and it tries to explain musical notation to a programmer so I'm getting a lot out of that. So far I have just been reading the book and sharing parts of it with my musical collaborator to see what she thinks of the music part.
I plan to start playing with the code soon - thanks again for the helpful examples people sent. Regards, Devon On Mon, Mar 30, 2020 at 3:18 PM Thomas McGuire <tmcguir...@gmail.com> wrote: > For those of you interested in using J as an adjunct to lilypond or other > such program: > > Making a few changes to the lilypond statements that get prepended and > appended to the notes generated (in my previous email on the subject). You > can get lilypond to generate a midi file of the score: > > lilypondhdr =: ('\score{',LF);('\version "2.20.0"',LF);('\relative c'' > {',LF);('\clef treble',LF);('\time 3/4',LF) > lilypondend =: (('\layout {}',LF);('\midi {}',LF)),<'}' > 'lilymusic.ly' fwrites~ ; lilypondhdr,(LF,~ each > lilypondnotes,<'}'),lilypondend > > Basically adding the score tag and inserting '\layout {}’ and ‘\midi {}’ > causes lilypond to generate both a pdf of the score and a midi file that > GargeBand or other such program can play for you. When I generated MusicXML > the musescore program could play the tune right from the score. > > Tom McGuire > > > On Mar 29, 2020, at 2:39 PM, Thomas McGuire <tmcguir...@gmail.com> > wrote: > > > > Using the wavefile.ijs that contains the VOSS routine for generating > random note sequences: > > > > mynotes =: 30 voss 3 > > mynotes > > 7 8 6 11 13 14 6 9 7 12 10 9 12 12 8 11 11 7 11 13 6 8 12 11 15 11 10 12 > 6 10 > > > > NB. Then using the NumToName function in MusicalSyntax.ijs > > NB. I get a boxed list of note names with octaves (adding 60 makes them > be around middle C): > > > > NumToName each ;/60+mynotes > > > ┌──┬───┬───┬──┬───┬──┬───┬──┬──┬──┬───┬──┬──┬──┬───┬──┬──┬──┬──┬───┬───┬───┬──┬──┬───┬──┬───┬──┬───┬───┐ > > > │G4│G#4│F#4│B4│C#5│D5│F#4│A4│G4│C5│A#4│A4│C5│C5│G#4│B4│B4│G4│B4│C#5│F#4│G#4│C5│B4│D#5│B4│A#4│C5│F#4│A#4│ > > > └──┴───┴───┴──┴───┴──┴───┴──┴──┴──┴───┴──┴──┴──┴───┴──┴──┴──┴──┴───┴───┴───┴──┴──┴───┴──┴───┴──┴───┴───┘ > > > > NB. Then massage that into something more lilypondish, > > NB. get rid of octave (you could convert the number into lilypond > apostrophes to set the octave), > > NB. make letters all lowercase, change the sharp symbol to ‘es’. > > NB. Then put them into groups of 3’s for 3/4 time. > > NB. (Replace _3 ]\ with _4 ]\ to group for 4/4 qtr notes) > > > > ('%s %s %s'&sprintf) each <"1 ]_3 ]\ tolower each > ('#';'es')&stringreplace each _1}. each NumToName each ;/60+mynotes > > > ┌─────────┬───────┬───────┬───────┬───────┬─────┬─────────┬───────┬─────────┬─────────┐ > > │g ges fes│b ces d│fes a g│c aes a│c c ges│b b g│b ces fes│ges c b│des b > aes│c fes aes│ > > > └─────────┴───────┴───────┴───────┴───────┴─────┴─────────┴───────┴─────────┴─────────┘ > > > > NB. So putting it all together you get the following > > lilypondnotes =: ('%s %s %s'&sprintf) each <"1 ]_3 ]\ tolower each > ('#’;'is')&stringreplace each _1}. each NumToName each ;/60+mynotes > > > ┌─────────┬───────┬───────┬───────┬───────┬─────┬─────────┬───────┬─────────┬─────────┐ > > │g gis fis│b cis d│fis a g│c ais a│c c gis│b b g│b cis fis│gis c b│dis b > ais│c fis ais│ > > > └─────────┴───────┴───────┴───────┴───────┴─────┴─────────┴───────┴─────────┴─────────┘ > > > > NB. Now create a lilypondhdr: > > > > lilypondhdr =: ('{',LF);('\version "2.20.0"',LF);('\relative c'' > {',LF);('\clef treble',LF);('\time 3/4',LF) > > > > 'lilymusic.ly <http://lilymusic.ly/>' fwrites~ ; lilypondhdr,(LF,~ each > lilypondnotes),(<‘}’,LF),(<‘}’) > > > > You end up with a file that looks like: > > { > > \version "2.20.0" > > \relative c' { > > \clef treble > > \time 3/4 > > g gis fis > > b cis d > > fis a g > > c ais a > > c c gis > > b b g > > b cis fis > > gis c b > > dis b ais > > c fis ais > > } > > } > > > > Running it through lilypond gave me the following pdf > > <lilymusic.pdf> > > > >> On Mar 29, 2020, at 3:47 AM, Hauke Rehr <hauke.r...@uni-jena.de > <mailto:hauke.r...@uni-jena.de>> wrote: > >> > >> could one as easily have a lilypond file created instead? > >> since converting from MusicXML usually doesn’t work that well > >> > >> else I’d rather re-implement the music generation in scheme > >> (guile) in order to use it in lilypond directly > >> > >> Am 29.03.20 um 05:14 schrieb Thomas McGuire: > >>> I have a couple of files one is rough and hastily thrown together. But > it pulls together a few ideas from various people and tries to implement a > VOSS algorithm to randomly generate music in a fractal pattern. It will > also generate MusicXML so you can load it it into a musical score > application. > >>> Tom McGuire > >>>> On Mar 28, 2020, at 5:27 PM, Devon McCormick <devon...@gmail.com > <mailto:devon...@gmail.com>> wrote: > >>>> > >>>> Hi - > >>>> has anyone done work with generating music or musical phrases in J? > I'm > >>>> helping someone develop a music training game that starts by > generating > >>>> sounds with a particular key, tempo, and phrase length. The idea is > to > >>>> help students to train their ears by testing them on their ability to > play > >>>> back a randomly-generated musical phrase. > >>>> > >>>> I've told my collaborator that I think the generation part should be > >>>> relatively straightforward but I am not schooled in music, so I'm not > sure > >>>> how to start. > >>>> I'm guessing that the second part of comparing the user's response to > the > >>>> generated phrase will be more difficult but I'd like to get any kind > of > >>>> start I can. > >>>> > >>>> Does anyone have any ideas about this? > >>>> > >>>> Thanks, > >>>> > >>>> Devon > >>>> > >>>> -- > >>>> > >>>> Devon McCormick, CFA > >>>> > >>>> Quantitative Consultant > >>>> ---------------------------------------------------------------------- > >>>> For information about J forums see > http://www.jsoftware.com/forums.htm <http://www.jsoftware.com/forums.htm> > >>> ---------------------------------------------------------------------- > >>> For information about J forums see http://www.jsoftware.com/forums.htm > <http://www.jsoftware.com/forums.htm> > >> > >> -- > >> ---------------------- > >> mail written using NEO > >> neo-layout.org <http://neo-layout.org/> > >> > >> ---------------------------------------------------------------------- > >> For information about J forums see http://www.jsoftware.com/forums.htm > > > > ---------------------------------------------------------------------- > For information about J forums see http://www.jsoftware.com/forums.htm > -- Devon McCormick, CFA Quantitative Consultant ---------------------------------------------------------------------- For information about J forums see http://www.jsoftware.com/forums.htm