moduleHaskore.Example.FlipwhereimportHaskore.MelodyasMelodyimportHaskore.Music.GeneralMIDIasMidiMusicimportData.Array(Array,(!),listArray)importqualifiedData.ListasList{-
flipSeq 2 !! n = parity of number of 1's in binary representation of n.
http://www.research.att.com/cgi-bin/access.cgi/as/njas/sequences/eisA.cgi?Anum=A010060-}flipSeq::Int->[Int]flipSeqn=letincListm=map(\x->mod(x+m)n)recursey=letz=concatMap(flipincListy)[1..(n-1)]inz++recurse(y++z)in[0]++recurse[0]{- based on Helmut Podhaisky's implementation
it must be flipSeq2 == flipSeq 2 -}flipSeq2::[Int]flipSeq2=letrecursey=letz=map(1-)yinz++recurse(y++z)in[0]++recurse[0]noteArray::[()->Melody.T()]->ArrayInt(Melody.T())noteArrayns=listArray(0,lengthns-1)(map(\n->n())ns)makeSong::[()->Melody.T()]->Melody.T()makeSongms=line(map(noteArrayms!)(flipSeq(lengthms)))song,song1,core,core1::Melody.T()song=changeTempo8corecore=makeSong[e1qn,g1qn,c2qn,e2qn]song1=changeTempo8core1core1=letrep=16inline$zipWith(!)(cycle(List.replicaterep(noteArray[e1qn,a1qn,c2qn,e2qn])++List.replicaterep(noteArray[g1qn,c2qn,e2qn,g2qn])++List.replicaterep(noteArray[a1qn,d2qn,f2qn,a2qn])++List.replicaterep(noteArray[a1qn,c2qn,f2qn,a2qn])++List.replicaterep(noteArray[a1qn,c2qn,e2qn,a2qn])))(flipSeq4){-
If you divide the stream into blocks of size n
each block will contain each of the indices of {0,..,n-1} exactly once.
Thus you can also choose musical atoms of different length
for generating rythms.
-}song2,core2::MidiMusic.Tsong2=changeTempo4core2core2=letrep=16flipper=MidiMusic.fromMelodyNullAttrMidiMusic.AcousticGrandPiano$line$zipWith(!)(cycle(List.replicaterep(noteArray[e1dqn,a1en,c2qn,e2qn])++List.replicaterep(noteArray[g1dqn,c2en,e2qn,g2qn])++List.replicaterep(noteArray[a1dqn,d2en,f2qn,a2qn])++List.replicaterep(noteArray[a1dqn,c2en,f2qn,a2qn])++List.replicaterep(noteArray[a1dqn,c2en,e2qn,a2qn])++List.replicaterep(noteArray[a1dqn,c2en,e2qn,a2qn])))(flipSeq4)bassLine=MidiMusic.fromMelodyNullAttrMidiMusic.Viola$transpose(-12)$line$cycle$concatMap(List.replicate8)$List.map($())[a0hn,c1hn,d1hn,f1hn,a1hn,a0hn]inflipper=:=bassLine