Csound Csound-dev Csound-tekno Search About

New member with burning question

Date1998-04-05 16:19
FromCarlton Wilkinson
SubjectNew member with burning question
I'm newly returned to the list after a couple years absence. You can
read and hear more about me if you're so inclined at the site below and
its links. (I say this because the message from majordomo encourages me
to say something about myself. Fine.)

Meantime, I have heard that there is a way, using a combination of
tablei.gen01 and two phasors, to create a smaller window that will scan
an entire soundfile at a variable speed--a non-FFT method of stretching
a sound while keeping the same pitch. I need a model. I'm running the
Mills PPC version, if that matters, and in it neither phasor nor tablei
will accept a varying rate (a k-rate or an a-rate) for the phase offset.
What's the secret here? Also, it seems to me you should be able to do
the same thing with the loscil code--somehow.
--
Carlton Joseph Wilkinson
http://excaliber.net/alex/wilkwrks.htm

Date1998-04-05 20:58
From"Matt J. Ingalls"
SubjectRe: New member with burning question
Carlton,
> Meantime, I have heard that there is a way, using a combination of
> tablei.gen01 and two phasors, to create a smaller window that will scan
> an entire soundfile at a variable speed--a non-FFT method of stretching
> a sound while keeping the same pitch. I need a model. I'm running the
> Mills PPC version, if that matters, and in it neither phasor nor tablei

theres alot of ways to do it.  (isnt this what "sndwarp" does?)

since you are using PPC version, you might want to consinder the score
generator - it would keep things simple:

;orc
ifilesize = 10 ; a 10 sec file. this could be in a p-field or gen2 lookup
iskip = p6*ifilesize
aout	diskin	p4, p5, iskip
kwindow	oscil1	0,1,p3,1
	out	aout*kwindow

;sco
f1 0 ; fill rest in of your window envelope

; a gesture from 0 to 60 sec
p0	0	60	785	1
; always instr 1
p1	1 0 
; start times every .15 to .25 sec
p2	.2 .1
; duration of window .3 seconds
p3	.3 0
; always soundin.1
p4	1 0
; pitch gliss normal to 1 oct up
p5	1 0	1	2  0
; skiptime of window just straight through file
p6	0 0 	1	1 0
E

see the doc for more info on scoregenerator
take a look at the "score generator changes" file
ps im going to update the example "scogen.orc" somehow and old version got
up on the ftp and i cant find a newer one...

==========
if your file is mono and short you might want to put the sound in a gen1
for speed..   what makes it tricky is that the table has to be a power of
2 yet your soundfile usually isnt - so you have to do some calculation for
that...

heres an orc of mine that does that. (with an warning of unused pfield
since the bottom stuff is commented out)

;===============================================;
;		rt.orc			matt ingalls			;
;
;
; 	simulation of Kent Dickey/Paul Lansky's		;
;	real-time mixer.		7/5/96				;
;
;
;	p2 = start(at)		p3 = dur				;
;	p4 = snd			p5 = skip
;
;	p6 = gain			p7 = pan
;
;	p8 = gliss func		p9 = transp				;
;	p10= rev flag
;
;===============================================;

        sr      =       44100
        kr      =       2205
        ksmps   =       20
        nchnls  =       2
        instr 1

;--- set up constants ---
isnd	=	p4
iskip	=	p5
iamp	=	p6
ipan	=	p7
ipitch	=	p9
isize	table	isnd - 101,100,0,0,0

;--- reading soundin ---
andx	phasor	ipitch*sr/isize,0
aout	tablei	isize*andx,isnd,0,0,1

;---- enveloping ----
kenvel	linen	iamp,.01,p3,.01
aenv		=	kenvel*aout

;--add your own panning/reverb stuff here ---

	outs		aenv, aenv
	
	endin


;===============================================;
;		rt.sco			matt ingalls			;
;
;
; 	simulation of Kent Dickey/Paul Lansky's		;
;	real-time mixer.		7/5/96				;
;
;
;	p2 = start(at)		p3 = dur				;
;	p4 = snd			p5 = skip
;
;	p6 = gain			p7 = pan
;
;	p8 = gliss func		p9 = transp				;
;	p10= rev flag
;
;===============================================;

;f10	0	512	8	.0001 20 .05 36 .1 20 .2 30 .4 150 1 150
.4 30 .2 20 .1 36 .05 20 .0001
;f11	0	512	9	.25 1 0
;f12	0	512	9	.25	1 0
;f13	0	513	7	0 512 1 1 1

; f100 is a look-up table of the actual sizes (in sample frames) of your
sounds. 
;  (the table sizes must be a power of 2!!)
f100	0	8	-2 80717
f101	0	131072	-1	"tubular"  0 4 0 0

;	2	3	4	5
i1	0	10	101	0	.5	.25	0 1 0
i1	0	10	101	0	.	.25	0 1.02 0
i1	0	10	101	0	.	.25	0 1.03 0
i1	0	10	101	0	.	.25	0 1.456 0
i1	0	10	101	0	.	.25	0 .21 0
i1	.10	10	101	0	.	.25	0 .81 0
e




===========

you can also manually set the index to your table - but be careful when
doing things like:	anx = anx + ifac
this will not do what you expect unless kr=sr.  use the 'interp' opcode
istead:

instr 2
	kwindln	line p4*sr,p3,p7*sr
	askip line p5*sr,p3,p8*sr
	kpitch line p6,p3,p9
	
	kndxl init 0
	kndxr init p4/2
	
	andxl interp kndxl,0
	andxr interp kndxr,p4/2
	
	aoutl tablei andxl+askip,1
	aoutr tablei andxr+askip,1
	
	kampl tablei kndxl/kwindln,2,1
	kampr tablei kndxr/kwindln,2,1
	
	kndxl = kndxl + kpitch*ksmps
	kndxr = kndxr + kpitch*ksmps

	;check for forwards wrap
	kndxl = (kndxl >= kwindln ? 0 : kndxl)
	kndxr = (kndxr >= kwindln ? 0 : kndxr)
		
	;check for backwards wrap
	kndxl = (kndxl < 0 ? kwindln : kndxl)
	kndxr = (kndxr < 0 ? kwindln : kndxr)
	
	outs aoutl*kampl,aoutr*kampr
endin

f1 0 262144 -1 "blues" 0 4 1
f2 0 1024	9 .5 1 0

i2 0 10 	.6 0 -1		.6  6  -1

e



-matt