Hello, not sure what’s going on, but a csound program works fine in QT but distorts when run by Unity/CS.
Here’s the simple instrument:
<Cabbage>
form caption("forBehaviorTree"), size(300, 200)
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -m0d
</CsOptions>
<CsInstruments>
sr = 44100
ksmps = 128
nchnls = 2
0dbfs = 1.0
instr 1
; setup
iCos ftgen 0, 0, 8192, 11, 1
iamp = p4
kfreq = cpspch(p5) ; 12 tone ET
; ifreq cpsxpch p5, 31, 3.5, 1 ; 31 tone
; asig oscil iamp, ifreq, 2 ; table 2
; tone gen
asig gbuzz 1, kfreq, 75, 1, 0.9, iCos
ifiltrise = 0.005
ifiltdec1 = 0.05
ifiltdec2 = p3 - (ifiltrise + ifiltdec1)
kfiltenv linseg 300, ifiltrise, 2500, ifiltdec1, 1000, ifiltdec2, 300
afilt moogladder asig, kfiltenv, 0.2
; output
aout linen afilt * iamp, 0.01, p3, 0.1
outs aout, aout
endin
</CsInstruments>
<CsScore>
f0 z ; run forever
t 0 100 ; tempo, slow down after x, y, z times in ordered pairs
</CsScore>
</CsoundSynthesizer>
Here’s the section of CS in Unity:
[Task]
bool Turn(float angle)
{
var p = this.transform.position + Quaternion.AngleAxis (angle, Vector3.up) * this.transform.forward;
target = p;
if(timedPlayback <= 0.0f)
{
csoundUnity.sendScoreEvent("i1 0 0.5 0.5 7.04 "); // mary had...
csoundUnity.sendScoreEvent("i1 1 0.5 0.5 7.06 "); // mary had...
csoundUnity.sendScoreEvent("i1 2 0.5 0.5 7.08 "); // mary had...
timedPlayback = timerReload;
}
return true;
}
it’s in a behavior tree. csound seems to initialize properly without error messages (except for a few dylibs) and runs audio, but the pitches don’t track properly and the sound is distorted. I’ve put a score in the instrument and in that context it sounds fine, not sure what the problem is.
Thanks for any help!!!
(sorry but the markers in the csound program are hidden, I think you get the idea… how should I copy the program or attach it?)