Csound Csound-dev Csound-tekno Search About

[Csnd] variable downsamp rate w/o using fold opcode

Date2020-06-09 18:16
Fromwalker
Subject[Csnd] variable downsamp rate w/o using fold opcode
hi all,

I am trying to get a modifiable/variable true sample rate reducer, without using the 'fold' opcode.  Although 'fold' does yield good results, I am very curious to see how those compare with a more 'true' sample rate reduction.  Is it possible to change the local ksmps as the downsamp opcode relies on that variable, or perhaps something similar to that?

In this code, I am looking to substitute the section that contains the 'fold' opcode, with the section that contains the 'downsamp' and 'upsamp'.

Any thoughts/advice is greatly appreciated, thank you.

Walker




-odac



sr        = 44100
ksmps     = 32
nchnls    = 2


instr 1
    Sfilename = "/Users/walkerboomy/Desktop/compression_test_files/csound_test.wav"
    ichnls = filenchnls(Sfilename)
    ktrans linseg 1, p3,1
    if (ichnls == 1) then
        asigL diskin2 Sfilename, ktrans
        asigR = 	asigL
    elseif (ichnls == 2) then
        asigL, asigR diskin2 Sfilename, ktrans
    else
        asigL = 0
        asigR = 0
    endif

    kfold linseg 44100, p3, 100

    ;;;; using fold
    afoldL fold asigL, 44100 / kfold 
    afoldR fold asigR, 44100 / kfold 

    outs afoldL, afoldR

    ;;;;; not using fold
    ; setksmps i(kfold)

    ; kdsL downsamp asigL
    ; ausL upsamp kdsL 
    
    ; kdsR downsamp asigR
    ; ausR upsamp kdsR 

    ; outs ausL, ausR
endin



  
i1     0    30

e



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

Date2020-06-09 18:17
FromOeyvind Brandtsegg
SubjectRe: [Csnd] variable downsamp rate w/o using fold opcode
Could you use setksmps in a UDO?

tir. 9. jun. 2020 kl. 19:16 skrev walker <walkerdavismusic@gmail.com>:
hi all,

I am trying to get a modifiable/variable true sample rate reducer, without using the 'fold' opcode.  Although 'fold' does yield good results, I am very curious to see how those compare with a more 'true' sample rate reduction.  Is it possible to change the local ksmps as the downsamp opcode relies on that variable, or perhaps something similar to that?

In this code, I am looking to substitute the section that contains the 'fold' opcode, with the section that contains the 'downsamp' and 'upsamp'.

Any thoughts/advice is greatly appreciated, thank you.

Walker


<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>

sr        = 44100
ksmps     = 32
nchnls    = 2


instr 1
    Sfilename = "/Users/walkerboomy/Desktop/compression_test_files/csound_test.wav"
    ichnls = filenchnls(Sfilename)
    ktrans linseg 1, p3,1
    if (ichnls == 1) then
        asigL diskin2 Sfilename, ktrans
        asigR =         asigL
    elseif (ichnls == 2) then
        asigL, asigR diskin2 Sfilename, ktrans
    else
        asigL = 0
        asigR = 0
    endif

    kfold linseg 44100, p3, 100

    ;;;; using fold
    afoldL fold asigL, 44100 / kfold
    afoldR fold asigR, 44100 / kfold

    outs afoldL, afoldR

    ;;;;; not using fold
    ; setksmps i(kfold)

    ; kdsL downsamp asigL
    ; ausL upsamp kdsL

    ; kdsR downsamp asigR
    ; ausR upsamp kdsR

    ; outs ausL, ausR
endin

</CsInstruments>
<CsScore>

i1     0    30

e
</CsScore>
</CsoundSynthesizer>

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

Date2020-06-09 19:16
FromRory Walsh
SubjectRe: [Csnd] variable downsamp rate w/o using fold opcode
setksmps can be used in instrument definitions too right? 

On Tue, 9 Jun 2020 at 18:18, Oeyvind Brandtsegg <obrandts@gmail.com> wrote:
Could you use setksmps in a UDO?

tir. 9. jun. 2020 kl. 19:16 skrev walker <walkerdavismusic@gmail.com>:
hi all,

I am trying to get a modifiable/variable true sample rate reducer, without using the 'fold' opcode.  Although 'fold' does yield good results, I am very curious to see how those compare with a more 'true' sample rate reduction.  Is it possible to change the local ksmps as the downsamp opcode relies on that variable, or perhaps something similar to that?

In this code, I am looking to substitute the section that contains the 'fold' opcode, with the section that contains the 'downsamp' and 'upsamp'.

Any thoughts/advice is greatly appreciated, thank you.

Walker


<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>

sr        = 44100
ksmps     = 32
nchnls    = 2


instr 1
    Sfilename = "/Users/walkerboomy/Desktop/compression_test_files/csound_test.wav"
    ichnls = filenchnls(Sfilename)
    ktrans linseg 1, p3,1
    if (ichnls == 1) then
        asigL diskin2 Sfilename, ktrans
        asigR =         asigL
    elseif (ichnls == 2) then
        asigL, asigR diskin2 Sfilename, ktrans
    else
        asigL = 0
        asigR = 0
    endif

    kfold linseg 44100, p3, 100

    ;;;; using fold
    afoldL fold asigL, 44100 / kfold
    afoldR fold asigR, 44100 / kfold

    outs afoldL, afoldR

    ;;;;; not using fold
    ; setksmps i(kfold)

    ; kdsL downsamp asigL
    ; ausL upsamp kdsL

    ; kdsR downsamp asigR
    ; ausR upsamp kdsR

    ; outs ausL, ausR
endin

</CsInstruments>
<CsScore>

i1     0    30

e
</CsScore>
</CsoundSynthesizer>

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

Date2020-06-09 19:48
Fromjoachim heintz
SubjectRe: [Csnd] variable downsamp rate w/o using fold opcode
in my experience, it is not really working in instrument definitions, 
whereas in UDOs it works perfectly.


On 09/06/2020 20:16, Rory Walsh wrote:
> setksmps can be used in instrument definitions too right?
> 
> On Tue, 9 Jun 2020 at 18:18, Oeyvind Brandtsegg  > wrote:
> 
>     Could you use setksmps in a UDO?
> 
>     tir. 9. jun. 2020 kl. 19:16 skrev walker      >:
> 
>         hi all,
> 
>         I am trying to get a modifiable/variable true sample rate
>         reducer, without using the 'fold' opcode.  Although 'fold' does
>         yield good results, I am very curious to see how those compare
>         with a more 'true' sample rate reduction.  Is it possible to
>         change the local ksmps as the downsamp opcode relies on that
>         variable, or perhaps something similar to that?
> 
>         In this code, I am looking to substitute the section that
>         contains the 'fold' opcode, with the section that contains the
>         'downsamp' and 'upsamp'.
> 
>         Any thoughts/advice is greatly appreciated, thank you.
> 
>         Walker
> 
> 
>         
>         
>         -odac
>         
>         
> 
>         sr        = 44100
>         ksmps     = 32
>         nchnls    = 2
> 
> 
>         instr 1
>              Sfilename =
>         "/Users/walkerboomy/Desktop/compression_test_files/csound_test.wav"
>              ichnls = filenchnls(Sfilename)
>              ktrans linseg 1, p3,1
>              if (ichnls == 1) then
>                  asigL diskin2 Sfilename, ktrans
>                  asigR =         asigL
>              elseif (ichnls == 2) then
>                  asigL, asigR diskin2 Sfilename, ktrans
>              else
>                  asigL = 0
>                  asigR = 0
>              endif
> 
>              kfold linseg 44100, p3, 100
> 
>              ;;;; using fold
>              afoldL fold asigL, 44100 / kfold
>              afoldR fold asigR, 44100 / kfold
> 
>              outs afoldL, afoldR
> 
>              ;;;;; not using fold
>              ; setksmps i(kfold)
> 
>              ; kdsL downsamp asigL
>              ; ausL upsamp kdsL
> 
>              ; kdsR downsamp asigR
>              ; ausR upsamp kdsR
> 
>              ; outs ausL, ausR
>         endin
> 
>         
>         
> 
>         i1     0    30
> 
>         e
>         
>         
> 
>         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

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

Date2020-06-09 20:04
FromRory Walsh
SubjectRe: [Csnd] variable downsamp rate w/o using fold opcode
That was my experience with it too, until recently, where it performed fine in an instrument definition. In relation to the original question, is it possible to dynamically change the local ksmps using a reinit? I keep getting errors. Strange that it reports the original ksmps to be 1, when it's set to 512?

<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>
;sr is set by the host
nchnls = 2 ;main outputs
ksmps = 512
0dbfs = 1

opcode Folda,ak
    aIn, kFreq xin    
    if changed(kFreq)==1 then
        reinit REINIT
    endif
    REINIT:
        setksmps 2^i(kFreq)
    
    kdsL downsamp aIn
    ausL upsamp kdsL 
    xout ausL
   
endop

instr 1
    aoscili 1300
    aOut Fold aL, int(line:k(01010))
    outs aOut, aOut
endin

</CsInstruments>

<CsScore>
i 1 0 [3600*24*7]
</CsScore>

</CsoundSynthesizer>


Output:
SECTION 1:
new alloc for instr 1:
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 2, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 4, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 8, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 16, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 32, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3


On Tue, 9 Jun 2020 at 19:48, joachim heintz <jh@joachimheintz.de> wrote:
in my experience, it is not really working in instrument definitions,
whereas in UDOs it works perfectly.


On 09/06/2020 20:16, Rory Walsh wrote:
> setksmps can be used in instrument definitions too right?
>
> On Tue, 9 Jun 2020 at 18:18, Oeyvind Brandtsegg <obrandts@gmail.com
> <mailto:obrandts@gmail.com>> wrote:
>
>     Could you use setksmps in a UDO?
>
>     tir. 9. jun. 2020 kl. 19:16 skrev walker <walkerdavismusic@gmail.com
>     <mailto:walkerdavismusic@gmail.com>>:
>
>         hi all,
>
>         I am trying to get a modifiable/variable true sample rate
>         reducer, without using the 'fold' opcode.  Although 'fold' does
>         yield good results, I am very curious to see how those compare
>         with a more 'true' sample rate reduction.  Is it possible to
>         change the local ksmps as the downsamp opcode relies on that
>         variable, or perhaps something similar to that?
>
>         In this code, I am looking to substitute the section that
>         contains the 'fold' opcode, with the section that contains the
>         'downsamp' and 'upsamp'.
>
>         Any thoughts/advice is greatly appreciated, thank you.
>
>         Walker
>
>
>         <CsoundSynthesizer>
>         <CsOptions>
>         -odac
>         </CsOptions>
>         <CsInstruments>
>
>         sr        = 44100
>         ksmps     = 32
>         nchnls    = 2
>
>
>         instr 1
>              Sfilename =
>         "/Users/walkerboomy/Desktop/compression_test_files/csound_test.wav"
>              ichnls = filenchnls(Sfilename)
>              ktrans linseg 1, p3,1
>              if (ichnls == 1) then
>                  asigL diskin2 Sfilename, ktrans
>                  asigR =         asigL
>              elseif (ichnls == 2) then
>                  asigL, asigR diskin2 Sfilename, ktrans
>              else
>                  asigL = 0
>                  asigR = 0
>              endif
>
>              kfold linseg 44100, p3, 100
>
>              ;;;; using fold
>              afoldL fold asigL, 44100 / kfold
>              afoldR fold asigR, 44100 / kfold
>
>              outs afoldL, afoldR
>
>              ;;;;; not using fold
>              ; setksmps i(kfold)
>
>              ; kdsL downsamp asigL
>              ; ausL upsamp kdsL
>
>              ; kdsR downsamp asigR
>              ; ausR upsamp kdsR
>
>              ; outs ausL, ausR
>         endin
>
>         </CsInstruments>
>         <CsScore>
>
>         i1     0    30
>
>         e
>         </CsScore>
>         </CsoundSynthesizer>
>
>         Csound mailing list
>         Csound@listserv.heanet.ie <mailto: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
>     <mailto: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
> <mailto: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

Date2020-06-10 00:51
Fromwalker davis
SubjectRe: [Csnd] variable downsamp rate w/o using fold opcode
Ok, I think what I am looking for is something more like a sample hold at the downsample krate.  From what I can tell, this is happening in Faust's downSample function, here:


Is this possible with csound's samphold opcode?  This would likely eliminate the need of a variable local ksmps...


Thanks again for all of the insight and help


On Tue, Jun 9, 2020 at 12:04 PM Rory Walsh <rorywalsh@ear.ie> wrote:
That was my experience with it too, until recently, where it performed fine in an instrument definition. In relation to the original question, is it possible to dynamically change the local ksmps using a reinit? I keep getting errors. Strange that it reports the original ksmps to be 1, when it's set to 512?

<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>
;sr is set by the host
nchnls = 2 ;main outputs
ksmps = 512
0dbfs = 1

opcode Folda,ak
    aIn, kFreq xin    
    if changed(kFreq)==1 then
        reinit REINIT
    endif
    REINIT:
        setksmps 2^i(kFreq)
    
    kdsL downsamp aIn
    ausL upsamp kdsL 
    xout ausL
   
endop

instr 1
    aoscili 1300
    aOut Fold aL, int(line:k(01010))
    outs aOut, aOut
endin

</CsInstruments>

<CsScore>
i 1 0 [3600*24*7]
</CsScore>

</CsoundSynthesizer>


Output:
SECTION 1:
new alloc for instr 1:
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 2, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 4, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 8, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 16, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 32, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3


On Tue, 9 Jun 2020 at 19:48, joachim heintz <jh@joachimheintz.de> wrote:
in my experience, it is not really working in instrument definitions,
whereas in UDOs it works perfectly.


On 09/06/2020 20:16, Rory Walsh wrote:
> setksmps can be used in instrument definitions too right?
>
> On Tue, 9 Jun 2020 at 18:18, Oeyvind Brandtsegg <obrandts@gmail.com
> <mailto:obrandts@gmail.com>> wrote:
>
>     Could you use setksmps in a UDO?
>
>     tir. 9. jun. 2020 kl. 19:16 skrev walker <walkerdavismusic@gmail.com
>     <mailto:walkerdavismusic@gmail.com>>:
>
>         hi all,
>
>         I am trying to get a modifiable/variable true sample rate
>         reducer, without using the 'fold' opcode.  Although 'fold' does
>         yield good results, I am very curious to see how those compare
>         with a more 'true' sample rate reduction.  Is it possible to
>         change the local ksmps as the downsamp opcode relies on that
>         variable, or perhaps something similar to that?
>
>         In this code, I am looking to substitute the section that
>         contains the 'fold' opcode, with the section that contains the
>         'downsamp' and 'upsamp'.
>
>         Any thoughts/advice is greatly appreciated, thank you.
>
>         Walker
>
>
>         <CsoundSynthesizer>
>         <CsOptions>
>         -odac
>         </CsOptions>
>         <CsInstruments>
>
>         sr        = 44100
>         ksmps     = 32
>         nchnls    = 2
>
>
>         instr 1
>              Sfilename =
>         "/Users/walkerboomy/Desktop/compression_test_files/csound_test.wav"
>              ichnls = filenchnls(Sfilename)
>              ktrans linseg 1, p3,1
>              if (ichnls == 1) then
>                  asigL diskin2 Sfilename, ktrans
>                  asigR =         asigL
>              elseif (ichnls == 2) then
>                  asigL, asigR diskin2 Sfilename, ktrans
>              else
>                  asigL = 0
>                  asigR = 0
>              endif
>
>              kfold linseg 44100, p3, 100
>
>              ;;;; using fold
>              afoldL fold asigL, 44100 / kfold
>              afoldR fold asigR, 44100 / kfold
>
>              outs afoldL, afoldR
>
>              ;;;;; not using fold
>              ; setksmps i(kfold)
>
>              ; kdsL downsamp asigL
>              ; ausL upsamp kdsL
>
>              ; kdsR downsamp asigR
>              ; ausR upsamp kdsR
>
>              ; outs ausL, ausR
>         endin
>
>         </CsInstruments>
>         <CsScore>
>
>         i1     0    30
>
>         e
>         </CsScore>
>         </CsoundSynthesizer>
>
>         Csound mailing list
>         Csound@listserv.heanet.ie <mailto: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
>     <mailto: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
> <mailto: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
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

Date2020-06-10 01:39
FromSteven Yi
SubjectRe: [Csnd] variable downsamp rate w/o using fold opcode
I think fold is doing sample and hold:


unless I'm missing something?

On Tue, Jun 9, 2020 at 7:51 PM walker davis <walkerdavismusic@gmail.com> wrote:
Ok, I think what I am looking for is something more like a sample hold at the downsample krate.  From what I can tell, this is happening in Faust's downSample function, here:


Is this possible with csound's samphold opcode?  This would likely eliminate the need of a variable local ksmps...


Thanks again for all of the insight and help


On Tue, Jun 9, 2020 at 12:04 PM Rory Walsh <rorywalsh@ear.ie> wrote:
That was my experience with it too, until recently, where it performed fine in an instrument definition. In relation to the original question, is it possible to dynamically change the local ksmps using a reinit? I keep getting errors. Strange that it reports the original ksmps to be 1, when it's set to 512?

<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>
;sr is set by the host
nchnls = 2 ;main outputs
ksmps = 512
0dbfs = 1

opcode Folda,ak
    aIn, kFreq xin    
    if changed(kFreq)==1 then
        reinit REINIT
    endif
    REINIT:
        setksmps 2^i(kFreq)
    
    kdsL downsamp aIn
    ausL upsamp kdsL 
    xout ausL
   
endop

instr 1
    aoscili 1300
    aOut Fold aL, int(line:k(01010))
    outs aOut, aOut
endin

</CsInstruments>

<CsScore>
i 1 0 [3600*24*7]
</CsScore>

</CsoundSynthesizer>


Output:
SECTION 1:
new alloc for instr 1:
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 2, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 4, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 8, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 16, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 32, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3


On Tue, 9 Jun 2020 at 19:48, joachim heintz <jh@joachimheintz.de> wrote:
in my experience, it is not really working in instrument definitions,
whereas in UDOs it works perfectly.


On 09/06/2020 20:16, Rory Walsh wrote:
> setksmps can be used in instrument definitions too right?
>
> On Tue, 9 Jun 2020 at 18:18, Oeyvind Brandtsegg <obrandts@gmail.com
> <mailto:obrandts@gmail.com>> wrote:
>
>     Could you use setksmps in a UDO?
>
>     tir. 9. jun. 2020 kl. 19:16 skrev walker <walkerdavismusic@gmail.com
>     <mailto:walkerdavismusic@gmail.com>>:
>
>         hi all,
>
>         I am trying to get a modifiable/variable true sample rate
>         reducer, without using the 'fold' opcode.  Although 'fold' does
>         yield good results, I am very curious to see how those compare
>         with a more 'true' sample rate reduction.  Is it possible to
>         change the local ksmps as the downsamp opcode relies on that
>         variable, or perhaps something similar to that?
>
>         In this code, I am looking to substitute the section that
>         contains the 'fold' opcode, with the section that contains the
>         'downsamp' and 'upsamp'.
>
>         Any thoughts/advice is greatly appreciated, thank you.
>
>         Walker
>
>
>         <CsoundSynthesizer>
>         <CsOptions>
>         -odac
>         </CsOptions>
>         <CsInstruments>
>
>         sr        = 44100
>         ksmps     = 32
>         nchnls    = 2
>
>
>         instr 1
>              Sfilename =
>         "/Users/walkerboomy/Desktop/compression_test_files/csound_test.wav"
>              ichnls = filenchnls(Sfilename)
>              ktrans linseg 1, p3,1
>              if (ichnls == 1) then
>                  asigL diskin2 Sfilename, ktrans
>                  asigR =         asigL
>              elseif (ichnls == 2) then
>                  asigL, asigR diskin2 Sfilename, ktrans
>              else
>                  asigL = 0
>                  asigR = 0
>              endif
>
>              kfold linseg 44100, p3, 100
>
>              ;;;; using fold
>              afoldL fold asigL, 44100 / kfold
>              afoldR fold asigR, 44100 / kfold
>
>              outs afoldL, afoldR
>
>              ;;;;; not using fold
>              ; setksmps i(kfold)
>
>              ; kdsL downsamp asigL
>              ; ausL upsamp kdsL
>
>              ; kdsR downsamp asigR
>              ; ausR upsamp kdsR
>
>              ; outs ausL, ausR
>         endin
>
>         </CsInstruments>
>         <CsScore>
>
>         i1     0    30
>
>         e
>         </CsScore>
>         </CsoundSynthesizer>
>
>         Csound mailing list
>         Csound@listserv.heanet.ie <mailto: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
>     <mailto: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
> <mailto: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
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

Date2020-06-10 01:55
Fromwalker davis
SubjectRe: [Csnd] variable downsamp rate w/o using fold opcode
Thanks Steven,

That makes sense.  I was able to use mpulse and samphold to get something going, but it looks like that is the same as fold...  At least I learned a few things on this venture haha.

Thanks for all the help everyone!



On Tue, Jun 9, 2020 at 5:39 PM Steven Yi <stevenyi@gmail.com> wrote:
I think fold is doing sample and hold:


unless I'm missing something?

On Tue, Jun 9, 2020 at 7:51 PM walker davis <walkerdavismusic@gmail.com> wrote:
Ok, I think what I am looking for is something more like a sample hold at the downsample krate.  From what I can tell, this is happening in Faust's downSample function, here:


Is this possible with csound's samphold opcode?  This would likely eliminate the need of a variable local ksmps...


Thanks again for all of the insight and help


On Tue, Jun 9, 2020 at 12:04 PM Rory Walsh <rorywalsh@ear.ie> wrote:
That was my experience with it too, until recently, where it performed fine in an instrument definition. In relation to the original question, is it possible to dynamically change the local ksmps using a reinit? I keep getting errors. Strange that it reports the original ksmps to be 1, when it's set to 512?

<CsoundSynthesizer>
<CsOptions>
-odac
</CsOptions>
<CsInstruments>
;sr is set by the host
nchnls = 2 ;main outputs
ksmps = 512
0dbfs = 1

opcode Folda,ak
    aIn, kFreq xin    
    if changed(kFreq)==1 then
        reinit REINIT
    endif
    REINIT:
        setksmps 2^i(kFreq)
    
    kdsL downsamp aIn
    ausL upsamp kdsL 
    xout ausL
   
endop

instr 1
    aoscili 1300
    aOut Fold aL, int(line:k(01010))
    outs aOut, aOut
endin

</CsInstruments>

<CsScore>
i 1 0 [3600*24*7]
</CsScore>

</CsoundSynthesizer>


Output:
SECTION 1:
new alloc for instr 1:
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 2, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 4, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 8, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 16, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3
INIT ERROR in instr 1 (opcode Fold) line 16: setksmps: invalid ksmps value: 32, original: 1
 from file .\CabbagePlugin (1).csd (1)
        setksmps        #i3


On Tue, 9 Jun 2020 at 19:48, joachim heintz <jh@joachimheintz.de> wrote:
in my experience, it is not really working in instrument definitions,
whereas in UDOs it works perfectly.


On 09/06/2020 20:16, Rory Walsh wrote:
> setksmps can be used in instrument definitions too right?
>
> On Tue, 9 Jun 2020 at 18:18, Oeyvind Brandtsegg <obrandts@gmail.com
> <mailto:obrandts@gmail.com>> wrote:
>
>     Could you use setksmps in a UDO?
>
>     tir. 9. jun. 2020 kl. 19:16 skrev walker <walkerdavismusic@gmail.com
>     <mailto:walkerdavismusic@gmail.com>>:
>
>         hi all,
>
>         I am trying to get a modifiable/variable true sample rate
>         reducer, without using the 'fold' opcode.  Although 'fold' does
>         yield good results, I am very curious to see how those compare
>         with a more 'true' sample rate reduction.  Is it possible to
>         change the local ksmps as the downsamp opcode relies on that
>         variable, or perhaps something similar to that?
>
>         In this code, I am looking to substitute the section that
>         contains the 'fold' opcode, with the section that contains the
>         'downsamp' and 'upsamp'.
>
>         Any thoughts/advice is greatly appreciated, thank you.
>
>         Walker
>
>
>         <CsoundSynthesizer>
>         <CsOptions>
>         -odac
>         </CsOptions>
>         <CsInstruments>
>
>         sr        = 44100
>         ksmps     = 32
>         nchnls    = 2
>
>
>         instr 1
>              Sfilename =
>         "/Users/walkerboomy/Desktop/compression_test_files/csound_test.wav"
>              ichnls = filenchnls(Sfilename)
>              ktrans linseg 1, p3,1
>              if (ichnls == 1) then
>                  asigL diskin2 Sfilename, ktrans
>                  asigR =         asigL
>              elseif (ichnls == 2) then
>                  asigL, asigR diskin2 Sfilename, ktrans
>              else
>                  asigL = 0
>                  asigR = 0
>              endif
>
>              kfold linseg 44100, p3, 100
>
>              ;;;; using fold
>              afoldL fold asigL, 44100 / kfold
>              afoldR fold asigR, 44100 / kfold
>
>              outs afoldL, afoldR
>
>              ;;;;; not using fold
>              ; setksmps i(kfold)
>
>              ; kdsL downsamp asigL
>              ; ausL upsamp kdsL
>
>              ; kdsR downsamp asigR
>              ; ausR upsamp kdsR
>
>              ; outs ausL, ausR
>         endin
>
>         </CsInstruments>
>         <CsScore>
>
>         i1     0    30
>
>         e
>         </CsScore>
>         </CsoundSynthesizer>
>
>         Csound mailing list
>         Csound@listserv.heanet.ie <mailto: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
>     <mailto: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
> <mailto: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
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