Csound Csound-dev Csound-tekno Search About

[Cs-dev] Real time events and timestamps

Date2014-07-29 21:15
From"Yogi A. Patel"
Subject[Cs-dev] Real time events and timestamps
AttachmentsNone  None  
Hi -

I have a few questions about real-time performance. I have csound fully working on the beaglebone black with angstrom (posting instructions soon since it was nontrivial).

I have the .csd file generating tones at the frequency and amplitude that I want and have a few questions:

1. I want to make sure that this tone generation is precise (tones are occurring every 500 ms). Is there a way to get a precise time reading for when each tone is generated?

2. I have a train of tones (call it tone1) being generated for 20 seconds at a rate of 0.5 hz. I want to generate a random tone (call it tone2) of a different frequency during the window of 10-18s within that 20s period tone1 is still playing. Is it possible to do this? I can’t seem to find any opcode that could do this?

3. I want to use a GPIO pin on the beaglebone to detect when two buttons are pressed - each in response to one of the two tones described above. What is the best way to do this using csound? Is it more precise (in terms of timing) to call csound with the .csd file from c or use the C API to generate these tones and control the buttons?

Thank you!

Yogi


Date2014-08-01 15:33
FromOeyvind Brandtsegg
SubjectRe: [Cs-dev] Real time events and timestamps
Maybe this is all too late, and you've figured it out already, but a
starting point for your setup might be something like this. You would
reinit instr 1 for each tone pair event. This can also be done
automatically within instr 1, just say if it matches what you need and
if you need more help with it.
Also, this is perhaps more suited for the normal csound list, as it is
a problem other users/programmers might be interested in. The dev list
is more focused on issues related to development of the Csound
language/library/core (programming of Csound) while the normal list is
more for the use of the language (programming in Csound).

all best
Oeyvind



;-odac -+rtaudio=jack -B256



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

    giSine        ftgen    0, 0, 65536, 10, 1                ; sine wave

    instr 1
        istart1         = 0                             ; start tone 1
immediately
        idur1           = 20                            ; duration of tone 1
        ioffset         = 10                            ; the minimum
time gap before tone 2
        irandrange      = 8                             ; the random time period
        irand           rnd31 irandrange,1              ; generate randome value
        istart2         = istart1+irand+ioffset         ; from start
of 1st tone, add offset and random times
        idur2           = idur1-istart2                 ; we want tone
2 to stop at the same time as tone 1 (just guessing...)
                        event_i "i", 2, istart1, idur1  ; generate
event for tone 1
                        event_i "i", 3, istart2, idur2  ; generete
event for tone 2
    endin

        instr 2
        itime   rtclock         ; get time when event started
        print itime
        a1      oscili 0.5, 440, giSine ; just some default values
here, for the sketch
                outs a1, a1
        endin

        instr 3
        itime   rtclock
        print itime
        a1      oscili 0.5, 660, giSine
                outs a1, a1
        endin



;    start    dur
i1    0    1
f0 60                   ; keep running for 60 seconds
e





2014-07-29 22:15 GMT+02:00 Yogi A. Patel :
> Hi -
>
> I have a few questions about real-time performance. I have csound fully
> working on the beaglebone black with angstrom (posting instructions soon
> since it was nontrivial).
>
> I have the .csd file generating tones at the frequency and amplitude that I
> want and have a few questions:
>
> 1. I want to make sure that this tone generation is precise (tones are
> occurring every 500 ms). Is there a way to get a precise time reading for
> when each tone is generated?
>
> 2. I have a train of tones (call it tone1) being generated for 20 seconds at
> a rate of 0.5 hz. I want to generate a random tone (call it tone2) of a
> different frequency during the window of 10-18s within that 20s period tone1
> is still playing. Is it possible to do this? I can't seem to find any opcode
> that could do this?
>
> 3. I want to use a GPIO pin on the beaglebone to detect when two buttons are
> pressed - each in response to one of the two tones described above. What is
> the best way to do this using csound? Is it more precise (in terms of
> timing) to call csound with the .csd file from c or use the C API to
> generate these tones and control the buttons?
>
> Thank you!
>
> Yogi
>
>
> ------------------------------------------------------------------------------
> Infragistics Professional
> Build stunning WinForms apps today!
> Reboot your WinForms applications with our WinForms controls.
> Build a bridge from your legacy apps to the future.
> http://pubads.g.doubleclick.net/gampad/clk?id=153845071&iu=/4140/ostg.clktrk
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
>



-- 

Oeyvind Brandtsegg
Professor of Music Technology
NTNU
7491 Trondheim
Norway
Cell: +47 92 203 205

http://flyndresang.no/
http://www.partikkelaudio.com/
http://soundcloud.com/brandtsegg
http://soundcloud.com/t-emp

------------------------------------------------------------------------------
Want fast and easy access to all the code in your enterprise? Index and
search up to 200,000 lines of code with a free copy of Black Duck
Code Sight - the same software that powers the world's largest code
search on Ohloh, the Black Duck Open Hub! Try it now.
http://p.sf.net/sfu/bds
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net