csound / manual

Csound Reference Manual (English)
Other
46 stars 29 forks source link

add ATS analysis to ATSA examples #561

Closed tjingboem closed 3 years ago

tjingboem commented 3 years ago

by adding system_i to ATSA examples:

csounder commented 3 years ago

great. these solutions make it so much easier to appreciate and explore 'all' the utilities and utility-based opcodes.

- dB

Dr. Richard Boulanger

Professor

Electronic Production and Design

Berklee College of Music

Professional Writing & Technology Division

On Mon, Jul 12, 2021 at 4:33 AM Menno Knevel @.***> wrote:

by adding system_i to ATSA examples:

-

ATSinfo

ATSread(nz)

ATSbufread

ATSinterpread

ATSpartialtap

ATSadd(nz)

ATScross

ATSsinnoi

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://us-west-2.protection.sophos.com?d=github.com&u=aHR0cHM6Ly9naXRodWIuY29tL2Nzb3VuZC9tYW51YWwvaXNzdWVzLzU2MQ==&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=N1Y3TUF0R2pVanRlaG5rK3pVMGFyZjR1aTQ4WmlwUVFidXZNZ0xUUS9aQT0=&h=c526a50513e54d5f9821058f198d7b9a, or unsubscribe https://us-west-2.protection.sophos.com?d=github.com&u=aHR0cHM6Ly9naXRodWIuY29tL25vdGlmaWNhdGlvbnMvdW5zdWJzY3JpYmUtYXV0aC9BQUxXWUZWVjc2NVZIUTRGUDNGWjVBVFRYS1NHREFOQ05GU001QUdMTUoyQQ==&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=N0VkNW1qcm1tYmxjaXdmcXVrU0lMVHc1c2pVOTFydWtadXNmVnhDSXB3cz0=&h=c526a50513e54d5f9821058f198d7b9a .

tjingboem commented 3 years ago

starting slowly with ATSinfo. Right now there are 2 examples on the manual page, but we can remove the first one. The second one is more complete, and now has the system_i opcode and a bit more transparent print output

<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
-n     ;;;no audio out
</CsOptions>
<CsInstruments>

;example by joachim heintz (& Menno Knevel)

sr = 44100
ksmps = 32
nchnls = 2
0dbfs =  1
;ATSA wants a mono file!
ires system_i 1,{{ atsa fox.wav fox.ats }} ; default settings

instr 1 
Sfile   =       "fox.ats"
isr     ATSinfo Sfile, 0
ifs     ATSinfo Sfile, 1
iws     ATSinfo Sfile, 2
inp     ATSinfo Sfile, 3
inf     ATSinfo Sfile, 4
ima     ATSinfo Sfile, 5
imf     ATSinfo Sfile, 6
id      ATSinfo Sfile, 7
ift     ATSinfo Sfile, 8
        prints  {{
*****fox.ats*********************
0. Sample rate = %d Hz
1. Frame Size  = %d samples
2. Window Size = %d samples
3. contains      %d partials
4. contains      %d frames
5. Max. Ampl.  = %f
6. Max. Freq.  = %f Hz
7. Duration    = %f seconds
8. File Type   = %d
*********************************\\n
}}, isr, ifs, iws, inp, inf, ima, imf, id, ift
endin
</CsInstruments>
<CsScore>
i 1 0 0 
e
</CsScore>
</CsoundSynthesizer>
tjingboem commented 3 years ago

This is the 1st of 2 examples for ATSadd:

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

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

; by Menno Knevel - 2021
;ATSA wants a mono file!
ires system_i 1,{{ atsa fox.wav fox.ats }} ; default settings

instr 1 
; synthesize 30 partials, using a ipartialoffset of 0 and ipartialincr of 2, 
; which means that we will start from the first partial and synthesize 30 partials in total, 
; skipping every other one (ie. partial 1, 3, 5,..).
ktime   line    0, p3, 2.756
asig    ATSadd  ktime, 1,  "fox.ats", 1, 30, 0, 2
    outs    asig*2.5, asig*2.5  ;amplify

endin

</CsInstruments>
<CsScore>
f 1 0 16384 10 1 0 .5 0 .3 0 .15    ;square wave

i 1 0 2.756 
e
</CsScore>
</CsoundSynthesizer>
tjingboem commented 3 years ago

The advanced example by Joachim, ATSadd-2.csd, is already great. I just added the system_i atsa rule, so that on every system the fox will be analyzed and will be ready for use. Also the atsa analyze settings are not default, resulting in less smearing.


<CsoundSynthesizer>
<CsOptions>
-odac -d -m1
</CsOptions>
<CsInstruments>
;example by joachim heintz (& Menno Knevel)
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

;ATSA wants a mono file!
ires system_i 1,{{ atsa -h.1 -c2 fox.wav fox.ats }} ; only 2 cycles and small hop size

giSine    ftgen     0, 0, 1024, 10, 1

  instr AllTheTones
Sfile     =         "fox.ats"
          prints    "Resynthesizing with all the tones.\n"
iDur      ATSinfo   Sfile, 7
p3        =         iDur
iNumParts ATSinfo   Sfile, 3
          prints    "Overall number of partials = %d\n", iNumParts
ktime     line      0, iDur, iDur
asig      ATSadd    ktime, 1, Sfile, giSine, iNumParts
          outs      asig, asig

;start next instr
          event_i   "i", "TonesInBandsOfTen", iDur+1, iDur, 0, iNumParts
  endin

  instr TonesInBandsOfTen
Sfile     =         "fox.ats"
iOffset   =         p4 ;start at this partial
iNumParts =         p5 ;overall number of partials
          prints    "Resynthesizing with partials %d - %d.\n", iOffset+1, iOffset+10
ktime     line      0, p3, p3
asig      ATSadd    ktime, 1, Sfile, giSine, 10, iOffset
          outs      asig, asig

;start next instance until there are enough partials left
 if iOffset+20 < iNumParts then
          event_i   "i", "TonesInBandsOfTen", p3+1, p3, iOffset+10, iNumParts
          else
          event_i   "i", "End", p3, 1
 endif
  endin

  instr End
          exitnow
  endin
</CsInstruments>
<CsScore>
i "AllTheTones" 0 1
e 999
</CsScore>
</CsoundSynthesizer>
tjingboem commented 3 years ago

For this advanced example of ATSaddnz from Joachim, i added the system_i atsa with some options . Now the fox sound like they are Borg (Star Trek). Resisting this example is futile!

<CsoundSynthesizer>
<CsOptions>
-odac -d -m1
</CsOptions>
<CsInstruments>
;example by joachim heintz (& Menno Knevel)
sr = 44100
ksmps = 32
nchnls = 2
0dbfs  = 1

;ATSA wants a mono file!
ires system_i 1,{{ atsa -h.1 -c1 fox.wav fox.ats }} ; only 1 cycle and small hop size

instr AllTheNoise
Sfile    =        "fox.ats"
         prints   "Resynthesizing with all the noise.\n"
iDur     ATSinfo  Sfile, 7
p3       =        iDur
ktime    line     0, iDur, iDur
asig     ATSaddnz ktime, Sfile, 25
         outs     asig, asig

;start next instr
         event_i  "i", "NoiseInBandsOfFive", iDur+1, 1, 0
endin

instr NoiseInBandsOfFive
Sfile    =        "fox.ats"
         prints   "Resynthesizing with noise bands %d - %d.\n", p4, p4+5
iDur     ATSinfo  Sfile, 7
p3       =        iDur
ktime    line     0, iDur, iDur
asig     ATSaddnz ktime, Sfile, 5, p4
         outs     asig, asig

;start next instr
if p4 < 20 then
         event_i  "i", "NoiseInBandsOfFive", iDur+1, 1, p4+5
endif
endin
</CsInstruments>
<CsScore>
i "AllTheNoise" 0 1
e 25
</CsScore>
</CsoundSynthesizer>
tjingboem commented 3 years ago

the simple ATSaddnz example

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

; by Menno Knevel - 2021

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

;ATSA wants a mono file!
ires system_i 1,{{ atsa beats.wav beats.ats }} ; default size

instr 1 

ktime   line     0, p3, p3
asig    ATSaddnz ktime, "beats.ats", 1, 4   ; only 1 noise band, the 4th noise band
    outs    asig*6, asig*6  ;amplify
endin

</CsInstruments>
<CsScore>
i1 0 2 
e
</CsScore>
</CsoundSynthesizer>
csounder commented 3 years ago

Its so nice to read about the sound and setting in the console. In total, these are such an inspiring set of examples. ATS is such a wonderful system - and this more complete and autoAnalyzing approach, really shows off more of their full potential.

Wonderful.

- dB

Dr. Richard Boulanger

Professor

Electronic Production and Design

Berklee College of Music

Professional Writing & Technology Division

On Thu, Jul 15, 2021 at 3:12 PM Menno Knevel @.***> wrote:

the simple ATSaddnz example

; Select audio/midi flags here according to platform -odac ;;;RT audio out ;-iadc ;;;uncomment -iadc for RT audio input is needed too ; For Non-realtime ouput leave only the line below: ; -o ATSaddnzwav -W ;;; for file output any platform sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 ;ATSA wants a mono file! ires system_i 1,{{ atsa beats.wav beats.ats }} ; default size instr 1 ktime line 0, p3, p3 asig ATSaddnz ktime, "beats.ats", 1, 4 ; only 1 noise band, the 4th noise band outs asig*6, asig*6 ;amplify endin i1 0 2 e

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://us-west-2.protection.sophos.com?d=github.com&u=aHR0cHM6Ly9naXRodWIuY29tL2Nzb3VuZC9tYW51YWwvaXNzdWVzLzU2MSNpc3N1ZWNvbW1lbnQtODgwOTQ2MTA4&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=VmRXRTF2L2x0RlQxbUpQc0pjQnZYVVhta3laSWRhWFZhOXhGYXZ5VlpWWT0=&h=9b30393f4e424c3995edc693dc29b5f1, or unsubscribe https://us-west-2.protection.sophos.com?d=github.com&u=aHR0cHM6Ly9naXRodWIuY29tL25vdGlmaWNhdGlvbnMvdW5zdWJzY3JpYmUtYXV0aC9BQUxXWUZTNkJCWk5LWUVFTjVUVlJaVFRYNFhJREFOQ05GU001QUdMTUoyQQ==&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=bkxJZm0yK1lXeUhSRzJUSk5HTU44dUs5WHlvNVhuTlFoUldValpBM2s1ND0=&h=9b30393f4e424c3995edc693dc29b5f1 .

joachimheintz commented 3 years ago

yeah --- really great work menno!!! cheers - j

On 15/07/2021 22:50, csounder wrote:

Its so nice to read about the sound and setting in the console. In total, these are such an inspiring set of examples. ATS is such a wonderful system - and this more complete and autoAnalyzing approach, really shows off more of their full potential.

Wonderful.

- dB

Dr. Richard Boulanger

Professor

Electronic Production and Design

Berklee College of Music

Professional Writing & Technology Division

On Thu, Jul 15, 2021 at 3:12 PM Menno Knevel @.***> wrote:

the simple ATSaddnz example

; Select audio/midi flags here according to platform -odac ;;;RT audio out ;-iadc ;;;uncomment -iadc for RT audio input is needed too ; For Non-realtime ouput leave only the line below: ; -o ATSaddnzwav -W ;;; for file output any platform sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 ;ATSA wants a mono file! ires system_i 1,{{ atsa beats.wav beats.ats }} ; default size instr 1 ktime line 0, p3, p3 asig ATSaddnz ktime, "beats.ats", 1, 4 ; only 1 noise band, the 4th noise band outs asig*6, asig*6 ;amplify endin i1 0 2 e

— You are receiving this because you commented. Reply to this email directly, view it on GitHub

https://us-west-2.protection.sophos.com?d=github.com&u=aHR0cHM6Ly9naXRodWIuY29tL2Nzb3VuZC9tYW51YWwvaXNzdWVzLzU2MSNpc3N1ZWNvbW1lbnQtODgwOTQ2MTA4&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=VmRXRTF2L2x0RlQxbUpQc0pjQnZYVVhta3laSWRhWFZhOXhGYXZ5VlpWWT0=&h=9b30393f4e424c3995edc693dc29b5f1, or unsubscribe

https://us-west-2.protection.sophos.com?d=github.com&u=aHR0cHM6Ly9naXRodWIuY29tL25vdGlmaWNhdGlvbnMvdW5zdWJzY3JpYmUtYXV0aC9BQUxXWUZTNkJCWk5LWUVFTjVUVlJaVFRYNFhJREFOQ05GU001QUdMTUoyQQ==&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=bkxJZm0yK1lXeUhSRzJUSk5HTU44dUs5WHlvNVhuTlFoUldValpBM2s1ND0=&h=9b30393f4e424c3995edc693dc29b5f1 .

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/csound/manual/issues/561#issuecomment-881004498, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQYHKSIW4FZPV7Y25NYCZTTX5C27ANCNFSM5AGLMJ2A.

tjingboem commented 3 years ago

Thanks, Joachim!

yes, this is a really nice way to change some settings in the atsa analyzer and getting sounding results fast. It is fun! I'm pretty confident more people may want to play with these opcodes!

tjingboem commented 3 years ago

these examples are committed: https://csound.com/manual/ATSadd.html https://csound.com/manual/ATSaddnz.html https://csound.com/manual/ATSinfo.html

tjingboem commented 3 years ago

possible example for ATSbufread

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

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

; by Menno Knevel - 2021

;ATSA wants a mono file!
;it takes a while to analyze these files...
ires1 system_i 1,{{ atsa finneganswake1.flac finneganswake.ats }} 
prints "\n***1st analyzed file is ready***\n\n"
ires2 system_i 1,{{ atsa beats.wav beats.ats }} 
prints "\n***2nd analyzed file is ready***\n\n"

instr 1
ipr ATSinfo "finneganswake.ats", 3                  ; get number of partials
prints "\n***number of partials = %d***\n\n", ipr

ktime1  line    0, p3, 12.67
ktime2  line    0, p3, 2
kline   line    0, p3, 1                            ; cross from voice to the beats
        ATSbufread ktime1, 1, "finneganswake.ats", ipr
aout    ATScross   ktime2, 1, "beats.ats", 1, kline, 1, ipr
    outs aout*1.7, aout*1.7

endin

</CsInstruments>
<CsScore>
; sine wave.
f 1 0 16384 10 1

i 1 0 12.7
e
</CsScore>
</CsoundSynthesizer>
tjingboem commented 3 years ago

ATScross

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

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

; by Menno Knevel - 2021

;ATSA wants a mono file!
;it takes a while to analyze these files...
ires1 system_i 1,{{ atsa finneganswake1.flac finneganswake.ats }} 
prints "\n***1st analyzed file is ready***\n\n"
ires2 system_i 1,{{ atsa beats.wav beats.ats }} 
prints "\n***2nd analyzed file is ready***\n\n"

instr 1
ipr ATSinfo "finneganswake.ats", 3                  ; get number of partials
prints "\n***number of partials = %d***\n\n", ipr

ktime1  line    0, p3, 12.67
ktime2  line    0, p3, 2
kline   line    p4, p3, p5                            
        ATSbufread ktime1, 1, "finneganswake.ats", ipr
aout    ATScross   ktime2, 1, "beats.ats", 1, kline, 1, ipr ; cross from p4 to p5
    outs aout*1.7, aout*1.7

endin

</CsInstruments>
<CsScore>
; sine wave.
f 1 0 16384 10 1
;          start    end
i 1 0 12.7   0       1 ; voice --> beats
i 1 15 12.7  1       0 ; beats --> voice
e
</CsScore>
</CsoundSynthesizer>
tjingboem commented 3 years ago

i think i understand the meaning of ATSinterpread?

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

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

; by Menno Knevel - 2021

ires system_i 1,{{ atsa fox.wav fox.ats }} ; ATSA wants a mono file!

instr 1 

ktime   line    0, p3, 2.65
    ATSbufread ktime, 1, "fox.ats", p4
kamp    ATSinterpread   p5  ; get envelope from partial
aosc    poscil3 kamp, p5
    outs    aosc * 8, aosc * 8

endin

</CsInstruments>
<CsScore>
;              partial     index         
s
i 1 0 2.65      12          1000
i 1 3 2.65      12          150
i 1 6 2.65      12          10000
s
i 1 0 2.65      72          1000
i 1 3 2.65      72          150
i 1 6 2.65      72          10000
e
</CsScore>
</CsoundSynthesizer>
tjingboem commented 3 years ago

ATSpartialstap

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

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

; by Menno Knevel - 2021

ires1 system_i 1,{{ atsa beats.wav beats1.ats }} ; default settings
ires2 system_i 1,{{ atsa -h.8 -c8 beats.wav beats2.ats }} ; longer hopsize & more cycles

instr 1 

ktime   line    0, p3, 2
    ATSbufread ktime, 1, p4 , 90
kfreq1, kam1    ATSpartialtap  5
kfreq2, kam2    ATSpartialtap  20
kfreq3, kam3    ATSpartialtap  30

aout1   oscil   kam1, kfreq1, 1
aout2   oscil   kam2, kfreq2, 1
aout3   oscil   kam3, kfreq3, 1
aout    =   (aout1+aout2+aout3)*10  ; amplify some more
    outs    aout * p5, aout * p5
endin

</CsInstruments>
<CsScore>
f 1 0 16384 10 1 0 .5 0 .33 ; square-ish wave
; stretch the beats 2x
i 1 0 2 "beats1.ats"    1   ; defaults settings for ATSA
i 1 3 2 "beats2.ats"    .25 ; different settings
e
</CsScore>
</CsoundSynthesizer>
tjingboem commented 3 years ago

i would not dare to touch Joachims' example ATSread-2. However, i have added the atsa trick- but will not add my name for it...

I would like to rename this one to ATSread-musical.csd as this is clearly a musical gesture. And not a a simple example. Are you okay with this, Joachim?

<CsoundSynthesizer>
<CsOptions>
-odac -d -m128
</CsOptions>
<CsInstruments>
;example by joachim heintz
sr = 44100
ksmps = 32
nchnls = 2
0dbfs  = 1

ires1 system_i 1,{{ atsa fox.wav fox.ats }} ; default settings

giSine    ftgen     0, 0, 1024, 10, 1
gSfile    =         "fox.ats"
giNumParts ATSinfo  gSfile, 3 ;overall number of partials
giDur     ATSinfo   gSfile, 7 ;duration 
          seed      0

  instr ReadOnePartial
iPartial  =         p4
p3        =         giDur
ktime     line      0, giDur, giDur
          prints    "Resynthesizing partial number %d.\n", iPartial
kFq,kAmp  ATSread   ktime, gSfile, iPartial
kAmp      port      kAmp, .1 ;smooth amplitudes - still not satisfactoring
aOut      poscil    kAmp, kFq, giSine
aOut      linen     aOut, 0, p3, .01 ;anti-click
          outs      aOut*10, aOut*10

;start next instr: normal speed, three loops, pause between loops one second
          event_i   "i", "MasterRand", giDur+3, 1, 1, 3, 2
  endin

  instr MasterRand
  ;random selections of 10 partials per second, overlapping
iSpeed    =         p4 ;speed of reading / playing
iNumLoops =         p5 ;number of loops
iPause    =         p6 ;length of pause between loops
          prints    "Resynthesizing random partials.\n"
p3        =         (giDur/iSpeed+iPause) * iNumLoops
;start next instr: half speed, three loops, three seonds pause between loops
          event_i   "i", "MasterArp", p3+3, 1, .5, 3, 3
;loop over duration plus pause
loop:
          timout    0, giDur/iSpeed+iPause, play
          reinit    loop
play:
gkTime    line      0, giDur/iSpeed, giDur ;start time from 0 in each loop
kTrig     metro     10 ;10 new partials per second
 ;call subinstrument if trigger and no pause
 if kTrig == 1 && gkTime < giDur then
kPart     random    1, giNumParts+.999
          event     "i", "PlayRand", 0, 1, int(kPart)
 endif

  endin

  instr MasterArp
  ;argeggio-like reading and playing of partials 
iSpeed    =         p4 ;speed of reading / playing
iNumLoops =         p5 ;number of loops
iPause    =         p6 ;length of pause between loops
          prints    "Arpeggiating partials.\n"
p3        =         (giDur/iSpeed+iPause) * iNumLoops
loop:
          timout    0, giDur/iSpeed+iPause, play
          reinit    loop
play:
gkTime    line      0, giDur/iSpeed, giDur
kArp      linseg    1, (giDur/iSpeed)/2, giNumParts, (giDur/iSpeed)/2, 1 ;arp up and down
kTrig     metro     10 ;10 new partials per second
 if kTrig == 1 && gkTime < giDur then
          event     "i", "PlayArp", 0, 5, int(kArp)
 endif

;exit csound when finished
          event_i   "i", "End", p3+5, 1
  endin

  instr PlayRand
iPartial  =         p4
kFq,kAmp  ATSread   gkTime, gSfile, iPartial
kamp      port      kAmp, .15 ;smooth amplitudes
aOut      poscil    kAmp, kFq, giSine
aOut      linen     aOut, .01, p3, .01
          outs      aOut, aOut
  endin

  instr PlayArp
kCount    init      1 ;k-cycle
iPartial  =         p4
kFq,kAmp  ATSread   gkTime, gSfile, iPartial
 if kCount == 1 then ;get freq from first k-cycle
kModFq    =         kFq
  ;avoid to go with 0 Hz as this blocks the mode filter
  if kModFq == 0 then
          turnoff
  endif
 endif
iVol      random    -42, -12 ;db
iOffset   random    .01, .1 ;no too regularily ...
aImp      mpulse    ampdb(iVol), p3, iOffset
iQ        random    500, 5000
aOut      mode      aImp, kModFq, iQ
aOut      linen     aOut, 0, p3, p3/3
          outs      aOut, aOut
kCount    =         2
  endin

  instr End
          exitnow
  endin
</CsInstruments>
<CsScore>
i "ReadOnePartial" 0 1 10
e 999
</CsScore>
</CsoundSynthesizer>
tjingboem commented 3 years ago

...where this would be the simple example for ATSread

<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 ATSread.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

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

; by Menno Knevel - 2021

ires system_i 1,{{ atsa fox.wav fox.ats }} ; default settings

instr 1 

ktime   line    0, p3, 2
kfreq, kamp ATSread  ktime, "beats.ats", 10 ; take the 10th partial
aenv    linen   1, 0, p3, .1    ; envelope to avoid clicks
aout    oscili  0.8, kfreq, 1
    outs    aout * aenv, aout * aenv

endin

</CsInstruments>
<CsScore>
f 1 0 16384 10 1 ;sine wave.

i 1 0 1         ; fast speed
i 1 2 2         ; normal
i 1 5 10        ; 5x slower 
e
</CsScore>
</CsoundSynthesizer>
tjingboem commented 3 years ago

simple example for ATSsinoi

<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 ATSsinnoi.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

; by Menno Knevel - 2021

ires system_i 1,{{ atsa -h.5 -c1 beats.wav beats.ats }} ; default settings

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

instr 1 ; "beats.ats" is created by atsa

ktime   line    0,  p3, 2
knzfade expon   0.001, p3, 2    ; fade to extra noise
aout    ATSsinnoi   ktime, 1, knzfade, 1, "beats.ats", 150
    outs    aout*2, aout*2      ;amplify some more
endin

</CsInstruments>
<CsScore>

i 1 0 2 
e
</CsScore>
</CsoundSynthesizer>
tjingboem commented 3 years ago

these examples are committed: https://csound.com/manual/ATSbufread.html https://csound.com/manual/ATScross.html https://csound.com/manual/ATSinterpread.html https://csound.com/manual/ATSread.html https://csound.com/manual/ATSpartialtap.html

tjingboem commented 3 years ago

example for ATSreadnz

<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 ATSreadnz.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

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

; by Menno Knevel - 2021

ires system_i 1,{{ atsa beats.wav beats.ats }} ; default settings

instr 1 

ktime   line    0, p3, 2
kenergy ATSreadnz ktime, "beats.ats", p4 ; return energy from band p4
anoise  randi   kenergy, 1500          
    outs    anoise *.7, anoise *.7
endin

</CsInstruments>
<CsScore>
;           band
i 1 0 2      6 
i 1 3 2      12 
i 1 6 2      17 
e

</CsScore>
</CsoundSynthesizer>
tjingboem commented 3 years ago

There is something odd with ATSsinoi To start with, the folowing simple example produces Segmentation fault

<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 ATSsinnoi.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

; by Menno Knevel - 2021

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

ires2 system_i 1,{{ atsa  beats.wav beats2.ats }} ; default settings -h.25 -c4
ires1 system_i 1,{{ atsa -h.5 -c1 beats.wav beats1.ats }} 

instr 1 

ktime   line    0,  p3, 2

aout    ATSsinnoi   ktime, 1, 1, 1, p4, 10
    outs    aout, aout      ;amplify some more
endin

</CsInstruments>
<CsScore>

i 1 0 2 "beats2.ats"
i 1 + 2 "beats1.ats"
e
</CsScore>
</CsoundSynthesizer>

I think it has to do with the hopsize or the cycles, but am not sure. Somehow the partial 10 can not be created. aout ATSsinnoi ktime, 1, 1, 1, p4, 30 works.

Should there be a built in protection when a partial can not be made?

joachimheintz commented 3 years ago

there was an issue with some internal mentioned by oscar pablo di liscia: https://github.com/csound/csound/pull/1495 perhaps it is related?

On 20/07/2021 17:08, Menno Knevel wrote:

There is something odd with ATSsinoi To start with, the folowing simple example produces Segmentation fault

| ; 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 ATSsinnoi.wav -W ;;; for file output any platform ; by Menno Knevel - 2021 sr = 44100 ksmps = 32 nchnls = 2 0dbfs = 1 ires2 system_i 1,{{ atsa beats.wav beats2.ats }} ; default settings -h.25 -c4 ires1 system_i 1,{{ atsa -h.5 -c1 beats.wav beats1.ats }} instr 1 ktime line 0, p3, 2 aout ATSsinnoi ktime, 1, 1, 1, p4, 10 outs aout, aout ;amplify some more endin

i 1 0 2 "beats2.ats" i 1 + 2 "beats1.ats" e

|

I think it has to do with the hopsize, but am not sure. Somehow the partial 10 can not be created. aout ATSsinnoi ktime, 1, 1, 1, p4, 30 works.

Should there be a built in protection when a partial can not be made?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/csound/manual/issues/561#issuecomment-883470842, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAQYHKXTUSRZD5YE6K4FNDTTYWGQFANCNFSM5AGLMJ2A.

tjingboem commented 3 years ago

added example for ATSreadnz: https://csound.com/manual/ATSreadnz.html updated all links to ATS website

Awaiting for any improvements of ATSsinoi

tjingboem commented 3 years ago

Now that ATSsinnoi seems to be repaired, this will be the simple example

<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 ATSsinnoi.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

; by Menno Knevel - 2021

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

ires1 system_i 1,{{ atsa -h.5 -c1 beats.wav beats1.ats }}
ires2 system_i 1,{{ atsa  beats.wav beats2.ats }} ; default settings -h.25 -c4

instr 1 

ktime   line    0,  p3, 2

aout    ATSsinnoi   ktime, 1, 1, 1, p4, p5
    outs    aout*.4, aout*.4        
endin

</CsInstruments>
<CsScore>
s
;           atsfile     partial
i 1 0 2 "beats1.ats"        3
i 1 3 2 "beats2.ats"        3
s
i 1 0 2 "beats1.ats"        13
i 1 3 2 "beats2.ats"        13
s
i 1 0 2 "beats1.ats"        30
i 1 3 2 "beats2.ats"        30

e
</CsScore>
</CsoundSynthesizer>
tjingboem commented 3 years ago

and the more complicated example ATSsinnoi-2.csd can be:

<CsoundSynthesizer>
<CsOptions>
-odac -d -m128
</CsOptions>
<CsInstruments>
;example by joachim heintz (& Menno Knevel)
sr = 44100
ksmps = 32
nchnls = 2
0dbfs = 1

ires system_i 1,{{ atsa fox.wav fox.ats }} ; default settings

giSine    ftgen     0, 0, 1024, 10, 1
gSfile    =         "fox.ats"
giNumParts ATSinfo  gSfile, 3 ;overall number of partials
giDur     ATSinfo   gSfile, 7 ;duration 
          seed      0

  instr PlayList
event_i "i", "PlayAll", 0, 1, 1, 0, .5 ;sine only, half speed
event_i "i", "PlayAll", giDur*2+1, 1, 0, 1, .5 ;noise only
event_i "i", "PlayAll", giDur*4+2, 1, .5, .5, .5 ;half sine, half noise
  endin

  instr PlayAll
iSinAmnt  =         p4 ;sinee amount (0-1)
iNzAmnt   =         p5 ;noise amount (0-1)
iSpeed    =         p6 ;speed
p3        =         giDur/iSpeed
ktime     line      0, giDur/iSpeed, giDur
          prints    "Resynthesizing all partials with tone = %.1f and noise = %.1f.\n", iSinAmnt, iNzAmnt
aOut      ATSsinnoi ktime, iSinAmnt, iNzAmnt, 1, gSfile, giNumParts
          outs      aOut, aOut
  endin

  instr PlayBand
iOffset   =         p4 ;offset in partials
iSpeed    =         p5 ;speed
p3        =         giDur/iSpeed
ktime     line      0, giDur/iSpeed, giDur
          prints    "Resynthesizing partials %d to %d with related noise.\n", iOffset+1, iOffset+10
aOut      ATSsinnoi ktime, 1, .3, 1, gSfile, 10, iOffset, 1 ; a bit less noise (.3)
          outs      aOut*2, aOut    ; left channel a bit louder
;call itself again
 if iOffset < giNumParts - 20 then
          event_i   "i", "PlayBand", giDur/iSpeed+1, 1, iOffset+10, iSpeed
 endif
  endin

  instr PlayWeighted
  ;sine amount, noise amount and speeed are varying
kSinAmnt  randomi   0, 1, 1, 3
kNzAmnt   =         1-kSinAmnt
kSpeed    randomi   .01, .3, 1, 3
async     init      0
atime, aEnd syncphasor kSpeed/giDur, async
kTrig     metro     100
kEnd      max_k     aEnd, kTrig, 1 ;1 if phasor signal crosses zero
ktime     downsamp  atime
aOut      ATSsinnoi ktime*giDur, kSinAmnt, kNzAmnt, 1, gSfile, giNumParts
          outs      aOut*.6, aOut   ; pan a bit to the right
  ;exit if file is at the end 
if kEnd == 1 then
           event     "e", 0, 0
endif

endin

</CsInstruments>
<CsScore>
i "PlayList" 0 1
i "PlayBand" 20 1 0 .5
i "PlayWeighted" 110 100
</CsScore>
</CsoundSynthesizer>
tjingboem commented 3 years ago

John fixed the ATSsinnoi issue, and all ATS examples are updated ATSsinnoi: https://csound.com/manual/ATSsinnoi.html i will close the issue

csounder commented 3 years ago

inspiring set of examples

- dB

Dr. Richard Boulanger

Professor

Electronic Production and Design

Berklee College of Music

Professional Writing & Technology Division

On Sun, Jul 25, 2021 at 6:20 AM Menno Knevel @.***> wrote:

John fixed the ATSsinnoi issue, and all ATS examples are updated ATSsinnoi: https://csound.com/manual/ATSsinnoi.html https://us-west-2.protection.sophos.com?d=csound.com&u=aHR0cHM6Ly9jc291bmQuY29tL21hbnVhbC9BVFNzaW5ub2kuaHRtbA==&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=Y1FlV1ljN2NqanErVWIyZXFmYW1WM1llSWN1b0xYVExJYks3ZG1rNk1jTT0=&h=fda2ca27376d453693ffd206b7a8ba0c i will close the issue

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://us-west-2.protection.sophos.com?d=github.com&u=aHR0cHM6Ly9naXRodWIuY29tL2Nzb3VuZC9tYW51YWwvaXNzdWVzLzU2MSNpc3N1ZWNvbW1lbnQtODg2MTc4OTY3&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=UzFzV0tSbkR4Vzh1WFBnZ0lUZnp4Q1A1NUNjODNqVnp0ZjZsTkVsUTVZND0=&h=fda2ca27376d453693ffd206b7a8ba0c, or unsubscribe https://us-west-2.protection.sophos.com?d=github.com&u=aHR0cHM6Ly9naXRodWIuY29tL25vdGlmaWNhdGlvbnMvdW5zdWJzY3JpYmUtYXV0aC9BQUxXWUZVSTc3SEU3RVVYWlhRRTdEM1RaUFFON0FOQ05GU001QUdMTUoyQQ==&i=NWYxNzBkMDNiNTVmZGEwZmIyNjczYmRm&t=bmZSbHM2dTJEdEtGOUtWYUVqMmZqYWtCMkFJQUtrZ2R4Nkd4eXAwc1B1ST0=&h=fda2ca27376d453693ffd206b7a8ba0c .