Csound Csound-dev Csound-tekno Search About

[Csnd] [share] - MIDI Synthesizer

Date2024-06-23 19:20
FromSteven Yi
Subject[Csnd] [share] - MIDI Synthesizer
Hi All,

I thought I'd share a MIDI synth that I thought might be useful as a
starter template for exploration. One interesting thing about it is
the declick_rel UDO. I hadn't ever thought to do something like this,
but it's intentionally using a linseg that won't run until release
time. It allowed me to create a declicking envelope that I could
control easily what would happen over the release segment. (Kind of a
problem for most -r opcodes that allow setting only one release
segment curve.) Maybe it's a technique others have used before but was
new to me. It's also pretty efficient in that it just returns the
initialized 1 value up until release time.

opcode declick_rel, a, ii
  irel, idec xin

  asig init 1

  if release() == 1 then
    // replace with whatever shape you like for release segment
    asig = linseg(1, irel - idec, 1, idec, 0)
  endif

  xout asig
endop

The synth itself is pretty straightforward:

* 2-OSC (vco2)
* 2-pole filter with filter cutoff env
* drift LFO and DADSR for vibrato LFO

and there is a simple mixer with reverb amount and pre-delay.

The example is available on the Web IDE at:

https://ide.csound.com/editor/4DprFSwVtugMtoEzODuo

and I've pasted the code below.

Cheers!
Steven

[CODE]

;; Author: Steven Yi
;; Date: 2024-06-23
;; Description: MIDI Synthesizer, 2-OSC, DADSR for modulation, Key Tracking,
;; novel declick env for control in release stage



-odac -M0


0dbfs=1
nchnls=2

ga1 init 0
ga2 init 0

opcode declick_rel, a, ii
  irel, idec xin

  asig init 1

  if release() == 1 then
    // replace with whatever shape you like for release segment
    asig = linseg(1, irel - idec, 1, idec, 0)
  endif

  xout asig
endop

instr 1
  ifreq = cpsmidinn(notnum())
  iamp = ampdbfs(-12)

  // slow LFO for slight drift
  klfo = lfo(7, 0.05)

  // DADSR for vibrato
  kdadsr = linsegr:k(0, .5, 0, 1, 1, 1, 1)
  kvib = cent(kdadsr * lfo(20, 4.7))

  kfreq = ifreq * cent(klfo) * kvib

  asig = vco2(.5, kfreq)
  // sleight detuning
  asig += vco2(.25, kfreq * cent(10),2, .4)

  asig *= iamp

  aenv = transegr:a(0, .05, 0, 1, 3, -4.2, 0.5, 4, -4.2, 0)

  ioct = octcps(ifreq)

  // modulated filter using base oct + env * key-tracked value
  asig = zdf_2pole(asig, limit(cpsoct(5.5 + aenv * (2 + (ioct * .5))),
20, 18000), .5)

  asig *= declick_rel(4, 2)

  ga1 += asig
  ga2 += asig
endin

instr Mixer

  // amount to send to reverb
  iamt = ampdbfs(-12)

  // pre-delay: 150ms
  a1 = delay(ga1 * iamt, .15)
  a2 = delay(ga2 * iamt, .15)

  a1, a2 reverbsc a1, a2, 0.88, 12000

  // sum dry + wet
  a1 += ga1
  a2 += ga2

  out a1, a2
  clear ga1, ga2
endin
schedule("Mixer", 0, -1)




Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here

Date2024-06-24 11:49
FromTarmo Johannes
SubjectRe: [Csnd] [share] - MIDI Synthesizer
Thanks for sharing the example!

The release opcode is very clever, I will definitely use it.

And the whole code is inspiring!

Tarmo

P, 23. juuni 2024 21:21 Steven Yi <stevenyi@gmail.com> kirjutas:
Hi All,

I thought I'd share a MIDI synth that I thought might be useful as a
starter template for exploration. One interesting thing about it is
the declick_rel UDO. I hadn't ever thought to do something like this,
but it's intentionally using a linseg that won't run until release
time. It allowed me to create a declicking envelope that I could
control easily what would happen over the release segment. (Kind of a
problem for most -r opcodes that allow setting only one release
segment curve.) Maybe it's a technique others have used before but was
new to me. It's also pretty efficient in that it just returns the
initialized 1 value up until release time.

opcode declick_rel, a, ii
  irel, idec xin

  asig init 1

  if release() == 1 then
    // replace with whatever shape you like for release segment
    asig = linseg(1, irel - idec, 1, idec, 0)
  endif

  xout asig
endop

The synth itself is pretty straightforward:

* 2-OSC (vco2)
* 2-pole filter with filter cutoff env
* drift LFO and DADSR for vibrato LFO

and there is a simple mixer with reverb amount and pre-delay.

The example is available on the Web IDE at:

https://ide.csound.com/editor/4DprFSwVtugMtoEzODuo

and I've pasted the code below.

Cheers!
Steven

[CODE]

;; Author: Steven Yi
;; Date: 2024-06-23
;; Description: MIDI Synthesizer, 2-OSC, DADSR for modulation, Key Tracking,
;; novel declick env for control in release stage

<CsoundSynthesizer>
<CsOptions>
-odac -M0
</CsOptions>
<CsInstruments>
0dbfs=1
nchnls=2

ga1 init 0
ga2 init 0

opcode declick_rel, a, ii
  irel, idec xin

  asig init 1

  if release() == 1 then
    // replace with whatever shape you like for release segment
    asig = linseg(1, irel - idec, 1, idec, 0)
  endif

  xout asig
endop

instr 1
  ifreq = cpsmidinn(notnum())
  iamp = ampdbfs(-12)

  // slow LFO for slight drift
  klfo = lfo(7, 0.05)

  // DADSR for vibrato
  kdadsr = linsegr:k(0, .5, 0, 1, 1, 1, 1)
  kvib = cent(kdadsr * lfo(20, 4.7))

  kfreq = ifreq * cent(klfo) * kvib

  asig = vco2(.5, kfreq)
  // sleight detuning
  asig += vco2(.25, kfreq * cent(10),2, .4)

  asig *= iamp

  aenv = transegr:a(0, .05, 0, 1, 3, -4.2, 0.5, 4, -4.2, 0)

  ioct = octcps(ifreq)

  // modulated filter using base oct + env * key-tracked value
  asig = zdf_2pole(asig, limit(cpsoct(5.5 + aenv * (2 + (ioct * .5))),
20, 18000), .5)

  asig *= declick_rel(4, 2)

  ga1 += asig
  ga2 += asig
endin

instr Mixer

  // amount to send to reverb
  iamt = ampdbfs(-12)

  // pre-delay: 150ms
  a1 = delay(ga1 * iamt, .15)
  a2 = delay(ga2 * iamt, .15)

  a1, a2 reverbsc a1, a2, 0.88, 12000

  // sum dry + wet
  a1 += ga1
  a2 += ga2

  out a1, a2
  clear ga1, ga2
endin
schedule("Mixer", 0, -1)

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

Date2024-06-26 22:35
FromAaron Krister Johnson
SubjectRe: [Csnd] [share] - MIDI Synthesizer
Thanks for sharing, Steven, I'll check it out.

An interesting side-meta-conversation can be had about the virtues of updating/clearing globals vs. using chnget/chnset (and obviously, the old deprecated ZAK opcodes).

These days, I see no reason _not_ to use old-fashioned globals to pass info between instruments, like you did here.

On Sun, Jun 23, 2024 at 11:21 AM Steven Yi <stevenyi@gmail.com> wrote:
Hi All,

I thought I'd share a MIDI synth that I thought might be useful as a
starter template for exploration. One interesting thing about it is
the declick_rel UDO. I hadn't ever thought to do something like this,
but it's intentionally using a linseg that won't run until release
time. It allowed me to create a declicking envelope that I could
control easily what would happen over the release segment. (Kind of a
problem for most -r opcodes that allow setting only one release
segment curve.) Maybe it's a technique others have used before but was
new to me. It's also pretty efficient in that it just returns the
initialized 1 value up until release time.

opcode declick_rel, a, ii
  irel, idec xin

  asig init 1

  if release() == 1 then
    // replace with whatever shape you like for release segment
    asig = linseg(1, irel - idec, 1, idec, 0)
  endif

  xout asig
endop

The synth itself is pretty straightforward:

* 2-OSC (vco2)
* 2-pole filter with filter cutoff env
* drift LFO and DADSR for vibrato LFO

and there is a simple mixer with reverb amount and pre-delay.

The example is available on the Web IDE at:

https://ide.csound.com/editor/4DprFSwVtugMtoEzODuo

and I've pasted the code below.

Cheers!
Steven

[CODE]

;; Author: Steven Yi
;; Date: 2024-06-23
;; Description: MIDI Synthesizer, 2-OSC, DADSR for modulation, Key Tracking,
;; novel declick env for control in release stage

<CsoundSynthesizer>
<CsOptions>
-odac -M0
</CsOptions>
<CsInstruments>
0dbfs=1
nchnls=2

ga1 init 0
ga2 init 0

opcode declick_rel, a, ii
  irel, idec xin

  asig init 1

  if release() == 1 then
    // replace with whatever shape you like for release segment
    asig = linseg(1, irel - idec, 1, idec, 0)
  endif

  xout asig
endop

instr 1
  ifreq = cpsmidinn(notnum())
  iamp = ampdbfs(-12)

  // slow LFO for slight drift
  klfo = lfo(7, 0.05)

  // DADSR for vibrato
  kdadsr = linsegr:k(0, .5, 0, 1, 1, 1, 1)
  kvib = cent(kdadsr * lfo(20, 4.7))

  kfreq = ifreq * cent(klfo) * kvib

  asig = vco2(.5, kfreq)
  // sleight detuning
  asig += vco2(.25, kfreq * cent(10),2, .4)

  asig *= iamp

  aenv = transegr:a(0, .05, 0, 1, 3, -4.2, 0.5, 4, -4.2, 0)

  ioct = octcps(ifreq)

  // modulated filter using base oct + env * key-tracked value
  asig = zdf_2pole(asig, limit(cpsoct(5.5 + aenv * (2 + (ioct * .5))),
20, 18000), .5)

  asig *= declick_rel(4, 2)

  ga1 += asig
  ga2 += asig
endin

instr Mixer

  // amount to send to reverb
  iamt = ampdbfs(-12)

  // pre-delay: 150ms
  a1 = delay(ga1 * iamt, .15)
  a2 = delay(ga2 * iamt, .15)

  a1, a2 reverbsc a1, a2, 0.88, 12000

  // sum dry + wet
  a1 += ga1
  a2 += ga2

  out a1, a2
  clear ga1, ga2
endin
schedule("Mixer", 0, -1)

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

Date2024-06-27 01:24
FromSteven Yi
SubjectRe: [Csnd] [share] - MIDI Synthesizer
Welcome guys!

I think channels are good for:

* Working with I/O with host app
* dynamic routing using sprintf to determine a channel to route to
(e.g., single instrument where each note reads from different
channels)

I think globals work well otherwise, including global arrays like in
my live code library's stereo bus system:

https://github.com/kunstmusik/csound-live-code/blob/main/livecode.orc#L1105-L1138

Larger projects I feel like benefit from some kind of abstraction like
the sbus UDOs in the above, or for the routing to be handled for you
(like in Blue), especially if you're planning out a complex mixing
scheme using a lot of effects and things like sidechaining.

On Wed, Jun 26, 2024 at 5:35 PM Aaron Krister Johnson
 wrote:
>
> Thanks for sharing, Steven, I'll check it out.
>
> An interesting side-meta-conversation can be had about the virtues of updating/clearing globals vs. using chnget/chnset (and obviously, the old deprecated ZAK opcodes).
>
> These days, I see no reason _not_ to use old-fashioned globals to pass info between instruments, like you did here.
>
> Aaron Krister Johnson
> Music, etc.:
> https://soundcloud.com/aaron-krister-johnson
> https://soundcloud.com/filtercreed
> https://www.youtube.com/channel/UC_utjGYbSizWE0dNyr0Vdmg
> https://aaronkristerjohnson.bandcamp.com/
> http://www.untwelve.org
> Code:
> https://github.com/akjmicro
>
>
> On Sun, Jun 23, 2024 at 11:21 AM Steven Yi  wrote:
>>
>> Hi All,
>>
>> I thought I'd share a MIDI synth that I thought might be useful as a
>> starter template for exploration. One interesting thing about it is
>> the declick_rel UDO. I hadn't ever thought to do something like this,
>> but it's intentionally using a linseg that won't run until release
>> time. It allowed me to create a declicking envelope that I could
>> control easily what would happen over the release segment. (Kind of a
>> problem for most -r opcodes that allow setting only one release
>> segment curve.) Maybe it's a technique others have used before but was
>> new to me. It's also pretty efficient in that it just returns the
>> initialized 1 value up until release time.
>>
>> opcode declick_rel, a, ii
>>   irel, idec xin
>>
>>   asig init 1
>>
>>   if release() == 1 then
>>     // replace with whatever shape you like for release segment
>>     asig = linseg(1, irel - idec, 1, idec, 0)
>>   endif
>>
>>   xout asig
>> endop
>>
>> The synth itself is pretty straightforward:
>>
>> * 2-OSC (vco2)
>> * 2-pole filter with filter cutoff env
>> * drift LFO and DADSR for vibrato LFO
>>
>> and there is a simple mixer with reverb amount and pre-delay.
>>
>> The example is available on the Web IDE at:
>>
>> https://ide.csound.com/editor/4DprFSwVtugMtoEzODuo
>>
>> and I've pasted the code below.
>>
>> Cheers!
>> Steven
>>
>> [CODE]
>>
>> ;; Author: Steven Yi
>> ;; Date: 2024-06-23
>> ;; Description: MIDI Synthesizer, 2-OSC, DADSR for modulation, Key Tracking,
>> ;; novel declick env for control in release stage
>>
>> 
>> 
>> -odac -M0
>> 
>> 
>> 0dbfs=1
>> nchnls=2
>>
>> ga1 init 0
>> ga2 init 0
>>
>> opcode declick_rel, a, ii
>>   irel, idec xin
>>
>>   asig init 1
>>
>>   if release() == 1 then
>>     // replace with whatever shape you like for release segment
>>     asig = linseg(1, irel - idec, 1, idec, 0)
>>   endif
>>
>>   xout asig
>> endop
>>
>> instr 1
>>   ifreq = cpsmidinn(notnum())
>>   iamp = ampdbfs(-12)
>>
>>   // slow LFO for slight drift
>>   klfo = lfo(7, 0.05)
>>
>>   // DADSR for vibrato
>>   kdadsr = linsegr:k(0, .5, 0, 1, 1, 1, 1)
>>   kvib = cent(kdadsr * lfo(20, 4.7))
>>
>>   kfreq = ifreq * cent(klfo) * kvib
>>
>>   asig = vco2(.5, kfreq)
>>   // sleight detuning
>>   asig += vco2(.25, kfreq * cent(10),2, .4)
>>
>>   asig *= iamp
>>
>>   aenv = transegr:a(0, .05, 0, 1, 3, -4.2, 0.5, 4, -4.2, 0)
>>
>>   ioct = octcps(ifreq)
>>
>>   // modulated filter using base oct + env * key-tracked value
>>   asig = zdf_2pole(asig, limit(cpsoct(5.5 + aenv * (2 + (ioct * .5))),
>> 20, 18000), .5)
>>
>>   asig *= declick_rel(4, 2)
>>
>>   ga1 += asig
>>   ga2 += asig
>> endin
>>
>> instr Mixer
>>
>>   // amount to send to reverb
>>   iamt = ampdbfs(-12)
>>
>>   // pre-delay: 150ms
>>   a1 = delay(ga1 * iamt, .15)
>>   a2 = delay(ga2 * iamt, .15)
>>
>>   a1, a2 reverbsc a1, a2, 0.88, 12000
>>
>>   // sum dry + wet
>>   a1 += ga1
>>   a2 += ga2
>>
>>   out a1, a2
>>   clear ga1, ga2
>> endin
>> schedule("Mixer", 0, -1)
>>
>> 
>> 
>>
>> 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

Date2024-06-30 03:08
From"Dr. Richard Boulanger"
SubjectRe: [Csnd] [share] - MIDI Synthesizer
Thanks Steven - all of this work is so inspiring.

The MIDI instrument is wonderful.

- Dr.B


Dr. Richard Boulanger

Professor

Electronic Production and Design

Berklee College of Music

Professional Writing & Technology Division



On Wed, Jun 26, 2024 at 8:25 PM Steven Yi <stevenyi@gmail.com> wrote:
Welcome guys!

I think channels are good for:

* Working with I/O with host app
* dynamic routing using sprintf to determine a channel to route to
(e.g., single instrument where each note reads from different
channels)

I think globals work well otherwise, including global arrays like in
my live code library's stereo bus system:

https://us-west-2.protection.sophos.com?d=github.com&u=aHR0cHM6Ly9naXRodWIuY29tL2t1bnN0bXVzaWsvY3NvdW5kLWxpdmUtY29kZS9ibG9iL21haW4vbGl2ZWNvZGUub3JjI0wxMTA1LUwxMTM4&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=T2NtVUlmdmdpVWErMDRQVERtZEZDZHVXOFVJQ3Z4TExEeVJVTVc3TVFqWT0=&h=c968df45a13e459486779cc5f1fb62a4&s=AVNPUEhUT0NFTkNSWVBUSVYpmKWVU1jKuTPLD5gnaWwAaG5wwcHTpfjKIfFGmt9h9A

Larger projects I feel like benefit from some kind of abstraction like
the sbus UDOs in the above, or for the routing to be handled for you
(like in Blue), especially if you're planning out a complex mixing
scheme using a lot of effects and things like sidechaining.

On Wed, Jun 26, 2024 at 5:35 PM Aaron Krister Johnson
<akjmicro@gmail.com> wrote:
>
> Thanks for sharing, Steven, I'll check it out.
>
> An interesting side-meta-conversation can be had about the virtues of updating/clearing globals vs. using chnget/chnset (and obviously, the old deprecated ZAK opcodes).
>
> These days, I see no reason _not_ to use old-fashioned globals to pass info between instruments, like you did here.
>
> Aaron Krister Johnson
> Music, etc.:
> https://us-west-2.protection.sophos.com?d=soundcloud.com&u=aHR0cHM6Ly9zb3VuZGNsb3VkLmNvbS9hYXJvbi1rcmlzdGVyLWpvaG5zb24=&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=VGVhMWp4VFVTVTNwWTlEUHZucVY0RjVzRTVQZUZHc3k2ZXhpTEY1bGNmZz0=&h=c968df45a13e459486779cc5f1fb62a4&s=AVNPUEhUT0NFTkNSWVBUSVYpmKWVU1jKuTPLD5gnaWwAaG5wwcHTpfjKIfFGmt9h9A
> https://us-west-2.protection.sophos.com?d=soundcloud.com&u=aHR0cHM6Ly9zb3VuZGNsb3VkLmNvbS9maWx0ZXJjcmVlZA==&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=eXQrbmltem1YcytveEtETVlLbjhNa1Rkc0FDcjJsNmxqWFdXQyttMmJPYz0=&h=c968df45a13e459486779cc5f1fb62a4&s=AVNPUEhUT0NFTkNSWVBUSVYpmKWVU1jKuTPLD5gnaWwAaG5wwcHTpfjKIfFGmt9h9A
> https://us-west-2.protection.sophos.com?d=youtube.com&u=aHR0cHM6Ly93d3cueW91dHViZS5jb20vY2hhbm5lbC9VQ191dGpHWWJTaXpXRTBkTnlyMFZkbWc=&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=NlVsZ3NkQWNSaldnVWlrTTNaelorU2FJUXZBVWJYYTJqWUNETXBtQ3B3TT0=&h=c968df45a13e459486779cc5f1fb62a4&s=AVNPUEhUT0NFTkNSWVBUSVYpmKWVU1jKuTPLD5gnaWwAaG5wwcHTpfjKIfFGmt9h9A
> https://us-west-2.protection.sophos.com?d=bandcamp.com&u=aHR0cHM6Ly9hYXJvbmtyaXN0ZXJqb2huc29uLmJhbmRjYW1wLmNvbS8=&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=TlEzNUlvMmlGVWFvdkRpYzN3NGVIWElpOHNBVElpc0FwdFVHMDlOdS9FOD0=&h=c968df45a13e459486779cc5f1fb62a4&s=AVNPUEhUT0NFTkNSWVBUSVYpmKWVU1jKuTPLD5gnaWwAaG5wwcHTpfjKIfFGmt9h9A
> https://us-west-2.protection.sophos.com?d=untwelve.org&u=aHR0cDovL3d3dy51bnR3ZWx2ZS5vcmc=&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=WjZONElFN2ZwMzRjQ0FXSkpxbUpXRVRFYWhLYjllZGg1VnRPU1pmdmRpST0=&h=c968df45a13e459486779cc5f1fb62a4&s=AVNPUEhUT0NFTkNSWVBUSVYpmKWVU1jKuTPLD5gnaWwAaG5wwcHTpfjKIfFGmt9h9A
> Code:
> https://us-west-2.protection.sophos.com?d=github.com&u=aHR0cHM6Ly9naXRodWIuY29tL2Fram1pY3Jv&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=VkIvQjN2bFFFVkJnU1NOS0VDVkREcU4yaXpJUENSanVjVnRCdU9EeFZVcz0=&h=c968df45a13e459486779cc5f1fb62a4&s=AVNPUEhUT0NFTkNSWVBUSVYpmKWVU1jKuTPLD5gnaWwAaG5wwcHTpfjKIfFGmt9h9A
>
>
> On Sun, Jun 23, 2024 at 11:21 AM Steven Yi <stevenyi@gmail.com> wrote:
>>
>> Hi All,
>>
>> I thought I'd share a MIDI synth that I thought might be useful as a
>> starter template for exploration. One interesting thing about it is
>> the declick_rel UDO. I hadn't ever thought to do something like this,
>> but it's intentionally using a linseg that won't run until release
>> time. It allowed me to create a declicking envelope that I could
>> control easily what would happen over the release segment. (Kind of a
>> problem for most -r opcodes that allow setting only one release
>> segment curve.) Maybe it's a technique others have used before but was
>> new to me. It's also pretty efficient in that it just returns the
>> initialized 1 value up until release time.
>>
>> opcode declick_rel, a, ii
>>   irel, idec xin
>>
>>   asig init 1
>>
>>   if release() == 1 then
>>     // replace with whatever shape you like for release segment
>>     asig = linseg(1, irel - idec, 1, idec, 0)
>>   endif
>>
>>   xout asig
>> endop
>>
>> The synth itself is pretty straightforward:
>>
>> * 2-OSC (vco2)
>> * 2-pole filter with filter cutoff env
>> * drift LFO and DADSR for vibrato LFO
>>
>> and there is a simple mixer with reverb amount and pre-delay.
>>
>> The example is available on the Web IDE at:
>>
>> https://us-west-2.protection.sophos.com?d=csound.com&u=aHR0cHM6Ly9pZGUuY3NvdW5kLmNvbS9lZGl0b3IvNERwckZTd1Z0dWdNdG9Fek9EdW8=&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=ZVJIdFJzc0FLd21tNHZTZzF1NWFTbklDOSs1b1lYTFV0MnF3MWFwN2xYUT0=&h=c968df45a13e459486779cc5f1fb62a4&s=AVNPUEhUT0NFTkNSWVBUSVYpmKWVU1jKuTPLD5gnaWwAaG5wwcHTpfjKIfFGmt9h9A
>>
>> and I've pasted the code below.
>>
>> Cheers!
>> Steven
>>
>> [CODE]
>>
>> ;; Author: Steven Yi
>> ;; Date: 2024-06-23
>> ;; Description: MIDI Synthesizer, 2-OSC, DADSR for modulation, Key Tracking,
>> ;; novel declick env for control in release stage
>>
>> <CsoundSynthesizer>
>> <CsOptions>
>> -odac -M0
>> </CsOptions>
>> <CsInstruments>
>> 0dbfs=1
>> nchnls=2
>>
>> ga1 init 0
>> ga2 init 0
>>
>> opcode declick_rel, a, ii
>>   irel, idec xin
>>
>>   asig init 1
>>
>>   if release() == 1 then
>>     // replace with whatever shape you like for release segment
>>     asig = linseg(1, irel - idec, 1, idec, 0)
>>   endif
>>
>>   xout asig
>> endop
>>
>> instr 1
>>   ifreq = cpsmidinn(notnum())
>>   iamp = ampdbfs(-12)
>>
>>   // slow LFO for slight drift
>>   klfo = lfo(7, 0.05)
>>
>>   // DADSR for vibrato
>>   kdadsr = linsegr:k(0, .5, 0, 1, 1, 1, 1)
>>   kvib = cent(kdadsr * lfo(20, 4.7))
>>
>>   kfreq = ifreq * cent(klfo) * kvib
>>
>>   asig = vco2(.5, kfreq)
>>   // sleight detuning
>>   asig += vco2(.25, kfreq * cent(10),2, .4)
>>
>>   asig *= iamp
>>
>>   aenv = transegr:a(0, .05, 0, 1, 3, -4.2, 0.5, 4, -4.2, 0)
>>
>>   ioct = octcps(ifreq)
>>
>>   // modulated filter using base oct + env * key-tracked value
>>   asig = zdf_2pole(asig, limit(cpsoct(5.5 + aenv * (2 + (ioct * .5))),
>> 20, 18000), .5)
>>
>>   asig *= declick_rel(4, 2)
>>
>>   ga1 += asig
>>   ga2 += asig
>> endin
>>
>> instr Mixer
>>
>>   // amount to send to reverb
>>   iamt = ampdbfs(-12)
>>
>>   // pre-delay: 150ms
>>   a1 = delay(ga1 * iamt, .15)
>>   a2 = delay(ga2 * iamt, .15)
>>
>>   a1, a2 reverbsc a1, a2, 0.88, 12000
>>
>>   // sum dry + wet
>>   a1 += ga1
>>   a2 += ga2
>>
>>   out a1, a2
>>   clear ga1, ga2
>> endin
>> schedule("Mixer", 0, -1)
>>
>> </CsInstruments>
>> </CsoundSynthesizer>
>>
>> Csound mailing list
>> Csound@listserv.heanet.ie
>> https://us-west-2.protection.sophos.com?d=heanet.ie&u=aHR0cHM6Ly9saXN0c2Vydi5oZWFuZXQuaWUvY2dpLWJpbi93YT9BMD1DU09VTkQ=&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=WVZMRlI4dlFUVUZ6V2NTOUU5eE9lZnFIemtoc2hxYlBDMFFCWmtKZzhzRT0=&h=c968df45a13e459486779cc5f1fb62a4&s=AVNPUEhUT0NFTkNSWVBUSVYpmKWVU1jKuTPLD5gnaWwAaG5wwcHTpfjKIfFGmt9h9A
>> Send bugs reports to
>>         https://us-west-2.protection.sophos.com?d=github.com&u=aHR0cHM6Ly9naXRodWIuY29tL2Nzb3VuZC9jc291bmQvaXNzdWVz&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=YlNrQ2lLclRLZUpGUE1iR0FyY2M1eW1NTUU5SUozWlJwMTNZU2NXT1BLOD0=&h=c968df45a13e459486779cc5f1fb62a4&s=AVNPUEhUT0NFTkNSWVBUSVYpmKWVU1jKuTPLD5gnaWwAaG5wwcHTpfjKIfFGmt9h9A
>> Discussions of bugs and features can be posted here
>
> Csound mailing list Csound@listserv.heanet.ie https://us-west-2.protection.sophos.com?d=heanet.ie&u=aHR0cHM6Ly9saXN0c2Vydi5oZWFuZXQuaWUvY2dpLWJpbi93YT9BMD1DU09VTkQ=&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=WVZMRlI4dlFUVUZ6V2NTOUU5eE9lZnFIemtoc2hxYlBDMFFCWmtKZzhzRT0=&h=c968df45a13e459486779cc5f1fb62a4&s=AVNPUEhUT0NFTkNSWVBUSVYpmKWVU1jKuTPLD5gnaWwAaG5wwcHTpfjKIfFGmt9h9A Send bugs reports to https://us-west-2.protection.sophos.com?d=github.com&u=aHR0cHM6Ly9naXRodWIuY29tL2Nzb3VuZC9jc291bmQvaXNzdWVz&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=YlNrQ2lLclRLZUpGUE1iR0FyY2M1eW1NTUU5SUozWlJwMTNZU2NXT1BLOD0=&h=c968df45a13e459486779cc5f1fb62a4&s=AVNPUEhUT0NFTkNSWVBUSVYpmKWVU1jKuTPLD5gnaWwAaG5wwcHTpfjKIfFGmt9h9A Discussions of bugs and features can be posted here

Csound mailing list
Csound@listserv.heanet.ie
https://us-west-2.protection.sophos.com?d=heanet.ie&u=aHR0cHM6Ly9saXN0c2Vydi5oZWFuZXQuaWUvY2dpLWJpbi93YT9BMD1DU09VTkQ=&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=WVZMRlI4dlFUVUZ6V2NTOUU5eE9lZnFIemtoc2hxYlBDMFFCWmtKZzhzRT0=&h=c968df45a13e459486779cc5f1fb62a4&s=AVNPUEhUT0NFTkNSWVBUSVYpmKWVU1jKuTPLD5gnaWwAaG5wwcHTpfjKIfFGmt9h9A
Send bugs reports to
        https://us-west-2.protection.sophos.com?d=github.com&u=aHR0cHM6Ly9naXRodWIuY29tL2Nzb3VuZC9jc291bmQvaXNzdWVz&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=YlNrQ2lLclRLZUpGUE1iR0FyY2M1eW1NTUU5SUozWlJwMTNZU2NXT1BLOD0=&h=c968df45a13e459486779cc5f1fb62a4&s=AVNPUEhUT0NFTkNSWVBUSVYpmKWVU1jKuTPLD5gnaWwAaG5wwcHTpfjKIfFGmt9h9A
Discussions of bugs and features can be posted here
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here

Date2024-09-08 23:57
FromPartev Sarkissian <0000060b2ef1338e-dmarc-request@LISTSERV.HEANET.IE>
SubjectRe: [Csnd] [share] - MIDI Synthesizer
I see on https://soundcloud.com/filtercreed  page, Steve Roach's Ambient Lounge? 
Steve Roach,... as in the synth group Moebius, with Bryce Robley and Bruce Courtois? 

Aaron,... learning about ZAK and his math lately. Very interesting and useful here. Nice. 
Dorian, I like it. Emoji


-Partev


On Wednesday, June 26, 2024 at 10:36:12 PM GMT+1, Aaron Krister Johnson <akjmicro@gmail.com> wrote:


Thanks for sharing, Steven, I'll check it out.

An interesting side-meta-conversation can be had about the virtues of updating/clearing globals vs. using chnget/chnset (and obviously, the old deprecated ZAK opcodes).

These days, I see no reason _not_ to use old-fashioned globals to pass info between instruments, like you did here.

On Sun, Jun 23, 2024 at 11:21 AM Steven Yi <stevenyi@gmail.com> wrote:
Hi All,

I thought I'd share a MIDI synth that I thought might be useful as a
starter template for exploration. One interesting thing about it is
the declick_rel UDO. I hadn't ever thought to do something like this,
but it's intentionally using a linseg that won't run until release
time. It allowed me to create a declicking envelope that I could
control easily what would happen over the release segment. (Kind of a
problem for most -r opcodes that allow setting only one release
segment curve.) Maybe it's a technique others have used before but was
new to me. It's also pretty efficient in that it just returns the
initialized 1 value up until release time.

opcode declick_rel, a, ii
  irel, idec xin

  asig init 1

  if release() == 1 then
    // replace with whatever shape you like for release segment
    asig = linseg(1, irel - idec, 1, idec, 0)
  endif

  xout asig
endop

The synth itself is pretty straightforward:

* 2-OSC (vco2)
* 2-pole filter with filter cutoff env
* drift LFO and DADSR for vibrato LFO

and there is a simple mixer with reverb amount and pre-delay.

The example is available on the Web IDE at:

https://ide.csound.com/editor/4DprFSwVtugMtoEzODuo

and I've pasted the code below.

Cheers!
Steven

[CODE]

;; Author: Steven Yi
;; Date: 2024-06-23
;; Description: MIDI Synthesizer, 2-OSC, DADSR for modulation, Key Tracking,
;; novel declick env for control in release stage

<CsoundSynthesizer>
<CsOptions>
-odac -M0
</CsOptions>
<CsInstruments>
0dbfs=1
nchnls=2

ga1 init 0
ga2 init 0

opcode declick_rel, a, ii
  irel, idec xin

  asig init 1

  if release() == 1 then
    // replace with whatever shape you like for release segment
    asig = linseg(1, irel - idec, 1, idec, 0)
  endif

  xout asig
endop

instr 1
  ifreq = cpsmidinn(notnum())
  iamp = ampdbfs(-12)

  // slow LFO for slight drift
  klfo = lfo(7, 0.05)

  // DADSR for vibrato
  kdadsr = linsegr:k(0, .5, 0, 1, 1, 1, 1)
  kvib = cent(kdadsr * lfo(20, 4.7))

  kfreq = ifreq * cent(klfo) * kvib

  asig = vco2(.5, kfreq)
  // sleight detuning
  asig += vco2(.25, kfreq * cent(10),2, .4)

  asig *= iamp

  aenv = transegr:a(0, .05, 0, 1, 3, -4.2, 0.5, 4, -4.2, 0)

  ioct = octcps(ifreq)

  // modulated filter using base oct + env * key-tracked value
  asig = zdf_2pole(asig, limit(cpsoct(5.5 + aenv * (2 + (ioct * .5))),
20, 18000), .5)

  asig *= declick_rel(4, 2)

  ga1 += asig
  ga2 += asig
endin

instr Mixer

  // amount to send to reverb
  iamt = ampdbfs(-12)

  // pre-delay: 150ms
  a1 = delay(ga1 * iamt, .15)
  a2 = delay(ga2 * iamt, .15)

  a1, a2 reverbsc a1, a2, 0.88, 12000

  // sum dry + wet
  a1 += ga1
  a2 += ga2

  out a1, a2
  clear ga1, ga2
endin
schedule("Mixer", 0, -1)

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