Csound Csound-dev Csound-tekno Search About

[Csnd] A slider to control the phase shift

Date2024-03-11 20:25
FromItal Rolando
Subject[Csnd] A slider to control the phase shift
Hello to everyone, a newbie here,
With this code I'm trying to control the phase of a sine with a slider, but I'm stuck why it doesn't update when Csound runs:

<CsoundSynthesizer>

<CsOptions>

;-odac8 -B1024 -b1024

</CsOptions>

<CsInstruments>


sr = 44100

ksmps = 64

nchnls = 2

0dbfs = 1


giSine ftgen 1, 0, 2^14, 10, 1


instr 1

kAmpLeft init 0.5

kAmpRight init 0.5

kFreqLeft invalue "freqmodLeft"

kFreqRight invalue "freqmodRight"

kPhaseLeft invalue "phaseLeft"

kMix invalue "mixPhase"

print i(kPhaseLeft)


aLeft oscili kAmpLeft, kFreqLeft, 1, i(kPhaseLeft)

aRight oscili kAmpRight, kFreqRight, 1, 0

outs aLeft + aRight * kMix, aLeft * kMix + aRight

endin


</CsInstruments>

<CsScore>


i1 0 1000

e



</CsScore>

</CsoundSynthesizer>


Ital
--
mob: +39 329 12 67 087
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

Date2024-03-11 20:59
FromST Music
SubjectRe: [Csnd] A slider to control the phase shift
Hi Ital,
   I could be wrong but I think that as oscili will read the phase at i rate this won't work.

You can instead read directly from the ftable using a table/tablei opcode. Here's an example, in this case the phase of the right output is being modulated.

<CsoundSynthesizer>
<CsOptions>
 -odac
; -o phase_mod.wav
</CsOptions>
<CsInstruments>

sr = 48000
ksmps = 32
nchnls = 2
0dbfs  = 1

giSine = ftgen(1, 0, 2^14, 10, 1)

instr 1
  kPhs = line(0, p3, 1) ; phase mod.
  aIdx = phasor(220)
  aL   = tablei:a(aIdx, 1, 1, 0, 1)
  aR   = tablei:a(aIdx + kPhs, 1, 1, 0, 1)
  iAmp = .8
  outs aL * iAmp, aR * iAmp
endin 

</CsInstruments>
<CsScore>
i1 0 16
</CsScore>
</CsoundSynthesizer>

Best,
Scott

On Mon, Mar 11, 2024, 4:25 p.m. Ital Rolando <ital.rolando@gmail.com> wrote:
Hello to everyone, a newbie here,
With this code I'm trying to control the phase of a sine with a slider, but I'm stuck why it doesn't update when Csound runs:

<CsoundSynthesizer>

<CsOptions>

;-odac8 -B1024 -b1024

</CsOptions>

<CsInstruments>


sr = 44100

ksmps = 64

nchnls = 2

0dbfs = 1


giSine ftgen 1, 0, 2^14, 10, 1


instr 1

kAmpLeft init 0.5

kAmpRight init 0.5

kFreqLeft invalue "freqmodLeft"

kFreqRight invalue "freqmodRight"

kPhaseLeft invalue "phaseLeft"

kMix invalue "mixPhase"

print i(kPhaseLeft)


aLeft oscili kAmpLeft, kFreqLeft, 1, i(kPhaseLeft)

aRight oscili kAmpRight, kFreqRight, 1, 0

outs aLeft + aRight * kMix, aLeft * kMix + aRight

endin


</CsInstruments>

<CsScore>


i1 0 1000

e



</CsScore>

</CsoundSynthesizer>


Ital
--
mob: +39 329 12 67 087
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

Date2024-03-11 21:03
FromST Music
SubjectRe: [Csnd] A slider to control the phase shift
I should have noted that the phasor value will determine the frequency of the oscillator. It can be varied at k or a rate.

On Mon, Mar 11, 2024, 4:59 p.m. ST Music <stunes6556@gmail.com> wrote:
Hi Ital,
   I could be wrong but I think that as oscili will read the phase at i rate this won't work.

You can instead read directly from the ftable using a table/tablei opcode. Here's an example, in this case the phase of the right output is being modulated.

<CsoundSynthesizer>
<CsOptions>
 -odac
; -o phase_mod.wav
</CsOptions>
<CsInstruments>

sr = 48000
ksmps = 32
nchnls = 2
0dbfs  = 1

giSine = ftgen(1, 0, 2^14, 10, 1)

instr 1
  kPhs = line(0, p3, 1) ; phase mod.
  aIdx = phasor(220)
  aL   = tablei:a(aIdx, 1, 1, 0, 1)
  aR   = tablei:a(aIdx + kPhs, 1, 1, 0, 1)
  iAmp = .8
  outs aL * iAmp, aR * iAmp
endin 

</CsInstruments>
<CsScore>
i1 0 16
</CsScore>
</CsoundSynthesizer>

Best,
Scott

On Mon, Mar 11, 2024, 4:25 p.m. Ital Rolando <ital.rolando@gmail.com> wrote:
Hello to everyone, a newbie here,
With this code I'm trying to control the phase of a sine with a slider, but I'm stuck why it doesn't update when Csound runs:

<CsoundSynthesizer>

<CsOptions>

;-odac8 -B1024 -b1024

</CsOptions>

<CsInstruments>


sr = 44100

ksmps = 64

nchnls = 2

0dbfs = 1


giSine ftgen 1, 0, 2^14, 10, 1


instr 1

kAmpLeft init 0.5

kAmpRight init 0.5

kFreqLeft invalue "freqmodLeft"

kFreqRight invalue "freqmodRight"

kPhaseLeft invalue "phaseLeft"

kMix invalue "mixPhase"

print i(kPhaseLeft)


aLeft oscili kAmpLeft, kFreqLeft, 1, i(kPhaseLeft)

aRight oscili kAmpRight, kFreqRight, 1, 0

outs aLeft + aRight * kMix, aLeft * kMix + aRight

endin


</CsInstruments>

<CsScore>


i1 0 1000

e



</CsScore>

</CsoundSynthesizer>


Ital
--
mob: +39 329 12 67 087
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

Date2024-03-12 11:53
FromVictor Lazzarini
SubjectRe: [Csnd] [EXTERNAL] [Csnd] A slider to control the phase shift
This is because oscillator phase can’t be changed by a control signal. Try this

kph    invalue    “phase”     
aph    phasor  ifreq                            ; oscillator phase
asig   tablei     aph + kph, -1, 1, 0, 1  ; oscillator output
asig  *= iamp                                      ; amplitude scaling

to replace 

asig oscilli iamp, ifreq

========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 11 Mar 2024, at 20:25, Ital Rolando  wrote:
> 
> *Warning*
> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> Hello to everyone, a newbie here, 
> With this code I'm trying to control the phase of a sine with a slider, but I'm stuck why it doesn't update when Csound runs:
> 
> 
> 
> ;-odac8 -B1024 -b1024
> 
> 
> 
> sr = 44100
> ksmps = 64
> nchnls = 2
> 0dbfs = 1
> 
> giSine ftgen 1, 0, 2^14, 10, 1
> 
> instr 1
> kAmpLeft init 0.5
> kAmpRight init 0.5
> kFreqLeft invalue "freqmodLeft" 
> kFreqRight invalue "freqmodRight" 
> kPhaseLeft invalue "phaseLeft" 
> kMix invalue "mixPhase" print i(kPhaseLeft)
> 
> aLeft oscili kAmpLeft, kFreqLeft, 1, i(kPhaseLeft)
> aRight oscili kAmpRight, kFreqRight, 1, 0outs aLeft + aRight * kMix, aLeft * kMix + aRight
> endin
> 
> 
> 
> 
> i1 0 1000
> e
> 
> 
> 
> 
> 
> Ital
> --
> mob: +39 329 12 67 087
> 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

Date2024-03-12 19:10
FromItal Rolando
SubjectRe: [Csnd] [EXTERNAL] [Csnd] A slider to control the phase shift

Thanks a lot Scott, what a great opportunity to learn more. Really appreciated.


Ital
--
mob: +39 329 12 67 087


Il giorno mar 12 mar 2024 alle ore 12:53 Victor Lazzarini <Victor.Lazzarini@mu.ie> ha scritto:
This is because oscillator phase can’t be changed by a control signal. Try this

kph    invalue    “phase”     
aph    phasor  ifreq                            ; oscillator phase
asig   tablei     aph + kph, -1, 1, 0, 1  ; oscillator output
asig  *= iamp                                      ; amplitude scaling

to replace

asig oscilli iamp, ifreq

========================
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 11 Mar 2024, at 20:25, Ital Rolando <ital.rolando@GMAIL.COM> wrote:
>
> *Warning*
> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
> Hello to everyone, a newbie here,
> With this code I'm trying to control the phase of a sine with a slider, but I'm stuck why it doesn't update when Csound runs:
>
> <CsoundSynthesizer>
> <CsOptions>
> ;-odac8 -B1024 -b1024
> </CsOptions>
> <CsInstruments>
>
> sr = 44100
> ksmps = 64
> nchnls = 2
> 0dbfs = 1
>
> giSine ftgen 1, 0, 2^14, 10, 1
>
> instr 1
> kAmpLeft init 0.5
> kAmpRight init 0.5
> kFreqLeft invalue "freqmodLeft"
> kFreqRight invalue "freqmodRight"
> kPhaseLeft invalue "phaseLeft"
> kMix invalue "mixPhase" print i(kPhaseLeft)
>
> aLeft oscili kAmpLeft, kFreqLeft, 1, i(kPhaseLeft)
> aRight oscili kAmpRight, kFreqRight, 1, 0outs aLeft + aRight * kMix, aLeft * kMix + aRight
> endin
>
> </CsInstruments>
> <CsScore>
>
> i1 0 1000
> e
>
>
> </CsScore>
> </CsoundSynthesizer>
>
> Ital
> --
> mob: +39 329 12 67 087
> 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
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