how to use serial data sent with header and footer and comma delimiters
OK. So, I asked the wrong question. How do I take a stream of values coming through the serial port and format a list?
I receive the value 104 which is encoded h
Then an encoded digit, lets call it $1
Then an encoded digit, lets call it $2
Then the value 44 which is a comma
Then an encoded digit, lets call it $3
Then an encoded digit, lets call it $4
Then the value 102 which is f
Stream looks like this and f is a float variable.
104
f
f
44
f
f
102 over and over
I know I can take ($1 - 48) x 10 + ($2 - 48) = sensor value x
($3 - 48) x 10 + ($4 - 48) = sensor value y
How do I make a list like reactivision or hid? So I can use route? I know this is alot to ask about with the little understanding I have, so I am extra grateful for any help.
how to use serial data sent with header and footer and comma delimiters
If I understand correctly, you want to break apart a complex symbol and access the values inside. There's no perfect method for doing this, but it is possible. Here are some options:
-
If you don't mind using externals, you can use Zexy's [symbol2list] to convert the symbol into a list of characters. You need to loadbang the right-hand inlet with [symbol( so that this will work. I'm not sure how this will respond to the commas, but with any luck you will get "list h 6 2 /, 5 6 ..." which you can then unpack. You'll then need to recombine the the 2nd and 3rd digits to get the original number.
-
If this doesn't work, then you can use [list fromsymbol] to convert to ASCII characters. After isolating the correct digits, you'll then have the fun of converting them back to the original values.
In either case, one thing that will have a big impact on the complexity is, do the numbers always correspond to the same digits? Ie. will you be getting symbols that look like "h2,141fh.." , where the first number is only 1 digit long and the second is 3, as opposed to the 2 and 2 in your example? If so, then you'll probably need to iterate the list and calculate the placement of the values based on delimiters, ie. "the first number begins after 'h' and ends before the comma; the second number begins after the comma and ends before the 'f'". Difficult, but not impossible.
all possible permutations with repetitions of harmonic volume from top to bottom
This version generates every combination directly from the previous one and is therefor in theory only limited by computer memory. On my computer it generated all 823543 combinations of 1 2 3 4 5 6 7 within a few minutes.
It can output the results in variable length, which can be set via creation argument or right inlet. If no length is provided, the results will have the same length as the original.
-
Input: abc
Output of [combinations]:
aaa, aab, aac, aba, abb, abc, aca, acb, acc, baa, bab, bac, bba, bbb, bbc, bca, bcb, bcc, caa, cab, cac, cba, cbb, cbc, cca, ccb, ccc -
Input: abcd
Output of [combinations 2]:
aa, ab, ac, ad, ba, bb, bc, bd, ca, cb, cc, cd, da, db, dc, dd -
Input: ab
Output of [combinations 4]:
aaaa, aaab, aaba, aabb, abaa, abab, abba, abbb, baaa, baab, baba, babb, bbaa, bbab, bbba, bbbb
The right outlet sends a bang when the generation is complete.

combinations.pd
combinations-help.pd
How it works:
Internally, the patch uses lists of numbers 0, 1, ..., n-1; n being the length of the original list. These numbers serve as digits of an n-ary system. It starts with a list of zeros. The digits of each list are send to the right branch (output) and the left branch (iteration) of the patch.
At each iteration, one is added to the first digit of the list. If the result equals n [mod] sets it to zero and [div] takes the carry-over (1) to the next digit. If there is still a carry-over after the last operation, meaning that the current combination is the last one, the spigot is closed and it stops.
Before the output, the internal digits of each list are replaced with the numbers or symbols of the original list. Zero is replaced with the first element, one with the second and so on.
After each iteration a delay 0 is used to brake the loop and avoid stack overflow.
Uses [list-drip] from list-abs extension.
Playing sound files based on numbers/sets of numbers?
@whale-av Hello again, thank you very much for replying so quickly!
Ok so, the computer will always be a PC and will always have Pd installed so that makes things a lot easier I suppose (not sure what version it will be though, but since all those computers have only recently been equipped with Pd I'm assuming it's either vanilla or extended so it should be ok).
I just put my 17 sound files in the same folder and named them 1.wav ...... 17.wav. They are in the same folder as your patch now too.
Well, the numbers are not exactly "set", in fact, each sound file corresponds to a certain range of numbers. Ugh, I did it again, forgot to mention the range... Sorry..... I'd probably need a different object for a range... It's still kinda difficult for me to think in "computer" language about things related to music so that's why I'm forgetting to mention tons of stuff, but I'll try to fix that in this reply, sorry again!
I will just post the table to make it easier for you to understand.
But first, I would just like to explain how the table works. First I need to ask if it's possible to attribute the same numbers/range to different sound files, depending on the number's "place" within the combination? (You'll understand once you see the table.) Maybe it isn't and in that case I should think of a way to change the table according to what can be done?
So, there should be 13 numbers in total within the combination (13 numbers to type, like 13 empty slots waiting to be filled with numbers), but I said there are five sub-combinations. The first, second and fourth are 2 digit numbers, the third is a 3 digit number and the fifth is a 4 digit number. Obviously, three of these are 2 digit numbers, but the thing is I can't really choose the ranges (I have a set range for each sub-combination and can only try to figure out the easiest way to work with them) and the ranges are actually intertwined, So some numbers can be repeated, that's why I'm asking if the same numbers can be attributed to different sound files based on whether it's the first, second or fourth sub-combination. If that's too complicated or even impossible, I can only think of sacrificing a couple of sound files and just let the program play the same file twice instead.
Also important: is it possible to "condition" to program into playing a sound file based on the first combination, the first 2 digit number? Simply put through simple chords, say in the first combination you can type either 01 or 02, where 01 is A major and 02 is B major. Next, you can type in either 02 or 03, where 03 is E major (irrelevant right now), but 02 can be either D major or F sharp major (not A major like in the first combination), based on what the previous number was. If it was 01 (A major), then this time 02 will be D major, but if the first number was 02 (B major) then the 02 in the second combination should be F sharp major. IS something like this even possible, or do I need to figure out a way to go around this and alter my table? I CAN alter the table, but I can't work with the ranges of the combinations, or the number of the combinations, it must be 5.
Lastly, can different numbers be attributed to the same sound file based on their position within the combination?
Ok so finally here's the table, and I will just give you my current table so you can tell me if it's possible to do. I understand if it's too complicated and I need to change it! Maybe you can give me some tips on how to change it to make it the easiest to do in Pd.
1st SUB-COMBINATION
01-19 - 1.wav
20-22 - 2.wav
23-31 - 3.wav
2nd SUB-COMB.
01-03 - 4.wav (if the first was 01-19 or 20-22; or shorter, 01-22)
01-03 - 5.wav (if the first was 23-31)
04-06 - 6.wav
07-09 - 7.wav (if the first was 01-19)
07-09 - 8.wav (if the first was 20-31)
10-12 - 9.wav (if the first was 01-19)
10-12 - 10.wav (if the first was 20-22)
10-22 - 11.wav (if the first was 23-31)
3rd SUB-COMB.
900-975 - 4.wav (if the first was 01-19)
900-975 - 2.wav (if the first was 20-22)
900-975 - 12.wav (if the first was 23-31)
976-999 and 000-020 - 1.wav (if the first was 10-22)
976-999 and 000-020 - 13.wav (if the first was 23-31)
4th SUB-COMB.
01-09 - 7.wav (if the first was 01-19)
01-09 - 8.wav (if the first was 20-31)
10-69 - 14.wav (if the first was 01-19)
10-69 - 3.wav (if the first was 20-31)
70-99 - 6.wav (if the first was 01-22)
70-99 - 11.wav (if the first was 23-31)
5th SUB-COMB.
(this one is arbitrary so no matter what the last 4 numbers are, the sound file that is triggered should be based on the first combination, or something like that, so...)
xxxx - 15.wav (if the first was 01-19)
xxxx - 16.wav (if the first was 20-22)
xxxx - 17.wav (if the first was 23-31)
Now, I need to thank you if you had the patience to actually read all that and think about it..... I can only hope you could understand the idea, but please, if this is just too complicated, do tell me to change the table. Maybe, if you can or think I will understand, try to explain how the ranges work when playing sound files and how I can use that to my advantage to still keep all the sound files (or as many as possible) but make the thing easier to program.
Now I know I had a few more questions but I can't remember right now and I don't want to bombard you with everything all at once, I realize even this is way more than I could have asked for, you have been a huge help, really! Even if I don't entirely understand every single element of your patches, I did study them and used the help option like you advised me to, so I really am trying to get the hang of this. I completely understand if you just want to take a break from this if it's too complicated and time-consuming, I just ask that you give me some kind of feedback so I know what to expect!
Anyway, thank you for all your help and guidance until now, and for the guidance you'll provide in the future if you so choose!
Playing sound files based on numbers/sets of numbers?
@Alexita Hello again. You don't absolutely need abstractions, but they make the building of the patch much quicker (a lot less typing). Putting 2 or 3 digit numbers is more difficult.... I will think about that. Stopping with a second enter will be possible.
The patch is already able to play only a selection of the 17 tracks...... although they must all "exist".
If the tracks are in the same folder as the patch the paths are not necessary, so it becomes much more portable.
But portable on a flash drive means putting Pd on the flash drive as well (in a portable format), and the tracks as well........ so a big enough flash drive. I am assuming that the computer the flash drive will be plugged into will not have Pd already installed. Will it always be a PC? or a Mac? or Linux? Or will it have some flavour of Pd installed already? That would be useful.
It will be much easier to build with abstractions if the tracks are named 1.wav, 2.wav, 3........ 17.wav.
What are the two, three and four digit numbers? How do they choose between the 17 files? 1-17 is easily understandable. Can you post a "table" of what they should be........ like?
1 - 33
2 - 41
3 - 123
4 - 18
5 - 6072
or is there supposed to be some sort of a random function...... where you are not really selecting at all? The task makes no sense to me with this requirement (at the moment). You would need to remember the 17 large numbers!
I will post an abstraction version, assuming all of the tracks in the same folder. A "sub" folder is easy as well (for the tracks).
............................ 17 tracks with loop abstractions.zip ...... now in "loop" mode already when it starts.
I have added metering, just for fun.
You must put 17 tracks named 1.wav ... 17.wav in the same folder.
The keyboard numbers 1 - 9 will work (for the moment, and for the first 9 tracks)
David.
PS..... looking for a pattern...... anyone?
Assuming...... only keys 1-9 or 0-9 used.

Of course! It's easy......... if 0 is not allowed
2 digits..... minimum total 2 max 18........ range 17
3 digits......minimum total 3 max 27........ divide by 1.5 and subtract (about) 1........ range 17
4 digits......minimum total 4 max 36........ divide by 2 and subtract (about) 1........ range 17
Need to round up or down..... look at results.....
For now.... 17 tracks loop enter start stop.zip starts and stops (stops tracks dead.... should the sequence complete?) with enter.
David.
Playing sound files based on numbers/sets of numbers?
@whale-av Hello, first I just want to say thank you very much for your help and sorry for not replying sooner, I read all the messages, I just didn't want to bother people before I had an actual issue or a question that I understood enough to know how to ask what to do next. So that's why I'm only replying now. And you're totally right, I have suffered and learned in the past day so my brain's kind of all over the place right now, I'm still struggling to get the hang of this and really understand the patches you sent me (thank you so much for taking the time to make them for me!).
To answer your questions, I will not be assessed for this part of the project, it doesn't matter much how I do it as long as it works because no one will look at the project anyway, the end result is what matters in this case. The only "limitation" is that it has to be done in Pd. Also, my version of Pd is Vanilla (I'm assuming that doesn't change your patch much since you said it'd work in that version), and actually no, there's not really a next stage to this project; all I'm supposed to do is get my sound files to play in a loop when I press Enter (after I've typed all my numbers) and to be able to stop the loop again with Enter. I probably should have mentioned that oops, does that mean I need another keyup object or would the one in the patch work for both starting and stopping the sound?
I actually had a patch of my own but it was very simple and mostly improvised based on what I managed to learn (like I said, completely new to this) and nothing like yours so it probably wouldn't have worked anyway... Is it ok if I use your patch as a starting point? If it is, I'm assuming the next step would be the abstractions. From what I understand, abstractions are used for referencing and reusing old patches in order to keep the new patch clean and not messy. I do need something like that, as I have 17 wav files ready to use. But not all 17 should be used in one loop. I actually only need 5 sound files per loop (like in your patch), but the total number of files I can choose from is 17. To be able to tell the program which file to play based on its corresponding number I probably need the select object, right? Would I need it within the calling patch or the patch being called, a.k.a. abstraction (if my thinking is right, it's probably the calling patch)? There's probably an easier way to do this than an x number of select objects but I'm just not familiar enough with the program, sorry... Also, what difference does it make if it's not 1-digit numbers, but 2-digit, 3-digit and 4-digit combinations? To be more precise, the first, second and fourth sound file should correspond to a 2-digit number, the third to a 3-digit number, and the fifth to a 4-digit number (and I can't change this unfortunately, it's part of the task).
Oh, and is there a way I can make this work on any computer, for example if I copy my files onto a flash drive? Or if I can't, would it drastically affect my main patch if I changed the sound file destinations later, once I know what computer is going to be doing all this? Would I need to change the file destinations in all the patches or would it be possible to do so automatically via abstractions, by changing them in the main patch only (probably not but eh I asked...)?
This is all probably waaay too advanced for a beginner (and I have no idea why they'd give me this task without any prior preparation.......) so I realize I might be asking for too much here, and maybe I'm getting ahead of myself, but I still hope you could give some advice on what to do from here, what's the next step, the elements I need to get this done etc. I'm not in too much hurry, I have time until the 5th of February, so it's ok if you don't have the time for me right now, I can wait a bit!
Thank you so so so much, even just sending me the first patch was such a huge help, thank you! And I hope you can guide me through this for a bit longer!
Book on Pd and Arduino just published
Hi all,
After a long time of hard and intensive work, my first book, 'Digital Electronics for Musicians' is out!
The book focuses on Pd patching and Arduino programming, and in the communication between the two platforms, creating musical interfaces. Some projects incorporate embedded computers, focusing on the Raspberry Pi, but giving generic information on this subject. Hopefully some people will find this helpful and fun!
http://www.apress.com/9781484215845?gtmf=s
On Amazon you can have a glance at some of its contents!
http://www.amazon.com/Digital-Electronics-Musicians-Alexandros-Drymonitis/dp/1484215842/ref=sr_1_1?s=books&ie=UTF8&qid=1450708668&sr=1-1&keywords=digital+electronics+for+musicians
Considering implementing libPD in a couple of game engines I use and have a couple questions.
@TerraByteTech said:
How difficult does it tend to be when it comes to implementing something like libpd into a 3d game engine with 3d sound.
Kind of hard yes (read below)
Would I have to implement it as a complete replacement of the existing audio engine or is it somewhere along the lines of plug-and-play?
Libpd doesn't handle the audio driver (no sound is coming out of libpd without an audio driver like portaudio so you need to plug libpd in the game engine AFAIK).
Can I use my existing PD patches and just add special bindings for it to be called by libPd or do i have to rewrite them as scripts?
Yes you can use the same patch, see this my tutorial:
http://www.workinprogress.ca/libpd/

Will I need someone more experienced than myself to make a proper implementation of libpd in these engines? (My programming experience is primarily in Python and visualbasic .NET (oh god, i can hear the negative comments coming already). I have a basic understanding of C and C++ but only good enough to look over code and sort of understand what's going on. I'm planning on taking a computer sciences course next college semester but i'm pretty certain that will not be enough for me to get anything serious done as far as implementation.)
Very much like so, but it's doable see my bridge of libpd to unity:
https://github.com/patricksebastien/libpd4unity
Cheers~
Considering implementing libPD in a couple of game engines I use and have a couple questions.
So, I use Blender Game Engine (written in C, uses python for scripting) for pc game development and Godot Engine (written in C++ and has an "easy to use" C++ API along with its own scripting language [gdscript]) for some pc games and mobile games.
I have a few questions about functionality and implementation.
- How difficult does it tend to be when it comes to implementing something like libpd into a 3d game engine with 3d sound.
- Would I have to implement it as a complete replacement of the existing audio engine or is it somewhere along the lines of plug-and-play?
- Can I use my existing PD patches and just add special bindings for it to be called by libPd or do i have to rewrite them as scripts?
- Will I need someone more experienced than myself to make a proper implementation of libpd in these engines? (My programming experience is primarily in Python and visualbasic .NET (oh god, i can hear the negative comments coming already). I have a basic understanding of C and C++ but only good enough to look over code and sort of understand what's going on. I'm planning on taking a computer sciences course next college semester but i'm pretty certain that will not be enough for me to get anything serious done as far as implementation.)
I really need libPd for the current projects since there's no procedural audio or sequencing system in these engines i'm working with.
Thanks in advance.
Digital waveguide
Hi
I've been using a patch for a digital waveguide I found to try and build my own
I've just realized that the delay lines he made are bi-directional, so they include both the left and right traveling waves. In the patch I have connected both delay lines up via a scattering junction, as this is the only way I can select input and output position.
Basically I want to be able to select the output out of the same delay line that I am able to select the input, as I only want to model 1 string, not the sympathetic resonance and output of one string which is excited by another.
I have included bits of description in the patch, basically the left hand side is the waveguide I can select input position for, but I also want to select the output position for the same one, therefore not needing the scattering junction or a second waveguide
Any help would be greatly appreciated
(ps i haven't sorted out the loadbangs properly yet, so values for top and bottom filters, waveguide lengths and filter values need to be put in before it will make any sound, sorry)
Thank you
http://www.pdpatchrepo.info/hurleur/Digital_Waveguide_Pd.zip




