Csound Csound-dev Csound-tekno Search About

[Csnd] spat3d distorts using gui

Date2010-09-07 22:10
Fromacousmetre
Subject[Csnd] spat3d distorts using gui
Hi List

I'm new to csound. I have a project where I need to spatialize audio
interactively using a quad speaker array. I've looked at a few of the
options available in csound and spat3d seems to be a good choice for
what I need, particularly with its simulation of room acoustics. As a
test I've put spat3d together with an FLjoy interface. It works, however
when I move the source quickly the sound distorts. This is not the case
when the coordinates for spat3d are generated non-interactively with
"line". I wonder what can be done to fix the situation? Interpolation?
>From what I read in the manual, this should already be done by spat3d.

I'm using linux with jack and a low-latency kernel. There aren't any
audio buffer overruns and all the csound demos i've tried, work well. I
have also tested my script with high latency settings in jack as well as
various settings for -b, -B and kr in csound, but nothing much helps.
Nor the realtime linux kernel.

I'll paste my test script below. Can anyone suggest a remedy?

It is set up for stereo now - with the top half of the FLjoy interface,
the active part.

Also - i'm using qutecsound and qjackctl - but i think my command line
would be this from a terminal: 

csound -+rtaudio=jack -+jack_client=QUTECSOUND -odac -iadc -d -b400
-+rtmidi=null spat3d_joystck.csd

Cheers,

Iain






; Select audio/midi flags here according to platform

; Audio out Audio in No messages

-odac -iadc -d -b400 -+rtmidi=null ;;;RT audio I/O

; --sched=1 -iadc

; For Non-realtime ouput leave only the line below:

; -o spat3d_stereo.wav -W ;;; for file output any platform





/* Written by Istvan Varga */

sr = 48000

kr = 480

ksmps = 100

nchnls = 2

;FLTK INTERFACE
CODE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

FLcolor 255, 255, 255, 0, 0, 0

; LABEL | WIDTH | HEIGHT | X | Y

FLpanel "hrtfer/hrtfmove/hrtfmove2/hrtfstat", 500, 520, 0, 0

;NUMBER DISPLAY BOXES WIDTH | HEIGHT | X | Y

idX FLvalue "x-axis", 70, 20, 170, 60

idY FLvalue "y-axis", 70, 20, 260, 60

;GENERAL_TEXT_SETTINGS SIZE | FONT | ALIGN | RED | GREEN | BLUE

FLlabel 13, 4, 1, 255, 255, 255 ;LABELS MADE INVISIBLE (I.E. SAME COLOR
AS PANEL)

;GENERAL_TEXT_SETTINGS SIZE | FONT | ALIGN | RED | GREEN | BLUE

FLlabel 13, 4, 3, 0, 0, 0 ;LABELS MADE VISIBLE AGAIN

;XY PANELS MINX | MAXX | MINY | MAXY | EXPX | EXPY | DISPX | DISPY |
WIDTH | HEIGHT | X | Y

gkX, gkY, ihX, ihY FLjoy "Spat3D Spatialisation", -4, 4, -4, 4, 0, 0,
idX, idY, 360, 280, 70, 100

;;SET INITIAL VALUES VALUE | HANDLE

FLsetVal_i 0, ihX 

FLsetVal_i 0, ihY

FLpanel_end

FLrun ;RUN THE FLTK WIDGET THREAD

;END OF FLTK INTERFACE
CODE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

/* room parameters */

idep = 1 /* early reflection depth */

itmp ftgen 1, 0, 64, -2, \

/* depth1, depth2, max delay, IR length, idist, seed */ \

idep, 48, -1, 0.01, 0.25, 123, \

1, 21.982, 0.05, 0.87, 4000.0, 0.6, 0.7, 2, /* ceil */ \

1, 1.753, 0.05, 0.87, 3500.0, 0.5, 0.7, 2, /* floor */ \

1, 15.220, 0.05, 0.87, 5000.0, 0.8, 0.7, 2, /* front */ \

1, 9.317, 0.05, 0.87, 5000.0, 0.8, 0.7, 2, /* back */ \

1, 17.545, 0.05, 0.87, 5000.0, 0.8, 0.7, 2, /* right */ \

1, 12.156, 0.05, 0.87, 5000.0, 0.8, 0.7, 2 /* left */

instr 1

gkX init -4

gkY init -4

/* some source signal */

a1 phasor 150 ; oscillator

a1 butterbp a1, 500, 200 ; filter

a1 = taninv(a1 * 100)

a2 phasor 3 ; envelope

a2 mirror 40*a2, -100, 5

a2 limit a2, 0, 1

a1 = a1 * a2 * 9000

;kazim line 0, 2.5, 360 ; move sound source around

;kdist line 1, 10, 4 ; distance

;; convert polar coordinates

;kX = sin(kazim * 3.14159 / 180) * kdist

;kY = cos(kazim * 3.14159 / 180) * kdist

kZ = 0

;printks "kX = %f, kY = %f\\n", 1, kX, kY

a1 = a1 + 0.000001 * 0.000001 ; avoid underflows

imode = 1 ; change this to 3 for 8 spk in a cube,

; or 1 for simple stereo

;convert screen derived coord to a-rate with interpolation???

;aX = a(gkX) ; this doesn't work spat3d requires krate coords

;aY = a(gkY) ; In any case interp should already be done by spat3d

;aZ = a(kZ) ; so why does the interface cause glitches?

aW, aX, aY, aZ spat3d a1, gkX, gkY, kZ, 1.0, 1, imode, 2, 2

;aW, aX, aY, aZ spat3d a1, kX, kY, kZ, 1.0, 1, imode, 2, 2

aW = aW * 1.4142

; stereo

;

aL = aW + aY /* left */

aR = aW - aY /* right */

; quad (square)

;

;aFL = aW + aX + aY /* front left */

;aFR = aW + aX - aY /* front right */

;aRL = aW - aX + aY /* rear left */

;aRR = aW - aX - aY /* rear right */

; eight channels (cube)

;

;aUFL = aW + aX + aY + aZ /* upper front left */

;aUFR = aW + aX - aY + aZ /* upper front right */

;aURL = aW - aX + aY + aZ /* upper rear left */

;aURR = aW - aX - aY + aZ /* upper rear right */

;aLFL = aW + aX + aY - aZ /* lower front left */

;aLFR = aW + aX - aY - aZ /* lower front right */

;aLRL = aW - aX + aY - aZ /* lower rear left */

;aLRR = aW - aX - aY - aZ /* lower rear right */

outs aL, aR

endin





/* Written by Istvan Varga */

i 1 0 3600

e








Send bugs reports to the Sourceforge bug tracker
            https://sourceforge.net/tracker/?group_id=81968&atid=564599
Discussions of bugs and features can be posted here
To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"

Date2010-09-08 00:47
FromIain McCurdy
Subject[Csnd] RE: spat3d distorts using gui
Hi Iain,

Some filtering smooths out the values for kX and kY. I use portk. Like this:

kporttime linseg 0,0.001,0.05
kX portk gkX,kporttime
kY portk gkY,kporttime
aW, aX, aY, aZ spat3d a1, kX, kY, kZ, 1.0, 1, imode, 2, 2

Raising kr might be worth investigating also.

Hope this helps,
Another Iain

> From: acousmetre@gmail.com
> To: csound@lists.bath.ac.uk
> Date: Tue, 7 Sep 2010 18:10:04 -0300
> Subject: [Csnd] spat3d distorts using gui
>
> Hi List
>
> I'm new to csound. I have a project where I need to spatialize audio
> interactively using a quad speaker array. I've looked at a few of the
> options available in csound and spat3d seems to be a good choice for
> what I need, particularly with its simulation of room acoustics. As a
> test I've put spat3d together with an FLjoy interface. It works, however
> when I move the source quickly the sound distorts. This is not the case
> when the coordinates for spat3d are generated non-interactively with
> "line". I wonder what can be done to fix the situation? Interpolation?
> >From what I read in the manual, this should already be done by spat3d.
>
> I'm using linux with jack and a low-latency kernel. There aren't any
> audio buffer overruns and all the csound demos i've tried, work well. I
> have also tested my script with high latency settings in jack as well as
> various settings for -b, -B and kr in csound, but nothing much helps.
> Nor the realtime linux kernel.
>
> I'll paste my test script below. Can anyone suggest a remedy?
>
> It is set up for stereo now - with the top half of the FLjoy interface,
> the active part.
>
> Also - i'm using qutecsound and qjackctl - but i think my command line
> would be this from a terminal:
>
> csound -+rtaudio=jack -+jack_client=QUTECSOUND -odac -iadc -d -b400
> -+rtmidi=null spat3d_joystck.csd
>
> Cheers,
>
> Iain
>
>
> <CsoundSynthesizer>
>
> <CsOptions>
>
> ; Select audio/midi flags here according to platform
>
> ; Audio out Audio in No messages
>
> -odac -iadc -d -b400 -+rtmidi=null ;;;RT audio I/O
>
> ; --sched=1 -iadc
>
> ; For Non-realtime ouput leave only the line below:
>
> ; -o spat3d_stereo.wav -W ;;; for file output any platform
>
> </CsOptions>
>
> <CsInstruments>
>
> /* Written by Istvan Varga */
>
> sr = 48000
>
> kr = 480
>
> ksmps = 100
>
> nchnls = 2
>
> ;FLTK INTERFACE
> CODE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> FLcolor 255, 255, 255, 0, 0, 0
>
> ; LABEL | WIDTH | HEIGHT | X | Y
>
> FLpanel "hrtfer/hrtfmove/hrtfmove2/hrtfstat", 500, 520, 0, 0
>
> ;NUMBER DISPLAY BOXES WIDTH | HEIGHT | X | Y
>
> idX FLvalue "x-axis", 70, 20, 170, 60
>
> idY FLvalue "y-axis", 70, 20, 260, 60
>
> ;GENERAL_TEXT_SETTINGS SIZE | FONT | ALIGN | RED | GREEN | BLUE
>
> FLlabel 13, 4, 1, 255, 255, 255 ;LABELS MADE INVISIBLE (I.E. SAME COLOR
> AS PANEL)
>
> ;GENERAL_TEXT_SETTINGS SIZE | FONT | ALIGN | RED | GREEN | BLUE
>
> FLlabel 13, 4, 3, 0, 0, 0 ;LABELS MADE VISIBLE AGAIN
>
> ;XY PANELS MINX | MAXX | MINY | MAXY | EXPX | EXPY | DISPX | DISPY |
> WIDTH | HEIGHT | X | Y
>
> gkX, gkY, ihX, ihY FLjoy "Spat3D Spatialisation", -4, 4, -4, 4, 0, 0,
> idX, idY, 360, 280, 70, 100
>
> ;;SET INITIAL VALUES VALUE | HANDLE
>
> FLsetVal_i 0, ihX
>
> FLsetVal_i 0, ihY
>
> FLpanel_end
>
> FLrun ;RUN THE FLTK WIDGET THREAD
>
> ;END OF FLTK INTERFACE
> CODE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
>
> /* room parameters */
>
> idep = 1 /* early reflection depth */
>
> itmp ftgen 1, 0, 64, -2, \
>
> /* depth1, depth2, max delay, IR length, idist, seed */ \
>
> idep, 48, -1, 0.01, 0.25, 123, \
>
> 1, 21.982, 0.05, 0.87, 4000.0, 0.6, 0.7, 2, /* ceil */ \
>
> 1, 1.753, 0.05, 0.87, 3500.0, 0.5, 0.7, 2, /* floor */ \
>
> 1, 15.220, 0.05, 0.87, 5000.0, 0.8, 0.7, 2, /* front */ \
>
> 1, 9.317, 0.05, 0.87, 5000.0, 0.8, 0.7, 2, /* back */ \
>
> 1, 17.545, 0.05, 0.87, 5000.0, 0.8, 0.7, 2, /* right */ \
>
> 1, 12.156, 0.05, 0.87, 5000.0, 0.8, 0.7, 2 /* left */
>
> instr 1
>
> gkX init -4
>
> gkY init -4
>
> /* some source signal */
>
> a1 phasor 150 ; oscillator
>
> a1 butterbp a1, 500, 200 ; filter
>
> a1 = taninv(a1 * 100)
>
> a2 phasor 3 ; envelope
>
> a2 mirror 40*a2, -100, 5
>
> a2 limit a2, 0, 1
>
> a1 = a1 * a2 * 9000
>
> ;kazim line 0, 2.5, 360 ; move sound source around
>
> ;kdist line 1, 10, 4 ; distance
>
> ;; convert polar coordinates
>
> ;kX = sin(kazim * 3.14159 / 180) * kdist
>
> ;kY = cos(kazim * 3.14159 / 180) * kdist
>
> kZ = 0
>
> ;printks "kX = %f, kY = %f\\n", 1, kX, kY
>
> a1 = a1 + 0.000001 * 0.000001 ; avoid underflows
>
> imode = 1 ; change this to 3 for 8 spk in a cube,
>
> ; or 1 for simple stereo
>
> ;convert screen derived coord to a-rate with interpolation???
>
> ;aX = a(gkX) ; this doesn't work spat3d requires krate coords
>
> ;aY = a(gkY) ; In any case interp should already be done by spat3d
>
> ;aZ = a(kZ) ; so why does the interface cause glitches?
>
> aW, aX, aY, aZ spat3d a1, gkX, gkY, kZ, 1.0, 1, imode, 2, 2
>
> ;aW, aX, aY, aZ spat3d a1, kX, kY, kZ, 1.0, 1, imode, 2, 2
>
> aW = aW * 1.4142
>
> ; stereo
>
> ;
>
> aL = aW + aY /* left */
>
> aR = aW - aY /* right */
>
> ; quad (square)
>
> ;
>
> ;aFL = aW + aX + aY /* front left */
>
> ;aFR = aW + aX - aY /* front right */
>
> ;aRL = aW - aX + aY /* rear left */
>
> ;aRR = aW - aX - aY /* rear right */
>
> ; eight channels (cube)
>
> ;
>
> ;aUFL = aW + aX + aY + aZ /* upper front left */
>
> ;aUFR = aW + aX - aY + aZ /* upper front right */
>
> ;aURL = aW - aX + aY + aZ /* upper rear left */
>
> ;aURR = aW - aX - aY + aZ /* upper rear right */
>
> ;aLFL = aW + aX + aY - aZ /* lower front left */
>
> ;aLFR = aW + aX - aY - aZ /* lower front right */
>
> ;aLRL = aW - aX + aY - aZ /* lower rear left */
>
> ;aLRR = aW - aX - aY - aZ /* lower rear right */
>
> outs aL, aR
>
> endin
>
> </CsInstruments>
>
> <CsScore>
>
> /* Written by Istvan Varga */
>
> i 1 0 3600
>
> e
>
> </CsScore>
>
> </CsoundSynthesizer>
>
>
>
>
> Send bugs reports to the Sourceforge bug tracker
> https://sourceforge.net/tracker/?group_id=81968&atid=564599
> Discussions of bugs and features can be posted here
> To unsubscribe, send email sympa@lists.bath.ac.uk with body "unsubscribe csound"
>