Monday, April 29, 2024
HomeiOS Developmentios - Utilizing DCT to create real-time "ranges" animation for microphone enter

ios – Utilizing DCT to create real-time “ranges” animation for microphone enter


For context: I am making an attempt to create a easy “stage monitor” animation of audio knowledge streaming from a microphone. I am operating this code on an iOS system and leaning closely on the Speed up framework for knowledge processing.

Loads of what I’ve thus far is closely influenced by this instance challenge from Apple: https://developer.apple.com/documentation/speed up/visualizing_sound_as_an_audio_spectrogram

Listed here are the present steps I am taking:

  1. Begin receiving (Int16) samples from the microphone utilizing AVFoundation.
  2. Retailer samples till I’ve at the least 1024, then ship the primary 1024 samples to my processing algorithm.
  3. Convert samples to denormalized Float (single-precision floating level).
  4. Apply a Hanning Window to the samples to forestall aliasing because the variety of samples is pretty low, for efficiency causes.
  5. Run a Ahead DCT-II transformation of the time-domain samples into frequency-domain samples.
  6. Absolute worth on all samples.
  7. “Bin” the samples to match the variety of bars I’ve to animate… for every 1024/n samples, discover the utmost worth in every vary.
  8. Normalize every of the bins into the 0…1 vary by dividing every by the best magnitude pattern that has been encountered, globally.

Truthfully, after step 5, I simply haven’t any intuitive understanding of what’s going on with the frequency area values. I get {that a} larger worth means the frequency represented by a single worth is extra prevalent within the time-domain knowledge… however I do not know what a worth of, say 12 vs 6492 means.

Anyway, the tip result’s that the bottom bin (0…255) has an influence that’s principally simply the general amplitude, whereas the upper 3 bins by no means rise above 0.001. I really feel like I am heading in the right direction, however that my ignorance of what the DCT output means is stopping me from determining what goes improper right here. I might additionally use FFT, if that may produce a greater consequence, however I am given to grasp that FFT and DCT produce analogous outcomes and Apple recommends DCT for efficiency.



Supply hyperlink

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments