Windowed-sync oscillator: Style questions
@jameslo "Since many programmers seem to want to avoid [fexpr~] at all costs, maybe you could rewrite your [fexpr~] with [expr~ $v1 > $v2] and [rzero_rev~ 0]"
Hmm, yeah. I had thought that both [expr~] and [fexpr~] were said to be bad for performance.
I suppose this might be another way to do a signal-rate comparison:
There's a very small chance of the [-~] result being between 0 and 1e-30, where the clip~ value would be between zero and one but not exactly either. With typical signal magnitudes, that's unlikely, so this wouldn't work in cases where only 0 and 1 are acceptable.
+1 RE the mystifying omissions and irregularities in vanilla. Since I started thinking of it as a scripting language (and stopped comparing it to c, c++, c#, Java...) everything became happy and easy-going.
Yes and no... Pd is an important and valuable tool and it's good to make friends with it as it is. At the same time, lack of some core operators can be seen as a usability issue.
I definitely wouldn't compare it to C and such. Miller Puckette himself acknowledges[1] that many algorithms are straightforward to write in procedural languages (and maybe even more straightforward in functional languages), but rip-your-hair-out painful in dataflow patchers. E.g., quicksort, which in Haskell goes:
quicksort :: Ord a => [a] -> [a]
quicksort [] = []
quicksort (p:xs) = (quicksort lesser) ++ [p] ++ (quicksort greater)
where
lesser = filter (< p) xs
greater = filter (>= p) xs
and in C is... somewhat longer but still a fairly straightforward recursive implementation.
I can literally not even imagine how to implement a quicksort in Pd.
In SuperCollider, I'm doing most of my performances using a sequence-scripting language of my own design, where SC code is parsing the expressions and translating them into SC patterns. That's been a long project but within reach of an object-oriented language with a full suite of data structures. Pd... again, I can't imagine where to begin.
Puckette points out in that interview that Max and Pd are designed to react to input events, and they are very elegant for this. In Pd, you can connect a slider to a number box. In SC, the same is:
(
var number, slider;
w = Window("slider", Rect(800, 200, 500, 400)).front;
w.layout = VLayout(
nil,
HLayout(
number = NumberBox().fixedWidth_(80),
slider = Slider().orientation_(\horizontal)
),
nil
);
slider.action = { |view|
number.value = view.value;
};
)
In that case, definitely, Pd's expression of the idea of a value flowing from an interface object toward the display object is as concise as you can imagine, and SC's version is verbose and puzzling until you get used to it. Use the tool that's right for the job.
lacuna:
There are [vphasor~], [vphasor2~] and [vsamphold~] from @Maelstorm .
Oh that's good.
It's hard to find extensions like this, if you don't know where it is.
In your patch [rpole~ 1] is working with a signal-inlet, isn't it?
Yes. The idea is, while the (signal) coefficient is 1, then the left-hand signal gets integrated. If, for a single sample, both the signal and coefficient are 0, then the output is 0, and it will start integrating again as soon as the coefficient flips back to 1.
Which is that other forum you mentioned?
TBH I think SC wins in terms of clear expression of this synthesis algorithm:
(
{
var sync = LFTri.ar(SinOsc.kr(0.2).exprange(100, 400));
var phase = Sweep.ar(sync, SinOsc.kr(0.12743).exprange(700/3, 2100));
var synced = SinOsc.ar(0, (phase % 1) * 2pi);
dup(LeakDC.ar(synced * sync) * 0.1)
}.play;
)
This is part of what I mean by "usability issues" -- Pd: 7 objects for the triangle wave vs SC: LFTri.ar(freq)
, or the automatic exponential scaling exprange
, and Sweep has a signal-rate retrigger built-in (there's also a range-rewrapping Phasor, and it has an audio-rate trigger too)... SC's initial learning curve is steeper but once you know it well, it took a couple of minutes to write that, vs 30-40 minutes (including head-scratching time) in Pd. (Admittedly I'm less fluent in Pd.)
hjh
[1] https://omny.fm/shows/future-of-coding/47-maxmsp-pure-data-miller-puckette
Windowed-sync oscillator: Style questions
Hi,
The topic of windowed sync oscillators came up on another forum. For fun, and also to improve my Pd chops -- this is what I came up with. (One reason for sharing is that I feel like this is a new level of Pd-idiomatic patching for me.)
I have a couple of questions, below the patch.
-
Is [fexpr~] the best way to check for the phasor reset? With cyclone I could do [rzero~ 1] --> [>~ 0] I think. The goal is a signal that is 1 while the phasor is incrementing, and 0 for exactly one sample when it wraps around. It must be 0 for exactly one sample, because this is used to reset the [rpole~] accumulator (syncing the sine oscillator).
(I've struggled with the lack of signal-rate comparators before. Yes, they're in cyclone, but... aren't these fundamental operators? Why not in vanilla? From past conversations, I gather that often, when a "basic" feature isn't present in vanilla, it's because you can build it from objects that do exist in vanilla. But I never figured out a good way, apart from [expr~] / [fexpr~], to do that for signal comparisons -- which feels like cheating in a way.)
-
The [rpole~ 1] is essentially a phasor with a signal-rate reset (as opposed to [phasor~], which can be reset, but only with control messages). Is there a better way? (Tbh I'm a little bit proud of this one
)
Thanks,
hjh
Ninjam external
When I enter a room I see the metronome and a "sync with vst" button. Perhaps the Jam Taba VST thinks PD is another VST? But when I press "sync with vst" PD crashes (and what should it sync to?). Maybe an external would be the only way to sync Pure Data and Ninjam?
Writesf~ start recording from "grid" possible?
@mariuste Then you will have to adjust (snap) them in the DAW afterwards.
Two two channel files are possible......... synced-record.pd ...... or a single 4-ch if you wish.... 64-ch max I think.
But what is the source? How do you know when the 2nd sound will start. Will you make the sound yourself and so start it at the right time?
Surely you will always be late with the second recording?
I have added a visual aid 2 seconds after you start recording....... synced-record-cue.pd
David.
Rewind and fast forward?
If you want to scrub a file it will need to be loaded to ram.
This will do it and then start at the point you choose.......... av-sync.pd
Vanilla or extended....... delete any objects that throw errors in vanilla (if they annoy you...!).
It will scrub video in sync as well if you have GEM, but you need to strip the audio from the video into a wav file.
It works without the video though...... just load a wav file into the audio block, and then use the video block scrub controls.
David.
PS there was a mistake in [av-sync] now corrected.
Query DSP state?
@jancsika said:
Searching for "biquad" does turn up biquad~ help, but the problem is that the help patch illustrates nothing about calculating filter coefficients.
Try the search again using the settings I gave in the comment under the issue you added to the tracker.
Seen that, thanks.
That Purr-Data for Mac doesn't support GEM is, unfortunately, a deal-breaker.
I'm not sure what your original terms were. Are you in search of
- the most suitable software
- the most suitable free/open source software
- the most suitable gratis software
- something else?
Pd-vanilla plus a few specific external libraries will meet the needs of that course. Purr Data's GUI is more attractive, and the zoom feature is extremely useful in the classroom, but these are not critical. The ability to use GEM or Ofelia on Mac, Windows and Linux platforms is critical for me.
I suppose really "the most suitable software" is Ableton Live + Max4Live. But I can't in good conscience require students to use a specific commercial software package when I know, practically speaking, most of the students here will not pay for it. So FLOSS is preferable, yes.
But that's not really relevant to the comment. The point is that Purr Data is, unfortunately, not currently suitable for multimedia on an OS platform that is widely used for digital arts, while Pd-vanilla is.
hjh
Save Settings Not Working PD_Vanilla
@flagpuppy On my Windows7 machines they are stored here.......
Vanilla and Extended stored separately in the following locations (Windows 7)........ Pd and Pd-extended folders in each address.
HKEY_CLASSES_ROOT\VirtualStore\MACHINE\SOFTWARE\Wow6432Node\
HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE\Wow6432Node\
Here the "big string" will be different for your machine.....
HKEY_USERS\......big string......Software\Classes\VirtualStore\MACHINE\SOFTWARE\Wow6432Node\
This one twice...... probably last known good, and?
It could be the same for Windows8.......?
I do not have Vanilla "installed".... I have many versions just sitting in a folder on my desktop, and the settings in the registry at those addresses are applied to all of them when any one of them is changed.
The prefs are put there by Windows....... google "UAC Virtualization" for more info..... which might help you resolve your problem........ https://blogs.msdn.microsoft.com/oldnewthing/20150902-00/?p=91681
It could be that you did not remove a block that was automatically put on your Pd folder by Windows8 when you downloaded the Pd program. Right-click the folder after it is unzipped and "unblock" might work.....?
Also..... check the security permissions for pd.exe (in pd/bin).
David.
Which version for an absolute noob?
@CrouchingPython Pd has midi output...... and you could connect an external synth and select it from the Pd "Media" "Midi Settings".
But if it is a software synth on your computer then you need to loop-back the output of Pd to the input of the software synth.
In Windows you could use loopMIDI........... http://www.tobias-erichsen.de/software.html
Open it and set up a loop (there could well be one opened straight away by loopMIDI..... then open Pd and connect to it....... and open your software synth and connect to it.........
Widows10 might still have "Microsoft GS Wavetable Synth" still built in, but some say it doesn't work and Google will find you plenty of free and better ones.
The Arturia is a controller...... it outputs midi messages the same as Pd....... and still needs a synth (something to make the sounds when triggered by midi messages).....
David.
Build a MIDI controller with the Arduino, Firmata and Pure Data
Time to start contributing some knowledge back to the wonderful world that is the internet; today, a step by step nice and easy tutorial on getting started to building your own MIDI controllers with the arduino.
When researching for my ableton controller project, I didn’t find much out there about using firmata on an arduino to send data to software. The standard approach just seemed to be create the code in the arduino language, upload it to your board and hack one of those MIDI to USB cables as a bodge job way of getting the MIDI out of the arduino.
So why firmata and pure data? Well the whole idea of firmata is that you flash it to your arduino, and it throws out serial about whats going on with the arduino inputs and outputs, then you decide how the software treats the readings coming in and going out.
Theory out the way, lets build some controllers. You’ll need a few things…
HARDWARE:
An arduino and something to wire into it (for this i’ll be using a pot)
A USB cable for your arduino
SOFTWARE:
Arduino – http://arduino.cc/en/Main/Software
Pure Data – http://puredata.info/downloads
Firmata – http://at.or.at/hans/pd/objects.html#pduino
Something to patch your new controller into; like Reason or Ableton Live
- SETTING UP FIRMATA AND PURE DATA
Install Pure Data and create a folder to store all your patches somewhere. Unzip Firmata and add the files ‘arduino.pd’, ‘arduino-test.pd’ and ‘arduino-help.pd’ to your new Pure Data folder. The ‘arduino.pd’ file is the object that we use in PD for opening up communication with your arduino and routing it to PD. Done? Awesome, your software is almost set up.
- FLASHING FIRMATA TO YOUR ARDUINO
Install the latest version of arduino and open it up. Connect your arduino with the USB cable to your laptop (i’m using a macbook for this by the way). In the example patches, open up “Standard Firmata”, select your board (im using an arduino mega), and your serial port (look for tty.usbserial for use with a USB cable). Then compile and hit the upload button and your arduino is now ready to use firmata and communicate with Pure Data!
- WIRING UP A POT
Potentiometers are cool, and theres a great arduino tutorial of how to wire one up here: http://www.arduino.cc/en/Tutorial/Potentiometer
Basically, all you need to know is that there are three pins; your two outer pins govern voltage flow across the pot, meaning one has to be 5V and the other has to be ground. It doesn’t matter which, but your 5v pin is going to be where your pot reads maximum, so convention dictates this should be the right hand pin. The center pin needs to be connected to an analog in on the arduino and will read the value of the pot as it sweeps from ground (0v) to 5v.
All wired up? Plug it into your laptop and open Pure Data, we’re ready to get things talking.
- SETTING UP OUR PATCH
Open the example “arduino-test.pd” Pure Data patch you copied over earlier. It should look like this one…
The test patch has everything we need to open a connection and enable pins. Firstly, lets delete a bunch of stuff and make our window a bit bigger. Hit Command + E to enter edit mode in Pure Data.
Ok a quick explaination; the key component here is the ‘arduino’ object. This is being drawn from the file you copied in earlier, and is what communicated with your arduino. Here we can do everything to control the arduino from opening a connection, to receiving data.
The large grid allows us to set the mode of each pin on the arduino. Remember pins 0 and 1 are reserved for Rx and Tx. I’m using analog pin 4 for this demo, so I’ve set my pin mode for pin 4 to ‘analog’.
Now we can plug our arduino in and get a reading from the potentiometer.
- ARDUINO INTO PURE DATA
With your arduino plugged in, hit command and E to bring us out of edit mode. In our patch, click on ‘Devices’ above the arduino object and open up the pure data terminal. (That other thing that loads with PD that has all the scary code in)
The “Devices” message connected to the arduino object pings your computer to find what devices are connected and on what serial ports. Since we’re using a USB cable to connect our arduino, we’re looking for something with ‘usbserial’ in it, in this case; port 2.
Select the relevent port in the green box at the top (remember the first box is ‘0’, second is ‘1’ and so forth) and hit ‘Open’ to establish a connection. Check the terminal to see if the connection was sucessful.
Now lets check we’re getting something in. Create a number box (Command + 3) and connect it to the relevent pin on the ‘Route analog’ box at the bottom. In this case, pin 4.
One more thing; if you’re not getting any readings in, you’ll need to click on ‘pd old analog/digital controls’ and enable your pins here too. What I tend to do in my patches is just not include the large grid but make my own ‘old pd’ controls custom to what i’m enabling/disabling to save space.
Here’s what the ‘old analog/digital controls’ subpatch looks like (pin 4 enabled)…
Come out of edit mode and check that you’ve got readings. If so congratulations! If not, troubleshoot, start with making sure your usb connection is opened, make sure all the correct pins are enabled (remember you’re counting from 0 not 1 on most of these buttons in PD, it’s just the way computers work).
- SCALING READINGS TO MIDI
So we’ve got a reading and chances are it’s to 3 decimal places between 0 to 1. No problem, create a new object (Command + 1) and type “autoscale 0 127”. This allows us to scale the input to a min and max value, in this case 0 to 127 of MIDI. Next, lets get things looking nice, create a new object and type “knob”. Connect this AFTER the autoscale object. (the knob is default set to read inputs from 0 to 127. Then create another number to display the scaled MIDI data coming out, and finally a new object and type “ctlout 1”.
It should look something like this…
The second box should be outputing values from 0 – 127 now, and the knob giving a visual representation of your potentiometer.
Now lets patch it into ableton…
- PURE DATA TO ABLETON LIVE
Firstly, you’ll need to set up your macs IAC driver if you’ve not done this. Basically you’ll need to go into Audio/MIDI preferences and enable your IAC driver. Then create a new input and output. One for input to DAW and one for output from DAW. Google around for a tutorial on this, its really simple, a 30 second job.
After you’ve set up your IAC driver, go back to PD and go to preferences > MIDI Settings, and connect your IAC driver.
Open ableton and go to its MIDI preferences. Create a device listing for your IAC driver and enable its ins and outs into ableton like so…
And thats it! Create an instrument and try to assign something! I’ve got it controlling the brightness of a bass sound here.
Shout out for Facu who requested this tutorial. Hopefully it’ll help some of you looking to get into this stuff and start building things but with no idea where to start.
Cyclone library stopped suddenly loading (PD Vanilla/Windows 10)
@LiamG @ilpoj
As I suspected, the startup preferences are stored in the registry.
It is likely that windows 10, pursuing the same lockdown techniques as OSX, is not allowing Pd to write to the registry. Google might get you further than this forum.
Everything..... paths, startup options, libraries to be loaded, audio and midi options are stored there.
If you cannot load libraries, or save your settings then that is because you cannot write to the registry.... it's part of the same problem.
I can post my settings that you could paste into your registry (and then modify) if you wish.... obviously at your own risk!........ but first.....
You can right-click the folders in the registry and change permissions.... which should be a zero risk.
Open Regedit and find the key folders listed below and check their permissions.....
You might need to open regedit with admin permissions.
You could also try opening Pd with admin permissions and trying to install cyclone and set paths, but I think it is wish85.exe that accesses the registry.
Vanilla and Extended preferences are stored separately in the following locations (Windows 7)....
HKEY_CLASSES_ROOT\VirtualStore\MACHINE\SOFTWARE\Wow6432Node\Pd
HKEY_CLASSES_ROOT\VirtualStore\MACHINE\SOFTWARE\Wow6432Node\Pd-extended
HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE\Wow6432Node\Pd
HKEY_CURRENT_USER\Software\Classes\VirtualStore\MACHINE\SOFTWARE\Wow6432Node\Pd-extended
This one twice...... probably last known good, and?
HKEY_USERS..."long string" ... Software\Classes\VirtualStore\MACHINE\SOFTWARE\Wow6432Node\Pd(and Pd-extended)
The "long string" will be different to mine on your machine.
@LiamG The garbled paths can be corrected and saved again....... which usually solves the problem.
That seems to be particular to Vanilla.
David.