🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.music
Article #3414

Re: Csound and samples again

#3414
From: Thomas Sullivan
Date: Tue, 25 Jun 1991 13:04
60 lines
2980 bytes
If you look in your Csound manual, you will see the following for
oscils:

kr	oscil(i)	kamp, kcps, ifn[, iphs]
ar	oscil(i)	xamp, xcps, ifn[, iphs]

These are the control rate and audio rate oscillators (the 'i' means
interpolated, if you wish a linear interpolation between samples,
instead of
a sample and hold type of behavoir).

ifn is the function table number.  Csound interprets this as ONE CYCLE
of the oscillator waveform, regardless of its size.  So, if you load
exactly one second of sound into the table (must be same sample rate as
the sample rate given for this orchestra) and give the cps field as 1,
then it will play back exactly.  Now, since people don't tend to use
power of 2 sampling rates, the chances of you loading exactly one second
of sound into a table are slim!  So, you have to fool with the cycles
per second field if you want to do things this way. 

From your post, it looks like you loaded some sound of length X samples
into a table of length Y (with the excess padded with zeros).   If the
sample 
rate of the original sound is R, then if you were to just play the X
samples of the original sound at rate R, it would take X/R seconds.  We
want things such that when one cycle of this oscillator is played
through, you get the original sound back.  this instrument will do this:

;; R is the sample rate of the original sound.  X is the number of samples of
;; the original sound used, Y is the the table length.  X and Y can be made
;; into 'p' parameters if you wish to use different tables with this same 
;; instrument.

	srate	R
	krate	R/N
	ksmps	N
	nchnls	1

	instr	1
;;  p3 is the amplitude, p4 is the warped cps, and p5 is the table number.
;;  so if p4 = 1, this will play the sound so it will come out normal., if you 

;;  make p4 = 2 then the sound will be an octave higher and so on.
a1	oscil	p3,  p4 * (R/Y), p5 
	out	a1
	endin

Basically, all that is going on here is that we are scaling the cps
field by the 
ratio between the real sample rate of the original sound, and the
"internal sample rate" of one cycle of a waveform, namely the table
length.  If you divide your table length into your original sound's
sample rate, do you get something in the neighborhood of the 0.18 that
you reported?

I haven't tested this, so let me know if it works.  It has been a while since 
I've done any serious Csound work.

--Tom
(tms@speech1.cs.cmu.edu)
Technical Details
Message-ID: <4cNnxvy00WB4AGm0Ug@andrew.cmu.edu>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!batcomputer!cornell!rochester!pt.cs.cmu.edu!o.gp.cs.cmu.edu!andrew.cmu.edu!ts09+
References: <1991Jun23.224435.1@cc.helsinki.fi>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!rpi!batcomputer!cornell!rochester!pt.cs.cmu.edu!o.gp.cs.cmu.edu!andrew.cmu.edu!ts09+
From: ts09+@andrew.cmu.edu (Thomas Sullivan)
Newsgroups: comp.music
Subject: Re: Csound and samples again
Message-ID: <4cNnxvy00WB4AGm0Ug@andrew.cmu.edu>
Date: 25 Jun 91 13:04:59 GMT
References: <1991Jun23.224435.1@cc.helsinki.fi>
Organization: Carnegie Mellon, Pittsburgh, PA
Lines: 60
In-Reply-To: <1991Jun23.224435.1@cc.helsinki.fi>