[Gambas-user] Gambas & API of ALSA

Ru Vuott vuott at ...325...
Tue May 25 09:55:06 CEST 2010


Ciao,

da quel che vedo sei italiano, e ti scrivo nella nostra comune lingua.
Ti ringrazio MOLTISSIMO del tuo suggerimento. Gli ho dato ora una lettura molto veloce, ma mi riservo di leggere con maggior attenzione oggi pomeriggio.

Avevo trovato qualche esempio, appunto, (c'è anche un sito in italiano relativo alla programmazione Midi in Linux) però gli esempi sono in linguaggio C.

Ti ringrazio per la tua disponibilità ad offrirmi aiuto, se sarà proprio necessario mi permetterò di contattarti per fugare gli eventuali dubbi.

Ancora grazie molte.
Ciao
Paolo



--- Mar 25/5/10, Doriano Blengino <doriano.blengino at ...1909...> ha scritto:

> Da: Doriano Blengino <doriano.blengino at ...1909...>
> Oggetto: Re: [Gambas-user] Gambas & API of ALSA
> A: "mailing list for gambas users" <gambas-user at lists.sourceforge.net>
> Data: Martedì 25 maggio 2010, 09:36
> Ru Vuott ha scritto:
> > Thank you very much.
> >
> > Now the problem is how I can use those information
> with Gambas !!! :-(
> >   
> I would interested too in writing a midi librarian for my
> keyboard, but 
> leaved this idea behind because I am too busy these days. I
> wrote a 
> working one under windows, but now I would need a linux
> version. So, if 
> you succeed in doing something, let me know.
> 
> If I well understand, you want to send data to a midi
> device. It seems 
> that you can do it in two ways - using the filesystem, or
> using the alsa 
> library.
> 
> In the documentation from:
> 
> >> I guess you can find some answers here, thanks
> google!
> >>
> >> https://ccrma.stanford.edu/~craig/articles/linuxmidi/
> >>     
> there are several C sources, which can be translated more
> or less to 
> gambas. The simplest of them is:
> 
>     int main(void) {
>        char* device = 
> "/dev/midi" ;
>        unsigned char data[3] =
> {0x90, 60, 127};
> 
>        // step 1: open the OSS
> device for writing
>        int fd = open(device,
> O_WRONLY, 0);
>        if (fd < 0) {
>           printf("Error: cannot
> open %s\n", device);
>           exit(1);
>        }
> 
>        // step 2: write the MIDI
> information to the OSS device
>        write(fd, data,
> sizeof(data));
> 
>        // step 3: (optional) close
> the OSS device
>        close(fd);
> 
>        return 0;
>     }
> 
> This code (output/method1.c) does something very simple -
> it write three 
> bytes to the file /dev/midi. You can try from console using
> something like:
>     cat myfile >/dev/midi
> where "myfile" has a suitable content, like 0x90, 60, 127,
> which in 
> gambas translate to &h90, 60, 127.
> 
> If you only want to send out some midi data, this approach
> seems to be 
> effective and easy: just open a file for output, and write
> some bytes to 
> it (you must know what to write - this is a different
> problem). If you 
> want to make your device play, you will have to output
> several "0x90 
> 0xXX 0xXX" (note on event) followed by "0x80 0xXX 0xXX";
> accurate timing 
> will be an issue.
> 
> The device /dev/sequencer does similar things, but is more
> intelligent 
> and can do good timing.
> 
> Alternatively, you can use a library like alsa. You must
> use "External 
> function declaration" in gambas, and you will have access
> to the power 
> of alsa. This is not easy, but possible; in this case, you
> must know a 
> little the C language.
> 
> To summarize, think at what you want to do and choose one
> of the three 
> methods: /dev/midi is poor and simple; /dev/sequencer is
> more 
> complicated but still easy in gambas; using alsa (OSS is
> older) is the 
> way to go if you want to do a complicated but powerful
> program.
> 
> Let me know if you have more doubts. I have no time to
> write a program 
> myself, but I can find some time to give you some hint.
> Please specify 
> more precisely what you want to do.
> 
> Regards,
> Doriano
> 
> ------------------------------------------------------------------------------
> 
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
> 







More information about the User mailing list