|
I've been able to answer a couple of my own questions. I post them here in case they are useful to others...
> A couple of weird things I ran into...
> 1) #defines are not brought in via #include
Macro definitions are brought in by #include but not if they are on the first line of the included file. By leaving the first line empty (i.e. just a CR/LF at the top) in the file being included I'm now able to use a common macro definition file for both orchestra and score.
> ...and a few questions
> 1) What is the upper bound on scored instrument copies (i1.1, i1.2, i1.n...)
It appears that scored instrument copies use floating point numbers for their identifiers so it's really a question of resolution. As an example I've found that the score statement i1.2 translates to something close to i1.999999997 on my machine.
- Andy F.
----- Original Message -----
From: "Andy Fillebrown"
To: csound@lists.bath.ac.uk
Sent: Thursday, April 10, 2008 12:37:24 AM (GMT-0400) America/Glace_Bay
Subject: [Csnd] more questions...
Hello again,
I tried out my first .csd today (I pasted it in at the end. Let me know if it's better to attach it next time).
It works but I'm sure there's a better way.
If anybody has any pointers on how to improve the control system within the instrument I'm all ears.
A couple of weird things I ran into...
1) #defines are not brought in via #include
2) leading white space on #define statements makes the parser silently ignore the definition.
3) #define statements in the score use a trailing period key ('.') --- that one cost me a few hours, grrrr.
...and a few questions
1) What is the upper bound on scored instrument copies (i1.1, i1.2, i1.n...)
2) What is the best/most-acceptable design route for controlling multiple opcode parameters using separate lines in the score (see pasted in .csd file for what I'm getting at).
Next up in the learning curve are buses and sub-instruments.
Any pre-advice on those subjects would be much appreciated.
Regards,
- Andy F.
=============================================
; Select audio/midi flags here according to platform
; Audio out Audio in No messages
;-odac -iadc -d ;;;RT audio I/O
; For Non-realtime ouput leave only the line below:
-o c:\test.wav -W ;;; for file output any platform
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1
0dbfs = 1
#define E_TRIGGER_NOTE_ON #9#
#define E_TRIGGER_NOTE_OFF #8#
#define E_TRIGGER_CTRL #-1#
#define E_CTRL_PITCH #1#
#define E_CTRL_VOL #2#
#define E_CTRL_END #99999999#
#define INSTR_SINE_PA #1#
#define C_A440_CENTS #6900#
#define C_A440_CENTS_D100 #69#
#define K_PRINT_FREQ #0.125#
instr $INSTR_SINE_PA
/* Branch on trigger type spec'd in p4.
*/
i_TriggerType = p4
if (i_TriggerType == $E_TRIGGER_CTRL) goto instr_read_params
if (i_TriggerType == $E_TRIGGER_NOTE_ON) goto instr_init
if (i_TriggerType == $E_TRIGGER_NOTE_OFF) goto instr_off
prints "\n*** Error *** Shouldn't get here.\n\n"
prints "...could be bad trigger type in p4.\n"
prints "i_TriggerType = %d\n", i_TriggerType
/*-----------------------------------------------------------------------*/
instr_off:
igoto instr_return
/*-----------------------------------------------------------------------*/
instr_init:
i_PitchFrom = 0
i_PitchTo = 0
i_PitchDuration = 0
i_AmpFrom = 1
i_AmpTo = 1
i_AmpDuration = 0
k_CurPitch = -1
k_CurAmp = -1
/*-----------------------------------------------------------------------*/
instr_read_params:
/* Read param type and set spec'd i variable.
*/
if (p5 == $E_CTRL_PITCH) then
i_PitchFrom = i_PitchTo
i_PitchTo = p6
i_PitchDuration = p7
elseif (p(5) == $E_CTRL_VOL) then
i_AmpFrom = i_AmpTo
i_AmpTo = p6
i_AmpDuration = p7
endif
/*-----------------------------------------------------------------------*/
instr_process:
/* Create k-lines.
*/
process_start:
if (i_PitchDuration != 0) igoto process_pitch
if (i_AmpDuration != 0) igoto process_amp
igoto process_end
process_pitch:
k_CurPitch line i_PitchFrom , i_PitchDuration , i_PitchTo
i_PitchDuration = 0
process_amp:
k_CurAmp line i_AmpFrom, i_AmpDuration, i_AmpTo
i_AmpDuration = 0
process_end:
/* Calc values for 'oscil' opcode call.
*/
k_CurCPS = 440 * semitone(k_CurPitch - $C_A440_CENTS_D100)
/* Skip rest of initializations if in a control pass.
(note is "tied" on control passes)
*/
if (i_TriggerType == $E_TRIGGER_CTRL) igoto instr_return
/* Init output per params.
*/
a_out poscil k_CurAmp, k_CurCPS, 1
out a_out
/*-----------------------------------------------------------------------*/
instr_return:
endin
#define E_TRIGGER_NOTE_ON #9#
#define E_TRIGGER_NOTE_OFF #8#
#define E_TRIGGER_CTRL #-1#
#define E_CTRL_PITCH #1#
#define E_CTRL_VOL #2#
#define E_CTRL_END #99999999#
#define INSTR_SINE_PA #1#
f 1 0 65536 10 1
i $INSTR_SINE_PA..1 0 -1 $E_TRIGGER_NOTE_ON $E_CTRL_PITCH 60 0
i $INSTR_SINE_PA..1 0 -1 $E_TRIGGER_CTRL $E_CTRL_VOL 0 0
i $INSTR_SINE_PA..1 0 -1 $E_TRIGGER_CTRL $E_CTRL_PITCH 72 1
i $INSTR_SINE_PA..1 1 -1 $E_TRIGGER_CTRL $E_CTRL_PITCH 60 1
i $INSTR_SINE_PA..1 2 0 $E_TRIGGER_NOTE_OFF
i $INSTR_SINE_PA..1 0 -1 $E_TRIGGER_CTRL $E_CTRL_VOL 0.5 0.5
i $INSTR_SINE_PA..1 0.5 -1 $E_TRIGGER_CTRL $E_CTRL_VOL 0.0 0.5
i $INSTR_SINE_PA..1 1 -1 $E_TRIGGER_CTRL $E_CTRL_VOL 0.5 0.5
i $INSTR_SINE_PA..1 1.5 -1 $E_TRIGGER_CTRL $E_CTRL_VOL 0.0 0.5
i $INSTR_SINE_PA..22 0 -1 $E_TRIGGER_NOTE_ON $E_CTRL_PITCH 60 0
i $INSTR_SINE_PA..22 0 -1 $E_TRIGGER_CTRL $E_CTRL_VOL 0 0
i $INSTR_SINE_PA..22 0 -1 $E_TRIGGER_CTRL $E_CTRL_PITCH 48 1
i $INSTR_SINE_PA..22 1 -1 $E_TRIGGER_CTRL $E_CTRL_PITCH 60 1
i $INSTR_SINE_PA..22 2 0 $E_TRIGGER_NOTE_OFF
i $INSTR_SINE_PA..22 0 -1 $E_TRIGGER_CTRL $E_CTRL_VOL 0.5 0.5
i $INSTR_SINE_PA..22 0.5 -1 $E_TRIGGER_CTRL $E_CTRL_VOL 0.0 0.5
i $INSTR_SINE_PA..22 1 -1 $E_TRIGGER_CTRL $E_CTRL_VOL 0.5 0.5
i $INSTR_SINE_PA..22 1.5 -1 $E_TRIGGER_CTRL $E_CTRL_VOL 0.0 0.5
e
Send bugs reports to this list.
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
|