measuring jack themes technologies tooltips linux measuring jack themes technologies tooltip linux limejack claim limejack limejack

Démarrer | Langue  de en fr | Menu | Carte | Recherchez

Vous êtes ici: start » fr » experiments » bubbletonia

BubbleTonia - Sounds by Bubbles

Wie hatten den Filter BubblesToSounds in zwei Filter zerteilt: BubblesToValues und ValuesToSounds.

BubblesToSounds:

  Bubbles     Cam       Filter1        Filter2    Amplifier  Loudspeaker     Sound
              __       _________       ________                   /|           ___
  o o   o   _|  |     |         |     |        |     |\        __/ |          |   |
   o   o   |_   |_____| Bubbles |_____| Values |_____| \ _____|    |          |  O'
  o  o  o    |__|     |    to   |     |   to   |     | /      |__  |         O'  
                      |  Values |     | Sounds |     |/          \ |                |\
                      |_________|     |________|                  \|               O'

Filter1 : Bubbles to Values

  • Idee : Webcam via opencv auslesen

Den Sichtbereich habe ich noch eingeschränkt:

  • Schnappschuss
  • via Gimp übermalen:
    • weiß : sichtbar
    • Rest : unsichtbar
  • mit imagemagick nach Text konvertiert: convert frame.png frame.txt
  • aus Text-Datei zu python-Array (sog. Matrix) verarbeitet

Der bearbeitete Schanppschuss :

Der txt2py-filter:

#!/bin/bash

echo 'import numpy'   > frame.py
echo 'Matrix = [[0 for x in range(480)] for y in range(640)]'   >> frame.py

grep '^[0-9].*white$' frame.txt | sed 's/^\([0-9][0-9]*\),\([0-9][0-9]*\): .*white/Matrix[\1][\2] = 1 /g'   >> frame.py

exit

Somit ergeben sich folgende Basis-Scripte:

Filter1 : Script 1 : lk_homography.py

Filter1 : Script 2 : motempl.py

Wir hatten uns für Script 1 entschieden, halte aber das Script 2 immer noch für brauchbar.

Filter2 : Values to Sound

Wir hatten drei Ansätze ersonnen:

  • Ausgabe von Midi-Befehlen und Ansteuerung von extern. Midi-Geräten (Midi output)
  • JACK sound server
  • Play simple wav files (using external soundserver)

Filter2 : Idee 1: Midi output

Gefunden unter https://ccrma.stanford.edu/~craig/articles/linuxmidi/https://ccrma.stanford.edu/~craig/articles/linuxmidi/; vielleicht nützt es ja.

//
// Programmer:    Craig Stuart Sapp <craig@ccrma.stanford.edu>
// Creation Date: Mon Dec 21 18:00:42 PST 1998
// Last Modified: Mon Dec 21 18:00:42 PST 1998
// Filename:      ...linuxmidi/output/method1.c
// Syntax:        C 
// $Smake:        gcc -O -o %b %f && strip %b
//
// Description:   This program sends out a single MIDI note (middle C)
//		  and then exits.  The MIDI driver usually turns the
//                note off automatically when the program is exited.
//

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

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


   // step 1: open the OSS device for writing
   int fd = open(device, O_WRONLY);
   if (fd < 0) {
      printf("Error: cannot open %s\n", device);
      exit(1);
   }
			

   // step 2: write the note-on message to MIDI output
   packet[1] = 0x90;                        // note-on MIDI command
   write(fd, packet, sizeof(packet));
   packet[1] = 60;                          // kenumber: 60 = middle c
   write(fd, packet, sizeof(packet));
   packet[1] = 127;                         // attack velocity: 127 = loud
   write(fd, packet, sizeof(packet));   


   // step 3: (optional) close the device
   close(fd);


   return 0;
}

Basierend auf Craig Stuart Sapp zwei funktioirende Programme für Ausgabe (craig1) und Lesen (craig2):

// based on Craig Stuart Sapp <craig@ccrma.stanford.edu>

#include <stdio.h>
#include <unistd.h>


int i;

FILE *fd; 

int main(void) {
  fd = fopen("/dev/midi2", "w");

  fputc(0x90,fd);   fputc(48,fd);   fputc(127,fd); fflush(fd); //play note by number 48
  sleep(10); 
  fputc(0x80,fd);   fputc(48,fd);   fputc(127,fd); fflush(fd); //leave note by number 48

  fclose(fd);

  return 0;
}
// based on Craig Stuart Sapp <craig@ccrma.stanford.edu>

#include <stdio.h>


int i,j,k;
int run=1;

char c ;

FILE *fd; 

int main(void) {
  fd = fopen("/dev/midi2","rb");

while( run==1 ) {
  i=fgetc(fd) ;

  if(i==144){ //Note pressed
    j=fgetc(fd) ;
    k=fgetc(fd) ;
    if(k==64){   printf("craig2 Note >  %d\n",j); }}; //note value as number


  if(i==192){ //Instrument choosed (without 2nd line)
    j=fgetc(fd) ;
    printf("craig2 Inst >  %d\n",j); }; //instrument value

  if(i==224){ //Pitch activated
    j=fgetc(fd) ;
    k=fgetc(fd) ;
    if(j==64){   printf("craig2 Pitch >  %d\n",k); }}; //pitch value

/*   printf("craig2 >  %d\n",i);*/
    }
  fclose(fd);
   return 0;
}

Filter2 : Idee 2: JACK sound server

  • bereits vorgeführt
  • Erfahrungen vorhanden
  • komplexe Umsetzung des Source Codes

Filter2 : Idee 3: play multiple wav files

Ich hatte noch nach Beispielen geschaut, wie man in python wav files abspielen kann. Ich stolperte über zwei Probleme in den Skripten:

  • Verwendung von Threads
  • Filtereingang via read

Threads

Die Idee, alles in einem Skript zu mixen, sollte die schwer händelbaren Threads vermeiden. Alle Skripte, die ich fand, verwendeten Threads. Dann wäre aber die Frage, ob das OS nicht besser die Prozesse händelt, wie es der erprobte for-Loop mithilfe von play getättig hatte.

Der Befehl play stammt ist aus dem sox-Paketen, die als Pipe-Tools stdin und stdout erwarten. Nohup und Co. kappen aber diese IOs. Verwendung von play click.ogg -q & (q-Option) lässt play brav im Hintergrund arbeiten.

Ein mgl. Skript könnte also so aussehen:

#!/bin/bash

while read aaa
do

  case ${aaa} in
  A1) play a1.ogg -q & ; play bell.ogg -q & ;;
  C1) play c1.ogg -q & ; play chicken.ogg -q & ;;
  usw.
  esac

done

read - Lesen vom Eingang

Das hat mich nun entsetzt, dass das Lesen vom Eingang (readkey) bei python derart OS-abhängig ist. Der Code muss an das OS angepasst werden.

Das Gefrickel entfällt bei obigem Bash-Skript zu Lasten der Geschwindigkeit bei der Ausführung des Programms. Oder man nutzt gleich C mit cross compiling, was dann auch zu schnellem Code führt.

MIDI Event Table

Quelle : http://www.onicos.com/staff/iz/formats/midi-event.html http://www.onicos.com/staff/iz/formats/midi-event.html

Status Byte Data Bytes
1st byte Function 2nd byte 3rd byte
0x80 Chan 1 Note off Note Number (0-127) Note Velocity (0-127)
0x81 Chan 2 Note off Note Number (0-127) Note Velocity (0-127)
0x82 Chan 3 Note off Note Number (0-127) Note Velocity (0-127)
0x83 Chan 4 Note off Note Number (0-127) Note Velocity (0-127)
0x84 Chan 5 Note off Note Number (0-127) Note Velocity (0-127)
0x85 Chan 6 Note off Note Number (0-127) Note Velocity (0-127)
0x86 Chan 7 Note off Note Number (0-127) Note Velocity (0-127)
0x87 Chan 8 Note off Note Number (0-127) Note Velocity (0-127)
0x88 Chan 9 Note off Note Number (0-127) Note Velocity (0-127)
0x89 Chan 10 Note off Note Number (0-127) Note Velocity (0-127)
0x8A Chan 11 Note off Note Number (0-127) Note Velocity (0-127)
0x8B Chan 12 Note off Note Number (0-127) Note Velocity (0-127)
0x8C Chan 13 Note off Note Number (0-127) Note Velocity (0-127)
0x8D Chan 14 Note off Note Number (0-127) Note Velocity (0-127)
0x8E Chan 15 Note off Note Number (0-127) Note Velocity (0-127)
0x8F Chan 16 Note off Note Number (0-127) Note Velocity (0-127)
0x90 Chan 1 Note on Note Number (0-127) Note Velocity (0-127)
0x91 Chan 2 Note on Note Number (0-127) Note Velocity (0-127)
0x92 Chan 3 Note on Note Number (0-127) Note Velocity (0-127)
0x93 Chan 4 Note on Note Number (0-127) Note Velocity (0-127)
0x94 Chan 5 Note on Note Number (0-127) Note Velocity (0-127)
0x95 Chan 6 Note on Note Number (0-127) Note Velocity (0-127)
0x96 Chan 7 Note on Note Number (0-127) Note Velocity (0-127)
0x97 Chan 8 Note on Note Number (0-127) Note Velocity (0-127)
0x98 Chan 9 Note on Note Number (0-127) Note Velocity (0-127)
0x99 Chan 10 Note on Note Number (0-127) Note Velocity (0-127)
0x9A Chan 11 Note on Note Number (0-127) Note Velocity (0-127)
0x9B Chan 12 Note on Note Number (0-127) Note Velocity (0-127)
0x9C Chan 13 Note on Note Number (0-127) Note Velocity (0-127)
0x9D Chan 14 Note on Note Number (0-127) Note Velocity (0-127)
0x9E Chan 15 Note on Note Number (0-127) Note Velocity (0-127)
0x9F Chan 16 Note on Note Number (0-127) Note Velocity (0-127)
0xA0 Chan 1 Polyphonic aftertouch Note Number (0-127) Aftertouch pressure (0-127)
0xA1 Chan 2 Polyphonic aftertouch Note Number (0-127) Aftertouch pressure (0-127)
0xA2 Chan 3 Polyphonic aftertouch Note Number (0-127) Aftertouch pressure (0-127)
0xA3 Chan 4 Polyphonic aftertouch Note Number (0-127) Aftertouch pressure (0-127)
0xA4 Chan 5 Polyphonic aftertouch Note Number (0-127) Aftertouch pressure (0-127)
0xA5 Chan 6 Polyphonic aftertouch Note Number (0-127) Aftertouch pressure (0-127)
0xA6 Chan 7 Polyphonic aftertouch Note Number (0-127) Aftertouch pressure (0-127)
0xA7 Chan 8 Polyphonic aftertouch Note Number (0-127) Aftertouch pressure (0-127)
0xA8 Chan 9 Polyphonic aftertouch Note Number (0-127) Aftertouch pressure (0-127)
0xA9 Chan 10 Polyphonic aftertouch Note Number (0-127) Aftertouch pressure (0-127)
0xAA Chan 11 Polyphonic aftertouch Note Number (0-127) Aftertouch pressure (0-127)
0xAB Chan 12 Polyphonic aftertouch Note Number (0-127) Aftertouch pressure (0-127)
0xAC Chan 13 Polyphonic aftertouch Note Number (0-127) Aftertouch pressure (0-127)
0xAD Chan 14 Polyphonic aftertouch Note Number (0-127) Aftertouch pressure (0-127)
0xAE Chan 15 Polyphonic aftertouch Note Number (0-127) Aftertouch pressure (0-127)
0xAF Chan 16 Polyphonic aftertouch Note Number (0-127) Aftertouch pressure (0-127)
0xB0 Chan 1 Control mode change See MIDI controls See MIDI controls
0xB1 Chan 2 Control mode change See MIDI controls See MIDI controls
0xB2 Chan 3 Control mode change See MIDI controls See MIDI controls
0xB3 Chan 4 Control mode change See MIDI controls See MIDI controls
0xB4 Chan 5 Control mode change See MIDI controls See MIDI controls
0xB5 Chan 6 Control mode change See MIDI controls See MIDI controls
0xB6 Chan 7 Control mode change See MIDI controls See MIDI controls
0xB7 Chan 8 Control mode change See MIDI controls See MIDI controls
0xB8 Chan 9 Control mode change See MIDI controls See MIDI controls
0xB9 Chan 10 Control mode change See MIDI controls See MIDI controls
0xBA Chan 11 Control mode change See MIDI controls See MIDI controls
0xBB Chan 12 Control mode change See MIDI controls See MIDI controls
0xBC Chan 13 Control mode change See MIDI controls See MIDI controls
0xBD Chan 14 Control mode change See MIDI controls See MIDI controls
0xBE Chan 15 Control mode change See MIDI controls See MIDI controls
0xBF Chan 16 Control mode change See MIDI controls See MIDI controls
0xC0 Chan 1 Program change Program # (0-127) -
0xC1 Chan 2 Program change Program # (0-127) -
0xC2 Chan 3 Program change Program # (0-127) -
0xC3 Chan 4 Program change Program # (0-127) -
0xC4 Chan 5 Program change Program # (0-127) -
0xC5 Chan 6 Program change Program # (0-127) -
0xC6 Chan 7 Program change Program # (0-127) -
0xC7 Chan 8 Program change Program # (0-127) -
0xC8 Chan 9 Program change Program # (0-127) -
0xC9 Chan 10 Program change Program # (0-127) -
0xCA Chan 11 Program change Program # (0-127) -
0xCB Chan 12 Program change Program # (0-127) -
0xCC Chan 13 Program change Program # (0-127) -
0xCD Chan 14 Program change Program # (0-127) -
0xCE Chan 15 Program change Program # (0-127) -
0xCF Chan 16 Program change Program # (0-127) -
0xD0 Chan 1 Channel aftertouch Aftertouch pressure (0-127) -
0xD1 Chan 2 Channel aftertouch Aftertouch pressure (0-127) -
0xD2 Chan 3 Channel aftertouch Aftertouch pressure (0-127) -
0xD3 Chan 4 Channel aftertouch Aftertouch pressure (0-127) -
0xD4 Chan 5 Channel aftertouch Aftertouch pressure (0-127) -
0xD5 Chan 6 Channel aftertouch Aftertouch pressure (0-127) -
0xD6 Chan 7 Channel aftertouch Aftertouch pressure (0-127) -
0xD7 Chan 8 Channel aftertouch Aftertouch pressure (0-127) -
0xD8 Chan 9 Channel aftertouch Aftertouch pressure (0-127) -
0xD9 Chan 10 Channel aftertouch Aftertouch pressure (0-127) -
0xDA Chan 11 Channel aftertouch Aftertouch pressure (0-127) -
0xDB Chan 12 Channel aftertouch Aftertouch pressure (0-127) -
0xDC Chan 13 Channel aftertouch Aftertouch pressure (0-127) -
0xDD Chan 14 Channel aftertouch Aftertouch pressure (0-127) -
0xDE Chan 15 Channel aftertouch Aftertouch pressure (0-127) -
0xDF Chan 16 Channel aftertouch Aftertouch pressure (0-127) -
0xE0 Chan 1 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
0xE1 Chan 2 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
0xE2 Chan 3 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
0xE3 Chan 4 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
0xE4 Chan 5 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
0xE5 Chan 6 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
0xE6 Chan 7 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
0xE7 Chan 8 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
0xE8 Chan 9 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
0xE9 Chan 10 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
0xEA Chan 11 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
0xEB Chan 12 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
0xEC Chan 13 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
0xED Chan 14 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
0xEE Chan 15 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
0xEF Chan 16 Pitch wheel range Pitch wheel LSB (0-127) Pitch wheel MSB (0-127)
0xF0 System Exclusive |
0xF1 System Common - undefined - -
0xF2 Sys Com Song Position Pntr LSB MSB
0xF3 Sys Com Song Select(Song #) (0-127) -
0xF4 System Common - undefined - -
0xF5 System Common - undefined - -
0xF6 Sys Com tune request - -
0xF7 Sys Com-end of SysEx (EOX) - -
0xF8 Sys real time timing clock - -
0xF9 Sys real time undefined - -
0xFA Sys real time start - -
0xFB Sys real time continue - -
0xFC Sys real time stop - -
0xFD Sys real time undefined - -
0xFE Sys real time active sensing - -
0xFF Sys real time sys reset - -
Disclaimer | Impressum | Privacy | Copyleft