Giter VIP home page Giter VIP logo

Comments (1)

swharden avatar swharden commented on May 26, 2024

Hi DeltaImpact, It's hard to assemble the high-level sequence of what is going on by looking at the code alone. I hope this brief summary helps clarify the topic and answer your question! I don't have the variable names memorized, but I think the terms I use will be general enough you may be able to figure them out if you understand these concepts. Note that I am referencing the microphone spectrograph source code for this example

  • a list of PCM audio values is added to List<short> unanalyzed_values every time a new audio buffer is completed
    • when waveIn.StartRecording() is called, the sound recorder starts filling-up the audio buffer
    • every time the buffer is full, Audio_buffer_captured() gets run (which adds the latest buffer to unanalyzed_values)
    • if a high frame-rate of updates is required, it's important to get a high rate of completed buffers per second (since the data is only updated when a buffer completes). That's why the waveIn.BufferMilliseconds = 1000 / buffer_update_hz line is important.
  • timer1 periodically looks at the analyzes PCM data and analyzes it when it's long enough
    • analysis always slightly lags behind recording, usually by 1-2 buffer lengths
    • if analysis falls behind (CPU load issues), excessively old analyzed data is deleted to lighten the load. However, this should only occur in near-error-like conditions, and is a fail-safe to prevent slowness or crashing.
    • analysis analyzes the last "chunk" of audio, which could be the buffer size itself or some other size. The chunk is probably the FFT size.
    • There is a 1:2 relationship between the input PCM data length and the output FFT data in my code. This is because I collapse the real and imaginary data into a single FFT array. A 1000 point PCM array analyzed in this way will produce a FFT with 500 points.
    • FFT analysis benefits from "windowing" the sample so its edges approach zero. Check out this page on windowing, but note that you can do a pretty good job just by applying a triangle-shape window to the data prior to the FFT.
    • when analysis completes, the analyzed data is deleted from the list of unrealized values
    • often spectrographs benefit from having overlapping "chunks" of sequential analysis, therefore it may be desired to delete less data than you actually analyzed, thus forcing partial re-analysis of overlapping data. This produces "smoother" output spectrographs.

I hope these notes help! Let me know if you have additional questions.
Best,
Scott

from csharp-data-visualization.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.