Csound Csound-dev Csound-tekno Search About

Re: for the future: more than four channels?

Date1998-12-24 08:18
FromGabriel Maldonado
SubjectRe: for the future: more than four channels?
Santa Claus is arriving!

I've just finished to write some opcodes for multi-channel files.
The new opcode 'fout' allow the output to a file of any number of audio channels (for now
the limit is arbitrary locked to 64, bat can be increased). It supports .wav format for
mono and stereo files in integer, raw format (without header) for 16 bit integer and 32
bit floating-point with any number of channels. In future, when the standard for
multichannel files will be definitively defined, it will support any format. 
I will send the sources to JPFF as soon as I can. 
A'vincr' and 'clear' opcodes are new useful tools when using 'fout'.
A modification of rdorch.c and entry.c files is needed to allow variant argument list at
a-rate.

fout opcode:

fout   "ifilename", iformat, aout1 [, aout2, aout3,....] 

DESCRIPTION 

Output a list of audio signal to a specified file 

INITIALIZATION 

ifilename - a double-quote delimited string file name 
iformat - a flag to choose output file format:
0 - 16-bit integers without header
1 - 32-bit floating point samples without header
2 - 16-bit integers with .wav type header 

PERFORMANCE 

aout1,... aoutN - output signals 

This opcode allows to write samples of audio signals to a file with any number of
channels. Channel number depends by the
number of aoutN variables (i.e. a mono signal with only an a-rate argument, a stereo
signal with two a-rate arguments etc.)
Maximum number of channels is fixed to 64. 

More fout opcodes can be present in the same instrument, allowing to open more audio to
disk streams in parallel. 

Notice that, differently by out, outs and outq, fout does not zeroes the audio variable,
so you must provide a zeroing after calling
fout is poliphony is used. You can use incr and clear opcodes for this task. 





vincr, clear 

vincr  asig, aincr
clear avar1 [,avar2, avar3,...,avarN] 

DESCRIPTION 

vincr increments an audio variable of another signal, i.e. accumulates output.
clear zeroes a list of audio signals. 

PERFORMANCE 

asig - audio variable to be incremented
aincr - incrementation signal
avar1 [,avar2, avar3,...,avarN] - signals to be zeroed 

vincr (variable increment) and clear are thinked to be used togheter. vincr stores the
result of the sum of two audio variables
into the first variable itself (which is thinked to be used as accumulator in case of
polyphony). The accumulator-variable can be
used for output signal by means of fout opcode. After the disk writing operation, the
accumulator-variable should be set to zero
by means of clear opcode (or it will explode). 


EXAMPLE OF 'FOUT', 'INCR' AND 'CLEAR':
-------------------------------------
;ORC
	sr = 44100
	kr = 441
	ksmps = 100
	nchnls = 1



ga1	init	0
ga2	init	0
ga3	init	0
ga4	init	0

;***************************************************
	instr	1
;***************************************************
k1	linseg	0,p3/3,1,p3/6,.5,p3/3,.5,p3/6,0
a1	oscili	10000,p4,1
a2	oscili	10000, p4*1.234567,1
a3	oscili	10000, p4*1.5,1
a4	oscili	10000, p4*.766,1


	vincr	ga1,a1*k1
	vincr	ga2,a2*k1
	vincr	ga3,a3*k1
	vincr	ga4,a4*k1

	out	a1	
	endin



;***************************************************
	instr	2
;***************************************************
 	fout	"fout.wav" ,2,ga1,ga2
 	fout	"fout2.wav" ,2,ga3,ga4
	clear	ga1,ga2,ga3,ga4
	endin

;-----------------------
;SCO
f1 0 4096 10 1
i1 0	1.8	106
i1 1.5	2	123.66
i1 3.1	2	51.123335
i2 0 10


-- 
Gabriel Maldonado

http://www.agora.stm.it/G.Maldonado/home2.htm