Sound-Engine

  • Dreieckskurve
    
    float deviceValue;       // 1 > deviceValue > 0
    float xValue    = 0.0;
    float amplitude = 1.0;
    
    while ( bufferSize -- )
    {
      buffer++ = ( xValue * amplitude );
      if( ( direction == 1 ) && (xValue >= deviceValue ) )
        direction = -1;
      else if ( ( direction == -1 ) && (deviceValue >= xValue ) )
        direction = 1;
    	
      ...
    		
      xValue += direction * (1.0 / 64.0 );
    }
    


  • Sinuskurve
    
    float deviceValue;     // 1 > deviceValue > 0
    float amplitude = 1.0;
    float phi       = 0.0;
    
    float frequency = exp ( 2 * deviceValue - 2 ) * SAMPLE-FREQ
    
    while ( bufferSize -- )
    {
      buffer++ = ( amplitude * cos ( phi ) );
      phi += ( 2.0 * PI * frequency / SAMPLE_FREQ );		
    }
    
    


    zurück |  inhalt |  weiter ]

© by gnaegi@icu.unizh.ch