GoConqr hat ein neues Design! Sag uns, wie es dir gefällt.

Quiz

Audio signal generation code: sine, sawtooth, sweep

Laurenz h 1 Frage

Quiz starten

Fragen in diesem Quiz (1)

  1. 1Write the code to generate a band limited 1000Hz sawtooth wave.
    1. A// Call to open the processing output

      if(!ProcessBegin())

      return;



      short audio[2];



      double t = 0;

      for(int i=0; i<SampleFrames(); i++, t+= 1. / SampleRate())

      {

      ProcessReadFrame(audio);

      double mix = 0.5 * audio[0] + 0.5 * audio[1];



      double pongL = sin(2 * M_PI * 5 * t) * 0.5 + 0.5;

      double pongR = 1 - pongL;



      audio[0] = short(audio[0] * pongL);

      audio[1] = short(audio[1] * pongR);



      ProcessWriteFrame(audio);



      // The progress control

      if(!ProcessProgress(double(i) / SampleFrames()))

      break;

      }





      // Call to close the generator output

      ProcessEnd();

      ///////////////////////////////////////////////
    2. Bfor(double time=0.; time < duration; time += 1. / sampleRate)

      {

      double s = 0;

      for(int h=1; h<(sampleRate / (2 * 1000)); h++)

      s += sin(2 * M_PI * h * 1000 * t) / h;



      short sample = short(amplitude *s);

      audio[0] = audio[1] = sample;



      GenerateFrame(audio);

      }
    3. Cdouble COscillator::GetSample()

      {

      double sample = amplitude * sin(radians);

      radians += (2 * M_PI * m_freq1) / m_sampleRate;

      return sample;

      }
    4. Ddouble radians = 0; // For the sine wave

      double samplePeriod = 1. / sampleRate;



      for(double time=0.; time < duration; time += samplePeriod)

      {

      double freq = 100 + (1000 - 100) * time / 10;



      short sample = short(amplitude * sin(radians));

      audio[0] = audio[1] = sample;



      // Increment the phases

      radians += (2 * M_PI * freq) / sampleRate;



      GenerateFrame(audio);

      }

      /////////////////////////////////////////////////////////////////////////////

Informationen

Beschreibung
CEO/Managing Director Multimedia Computign Quiz am Ohne Titel, erstellt von Laurenz h am 10/11/2021.
Sprache
Deutsch
Aufrufe
0
Schlagwörter
multimedia computignceo/managing director
Bewertung
Noch keine Bewertungen
Bewerte dieses Quiz
Bewerte dieses Quiz

Feedback

Worum geht es?

Wie gefällt dir das neue Design?

Dein Eindruck