teaching markov chains with midi

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

teaching markov chains with midi

mh2022
Hi everyone!

Following some older posts about how to turn MIDI files into patterns, I have the code bellow. However, it neither plays as a pattern nor fills the MarkovSet with events. I'd much appreciate your advice on this...

Cheers!

MH

f = SimpleMIDIFile.read( "something.mid" );

x = f.generatePatternSeqs;
y = x.iter.all(());
z = Pseq(y, inf);

m = MarkovSet.fill(20, Pevent(z, Event.default).asStream);

(
b = Pchain(Pfsm2(m), (instrument: \default));
b.play;
)
Reply | Threaded
Open this post in threaded view
|

Re: teaching markov chains with midi

daniel-mayer

Am 11.02.2017 um 23:12 schrieb mh2022 <[hidden email]>:

> Hi everyone!
>
> Following some older posts about how to turn MIDI files into patterns, I
> have the code bellow. However, it neither plays as a pattern nor fills the
> MarkovSet with events. I'd much appreciate your advice on this...
>
> Cheers!
>
> MH
>
> f = SimpleMIDIFile.read( "something.mid" );
>
> x = f.generatePatternSeqs;


Hi,

there might be an issue with generatePatternSeqs

http://new-supercollider-mailing-lists-forums-use-these.2681727.n2.nabble.com/SimpleMIDIFile-generatePatternSeqs-td7627552.html

I don't have the newest version of SimpleMIDIFile installed,
but according to the help file I tried with the 'p'-method
and at least the example seems to work.


(
m = SimpleMIDIFile( "~/Desktop/midifiletest.mid" );

m.init1( 3, 120, "4/4" );

m.timeMode = \seconds;  

((0,(1/8)..5)).do({ |starttime|
        m.addNote( 36 + 50.rand, 32 + 96.rand, starttime, [0.1,0.05].choose, 127,
                track: 1 )
        });

((0,(1/4)..5)).do({ |starttime|
        m.addNote( 36 + 50.rand, 64 + 64.rand, starttime, [0.1,0.025].choose, 127,
                channel: 1,  
                track: 2 )
        });

m.adjustEndOfTrack;
m.write;
m.plot
)


x = m.p;
y = x.iter.all(());

z = Pseq(y, inf);

z.play


m = MarkovSet.fill(20, Pevent(z, Event.default).asStream);

(
b = Pchain(Pfsm2(m), (instrument: \default));
b.play;
)


Regards

Daniel

-----------------------------
www.daniel-mayer.at
-----------------------------




_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: http://www.listarc.bham.ac.uk/marchives/sc-users/
search: http://www.listarc.bham.ac.uk/lists/sc-users/search/
Reply | Threaded
Open this post in threaded view
|

Re: teaching markov chains with midi

mh2022
Works great! Thanks a lot, Daniel.