[pix] + [pix-ds] Draw images directly onto the patch (vanilla)
The abstraction [pix] allows to draw images that are in plain PPM format directly onto the patch. Any image can be converted into PPM using graphic software like GIMP or others. The images are displayed in full RGB color.
There is also [pix-ds], which is much faster, as it uses data structures. It only uses the reduced color space of data structures. [pix-ds] still has a border on the right and bottom. Sorry!
[pix] uses canvases to create the image. Depending on the image size, the number of canvases can get very large and it may take a long time to display the image and also to close the patch! [pix-ds] will run into the same issues. Images will also add up! Use with care!
Due to the limitations of the Pd GUI this is just a nerdy fun project and may not be really usable for a serious task.
Anyhow, enjoy!
Download: pix.zip
PDuino - simultaneous analog input and digital output problems
Hello!
I'm trying to get PDuino working in a setup where I have Arduino reading an analog input and also controlling a relay on the digital output. I have tried the StandardFirmata sketch for Arduino but it doesn't seem to be able to read the analog input with this sketch (it controls the digital output no problem with this however). When I use the AllInputsFirmata instead, it reads the analog inputs just fine but I'm getting no response on the digital outputs.
Is there perhaps something where you can't use analog inputs and digital outputs at the same time? Could I be doing something else wrong? I've tried all the other Firmata sketches that come with the Pduino setup files (out of desperation!) but with no success. Any help greatly appreciated!
FM stacked modulators
@weightless, thank you so much to your patch! It finally shed some light on this whole FM/PM thing. Sorry, but lots of questions coming:
- I spent half a day reading about FM/PM, but it's still not clear what's the fuzz is all about. If FM could be described with these equations:
And PM with these:
While phase and frequency are connected as following:
(Formulas were take from here: https://www.st-andrews.ac.uk/~www_pa/Scots_Guide/RadCom/part12/page1.html)
Isn't it all the same?
I undersand that perhaps in 80's PM was easier to implement, But if math works essentialy the same in both ways, why do results differ?
- In my patch I've used modulation index in range 0-14 as it is shown in Chowning's book (as it correspond to 0-99 of operator output for synth):
I notice, that for PM you are using modulation index in range 0-2 (200/100 right?) and it sounds exactly the same? Could you please explain those numbers?
Once again, thank you so much for your help!
Possible audio file playback methods
@Transcend Ahh..... that is where the confusion arises. What is being read is individual samples.... at 44100Hz sample rate there are 44100 every second. The pitch is heard because of the rate at which they rise and fall in value.
In Pd a sine wave at 100 Hz would have a sample value of zero (maybe, it depends at what time the wave starts) at index 0, and then rising sample values to a value of 1 at sample number 110 (more or less) falling back to a sample value of 0 at sample 220, continuing to fall to -1 at sample 330 and then rising back to a value of zero at sample number 441....... etc. etc.
When those values are read by [tabread4~] the output would....... eventually, once it gets to your speakers..... push and pull the speaker smoothly 100 times a second, and be heard as 100Hz. Depending on the bit-depth of the dac the actual sample values later in the chain will be much larger, but Pd max/min values are +1/-1 at the output to the [dac~]. Your soundcard and Pd take care of that automatically.
If there is another sound, say at 1KHz., that would modulate that 100Hz wave..... it would look like a ripple on the 100Hz wave........ and so on. A music track will look a real mess when you look at it, with only loud / quiet parts really recognisable. But our ears, or more especially our brains, can make total sense of it.
Samplerate (audio) objects are used to set the indexes because they send a value at the samplerate...... so 44100 times a second...... so every single index is sent to [tabread4~]
Digital audio (FFT) is fiendishly complicated to understand, but this gets you quite a long way into it in only a few minutes........ https://medium.com/@djtech42/explanation-of-sample-rate-in-digital-audio-and-breakdown-of-misconceptions-38f912fb3b1f
Actually it gets you a very long way toward a good understanding in just a few minutes.......
David.
dbtorms
@pomolo This needed re-writing.
Dynamic range is meaningless in Pd (or any computer digital processing), in that it cannot be reproduced in the real world. The dynamic range is determined by the ratio of the biggest possible number to the smallest. Even in Pd 32-bit the biggest possible number is massive compared to the smallest.
Of course for FFT the dynamic range is constrained, as it depends on the sample-rate and bit depth.......
https://en.wikipedia.org/wiki/Audio_bit_depth
dB(something) becomes fixed, with real measurable (but weighted) values, when it is measured as sound waves in the air....... and it is fixed then because it is universally agreed that 0dB is the smallest pressure wave that can be heard by a human.
Only then can you define +100dB
RMS..... volts do not "exist" either until the [dac~] does it's work
How you scale the numbers to match your soundcard is up to you.
As Pierre says above 1V = +100dB has been "chosen" as sensible for Pd.
But as we all know, a traditional VU meter will show 0dB as "maximum".... not +100dB.
Hence the dB-100 part of the formula above.
+1...-1 (about zero) is considered safe for [dac~]
If the soundcard sees 1 as max for its conversion to analog all is well.
At 1.00001 it will clip. This value is fixed and known. There is nothing to be done about it.
The dynamic range of your card is not from 0dB to +94dB.
(Well....... it is, but that is what confuses the mind).
Its dynamic range is determined by its noise floor, and your card has a noise floor 94dB "below" the maximum that it can output before clipping.
The dynamic range of your card is from -94dB to 0dB........ if we agree that it will "clip" above 0dB.
So if Pd +100dB is 1 (in fact shown on the VU Gui in Pd as 0dB) then when the Pd Gui shows -95dB any Pd output will be masked by the noise floor of the soundcard....... (or more likely by dither if the soundcard is any good), as the very small numbers cannot be properly resolved, and that results in unpleasant audible artefacts.
And then there is the metering of the soundcard (if it has any).
Because it was traditional to overload magnetic tape, many of the first pro digital systems actually showed 0dB (the max number without clipping) as +18dB..... and showed red bars from +12dB upwards. Trying to make sure you would not clip your recording.
This has most of the info you are looking for I think........
https://sound.stackexchange.com/questions/25529/what-is-0-db-in-digital-audio
As with any analog or digital system you need to know "where you are" with the audio chain before you start work. Set an oscillator into a [dac~] with a VU driven by [pvu~]. You will see 0dB on the meter (1V RMS in Pd).
What does your soundcard show?
Do you need to trim the output of all your patches with a [*~ ?].?
Probably not.
Are there standards
No, not for metering.
If it shows +18dB or +12dB that is probably correct.
0dB on the Pd VU should show as the last bar on your soundcard before the red bars, but the soundcard metering might be lying..... to save you from yourself.
You will only get clipping where the maximum possible value is exceeded.
Volts, RMS or peak, are measures on a linear scale.
But our ears hear "power" and so the dB scale of relative power is a logarithmic scale.
The formula above equates the linear scale to the log scale, but they can "slide" against each other.
Putting an amplifier increases the volts, but how much more volume (dB) you get depends on the efficiency of the speaker...... losses in cables etc.
Only when you have decided 0dB can you say what is 100dB.
Or when you have decided 100dB you can say "how much" is 0dB.
Because it is all relative.
David.
How to synchronize two control signals?
Hey there, I recall from the tutorial that pd uses depth-first when triggering signals and thats what [trigger] is for. Well I'm trying to read keyboard input and I'm piecing together a message that gets passed to [route] but I'm having all kinds of trouble.
When I press a key using this patch, the keydown parameter is late. That is the first message is "shift 0" and the second message is "shift 1".
The next thing I tried is to use trigger on the right (cold) input to pack. However, now I'm receiving duplicate messages. I get "shift 0" "shift 1" when pressing and then "shift 1", "shift 0" when I let go.
A pragmatic solution that seems to work is simply reordering things and using the message box to select the other elements.
This works as expected. The result is "shift 1", "shift 0".
But I'm still a bit confused. I'd imagine that in a more complicated program, this sort of refactoring might not be possible. Or it might be hard to find or debug. So I'm wondering, is there a way to get this all to work without switching the order of the arguments going into pack?
Thanks!
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!