Skip to content

Commit

Permalink
update maxPointsCount -> maxSamplesCount
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrewmika committed Sep 20, 2020
1 parent b5acff1 commit 9ee0f1a
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion ASAudioWaveformView.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

Pod::Spec.new do |s|
s.name = 'ASAudioWaveformView'
s.version = '1.0.0'
s.version = '1.0.1'
s.summary = 'a simple and easy way to create audio waveform view'

# This description is used to generate tags and improve search results.
Expand Down
10 changes: 5 additions & 5 deletions ASAudioWaveformView/Classes/ASAudioWaveformView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public class ASAudioWaveformConfig {
var contentType: ASAudioWaveformView.ContentType = .polyLine
var fillColor: UIColor = .yellow
var audioURL: URL?
var maxPointsCount: Int = 600
var maxSamplesCount: Int = 600

/// config waveform postion, the default is center
@discardableResult
Expand Down Expand Up @@ -45,8 +45,8 @@ public class ASAudioWaveformConfig {

/// config max samples count, the default is 1000
@discardableResult
public func maxPointsCount(_ count: Int) -> ASAudioWaveformConfig {
maxPointsCount = count
public func maxSamplesCount(_ count: Int) -> ASAudioWaveformConfig {
maxSamplesCount = count
return self
}
}
Expand Down Expand Up @@ -93,7 +93,7 @@ public class ASAudioWaveformView: UIView {
guard !frame.size.equalTo(.zero), let URL = waveformConfig.audioURL else {
return
}
ASAudioWaveformDataFactory.loadAudioWaveformData(from: URL, formateSize: (waveformConfig.maxPointsCount, frame.height * 0.5)) { (samples, assetData) in
ASAudioWaveformDataFactory.loadAudioWaveformData(from: URL, formateSize: (waveformConfig.maxSamplesCount, frame.height * 0.5)) { (samples, assetData) in
self.filteredSamples = samples
self.drawWaveform()
}
Expand All @@ -107,7 +107,7 @@ public class ASAudioWaveformView: UIView {
return
}
waveformConfig.audioURL = audioURL
ASAudioWaveformDataFactory.loadAudioWaveformData(from: url, formateSize: (waveformConfig.maxPointsCount, frame.height * 0.5)) { (samples, waveData) in
ASAudioWaveformDataFactory.loadAudioWaveformData(from: url, formateSize: (waveformConfig.maxSamplesCount, frame.height * 0.5)) { (samples, waveData) in
self.filteredSamples = samples
self.drawWaveform()
}
Expand Down
4 changes: 2 additions & 2 deletions Example/ASAudioWaveformView/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class ViewController: UIViewController {
// Do any additional setup after loading the view, typically from a nib.
wave = ASAudioWaveformView.create(frame: CGRect(x: 0, y: 40, width: view.frame.width, height: 100)) { (config) in
let url = Bundle.main.url(forResource: "test", withExtension: "mp3")
config.audioURL(url).maxPointsCount(500).fillColor(.systemTeal)
config.audioURL(url).maxSamplesCount(500).fillColor(.systemTeal)
}
wave.backgroundColor = .blue
self.view.addSubview(wave)
Expand All @@ -37,7 +37,7 @@ class ViewController: UIViewController {

wave3.createWaveform { (config) in
let url = Bundle.main.url(forResource: "test", withExtension: "mp3")
config.audioURL(url).contentType(.singleLine).maxPointsCount(500).fillColor(.red)
config.audioURL(url).contentType(.singleLine).maxSamplesCount(300).fillColor(.red)
}

}
Expand Down
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pod 'ASAudioWaveformView'
```swift
let wave = ASAudioWaveformView.create(frame: CGRect(x: 0, y: 40, width: 200, height: 100)) { (config) in
let url = Bundle.main.url(forResource: "test", withExtension: "mp3")
config.audioURL(url).maxPointsCount(500).fillColor(.systemTeal)
config.audioURL(url).maxSamplesCount(500).fillColor(.systemTeal)
}
```
2. if you use Autolayout or set the frame later
Expand Down Expand Up @@ -58,12 +58,12 @@ pod 'ASAudioWaveformView'
public func audioURL(_ URL: URL?) -> ASAudioWaveformConfig

/// config max samples count, the default is 1000
public func maxPointsCount(_ count: Int) -> ASAudioWaveformConfig
public func maxSamplesCount(_ count: Int) -> ASAudioWaveformConfig
```
1. position type center, content type polyLine
![center](https://raw.githubusercontent.com/Andrewmika/MyPicBed/master/img/center.png)
![center](https://raw.githubusercontent.com/Andrewmika/MyPicBed/master/img/center.png)
2. position type top, content type polyLine
Expand Down

0 comments on commit 9ee0f1a

Please sign in to comment.