Hello PD list I'm trying to extract one of three number columns from a text file to drive the pitch of an audio oscillator. I have the .txt file reading all 3 columns of numbers into an array at present but I only want the second column. Ideally I'd like to extract the 2nd column before being read into the array but another solution in this case may also be limiting the numbers read from the array to the oscillator to within a particular range (i.e. the number value range of the 2nd column; 840 - 890). Though the latter wouldn't provide a pure solution it would be workable in this case. As you may have guessed, I'm grapping with pd fundamentals here as an abolute beginner, so I'd really appreciate any suggestions/ patch examples/ explanations etc. thanks Toby
Yahoo! Answers - Get better answers from someone who knows. Tryit now.
A more workable solution might be to use the IEM matrix object set, which is designed for exactly this sort of tabular data. I hacked together a pretty good preset saving system a month or two ago using them. You might have to format the txt file you are using a bit to get it to load, however. Check 5.reference/iemmatrix/matrix-help.pd (at least on Extended) for details.
d.
toby zardoz wrote:
Hello PD list I'm trying to extract one of three number columns from a text file to drive the pitch of an audio oscillator. I have the .txt file reading all 3 columns of numbers into an array at present but I only want the second column. Ideally I'd like to extract the 2nd column before being read into the array but another solution in this case may also be limiting the numbers read from the array to the oscillator to within a particular range (i.e. the number value range of the 2nd column; 840 - 890). Though the latter wouldn't provide a pure solution it would be workable in this case. As you may have guessed, I'm grapping with pd fundamentals here as an abolute beginner, so I'd really appreciate any suggestions/ patch examples/ explanations etc. thanks Toby
hi toby
since [textfile] doesn't provide any mechanism to jump to a certain line, you need to step through all lines from the beginning. this conflicts with your intention to only read certain lines out, not all of them. you could solve this conflict by appending a [spigot] object to [textfile]. [spigot] lets you choose, if messages should get passed or not, by sending to its right inlet '1' or '0'. a solution would be to set [spigot] to '0' until [textfile] reaches the line you want. then you could set [spigot] to '1', so that the output of [textfile] is sent to the array.
if you are on pd-extended or you have the zexy external installed, then you could also use [msgfile] (on pd-extended you may need to create a [import zexy] first). it works similar to [textfile], but provides more 'commands'. you could send it a 'goto 2' message in order to set the read pointer to line 2. sending it a 'bang' now, will let it output line 2.
roman
On Fri, 2007-06-22 at 12:11 +0100, toby zardoz wrote:
Hello PD list I'm trying to extract one of three number columns from a text file to drive the pitch of an audio oscillator. I have the .txt file reading all 3 columns of numbers into an array at present but I only want the second column. Ideally I'd like to extract the 2nd column before being read into the array but another solution in this case may also be limiting the numbers read from the array to the oscillator to within a particular range (i.e. the number value range of the 2nd column; 840 - 890). Though the latter wouldn't provide a pure solution it would be workable in this case. As you may have guessed, I'm grapping with pd fundamentals here as an abolute beginner, so I'd really appreciate any suggestions/ patch examples/ explanations etc. thanks Toby
Yahoo! Answers - Get better answers from someone who knows. Try it now. _______________________________________________ PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list
___________________________________________________________ Der frühe Vogel fängt den Wurm. Hier gelangen Sie zum neuen Yahoo! Mail: http://mail.yahoo.de
Hallo, toby zardoz hat gesagt: // toby zardoz wrote:
I'm trying to extract one of three number columns from a text file to drive the pitch of an audio oscillator.
I have the .txt file reading all 3 columns of numbers into an array at present but I only want the second column.
I don't yet understand why you are reading the numbers into an array?
Anyway, assuming you use [textfile] to read in the file, you can extract the middle number of each row using a message box with [$2( in it.
An alternative approach is to load your external data into data structures. That's a bit more advanced, but very flexible.
Frank Barknecht _ ______footils.org_ __goto10.org__
On Fri, 2007-06-22 at 14:51 +0200, Frank Barknecht wrote:
Hallo, toby zardoz hat gesagt: // toby zardoz wrote:
I'm trying to extract one of three number columns from a text file to drive the pitch of an audio oscillator.
I have the .txt file reading all 3 columns of numbers into an array at present but I only want the second column.
I don't yet understand why you are reading the numbers into an array?
Anyway, assuming you use [textfile] to read in the file, you can extract the middle number of each row using a message box with [$2( in it.
An alternative approach is to load your external data into data structures. That's a bit more advanced, but very flexible.
Ciao
oops, i mixed up columns and lines in my previous post. sorry for that........
roman
Telefonate ohne weitere Kosten vom PC zum PC: http://messenger.yahoo.de
Hello Toby, I hope that it will help you.
Jack
Hello PD list I'm trying to extract one of three number columns from a text file to drive the pitch of an audio oscillator. I have the .txt file reading all 3 columns of numbers into an array at present but I only want the second column. Ideally I'd like to extract the 2nd column before being read into the array but another solution in this case may also be limiting the numbers read from the array to the oscillator to within a particular range (i.e. the number value range of the 2nd column; 840 - 890). Though the latter wouldn't provide a pure solution it would be workable in this case. As you may have guessed, I'm grapping with pd fundamentals here as an abolute beginner, so I'd really appreciate any suggestions/ patch examples/ explanations etc. thanks Toby
Yahoo! Answers - Get better answers from someone who knows. Tryit now._______________________________________________ PD-list@iem.at mailing list UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list