Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

opcodes need cool examples #738

Open
4 of 28 tasks
tjingboem opened this issue May 31, 2024 · 11 comments
Open
4 of 28 tasks

opcodes need cool examples #738

tjingboem opened this issue May 31, 2024 · 11 comments
Labels

Comments

@tjingboem
Copy link
Member

tjingboem commented May 31, 2024

There are examples for these opcodes but they only print a value. Cool examples can be added to show their (basic) musical application

  • << and >>
  • cosh
  • cosinv
  • ctrl21
  • ctrl14
  • floor
  • frac
  • ftfree
  • octmidinn
  • octmidib
  • octmidi
  • octcps
  • logbtwo
  • log2
  • log10
  • octpch
  • pchmidib
  • pchmidi
  • taninv
  • tan
  • exp
  • log
  • ksmps
  • pchoct
  • poisson
  • sinh
  • sininv
  • rand example that shows pink, blue, brown noise
@AsterixMusic
Copy link

AsterixMusic commented Jun 2, 2024

Example for "ksmps"

<CsoundSynthesizer>
<CsOptions>

; Select audio/midi flags here according to platform
-odac      ;;;realtime audio out
;-iadc    ;;;uncomment -iadc if realtime audio input is needed too

; By Stefano Cucchi - 2024

</CsOptions>

<CsInstruments>

sr = 48000 

; If you set ksmps = 24000, then kr = 2, so you hear 2 step every sec.
ksmps = 24000

; If you set ksmps = 32, then kr = 1500: you can hear a smooth glissando
;ksmps = 32 

nchnls = 2
0dbfs = 1

instr 1
  kamp = 0.4
  kfreq expseg p4, p3, p5
  a1 oscil3 kamp, kfreq, 1
  outs a1, a1
endin


</CsInstruments>
<CsScore>

f 1 0 524288 10 1

i 1 0 15 100  13000

e


</CsScore>
</CsoundSynthesizer>

@tjingboem
Copy link
Member Author

tjingboem commented Jun 2, 2024

ksmps.csd added, thanks!

https://csound.com/manual/ksmps.html

@csounder
Copy link

csounder commented Jun 3, 2024 via email

@AsterixMusic
Copy link

2 examples for "poisson"

  1. simple example
<CsoundSynthesizer>
<CsOptions>


; Select audio/midi flags here according to platform
-odac     ;;;realtime audio out
;-iadc    ;;;uncomment -iadc if RT audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o loop_ge.wav -W ;;; for file output any platform

; By Stefano Cucchi - 2024



</CsOptions>
<CsInstruments>

; Initialize the global variables.

sr     =        48000
kr     =        32
nchnls =        2
0dbfs = 1

instr 1

klambda expseg p4, p3, p5
kpitch poisson klambda
printk (ksmps/sr),kpitch ;prints every k-period

a1 oscili 0.3, kpitch, 1
outs a1, a1

endin


</CsInstruments>
<CsScore>

f1 0 4096 10 1 0.1 0 0.2 0 0.3 0 0.1

i 1 0 10 300 300

e

</CsScore>

</CsoundSynthesizer>
  1. "musical" example
<CsoundSynthesizer>
<CsOptions>

; Select audio/midi flags here according to platform
-odac     ;;;realtime audio out
;-iadc    ;;;uncomment -iadc if RT audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o loop_ge.wav -W ;;; for file output any platform

; By Stefano Cucchi - 2024



</CsOptions>
<CsInstruments>

sr      =      48000
kr    	=     	4800
ksmps  	=     	10
nchnls	=	2
0dbfs  = 1


instr 1

klambda1 linseg p4, p3, p5
kindex poisson klambda1


klambda2 linseg p6, p3, p7
ktrigfreq poisson klambda2

ksig oscil 1, ktrigfreq
ktrig trigger ksig, 0, 0

schedkwhen ktrig, 0, 20, 10, 0, 0.2, kindex, 10

endin 


instr 10      

kcnt = p4
kpc     table   kcnt, p5         
kcps    =       cpspch(kpc)   

asig1    oscil   0.5, kcps, 1    

kenvelope linseg 0, p3*0.5, 1, p3*0.5, 0

asig1 = asig1*kenvelope
outs asig1, asig1  


endin       

</CsInstruments>
<CsScore>


f 1 0 4096 10 1 0 1 0 1 0 0 1 1 

f 10 0 24 -2 8.00 8.01 8.02 8.03 8.04 8.05 8.06 8.07 8.08 8.09 8.10 8.11 9.00 9.01 9.02 9.03 9.04 9.05 9.06 9.07 9.08 9.09 9.10 9.11 


i1 0 30 0 23 2 17
            
e

</CsScore>

@tjingboem
Copy link
Member Author

Could you @AsterixMusic agree to change the examples to
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

It will sound a bit different. Can you check them out please?

@AsterixMusic
Copy link

@tjingboem You can change the examples!

@tjingboem
Copy link
Member Author

thanks. I changed them a bit
they will be part of the manual soon

@csounder
Copy link

csounder commented Jun 6, 2024 via email

@AsterixMusic
Copy link

Simple example using FRAC and FLOOR

<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-odac     ;;;RT audio out
;-iadc    ;;;uncomment -iadc if RT audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o FracFloor.wav -W ;;; for file output any platform

; By Stefano Cucchi 2024

</CsOptions>

<CsInstruments>

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

instr 1

gkrandom randomh 1, 45, 300, 2,  3 ; generate some random numbers
gkrandomINT = floor (gkrandom) ; take the integer part
gkrandomFRAC = frac (gkrandom) ; take the fractional part

endin

instr 10

  ktrigger metro 4
  kmintim = 0
  kmaxnum = 10
  kinsnum = 20
  kwhen = 0
  kdur = ktrigger*0.25
 
  schedkwhen ktrigger, kmintim, kmaxnum, kinsnum, kwhen, kdur
  
endin


instr 20

  irandomINT = i(gkrandomINT) 
  irandomFRAC = i(gkrandomFRAC)

  ; Use the integer part to control the number of harmonics of every note
  ; after converting (k) value to (i)

  a1 buzz 0.5, 120, irandomINT, 1 
                            
  kenvelope linseg 0, p3*0.1, 1, p3*0.8, 1, p3*0.1, 0

  a1 = a1*kenvelope

  aL, aR pan2 a1, irandomFRAC, 1 ; use the fractional part to control the pan position 
  outs aL, aR
  
endin


</CsInstruments>
<CsScore>


f 1 0 16384 10 1

i 1 0 10

i 10 0 10 

e

@tjingboem
Copy link
Member Author

tjingboem commented Jun 8, 2024

what a fun example!
thanks!

I added some printing of floor and frac

@csounder
Copy link

csounder commented Jun 10, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants