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' 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


> On Mar 29, 2020, at 3:47 AM, Hauke Rehr <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> 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
>> ----------------------------------------------------------------------
>> For information about J forums see http://www.jsoftware.com/forums.htm
> 
> -- 
> ----------------------
> mail written using NEO
> 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

Reply via email to