Messages Search About

[Csnd] Newbie post - Function Table Arpeggios example

Date2022-08-25 21:48
FromScott Daughtrey
Subject[Csnd] Newbie post - Function Table Arpeggios example
WARNING: somewhat pedestrian newbie stuff ahead. Coding anything Is quite new to me. Other relative beginners may find this example interesting. 

Having just read the FLOSS manual section on tables, and based on an earlier example from Iain McCurdy using a function table to randomize notes, I decided to further explore using tables for scales and arpeggios etc.

My previous experiments with arpeggios often used score loops which have certain drawbacks, for example the inability to transpose as easily and especially not being able to alter the colour (major, minor, dominant, adding 7ths, 9ths etc.) without creating specific loops. 

This example reads the Note tables incrementally. Instr 1 feeds either instr 2 or 3 depending on the value of p6. I found that, as the tables are read in order by instr 1, that when a new instance is called in the score it starts one increment from the index where the previous one ended, thereby creating a smoother transition between patterns as opposed to always starting on the first note (Root) of the arp. 

To better hear the transitions, line 26:
kTrig metro       8/kDur 
can be altered from 8 to 6 or 4 to slow it down.

Possibly not the most efficient method or coding but hey, that's why I'm a newbie. Instr are full stereo,although it wasn't really necessary,  for further experimenting with adding panning etc.



-odac
; output for writing audio file with
; Android version of Csound:
; -o/sdcard/TableArps.wav


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

gaRvbL    init  0
gaRvbR    init  0
; initialize Count at -1 so Note tables are read starting at index 0
giCount   init -1
; min add 2 arpeggio
giNotes1  ftgen   0,0,-11,-17,0,60,1,62, 2,63, 3,67, 4,72, 
                5,74, 6,75, 7,74, 8,72, 9,67, 10,63, 11,62
; maj add 2 arpeggio
giNotes2  ftgen   0,0,-11,-17,0,60,1,62, 2,64, 3,67, 4,72, 
                5,74, 6,76, 7,74, 8,72, 9,67, 10,64, 11,62


  instr 1
kDur  init        1      ; initial rhythmic duration
kTrig metro       8/kDur ; metronome freq. 8 times inverse of duration
      schedkwhen  kTrig,0,0,p6,0,1/3,p4,p5; trigger a note!
  endin

  instr 2

giCount = giCount + 1
iNote table     giCount,giNotes1,0,0,1 ;read incrementally from the table
kEnv  linsegr   0, 0.005, p5, p3, p5, .5, 0 ; amplitude envelope
iPlk  random    0.1, 0.3    ; point at which to pluck the string
iDtn  random    -0.05, 0.05 ; random detune
iCps = cpsmidinn(iNote+p4+iDtn)
aSig  wgpluck2  0.98, 0.2, iCps, iPlk, 0.06
kEnv2 linseg    .1,p3/2, 0                                          
aSig2 foscil    kEnv2*.1,iCps+12,2,1,5, 1
amixL = aSig*kEnv+aSig2/2
amixR = aSig*kEnv+aSig2
      outs      amixL,amixR
gaRvbL   =  gaRvbL+(aSig*.22)
gaRvbR   =  gaRvbR+(aSig*.22)
  endin

  instr 3

giCount = giCount + 1
iNote table     giCount,giNotes2,0,0,1
kEnv  linsegr   0, 0.005, p5, p3, p5, .5, 0
iPlk  random    0.1, 0.3
iDtn  random    -0.05, 0.05
iCps = cpsmidinn(iNote+p4+iDtn)
aSig  wgpluck2  0.98, 0.2, iCps, iPlk, 0.06
kEnv2 linseg    .1,p3/2, 0                                          
aSig2 foscil    kEnv2*.1,iCps+12,2,1,5, 1
amixL = aSig*kEnv+aSig2/2
amixR = aSig*kEnv+aSig2
      outs      amixL,amixR
gaRvbL   =  gaRvbL+(aSig*.22)
gaRvbR   =  gaRvbR+(aSig*.22)
  endin

  
  instr 4

aRvbL,aRvbR reverbsc gaRvbL,gaRvbR,0.91,11000
            outs     aRvbL,aRvbR
            clear    gaRvbL,gaRvbR
 endin



f 1 0 16384 10 1
i 4  0  40

i 1  0   5     0  .8  2
i 1  5   .    -4  .8  3
i 1 10   .    -7  .8  2
i 1 15   5.1  -2  .8  3

i 1 22   1   -12  .8  2
i 1 23   .    -9  .8  3
i 1 24   .    -7  .8  2
i 1 25   .    -4  .8  3
i 1 26   .    -2  .8  3
i 1 27   2     0  .8  2
i 1 29   1.2   3  .8  3

e


; inspired by an example by Iain McCurdy
; 01D13 from the FLOSS manual

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

Date2022-08-25 22:31
From"Jeanette C."
SubjectRe: [Csnd] Newbie post - Function Table Arpeggios example
Aug 25 2022, Scott Daughtrey has written:
...
> This example reads the Note tables incrementally. Instr 1 feeds either instr 2 or 3 depending on the value of p6. I found that, as the tables are read in order by instr 1, that when a new instance is called in the score it starts one increment from the index where the previous one ended, thereby creating a smoother transition between patterns as opposed to always starting on the first note (Root) of the arp.
...
Nice, imaginative little arpeggiator/chord generator. Thanks for
sharing. Not stupid at all.

Best wishes,

Jeanette

-- 
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

There must be another way
Cause I believe in taking chances
But who am I to say - What a girl is to do <3
(Britney Spears)

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

Date2022-08-25 22:50
FromST Music
SubjectRe: [Csnd] Newbie post - Function Table Arpeggios example
Thank you for the replies Jeanette. I appreciate the feedback, I'm here to learn. Feel free to email me off-list anytime you like. 

I read your previous comments and will look at them all more carefully, it may take a little while to digest. I'm still learning the basics so of course it's often hard to see the myriad of approaches to doing things. I know from my experience using DAWs, synths and virtual modular synthesis that there are often several different ways get similiar  results, some more efficient than others. With coding I'm sure that increases exponentially. 

Looking forward to eventually trying your Hexacon at some point, unfortunately I can't yet afford a new computer so I'm doing everything for now on an Android phone and it doesn't like your code - it just crashes lol. Oh well, I can't complain, my phone is probably far more powerful than many of my previous computers.

Thank you again and warm regards,

On Thu, Aug 25, 2022, 5:33 PM Jeanette C., <julien@mail.upb.de> wrote:
Aug 25 2022, Scott Daughtrey has written:
...
> This example reads the Note tables incrementally. Instr 1 feeds either instr 2 or 3 depending on the value of p6. I found that, as the tables are read in order by instr 1, that when a new instance is called in the score it starts one increment from the index where the previous one ended, thereby creating a smoother transition between patterns as opposed to always starting on the first note (Root) of the arp.
...
Nice, imaginative little arpeggiator/chord generator. Thanks for
sharing. Not stupid at all.

Best wishes,

Jeanette

--
  * Website: http://juliencoder.de - for summer is a state of sound
  * Youtube: https://www.youtube.com/channel/UCMS4rfGrTwz8W7jhC1Jnv7g
  * Audiobombs: https://www.audiobombs.com/users/jeanette_c
  * GitHub: https://github.com/jeanette-c

There must be another way
Cause I believe in taking chances
But who am I to say - What a girl is to do <3
(Britney Spears)

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