[Csnd] Working MIDI trigger

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

[Csnd] Working MIDI trigger

Chuckk Hubbard
Gabriel, and anyone else interested- this version works.  I tried to
clean it up as much as I could; I don't understand gluPerspective or
glTranslate exactly, but I found these numbers work.
I merely need to change GLfps according to the file I work with (or
the music I compose won't line up!), and change the phasor rate and
phase according to total frames and which frame I want to start at.

If I really get into scoring, I might fix up a FLTK setup to create
markers responding to specific MIDI messages, so playback could be set
to start at different spots.  I tried setting up a p-field system for
frames and starting frame, but it's just as simple to change them in
the csd.
Next I have to see if I can trigger this from Blue with midiYoke.
Maybe I can set up my keyboard with MIDI thru, but I'll have to watch
out for feedback.

-Chuckk

<CsoundSynthesizer>
<CsOptions>

-+Y -+K

</CsOptions>
<CsInstruments>

        sr = 48000
        kr = 48000
        ksmps = 1
        nchnls = 2

        set_t_del 7
        GLfps 23, .5
        GLpanel "OpenGL panel", 528, 432
        GLpanel_end
       
        FLrun

#include "OpenGL.h"


giVidHand GLopenVideoFile "madgab.avi", .3


GLinsert_i $GL_INIT

        glMatrixMode $GL_PROJECTION
        glLoadIdentity
        gluPerspective 25,1,100
        glMatrixMode $GL_MODELVIEW
        glLoadIdentity
       

        glColor3 0,0,0
       
GLinsert_i $GL_NOT_VALID
        glClear $GL_COLOR_BUFFER_BIT +

$GL_DEPTH_BUFFER_BIT

GLinsert_i 1
gtTex init 0


;///////////////////////////////////////////////////
        instr 1
;///////////////////////////////////////////////////

gkmid init 0
gkmid, kchan, kdata1, kdata2 midiin


endin


;///////////////////////////////////////////////////
        instr 2
;///////////////////////////////////////////////////


        glBindTexture gtTex
        glTranslate .3,.45,-3
        glColor 1.5, 1.5, 1.5, 1.2
        GLtexSquare 1, 0,0, 1,0, 1,1, 0,1



GLinsert 1.1


printk2 gkmid

        schedwhen gkmid, 3, 0, 3600


        endin


;//////////////////////////////////////////////
        instr 3
;//////////////////////////////////////////////

        glMatrixMode $GL_MODELVIEW
        glLoadIdentity

tframe GLphasor 389, 0/389
gtTex GLvideo2tex giVidHand, tframe * 389
GLinsert 1.05


        endin


</CsInstruments>
<CsScore>
f1 3600 513 10 1

i1 0 3600
i2 2 3600


</CsScore>
</CsoundSynthesizer>


--
"Some people got attitude,
Backed up with attitude."
-G. Love
--
Send bugs reports to [hidden email]
              (or to http://www.cs.bath.ac.uk/cgi-bin/csound )
To unsubscribe, send email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Working MIDI trigger

Chuckk Hubbard
I swear I'll get this right.
These lines:
>        glClear $GL_COLOR_BUFFER_BIT +
>
> $GL_DEPTH_BUFFER_BIT

should be:
        glClear $GL_COLOR_BUFFER_BIT + $GL_DEPTH_BUFFER_BIT


On 5/11/05, Chuckk Hubbard <[hidden email]> wrote:

> Gabriel, and anyone else interested- this version works.  I tried to
> clean it up as much as I could; I don't understand gluPerspective or
> glTranslate exactly, but I found these numbers work.
> I merely need to change GLfps according to the file I work with (or
> the music I compose won't line up!), and change the phasor rate and
> phase according to total frames and which frame I want to start at.
>
> If I really get into scoring, I might fix up a FLTK setup to create
> markers responding to specific MIDI messages, so playback could be set
> to start at different spots.  I tried setting up a p-field system for
> frames and starting frame, but it's just as simple to change them in
> the csd.
> Next I have to see if I can trigger this from Blue with midiYoke.
> Maybe I can set up my keyboard with MIDI thru, but I'll have to watch
> out for feedback.
>
> -Chuckk
>
> <CsoundSynthesizer>
> <CsOptions>
>
> -+Y -+K
>
> </CsOptions>
> <CsInstruments>
>
>        sr = 48000
>        kr = 48000
>        ksmps = 1
>        nchnls = 2
>
>        set_t_del       7
>        GLfps   23, .5
>        GLpanel "OpenGL panel", 528, 432
>        GLpanel_end
>
>        FLrun
>
> #include "OpenGL.h"
>
> giVidHand       GLopenVideoFile "madgab.avi", .3
>
> GLinsert_i $GL_INIT
>
>        glMatrixMode    $GL_PROJECTION
>        glLoadIdentity
>        gluPerspective  25,1,100
>        glMatrixMode    $GL_MODELVIEW
>        glLoadIdentity
>
>        glColor3        0,0,0
>
> GLinsert_i $GL_NOT_VALID
>        glClear $GL_COLOR_BUFFER_BIT +
>
> $GL_DEPTH_BUFFER_BIT
>
> GLinsert_i 1
> gtTex   init    0
>
> ;///////////////////////////////////////////////////
>        instr 1
> ;///////////////////////////////////////////////////
>
> gkmid init 0
> gkmid, kchan, kdata1, kdata2    midiin
>
> endin
>
> ;///////////////////////////////////////////////////
>        instr   2
> ;///////////////////////////////////////////////////
>
>        glBindTexture   gtTex
>        glTranslate     .3,.45,-3
>        glColor 1.5, 1.5, 1.5, 1.2
>        GLtexSquare     1, 0,0, 1,0, 1,1, 0,1
>
> GLinsert        1.1
>
> printk2 gkmid
>
>        schedwhen gkmid, 3, 0, 3600
>
>        endin
>
> ;//////////////////////////////////////////////
>        instr   3
> ;//////////////////////////////////////////////
>
>        glMatrixMode    $GL_MODELVIEW
>        glLoadIdentity
>
> tframe GLphasor 389, 0/389
> gtTex   GLvideo2tex     giVidHand, tframe * 389
> GLinsert        1.05
>
>        endin
>
> </CsInstruments>
> <CsScore>
> f1 3600 513 10 1
>
> i1 0 3600
> i2 2 3600
>
> </CsScore>
> </CsoundSynthesizer>
>
> --
> "Some people got attitude,
> Backed up with attitude."
> -G. Love
>


--
"Some people got attitude,
Backed up with attitude."
-G. Love
--
Send bugs reports to [hidden email]
              (or to http://www.cs.bath.ac.uk/cgi-bin/csound )
To unsubscribe, send email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Working MIDI trigger

Gabriel Maldonado-2
In reply to this post by Chuckk Hubbard
Here is the modified version, notice that in this case also the note-off
message triggers the video (whose duration is 1 second per each
trigger). Notice also that I substituted the schedwhen with the schedk
opocode (much more reliable in CsoundAV).

I also renumbered instr 1 and 2 with 100 and 200 in order to avoid
conflicts with the bogus instr 1.



Gabriel

Chuckk Hubbard wrote:

> Gabriel, and anyone else interested- this version works.  I tried to
> clean it up as much as I could; I don't understand gluPerspective or
> glTranslate exactly, but I found these numbers work.
> I merely need to change GLfps according to the file I work with (or
> the music I compose won't line up!), and change the phasor rate and
> phase according to total frames and which frame I want to start at.
>
> If I really get into scoring, I might fix up a FLTK setup to create
> markers responding to specific MIDI messages, so playback could be set
> to start at different spots.  I tried setting up a p-field system for
> frames and starting frame, but it's just as simple to change them in
> the csd.
> Next I have to see if I can trigger this from Blue with midiYoke.
> Maybe I can set up my keyboard with MIDI thru, but I'll have to watch
> out for feedback.
>
> -Chuckk
>
> <CsoundSynthesizer>
> <CsOptions>
>
> -+Y -+K
>
> </CsOptions>
> <CsInstruments>
>
> sr = 48000
> kr = 48000
> ksmps = 1
> nchnls = 2
>
> set_t_del 7
> GLfps 23, .5
> GLpanel "OpenGL panel", 528, 432
> GLpanel_end
>
> FLrun
>
> #include "OpenGL.h"
>
>
> giVidHand GLopenVideoFile "madgab.avi", .3
>
>
> GLinsert_i $GL_INIT
>
> glMatrixMode $GL_PROJECTION
> glLoadIdentity
> gluPerspective 25,1,100
> glMatrixMode $GL_MODELVIEW
> glLoadIdentity
>
>
> glColor3 0,0,0
>
> GLinsert_i $GL_NOT_VALID
> glClear $GL_COLOR_BUFFER_BIT +
>
> $GL_DEPTH_BUFFER_BIT
>
> GLinsert_i 1
> gtTex init 0
>
>
> ;///////////////////////////////////////////////////
> instr 1
> ;///////////////////////////////////////////////////
>
> gkmid init 0
> gkmid, kchan, kdata1, kdata2 midiin
>
>
> endin
>
>
> ;///////////////////////////////////////////////////
> instr 2
> ;///////////////////////////////////////////////////
>
>
> glBindTexture gtTex
> glTranslate .3,.45,-3
> glColor 1.5, 1.5, 1.5, 1.2
> GLtexSquare 1, 0,0, 1,0, 1,1, 0,1
>
>
>
> GLinsert 1.1
>
>
> printk2 gkmid
>
> schedwhen gkmid, 3, 0, 3600
>
>
> endin
>
>
> ;//////////////////////////////////////////////
> instr 3
> ;//////////////////////////////////////////////
>
> glMatrixMode $GL_MODELVIEW
> glLoadIdentity
>
> tframe GLphasor 389, 0/389
> gtTex GLvideo2tex giVidHand, tframe * 389
> GLinsert 1.05
>
>
> endin
>
>
> </CsInstruments>
> <CsScore>
> f1 3600 513 10 1
>
> i1 0 3600
> i2 2 3600
>
>
> </CsScore>
> </CsoundSynthesizer>
>
>
--
Gabriel Maldonado
http://csounds.com/maldonado
--

<CsoundSynthesizer>
<CsOptions>

-+Y -+K

</CsOptions>
<CsInstruments>

        sr = 48000
        kr = 48
        ksmps = 1000
        nchnls = 2

        set_t_del 7
        GLfps 23, .5
        GLpanel "OpenGL panel", 528, 432
        GLpanel_end
       
        FLrun

#include "OpenGL.h"


giVidHand GLopenVideoFile "madgab.avi", .3


GLinsert_i $GL_INIT

        glMatrixMode $GL_PROJECTION
        glLoadIdentity
        gluPerspective 25,1,100
        glMatrixMode $GL_MODELVIEW
        glLoadIdentity
       

        glColor3 0,0,0
       
GLinsert_i $GL_NOT_VALID
        glClear $GL_COLOR_BUFFER_BIT + $GL_DEPTH_BUFFER_BIT

GLinsert_i 1
gtTex init 0


instr 1
endin

;///////////////////////////////////////////////////
        instr 100
;///////////////////////////////////////////////////

gkmid init 0
gkmid, kchan, kdata1, kdata2 midiin

endin


;///////////////////////////////////////////////////
        instr 200
;///////////////////////////////////////////////////
       

        glBindTexture gtTex
        glTranslate .3,.45,-3
        glColor 1.5, 1.5, 1.5, 1.2
        GLtexSquare 1, 0,0, 1,0, 1,1, 0,1



GLinsert 1.1

printk2 gkmid
        schedk gkmid, 0, 3, 0, 1

        endin

;//////////////////////////////////////////////
        instr 3
;//////////////////////////////////////////////
        glMatrixMode $GL_MODELVIEW
        glMatrixMode $GL_MODELVIEW
        glLoadIdentity

tframe GLphasor 389, 0/389
gtTex GLvideo2tex giVidHand, tframe * 389
GLinsert 1.05

        endin


</CsInstruments>
<CsScore>
f0 3600

i100 0 3600
i200 0 3600


</CsScore>
</CsoundSynthesizer>
Reply | Threaded
Open this post in threaded view
|

Re: [Csnd] Working MIDI trigger

Chuckk Hubbard
Thank you, Gabriel.  It never occured to me to use a bogus instrument, it works!
Since I discovered... heh... that Blue doesn't send MIDI out, I'm
going to use CsoundAV as Blue's executable, and pass the whole csd at
once, audio, video, and synthesis.  I don't know how well the timing
will work, since I can't call 2 instances that way.

I still don't quite fathom fluPerspective and GLtranslate.  I can
quote what they're supposed to do, but the units don't seem to make
any sense.  I can't find a 3-d illustration showing what each pertains
to, either.  Just seeing a map of it would make it clear.
Thanks for straightening this MIDI stuff out!

-Chuckk

On 5/12/05, Gabriel Maldonado <[hidden email]> wrote:

> Here is the modified version, notice that in this case also the note-off
> message triggers the video (whose duration is 1 second per each
> trigger). Notice also that I substituted the schedwhen with the schedk
> opocode (much more reliable in CsoundAV).
>
> I also renumbered instr 1 and 2 with 100 and 200 in order to avoid
> conflicts with the bogus instr 1.
>
>
>
> Gabriel
>
> Chuckk Hubbard wrote:
>
> > Gabriel, and anyone else interested- this version works.  I tried to
> > clean it up as much as I could; I don't understand gluPerspective or
> > glTranslate exactly, but I found these numbers work.
> > I merely need to change GLfps according to the file I work with (or
> > the music I compose won't line up!), and change the phasor rate and
> > phase according to total frames and which frame I want to start at.
> >
> > If I really get into scoring, I might fix up a FLTK setup to create
> > markers responding to specific MIDI messages, so playback could be set
> > to start at different spots.  I tried setting up a p-field system for
> > frames and starting frame, but it's just as simple to change them in
> > the csd.
> > Next I have to see if I can trigger this from Blue with midiYoke.
> > Maybe I can set up my keyboard with MIDI thru, but I'll have to watch
> > out for feedback.
> >
> > -Chuckk
> >
> > <CsoundSynthesizer>
> > <CsOptions>
> >
> > -+Y -+K
> >
> > </CsOptions>
> > <CsInstruments>
> >
> >       sr = 48000
> >       kr = 48000
> >       ksmps = 1
> >       nchnls = 2
> >
> >       set_t_del       7
> >       GLfps   23, .5
> >       GLpanel "OpenGL panel", 528, 432
> >       GLpanel_end
> >
> >       FLrun
> >
> > #include "OpenGL.h"
> >
> >
> > giVidHand     GLopenVideoFile "madgab.avi", .3
> >
> >
> > GLinsert_i $GL_INIT
> >
> >       glMatrixMode    $GL_PROJECTION
> >       glLoadIdentity
> >       gluPerspective  25,1,100
> >       glMatrixMode    $GL_MODELVIEW
> >       glLoadIdentity
> >
> >
> >       glColor3        0,0,0
> >
> > GLinsert_i $GL_NOT_VALID
> >       glClear $GL_COLOR_BUFFER_BIT +
> >
> > $GL_DEPTH_BUFFER_BIT
> >
> > GLinsert_i 1
> > gtTex init    0
> >
> >
> > ;///////////////////////////////////////////////////
> >       instr 1
> > ;///////////////////////////////////////////////////
> >
> > gkmid init 0
> > gkmid, kchan, kdata1, kdata2  midiin
> >
> >
> > endin
> >
> >
> > ;///////////////////////////////////////////////////
> >       instr   2
> > ;///////////////////////////////////////////////////
> >
> >
> >       glBindTexture   gtTex
> >       glTranslate     .3,.45,-3
> >       glColor 1.5, 1.5, 1.5, 1.2
> >       GLtexSquare     1, 0,0, 1,0, 1,1, 0,1
> >
> >
> >
> > GLinsert      1.1
> >
> >
> > printk2 gkmid
> >
> >       schedwhen gkmid, 3, 0, 3600
> >
> >
> >       endin
> >
> >
> > ;//////////////////////////////////////////////
> >       instr   3
> > ;//////////////////////////////////////////////
> >
> >       glMatrixMode    $GL_MODELVIEW
> >       glLoadIdentity
> >
> > tframe GLphasor 389, 0/389
> > gtTex GLvideo2tex     giVidHand, tframe * 389
> > GLinsert      1.05
> >
> >
> >       endin
> >
> >
> > </CsInstruments>
> > <CsScore>
> > f1 3600 513 10 1
> >
> > i1 0 3600
> > i2 2 3600
> >
> >
> > </CsScore>
> > </CsoundSynthesizer>
> >
> >
>
> --
> Gabriel Maldonado
> http://csounds.com/maldonado
> --
>
>
> <CsoundSynthesizer>
> <CsOptions>
>
> -+Y -+K
>
> </CsOptions>
> <CsInstruments>
>
>        sr = 48000
>        kr = 48
>        ksmps = 1000
>        nchnls = 2
>
>        set_t_del       7
>        GLfps   23, .5
>        GLpanel "OpenGL panel", 528, 432
>        GLpanel_end
>
>        FLrun
>
> #include "OpenGL.h"
>
>
> giVidHand       GLopenVideoFile "madgab.avi", .3
>
>
> GLinsert_i $GL_INIT
>
>        glMatrixMode    $GL_PROJECTION
>        glLoadIdentity
>        gluPerspective  25,1,100
>        glMatrixMode    $GL_MODELVIEW
>        glLoadIdentity
>
>
>        glColor3        0,0,0
>
> GLinsert_i $GL_NOT_VALID
>        glClear $GL_COLOR_BUFFER_BIT + $GL_DEPTH_BUFFER_BIT
>
> GLinsert_i 1
> gtTex   init    0
>
>
> instr 1
> endin
>
> ;///////////////////////////////////////////////////
>        instr 100
> ;///////////////////////////////////////////////////
>
> gkmid init 0
> gkmid, kchan, kdata1, kdata2    midiin
>
> endin
>
>
> ;///////////////////////////////////////////////////
>        instr   200
> ;///////////////////////////////////////////////////
>
>
>        glBindTexture   gtTex
>        glTranslate     .3,.45,-3
>        glColor 1.5, 1.5, 1.5, 1.2
>        GLtexSquare     1, 0,0, 1,0, 1,1, 0,1
>
>
>
> GLinsert        1.1
>
> printk2 gkmid
>        schedk gkmid, 0, 3, 0, 1
>
>        endin
>
> ;//////////////////////////////////////////////
>        instr   3
> ;//////////////////////////////////////////////
>        glMatrixMode    $GL_MODELVIEW
>        glMatrixMode    $GL_MODELVIEW
>        glLoadIdentity
>
> tframe GLphasor 389, 0/389
> gtTex   GLvideo2tex     giVidHand, tframe * 389
> GLinsert        1.05
>
>        endin
>
>
> </CsInstruments>
> <CsScore>
> f0 3600
>
> i100 0 3600
> i200 0 3600
>
>
> </CsScore>
> </CsoundSynthesizer>
>
>


--
"Some people got attitude,
Backed up with attitude."
-G. Love
--
Send bugs reports to [hidden email]
              (or to http://www.cs.bath.ac.uk/cgi-bin/csound )
To unsubscribe, send email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Working MIDI trigger

Gabriel Maldonado-2
The OpenGL part of CsoundAV is not a novice tool. It is a quite advanced
topic since it requires one to know the basics of 3-D theory and of
OpenGL programming. I suggest you to read the OpenGL red-book in order
to learn OpenGL basics. Here is an online version:

http://fly.cc.fer.hr/~unreal/theredbook/

And, to refer to the OpenGL blue-book as a reference on the various API
functions (that are wrapped in CsoundAV):

http://rush3d.com/reference/opengl-bluebook-1.0/

(you can also buy updated printed versions of these books at amazon or
barnes & noble)

Good luck!

Gabriel

Chuckk Hubbard wrote:

> Thank you, Gabriel.  It never occured to me to use a bogus instrument, it works!
> Since I discovered... heh... that Blue doesn't send MIDI out, I'm
> going to use CsoundAV as Blue's executable, and pass the whole csd at
> once, audio, video, and synthesis.  I don't know how well the timing
> will work, since I can't call 2 instances that way.
>
> I still don't quite fathom fluPerspective and GLtranslate.  I can
> quote what they're supposed to do, but the units don't seem to make
> any sense.  I can't find a 3-d illustration showing what each pertains
> to, either.  Just seeing a map of it would make it clear.
> Thanks for straightening this MIDI stuff out!
>
> -Chuckk
>
> On 5/12/05, Gabriel Maldonado <[hidden email]> wrote:
>
>>Here is the modified version, notice that in this case also the note-off
>>message triggers the video (whose duration is 1 second per each
>>trigger). Notice also that I substituted the schedwhen with the schedk
>>opocode (much more reliable in CsoundAV).
>>
>>I also renumbered instr 1 and 2 with 100 and 200 in order to avoid
>>conflicts with the bogus instr 1.
>>
>>
>>
>>Gabriel
>>
>>Chuckk Hubbard wrote:
>>
>>
>>>Gabriel, and anyone else interested- this version works.  I tried to
>>>clean it up as much as I could; I don't understand gluPerspective or
>>>glTranslate exactly, but I found these numbers work.
>>>I merely need to change GLfps according to the file I work with (or
>>>the music I compose won't line up!), and change the phasor rate and
>>>phase according to total frames and which frame I want to start at.
>>>
>>>If I really get into scoring, I might fix up a FLTK setup to create
>>>markers responding to specific MIDI messages, so playback could be set
>>>to start at different spots.  I tried setting up a p-field system for
>>>frames and starting frame, but it's just as simple to change them in
>>>the csd.
>>>Next I have to see if I can trigger this from Blue with midiYoke.
>>>Maybe I can set up my keyboard with MIDI thru, but I'll have to watch
>>>out for feedback.
>>>
>>>-Chuckk
>>>
>>><CsoundSynthesizer>
>>><CsOptions>
>>>
>>>-+Y -+K
>>>
>>></CsOptions>
>>><CsInstruments>
>>>
>>>      sr = 48000
>>>      kr = 48000
>>>      ksmps = 1
>>>      nchnls = 2
>>>
>>>      set_t_del       7
>>>      GLfps   23, .5
>>>      GLpanel "OpenGL panel", 528, 432
>>>      GLpanel_end
>>>
>>>      FLrun
>>>
>>>#include "OpenGL.h"
>>>
>>>
>>>giVidHand     GLopenVideoFile "madgab.avi", .3
>>>
>>>
>>>GLinsert_i $GL_INIT
>>>
>>>      glMatrixMode    $GL_PROJECTION
>>>      glLoadIdentity
>>>      gluPerspective  25,1,100
>>>      glMatrixMode    $GL_MODELVIEW
>>>      glLoadIdentity
>>>
>>>
>>>      glColor3        0,0,0
>>>
>>>GLinsert_i $GL_NOT_VALID
>>>      glClear $GL_COLOR_BUFFER_BIT +
>>>
>>>$GL_DEPTH_BUFFER_BIT
>>>
>>>GLinsert_i 1
>>>gtTex init    0
>>>
>>>
>>>;///////////////////////////////////////////////////
>>>      instr 1
>>>;///////////////////////////////////////////////////
>>>
>>>gkmid init 0
>>>gkmid, kchan, kdata1, kdata2  midiin
>>>
>>>
>>>endin
>>>
>>>
>>>;///////////////////////////////////////////////////
>>>      instr   2
>>>;///////////////////////////////////////////////////
>>>
>>>
>>>      glBindTexture   gtTex
>>>      glTranslate     .3,.45,-3
>>>      glColor 1.5, 1.5, 1.5, 1.2
>>>      GLtexSquare     1, 0,0, 1,0, 1,1, 0,1
>>>
>>>
>>>
>>>GLinsert      1.1
>>>
>>>
>>>printk2 gkmid
>>>
>>>      schedwhen gkmid, 3, 0, 3600
>>>
>>>
>>>      endin
>>>
>>>
>>>;//////////////////////////////////////////////
>>>      instr   3
>>>;//////////////////////////////////////////////
>>>
>>>      glMatrixMode    $GL_MODELVIEW
>>>      glLoadIdentity
>>>
>>>tframe GLphasor 389, 0/389
>>>gtTex GLvideo2tex     giVidHand, tframe * 389
>>>GLinsert      1.05
>>>
>>>
>>>      endin
>>>
>>>
>>></CsInstruments>
>>><CsScore>
>>>f1 3600 513 10 1
>>>
>>>i1 0 3600
>>>i2 2 3600
>>>
>>>
>>></CsScore>
>>></CsoundSynthesizer>
>>>
>>>
>>--
>>Gabriel Maldonado
>>http://csounds.com/maldonado
>>--
>>
>>
>><CsoundSynthesizer>
>><CsOptions>
>>
>>-+Y -+K
>>
>></CsOptions>
>><CsInstruments>
>>
>>       sr = 48000
>>       kr = 48
>>       ksmps = 1000
>>       nchnls = 2
>>
>>       set_t_del       7
>>       GLfps   23, .5
>>       GLpanel "OpenGL panel", 528, 432
>>       GLpanel_end
>>
>>       FLrun
>>
>>#include "OpenGL.h"
>>
>>
>>giVidHand       GLopenVideoFile "madgab.avi", .3
>>
>>
>>GLinsert_i $GL_INIT
>>
>>       glMatrixMode    $GL_PROJECTION
>>       glLoadIdentity
>>       gluPerspective  25,1,100
>>       glMatrixMode    $GL_MODELVIEW
>>       glLoadIdentity
>>
>>
>>       glColor3        0,0,0
>>
>>GLinsert_i $GL_NOT_VALID
>>       glClear $GL_COLOR_BUFFER_BIT + $GL_DEPTH_BUFFER_BIT
>>
>>GLinsert_i 1
>>gtTex   init    0
>>
>>
>>instr 1
>>endin
>>
>>;///////////////////////////////////////////////////
>>       instr 100
>>;///////////////////////////////////////////////////
>>
>>gkmid init 0
>>gkmid, kchan, kdata1, kdata2    midiin
>>
>>endin
>>
>>
>>;///////////////////////////////////////////////////
>>       instr   200
>>;///////////////////////////////////////////////////
>>
>>
>>       glBindTexture   gtTex
>>       glTranslate     .3,.45,-3
>>       glColor 1.5, 1.5, 1.5, 1.2
>>       GLtexSquare     1, 0,0, 1,0, 1,1, 0,1
>>
>>
>>
>>GLinsert        1.1
>>
>>printk2 gkmid
>>       schedk gkmid, 0, 3, 0, 1
>>
>>       endin
>>
>>;//////////////////////////////////////////////
>>       instr   3
>>;//////////////////////////////////////////////
>>       glMatrixMode    $GL_MODELVIEW
>>       glMatrixMode    $GL_MODELVIEW
>>       glLoadIdentity
>>
>>tframe GLphasor 389, 0/389
>>gtTex   GLvideo2tex     giVidHand, tframe * 389
>>GLinsert        1.05
>>
>>       endin
>>
>>
>></CsInstruments>
>><CsScore>
>>f0 3600
>>
>>i100 0 3600
>>i200 0 3600
>>
>>
>></CsScore>
>></CsoundSynthesizer>
>>
>>
>
>

--
Gabriel Maldonado
http://csounds.com/maldonado
--
--
Send bugs reports to [hidden email]
              (or to http://www.cs.bath.ac.uk/cgi-bin/csound )
To unsubscribe, send email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Working MIDI trigger

Chuckk Hubbard
Yes, this is pretty dense stuff.  None of the tutorials I've looked at
explain what a texture is.  They say gltranslatef multiplies the
coordinates, but it seems to me like it is adding them.  If model and
viewer both start at 0,0,0, then multiplication would never have any
effect.

I've been using your GLtexsquare.  It seems like the coordinates I
type are resizing the texture in relation to the image, but that the
image is what is changing from my view.  I can't find any reference
saying where these coordinates originate, and I can't tell by looking.

Correct me if I'm wrong, but it seems like OpenGL is not very suited
to standard video playback; at least, noone has responded in any
groups.  The model coordinates, the distance to the object, and the
field of view would all depend on the size of the video.  It seems to
place the image by the lower left corner, rather than the center.  I
will have to go through the process for each video I try to score.

I can do that, but it seems funny that a language so deep is unsuited
to such a low-level task.

Thanks for the references, I'm looking through them.

-Chuckk

On 5/15/05, Gabriel Maldonado <[hidden email]> wrote:

> The OpenGL part of CsoundAV is not a novice tool. It is a quite advanced
> topic since it requires one to know the basics of 3-D theory and of
> OpenGL programming. I suggest you to read the OpenGL red-book in order
> to learn OpenGL basics. Here is an online version:
>
> http://fly.cc.fer.hr/~unreal/theredbook/
>
> And, to refer to the OpenGL blue-book as a reference on the various API
> functions (that are wrapped in CsoundAV):
>
> http://rush3d.com/reference/opengl-bluebook-1.0/
>
> (you can also buy updated printed versions of these books at amazon or
> barnes & noble)
>
> Good luck!
>
> Gabriel
>
> Chuckk Hubbard wrote:
> > Thank you, Gabriel.  It never occured to me to use a bogus instrument, it works!
> > Since I discovered... heh... that Blue doesn't send MIDI out, I'm
> > going to use CsoundAV as Blue's executable, and pass the whole csd at
> > once, audio, video, and synthesis.  I don't know how well the timing
> > will work, since I can't call 2 instances that way.
> >
> > I still don't quite fathom fluPerspective and GLtranslate.  I can
> > quote what they're supposed to do, but the units don't seem to make
> > any sense.  I can't find a 3-d illustration showing what each pertains
> > to, either.  Just seeing a map of it would make it clear.
> > Thanks for straightening this MIDI stuff out!
> >
> > -Chuckk
> >
> > On 5/12/05, Gabriel Maldonado <[hidden email]> wrote:
> >
> >>Here is the modified version, notice that in this case also the note-off
> >>message triggers the video (whose duration is 1 second per each
> >>trigger). Notice also that I substituted the schedwhen with the schedk
> >>opocode (much more reliable in CsoundAV).
> >>
> >>I also renumbered instr 1 and 2 with 100 and 200 in order to avoid
> >>conflicts with the bogus instr 1.
> >>
> >>
> >>
> >>Gabriel
> >>
> >>Chuckk Hubbard wrote:
> >>
> >>
> >>>Gabriel, and anyone else interested- this version works.  I tried to
> >>>clean it up as much as I could; I don't understand gluPerspective or
> >>>glTranslate exactly, but I found these numbers work.
> >>>I merely need to change GLfps according to the file I work with (or
> >>>the music I compose won't line up!), and change the phasor rate and
> >>>phase according to total frames and which frame I want to start at.
> >>>
> >>>If I really get into scoring, I might fix up a FLTK setup to create
> >>>markers responding to specific MIDI messages, so playback could be set
> >>>to start at different spots.  I tried setting up a p-field system for
> >>>frames and starting frame, but it's just as simple to change them in
> >>>the csd.
> >>>Next I have to see if I can trigger this from Blue with midiYoke.
> >>>Maybe I can set up my keyboard with MIDI thru, but I'll have to watch
> >>>out for feedback.
> >>>
> >>>-Chuckk
> >>>
> >>><CsoundSynthesizer>
> >>><CsOptions>
> >>>
> >>>-+Y -+K
> >>>
> >>></CsOptions>
> >>><CsInstruments>
> >>>
> >>>      sr = 48000
> >>>      kr = 48000
> >>>      ksmps = 1
> >>>      nchnls = 2
> >>>
> >>>      set_t_del       7
> >>>      GLfps   23, .5
> >>>      GLpanel "OpenGL panel", 528, 432
> >>>      GLpanel_end
> >>>
> >>>      FLrun
> >>>
> >>>#include "OpenGL.h"
> >>>
> >>>
> >>>giVidHand     GLopenVideoFile "madgab.avi", .3
> >>>
> >>>
> >>>GLinsert_i $GL_INIT
> >>>
> >>>      glMatrixMode    $GL_PROJECTION
> >>>      glLoadIdentity
> >>>      gluPerspective  25,1,100
> >>>      glMatrixMode    $GL_MODELVIEW
> >>>      glLoadIdentity
> >>>
> >>>
> >>>      glColor3        0,0,0
> >>>
> >>>GLinsert_i $GL_NOT_VALID
> >>>      glClear $GL_COLOR_BUFFER_BIT +
> >>>
> >>>$GL_DEPTH_BUFFER_BIT
> >>>
> >>>GLinsert_i 1
> >>>gtTex init    0
> >>>
> >>>
> >>>;///////////////////////////////////////////////////
> >>>      instr 1
> >>>;///////////////////////////////////////////////////
> >>>
> >>>gkmid init 0
> >>>gkmid, kchan, kdata1, kdata2  midiin
> >>>
> >>>
> >>>endin
> >>>
> >>>
> >>>;///////////////////////////////////////////////////
> >>>      instr   2
> >>>;///////////////////////////////////////////////////
> >>>
> >>>
> >>>      glBindTexture   gtTex
> >>>      glTranslate     .3,.45,-3
> >>>      glColor 1.5, 1.5, 1.5, 1.2
> >>>      GLtexSquare     1, 0,0, 1,0, 1,1, 0,1
> >>>
> >>>
> >>>
> >>>GLinsert      1.1
> >>>
> >>>
> >>>printk2 gkmid
> >>>
> >>>      schedwhen gkmid, 3, 0, 3600
> >>>
> >>>
> >>>      endin
> >>>
> >>>
> >>>;//////////////////////////////////////////////
> >>>      instr   3
> >>>;//////////////////////////////////////////////
> >>>
> >>>      glMatrixMode    $GL_MODELVIEW
> >>>      glLoadIdentity
> >>>
> >>>tframe GLphasor 389, 0/389
> >>>gtTex GLvideo2tex     giVidHand, tframe * 389
> >>>GLinsert      1.05
> >>>
> >>>
> >>>      endin
> >>>
> >>>
> >>></CsInstruments>
> >>><CsScore>
> >>>f1 3600 513 10 1
> >>>
> >>>i1 0 3600
> >>>i2 2 3600
> >>>
> >>>
> >>></CsScore>
> >>></CsoundSynthesizer>
> >>>
> >>>
> >>--
> >>Gabriel Maldonado
> >>http://csounds.com/maldonado
> >>--
> >>
> >>
> >><CsoundSynthesizer>
> >><CsOptions>
> >>
> >>-+Y -+K
> >>
> >></CsOptions>
> >><CsInstruments>
> >>
> >>       sr = 48000
> >>       kr = 48
> >>       ksmps = 1000
> >>       nchnls = 2
> >>
> >>       set_t_del       7
> >>       GLfps   23, .5
> >>       GLpanel "OpenGL panel", 528, 432
> >>       GLpanel_end
> >>
> >>       FLrun
> >>
> >>#include "OpenGL.h"
> >>
> >>
> >>giVidHand       GLopenVideoFile "madgab.avi", .3
> >>
> >>
> >>GLinsert_i $GL_INIT
> >>
> >>       glMatrixMode    $GL_PROJECTION
> >>       glLoadIdentity
> >>       gluPerspective  25,1,100
> >>       glMatrixMode    $GL_MODELVIEW
> >>       glLoadIdentity
> >>
> >>
> >>       glColor3        0,0,0
> >>
> >>GLinsert_i $GL_NOT_VALID
> >>       glClear $GL_COLOR_BUFFER_BIT + $GL_DEPTH_BUFFER_BIT
> >>
> >>GLinsert_i 1
> >>gtTex   init    0
> >>
> >>
> >>instr 1
> >>endin
> >>
> >>;///////////////////////////////////////////////////
> >>       instr 100
> >>;///////////////////////////////////////////////////
> >>
> >>gkmid init 0
> >>gkmid, kchan, kdata1, kdata2    midiin
> >>
> >>endin
> >>
> >>
> >>;///////////////////////////////////////////////////
> >>       instr   200
> >>;///////////////////////////////////////////////////
> >>
> >>
> >>       glBindTexture   gtTex
> >>       glTranslate     .3,.45,-3
> >>       glColor 1.5, 1.5, 1.5, 1.2
> >>       GLtexSquare     1, 0,0, 1,0, 1,1, 0,1
> >>
> >>
> >>
> >>GLinsert        1.1
> >>
> >>printk2 gkmid
> >>       schedk gkmid, 0, 3, 0, 1
> >>
> >>       endin
> >>
> >>;//////////////////////////////////////////////
> >>       instr   3
> >>;//////////////////////////////////////////////
> >>       glMatrixMode    $GL_MODELVIEW
> >>       glMatrixMode    $GL_MODELVIEW
> >>       glLoadIdentity
> >>
> >>tframe GLphasor 389, 0/389
> >>gtTex   GLvideo2tex     giVidHand, tframe * 389
> >>GLinsert        1.05
> >>
> >>       endin
> >>
> >>
> >></CsInstruments>
> >><CsScore>
> >>f0 3600
> >>
> >>i100 0 3600
> >>i200 0 3600
> >>
> >>
> >></CsScore>
> >></CsoundSynthesizer>
> >>
> >>
> >
> >
>
> --
> Gabriel Maldonado
> http://csounds.com/maldonado
> --
> --
> Send bugs reports to [hidden email]
>              (or to http://www.cs.bath.ac.uk/cgi-bin/csound )
> To unsubscribe, send email to [hidden email]
>


--
"Some people got attitude,
Backed up with attitude."
-G. Love
--
Send bugs reports to [hidden email]
              (or to http://www.cs.bath.ac.uk/cgi-bin/csound )
To unsubscribe, send email to [hidden email]
Reply | Threaded
Open this post in threaded view
|

Re: Working MIDI trigger

Michael Gogins
In reply to this post by Chuckk Hubbard
It is matrix multiplication. If the matrixes are homogeneous --

Homogeneous matrix? Say, we have 3 dimensions. But, the matrix is 4 x 4 instead of 3 x 3. The last row is all 0s except for the last element which is 1.  This means, the top 3 x 3 elements do multiplication and the last column (3 x 1) does addition. The 1 at the bottom just keeps the space homogeneous -- keeps all the dimensions the same size.

I.e.: a point at 0,0,0 is (the final 1 is for homogeneity, again, and has nothing to do with position):

0 0 0 1

times:

1 0 0 0
0 1 0 2
0 0 1 0
0 0 0 1

equals:

0 2 0 1

i.e. adds 2 to the y dimension.

The 1s all down the diagonal of the matrix mean, keep everything the same size on each dimension.

If the matrixes are homogeneous, then one "matrix multiplication" can do any combination of rescaling (multiplying), rotating (another way of multiplying, but across dimensions instead of within dimensions) and translating (adding to a dimension) in one operation.

OpenGL uses 4 x 4 matrices, so presumably it uses homogeneous matrices as I have described.

Regards,
Mike

-----Original Message-----
From: Chuckk Hubbard <[hidden email]>
Sent: May 15, 2005 4:32 PM
To: [hidden email]
Subject: Re: [Csnd] Working MIDI trigger

Yes, this is pretty dense stuff.  None of the tutorials I've looked at
explain what a texture is.  They say gltranslatef multiplies the
coordinates, but it seems to me like it is adding them.  If model and
viewer both start at 0,0,0, then multiplication would never have any
effect.

I've been using your GLtexsquare.  It seems like the coordinates I
type are resizing the texture in relation to the image, but that the
image is what is changing from my view.  I can't find any reference
saying where these coordinates originate, and I can't tell by looking.

Correct me if I'm wrong, but it seems like OpenGL is not very suited
to standard video playback; at least, noone has responded in any
groups.  The model coordinates, the distance to the object, and the
field of view would all depend on the size of the video.  It seems to
place the image by the lower left corner, rather than the center.  I
will have to go through the process for each video I try to score.

I can do that, but it seems funny that a language so deep is unsuited
to such a low-level task.

Thanks for the references, I'm looking through them.

-Chuckk

On 5/15/05, Gabriel Maldonado <[hidden email]> wrote:

> The OpenGL part of CsoundAV is not a novice tool. It is a quite advanced
> topic since it requires one to know the basics of 3-D theory and of
> OpenGL programming. I suggest you to read the OpenGL red-book in order
> to learn OpenGL basics. Here is an online version:
>
> http://fly.cc.fer.hr/~unreal/theredbook/
>
> And, to refer to the OpenGL blue-book as a reference on the various API
> functions (that are wrapped in CsoundAV):
>
> http://rush3d.com/reference/opengl-bluebook-1.0/
>
> (you can also buy updated printed versions of these books at amazon or
> barnes & noble)
>
> Good luck!
>
> Gabriel
>
> Chuckk Hubbard wrote:
> > Thank you, Gabriel.  It never occured to me to use a bogus instrument, it works!
> > Since I discovered... heh... that Blue doesn't send MIDI out, I'm
> > going to use CsoundAV as Blue's executable, and pass the whole csd at
> > once, audio, video, and synthesis.  I don't know how well the timing
> > will work, since I can't call 2 instances that way.
> >
> > I still don't quite fathom fluPerspective and GLtranslate.  I can
> > quote what they're supposed to do, but the units don't seem to make
> > any sense.  I can't find a 3-d illustration showing what each pertains
> > to, either.  Just seeing a map of it would make it clear.
> > Thanks for straightening this MIDI stuff out!
> >
> > -Chuckk
> >
> > On 5/12/05, Gabriel Maldonado <[hidden email]> wrote:
> >
> >>Here is the modified version, notice that in this case also the note-off
> >>message triggers the video (whose duration is 1 second per each
> >>trigger). Notice also that I substituted the schedwhen with the schedk
> >>opocode (much more reliable in CsoundAV).
> >>
> >>I also renumbered instr 1 and 2 with 100 and 200 in order to avoid
> >>conflicts with the bogus instr 1.
> >>
> >>
> >>
> >>Gabriel
> >>
> >>Chuckk Hubbard wrote:
> >>
> >>
> >>>Gabriel, and anyone else interested- this version works.  I tried to
> >>>clean it up as much as I could; I don't understand gluPerspective or
> >>>glTranslate exactly, but I found these numbers work.
> >>>I merely need to change GLfps according to the file I work with (or
> >>>the music I compose won't line up!), and change the phasor rate and
> >>>phase according to total frames and which frame I want to start at.
> >>>
> >>>If I really get into scoring, I might fix up a FLTK setup to create
> >>>markers responding to specific MIDI messages, so playback could be set
> >>>to start at different spots.  I tried setting up a p-field system for
> >>>frames and starting frame, but it's just as simple to change them in
> >>>the csd.
> >>>Next I have to see if I can trigger this from Blue with midiYoke.
> >>>Maybe I can set up my keyboard with MIDI thru, but I'll have to watch
> >>>out for feedback.
> >>>
> >>>-Chuckk
> >>>
> >>><CsoundSynthesizer>
> >>><CsOptions>
> >>>
> >>>-+Y -+K
> >>>
> >>></CsOptions>
> >>><CsInstruments>
> >>>
> >>>      sr = 48000
> >>>      kr = 48000
> >>>      ksmps = 1
> >>>      nchnls = 2
> >>>
> >>>      set_t_del       7
> >>>      GLfps   23, .5
> >>>      GLpanel "OpenGL panel", 528, 432
> >>>      GLpanel_end
> >>>
> >>>      FLrun
> >>>
> >>>#include "OpenGL.h"
> >>>
> >>>
> >>>giVidHand     GLopenVideoFile "madgab.avi", .3
> >>>
> >>>
> >>>GLinsert_i $GL_INIT
> >>>
> >>>      glMatrixMode    $GL_PROJECTION
> >>>      glLoadIdentity
> >>>      gluPerspective  25,1,100
> >>>      glMatrixMode    $GL_MODELVIEW
> >>>      glLoadIdentity
> >>>
> >>>
> >>>      glColor3        0,0,0
> >>>
> >>>GLinsert_i $GL_NOT_VALID
> >>>      glClear $GL_COLOR_BUFFER_BIT +
> >>>
> >>>$GL_DEPTH_BUFFER_BIT
> >>>
> >>>GLinsert_i 1
> >>>gtTex init    0
> >>>
> >>>
> >>>;///////////////////////////////////////////////////
> >>>      instr 1
> >>>;///////////////////////////////////////////////////
> >>>
> >>>gkmid init 0
> >>>gkmid, kchan, kdata1, kdata2  midiin
> >>>
> >>>
> >>>endin
> >>>
> >>>
> >>>;///////////////////////////////////////////////////
> >>>      instr   2
> >>>;///////////////////////////////////////////////////
> >>>
> >>>
> >>>      glBindTexture   gtTex
> >>>      glTranslate     .3,.45,-3
> >>>      glColor 1.5, 1.5, 1.5, 1.2
> >>>      GLtexSquare     1, 0,0, 1,0, 1,1, 0,1
> >>>
> >>>
> >>>
> >>>GLinsert      1.1
> >>>
> >>>
> >>>printk2 gkmid
> >>>
> >>>      schedwhen gkmid, 3, 0, 3600
> >>>
> >>>
> >>>      endin
> >>>
> >>>
> >>>;//////////////////////////////////////////////
> >>>      instr   3
> >>>;//////////////////////////////////////////////
> >>>
> >>>      glMatrixMode    $GL_MODELVIEW
> >>>      glLoadIdentity
> >>>
> >>>tframe GLphasor 389, 0/389
> >>>gtTex GLvideo2tex     giVidHand, tframe * 389
> >>>GLinsert      1.05
> >>>
> >>>
> >>>      endin
> >>>
> >>>
> >>></CsInstruments>
> >>><CsScore>
> >>>f1 3600 513 10 1
> >>>
> >>>i1 0 3600
> >>>i2 2 3600
> >>>
> >>>
> >>></CsScore>
> >>></CsoundSynthesizer>
> >>>
> >>>
> >>--
> >>Gabriel Maldonado
> >>http://csounds.com/maldonado
> >>--
> >>
> >>
> >><CsoundSynthesizer>
> >><CsOptions>
> >>
> >>-+Y -+K
> >>
> >></CsOptions>
> >><CsInstruments>
> >>
> >>       sr = 48000
> >>       kr = 48
> >>       ksmps = 1000
> >>       nchnls = 2
> >>
> >>       set_t_del       7
> >>       GLfps   23, .5
> >>       GLpanel "OpenGL panel", 528, 432
> >>       GLpanel_end
> >>
> >>       FLrun
> >>
> >>#include "OpenGL.h"
> >>
> >>
> >>giVidHand       GLopenVideoFile "madgab.avi", .3
> >>
> >>
> >>GLinsert_i $GL_INIT
> >>
> >>       glMatrixMode    $GL_PROJECTION
> >>       glLoadIdentity
> >>       gluPerspective  25,1,100
> >>       glMatrixMode    $GL_MODELVIEW
> >>       glLoadIdentity
> >>
> >>
> >>       glColor3        0,0,0
> >>
> >>GLinsert_i $GL_NOT_VALID
> >>       glClear $GL_COLOR_BUFFER_BIT + $GL_DEPTH_BUFFER_BIT
> >>
> >>GLinsert_i 1
> >>gtTex   init    0
> >>
> >>
> >>instr 1
> >>endin
> >>
> >>;///////////////////////////////////////////////////
> >>       instr 100
> >>;///////////////////////////////////////////////////
> >>
> >>gkmid init 0
> >>gkmid, kchan, kdata1, kdata2    midiin
> >>
> >>endin
> >>
> >>
> >>;///////////////////////////////////////////////////
> >>       instr   200
> >>;///////////////////////////////////////////////////
> >>
> >>
> >>       glBindTexture   gtTex
> >>       glTranslate     .3,.45,-3
> >>       glColor 1.5, 1.5, 1.5, 1.2
> >>       GLtexSquare     1, 0,0, 1,0, 1,1, 0,1
> >>
> >>
> >>
> >>GLinsert        1.1
> >>
> >>printk2 gkmid
> >>       schedk gkmid, 0, 3, 0, 1
> >>
> >>       endin
> >>
> >>;//////////////////////////////////////////////
> >>       instr   3
> >>;//////////////////////////////////////////////
> >>       glMatrixMode    $GL_MODELVIEW
> >>       glMatrixMode    $GL_MODELVIEW
> >>       glLoadIdentity
> >>
> >>tframe GLphasor 389, 0/389
> >>gtTex   GLvideo2tex     giVidHand, tframe * 389
> >>GLinsert        1.05
> >>
> >>       endin
> >>
> >>
> >></CsInstruments>
> >><CsScore>
> >>f0 3600
> >>
> >>i100 0 3600
> >>i200 0 3600
> >>
> >>
> >></CsScore>
> >></CsoundSynthesizer>
> >>
> >>
> >
> >
>
> --
> Gabriel Maldonado
> http://csounds.com/maldonado
> --
> --
> Send bugs reports to [hidden email]
>              (or to http://www.cs.bath.ac.uk/cgi-bin/csound )
> To unsubscribe, send email to [hidden email]
>


--
"Some people got attitude,
Backed up with attitude."
-G. Love
--
Send bugs reports to [hidden email]
              (or to http://www.cs.bath.ac.uk/cgi-bin/csound )
To unsubscribe, send email to [hidden email]



--
Send bugs reports to [hidden email]
              (or to http://www.cs.bath.ac.uk/cgi-bin/csound )
To unsubscribe, send email to [hidden email]