Csound Csound-dev Csound-tekno Search About

[Cs-dev] upsamp parser issue

Date2011-11-20 12:27
Frommenno
Subject[Cs-dev] upsamp parser issue
Hi,

looking for a sensible example for the manual for the upsamp opcode, and
finding one in the UDO repo, i noticed a difference when i ran the example
with the old parser versus the new parser.
(The example is modified a bit, using 0dbfs=1 now)

So i report: with old parser the 3 notes are played, with the new parser
only 2 - but no crash



; Select audio/midi flags here according to platform
-odac     ;;;realtime audio out
;-iadc    ;;;uncomment -iadc if RT audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o upsamp.wav -W ;;; for file output any platform



sr = 44100
ksmps = 32
nchnls = 2
0dbfs  = 1

opcode	decimator, a, akk	;UDO

      setksmps 1
ain, kbit, ksrate xin

kbits = 2^kbit			;bit depth (1 to 16)
kfold = (sr/ksrate)		;sample rate
kin   downsamp  ain		;convert to kr
kin   = (kin + 1)		;add DC to avoid (-)
kin   = kin*(kbits / 2)		;divide signal level
kin   = int(kin)		;quantise
aout  upsamp  kin		;convert to sr
aout  = aout * (2/kbits) - 1	;scale and remove DC
a0ut  fold aout, kfold		;resample
      xout a0ut

	endop
		
instr 1	;avoid playing this too loud

kbet = p4
kser = 441000
asig diskin "fox.wav", 1
aout decimator	asig, kbet, kser
     printk2 kbet
     printk2 kser
     outs aout*.7, aout*.7

endin



i 1 0	3 16		;sounds allright but
i 1 +	3 5		;it's getting worse
i 1 +	3 1		;and worse...

e	





--
View this message in context: http://csound.1045644.n5.nabble.com/upsamp-parser-issue-tp5008108p5008108.html
Sent from the Csound - Dev mailing list archive at Nabble.com.

------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net

Date2011-11-20 12:42
FromVictor Lazzarini
SubjectRe: [Cs-dev] upsamp parser issue
I think the three notes are playing but the first one is kind of silent...
This line is the problem:

kbits = 2^kbit			;bit depth (1 to 16)

the ^ operator is giving us trouble. Change to

kbits pow  2, kbit

and it works.

I remember that the ^ operator was not working in the new parser a while ago and I reported it. It was fixed then (I thought), but it may need another look now.

Regards

Victor

On 20 Nov 2011, at 12:27, menno wrote:

> Hi,
> 
> looking for a sensible example for the manual for the upsamp opcode, and
> finding one in the UDO repo, i noticed a difference when i ran the example
> with the old parser versus the new parser.
> (The example is modified a bit, using 0dbfs=1 now)
> 
> So i report: with old parser the 3 notes are played, with the new parser
> only 2 - but no crash
> 
> 
> 
> ; Select audio/midi flags here according to platform
> -odac     ;;;realtime audio out
> ;-iadc    ;;;uncomment -iadc if RT audio input is needed too
> ; For Non-realtime ouput leave only the line below:
> ; -o upsamp.wav -W ;;; for file output any platform
> 
> 
> 
> sr = 44100
> ksmps = 32
> nchnls = 2
> 0dbfs  = 1
> 
> opcode	decimator, a, akk	;UDO
> 
>      setksmps 1
> ain, kbit, ksrate xin
> 
> kbits = 2^kbit			;bit depth (1 to 16)
> kfold = (sr/ksrate)		;sample rate
> kin   downsamp  ain		;convert to kr
> kin   = (kin + 1)		;add DC to avoid (-)
> kin   = kin*(kbits / 2)		;divide signal level
> kin   = int(kin)		;quantise
> aout  upsamp  kin		;convert to sr
> aout  = aout * (2/kbits) - 1	;scale and remove DC
> a0ut  fold aout, kfold		;resample
>      xout a0ut
> 
> 	endop
> 		
> instr 1	;avoid playing this too loud
> 
> kbet = p4
> kser = 441000
> asig diskin "fox.wav", 1
> aout decimator	asig, kbet, kser
>     printk2 kbet
>     printk2 kser
>     outs aout*.7, aout*.7
> 
> endin
> 
> 
> 
> i 1 0	3 16		;sounds allright but
> i 1 +	3 5		;it's getting worse
> i 1 +	3 1		;and worse...
> 
> e	
> 
> 
> 
> 
> 
> --
> View this message in context: http://csound.1045644.n5.nabble.com/upsamp-parser-issue-tp5008108p5008108.html
> Sent from the Csound - Dev mailing list archive at Nabble.com.
> 
> ------------------------------------------------------------------------------
> All the data continuously generated in your IT infrastructure 
> contains a definitive record of customers, application performance, 
> security threats, fraudulent activity, and more. Splunk takes this 
> data and makes sense of it. IT sense. And common sense.
> http://p.sf.net/sfu/splunk-novd2d
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel

Dr Victor Lazzarini
Senior Lecturer
Dept. of Music
NUI Maynooth Ireland
tel.: +353 1 708 3545
Victor dot Lazzarini AT nuim dot ie




------------------------------------------------------------------------------
All the data continuously generated in your IT infrastructure 
contains a definitive record of customers, application performance, 
security threats, fraudulent activity, and more. Splunk takes this 
data and makes sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-novd2d
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net