File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 5
5
// Created by Bastien Falcou on 12/6/16.
6
6
//
7
7
8
+ import AVFoundation
8
9
import UIKit
9
10
10
11
public class AudioVisualizationView : BaseNibView {
@@ -149,6 +150,22 @@ public class AudioVisualizationView: BaseNibView {
149
150
return self . meteringLevelsClusteredArray
150
151
}
151
152
153
+ // PRAGMA: - Analyze Sound File
154
+
155
+ private func buffer( url: URL ) {
156
+ do {
157
+ let track = try AVAudioFile ( forReading: url)
158
+ let format = AVAudioFormat ( commonFormat: . pcmFormatFloat32,
159
+ sampleRate: track. fileFormat. sampleRate,
160
+ channels: track. fileFormat. channelCount,
161
+ interleaved: false )
162
+ let buffer = AVAudioPCMBuffer ( pcmFormat: format!, frameCapacity: UInt32 ( track. length) ) !
163
+ try track. read ( into : buffer, frameCount: UInt32 ( track. length) )
164
+ } catch {
165
+ print ( error)
166
+ }
167
+ }
168
+
152
169
// PRAGMA: - Play Mode Handling
153
170
154
171
public func play( for duration: TimeInterval ) {
You can’t perform that action at this time.
0 commit comments