Csound Csound-dev Csound-tekno Search About

[Csnd] monitor opcode

Date2021-01-22 09:58
Fromthorin kerr
Subject[Csnd] monitor opcode
Hi all... quick question re. the monitor opcode - https://csound.com/docs/manual/monitor.html - the manual mentions "It should not be used for processing the signal further."  Is there a good reason for this? Does it mess up threading or something under the hood?

Thorin


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

Date2021-01-22 10:03
FromOeyvind Brandtsegg
SubjectRe: [Csnd] monitor opcode
I think it is because the audio output from monitor is the actual audio output from Csound, so if you process it and then send the processed signal out, you might get some oddities. Haven't tried it, but I suspect you might get a closed feedback loop.

fre. 22. jan. 2021 kl. 10:58 skrev thorin kerr <thorin.kerr@gmail.com>:
Hi all... quick question re. the monitor opcode - https://csound.com/docs/manual/monitor.html - the manual mentions "It should not be used for processing the signal further."  Is there a good reason for this? Does it mess up threading or something under the hood?

Thorin


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

Date2021-01-22 15:12
Fromthorin kerr
SubjectRe: [Csnd] monitor opcode
Well...this seems to work, and could have its uses.
If you output an inverted phase version of the monitor output, that'll effectively cancel the output. But in-between it also gives you the opportunity to process a copy of the audio from monitor, and mix the processed version into the output. So, after the original is cancelled, all you're left with is the processed output.

That was wordy, so here's an example. Append this instrument (and event) to any orchestra, and you instantly have a global volume limiter.

;;make sure this is the highest numbered instrument!
instr 100
aout1, aout2 monitor ;get audio from spout

;;copy audio and limit
areplaceout1 compress aout1, aout1, 0, 90, 90, 100, 0.0, 0.08, 0.08
areplaceout2 compress aout2, aout2, 0, 90, 90, 100, 0.0, 0.08, 0.08

;;phase flip original signal
acancel1 = -aout1
acancel2 = -aout2

;sum
asum1 = areplaceout1 + acancel1
asum2 = areplaceout2 + acancel2

;output - the phase flipped signal should cancel the original,
;leaving just the compressed signal.  
outs asum1, asum2
endin

event_i "i", 100, 0, -1







On Fri, Jan 22, 2021 at 8:04 PM Oeyvind Brandtsegg <obrandts@gmail.com> wrote:
I think it is because the audio output from monitor is the actual audio output from Csound, so if you process it and then send the processed signal out, you might get some oddities. Haven't tried it, but I suspect you might get a closed feedback loop.

fre. 22. jan. 2021 kl. 10:58 skrev thorin kerr <thorin.kerr@gmail.com>:
Hi all... quick question re. the monitor opcode - https://csound.com/docs/manual/monitor.html - the manual mentions "It should not be used for processing the signal further."  Is there a good reason for this? Does it mess up threading or something under the hood?

Thorin


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

Date2021-01-28 23:24
From"Dr. Richard Boulanger"
SubjectRe: [Csnd] monitor opcode
This works really great.  
Thanks for sharing it.  

Here is a little test example for everyone to try.
- For me, this will be worth dropping into a lot of 'test' instruments (and student homework assignments!!! ;-) )

<CsoundSynthesizer>

<CsOptions>

</CsOptions>

<CsInstruments>

sr = 44100

ksmps = 32

nchnls = 2

0dbfs = 1


instr 1

idb = ampdbfs(p4)

k1 adsr .1,.1,.9,.1

a1 poscil idb*k1, cpsmidinn(p5)

outs a1, a1

endin


;;Thorin Kerr - Global Limiter Instrument

;;NOTE: Make sure this is the highest numbered instrument!


instr 100

aout1, aout2 monitor ;get audio from spout


;;copy audio and limit

areplaceout1 compress aout1, aout1, 0, 90, 90, 100, 0.0, 0.08, 0.08

areplaceout2 compress aout2, aout2, 0, 90, 90, 100, 0.0, 0.08, 0.08


;;phase flip original signal

acancel1 = -aout1

acancel2 = -aout2


;;sum

asum1 = areplaceout1 + acancel1

asum2 = areplaceout2 + acancel2


;;output - the phase flipped signal should cancel the original,

;;leaving just the compressed signal.

outs asum1, asum2

endin


event_i "i", 100, 0, -1


</CsInstruments>

<CsScore>

f1 0 4096 10 1

t 0 120

i1 0 1 -24 60

i. 2 . -18 62

i. 4 . -6 64

i. 6 . -3 65

i. 8 . 0 67

i. 10 . +3 69

i. 12 . +6 71

i. 14 . +12 72

s

f0 1

s

i1 0 2 -1 60

i. 0 . -1 62

i. 0 . -1 64

i. 0 . -1 65

i. 0 . -1 67

i. 0 . -1 69

i. 0 . -1 71

i. 0 . -1 72

s

f0 1

s

i1 0 2 6 60

i. 0 . . 62

i. 0 . . 64

i. 0 . . 65

i. 0 . . 67

i. 0 . . 69

i. 0 . . 71

i. 0 . . 72

s

f0 1

s

i1 0 2 36 60

i. 0 . . 62

i. 0 . . 64

i. 0 . . 65

i. 0 . . 67

i. 0 . . 69

i. 0 . . 71

i. 0 . . 72

s

f0 1

s

i1 0 2 96 60

i. 0 . . 62

i. 0 . . 64

i. 0 . . 65

i. 0 . . 67

i. 0 . . 69

i. 0 . . 71

i. 0 . . 72

s

f0 1

s

i1 0 4 -24 60

i. 0 . . 62

i. 0 . . 64

i. 0 . . 65

i. 0 . . 67

i. 0 . . 69

i. 0 . . 71

i. 0 . . 72

</CsScore>

</CsoundSynthesizer>


- dB


Dr. Richard Boulanger

Professor

Electronic Production and Design

Berklee College of Music

Professional Writing & Technology Division



On Fri, Jan 22, 2021 at 10:13 AM thorin kerr <thorin.kerr@gmail.com> wrote:
Well...this seems to work, and could have its uses.
If you output an inverted phase version of the monitor output, that'll effectively cancel the output. But in-between it also gives you the opportunity to process a copy of the audio from monitor, and mix the processed version into the output. So, after the original is cancelled, all you're left with is the processed output.

That was wordy, so here's an example. Append this instrument (and event) to any orchestra, and you instantly have a global volume limiter.

;;make sure this is the highest numbered instrument!
instr 100
aout1, aout2 monitor ;get audio from spout

;;copy audio and limit
areplaceout1 compress aout1, aout1, 0, 90, 90, 100, 0.0, 0.08, 0.08
areplaceout2 compress aout2, aout2, 0, 90, 90, 100, 0.0, 0.08, 0.08

;;phase flip original signal
acancel1 = -aout1
acancel2 = -aout2

;sum
asum1 = areplaceout1 + acancel1
asum2 = areplaceout2 + acancel2

;output - the phase flipped signal should cancel the original,
;leaving just the compressed signal.  
outs asum1, asum2
endin

event_i "i", 100, 0, -1







On Fri, Jan 22, 2021 at 8:04 PM Oeyvind Brandtsegg <obrandts@gmail.com> wrote:
I think it is because the audio output from monitor is the actual audio output from Csound, so if you process it and then send the processed signal out, you might get some oddities. Haven't tried it, but I suspect you might get a closed feedback loop.

fre. 22. jan. 2021 kl. 10:58 skrev thorin kerr <thorin.kerr@gmail.com>:
Hi all... quick question re. the monitor opcode - https://csound.com/docs/manual/monitor.html - the manual mentions "It should not be used for processing the signal further."  Is there a good reason for this? Does it mess up threading or something under the hood?

Thorin


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