Csound Csound-dev Csound-tekno Search About

[Csnd] trouble adding phase deviation to fog pointer

Date2018-12-03 16:18
Frompacos1989
Subject[Csnd] trouble adding phase deviation to fog pointer
hi all, 
On the way to build a real time Granular Synthetizer of a sound source some 
unaspected results come out,one of this when adding phase deviation values 
to the reading pointer. 
It s seem that adding random values to the pointer implicate a double 
reading of one full cycle of the writing table. In this way we listen after 
first table cycle the delayed signal  with the new signal  of the second 
cycle of the table. That doesn't happen with no phase deviation. Anyone have
an explanation for this? 

- win 7 intel core duo , 4 gb ram , 
  csoundqt 0.9.3 



;-W -G -ofile#1.wav 
-odac 



sr      = 44100 
ksmps   = 1 
nchnls  = 2 
0dbfs   = 1 

gibuflen = 524288               ; buffer length 
gilivebuf ftgen 1,0,gibuflen,2,0        ;  function table 

;------------writing buffer------------ 

instr 1 

;asig   in 
asig,asig0 diskin2 "testsample.wav",1 
gkpnt = sr/524288 
gapnt phasor gkpnt 
        tablew asig,gapnt,gilivebuf,1,0,2 

endin 

;---------------Granulator------------------------------ 
instr 2 

ifna    = gilivebuf                             ; sound buffer 
ifnb    = 2                                     ; Hanning window 
;----------------------------------------------------------------------- 
; DENSITY 
kdns    init 50   
kdnsd   init 0   
kdnsf   init 1 
;       printk .1,kdns 

kdnsr   randh kdnsd, kdns, 2, 1 
kdnsf   = kdns * (1+kdnsr) 
        ;display kdnsr, p3 
        ;printk .5, kdnsf 
;----------------------------------------------------------------------- 
; DURATION 

kgdur   init 0.5 
kgdurd  init 0 

kgdurdr rand kgdurd 

kgdur   = kgdur * (1+kgdurdr) 

kris    = kgdur * .5 
kdec    = kgdur * .5 
;============================================== 
; POINTER 
;============================================== 
kphdev  init 0.2                ; random phase value 
;kphdev init 0          ; no random phase value added 
kph     rand kphdev 
areadpnt        = gapnt + kph 
areadpnt mirror areadpnt, 0,1 
;--------------------------------------------------------- 
;TRANSPOSITION 

ktransp init 1 
;-------------------------------------------------------------------------------------------------- 
; Scale amplitude with density 
krisc   tablei kdns/4096, 190, 1                 
kamp    = 0.5 * krisc 

;ar     fog xamp, xdens, kcps,   areadpnt, koct, kband, kris, kgdur, kdec, 
iolaps, ifna, ifnb, itotdur[, iphs][, itmode][, iskip] 
ar      fog kamp, kdnsf,ktransp, areadpnt, 0,    0,     kris, kgdur, kdec,
1000, 
ifna, ifnb, p3 

outs ar,ar 
endin 



;================================================================================================= 
; grain envelope (hanning) 
;================================================================================================= 
f2 0    8192    19  .5 .5 270 .5 
;================================================================================================= 
; amplitude scaling 
f190 0  4096    -25     0 1     4096 .05         

i 1 0 30 
i 2 0 30 
e 




many  thanks, 
Pascal



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2018-12-03 16:53
FromOeyvind Brandtsegg
SubjectRe: [Csnd] trouble adding phase deviation to fog pointer
I haven't tested your code, but it is highly likely that the random deviation to the time pointer will interact with the write position. What happens is probably that some grains are started just after the write position (which is fine, they get a few milliseconds delay), while some grains are started just before the write position (which will create a delay equal to the buffer size of the circular buffer you are using to write the live audio input). Taking care that the write and read pointers do not cross each other is important to maintain a predictable output. You might also get odd glitches if you start reading just before the write position but you also transpose up, making the read pointer "overtake" the write pointer, and then there is a discontinuity in the circular buffer right there.

An easy fix *might* be to try
areadpnt        = gapnt + abs(kph)   
as you would then avoid the bipolar randomness.
This is a quick guess from my side,m so please don't shoot if it does not work ;-)

Oeyvind



Den man. 3. des. 2018 kl. 17:28 skrev pacos1989 <p.graziano89@gmail.com>:
hi all,
On the way to build a real time Granular Synthetizer of a sound source some
unaspected results come out,one of this when adding phase deviation values
to the reading pointer.
It s seem that adding random values to the pointer implicate a double
reading of one full cycle of the writing table. In this way we listen after
first table cycle the delayed signal  with the new signal  of the second
cycle of the table. That doesn't happen with no phase deviation. Anyone have
an explanation for this?

- win 7 intel core duo , 4 gb ram ,
  csoundqt 0.9.3

<CsoundSynthesizer>
<CsOptions>
;-W -G -ofile#1.wav
-odac
</CsOptions>
<CsInstruments>

sr      = 44100
ksmps   = 1
nchnls  = 2
0dbfs   = 1

gibuflen = 524288               ; buffer length
gilivebuf ftgen 1,0,gibuflen,2,0        ;  function table

;------------writing buffer------------

instr 1

;asig   in
asig,asig0 diskin2 "testsample.wav",1
gkpnt = sr/524288
gapnt phasor gkpnt
        tablew asig,gapnt,gilivebuf,1,0,2

endin

;---------------Granulator------------------------------
instr 2

ifna    = gilivebuf                             ; sound buffer
ifnb    = 2                                     ; Hanning window
;-----------------------------------------------------------------------
; DENSITY
kdns    init 50   
kdnsd   init 0   
kdnsf   init 1
;       printk .1,kdns

kdnsr   randh kdnsd, kdns, 2, 1
kdnsf   = kdns * (1+kdnsr)
        ;display kdnsr, p3
        ;printk .5, kdnsf
;-----------------------------------------------------------------------
; DURATION

kgdur   init 0.5
kgdurd  init 0

kgdurdr rand kgdurd

kgdur   = kgdur * (1+kgdurdr)

kris    = kgdur * .5
kdec    = kgdur * .5
;==============================================
; POINTER
;==============================================
kphdev  init 0.2                ; random phase value
;kphdev init 0          ; no random phase value added
kph     rand kphdev
areadpnt        = gapnt + kph
areadpnt mirror areadpnt, 0,1
;---------------------------------------------------------
;TRANSPOSITION

ktransp init 1
;--------------------------------------------------------------------------------------------------
; Scale amplitude with density
krisc   tablei kdns/4096, 190, 1                 
kamp    = 0.5 * krisc

;ar     fog xamp, xdens, kcps,   areadpnt, koct, kband, kris, kgdur, kdec,
iolaps, ifna, ifnb, itotdur[, iphs][, itmode][, iskip]
ar      fog kamp, kdnsf,ktransp, areadpnt, 0,    0,     kris, kgdur, kdec,
1000,
ifna, ifnb, p3

outs ar,ar
endin

</CsInstruments>
<CsScore>
;=================================================================================================
; grain envelope (hanning)
;=================================================================================================
f2 0    8192    19  .5 .5 270 .5
;=================================================================================================
; amplitude scaling
f190 0  4096    -25     0 1     4096 .05         

i 1 0 30
i 2 0 30
e
</CsScore>
</CsoundSynthesizer>


many  thanks,
Pascal



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here


--
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2018-12-03 22:16
Frompacos1989
SubjectRe: [Csnd] trouble adding phase deviation to fog pointer
i had already considered to circumscribe pointer boundaries, using linrand in
a similar patch to add jitter to the pointer. Unfortunately it seems doesn
't work as expected, 
making me even more perplexed and curious about how the pointer can still
delay a table cycle. Anyway thanks me to remind me that  



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2018-12-04 07:48
FromOeyvind Brandtsegg
SubjectRe: [Csnd] trouble adding phase deviation to fog pointer
IIRC there are some examples of how to do this in the Springer Csound book, using partikkel. 

Den man. 3. des. 2018, 11:16 p.m. skrev pacos1989 <p.graziano89@gmail.com:
i had already considered to circumscribe pointer boundaries, using linrand in
a similar patch to add jitter to the pointer. Unfortunately it seems doesn
't work as expected,
making me even more perplexed and curious about how the pointer can still
delay a table cycle. Anyway thanks me to remind me that 



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2018-12-04 10:55
Frompacos1989
SubjectRe: [Csnd] trouble adding phase deviation to fog pointer
I ve that book (Springer) and already checked the  exhaustive 15th chapter
about granular synthesis. i will do it again more carefully!



--
Sent from: http://csound.1045644.n5.nabble.com/Csound-General-f1093014.html

Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here