-
Koos
I am using a float as part of a filename (of a sound I record). However the filenames are like:
blabla0.wav
blabla10.wav
blabla20.wav
[..]
blabla100.wavNow, I was wondering if it is possible to get:
blabla000.wav
blabla010.wav
blabla020.wav
[..]
blabla100.wavIn other words can I get a specific output format, e.g. 3decimals, from a [float]?
Note: I am computing the float (counter*constant), so I can't just type a 3 decimal number as input for the [makefilename]
-
Koos
I have a loop that makes a recording during each pass.
At the moment the files are named sound%d.wav, where %d is the counter value.Now, I want to get more logical filenames based on two parameters. One to dermine a preset and the second, based on the counter value ,to determine the second part of the filename. The problem is the second part not having an equal length for each preset.
For Example:
when preset/first part is set to:
* A1 the second part will be: X1, X3, X4 (counter 1->3)
* B1 the second part will be: Y6, Y-4, Y-1, Y3 (couter 1->4)
* C1 the second part will be: Z4, Z-3 (counter 1->2)In other words (as I think I the above is not really clear):
I want to do some conditional (?) selectionwhen preset is A1 and counter 1 -> A1X3.wav
A1 and counter 2 -> A1X3.wav
etc
C1 and counter 1 -> C1Z4.wav
C1 and conter 2 -> C1Z-3.wav.. but how?
edit: Only need to run the loop for one (a priori chosen) preset !
-
Koos
Goal: Saving two arrays (left and right channel) in a (stereo) wave file with a specific filename e.g. sound1.wav. Then overwritting the arrays and save again with different filename e.g. sound2.wav.
So far, I am able to save the arrays using
|bang(
|
[savepanel] (Bang->savepanel gives "save as menu")
|
[write(
|
[soundfiler]I tried to get rid of the "save as" by sending the specified file name e.g. sound1(.wav) to [savepanel]. However this results in:
error: savepanel: no such method for 'sound1(.wav)'
I tried changing various things (writesf~, no savepanel etc), but so far I haven't found the mistake...
Edit: I do have a counter available, so I can use something like "sound$1" as filename (where $1 is the counter value) or use [select].
-
Koos
I made a abstraction with three inputs e.g. in1, in2 and in3 and three outputs out1, out2 and out3.
Now I made patch, where I use this abstraction. I set in2 and in3 with a (load)bang and have a counter to change in1; in1 = constant * counter.
The output of the abstraction is something like:
out1 = cos(in1)*sin(in2)*in3
out2 = sin(in1)*sin(in2)*in3
out3 = in3*cos(in2)Indeed, a polar to cartesian conversion. Then I send the cartesian coordinates to a box to indicate a point and in the meanwhile a bang is send to update the counter by one. E.g.
[in1] [in2] [in3]
| | |
[PolarToCartesian]
| | |
[out1] [out2] [out3]
| | |[r out1][r out2][r out3]
| | |
|ToBox $1 $2 $3;(
|ToCounter bang (The problem is that as soon as I set in2 and in3 the out's are calculated (with in1 being the last value inputed..?) and the loop starts running till the stop certeria (max counter)is reached.
However I want to start getting outputs when I start the counter manual (e.g. in1 = 0 -> in2 = contanst * 1 -> in2=constant*2 etc).
Is this possible?
-
Koos
Hello,
I am trying to make a loop in PD that runs a couple of times, but before the next run starts I want to insert a delay.
For example: I want to print the numbers 0-2 with a delay of 2 seconds.
As a test I tried to alter the loop shown in the [until] help, but as delay outputs a bang I am not sure how to implement this correct.
Any tips?
-
Koos
Ah, thanks the solution!
I tried %d3, which -obvious- didn't work.
-
Koos
ehm, I guess I don't have that library?
I only see/have
, , , (still new to PD)
-
Koos
@hardoff said:
check out [list2symbol] from zexy for combining 2 messages into one.
I think [pack] will do the same.
However -current- main problem is the selection process. Obivious I can make one big [select] with 144 arg's, but with 5 different presets and two different 'lists' for the second part (one of 36 values and one of 18) I think there is a better way.
-
Koos
In case anybody needs this in the future:
[bang( [r counter]
| /
\ /
\ /
[float]
|
[makefilename ./rec/sound%d.wav]
|
[write $1]
|
[soundfiler]Notes:
- I had to use ./directory/ instead of ../directory/
I saw ../ mentioned couple of times.
- Make sure to use %d (if input is float/number) when I used %s PD crashed when attempting to save the second wav
Now I have another (small) problem:
Is there a way to overwrite files if they already exist?edit: Nevermind, files are overwritten.
- I had to use ./directory/ instead of ../directory/
-
Koos
@sunji said:
check out [makefilename]
Thanks for the tip. 'Found' this object/command just before reading your reply .
@thep said:
Hey,
I don't know if I'm understanding you correctly, but it seems like you think that the [savepanel] object has something to do with the actual saving of the soundfile.It doesn't it just generates a filename. It's the 'write' message being sent to the soundfiler which causes the soundfiler object to write to disk.
My suggestion is this:
[counter] (assuming this outputs a float when you bang the top)
|
[makesymbol sound%s.wav]
|
|write $1(
|
[soundfiler]The makesymbol will take whatever float you send it and output a symbol soundXXX.wav (the %s in the argument is replaced by whatever float you input to the object). The write $1 then prepends write to the filename, and sends the instruction to soundfiler to write the wav file.
Theo
I tried couple of things without savepanel, but I didn't get any saved file(s). Now I see what I did wrong: I forgot to connect [write] and [soundfiler]. The following works
[bang(
|
[test.wav]
|
[write $1]
|
[soundfiler]Now going to change this to get the filenames right!
By the way I think [makesymbol] should be [symbol]? -
Koos
Well, that does the trick! I made a note to make sure I won't forget to use the trigger when needed.
Futhermore, I was wondering if there is a way around the screenshot as I might come across more problems while expanding the program.
The screenshot is a subpatch of a bigger program, which needs/uses subdirectories and patches in order to work.
I can't copy/paste the subpatch [the screenshot] into a new file & attach.. as copy/paste options are limited in PD (?).I noticed another minor problem, when restarting the program the initial values in the message boxes e.g. reso_rad are rounded to 4 decimals (5 significant numbers) can this be changed?
Oh, I really appreciate all the help!
-
Koos
I know, but the subpatch is part of a bigger program, and I can't just attach that part of the program (won't work for you)
PolToCar is indeed a abstraction, which I have attached.
-
Koos
Ok, I removed the bangs and inserted a [t b f] after [r reso_rad] and a [t f b] after [r phi_rad].
But still get a wrong z. I get zero, which I is the initialized value. But I want the one calculated during first loop (here 1.767), which is the 3rd out of [PolToCar]
-
Koos
It's not really a abstraction problem anymore (I think), but I still need some help.
Outline: I have a room (x,y,z coordinates), which contains a head (position head_xyz) and a source (src 1). The goal is to let the source circle around the head (origin) at a specific height (z) and with a certain resolution in phi/azimuth(reso_rad).
The source position is determined with the help of sphere coordinates (phi being the azimuth, theta elevation).
To do this I have made the following subpatch:
http://i28.tinypic.com/ke9c8l.jpg* First I put head and source in the origin and reset counter (upper left).
* Then I hit the bang beneath start to determine source position and place the source at that position in the room.
Keep hitting bang until circle is completed (in the end I want to do this automatic, by sending a bang to the banger after source position is taken).In principle this works. Except when I have just started the program and hit the bang first time the first position is not correct (all others are). I think it has something to do with the cold/hot inlet thing, but not sure (newbie)..
-
Koos
Well, that does work! But when I restart PD/program first run something goes wrong (output values of last run before closing are used?)
What I do:
-
Start the counter & send the in2 and in3 values to (right inlet of) [f]
-
Compute in3 and send it to left inlet of the abstraction
& bang the left inlets of the [f] for in2 and in3.
-
-
Koos
@excalibur said:
Maybe you can use [delay 2000] for that.
I know/did, but the problem is (was) where to insert it when using [until]
@hardoff said:
[until] just sends as many bangs as you tell it to, but without any delay.
for delayed action, you need to use a counter and a [select] object to stop counting when you reach the desired number.
Thanks for the input!
I already managed to solved the prolbem:
-
Adding a delay to the counter in the help section (control examples).
-
Stop counter with help of [moses] after specified number of loops/counts.
--
P.s. Is this right place to ask these type of questions or should I have used "extra"? -