|
Thanks so much Anthony -- this does indeed look like exactly what I
need.
Thanks also TIm and Michael -- your replies also provide food for
thought (and thanks for pointing out gen23, which I had somehow
overlooked).
-Lee
On Feb 5, 2008, at 2:28 PM, Anthony Kozar wrote:
> I think that the readk opcode is exactly what Lee is looking for --
> writing
> a Python host or using schedkwhen both seem like overkill.
>
> The Csound 5.07 documentation for readk is here:
>
> http://csounds.com/manual/html/readk.html
>
> You will want to use iformat = 7 or 8 (text integers or text
> floating-point
> numbers). And set the "iprd" parameter to the frame period (1 /
> frame-rate).
>
> Note that the current online version of the readk manual page is a
> little
> confusing and does not give a good example. It has been rewritten
> for the
> forthcoming Csound 5.08 manual.
>
> Here is the updated manual page along with a new example written by
> Andres
> Cabrera:
>
> readk
>
> Periodically reads an orchestra control-signal value from an
> external file.
>
>
> Description
>
> Periodically reads an orchestra control-signal value to a named
> external file in a specific format.
>
>
> Syntax
> kres readk ifilname, iformat, iprd
>
> Initialization
>
> ifilname -- an integer N denoting a file named "readk.N" or a
> character string (in double quotes, spaces permitted) denoting the
> external file name. For a string, it may either be a full path
> name
> with directory specified or a simple filename. In the later case,
> the file is sought first in the current directory, then in SSDIR,
> and finally in SFDIR.
>
> iformat -- specifies the input data format:
>
> 1 = 8-bit signed integers (char)
>
> 4 = 16-bit short integers
>
> 5 = 32-bit long integers
>
> 6 = 32-bit floats
>
> 7 = ASCII long integers (plain text)
>
> 8 = ASCII floats (plain text)
>
> Note that A-law and U-law formats are not available, and that all
> formats except the last two are binary. The input file should be a
> "raw", headerless data file.
>
> iprd -- the rate (period) in seconds, rounded to the nearest
> orchestra control period, at which the signal is read from the
> input file. A value of 0 implies one control period (the enforced
> minimum), which will read new values at the orchestra control
> rate.
> Longer periods will cause the same values to repeat for more than
> one control period unless interpolation is used.
>
> Performance
>
> kres -- output of the signal read from ifilname.
>
> This opcode allows a generated control signal value to be read
> from
> a named external file. The file should contain no header
> information
> but it should contain a regularly sampled time series of control
> values. For ASCII text formats, the values are assumed to be
> separated by at least one whitespace character. There may be any
> number of readk opcodes in an instrument or orchestra and they may
> read from the same or different files.
>
> Examples
> Here is an example of the readk opcode. (see below)
>
> See Also
> dumpk, dumpk2, dumpk3, dumpk4, readk2, readk3, readk4
>
> Credits By: John ffitch Feb 14 1999
>
> -------------------
>
>
>
> ; Select audio/midi flags here according to platform
> ; Audio out Audio in
> -odac -iadc ;;;RT audio I/O
> ; For Non-realtime ouput leave only the line below:
> ; -o readk.wav -W ;;; for file output any platform
>
>
>
> ; Initialize the global variables.
> sr = 44100
> kr = 4410
> ksmps = 10
> nchnls = 1
>
> 0dbfs = 1
> ; By Andres Cabrera 2008
>
> instr 1
> ; Read a number from the file every 0.5 seconds
> kfibo readk "fibonacci.txt", 7, 0.5
> kpitchclass = 8 + ((kfibo % 12)/100)
> printk2 kpitchclass
> kcps = cpspch( kpitchclass )
> printk2 kcps
> a1 oscil 0.5, kcps, 1
> out a1
> endin
>
>
>
>
> f 1 0 1024 10 1
> i 1 0 10
> e
>
>
>
>
>
> -------------------
>
> fibonacci.txt:
>
> 1
> 1
> 2
> 3
> 5
> 8
> 13
> 21
> 34
> 55
> 89
> 144
> 233
> 377
> 610
> 987
> 1597
> 2584
> 4181
> 6765
>
>
> -------------------
>
> Michael Gogins wrote on 2/4/08 7:51 PM:
>
>> 3. Have the script run Csound one kperiod (which could be just 1
>> sample) at
>> a time.
>>
>> 3. In between samples, have the script read the film cue file,
>> look up the
>> pending film cues for that sample, and set the relevant global
>> control
>> channels.
>
>> ----- Original Message -----
>> From: "Tim Mortimer"
>> To:
>> Sent: Monday, February 04, 2008 6:31 PM
>> Subject: [Csnd] Re: simple example sought for controlling sound by
>> numbers
>> in file
>
>>> it may seem slightly counter intuitive, but using one instrument to
>>> schedule
>>> a second instrument that continually rewrites the value of a
>>> global k
>>> variable that is accessed by a third instrument (to provide
>>> something like
>>> reverbmix..) is not an uncomon practice! ; ) & that might be the
>>> type of
>>> model you are looking for...
>
>>> Lee Spector wrote:
>
>>>> I want features of my sound to be controlled by a list of
>>>> numbers that I
>>>> have in a text file. The numbers come from a movie, with one
>>>> number per
>>>> frame (actually derived from the frame), and I want them to be
>>>> applied to
>>>> the sound at the same rate as they occur in the movie, so that I
>>>> can
>>>> later
>>>> add the sound back to the movie and have the frames and their audio
>>>> correlates be synchronized (or close -- I'm not worried about exact
>>>> synchronization). If it helps I could generate an "expanded"
>>>> version of
>>>> the data file so that it represents a signal at k-rate, e.g. by
>>>> just
>>>> duplicating each value k-rate/frame-rate many times. I could also
>>>> pre-scale the numbers to any range, e.g. 0-1.
>>>>
>>>> What I'm looking for is a simple example that reads such a file
>>>> and uses
>>>> the numbers to control some aspect of a sound at the right rate;
>>>> any
>>>> aspect would do as an example, e.g. amplitude, pitch, filter
>>>> values,
>>>> global reverb amount, etc.
>
>
>
> Send bugs reports to this list.
> To unsubscribe, send email sympa@lists.bath.ac.uk with body
> "unsubscribe csound"
--
Lee Spector, Professor of Computer Science
School of Cognitive Science, Hampshire College
893 West Street, Amherst, MA 01002-3359
lspector@hampshire.edu, http://hampshire.edu/lspector/
Phone: 413-559-5352, Fax: 413-559-5438
|