Csound Csound-dev Csound-tekno Search About

Samples tuning

Date1998-01-17 10:20
FromSilvano Zambon
SubjectSamples tuning
Hello all,

   Often the AIFF samples have an incorrect base frequency given 
in header, usually the c5, and loscil don't play the correct note. 

The below .ORC is useful for their automatic re-tuning: at the
begin of the performance compute a correction for each instrument.

It use the octdown e noctdft opcodes et seems to work, but is compiled
only by the 486 version, the version 3.46 says: "... octdown not
initialized ..." and in the version 3.47 the opcodes octdown e noctdft
are removed! 
It is odd because remains active, but inserviceable, the opcodes specptrk, 
spec..ecc.

I am a beginner and think to miss something. Can anyone tell me:

- exist a more simple way to re-tuning the samples?
- the opcodes octdown e noctdft are replaced with something other?

Thanks,
Silvano Zambon
s.zambon@rdn.it
---------------------------------------------------------------------

;        re-tuning of n samples
;        at the begin of the performance, the instr, 200, for each sample,
;        find the note played from loscil and compare with the requested
;        (inotarif).
;        Then compute a correction coefficient  - gkcoeff1,2,..,n -
;        for use with loscil inside each instrument.

sr = 44100      ; must be the same of the sample (?)
kr = 2205
ksmps = 20
nchnls = 1

gkcoeff1 init 0 
gkcoeff2 init 0

;gkcoeffn init 0

instr 1  ;sample 1
   iamp 	= ampdb(p4)
   inota        = cpspch(p5)
   icoeff =i(gkcoeff1)
   
   asig      loscil  iamp, inota * icoeff, 1
              out  asig
endin

instr 2  ;sample 2
   iamp 	= ampdb(p4)
   inota        = cpspch(p5)
   icoeff =i(gkcoeff2)
   
   asig      loscil  iamp, inota * icoeff, 2
              out  asig
endin

; instr ...

;instr n  ;sample n
;   iamp 	= ampdb(p4)
;   inota        = cpspch(p5)
;   icoeff =i(gkcoeffn)
;
;   asig      loscil  iamp, inota * icoeff, 2
;              out  asig
;endin

 ;------
 instr 200   ; at the begin of the performance, find  a correction coefficient
             ; for each sample
   inotarif = 5000   ; seems good for all the samples

   asamp   loscil  32000, inotarif, 1
   dsamp1  octdown  asamp, 8, 180, 0
   wsig1   noctdft  dsamp1, .05, 96, 33, 0, 0, 0   
   koct    specptrk wsig1, 8, .8, 0  
   knotau = cpsoct(koct)
   gkcoeff1 = inotarif/knotau  ; requested note / played note

   asamp   loscil  32000, inotarif, 2
   dsamp2  octdown  asamp, 8, 180, 0
   wsig2   noctdft  dsamp2, .05, 96, 33, 0, 0, 0 
   koct    specptrk wsig2, 8, .8, 0  
   knotau = cpsoct(koct)
   gkcoeff2 = inotarif/knotau

;  ....

;  asamp   loscil  32000, inotarif, n
;  dsampn  octdown  asamp, 8, 180, 0
;  wsign   noctdft  dsampn, .05, 96, 33, 0, 0, 0
;  koct    specptrk wsign, 8, .8, 0
;  knotau = cpsoct(koct)
;  gkcoeffn = inotarif/knotau

 endin

instr 99   ; sinus. for comparison "at ear".
   iamp    = ampdb(p4)
   inota   = cpspch(p5)  
   asig    oscil  iamp, inota, 99
           out asig   
endin

-------------------
;score:

f 1  0      0     1  "sample1.aif"  0  0  0
f 2  0      0     1  "sample2.aif"  0  0  0
; ...
f n  0      0     1  "samplen.aif"  0  0  0

f 99  0 4096 10 1    ;sine wave

; instrument   	start  duration	amp(p4)	freq(p5)
    i200        0       1
    i1		1	1       80	8.00
    i2 		2	1	80	8.00
    i99 	3	1	80	8.00
e