ALSA output error (snd\_pcm\_open) Device or resource busy
Sorry to necro this thread, but I finally found out how to run PureData under Pulseaudio (which otherwise results with "ALSA output error (snd_pcm_open): Device or resource busy").
First of all, run:
pd -alsa -listdev
PD will start, and in the message window you'll see:
audio input devices:
1. HDA Intel PCH (hardware)
2. HDA Intel PCH (plug-in)
audio output devices:
1. HDA Intel PCH (hardware)
2. HDA Intel PCH (plug-in)
API number 1
no midi input devices found
no midi output devices found
... or something similar.
Now, let's add the pulse
ALSA device, and run -listdev
again:
pd -alsa -alsaadd pulse -listdev
The output is now:
audio input devices:
1. HDA Intel PCH (hardware)
2. HDA Intel PCH (plug-in)
3. pulse
audio output devices:
1. HDA Intel PCH (hardware)
2. HDA Intel PCH (plug-in)
3. pulse
API number 1
no midi input devices found
no midi output devices found
Notice, how from the original two ALSA devices, now we got three - where the third one is pulse
!
Now, the only thing we want to do, is that at startup (so, via the command line), we set pd
to run in ALSA mode, we add the pulse
ALSA device, and then we choose the third (3) device (which is to say, pulse
) as the audio output device - and the command line argument for that in pd
is -audiooutdev
:
pd -alsa -alsaadd pulse -audiooutdev 3 ~/Desktop/mypatch.pd
Yup, now when you enable DSP, the patch mypatch.pd
should play through Pulseaudio, which means it will play (and mix) with other applications that may be playing sound at the time! You can confirm that the correct output device has been selected from the command line, if you open Media/Audio Settings... once pd
starts:
As the screenshot shows, now "Output device 1" is set to "pulse", which is what we needed.
Hope this helps someone!
EDIT: I had also done changes to /etc/pulse/default.pa
as per https://wiki.archlinux.org/index.php/PulseAudio#ALSA.2Fdmix_without_grabbing_hardware_device beforehand, not sure whether that makes a difference or not (in any case, trying to add dmix
as a PD device and playing through it, doesn't work on my Ubuntu 14.04)
PD-2-ThoughtMap (a patch and its children as a plantuml-usecase) (Linux Shell Script/Package) (v0.1.1 update below)
Background:
The project I have been working on, for over a year now, began to be more complex than I was able to visualize.
As such, I was required to build something which would allow me to "see" it in its entirety.
NOT the audio stream, passing from one object to another, nor the variables, nor sends.
But rather, I needed to see my objects, i.e. subpatches and abstractions themselves. And how they were embedded within one another. I needed to see the "programmatic-flow" from one sub-object to the next.
Which is how this came about. Examples:
simple example
1.poly.synth
Preface:
Miller's bi-recursive/toroidal loop function, i.e. going "../" up and/or going down "/x/y/z.pd" the embedded object-tree has (thus far eluded me. So the patch for now only recurses down the tree.
Purpose:
By setting up a "Send-To" link to ".pd" filetypes (within Linux), one is able to right-click and send any ".pd" file to the pd2thoughtmap shell script and after a brief time (depending on the complexity of the patch). the "defaultbrowser" will open with a plantuml (http:///www.plantuml.com) usecase diagram showing the "object-flow" from one nested object to the next (clipping branches which have no embedded abstractions).
My hope has been the benefit I have/can gain from this tool, will also benefit the pd community and folks in being able to better "see" what they have done. And how to better organize their patches to suit their vision, the need of the project, or just plain Efficiency.
Instructions:
1-Download the pd2thoughtmap.zip file: pd2thoughtmapv0.1.zip
2-Unzip the file into the /root/pd-externals directory;
3-Right-click on a ".pd" file and go to ~"Configure Send-To" or the equivalent for your linux system;
4-Symlink from the /root/pd-externals/pd2thoughtmap/pd2thoughtmap shell script to the Send-To folder for ".pd" files
5-Right-click on a .pd file and "Send-To pd2thoughtmap";
6-After a pause, your default browser will open with the thoughtmap in a tab. (If your browser is already open it will just open another tab).
note: file processing is managed in the /tmp/pd2thoughtmap folder so unloaded at shutdown.
May this tool expedite your auditory "vision" and make it easier for you to comprehend.
Peace, Love, and Music through us all,
Scott
Footnotes:
It recurses down (the directory-tree finding descendants) just fine but will not go up (find predecessors/ancestors).
It will not recurse abstractions if the filenames have more than one period (i.e. the one in the ".pd" suffix).
It Excludes native pd abstractions/classes, ex. [adc~], etc., if they are 1) on the res/objectlist.txt, 2) a ".pd_linux" file in the pure data paths, i.e. "/root/pd-externals/", "/usr/lib/pd/extra/", or "/usr/lib/puredata/". or 3) manually entered into the "res/exclude.txt" file (in the case where one abstraction is repeated many times and you want to ignore it).
If using the command line, there are four total parameters available (to be used all together): $1=the absolute path to the file, $2={0|1|2,3} to indicate if you want "abs and subpatches", "abs only", "subpatches only", or all pd object types, ex. messages, floatatoms, etc; and $3=the height of the image in pixels, and $4=the width of the image in pixels.
If you want me to debug something, please, attach the outputted .png and the /tmp/pd2plantuml/log.txt to your post.
If you find it outputting things that should have been excluded, you can try to eliminate them by adding the object name to the exclude.txt file. This inconsistency is derived from my complete knowledge of the pd file structure. Perhaps I will address it in the future.
I need to work on the original patch for a while, so will update this patch over time and get back with you when I can.
Tally-Ho! And Joy!
-S
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!
Pure Data noob
Ok...... So I have been meaning to do this for a very long time......
I don't think it is the perfect "show_me_dollars" and so I will change it from time to time.
3rd attempt.........
show_me_dollars.zip
Here is a really terrifying screenshot, but I have also tried to explain it in words.
In many ways I think words ( below the screenshot) are easier to understand.
David.
Dollar $ variables in Pure Data patches.
A dollar variable is a thing that can be given a new value.
The new value can be a float or a symbol.
- If the Dollar variable is in an [object] box
A Pd patch can be saved and used inside another patch. We then call it an abstraction.... and it is just like a programming sub-routine.
If you want to use it many times then you have a problem, that they are all the same, so if you put an object [receive woof] they will all receive any message that you send with [send woof].
That might well be what you want to do.
But what if you want to send the message to only one of them?
You can give it an [inlet], but your patch will get messy, and what if your patch needs to make its own mind up about which abstraction it wants to send the message to, maybe depending on which midi note it received?
The solution is to give the abstraction arguments... some parameters that define it and make it different to the other copies.
For example [my_abstraction]
Let’s give it some arguments [my_abstraction 5 9 woof]
Inside the abstraction, as it is created (you open its parent patch) the dollar variables will be replaced. Wherever you see $1 written IN AN OBJECT it has been replaced by the number 5.
Number 5 because 5 is the first argument and has actually replaced the $1. You still see $1, but if you bang a [$1] object it will output 5.
[f $2] will output 9
[symbol $3] will output woof
So if you have an object [receive $1-$3] then it has now become [receive 5-woof]
And if you want to send it a message from outside, from another patch or abstraction, you will need to use [send 5-woof]
Every Pd patch, which remember includes your abstractions, also has a secret number. The number is unique and greater than 1000. As Pd opens each patch it gives it the number, increased by one from the last number it gave.
That number will replace $0 as the patch is created. You can find out what the number is by banging a [$0] object and connecting its output to a number box, or [print] object.
$0 can be used in any object as part of the name or the address, which means that a message cannot escape from the abstraction. A sub-patch like [pd my-subpatch] will be given the same number.
But from outside your abstraction you don’t know what it will be when the patch is created, so it is not useful. (A lie, you can find out, but as it can change every time you open your patch it is not worth the bother).
Use it to send messages within your patch [send $0-reset] to [receive $0-reset] for example, because the message is absolutely unique to its window, so you know it cannot interfere with other abstractions.
Use it also for objects like [delwrite~ $0-buffer 100] or for an array name [array $0-array] so that in each abstraction they have a different name and you will not have problems with their being "multiply defined"...... as each name can only exist once in your patch.
- If the Dollar $ variable is in a [message( box
Dollar $ variables are also replaced, but not as the patch is created (drawn by Pd as you open it).
Dollar zero $0 has no meaning in a message box. It will produce a zero if the message is banged, but that is it.
It is a mistake, a patching error, to put a $0 in a message box.
$1 $2 $3 $4 etc. in a message box are replaced by incoming atoms (individual floats or symbols or whatever) when they arrive. $1 will be replaced by the first atom in the list, $2 the second etc.
So if you have a message box [$1 $2 $3( ..... and you send into it a list [3 48 lala( .....then it will output 3 48 lala
That is not really very useful.
But it is actually very powerful.
Make a list in a message box........ [33 12 wav(
And bang it into a message box [open my-track$2-$1.$3( and you will get the output.........
open my-track12-33.wav
Which could be just the message that you want to send to [soundfiler]
P.S. If the first item in the incoming list is a symbol then it will be dropped causing errors.
You can fix that by making the message a list by passing it through the object [list].
Unfortunately only messages starting with a float are automatically recognised as lists.
getting the sent symbol of a number atom
If you want to send a text message with a number you just make a message box containing the info you want to send and connect it to [send xyz] and then bang the message at the same time you send the variable, then you can [receive xyz] at the other end. (if you want to do that automatically whenever you change a number then just connect the output of the number box to the input of the message box).
You can't send both a number and text in the same send & receive box unless you start packing them into lists... probably simpler just to use 1 send & receive pair for the number and 1 send & receive pair for the text.
It's not that elegant!
In writing sequences I haven't found a need to send text with numbers. Just label stuff with comments to help you see where it's going.
I haven't seen your patch but possibly a way to make it more efficient is to bear in mind that if the numbers for each step are stored in the number boxes or sliders used to edit the sequencer, then they don't need to be additionally stored anywhere else unless you are saving/loading patterns. If you want pattern storage then, yes, you will need some pretty intense messaging to exchange the data between the displayed/currently played sequence and the memory banks.
Ewolverine 4 U
New version 7 (currently testing)
- added automatic loosening of minimum fitness limit for the case that a population of sounds gets stuck in a local maximum in the fitness landscape (really nerdy jabbering, but trust me, it's useful ^^)
- added automatic "jumping" out of local maximums after a certain number of fruitless climbing-trials
EWOLVERINE v.7 by Henry Dalcke.pd
plans:
• bugfix: prevent a newly audible sound from being selected after manually stopping the target drive
• simulated annealing in target drive mode: span "temperature" value onto fitnesslandscape and decrease step length (modwheel) and probability value in the splice-pattern-generator the closer the fitness gets to optimal fitness value
• interactive mode: automatic narrowing of the range of generated parameter values around a mean value that's derived from the repeated selection of similar values of individual parameters throughout the generations (increases the number of similar sounds per generation that are located around a certain coordinate in parameter space; increases the likelihood of the generation of the desired sound in a smaller amount of time)
• stop-condition for automatic stopping of target drive
• make default settings for modwheel-position, splice-pattern-generator's probability, anti-stuck and allowed minimum fitness value in target drive adjustable from GUI
• adjustable MIDI output message blocker (useful for instruments with a fixed MIDI implementation, for instance: If you want to breed a bass drum in a drum synth with multiple instruments, you may not want to ruin the parameter adjustments of the snare drum meanwhile you're selecting for good bass drums)
• storage for self-created splicer patterns (maybe in connection to the MIDI output message blocker)
• low-value-weighted probability for the generation of MIDI-CC-values in new populations; switchable per MIDI-CC either manually or randomly (increases the probability for the generation of short attack and decay values in synth's envelopes)
• bigger populations for each sound-set: 4 more random sounds per set (A/B) to select from
• discontinuous MIDI messaging interrupted by assignment switching CC events (special build for FM-Heaven) - low priority
• possibility to interpolate between new random population's sounds to smoothly re-direct the modwheel-morphing path while morphing
• selection-history recorder that one can use to re-load the selected sounds of each past generation
• a visualizer that generates a "tree of life" from directions (keys C,D,E,F) and steplengths (modwheel) of formerly selected individuals and their respective distances to their parent sounds
Time Stretching Patches - any recommendations?
@s.elliot.perez Hello s......... I have just read through your thread...... and if I understand correctly you want an endless waveform, without repetitive artefacts.
You mention contrabass. If plucked this will be almost impossible (and pointless?) but if bowed then it should be easier.
The difference with an organ is two-fold:
the organ (a tuned pipe) produces a repetitive waveform (with colour that remains constant)
the organ produces a constant volume
A perfectly bowed contrabass note would do (almost) the same, but a plucked note is not the same animal.
So, do you want to do this "on the fly".......
If you want to produce an endless note (without pitch shift) then you need a looped delay, and as @JohhnyMauser just mentioned you need the loop point to be at a moment where the waveform is crossing the zero level....... i.e. .....no sound........ so as to avoid clicks at that point.
And you need the volume of the sample to be constant so that you hear no "rhythm".
And you need the colour of the sample to be constant for the same reason.
Then you have the equivalent of a "Mellotron"...... the very first keyboard synthesiser....... for one "key".......
The best way to create this sample is in your audio editor, where you can tailor it exactly to what you want........ and then play it in Pd repetitively (in a loop).
If you want to do this "on the fly" the result cannot be perfect unless you can play the perfect note. But you can get closer, as you have found, by "mushing up" the sound with reverb etc after the output of the loop.
You should use a "total" compressor.... so that the sound level and power never varies throughout the sample.
You can use [zerox~] to automatically loop at a "zero crossing".
And the input signal needs to be as perfectly constant in colour as is possible.
And the shorter the sample the better your chances....... but........ then you have a less "interesting" and (maybe) more "metallic" sound.
David.
how does [list drip] actually work?
it's a recursive thing: I'll walk through part of an example:
say the list has 5 elements.
The list comes in, and goes into the open spigot.
so at this point the [t a a a a] is sending a list of 5 elements. the following is what happens to the right [list-split] at this moment:
the first 2 elements of the list are sent back to the upper trigger, and go back into the spigot, where they are split again into lists of length 1. element 1 goes back into the upper trigger and out of the outlet, and then the second does as well.
All of this happens before the list of 5 elements is even sent to the left [list split], because of the trigger. A similar thing occurs:
the last 3 elements of the 5-element list are sent to the upper trigger and into the open spigot, and then the first element of that is split off and sent out the outlet. Then the last 2 elements are sent through the spigot and split, and are sent out in order.
The crucial thing to understand is the recursive nature; it has to do with the depth-first message passing in pd.
The first half of the list is split off before the second half, and sent to be split in half again before the second half of the original list is even processed. So it goes the first half of the first half of the first half, etc. until the first element is sent to the outlet. Then it goes back up the "stack" to the second halves of the lists that it missed in doing the first half every time (this happens because of the triggers). So after the first element is sent, the second element is sent. After that, elements 3 and 4 (in a list since they weren't even processed to be split yet) are split and sent out in order. then elements 5-8, which are still in a list, are sent back and processed in the same manner.
Hopefully that's somewhat clear..
(rambling extra stuff:)
From a "computer science" perspective, you could say that you process the first half and put the second half on a "stack" , and then go into the first half, split it in half, put the second half on the "stack", etc. And then after the 1st element is put out, repeat that process for each thing on the top of the stack until you end up with 1 element:
in "pseudocode" (with a datatype "list" and an assumed stack):
function splitlist (list inlist) {
list firsthalf;
list secondhalf;
if length(inlist) == 1 then {
output(inlist); -- pass the element
if stack exists then {
secondhalf = popstack(); -- get the next thing on the stack
splitlist(secondhalf); -- call the function recursively
}
} else {
firsthalf, secondhalf = split(inlist); -- split the list, pass to variables
pushstack(second half); --- push the second half onto the stack
splitlist(firsthalf); -- call the function recursively
}
}
I think that in reality most of this is taken care of in the computer's call stack, though not completely sure on how the memory for the lists is dealt with
PD sending to two devices?
You can assign discreet inputs and outputs but not multiple outputs across different audio devices. Sound software has to access sound hardware through it's drivers and it can't handle 2 sets of calls to two different drivers (if someone has the proper tech jargon, please step in).
There are ways of cheating but they all stink in some way:
On windows: VAC/audio repeater combo
You can use 'Virtual Audio cables' to create virtual devices that you can use for input and output between software. You can piggy-back that audio to different hardware devices by using the audiorepeater utility. So you can set up VAC to make 2 cables (VAC1 and VAC2). PD will use VAC1 and VAC2 as outputs. (Since VAC1 or VAC2 aren't hooked up to real hardware, you don't hear anything.) Then you run 2 instances of audiorepeater. One instance routes VAC1 to 'Onboard speaker out' and the other instance will route VAC2 to 'USB audio device out'.
Downside: Latency, Latency, Latency
The sound is delayed through each step in the chain, and the audio repeater latency can only go but so low before you get scratchy static and dropouts.
On Linux: ALSA virtual device
You can make a virtual soundcard using ALSA that can combine the outputs of two audio cards into one
'virtual' one and then set JACK to output to that device (the setup of which is too complex to explain here).
Downside: Latency/Timing
Each soundcard has it's own timing, and there's no way to keep them in synch, so you can control the latency and you'll have clicks, pops, dropouts, and tons of underruns.
On Mac OSX:
I haven't tried it, but I believe you can also make an aggregate device
There is also a VAC/audiorepeater type program you can use called Soundflower, but like VAC it's really only for routing sound between apps, not between hardware.
Long story short, between the latency introduced by the software and the clock timing differences between soundcards, you can really get anything usable.
"audio i/o stuck"
For each program that is using the ASIO drivers, an ASIO control panel will pop up in the system tray (you might need to adjust your system tray preferences). Each panel controls an instance of the ASIO drivers for that program. You can open that panel and set the inputs and outputs you want to use for that instance.
I said in the above post that ASIO can connect to one program at a time....but that isn't the full explanation. Each ASIO instance can connect 1 program to the same hardware inputs and outputs at a time.
So if you had a soundcard that had 4 outputs, you can setup 2 programs to use the ASIO drivers, one instance goes to output1 and output2, and the other instance can go to output3 and output4.
Getting your sound program running through ASIO (that's by default connected to all inputs and outputs) and getting sound from the browser (Firefox? Chrome? IE?)
is tricky. The browser doesn't use ASIO, it's using the default windows sound driver to access the soundcard. Try loading the browser first then load PD with ASIO or vica versa.
I've only been able to get a consistent working setup by having multiple (2 or more) soundcards. Windows controls one (browser sound, programs that don't use ASIO) and ASIO drivers control the other (PD, tracktor, cubase, FLstudio, etc). Route the sound output from both cards into an external mixer, and the mixer controls the main speakers (or monitors)