How is audio represented with numbers in computers?

后端 未结 10 1174
野的像风
野的像风 2020-11-29 16:50

I like thinking about how everything can be and is represented by numbers. For example, plaintext is represented by a code like ASCII, and images are represented by RGB valu

10条回答
  •  有刺的猬
    2020-11-29 17:39

    I think a good way to start playing with audio would be with Processing and Minim. This program will draw the frequency spectrum of sound from your microphone!

    import ddf.minim.*;
    import ddf.minim.analysis.*;
    
    AudioInput in;
    FFT fft;
    
    void setup()
    {
      size(1024, 600);
      noSmooth();
      Minim.start(this);
      in = Minim.getLineIn();
      fft = new FFT(in.bufferSize(), in.sampleRate());
    }
    
    void draw()
    {
      background(0);
      fft.forward(in.mix);
      stroke(255);
      for(int i = 0; i < fft.specSize(); i++)
        line(i*2+1, height, i*2+1, height - fft.getBand(i)*10);
    }
    
    void stop()
    {
      in.close();
      Minim.stop();
      super.stop();
    }
    

提交回复
热议问题