Quantcast

[Csnd] trying to do audio rate compare

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

[Csnd] trying to do audio rate compare

zappfinger
For my 'reversal' project I am trying to read an audio table containing
several guitar notes. I want to find where a note starts and ends, in
order to copy it reversed to another table. When I execute the following
code, the 'found one' message appears only once.
I realize that a prints at audio rate might be too much. In fact it is k
rate, but with setksmps to 1.

So why does it happen only once and what is the best way to to audio
rate compare? I cannot directly compare an a-rate variable to a value,
so it seems:

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

gifn1 ftgen 1, 0, 0, 1, "../samples/gitar#gottobe.wav", 0, 4, 0
;deferred-size table
gisize = ftlen(gifn1)
giEmpty   ftgen     2, 0, -gisize, 2, 0        ;empty table of the same size
;ftsave    "track.txt", 1, 1

instr 1
setksmps 1
atab  init 0
isize tableng 1                    ;length of table?
print isize
andx  phasor 1 / (isize / sr)
asig  tab andx, 1, 1                ;has a 0 to 1 range for the index
if (abs(asig)>0.1) then        ; this gives: error: boolean expression
'>' with arg types ac not found
;if (k(abs(asig))>0.1) then    ; this prints only once
     prints "found one"
endif

       outs asig, asig

endin
</CsInstruments>
<CsScore>


i 1 0 35

Csound mailing list
[hidden email]
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
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd] trying to do audio rate compare

zappfinger
Found it, I need to use prinks of course...

Richard
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: [Csnd] trying to do audio rate compare

zappfinger
Hmm, this is not as easy as it seems. Now I am copying each sample to
the second, empty table, and play it when done. There was no sound.
The copying happens in the phasor loop:

instr 1
setksmps 1
isize tableng 1                    ;length of table?
print isize
andx  phasor 1 / (isize / sr)
asig  tab andx, gifn1, 1                ;has a 0 to 1 range for the index
tabw asig, andx, giEmpty                ; just copy
outs asig, asig
endin

I printed the table and it had some differences in the header:

header 1:

======= TABLE 1 size: 2369995 values ======
flen: 2369995
lenmask: 0
lobits: 0
lomask: 0
lodiv: 0.000000
cvtbas: 1024.000000
cpscvt: 0.000000
loopmode1: 0
loopmode2: 0
begin1: 0
end1: 2369995
begin2: 0
end2: 0
soundend: 2369995
flenfrms: 2369995
nchnls: 1
fno: 1
gen01args.gen01: 0.000000
gen01args.ifilno: 0.000000
gen01args.iskptim: 0.000000
gen01args.iformat: 0.000000
gen01args.channel: 0.000000
gen01args.sample_rate: 44100.000000

header 2:

======= TABLE 2 size: 2369995 values ======
flen: 2369995
lenmask: -1
lobits: 0
lomask: 0
lodiv: 1.000000
cvtbas: 0.000000
cpscvt: 0.000000
loopmode1: 0
loopmode2: 0
begin1: 0
end1: 0
begin2: 0
end2: 0
soundend: 0
flenfrms: 2369995
nchnls: 1
fno: 2
gen01args.gen01: 0.000000
gen01args.ifilno: 0.000000
gen01args.iskptim: 0.000000
gen01args.iformat: 0.000000
gen01args.channel: 0.000000
gen01args.sample_rate: 0.000000

Is this because table 1 was created by a Gen1?
Are the headers (in the printout) part of the tables or are they added
when doing the ftsave?

Richard


On 17/02/17 10:39, zappfinger wrote:

> Found it, I need to use prinks of course...
>
> Richard
>
>
>
> --
> View this message in context: http://csound.1045644.n5.nabble.com/Csnd-trying-to-do-audio-rate-compare-tp5754639p5754640.html
> Sent from the Csound - General mailing list archive at Nabble.com.
>
> Csound mailing list
> [hidden email]
> 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

Csound mailing list
[hidden email]
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
Loading...