So, I'm trying to take a text file and read a number list of value data as a waveform. I've been trying to use [tabosc4~] but I clearly don't understand how it works. I've been able to get
-
Reading text file as waveform
-
If all you're looking to do is create a sound file from the data:
-
Look at Help Browser -> PureData -> 2.control.examples -> 15.array.pd to see an example of loading from a text file into an array.
-
Use [soundfiler] to save it as a soundfile. See it's help for saving it in the format you want.
-
-
Great. perfect. thanks.
However, I now have a related issue that I didn't think I'd need to deal with. Taking a text file with two columns (tab delimited in this case) where the first column is a position and the second is value - I would like to have the waveform to become the new value at the sample position. Also - perhaps a little less complicated, doing the same but using the values as a control value at the set sample time points.
I didn't think I needed to do this originally as I thought all values were equidistant. I was wrong, and synchronicity is necessary here. I could just write a perl script to fill in the blanks but I'd rather not as that will massively increase my file sizes.
Thanks
-
Could you post an example text file?
-
Here are the two versions:
forController.txt is a sample of the versions that will exist to control volume/frequency
forWave.txt is the version that would be converted to a wavetable.the first column is the position in time, the second is the value.
Thanks again.
-
Here are the two versions:
forController.txt is a sample of the versions that will exist to control volume/frequency
forWave.txt is the version that would be converted to a wavetable.the first column is the position in time, the second is the value.
Thanks again.
-
I've attached a version that uses [zexy/msgfile] to read the text files and write them to an array. I wasn't sure if Pd would treat the tab as a space, and it looks like it does, which is good news. So, when it outputs each line, it's just a two-element list.
I've commented the main points in the patch, so hopefully you can figure it out. But basically, the file is first loaded and it immediately jump to the last line to find out how big the table should be. Then, you tell it to read through the file line-by-line. Each time it dumps a new line, it takes the previous sample's value and uses that to fill in the samples up to the current one.
There is one catch to making this work correctly. When Pd reads text files, it uses semicolons to separate lines, not carriage returns. As you'll see in the patch, you can just use the "cr" option in the [read( message to get around that. However, it's not reading the last line correctly when doing this, and I think it has something to do with the tabspace and the fact that there is no carriage return on that line. So, in order to read the last line, you should open the files by hand and make sure the last line ends with a carriage return.
btw, I wouldn't use [tabosc4~], as it's really meant for small wavetables that are a power-of-two in size. You should instead use a [phasor~] to look up [tabread4~].
-
This is fantastic. Thanks.