Csound Csound-dev Csound-tekno Search About

Re: [Csnd] Quasi-Square Wave via F-Table Values

Date2020-10-25 19:15
FromMark Ferguson
SubjectRe: [Csnd] Quasi-Square Wave via F-Table Values
Joachim/Rory:

My apologies; issues resolved. I had table values in there that I hadn't checked via printing.

I've got what I need now. FYI, code below. Just messing around; I'm sure there are infinitely easier ways to achieve same. :)




sr        =         192000
ksmps     =         10
nchnls    =         1
0dbfs     =         1

instr Test

giRecfn 	ftgen	0, 0, 0, 1, "file.wav", 0, 0, 0 ; Original recording.

idur	=	p3
ifilecod	=	p4
isize	=	ftlen(giRecfn)

//////////

index1            =         0
index2            =         0

iWritefn	ftgen	0, 0, isize, 21, 3	; Create value writing table.

; Set all iWritefn table values to 0.
loop1_start:
          tableiw   0, index1, iWritefn
          loop_lt   index1, 1, isize, loop1_start

; Read every 10th sample from giRecfn and write to iWritefn.
loop2_start:
          iwrval    table    index2, giRecfn
                    tableiw   iwrval, index2, iWritefn
          loop_lt   index2, 10, isize, loop2_start

//////////

/*
; Test every 10th sample for value.
indx	=	0

until indx == ftlen(iWritefn)/100 do
	ival	table	indx, iWritefn, 0
	print	ival
	indx +=	1
od
*/

//////////

aphase	phasor	1/idur
asig	table	aphase * ftlen(iWritefn), iWritefn, 0

out	asig * 1

endin






i"Test" 0 1 "file.wav"





Csound mailing list
Csound@listserv.heanet.ie
https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND
Send bugs reports to
        https://github.com/csound/csound/issues
Discussions of bugs and features can be posted here