Csound Csound-dev Csound-tekno Search About

Re: Grains from Audio files

Date1999-03-07 02:44
FromHans Mikelson
SubjectRe: Grains from Audio files
Hi,

The tricky thing when using samples with Csound's grain opcode is that the
frequency indicates the rate at which the *entire* sound file is scanned
since there is way to indicate a base frequency.  So if you want the
granular sound to be approximately the same pitch as the sample be sure to
indicate a frequency of 1/sample length.

Below is an example.  Note: Take out the line wraps.

Bye,
Hans Mikelson

; ORC
sr=44100
kr=4410
ksmps=10
nchnls=2

;---------------------------------------------------------------------------
-------
; Basic Granular Sampler Synthesis
;---------------------------------------------------------------------------
-------
       instr    4

idur    =       p3
iamp    =       p4
ifqc    =       p5
igrtab  =       p6
iwintab =       p7
ifrng   =       p8
idens   =       p9
ifade   =       p10
igdur   =       p11
iamprng =       p12

kamp    linseg  0, ifade, 1, idur-2*ifade, 1, ifade, 0

;              Amp  Fqc   Dense  AmpOff       PitchOff    GrDur  GrTable
WinTable  MaxGrDur
aoutl   grain  p4,  ifqc, idens, 100*iamprng, ifqc*ifrng, igdur, igrtab,
iwintab,  5
aoutr   grain  p4,  ifqc, idens, 100*iamprng, ifqc*ifrng, igdur, igrtab,
iwintab,  5

        outs   aoutl*kamp, aoutr*kamp

      endin

; SCO
f2 0 524288 1 "soundin.11" 0 4 0
f7 0 1024 8  0 512 1 512 0

;  Start  Dur  Amp    Freq  GrTab  WinTab  FqcRng  Dens  Fade  GrDur  AmpRng
i4   0.0  2    20000  .08   2      7       .021    200   .2    .1     1