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 no examples #737

Open
4 of 97 tasks
tjingboem opened this issue May 31, 2024 · 23 comments
Open
4 of 97 tasks

opcodes no examples #737

tjingboem opened this issue May 31, 2024 · 23 comments

Comments

@tjingboem
Copy link
Member

tjingboem commented May 31, 2024

  • arduinoStart
  • arduinoStop
  • chnparams
  • control
  • ftload
  • ftloadk
  • ftsavek
  • hvs3
  • i
  • in32
  • inh
  • initc14
  • het_import
  • count
  • cntState
  • cntDelete
  • fareylen
  • initc21
  • inletf
  • inletkid
  • ino
  • inrg
  • insglobal
  • inx
  • inz
  • midglobal
  • link_beat_request
  • link_beat_get
  • link_beat_force
  • k
  • initc21
  • noteon
  • noteoff
  • mrtmsg
  • outkpat
  • outkc14
  • outipat
  • outic14
  • outh
  • out32
  • outx
  • outo
  • outletv
  • outletkid
  • outletf
  • vphaseseg
  • tab2pvs
  • tablewkt
  • tableigpw
  • tableicopy
  • tablegpw
  • tabw_i
  • vphaseseg
  • tableigpw
  • tabw
  • tablew
  • tab_i
  • strupperk
  • strupper
  • slider32table
  • slider32tablef
  • slider64
  • slider64f
  • slider64table
  • slider64tablef
  • slider8
  • slider8f
  • slider8table
  • slider8tablef
  • strchark
  • strcmpk
  • strindex
  • strlen
  • strlenk
  • remoteport
  • remove
  • rigoto
  • S
  • s32b14
  • schedulek
  • serialEnd
  • serialFlush
  • serialPrint
  • serialWrite_i
  • slider16
  • slider16f
  • slider16table
  • slider16tablef
  • slider32
  • slider32f
  • strlowerk
  • strrindexk
  • strsubk
  • strtod
  • strtodk
  • strtol
  • strtolk
@AsterixMusic
Copy link

Simple example for "schedulek"

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

; By Stefano Cucchi 2024


</CsOptions>
<CsInstruments>

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

instr 1

kfreqnote randomh 0.1, 6.3, 2

kTrigger  metro   kfreqnote 
if kTrigger == 1 then ;

schedulek 10, 0, 0.1 ;call the instrument
endif

endin


instr 10

a1 oscili 0.2, 440, 2

outs a1, a1

endin


</CsInstruments>
<CsScore>

f 2 0 4096 10 1 0.9 0.8 0.7 0.6

i 1 0 10


</CsScore>
</CsoundSynthesizer> 

@AsterixMusic
Copy link

Simple example for "tableicopy"

Copying the source table to destination tables with different dimensions and reading with no interpolating opcode.

<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 tableicopy.wav -W ;;; for file output any platform

; By Stefano Cucchi 2024

</CsOptions>
<CsInstruments>


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


instr 1 

tableicopy 2, 1 

a1 oscil 0.2, 440, 2 
outs a1, a1

endin


instr 2 


tableicopy 3, 1

a1 oscil 0.2, 440, 3
outs a1, a1

endin


</CsInstruments>

<CsScore>

f1 0 4096 10 1 0 1 0 1 1 0 1 0 1

f2 0 8 10 1

f3 0 4096 10 1

i 1 0 4

i 2 4 4 

e


</CsScore>

</CsoundSynthesizer>

@joachimheintz
Copy link
Contributor

joachimheintz commented Jun 9, 2024 via email

@tjingboem
Copy link
Member Author

the simple example for schedulek is added to the manual, but the musical example from Joachim did threw an error:
missing " to terminate stringunknown CSD tag:

@csounder
Copy link

csounder commented Jun 10, 2024 via email

@csounder
Copy link

csounder commented Jun 10, 2024 via email

@csounder
Copy link

csounder commented Jun 10, 2024 via email

@AsterixMusic
Copy link

Now should work, there was a typo error in line 79 or some error during copy & paste the code
Thanyou @joachimheintz

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

; by joachim heintz 2024


</CsOptions>
<CsInstruments>

sr = 48000
ksmps	= 64
nchnls = 2
0dbfs	= 1
seed 0

opcode RndHarm,i[],iop
   //generates an array with iLen random numbers
   iLen,iMin,iMax xin //defaults to iMin=0 and iMax=1
   iOut[] init iLen
   indx = 0
   while (indx<iLen) do
     iOut[indx] = random:i(iMin,iMax)
     indx += 1
   od
   xout iOut
endop


instr GenerateSpectrum
   iHarmonics[] = RndHarm(p4)
   giSound = ftgen(0,0,4096,10,iHarmonics)
endin
schedule("GenerateSpectrum",0,0,4)

instr Call
   iStartPitch = 80 //MIDI note number
   kPitch init iStartPitch
   kStep init 3
   kNoteCount init 0
   kTrigMaxFreq init 3
   kTrigFreq init 2
   kPan init 0.9
   kNumHarm init 4
   kCycleCount init 1
   if (metro:k(kTrigFreq) == 1) then
     // call instrument
     schedulek("Play",0,kCycleCount/kTrigMaxFreq,kPitch,kPan)
     // update values
     kTrigFreq = random:k(kTrigMaxFreq/2,kTrigMaxFreq)
     kNoteCount += 1
     kPan -= 0.8/7
     kPitch -= kStep
     // if seven tones have been played, start again differently
     if (kNoteCount == 7) then
       kPitch = iStartPitch
       kPan = 0.9
       kStep /= 1.5
       kTrigMaxFreq /= 1.5
       kNoteCount = 0
       kNumHarm *= 1.5
       kCycleCount += 1
       schedulek("GenerateSpectrum",0,0,int(kNumHarm))
     endif
     // stop after six cycles
     if (kCycleCount == 7) then
       schedulek("Terminate",kCycleCount/kTrigMaxFreq,1)
       turnoff
     endif
   endif
   // print main values
   if (changed(kCycleCount) == 1) then
     printks("Cycle %d:\n",0,kCycleCount)
     printks("   kStep (semitones) and kTrigMaxFreq (Hz) = %.3f\n number of harmonics = %.3f\n",0,kStep,int(kNumHarm))
   endif
endin
schedule("Call",0,-1)

instr Play
   iPitch = p4
   iPan = p5
   aOut = oscili:a(0.2,mtof:i(iPitch),giSound)
   aOut = linen:a(aOut,0,p3,p3/2)
   aL,aR pan2 aOut,iPan
   out(aL,aR)
endin

instr Terminate
   event("e",0,0)
endin

</CsInstruments>
<CsScore>
</CsScore>
</CsoundSynthesizer>

@csounder
Copy link

csounder commented Jun 10, 2024 via email

@tjingboem
Copy link
Member Author

and a new musical example is born!

@joachimheintz
Copy link
Contributor

joachimheintz commented Jun 10, 2024 via email

@AsterixMusic
Copy link

very simple example for "tabw"

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

;By Stefano Cucchi 2024


</CsOptions>
<CsInstruments>

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


instr 1

tabw p4, 0, 2 ; write content of function number "2"
tabw p5, 1, 2
tabw p6, 2, 2
tabw p7, 3, 2
tabw p8, 4, 2

kamp oscili 1, 1/p3, 2 ;use f2 as envelope
asig poscil kamp, 440, 1		
     outs asig, asig

endin

</CsInstruments>
<CsScore>

f 1 0 8192 10 1 0.6 0 0.4 0.6	
f2 0 5 2 0 0 0 0 0

i1 0 2 0 0.9 0 0.2 0.9 ; every note has different envelope
i1 3 2 1 1 0 0.5 0

e
</CsScore>
</CsoundSynthesizer>

@csounder
Copy link

csounder commented Jun 10, 2024 via email

@tjingboem
Copy link
Member Author

i added an extra note and the notes now have a slightly longer duration. I can hear better now it envelopes:

i1 0 3 0 0.9 0 0.2 0.9 ; every note has different envelope
i1 4 3 1 0.01 1 0.5 0
i1 8 3 1 1 0 0.5 0

@csounder
Copy link

csounder commented Jun 10, 2024 via email

@AsterixMusic
Copy link

simple example for "tabw_i"

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

; By Stefano Cucchi 2024

</CsOptions>
<CsInstruments>

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


instr 1

ain diskin "fox.wav"

ifn = 1 ; table filled with "0"

isig1 = p4
indx1 = p5
tabw_i isig1, indx1, ifn ; write a value in the table 


isig2 = p6
indx2 = p7
tabw_i isig2, indx2, ifn  ; write a value in the table 


aconv dconv ain, 32768, 1 ; convolution 

outs aconv, aconv

endin


</CsInstruments>
<CsScore>


f1 0 32768 7  0 32768 0

i1 0 10 1 1  1 16384 ; writes 1 at the beginning and 1 in the middle so we hear 2 copyes of the "fox"

e


</CsScore>
</CsoundSynthesizer>

@tjingboem
Copy link
Member Author

tjingboem commented Jun 14, 2024

on my machine i get a lot of
WARNING: Buffer underrun in real-time audio output
WARNING: Buffer underrun in real-time audio output
but it seems to work

And a quote from Richard:
The recent example with tab and fox and convolution produced noise on my M1 MacBookDr. Richard BoulangerProfessorElectronic Production and DesignBerklee College of MusicOn Jun 14, 2024, at 2:21 PM

@csounder
Copy link

csounder commented Jun 14, 2024 via email

@AsterixMusic
Copy link

@csounder
Copy link

csounder commented Jun 14, 2024 via email

@csounder
Copy link

csounder commented Jun 14, 2024 via email

@tjingboem
Copy link
Member Author

I got an error trying to access Dropbox.
But that is no problem, i heard the audio stumbling through my speakers with buffer underruns.

As this example is clearly CPU demanding, we could get the -odac command out and only let it render to disk?

@tjingboem
Copy link
Member Author

The example from Joachim is now part of the musical examples folder.
Thanks!

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

No branches or pull requests

4 participants