PD <-> DAW interactions tutorials please?
@jameslo said:
for completeness I suppose one should mention using MIDI and audio loopback software,
@parisgraphics said:
I have access to PD on Linux
In that case Jack server is your friend. Get QjackCtl for easy setup and patching. I do such things as control pd patches from my DAW via midi through jack to PD, translate midi messages from my keyboard in PD and route them to my DAW through jack, route audio from my DAW to PD for processing and back again through jack, the possibilities are endless...
DAW's that work for these kinds of setups on linux (that I have worked with): Ardour, Qtractor, Reaper. Rosegarden - there are probably more. For the time being I prefer reaper
@jameslo said:
the flexible MIDI and audio routing capabilities in Reaper seem to make them unnecessary.
I haven't been using reaper for a more than a couple of months, but at least on linux all external routing has to be patched through jack server
Audio click occur when change start point and end point using |phasor~| and |tabread4~|
@Junzhe-hou said:
@ddw_music Hi professor!?!? good to see you here!
Yes, it's me -- I almost didn't notice your username
I read your email last week but im so confused with your
patch--varispeed-segment:|noise~|
|
|lop~ 3|
|
|*~ 30|
|
|+~ 1|
This is just a way to generate a modulator for the playback rate. It could be any other modulator (LFO, envelope, anything).
After that, this is multiplied by a sample rate scaling factor.
As you asked jameslo: "if sample rate (in audio setting) changed the result sound different":
-
If the file sample rate is 96 kHz and the soundcard sample rate is 96 kHz, then normal-speed playback is to move forward exactly 1 sample in the file for every output sample.
-
If the file sample rate is 96 kHz and the soundcard sample rate is 48 KHz, then normal-speed playback is to move forward exactly 2 samples in the file for every output sample. (If you playback at 1:1, then the file will sound slower at the lower soundcard sample rate.)
This was one of the big reasons for me to make [soundfiler2] in my abstraction set. It calculates file_sr / system_sr
and saves this in a value object named after the ID+"scale". If you multiply the playback rate by this scaling factor, then the file should sound correct at any system sample rate.
(BTW you would have the same issue in SuperCollider: PlayBuf.ar(1, bufnum, rate: 1)
will sound different depending on the hardware sample rate, but PlayBuf.ar(1, bufnum, rate: BufRateScale.kr(bufnum))
would sound the same, except maybe for aliasing when downsampling.)
You method "L inlet = rate * scale for sample increment",so is the rate always changing?
Yes -- variable-speed playback.
@jameslo "I'm sorry if I just did your student's homework" -- actually this isn't for my class -- independent project. There are still some students who do hard things just because it's fun to overcome challenges
hjh
Problems with jack on linux.
@bocanegra Thank you, i do hve librewolf (firefox) open, so i want that to work. i installed qjackctl and pulseaudio-jack on my artix (arch based) openrc system. it worked, purr data works, but librewolf audio clips and sounds like crap, i disconnected my usb headphones and reconnected them, but now librewolf outpts no audio, the same with purr data, except it shows up in the graph in qjackctl unlike librewolf which disappeared from there.
i restarted my system just now and jack won't start for some reason, but librewolf audio works fine.
error message in qjackctl:
13:31:47.206 JACK is starting...
13:31:47.208 /usr/bin/jackd -dalsa -dhw:0 -r48000 -p64
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
13:31:47.226 JACK was started with PID=3085.
Could not open component .so '/usr/lib/jack/jack_firewire.so': libffado.so.2: cannot open shared object file: No such file or directory
Could not open component .so '/usr/lib/jack/jack_firewire.so': libffado.so.2: cannot open shared object file: No such file or directory
jack_get_descriptor : dll
jack_get_descriptor returns null for 'jack_firewire.so'
Could not open component .so '/usr/lib/jack/jack_firewire.so': libffado.so.2: cannot open shared object file: No such file or directory
jackdmp 1.9.19
Copyright 2001-2005 Paul Davis and others.
Copyright 2004-2016 Grame.
Copyright 2016-2021 Filipe Coelho.
jackdmp comes with ABSOLUTELY NO WARRANTY
This is free software, and you are welcome to redistribute it
under certain conditions; see the file COPYING for details
JACK server starting in realtime mode with priority 10
self-connect-mode is "Don't restrict self connect requests"
Cannot lock down 107341340 byte memory area (Cannot allocate memory)
audio_reservation_init
Acquire audio card Audio0
creating alsa driver ... hw:0|hw:0|64|2|48000|0|0|nomon|swmeter|-|32bit
ATTENTION: The playback device "hw:0" is already in use. Please stop the application using it and run JACK again
Released audio card Audio0
audio_reservation_finish
Cannot initialize driver
JackServer::Open failed with -1
Failed to open server
13:31:47.348 JACK was stopped
13:31:49.270 Could not connect to JACK server as client. - Overall operation failed. - Unable to connect to server. Please check the messages window for more info.
Cannot connect to server socket err = No such file or directory
Cannot connect to server request channel
jack server is not running or cannot be started
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
JackShmReadWritePtr::~JackShmReadWritePtr - Init not done for -1, skipping unlock
Any help?
Problems with jack on linux.
It's hard to tell without knowing your setup. OS? Hardware?
I run PD vanilla on xubuntu 20.?? (latest LTS) and an external sound card/mixer (cheap behringer). I can get audio both with and without jack
If I set up PD to run just with ALSA (no jack) and I have some other programs running that are using the sound card (like a browser or whatever) PD will tell me:
ALSA input error (snd_pcm_open): No such file or directory
ALSA output error (snd_pcm_open): No such file or directory
However, closing my browser and/or other programs that route sound through ALSA solves this
Using jack instead gives me the advantage of running other DAW software along side PD and route both midi and audio back and forth between them (non jack programs will be silenced), but jack has to be set up properly for the server to run without dropouts (select the correct soundcard, buffer size etc in settings), or even start at all. For this purpose I use qjackctl, which is a GUI control panel for the jack server- should be in your distro's repositories.
The errors you get with jack simply states that the jack server is not running- it has to be started manually. You can do that with a command from your terminal or get the qjackctl software for the GUI (which I reckon you will prefer as a windows convert). Run: sudo apt install qjackctl
from your terminal to install it if you are using a debian based distro (*ubuntu, mint et al)
Pd for Windows with Jack support ?
@jyg What do you want Jack to do for you?
Pd asks the OS for a list of audio drivers and their "pins" at startup..... audio connections in and out..... so you can then select the ones you want to use in the audiosettings menu.
If you want low latency and/or to use multiple devices then Asio4All is a good driver...... http://www.asio4all.org/
It will give you the same function as "aggregate device" on osx.
If you want to pass audio between applications then you can use virtual audio cables.... https://vb-audio.com/Cable/
They and Asio4All will all appear in the audiosettings menu (select asio first) and you can route your audio where you wish.
If you choose to use Asio4All as the driver then you will also see the virtual cables in its window.
You can then route Pd audio anywhere you wish using [adc~ x] and [dac~ x]
David.
Pd for audio processing on low-end hardware
Hi all,
I recently dug out an old Eeepc 701 4G from Asus that I bought second-hand in 2008 - 1-core Intel Celeron inside, with 4GB RAM. I have an audio interface Roland UA22 so that the setup can support realtime audio (Debian 10, RT kernel, jack with RT) with no XRuns and latency <10ms at 44100Hz/128/3. However, obviously, as soon as the CPU is expected to do some calculation, it is much less fun!
In particular I want to use a sampler for some instruments, typically a drumkit connected to MIDI pads, so I wrote a small no-gui Pd patch to load one single wav file in each of 16 clones (for 16 pads) responding to 16 midi notes. I want to keep them in separate clones so that I can assign them to different audio output. Right now it is quite CPU intensive, so I will have to add [switch~] and volume ramps to turn on dsp processing only when the midi note is played and hopefully without clicks.
Further in the workflow, Non-Mixer and Non-Timeline work great for a few tracks, but if I try to record several tracks for several of the drums audio outputs at the same time then the poor laptop is struggling.
TL;DR: Long story short, I'm considering using less fancy mixer and audio sequencer, i.e. command line or Pd patches with no or very basic GUI (no live GUI update as I record for example), BUT I would like to be able to occasionally use some audio effects (reverb, delay and such). Before I get into that, do you guys think that such solution would be bearable for the brave eeepc? Would other languages be more efficient than Pd on this machine?
Or (this is not the right place to ask, but I try anyway) do you know terminal-based utilities that could fulfill this otherwise? I'm thinking of a ncurses mixer similar to alsamixer, or an audio sequencer in the style of CuSE, which would be awesome.
Thanks!
Shared references to stateful objects?
This is how i see it:
┏━ | ━━━━━━━━━━━━━━━━━━ | ┳━ | ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ┓ |
---|---|---|---|---|
┃ | Functional programming | ┃ | Pure Data | ┃ |
┡━ | ━━━━━━━━━━━━━━━━━━ | ╇━ | ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ | ┩ |
├ | Function | ┼ | Abstraction | ┤ |
├─ | ────────────────── | ┼─ | ──────────────────────────────── | ┤ |
├ | Define function in code | ┼ | Create abstraction as separate file | ┤ |
├─ | ────────────────── | ┼─ | ──────────────────────────────── | ┤ |
├ | Call function | ┼ | Send a message to left inlet of the abstraction | ┤ |
├─ | ────────────────── | ┼─ | ──────────────────────────────── | ┤ |
├ | Arguments | ┼ | Input into the inlets and creation arguments | ┤ |
├─ | ────────────────── | ┼─ | ──────────────────────────────── | ┤ |
├ | Return values | ┼ | Output of the outlets | ┤ |
├─ | ────────────────── | ┼─ | ──────────────────────────────── | ┤ |
├ | Local variables | ┼ | $0 in object names | ┤ |
├─ | ────────────────── | ┼─ | ──────────────────────────────── | ┤ |
├ | Recursive function | ┼ | Manual recursion by using [until] outside of the abstraction | ┤ |
└─ | ────────────────── | ┴─ | ──────────────────────────────── | ┘ |
CPU usage of idle patches, tabread4~?
Hi zigmhount!
This is a copy paste of a message I (hopefully) sent via chat as well:
I figured I’d tell you a bit more about my patch so we can see if there’s overlap. Switch is definitely an overlap. I’m not using a metronome at all on mine. The inspiration was two loopers I love: the line 6 DL4 and the EHX 45000. It’s going to be 4 foot switches. Record, play, previous and next. Record and play function the way they do in the DL4. Record to start a new loop, record again to set length and start overdubbing or play to simply set length and start looping. From there record works like overdub on/ off toggle and play stop or restarts the loop. Previous and next are where it gets interesting.
There’s a 7 segment display (meaning a 1 digit number read out) that tells you what loop you’re “focused” on. It starts on 0. You can’t change focus until you have a loop going. Once you do, prev or next change focus. If you change focus while recording, it closes the loop you’re on and starts playing it, then immediately starts recording the next loop. The next loop though can be as long as you want. However, silence gets added to the end of the loop when you are done so that it matches up with a multiple of “loop 0”
In other words, loop 0, acts as a measure length and all other loops are set to a multiple of that measure length.
But...they can start anywhere you want. To the person playing the looper, it will feel like individual loops are all overdubs of the first loop, just at any length you want. I don’t know if I’m explaining this so well, but the point is, you don’t have to worry about timing or a metronome with this. You don’t have to wait for the beginning of measures to start or end loops. Once you have the timing of the first loop down there’s no waiting... you start recording and playing whenever you want as long as you want t and if it’s in time when you play it it will be i the recording.
So far I have recording and overdubbing down on loop 0 WITHOUT CLICKS. this took a lot of work and messing. Sounds like you are struggling with that now. Hardware is important yes.
I’m running it on a rasberry pi 4b 4 gig memory but with a pi sound audio interface. It’s more expensive than the pi but the latency and sound quality are GREAT. I also wanted to make the hardware all independent eventually and have the whole thing fit i it’s own box. The foot pedals run on an arduino that talks through comport to the pi and pure data.
In pure data I’m timing the loops and recording them via tabwrite. I’m then playing them with tabplay with a 0 $1 message box where 0 is start and $1 is the length, rounded to block size, of the recording. I record and play the same arrays for each loop at the same time while overdubbing, but delay the recording so it’s a few blocks back from the tabplay. The delay on the recording seemed to help elimate clocks as well. So did using tabplay instead of tabread 4. I think the phasor is CPU expensive or something. I don’t know. When I start / stop recording I use a line ramp on the volume going into the recording of 5 msecs. This is also necessary to eliminate clicks. Also, I had to stop resizing or clearing arrays as both cause clicks. Now I just overwrite what I need and don’t read from what I didn’t overwrite (If that makes sense).
If you are getting clicking I would try upping block size, buffer size and just delaying the actual recording (delay the audio in the same amount) giving the computer time to think avoids drop outs. Also you don’t want monitoring if you can avoid it. I don’t know if you are using a mic or what.
Hopefully some of this made sense.
[bang~] bangs before the end of a dsp block at startup
@jameslo @Nicolas-Danet has visited this before and posted some insights during his research...... https://forum.pdpatchrepo.info/topic/12390/pd-s-scheduler-timing-control-rate-audio-rate-block-size-sub-sample-accuracy
A probably (but not necessarily) wrong thought.....
...... maybe until dsp is first turned on scheduling is not tied to audio ticks even though there are audio objects in the patch.
Pd being deterministic the events already scheduled (time stamped) before audio is turned on cannot be re-ordered. So the timing of control rate messages relative to the 64 sample window are unpredictable at the moment Pd first syncs audio ticks with the os?
Probably wrong as your patch is idle at load..... unless [bang~] is guesstimate scheduled without sync to the samplerate as dsp is off.
But I see Nicolas has it properly documented above.
David.
Aftertouch last note priority
@Jona said:
and you need Jack to route ALSA MIDI:
aconnect -l
in any terminal will list all available software and hardware midi ports and then you can connect any of them by name or port number aconnect 'Pure Data:4' Blofeld
or aconnect 128:4 28:0
will connect pd's midi out to my Blofeld and aconnect -x
will disconnect everything or just one conenction if specified. Generally this sort of work is just handled by a script, so for me midiup
will check what programs I have open and what hardware connected and figure out how they should be connected . For audio between applications we use the alsa loopback device to create a virtual soundcard to route the audio through using the alsaloop
utility, with a script or through alsa configuration files. Alsa can do a great deal more than most think and often can do it better than Jack, Jack is just intuitive, alsa requires you to study up. The main drawback to alsa is that some applications have dropped alsa support, mainly DAWs, which is odd since they generally have no use for Jack since it is rare for a user to route audio between a DAW and another application, it is all internally connected in the DAW to the various plugins, everything is a plugin and Jack is often a redundant requirement that just consumes.
My setup is as simple as possible, midi controller to USB, alsa, pd, no jack. This problem has persisted through multiple pd versions and two different systems, the only commonalities between them are that both systems are source based and use old fashioned SysV. I have spent a fair amount of time in the past in both the alsa and pd IRC channels trouble shooting this and the best guess so far is that under certain circumstances pd does not clean up properly on shutdown and leaves alsa unable to make a proper midi connection into pd, midi out seems unaffected, aconnect -l shows the midi connection into pd hangs at 'connecting.' When this happens midi still works properly in all other applications, it is just pd and I have not been able to recreate the garbled midi in any other application.
Yes, [max], I have been learning [expr] lately and have become somewhat fixated on it, I often find myself using it for things which pd already offers a simple solution for, but I am getting better about that.
Edit; Forgot to mention, you can automate a great deal of the alsa connection, with the use of udev rules you can have the hardware to software connections made automaticaly when a device is plugged in and you can have a script that starts up all your programs and makes the connections between them, so one command or one click and everything is done for you. This works best for those that always use the same setup, but it can be worked to adapt to changing setups as well.