markovGenerator: A music generator based on Markov chains with variable length
Edit: There is a general [markov] abstraction now at https://forum.pdpatchrepo.info/topic/12147/midi-into-seq-and-markov-chains/45
This is one of the early projects by @Jona and me. Happy to finally release it.
markovGenerator
Generates music from learned material using Markov chains. It is polyphonic, plays endlessly and supports Markov chains with variable length.
markovGenerator.zip (updated)
Usage:
- Record midi notes or load midi files
- Make Markov system
- Play
-
Record midi notes or load midi files
Until you reset the memory, each new recording will be added to the memory. The recorded material is seen as a loop, so that the last note is followed by the the first note, for endless play. markovGenerator handles recording midi and loading midi files differently: When you record midi, it will record notes according to the midi clock every sixth midi tick. This is defined in the counter in [pd midiclock]. So that way, breaks are being recorded and the rhythm is preserved. When loading midi files, no breaks are being recorded, the notes are just recorded in order, so the rhythm will be lost. In any case, simultaneous notes will be recorded as chords, so polyphony is preserved. -
Make Markov system
Set markovOrder to specify the length of the Markov chain. The higher the order, the more musical information will be kept, the lower the order, the more random it gets. You can use soundFilter and channelFilter to only use notes of the specified sound or channel. This is especially useful when working with midi files. Note that if there are no notes of the specified sound or channel, the Markov system will be empty and nothing will be played. Set the filters to zero to disable them. If you change the settings for the Markov system, click makeMarkov again for them to take effect. You can make new Markov systems with different settings out of the same recorded material over and over again, even when playing. If you record additional notes, click makeMarkov again to incorporate them into the Markov system. -
Play
While playing, you can change the note length, sound and midi out channel. Set soundOut and channelOut to zero to use the sound and channel information of the original material. Playing starts with the Markov chain of the last recorded notes, so the first note might be played first.
Use the markovAll section on the right to control all Markov channels at once. Here you can also set tempo, swing and midiSync, and you can save the project or load previous projects.
Have fun!
If it does not play, make sure that
- you recorded some notes,
- you hit the makeMarkov button,
- soundFilter and channelFilter are not set to values where there are no notes. Try setting the filters to zero and hit makeMarkov again.
About the Markov system:
You can see the Markov system of each Markov channel in [text define $0markov]. Notes are stored as symbols, where the values are joined by "?". A note might look like 42?69?35?10 (pitch?velocity?sound?channel). Chords are joined by "=". A chord of two notes might look like 40?113?35?10=42?49?35?10. Notes and chords are joined to Markov chains by "-". The velocity values are not included in the chains. Sound and midi channel values are only included, if soundFilter or channelFilter are off, respectively. Markov chains of order three may look like 42?35?10-36?35?10=42?35?10-60?35?2 with filters off and simply like 42-37-40 with both filters active, only using the pitch value.
Requires Pd 0.47.1 with the libraries cyclone, zexy and list-abs.
Vanilla struct multislider with jump on click and drag
i updated the original post. The current version is now stable even without the virtual mouse click.
The problem was, that to drag the whole plotted array, the click has to go to the invisible grabbing area of the element, which represents the variable y. In the first version, when this area was missed, the click would not grab the element and dragging wouldn't work. The virtual mouse click solved this, because it would always click at the center of the element where the grabbing area is located.
The current version doesn't need the virtual click anymore, because it moves the whole struct on click, so that the grabbing area of the element is moved to where the mouse is. After it got the click, it is moved back to the original position.
The drawback is, that it is not always accurate while dragging (the virtual click solution has the same problem). The further you click away from the center of a slider, the more inaccurate it becomes. i am still looking for a solution for this.
i also made another version, which uses pixel dragging instead of the plotted array drawing feature:
Now this way it is always accurate, but because it is processed through Pd and not directly working on the data structure, it will miss some sliders if you move the mouse fast. This is the effect you also get if you use an external to get the mouse position and set the sliders from there.
Metro sync
@CBronisimo The easiest way to do such a thing is to use a metro as a clock signal at the fastest time division you'd like to obtain. Then use a counter, a [mod N] and a [sel 0] to bang every N beats.
This way you can have lots of pseudo-metro functions that depend on just one metro, and they will be in sync every time. Obviously you'll have to reset the counter if you stop and restart the clock metro.
For example, if you want a whole time to beat every 1000 ms, set metro to 1000/32, then use [mod 32] to bang whole time, [mod 16] to bang 1/2, [mod 8] to bang 1/4 and so on up to 1/32 with no mod at all, or [mod 64] to bang twice the time etc... If you plan to go even faster just set the clock metro to 1000/64 or 1000/128 and change [mod N] accordingly. You can even get dotted and odd time signatures this way.
Hope this helps!
Fifo Overflow
Whoops! Missed this post, just found it by accident. Don't know if the OP gave up but might as well respond for the archive and mention that I finally filed a bug on this issue.
The known problem here -- as I have stated in other threads -- is probably not a midi clock issue but Active Sense messages (the Yamaha PSR-E323 midi implementation chart indicates that these are implemented in that device). Active Sense is part of the System Realtime group of commands in the midi spec (also includes clock, stop, start, and continue).
If configured correctly, Midi Patchbay on the MAC will stop these messages, but it can only be configured to block the entire System Realtime group. If the other messages are needed, a more selective option might be Midi Pipe, thou I have not yet tested this. It can be downloaded from here:
https://www.macupdate.com/app/mac/10541/description
See also these threads:
http://forum.pdpatchrepo.info/topic/9565/midi-issue
http://forum.pdpatchrepo.info/topic/9501/filter-out-midi-clock-information
http://forum.pdpatchrepo.info/topic/9635/does-midirealtimein-still-work
Pd quits when opening Midi settings
Which version of Pd and on which operating system?
Can't say for sure what's up, one long-standing issue with Mac and Windows PD is that PD has never had a proper software midi interface between the app and the system. What it does have is a hack-in that will connect PD midi to - at maximum - the first nine ports on the system's midi port list and nowhere else. ATM only ALSA MIDI on linux has anything close to a fully interfaced PD midi to system buss.
To get full access to the max available midi porting on Mac/Win you have to start with all midi ports on the system deactivated. You then have to use 3d party midi patching software such as Midi Patchbay on Mac (don't use IAC leave it deactivated) or an equivalent Windows program to create nine virtual midi ports to occupy those first eight slots on the system list. Start PD and connect it to the nine virtual ports. Activate all the other midi ports/devices that you need on the system, then use the patching software to do the actually midi routing to external software and devices.
If the above sounds ridiculous -- it is! Supposedly this is actually being worked on (finally) but it requires a major rewrite of badly botched coding. Most of the Pd coders don't really "get" midi and the few that do haven't been very active since they contributed the ALSA code. Take it from someone who has written multiple midi synth editors with Pd-- there's a reason I prefer PureData on linux.
libpd on mac: clarification requested on expected behavior of cpp sample
Hi! I am running Pd-0.47-1-64bit on Mac OS 10.11.6 and libpd 0.9.2. I am trying to work with the samples/cpp/pdtest. Here's the github repo. I currently have an app that takes video and spits out a 2D array of color values for regions of interest to file. I have a pd patch that then loads those into a table and plays the corresponding pitch. I need the two (patch, c++ app) to coordinate the IPC.
I compiled the cpp code in the samples directory however, when running pdtest executable there is no patch opened. Is this by design? I was not able to find a pd-vanilla to build from source so took the most recent (pd-0.47-1-64bit.mac.tar.gz). Does libpd need to have the pd built after libpd? If so, can anyone please point me to a src file?
Here is a truncated output from running the compiled pdtest. Could someone tell me if this is what is expected?
Thank you for your help.
BEGIN Patch Test
Patch: "pd/test.pd" $0: 1003 valid: 1
Patch: "pd/test.pd" $0: 0 valid: 0
Patch: "pd/test.pd" $0: 1005 valid: 1
PD: PATCH OPENED: 1003
print: 0
PD: PATCH OPENED: 1005
print: 0
FINISH Patch Test
BEGIN Message Test
FINISH Message Test
BEGIN MIDI Test
FINISH MIDI Test
BEGIN Array Test
array1 len: 10
array1 0.0857145 0.328572 0.500001 0.57143 0.514287 0.47143 0.357144 0.285715 0.057143 0
array1 0 1 2 3 4 5 6 7 8 9
array1 10 10 10 10 10 10 10 10 10 10
FINISH Array Test
BEGIN PD Test
FINISH PD Test
Processing PD
PD: bang
PD: 100
PD: symbol test string
PD: bang
PD: 100
PD: symbol test string
PD: 1.23 a symbol
PD dollar zero: 1.23 a symbol
PD: 1.23 sent from a List object
PD: msg 1.23 sent from a List object
PD: 1.23 sent from a streamed list
PD MIDI: notein 2 60 64
PD MIDI: ctlin 2 0 64
PD MIDI: pgm 2 101
PD MIDI: midiin 1 239
PD: symbol test
PD: START MSG TEST
CPP: bang toCPP
CPP: float toCPP: 100
CPP: symbol toCPP: kaaa
CPP: list toCPP: 100 2.3 test 1 2 3 ffsfff
CPP: message toCPP: kaa 1 2.3 test ffs
PD: MSG TEST FINISH
PD: START MIDI TEST
PD: MIDI TEST FINISHED
PD: START ARRAY TEST
PD array1: 10
PD array1: 10
PD array1: 10
PD array1: 10
PD array1: 10
PD array1: 10
PD array1: 10
PD array1: 10
PD array1: 10
PD array1: 10
PD: FINISH ARRAY TEST
PD: test_abs: Hello World!
CPP MIDI: note on: 0 0 127
CPP MIDI: note on: 0 0 127
CPP MIDI: note on: 0 60 64
CPP MIDI: control change: 0 64 100
CPP MIDI: program change: 0 99
CPP MIDI: pitch bend: 0 2000
CPP MIDI: aftertouch: 0 100
CPP MIDI: poly aftertouch: 0 64 100
CPP MIDI: midi byte: 0 239
CPP: float env: 75.5457
CPP: float env: 87.9506
CPP: float env: 93.5842
...
CPP: float env: 88.5503
CPP: float env: 87.7612
print: 1
CPP MIDI: note on: 0 0 0
CPP MIDI: note on: 0 1 127
CPP: float env: 86.8932
...
CPP: float env: 41.2584
CPP: float env: 0
print: 2
CPP MIDI: note on: 0 1 0
CPP MIDI: note on: 0 2 127
...
print: 20
CPP MIDI: note on: 0 19 0
CPP MIDI: note on: 0 20 127
Sending record/play/pause/stop etc. to a sequencer supporting mmc/cc
@RickyGWave Hello Ricky......
You will need a midi loopback program so that the midi output of Pd can be sent to the midi input of Propeller, unless you are using osx, in which case I think you can use the built-in midi-settings to loop the midi internally.
Try http://www.tobias-erichsen.de/software/loopmidi.html for windows.
Then you send a midi note from Pd to a named midi output.
You set the midi output in Pd under the Media tab.
In Reason (propeller?) you set the same name as a midi input, and then activate the learn function for the record button. When you send the note from Pd by clicking the message Reason will associate that note with the record button.
David.
PortMidi 'Invalid Device ID'
I have been having this issue (maybe non-issue) for some time.
Here is my set up:
Teensy 2.0 MIDI Device
Pd 0.46.7
Late 2013 Macbook Pro
I am using a Teensy MIDI device in Pd.
If I connect the Teensy device, then launch Pd, I get the following error message:
could not open midi input 0 (Teensy MIDI): PortMidi: 'Invalid device ID'
could not open midi output 1 (Teensy MIDI): PortMidi: 'Invalid device ID'
Under my MIDI settings I have "Teensy MIDI" selected both as my input and output.
If I re-select "Teensy MIDI" in both dialogs of the MIDI preferences menu, and hit OK the same error message will reappear in Pd's print window.
Though I get this error, it seems to not effect the use of the device in any way.
When I connect the device to a windows machine, I don't have this PortMidi error message.
I have also connected this device to my iPhone using MobMuPlat, no issues.
Any advice would be helpful.
MIDI Controller experiences/suggestions
@lovelovevideo Hello again.......... if your computer can talk to to the midi device then Pd will work fine. So the real question is "what usb midi devices will work with your computer".
The most future proof for you will be a usb soundcard with midi connectors, or just a usb midi card...... because then any and all midi devices will talk to it through standard 5-pin din connectors. But if a midi device will talk to your computer then it will talk to Pd.
That was a bit long winded... the question is...... "does my computer have the drivers available........ that work!........... for the device?....."
I don't use midi much nowadays as for control I use the "new midi" called osc. Pd works well with osc and you could try it if you have a tablet. I use this app http://hexler.net/software/touchosc which apart from being very reasonably priced and being available for ios and android (sounds like an advert!) will let you draw toggles buttons sliders and XY pads and more on your tablet.
Musicians still use midi for the notes (better timing) but are increasingly using osc for control....
It is far easier to understand than midi.
David.
Need help to slightly modify a PD project (Rythmboy)
Hello everyone!
I recently stumbled upon a PuraData based step sequencer for my QuNeo MIDI controller, the so called Rythmboy:
http://subtersonic.weebly.com/blog/rhythmboy-a-step-sequencer-for-kmi-quneo
I want to use it as a step sequencer to use with the remix decks in Traktor, so I can add drums to the tracks I play.
Unfortunately, the Rythmboy has an internal MIDI clock, so I can't sync it with an external clock. I already tried to replace the BPM rotary in the patch with "MIDIrealtimein" and the stuff that's also needed, but I can't get it to work.
I managed to do all the other stuff that is needed to work with Traktor (changing the note output, optically mirroring the rotaries, limiting the notes ranges etc.), so I tried, but I don't know how to work with an external midi clock. Another problem that may occur is that the Rhythmboy then needs two MIDI inputs, #1 is the QuNeo and #2 is the external clock (Traktor or my Xone4D mixer).
This is the part of the Rhythmboy that controls the MIDI clock:
The blue box is a tap button to tap in the tempo. This is not needed.
The red box converts a rotary MIDI input between 0 and 127 into a BPM value between 60 and 240 bpm and gives out that value. This is where the changes need to happen I think. I need something that changes the MIDI clock in into a numerical BPM value.
The green box gives output to the rotary LEDs to show the current BPM. This is also not needed.
The other stuff lets a LED blink a metronome, I think.
So, would one of you please tell me what to put in instead of the red box, to make the magic happen?
Best regards,
Spatz