Csound Csound-dev Csound-tekno Search About

[Csnd] Opcode Design - Trigger Mechanism

Date2025-04-25 20:09
FromPhilipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE>
Subject[Csnd] Opcode Design - Trigger Mechanism
Hello all!

I need some help with an opcode design:

A opcode i wrote in C can receive a k-trig to set some internal variables to a specific state, which influences the a-output, more precise it sets the output values to a predefined value.
But since itโ€™s a k-trig the whole audio output vector will be set to this value. This is to long for my purpose. I want only the first value of the vector to have this value and go on with the processing loop.

I could change the k-trig to an a-trig, but this makes the opcode not very userfriendly inside csound, because k-trigs are more common.

Can i solve this in some way?

All the Best,
Philipp von Neumann (He/Him)
Composition | Computer Music | Programming

๐Ÿ“ง philipp@von-neumann.com
๐Ÿ“ž +49 159 01 20 71 03
๐ŸŒ von-neumann.com
๐Ÿ”Š SoundCloud: https://soundcloud.com/phvon
๐ŸŒฟ Bluesky: https://bsky.app/profile/von-neumann.com
๐Ÿฆฃ Mastodon: https://mastodon.social/@PvN

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

Date2025-04-25 20:27
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] Opcode Design - Trigger Mechanism
Not sure I understand the problem. Why don't you have a k-var output if you only need a scalar to be set instead of a whole vector?

Maybe you can show the opcode syntax description so we have a better idea.


Prof. Victor Lazzarini
Maynooth University
Ireland

> On 25 Apr 2025, at 20:09, Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
> 
> ๏ปฟHello all!
> 
> I need some help with an opcode design:
> 
> A opcode i wrote in C can receive a k-trig to set some internal variables to a specific state, which influences the a-output, more precise it sets the output values to a predefined value.
> But since itโ€™s a k-trig the whole audio output vector will be set to this value. This is to long for my purpose. I want only the first value of the vector to have this value and go on with the processing loop.
> 
> I could change the k-trig to an a-trig, but this makes the opcode not very userfriendly inside csound, because k-trigs are more common.
> 
> Can i solve this in some way?
> 
> All the Best,
> Philipp von Neumann (He/Him)
> Composition | Computer Music | Programming
> 
> ๐Ÿ“ง philipp@von-neumann.com
> ๐Ÿ“ž +49 159 01 20 71 03
> ๐ŸŒ von-neumann.com
> ๐Ÿ”Š SoundCloud: https://soundcloud.com/phvon
> ๐ŸŒฟ Bluesky: https://bsky.app/profile/von-neumann.com
> ๐Ÿฆฃ Mastodon: https://mastodon.social/@PvN
> 
> 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

Date2025-04-25 20:40
FromPhilipp Neumann <0000119f78f3a4f9-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] Opcode Design - Trigger Mechanism
Ok, i try to explain it more clear, i hope this makes this understandable:

This is a simplified version of the opcode syntax: 

a1 my_opcode kTrig, iStart

When the instrument is called the first value of the output vector is iStart. After this a differential equation is calculating the next values of the vector.
When kTrig = 1 the output vector is reset to iStart. And this is the problem. Because kTrig is equal to 1 for a whole k-cycle the whole output vector is now set to iStart. But i only need to set the first value of the output vector to iStart and let the differential equation inside the processing loop fill the next values of the output vector.

Is this more clear?

> Am 25.04.2025 um 21:27 schrieb Victor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>:
> 
> Not sure I understand the problem. Why don't you have a k-var output if you only need a scalar to be set instead of a whole vector?
> 
> Maybe you can show the opcode syntax description so we have a better idea.
> 
> 
> Prof. Victor Lazzarini
> Maynooth University
> Ireland
> 
>> On 25 Apr 2025, at 20:09, Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
>> 
>> ๏ปฟHello all!
>> 
>> I need some help with an opcode design:
>> 
>> A opcode i wrote in C can receive a k-trig to set some internal variables to a specific state, which influences the a-output, more precise it sets the output values to a predefined value.
>> But since itโ€™s a k-trig the whole audio output vector will be set to this value. This is to long for my purpose. I want only the first value of the vector to have this value and go on with the processing loop.
>> 
>> I could change the k-trig to an a-trig, but this makes the opcode not very userfriendly inside csound, because k-trigs are more common.
>> 
>> Can i solve this in some way?
>> 
>> All the Best,
>> Philipp von Neumann (He/Him)
>> Composition | Computer Music | Programming
>> 
>> ๐Ÿ“ง philipp@von-neumann.com
>> ๐Ÿ“ž +49 159 01 20 71 03
>> ๐ŸŒ von-neumann.com
>> ๐Ÿ”Š SoundCloud: https://soundcloud.com/phvon
>> ๐ŸŒฟ Bluesky: https://bsky.app/profile/von-neumann.com
>> ๐Ÿฆฃ Mastodon: https://mastodon.social/@PvN
>> 
>> 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

Date2025-04-25 20:49
FromVictor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] [EXTERNAL] Re: [Csnd] Opcode Design - Trigger Mechanism
Ok, so all you need to do is use ktrig to do what you said, when it's one you reset the start value and go off to compute the rest of the vector. It does not matter that ktrig does not change - unless you want the reset to happen on sample boundary rather than block boundary.

I don't really see a problem. It's just a matter of using the right logic. If ktrig is zero, nothing is done, just carry on computing, if it's one, set first value and move on to compute the rest. The process does not need to be dependent on ktrig changing during the processing loop.

HTH
Prof. Victor Lazzarini
Maynooth University
Ireland

> On 25 Apr 2025, at 20:40, Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
>
> ๏ปฟ*Warning*
>
> This email originated from outside of Maynooth University's Mail System. Do not reply, click links or open attachments unless you recognise the sender and know the content is safe.
>
> Ok, i try to explain it more clear, i hope this makes this understandable:
>
> This is a simplified version of the opcode syntax:
>
> a1 my_opcode kTrig, iStart
>
> When the instrument is called the first value of the output vector is iStart. After this a differential equation is calculating the next values of the vector.
> When kTrig = 1 the output vector is reset to iStart. And this is the problem. Because kTrig is equal to 1 for a whole k-cycle the whole output vector is now set to iStart. But i only need to set the first value of the output vector to iStart and let the differential equation inside the processing loop fill the next values of the output vector.
>
> Is this more clear?
>
>> Am 25.04.2025 um 21:27 schrieb Victor Lazzarini <000010b17ddd988e-dmarc-request@LISTSERV.HEANET.IE>:
>>
>> Not sure I understand the problem. Why don't you have a k-var output if you only need a scalar to be set instead of a whole vector?
>>
>> Maybe you can show the opcode syntax description so we have a better idea.
>>
>>
>> Prof. Victor Lazzarini
>> Maynooth University
>> Ireland
>>
>>>> On 25 Apr 2025, at 20:09, Philipp Neumann <0000119f78f3a4f9-dmarc-request@listserv.heanet.ie> wrote:
>>>
>>> ๏ปฟHello all!
>>>
>>> I need some help with an opcode design:
>>>
>>> A opcode i wrote in C can receive a k-trig to set some internal variables to a specific state, which influences the a-output, more precise it sets the output values to a predefined value.
>>> But since itโ€™s a k-trig the whole audio output vector will be set to this value. This is to long for my purpose. I want only the first value of the vector to have this value and go on with the processing loop.
>>>
>>> I could change the k-trig to an a-trig, but this makes the opcode not very userfriendly inside csound, because k-trigs are more common.
>>>
>>> Can i solve this in some way?
>>>
>>> All the Best,
>>> Philipp von Neumann (He/Him)
>>> Composition | Computer Music | Programming
>>>
>>> ๐Ÿ“ง philipp@von-neumann.com
>>> ๐Ÿ“ž +49 159 01 20 71 03
>>> ๐ŸŒ von-neumann.com
>>> ๐Ÿ”Š SoundCloud: https://soundcloud.com/phvon
>>> ๐ŸŒฟ Bluesky: https://bsky.app/profile/von-neumann.com
>>> ๐Ÿฆฃ Mastodon: https://mastodon.social/@PvN
>>>
>>> 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