Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AudioKit - Drawing full waveform of file

I've been going through documentation looking for an answer for this. I see that AudioKit can draw waveforms for in realtime as you record or playback, but I was wondering if you could load in a file and it draw the waveform in full so I can see the whole file's waveform without playing it back.

Any help would be greatly appreciated. Even just a pointer to what object I should look into.

like image 595
kernelpanic Avatar asked Oct 09 '17 00:10

kernelpanic


2 Answers

You can also use the Objective C EZAudioPlot class which is in AudioKitUI:

let file = EZAudioFile(url: url)
guard let data = file?.getWaveformData() else { return }

let waveform = EZAudioPlot()
addSubview( waveform )
waveform.frame = NSMakeRect(0, 0, 200, 20)
waveform.plotType = EZPlotType.buffer
waveform.shouldFill = true
waveform.shouldMirror = true
waveform.color = NSColor.black
waveform.updateBuffer( data.buffers[0], withBufferSize: data.bufferSize )

I haven't benchmarked the two methods, but the plot version is very fast for longer files. For stereo files, make two stacked plots using buffers[0] and [1]

like image 64
Ryan Francesconi Avatar answered Nov 19 '22 14:11

Ryan Francesconi


there is a waveform that is drawn in the tables playground example here: http://audiokit.io/playgrounds/Basics/Tables/

Basically:

let file = try AKAudioFile(readFileName: "drumloop.wav")
let fileTable = AKTable(file: file)
...UI set up...
addView(AKTableView(fileTable))
like image 3
Aurelius Prochazka Avatar answered Nov 19 '22 14:11

Aurelius Prochazka