Die Routine "Stosse_ins_Horn(int nr)"



/* Wenn dieses Modul benutzt wird sollten keine sonstigen Zugriffe auf den */ 
/* Beeper (mit tone(x), beeper_on() oder beeper_off()) gemacht werden.     */

float tonleiter = 268.0; /* Grundfrequenz */ 
int ganze_note = 1920; /* Dauer einer ganzen Note */ 
int teiler = 12; /* Eine Note wird nie ganz gespielt, immer nur n/12 davon */

/* Prozess-ID des laufenden Musikprozess */ 
int music_pid = 0;

/* Die Semaphore music_done schuetzt die "knappe" Resource Beeper.   */ 
/* 1: es laeuft kein Musikprozess; 0: Robbi stoesst gerade ins Horn. */ 
int music_done = 1;

/* Nummern der Signale */ 
int ATTACKE   = 0; 
int AUFBRUCH  = 1; 
int ANFEUERN  = 2; 
int HALALI    = 3; 
int REHTOD    = 4; 
int FUCHSTOD  = 5; 
int HIRSCHTOD = 6; 
int FUERST    = 7;

/* Startet einen Prozess, der das Jagd-Signal  auf dem Beeper ausgibt. */ 
void Stosse_ins_Horn(int nr) 
{
  /* Wenn kein Signal laeuft, dann gleich Semaphore setzen. Dabei sollte     */
  /* nichts schiefgehen koennen, denn dafuer ist die Zeitscheibe selbst      */
  /* mit 1 ms lang genug.                                                    */
  /* Die einzelnen Musikprozesse muessen die Semaphore (mit signal_ende())   */
  /* selber zuruecksetzen, wenn sie fertig sind.                             */

  if (music_done) 
    {
      if (nr == ATTACKE)   
	{ music_done = 0; music_pid = start_process( attacke(), 1, 64 ); }
      else if (nr == AUFBRUCH)
	{ music_done = 0; music_pid = start_process( aufbruch(), 1, 64 ); }
      else if (nr == ANFEUERN)
	{ music_done = 0; music_pid = start_process( anfeuern(), 1, 64 ); }
      else if (nr == HALALI)
	{ music_done = 0; music_pid = start_process( halali(), 1, 64 ); }
      else if (nr == REHTOD)
	{ music_done = 0; music_pid = start_process( rehtod(), 1, 64 ); }
      else if (nr == FUCHSTOD)
	{ music_done = 0; music_pid = start_process( fuchstod(), 1, 64 ); }
      else if (nr == HIRSCHTOD)
	{ music_done = 0; music_pid = start_process( hirschtod(), 1, 64 ); }
      else if (nr == FUERST)
	{ music_done = 0; music_pid = start_process( fuerst(), 1, 64 ); }
    } 
}

/*****************************************************************************/ 
/*                                                                           */ 
/* Niemals Funktionen unterhalb dieser Linie im eigenen Code aufrufen!       */ 
/*                                                                           */ 
/* Nur Stosse_ins_Horn(n) verwenden, um mehrfache Zugriffe auf den Beeper    */ 
/* auszuschliessen.                                                          */ 
/*                                                                           */ 
/*****************************************************************************/

void note(int ton, int dauerzaehler, int dauerteiler, int tonlaenge) 
{
  int dauer = ( ganze_note * dauerzaehler ) / ( teiler * dauerteiler );
  /* ton == 0 ist eine Pause */
  if (ton) tone( tonleiter * (float)ton, ( tonlaenge*dauer ) );
  msleep( (long)( (teiler-tonlaenge) * dauer ) ); 
}

void signal_ende() 
{
  beeper_off(); 
  music_done = 1;
  kill_process(my_pid); 
}

void tot() 
{
  note(2, 1, 16, 8);
  note(3, 1, 4, 12);
  note(5, 3, 8, 10);
  note(0, 1, 16, 12);
  note(2, 1, 16, 8);
  note(3, 1, 4, 12);
  note(4, 3, 8, 12); 
}

void lauffuchs1() 
{
  note(4, 1, 4, 8);
  note(3, 1, 8, 6);
  note(4, 1, 4, 8); 
}

void lauffuchs2() 
{
  note(4, 1, 8, 6);
  note(5, 1, 8, 6);
  note(3, 1, 8, 6);
  note(5, 1, 8, 6); 
}

void laufhirsch() 
{
  note(4, 1, 8, 6);
  note(5, 1, 8, 12);
  note(4, 1, 8, 8); 
}

void laufreh() 
{
  note(4, 3, 16, 8);
  note(3, 1, 16, 8);
  note(3, 1, 4, 8); 
}

void fuerst() 
{
  int my_pid = music_pid;
  int i,j;
  
  beeper_on();
  
  note(4, 1, 4, 8);
  note(3, 1, 2, 10);
  note(3, 1, 12, 2);
  note(4, 1, 12, 6);
  note(5, 1, 12, 6);
  note(6, 1, 12, 6);
  note(5, 1, 12, 6);
  note(4, 1, 12, 6);
  note(3, 3, 4, 7);
  for (i=0; i<2; i++)
    {
      note(3, 1, 8, 6);
      note(4, 1, 8, 6);
      note(4, 1, 16, 6);
      note(4, 1, 16, 6);
      note(4, 1, 8, 6);
      note(4, 1, 4, 10);
      note(4, 1, 4, 10);
      note(3, 1, 8, 6);
      note(4, 1, 4, 12);
      note(5, 1, 8, 6);
      note(6, 1, 8, 6);
      note(5, 1, 8, 6);
      note(6, 1, 8, 6);
      note(4, 1, 8, 6);
      note(4, 1, 16, 6);
      note(4, 1, 8, 6);
      note(4, 1, 4, 10);
      note(3, 1, 8, 6);
      note(4, 1, 4, 10);
      note(5, 1, 8, 6);
      note(6, 1, 8, 12);
      note(5, 1, 8, 6);
      note(4, 1, 8, 6);
      note(6, 3, 8, 12);
      note(0, 1, 4, 0);
    };
  note(0, 1, 8, 0);
  for (i=0; i<2; i++)
    {
      for (j=0; j<2; j++)
	{
	  note(3, 1, 8, 6);
	  note(3, 1, 16, 6);
	  note(3, 1, 16, 6);
	  note(3, 1, 8, 6);
	  note(3, 1, 4, 8);
	  note(5, 1, 8, 6);
	  note(4, 1 ,4, 8);
	  note(6, 1, 8, 6);
	  note(5, 1, 4, 8);
	  note(4, 1, 8, 6);
	  note(6, 1, 8, 12);
	  note(5, 1, 8, 6);
	  note(4, 1, 8, 6);
	  note(6, 1, 8, 12);
	  note(5, 1, 8, 6);
	  note(4, 1, 8, 6);
	  note(3, 1, 8, 6);
	  note(3, 1, 16, 6);
	  note(3, 1, 8, 6);
	  note(3, 3, 8, 8);
	};
      note(4, 4, 4, 6);
    };
  
  signal_ende(); 
}


void aufbruch() 
{
  int my_pid = music_pid;
  
  beeper_on();
  
  note(2, 1, 16, 12);
  note(3, 3, 16, 8);
  note(2, 1, 16, 12);
  note(3, 7, 16, 8);
  note(2, 1, 16, 8);
  note(3, 3, 16, 12);
  note(2, 1, 16, 8);
  note(3, 7, 16, 8);
  note(2, 1, 16, 8);
  note(3, 3, 16, 12);
  note(2, 1, 16, 8);
  note(3, 1, 4, 10);
  note(4, 3, 4, 8);
  
  signal_ende(); 
}

void attacke() 
{
  int my_pid = music_pid;
  
  beeper_on();
  
  note(3, 1, 16, 8);
  note(4, 7, 16, 8);
  note(3, 1, 16, 8);
  note(4, 7, 16, 8);
  note(3, 1, 16, 6);
  note(4, 1, 8, 6);
  note(4, 1, 16, 6);
  note(4, 1, 8, 6);
  note(3, 1, 8, 6);
  note(4, 1, 4, 12);
  
  signal_ende(); 
}

void halali() 
{
  int my_pid = music_pid;
  int i;
  
  beeper_on();
  
  note(4, 1, 8, 6);
  note(4, 1 ,8, 12);
  note(3, 1, 8, 6);
  note(4, 1, 8, 6);
  note(4, 3, 8, 12);
  note(3, 1, 4, 8);
  note(5, 1, 8, 6);
  note(5, 1, 8, 12);
  note(4, 1, 8, 6);
  note(5, 1, 8, 6);
  note(5, 3, 8, 12);
  note(4, 1, 4, 8);
  note(6, 1, 8, 6);
  for (i=0; i<4; i++)
    {
      note(6, 1, 8, 12);
      note(5, 1, 8, 6);
      note(6, 1, 8, 6);
    }
  note(6, 1, 1, 12);
  
  signal_ende(); 
}

void anfeuern() 
{
  int my_pid = music_pid;
  
  beeper_on();
  
  note(3, 1, 8, 6);
  note(4, 3, 16, 8);
  note(5, 1, 16, 6);
  note(6, 1, 8, 6);
  note(5, 1, 8, 6);
  note(4, 1, 8, 6);
  note(4, 1, 16, 6);
  note(4, 1, 16, 6);
  note(4, 1, 8, 6);	
  note(3, 1, 8, 6);
  note(4, 3, 16, 8);
  note(5, 1, 16, 6);
  note(6, 1, 8, 6);
  note(5, 1, 8, 6);
  note(4, 1, 8, 6);
  note(4, 1, 16, 6);
  note(4, 1, 16, 6);
  note(4, 1, 8, 6);	
  note(3, 1, 8, 6);
  note(4, 3, 16, 8);
  note(5, 1, 16, 6);
  note(6, 1, 8, 6);
  note(5, 1, 8, 6);
  note(4, 1, 2, 8);
  
  signal_ende(); 
}

void fuchstod() 
{
  int my_pid = music_pid;
  
  beeper_on();

  note(6, 1, 4, 8);
  note(5, 1, 4, 8);
  lauffuchs1();
  lauffuchs1();
  note(4, 1, 4, 8);
  note(3, 1, 8, 6);
  note(5, 1, 8, 6);
  lauffuchs2();
  lauffuchs1();
  lauffuchs1();
  lauffuchs1();
  lauffuchs2();
  note(4, 1, 4, 8);
  note(3, 3, 8, 8);
  note(6, 1, 4, 10);
  note(5, 1, 4, 10);
  note(4, 1, 4, 10);
  note(3, 1, 2, 6);
  tot();
  
  signal_ende(); 
}

void hirschtod() 
{
  int my_pid = music_pid;
  int i,j;
  
  beeper_on();

  for (i=0; i<2; i++)
    {
      note(6, 3, 8, 8);
      note(5, 3, 8, 8);
      for (j=0; j<2; j++)
	{
	  laufhirsch();
	  note(3, 3, 8, 8);
	}
      laufhirsch();
      note(3, 1, 8, 6);
      note(3, 1, 16, 6);
      note(3, 1, 16, 6);
      note(3, 1, 8, 6);				
      laufhirsch();
      note(3, 3, 8, 8);
    }
  tot();
  
  signal_ende(); 
}

void rehtod() 
{
  int my_pid = music_pid;
  int i,j;
  
  beeper_on();

  for (i=0; i<2; i++)
    {
      laufreh();
      note(5, 3, 16, 8);
      note(3, 1, 16, 8);
      note(3, 1, 4, 8);		
      note(4, 1, 8, 6);
      note(3, 1, 8, 6);
      note(5, 1, 8, 6);
      note(3, 1, 8, 6);
      laufreh();
    }
  note(3, 1, 8, 6);
  note(4, 1, 16, 6);
  note(5, 1, 16, 6);
  note(6, 1, 8, 6);
  note(5, 1, 16, 6);
  note(4, 1, 16, 6);
  note(3, 1, 4, 6);
  tot();
  
  signal_ende(); 
}



© Gunnar Mecke, Letzte Änderung: 29.09.97

Zurück zu den Jagdmelodien