[sanniolug] Re: SBLive + ALSA + MIDI

  • From: Brix <brix82@xxxxxxxxx>
  • To: sanniolug@xxxxxxxxxxxxx
  • Date: Mon, 25 Aug 2003 16:34:43 +0200

On Fri, 22 Aug 2003 16:34:57 +0200
Massimiliano Mirra <mmirra@xxxxxxxxx> wrote:

> Benvenuto. :-)

Grazie :D

> Questi sono i moduli attinenti al caso che compaiono da me nell'output
> di lsmod:
> 
> Module                  Size  Used by    Tainted: P  
> [...]
> 
> Coincide con la tua?
> 

io a dire il vero ho un modulo in più:

snd-page-alloc          5476   0  [snd-emu10k1 snd-pcm]

> Prova ad eseguire questo comando:
> 
> strace -o log pmidi -l

le cose più interessanti che ottengo sono queste:

[...]
open("/dev/snd/seq", O_RDWR)            = 3
ioctl(3, 0x80045300, 0xbffff7e4)        = 0
ioctl(3, 0x80045301, 0xbffff7e0)        = 0
brk(0)                                  = 0x804ce60
brk(0x804de60)                          = 0x804de60
brk(0)                                  = 0x804de60
brk(0x804e000)                          = 0x804e000
brk(0)                                  = 0x804e000
brk(0x8051000)                          = 0x8051000
brk(0)                                  = 0x8051000
brk(0x8052000)                          = 0x8052000
ioctl(3, 0xc0305302, 0xbffff840)        = 0
fstat64(1, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0
old_mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 
0x40012000
write(1, " Port     Client name           "..., 54) = 54
ioctl(3, 0xc0dc5310, 0xbffff93c)        = -1 ENOTTY (Inappropriate ioctl for 
device)
ioctl(3, 0xc0dc5310, 0xbffff93c)        = -1 ENOTTY (Inappropriate ioctl for 
device)
...
/* segue una sfilza di ioctl() a vuoto ... */
...
ioctl(3, 0xc0dc5310, 0xbffff93c)        = -1 ENOTTY (Inappropriate ioctl for 
device)
munmap(0x40012000, 4096)                = 0
_exit(0)                                = ?
[...]

Vorrei realizzare un "ear trainer", solo che non posso con OSS perchè serve la 
versione commerciale.
Copio qui un pezzo di codice che ho usato per fare alcune ioctl() ai vari 
dispositivi e tentare di avere informazioni:

/* Questo programma usa OSS o una sua emulazione per avere informazioni */

#include <linux/soundcard.h>
#include <unistd.h>
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>

extern int errno;

int main(void) {
   char* device = "/dev/sequencer";
   unsigned char devnum = 0x0F;
   unsigned char packet[4] = {SEQ_MIDIPUTC, 0, devnum, 0};
   int status, midi_count, bytes_written;

   // open the device for writing
   int fd = open(device, O_WRONLY, 0);
   printf("Opening %s ...\n", device);
   
   // retrieve informations about number of synths
   if ( (status = ioctl(fd, SNDCTL_SEQ_NRSYNTHS, &midi_count)) != 0 )
     printf("Error getting number of synth\n");
   else
     printf("%d synths available\n", midi_count);

   // retrieve informations about number of midi sequencers
   if ( (status = ioctl(fd, SNDCTL_SEQ_NRMIDIS, &midi_count)) != 0 )
     printf("Error getting number of midi\n");
   else
     printf("%d midi sequencers available\n", midi_count);

   // error opening the device?
   if (fd < 0) {
      printf("Error: cannot open %s\n", device);
      exit(1);
   }

   // attempt to write the note-on message
   packet[1] = 0x90;                   // note-on command
   if ( bytes_written = write(fd, packet, sizeof(packet)) == -1 )
     printf("error writing packet to %s : %s\n", device, strerror(errno) );
   else
     printf("%d bytes written to %s\n", bytes_written, device);

   close(fd);

   return 0;
}

Facendolo girare sul device /dev/sequencer ottengo:

Opening /dev/sequencer ...
1 synths available
5 midi sequencers available
0 bytes written to /dev/sequencer

Su /dev/music, invece:

Opening /dev/music ...
6 synths available
5 midi sequencers available
error writing packet to /dev/music : Invalid argument

Non ci ho capito nulla.
Tra l'altro ho provato ad installare rosegarden, e noto con [dis]piacere che 
riesce a suonarmi i files midi su /dev/sequencer. Boh!


-- 

        Hardware is never old.
        People just choose the wrong OS.


Other related posts: