Die Soundausgabe

Der Original-Player stammt von Randy Sargent, wir haben ihn nur etwas an unsere Bedürfnisse angepasst.

Funktionsweise:

Programm:

/****************************************************/
/*     Soundausgabe beim Rug Warrior                */
/*    Katja Steuernagel, Michael Kapp               */
/*              SS 99                               */
/****************************************************/

#define DEF_TEMPO 12

/* Theme from the Ninth Symphony - L. van Beethoven */
char NINE[]="2e2e2f2g2g2f2e2d2c2c2d2e2e2d4d2e2e2f2g2g2f2e2d2c2c2d2e2d2c4c";
/* Haenschen Klein */
char HANS[]="2g2e4e2f2d4d2c2d2e2f2g2g4g2g2e4e2f2d4d2c2e2g2gD8c";
/* Pop goes the Weasel */
char WEASEL[]="4f2f4g2g2aU2cD2a4f4a2a4g2g6a4f4f2f4g2g2aU2cD2a4f1g1a1&bU1cD2d4g2&b6a2f";
/* When the saints go marching in */
char SAINT[]="2c2e2f10g2c2e2f10g2c2e2f4g4e4c4e12d2e2d6c2c4e2g2g2g10f2e2f4g4e4d4e10c";
/* I want to break free */
char BREAKFREE[]="2c2f3f2g4a1r D2c2f3f2g2#a3a2g2#a3a2g2#a3a2g2#a3a2g4g2f";
/* The Entertainer - Tempo 14*/
char ENTER[]="1#d1d1eU2cD1eU2cD1eU6c1c1d1#d1e1c1d2eD1bU2d6cD1d1#d1eU2cD1e
U2cD1eU7cD1a1g1#f1aU1c2e1d1cD1aU6dD1d1#d1eU2cD1eU2cD1eU6c1c1d1#d1e1c1d2e
D1bU2d6c1c1d1e1c1d2e1c1d1c1e1c1e2e1c1d1c1e1c1d2eD1bU2d6c"; 
/* Freut euch des Lebens - Tempo 16*/
char FREU[]="3#f1g1#f1g2aU1d3dD3d1e1d1e1#f1g1#f3e3#f1g1#f1g2aU1d3dD3#f1e1d1e4d";
/* La cucaracha */
char LACUCA[]="1d1d1d4g1b1g1d1d4g4b1g1g1#f1#f1e1e5d1d1d1d4#f1a1d1d1d4#f4a
U1d1e1d1cD1b1a2g";
/* Fuer Elise - L. van Beethoven*/
char ELISE[]="U1e1#d1e1#d1e1b1d1c3aD1c1e1a3bD1e1#g1b4c1e1#d1e1#d1e1b1d1c3a
D1c1e1a3b1eU1c1b4a";
/* For he`s a jolly good fellow */
char FELLOW[]="1f2a1a1a1g1a3&b2a1a2g1g1g1f1g3a2f1g2a1a1a1g1a3&bU2d1d2cD1&b2a1g5f";
/* Indiana Jones Theme */
char INDY[]="3e1f2g8c D3d1e8f 3f1g2aU8f D2g2a4c4d4e D3e1f2g8c 3c1e8f D2g2g
U4e2d D2gU4e2d D2gU4f2e2d6cD4f2e2d6c";
/* Ole */
char OLE[]="2a3c1a1c1a1c1a4f1a1a1a3gD3cU2a6g2a3c1a1c1a1c1a4f1a1a1a3gD3cU2a4f";
/* Tell me why I dont like mondays */
char MONDAY[]="1f1f2fD2a2c2f4g4f 1f1f2f2f2f2f4e4f";
/* Obladi, oblada - The Beatles */
char OBLADI[]="2c2e4gD2c2e4gD2c2e8g8c4g2f2e2f2e4d8c";
/* Yesterday - The Beatles */
char YESTERDAY[]="3d1c6c 2e2f2g2a2b2c4b2a4a";


/* Song abspielen */
void play(char song[], int tempo)
{
   int i, sustain, duration, reset_dur, accidental, delta;
   int notes[] = {0,2,3,5,7,8,10};
   int old_note = 30;
   
   i=0;
   while (song[i]) {
      while (song[i]==' ') i++;
      while (song[i]=='D') { old_note-=12; i++; }
      while (song[i]=='U') { old_note+=12; i++; }
      reset_dur=1;
      while ('0'<=song[i] && song[i]<='9') {
         if (reset_dur) { duration=reset_dur=0; }
         duration=duration*10+song[i++]-'0';
      }
      if (song[i]=='#') { accidental=+1; i++; }
      else if (song[i]=='&') { accidental=-1; i++; }
      else accidental=0;
      
      sustain=duration*tempo;
      if (song[i]=='r') msleep((long)(sustain*6));
      else {
         if (song[i]<'a' || song[i]>'g') {
             beep(); beep(); beep();
             return;
         }
         delta = notes[song[i]-'a'] + accidental - old_note%12;
         old_note += delta;
         if (delta>+5) old_note-=12;
         if (delta<-5) old_note+=12;
         tone(55.0 * (2.0 ^ (((float) old_note) / 12.0)), sustain*5 );
         msleep((long)sustain);
      }
      i++;
   }
}


Fragen, Anregungen, Kritik, Gummibärchen an: steuerna@rhrk.uni-kl.de (Katja) oder mkapp@rhrk.uni-kl.de (Michael).
Letzte Änderung: 29.11.99©1999 Katja & Michael
Zurück zur Hauptseite Fernbedienung