Csound Csound-dev Csound-tekno Search About

[Csnd] compress opcode discontinuities using acontrolsig - is there a csound zeros opcode?

Date2020-05-12 18:58
Fromwalker
Subject[Csnd] compress opcode discontinuities using acontrolsig - is there a csound zeros opcode?
Hey everybody,

Hope you are all well.  Anyways, I am trying to do some side chain
compression on audio files(this problem does not seem to exist with oscil
instruments, if I remember correctly).  

In this example/issue, I have 2 instruments here.  instr 1 is the signal
that is to be compressed/sidechained/dipped, a pad or reverb-y/suspended
sample works nicely.  instr 2 is the control signal, generally something
shorter like a kick or snare sample.  I have routed both of these to global
signals which are the input to 'bus' instrument tracks, instr 20.  For this
demo/test the control signal never reaches the DAC, it is just in place to
manipulate the compressed signal.

Using just two of the diskin2 opcodes to read and play the audio file data,
there are a few issues.
- when the control signal is not producing noise(end of event or audio
file), the compressed signal drops out
- there are some clear discontinuities and pops when this happens

Hack-y remedy:
Uncomment instr 3, a signal of very quiet white noise.  This prevents the
drop outs and discontinuities from happening.  To me, this makes the
compress opcode behave like compressors and compressor plug-ins I have used
outside of Csound...  The audio results sounds good to me, but it just feels
weird/unnecessary to use noise as the signal stabilizer though...  Is there
some kind of zero generating opcode?  I have searched, but haven't found
anything...  

Noise amplitude issue:
You will see that in the below code, there are two lines for noise
generation.  When the amplitude of noise is 0.0001, my hack works.  When the
amplitude is decreased to 0.00001, the discontinuities and pops return. 
This is not a major issue, but I don't quite understand....


This code demonstrates should work so long as you supply file paths for
instr's 1 and 2.




; Select audio/midi flags here according to platform
-odac  ;-iadc    ;;;RT audio out and in
; For Non-realtime ouput leave only the line below:



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

ga_compressed_sig        init 0
ga_control_sig           init 0


; signal to be sidechained/dipped
instr 1
     Sfilename = PAD_OR_LONG_SAMPLE_FILEPATH
     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

     ga_compressed_sig += asigL
endin

; signal controlling/doing the chaining/dipping
instr 2
     Sfilename = SNARE_OR_SHORT_SAMPLE_FILEPATH
     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

     ga_control_sig += asigL
endin

;; add noise to control signal to prevent pops, seems hacky tho
; instr 3
;      asig noise 0.0001, 0
;;      asig noise 0.00001, 0 ;discontinuities return

;      ga_control_sig += asig
; endin

instr 20

     acomp     compress ga_compressed_sig, (ga_control_sig / 2), -10, 40,
60, 300, 0.005, 0.01, 0.0
     outs acomp, acomp

     ga_compressed_sig = 0
     ga_control_sig = 0
endin





i20     0   7

i1      0   7 

i2      0   1
i2      +   1
i2      +   1
i2      +   1
i2      +   1
i2      +   1
i2      +   1

i3      0   7

e





--
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

Date2020-05-15 20:17
Fromwalker
SubjectRe: [Csnd] compress opcode discontinuities using acontrolsig - is there a csound zeros opcode?
Just looping back on this from earlier this week.....

Didn't hear from anybody, so I thought I would resend.  I really hate to
spam, but this issue definitely exceeds my csound knowledge.  Any
advice/tips/conversation on this would be greatly appreciated.

Cheers,

Walker



--
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

Date2020-05-16 07:06
FromPete Goodeve
SubjectRe: [Csnd] compress opcode discontinuities using acontrolsig - is there a csound zeros opcode?
AttachmentsNone  

Date2020-05-16 16:43
FromHlöðver Sigurðsson
SubjectRe: [Csnd] compress opcode discontinuities using acontrolsig - is there a csound zeros opcode?
Interestign question, I'll have a look tonight. Don't see fully what's going on, but if you need to add noise, you could check if you change headphones/speakers has any effect (dither effect). Or this is just a click from too sudden silence to noise. I don't see any line:a port:a opcodes usage on a quick look.

On Sat, 16 May 2020 at 08:06, Pete Goodeve <pete.goodeve@computer.org> wrote:
Hi Walker,

It's a  shame no-one with actual experience with the opcode
has responded (:-/) but I had some spare time, so I played a bit.

All I can say is that 'compress' is one peculiar beast.  As increasing
the control signal decreases the amplitude of the controlled audio,
I would naturally expect a *zero* control to give *maximum* output.
On the contrary, a zero control *suppresses* the output!

In fact, any DC control value kills the output, and the AC has to
be above a certain (small) level to be noticed. (As you found.)

I have actually just found that giving the threshold parameter of
compress a *large* negative value -- I tried '-10000' -- prevents
killing the signal even with zero noise.

Not sure about the 'pops'.  May depend on the sources/  I used
'mandpluk.aiff for the impulse, and a handy sustained-chord test
file I had around for the other.

Hope that's some use...

        -- Pete --


On Tue, May 12, 2020 at 10:58:34AM -0700, walker wrote:
> Hey everybody,
>
> Hope you are all well.  Anyways, I am trying to do some side chain
> compression on audio files(this problem does not seem to exist with oscil
> instruments, if I remember correctly). 
>
> In this example/issue, I have 2 instruments here.  instr 1 is the signal
> that is to be compressed/sidechained/dipped, a pad or reverb-y/suspended
> sample works nicely.  instr 2 is the control signal, generally something
> shorter like a kick or snare sample.  I have routed both of these to global
> signals which are the input to 'bus' instrument tracks, instr 20.  For this
> demo/test the control signal never reaches the DAC, it is just in place to
> manipulate the compressed signal.
>
> Using just two of the diskin2 opcodes to read and play the audio file data,
> there are a few issues.
> - when the control signal is not producing noise(end of event or audio
> file), the compressed signal drops out
> - there are some clear discontinuities and pops when this happens
>
> Hack-y remedy:
> Uncomment instr 3, a signal of very quiet white noise.  This prevents the
> drop outs and discontinuities from happening.  To me, this makes the
> compress opcode behave like compressors and compressor plug-ins I have used
> outside of Csound...  The audio results sounds good to me, but it just feels
> weird/unnecessary to use noise as the signal stabilizer though...  Is there
> some kind of zero generating opcode?  I have searched, but haven't found
> anything... 
>
> Noise amplitude issue:
> You will see that in the below code, there are two lines for noise
> generation.  When the amplitude of noise is 0.0001, my hack works.  When the
> amplitude is decreased to 0.00001, the discontinuities and pops return.
> This is not a major issue, but I don't quite understand....
>
>
> This code demonstrates should work so long as you supply file paths for
> instr's 1 and 2.
>
>
> <CsoundSynthesizer>
> <CsOptions>
> ; Select audio/midi flags here according to platform
> -odac  ;-iadc    ;;;RT audio out and in
> ; For Non-realtime ouput leave only the line below:
> </CsOptions>
> <CsInstruments>
>
> sr        = 44100
> ksmps     = 441
> nchnls    = 2
> 0dbfs     = 1
>
> ga_compressed_sig        init 0
> ga_control_sig           init 0
>
>
> ; signal to be sidechained/dipped
> instr 1
>      Sfilename = PAD_OR_LONG_SAMPLE_FILEPATH
>      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
>
>      ga_compressed_sig += asigL
> endin
>
> ; signal controlling/doing the chaining/dipping
> instr 2
>      Sfilename = SNARE_OR_SHORT_SAMPLE_FILEPATH
>      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
>
>      ga_control_sig += asigL
> endin
>
> ;; add noise to control signal to prevent pops, seems hacky tho
> ; instr 3
> ;      asig noise 0.0001, 0
> ;;      asig noise 0.00001, 0 ;discontinuities return
>
> ;      ga_control_sig += asig
> ; endin
>
> instr 20
>
>      acomp     compress ga_compressed_sig, (ga_control_sig / 2), -10, 40,
> 60, 300, 0.005, 0.01, 0.0
>      outs acomp, acomp
>
>      ga_compressed_sig = 0
>      ga_control_sig = 0
> endin
>
>
> </CsInstruments>
> <CsScore>
>
> i20     0   7
>
> i1      0   7
>
> i2      0   1
> i2      +   1
> i2      +   1
> i2      +   1
> i2      +   1
> i2      +   1
> i2      +   1
>
> i3      0   7
>
> e
> </CsScore>
> </CsoundSynthesizer>
>
>
>
> --
> 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
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-05-16 19:20
Fromwalker davis
SubjectRe: [Csnd] compress opcode discontinuities using acontrolsig - is there a csound zeros opcode?
Pete - Thanks for the reply, I just didn't want this question to make its way too far down the queue.  Setting the threshold to -10000 seems like a good trick, but might limit the functionality/compression controls.

Hlöðver - I think the click is just from too sudden silence to noise.  Generally just listening from my laptop speakers or headphones, results are pretty similar.  I think that the discontinuity of the  compressed signal and the relatively short/fast compressor attack and release might cause the pops/discontinuities.

After thinking about this issue, and seeing both of your responses, it makes me wonder if it has something to do with besides compress opcode....
The compress opcode behaves  as it should when there is both an audio and control signal.  Do global ga signals produce constant output, arrays of zeros, through the entirety of the score?  Or just when another signal is added/passed to them...  To me, it seems like the ga signal is dropping out, that was why I added the noise opcode in there...

Thanks to you both!

--------------------------------
Walker Davis



On Sat, May 16, 2020 at 8:43 AM Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
Interestign question, I'll have a look tonight. Don't see fully what's going on, but if you need to add noise, you could check if you change headphones/speakers has any effect (dither effect). Or this is just a click from too sudden silence to noise. I don't see any line:a port:a opcodes usage on a quick look.

On Sat, 16 May 2020 at 08:06, Pete Goodeve <pete.goodeve@computer.org> wrote:
Hi Walker,

It's a  shame no-one with actual experience with the opcode
has responded (:-/) but I had some spare time, so I played a bit.

All I can say is that 'compress' is one peculiar beast.  As increasing
the control signal decreases the amplitude of the controlled audio,
I would naturally expect a *zero* control to give *maximum* output.
On the contrary, a zero control *suppresses* the output!

In fact, any DC control value kills the output, and the AC has to
be above a certain (small) level to be noticed. (As you found.)

I have actually just found that giving the threshold parameter of
compress a *large* negative value -- I tried '-10000' -- prevents
killing the signal even with zero noise.

Not sure about the 'pops'.  May depend on the sources/  I used
'mandpluk.aiff for the impulse, and a handy sustained-chord test
file I had around for the other.

Hope that's some use...

        -- Pete --


On Tue, May 12, 2020 at 10:58:34AM -0700, walker wrote:
> Hey everybody,
>
> Hope you are all well.  Anyways, I am trying to do some side chain
> compression on audio files(this problem does not seem to exist with oscil
> instruments, if I remember correctly). 
>
> In this example/issue, I have 2 instruments here.  instr 1 is the signal
> that is to be compressed/sidechained/dipped, a pad or reverb-y/suspended
> sample works nicely.  instr 2 is the control signal, generally something
> shorter like a kick or snare sample.  I have routed both of these to global
> signals which are the input to 'bus' instrument tracks, instr 20.  For this
> demo/test the control signal never reaches the DAC, it is just in place to
> manipulate the compressed signal.
>
> Using just two of the diskin2 opcodes to read and play the audio file data,
> there are a few issues.
> - when the control signal is not producing noise(end of event or audio
> file), the compressed signal drops out
> - there are some clear discontinuities and pops when this happens
>
> Hack-y remedy:
> Uncomment instr 3, a signal of very quiet white noise.  This prevents the
> drop outs and discontinuities from happening.  To me, this makes the
> compress opcode behave like compressors and compressor plug-ins I have used
> outside of Csound...  The audio results sounds good to me, but it just feels
> weird/unnecessary to use noise as the signal stabilizer though...  Is there
> some kind of zero generating opcode?  I have searched, but haven't found
> anything... 
>
> Noise amplitude issue:
> You will see that in the below code, there are two lines for noise
> generation.  When the amplitude of noise is 0.0001, my hack works.  When the
> amplitude is decreased to 0.00001, the discontinuities and pops return.
> This is not a major issue, but I don't quite understand....
>
>
> This code demonstrates should work so long as you supply file paths for
> instr's 1 and 2.
>
>
> <CsoundSynthesizer>
> <CsOptions>
> ; Select audio/midi flags here according to platform
> -odac  ;-iadc    ;;;RT audio out and in
> ; For Non-realtime ouput leave only the line below:
> </CsOptions>
> <CsInstruments>
>
> sr        = 44100
> ksmps     = 441
> nchnls    = 2
> 0dbfs     = 1
>
> ga_compressed_sig        init 0
> ga_control_sig           init 0
>
>
> ; signal to be sidechained/dipped
> instr 1
>      Sfilename = PAD_OR_LONG_SAMPLE_FILEPATH
>      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
>
>      ga_compressed_sig += asigL
> endin
>
> ; signal controlling/doing the chaining/dipping
> instr 2
>      Sfilename = SNARE_OR_SHORT_SAMPLE_FILEPATH
>      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
>
>      ga_control_sig += asigL
> endin
>
> ;; add noise to control signal to prevent pops, seems hacky tho
> ; instr 3
> ;      asig noise 0.0001, 0
> ;;      asig noise 0.00001, 0 ;discontinuities return
>
> ;      ga_control_sig += asig
> ; endin
>
> instr 20
>
>      acomp     compress ga_compressed_sig, (ga_control_sig / 2), -10, 40,
> 60, 300, 0.005, 0.01, 0.0
>      outs acomp, acomp
>
>      ga_compressed_sig = 0
>      ga_control_sig = 0
> endin
>
>
> </CsInstruments>
> <CsScore>
>
> i20     0   7
>
> i1      0   7
>
> i2      0   1
> i2      +   1
> i2      +   1
> i2      +   1
> i2      +   1
> i2      +   1
> i2      +   1
>
> i3      0   7
>
> e
> </CsScore>
> </CsoundSynthesizer>
>
>
>
> --
> 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
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-05-16 19:46
FromRory Walsh
SubjectRe: [Csnd] compress opcode discontinuities using acontrolsig - is there a csound zeros opcode?
I too have very little experience with the compress opcode, but have you looked Iain's use of it here:
here
and

Perhaps he is doing something to handle the issues you've mentioned? 

On Sat, 16 May 2020 at 19:21, walker davis <walkerdavismusic@gmail.com> wrote:
Pete - Thanks for the reply, I just didn't want this question to make its way too far down the queue.  Setting the threshold to -10000 seems like a good trick, but might limit the functionality/compression controls.

Hlöðver - I think the click is just from too sudden silence to noise.  Generally just listening from my laptop speakers or headphones, results are pretty similar.  I think that the discontinuity of the  compressed signal and the relatively short/fast compressor attack and release might cause the pops/discontinuities.

After thinking about this issue, and seeing both of your responses, it makes me wonder if it has something to do with besides compress opcode....
The compress opcode behaves  as it should when there is both an audio and control signal.  Do global ga signals produce constant output, arrays of zeros, through the entirety of the score?  Or just when another signal is added/passed to them...  To me, it seems like the ga signal is dropping out, that was why I added the noise opcode in there...

Thanks to you both!

--------------------------------
Walker Davis



On Sat, May 16, 2020 at 8:43 AM Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
Interestign question, I'll have a look tonight. Don't see fully what's going on, but if you need to add noise, you could check if you change headphones/speakers has any effect (dither effect). Or this is just a click from too sudden silence to noise. I don't see any line:a port:a opcodes usage on a quick look.

On Sat, 16 May 2020 at 08:06, Pete Goodeve <pete.goodeve@computer.org> wrote:
Hi Walker,

It's a  shame no-one with actual experience with the opcode
has responded (:-/) but I had some spare time, so I played a bit.

All I can say is that 'compress' is one peculiar beast.  As increasing
the control signal decreases the amplitude of the controlled audio,
I would naturally expect a *zero* control to give *maximum* output.
On the contrary, a zero control *suppresses* the output!

In fact, any DC control value kills the output, and the AC has to
be above a certain (small) level to be noticed. (As you found.)

I have actually just found that giving the threshold parameter of
compress a *large* negative value -- I tried '-10000' -- prevents
killing the signal even with zero noise.

Not sure about the 'pops'.  May depend on the sources/  I used
'mandpluk.aiff for the impulse, and a handy sustained-chord test
file I had around for the other.

Hope that's some use...

        -- Pete --


On Tue, May 12, 2020 at 10:58:34AM -0700, walker wrote:
> Hey everybody,
>
> Hope you are all well.  Anyways, I am trying to do some side chain
> compression on audio files(this problem does not seem to exist with oscil
> instruments, if I remember correctly). 
>
> In this example/issue, I have 2 instruments here.  instr 1 is the signal
> that is to be compressed/sidechained/dipped, a pad or reverb-y/suspended
> sample works nicely.  instr 2 is the control signal, generally something
> shorter like a kick or snare sample.  I have routed both of these to global
> signals which are the input to 'bus' instrument tracks, instr 20.  For this
> demo/test the control signal never reaches the DAC, it is just in place to
> manipulate the compressed signal.
>
> Using just two of the diskin2 opcodes to read and play the audio file data,
> there are a few issues.
> - when the control signal is not producing noise(end of event or audio
> file), the compressed signal drops out
> - there are some clear discontinuities and pops when this happens
>
> Hack-y remedy:
> Uncomment instr 3, a signal of very quiet white noise.  This prevents the
> drop outs and discontinuities from happening.  To me, this makes the
> compress opcode behave like compressors and compressor plug-ins I have used
> outside of Csound...  The audio results sounds good to me, but it just feels
> weird/unnecessary to use noise as the signal stabilizer though...  Is there
> some kind of zero generating opcode?  I have searched, but haven't found
> anything... 
>
> Noise amplitude issue:
> You will see that in the below code, there are two lines for noise
> generation.  When the amplitude of noise is 0.0001, my hack works.  When the
> amplitude is decreased to 0.00001, the discontinuities and pops return.
> This is not a major issue, but I don't quite understand....
>
>
> This code demonstrates should work so long as you supply file paths for
> instr's 1 and 2.
>
>
> <CsoundSynthesizer>
> <CsOptions>
> ; Select audio/midi flags here according to platform
> -odac  ;-iadc    ;;;RT audio out and in
> ; For Non-realtime ouput leave only the line below:
> </CsOptions>
> <CsInstruments>
>
> sr        = 44100
> ksmps     = 441
> nchnls    = 2
> 0dbfs     = 1
>
> ga_compressed_sig        init 0
> ga_control_sig           init 0
>
>
> ; signal to be sidechained/dipped
> instr 1
>      Sfilename = PAD_OR_LONG_SAMPLE_FILEPATH
>      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
>
>      ga_compressed_sig += asigL
> endin
>
> ; signal controlling/doing the chaining/dipping
> instr 2
>      Sfilename = SNARE_OR_SHORT_SAMPLE_FILEPATH
>      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
>
>      ga_control_sig += asigL
> endin
>
> ;; add noise to control signal to prevent pops, seems hacky tho
> ; instr 3
> ;      asig noise 0.0001, 0
> ;;      asig noise 0.00001, 0 ;discontinuities return
>
> ;      ga_control_sig += asig
> ; endin
>
> instr 20
>
>      acomp     compress ga_compressed_sig, (ga_control_sig / 2), -10, 40,
> 60, 300, 0.005, 0.01, 0.0
>      outs acomp, acomp
>
>      ga_compressed_sig = 0
>      ga_control_sig = 0
> endin
>
>
> </CsInstruments>
> <CsScore>
>
> i20     0   7
>
> i1      0   7
>
> i2      0   1
> i2      +   1
> i2      +   1
> i2      +   1
> i2      +   1
> i2      +   1
> i2      +   1
>
> i3      0   7
>
> e
> </CsScore>
> </CsoundSynthesizer>
>
>
>
> --
> 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
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-05-16 20:22
FromPete Goodeve
SubjectRe: [Csnd] compress opcode discontinuities using acontrolsig - is there a csound zeros opcode?
AttachmentsNone  

Date2020-05-16 20:58
FromPete Goodeve
SubjectRe: [Csnd] compress opcode discontinuities using acontrolsig - is there a csound zeros opcode?
AttachmentsNone  

Date2020-05-16 22:58
FromHlöðver Sigurðsson
SubjectRe: [Csnd] compress opcode discontinuities using acontrolsig - is there a csound zeros opcode?
I tested it locally, and you are correct that the audio buffers aren't clearing, but I did hear improvement using 

clear ga_compressed_sig, ga_control_sig 

instead of assigning them to 0,

also from what I hear, the clicks are only at the beginning of the audio samples, and it differs a lot from sample to sample,
but you should change: ktrans linseg 1, p3,1 
for some real declick function, and adjust the the dicklick time so that you don't hear the clicks but short enough it doesn't affect the sample.

On Sat, 16 May 2020 at 21:58, Pete Goodeve <pete.goodeve@computer.org> wrote:
Walker, you might want  to look at 'compress2', which John
apparently wrote to make the dB values a little more Csound
compatible (otherwise the same as 'compress').

There's a misprint in the docs, though:

"These are given as positive values, where 0 db corresponds to an amplitude of 0dbfs."

That obviously should be *negative values*, as they are in the
example CSD.

        -- Pete --

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-05-17 01:51
Fromwalker davis
SubjectRe: [Csnd] compress opcode discontinuities using acontrolsig - is there a csound zeros opcode?
awesome, thank you very much guys.

good to know that:
- ga_signals always have zeros 
- i was clearing the buffers incorrectly.
- compress2 is very similar to compress, just with different, perhaps more standardized, looking inputs values...

I think I misunderstood the kthresh param, assuming that threshold in this case meant point at which compression started, not point of noise floor. 

All super helpful guys, really appreciate it, thank you!


--------------------------------
Walker Davis


On Sat, May 16, 2020 at 2:59 PM Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
I tested it locally, and you are correct that the audio buffers aren't clearing, but I did hear improvement using 

clear ga_compressed_sig, ga_control_sig 

instead of assigning them to 0,

also from what I hear, the clicks are only at the beginning of the audio samples, and it differs a lot from sample to sample,
but you should change: ktrans linseg 1, p3,1 
for some real declick function, and adjust the the dicklick time so that you don't hear the clicks but short enough it doesn't affect the sample.

On Sat, 16 May 2020 at 21:58, Pete Goodeve <pete.goodeve@computer.org> wrote:
Walker, you might want  to look at 'compress2', which John
apparently wrote to make the dB values a little more Csound
compatible (otherwise the same as 'compress').

There's a misprint in the docs, though:

"These are given as positive values, where 0 db corresponds to an amplitude of 0dbfs."

That obviously should be *negative values*, as they are in the
example CSD.

        -- Pete --

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-05-17 02:43
From"Dr. Richard Boulanger"
SubjectRe: [Csnd] compress opcode discontinuities using acontrolsig - is there a csound zeros opcode?
Thanks for sharing these McCurdy models with us Rory.
- Are you aware that Csound's FLTK opcodes no longer work on the Mac?  (And sadly, the first example shows a blank screen!)
This is a great loss.
_____________________________________________
Dr. Richard Boulanger
Professor of Electronic Production and Design



On Sat, May 16, 2020 at 2:46 PM Rory Walsh <rorywalsh@ear.ie> wrote:
I too have very little experience with the compress opcode, but have you looked Iain's use of it here:
here
and

Perhaps he is doing something to handle the issues you've mentioned? 

On Sat, 16 May 2020 at 19:21, walker davis <walkerdavismusic@gmail.com> wrote:
Pete - Thanks for the reply, I just didn't want this question to make its way too far down the queue.  Setting the threshold to -10000 seems like a good trick, but might limit the functionality/compression controls.

Hlöðver - I think the click is just from too sudden silence to noise.  Generally just listening from my laptop speakers or headphones, results are pretty similar.  I think that the discontinuity of the  compressed signal and the relatively short/fast compressor attack and release might cause the pops/discontinuities.

After thinking about this issue, and seeing both of your responses, it makes me wonder if it has something to do with besides compress opcode....
The compress opcode behaves  as it should when there is both an audio and control signal.  Do global ga signals produce constant output, arrays of zeros, through the entirety of the score?  Or just when another signal is added/passed to them...  To me, it seems like the ga signal is dropping out, that was why I added the noise opcode in there...

Thanks to you both!

--------------------------------
Walker Davis



On Sat, May 16, 2020 at 8:43 AM Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
Interestign question, I'll have a look tonight. Don't see fully what's going on, but if you need to add noise, you could check if you change headphones/speakers has any effect (dither effect). Or this is just a click from too sudden silence to noise. I don't see any line:a port:a opcodes usage on a quick look.

On Sat, 16 May 2020 at 08:06, Pete Goodeve <pete.goodeve@computer.org> wrote:
Hi Walker,

It's a  shame no-one with actual experience with the opcode
has responded (:-/) but I had some spare time, so I played a bit.

All I can say is that 'compress' is one peculiar beast.  As increasing
the control signal decreases the amplitude of the controlled audio,
I would naturally expect a *zero* control to give *maximum* output.
On the contrary, a zero control *suppresses* the output!

In fact, any DC control value kills the output, and the AC has to
be above a certain (small) level to be noticed. (As you found.)

I have actually just found that giving the threshold parameter of
compress a *large* negative value -- I tried '-10000' -- prevents
killing the signal even with zero noise.

Not sure about the 'pops'.  May depend on the sources/  I used
'mandpluk.aiff for the impulse, and a handy sustained-chord test
file I had around for the other.

Hope that's some use...

        -- Pete --


On Tue, May 12, 2020 at 10:58:34AM -0700, walker wrote:
> Hey everybody,
>
> Hope you are all well.  Anyways, I am trying to do some side chain
> compression on audio files(this problem does not seem to exist with oscil
> instruments, if I remember correctly). 
>
> In this example/issue, I have 2 instruments here.  instr 1 is the signal
> that is to be compressed/sidechained/dipped, a pad or reverb-y/suspended
> sample works nicely.  instr 2 is the control signal, generally something
> shorter like a kick or snare sample.  I have routed both of these to global
> signals which are the input to 'bus' instrument tracks, instr 20.  For this
> demo/test the control signal never reaches the DAC, it is just in place to
> manipulate the compressed signal.
>
> Using just two of the diskin2 opcodes to read and play the audio file data,
> there are a few issues.
> - when the control signal is not producing noise(end of event or audio
> file), the compressed signal drops out
> - there are some clear discontinuities and pops when this happens
>
> Hack-y remedy:
> Uncomment instr 3, a signal of very quiet white noise.  This prevents the
> drop outs and discontinuities from happening.  To me, this makes the
> compress opcode behave like compressors and compressor plug-ins I have used
> outside of Csound...  The audio results sounds good to me, but it just feels
> weird/unnecessary to use noise as the signal stabilizer though...  Is there
> some kind of zero generating opcode?  I have searched, but haven't found
> anything... 
>
> Noise amplitude issue:
> You will see that in the below code, there are two lines for noise
> generation.  When the amplitude of noise is 0.0001, my hack works.  When the
> amplitude is decreased to 0.00001, the discontinuities and pops return.
> This is not a major issue, but I don't quite understand....
>
>
> This code demonstrates should work so long as you supply file paths for
> instr's 1 and 2.
>
>
> <CsoundSynthesizer>
> <CsOptions>
> ; Select audio/midi flags here according to platform
> -odac  ;-iadc    ;;;RT audio out and in
> ; For Non-realtime ouput leave only the line below:
> </CsOptions>
> <CsInstruments>
>
> sr        = 44100
> ksmps     = 441
> nchnls    = 2
> 0dbfs     = 1
>
> ga_compressed_sig        init 0
> ga_control_sig           init 0
>
>
> ; signal to be sidechained/dipped
> instr 1
>      Sfilename = PAD_OR_LONG_SAMPLE_FILEPATH
>      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
>
>      ga_compressed_sig += asigL
> endin
>
> ; signal controlling/doing the chaining/dipping
> instr 2
>      Sfilename = SNARE_OR_SHORT_SAMPLE_FILEPATH
>      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
>
>      ga_control_sig += asigL
> endin
>
> ;; add noise to control signal to prevent pops, seems hacky tho
> ; instr 3
> ;      asig noise 0.0001, 0
> ;;      asig noise 0.00001, 0 ;discontinuities return
>
> ;      ga_control_sig += asig
> ; endin
>
> instr 20
>
>      acomp     compress ga_compressed_sig, (ga_control_sig / 2), -10, 40,
> 60, 300, 0.005, 0.01, 0.0
>      outs acomp, acomp
>
>      ga_compressed_sig = 0
>      ga_control_sig = 0
> endin
>
>
> </CsInstruments>
> <CsScore>
>
> i20     0   7
>
> i1      0   7
>
> i2      0   1
> i2      +   1
> i2      +   1
> i2      +   1
> i2      +   1
> i2      +   1
> i2      +   1
>
> i3      0   7
>
> e
> </CsScore>
> </CsoundSynthesizer>
>
>
>
> --
> 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
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-05-17 02:53
From"Dr. Richard Boulanger"
SubjectRe: [Csnd] compress opcode discontinuities using acontrolsig - is there a csound zeros opcode?
PS - The McCurdy Models in Cabbage are great
_____________________________________________
Dr. Richard Boulanger
Professor of Electronic Production and Design

On Sat, May 16, 2020 at 9:43 PM Dr. Richard Boulanger <rboulanger@berklee.edu> wrote:
Thanks for sharing these McCurdy models with us Rory.
- Are you aware that Csound's FLTK opcodes no longer work on the Mac?  (And sadly, the first example shows a blank screen!)
This is a great loss.
_____________________________________________
Dr. Richard Boulanger
Professor of Electronic Production and Design



On Sat, May 16, 2020 at 2:46 PM Rory Walsh <rorywalsh@ear.ie> wrote:
I too have very little experience with the compress opcode, but have you looked Iain's use of it here:
here
and

Perhaps he is doing something to handle the issues you've mentioned? 

On Sat, 16 May 2020 at 19:21, walker davis <walkerdavismusic@gmail.com> wrote:
Pete - Thanks for the reply, I just didn't want this question to make its way too far down the queue.  Setting the threshold to -10000 seems like a good trick, but might limit the functionality/compression controls.

Hlöðver - I think the click is just from too sudden silence to noise.  Generally just listening from my laptop speakers or headphones, results are pretty similar.  I think that the discontinuity of the  compressed signal and the relatively short/fast compressor attack and release might cause the pops/discontinuities.

After thinking about this issue, and seeing both of your responses, it makes me wonder if it has something to do with besides compress opcode....
The compress opcode behaves  as it should when there is both an audio and control signal.  Do global ga signals produce constant output, arrays of zeros, through the entirety of the score?  Or just when another signal is added/passed to them...  To me, it seems like the ga signal is dropping out, that was why I added the noise opcode in there...

Thanks to you both!

--------------------------------
Walker Davis



On Sat, May 16, 2020 at 8:43 AM Hlöðver Sigurðsson <hlolli@gmail.com> wrote:
Interestign question, I'll have a look tonight. Don't see fully what's going on, but if you need to add noise, you could check if you change headphones/speakers has any effect (dither effect). Or this is just a click from too sudden silence to noise. I don't see any line:a port:a opcodes usage on a quick look.

On Sat, 16 May 2020 at 08:06, Pete Goodeve <pete.goodeve@computer.org> wrote:
Hi Walker,

It's a  shame no-one with actual experience with the opcode
has responded (:-/) but I had some spare time, so I played a bit.

All I can say is that 'compress' is one peculiar beast.  As increasing
the control signal decreases the amplitude of the controlled audio,
I would naturally expect a *zero* control to give *maximum* output.
On the contrary, a zero control *suppresses* the output!

In fact, any DC control value kills the output, and the AC has to
be above a certain (small) level to be noticed. (As you found.)

I have actually just found that giving the threshold parameter of
compress a *large* negative value -- I tried '-10000' -- prevents
killing the signal even with zero noise.

Not sure about the 'pops'.  May depend on the sources/  I used
'mandpluk.aiff for the impulse, and a handy sustained-chord test
file I had around for the other.

Hope that's some use...

        -- Pete --


On Tue, May 12, 2020 at 10:58:34AM -0700, walker wrote:
> Hey everybody,
>
> Hope you are all well.  Anyways, I am trying to do some side chain
> compression on audio files(this problem does not seem to exist with oscil
> instruments, if I remember correctly). 
>
> In this example/issue, I have 2 instruments here.  instr 1 is the signal
> that is to be compressed/sidechained/dipped, a pad or reverb-y/suspended
> sample works nicely.  instr 2 is the control signal, generally something
> shorter like a kick or snare sample.  I have routed both of these to global
> signals which are the input to 'bus' instrument tracks, instr 20.  For this
> demo/test the control signal never reaches the DAC, it is just in place to
> manipulate the compressed signal.
>
> Using just two of the diskin2 opcodes to read and play the audio file data,
> there are a few issues.
> - when the control signal is not producing noise(end of event or audio
> file), the compressed signal drops out
> - there are some clear discontinuities and pops when this happens
>
> Hack-y remedy:
> Uncomment instr 3, a signal of very quiet white noise.  This prevents the
> drop outs and discontinuities from happening.  To me, this makes the
> compress opcode behave like compressors and compressor plug-ins I have used
> outside of Csound...  The audio results sounds good to me, but it just feels
> weird/unnecessary to use noise as the signal stabilizer though...  Is there
> some kind of zero generating opcode?  I have searched, but haven't found
> anything... 
>
> Noise amplitude issue:
> You will see that in the below code, there are two lines for noise
> generation.  When the amplitude of noise is 0.0001, my hack works.  When the
> amplitude is decreased to 0.00001, the discontinuities and pops return.
> This is not a major issue, but I don't quite understand....
>
>
> This code demonstrates should work so long as you supply file paths for
> instr's 1 and 2.
>
>
> <CsoundSynthesizer>
> <CsOptions>
> ; Select audio/midi flags here according to platform
> -odac  ;-iadc    ;;;RT audio out and in
> ; For Non-realtime ouput leave only the line below:
> </CsOptions>
> <CsInstruments>
>
> sr        = 44100
> ksmps     = 441
> nchnls    = 2
> 0dbfs     = 1
>
> ga_compressed_sig        init 0
> ga_control_sig           init 0
>
>
> ; signal to be sidechained/dipped
> instr 1
>      Sfilename = PAD_OR_LONG_SAMPLE_FILEPATH
>      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
>
>      ga_compressed_sig += asigL
> endin
>
> ; signal controlling/doing the chaining/dipping
> instr 2
>      Sfilename = SNARE_OR_SHORT_SAMPLE_FILEPATH
>      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
>
>      ga_control_sig += asigL
> endin
>
> ;; add noise to control signal to prevent pops, seems hacky tho
> ; instr 3
> ;      asig noise 0.0001, 0
> ;;      asig noise 0.00001, 0 ;discontinuities return
>
> ;      ga_control_sig += asig
> ; endin
>
> instr 20
>
>      acomp     compress ga_compressed_sig, (ga_control_sig / 2), -10, 40,
> 60, 300, 0.005, 0.01, 0.0
>      outs acomp, acomp
>
>      ga_compressed_sig = 0
>      ga_control_sig = 0
> endin
>
>
> </CsInstruments>
> <CsScore>
>
> i20     0   7
>
> i1      0   7
>
> i2      0   1
> i2      +   1
> i2      +   1
> i2      +   1
> i2      +   1
> i2      +   1
> i2      +   1
>
> i3      0   7
>
> e
> </CsScore>
> </CsoundSynthesizer>
>
>
>
> --
> 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
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