简体   繁体   中英

representing sound graphically as wave

I Have created an app that records and plays sound and I am looking for a way of showing a simple wave representation of the recorded sound, no animation is necessary, just a simple graph.

It would also be nice it is was possible to select a subset of the wave and ofcourrse even more nice playing that section aswell.

To sum up, what I'm looking for:

  1. A way of graphically represent a recorded sound as a wave (eg as seen in audacity)
  2. A way of graphically selecting a subset of the wave representation.

And to clarify a bit further of what I'm looking for:

  1. If there is a lib for this I'd be insanely happy :)
  2. A hint on what components to best use for handling the graph drawing.
  3. A tip on how to handle the selection within the graphical component.

I already did this in another application and have been struggling with it for a while ...

You would divide the number of samples the audio file has by the number of pixels you have to display the graph. This gives you a chunksize. For all the "buckets" you calculate the min and max value and display them in relation to the sample resolution used.

Can provide further examples if needed.


Regarding the graphics stuff: (I am not an iOS developer but Mac programming isn't that much different I think.) Just create a subclass of NSView ( should be UIView in iOS ) and override the drawRect method. Then just create a function which you pass an array of values for your file and draw a bunch of lines to the screen. It's no black magic here!!

This is really nothing you would need a library for! And, as another positive aspect : if you keep it generic enough you can always reuse it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM