Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift implementation (IOS Equalizer) #658

Closed
wants to merge 41 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6d314f9
initial structure for reimplementation ios and macos
toonvanstrijpwavy Nov 13, 2021
4f075a9
add all methods and basic structure
toonvanstrijpwavy Nov 15, 2021
51daf6f
Add AudioKit dependency
toonvanstrijpwavy Nov 15, 2021
21ed336
WIP: Basic Audio player functionalities
toonvanstrijpwavy Nov 18, 2021
c98daf7
add orderUpdate
toonvanstrijpwavy Nov 18, 2021
007b2e1
WIP: Audikit
toonvanstrijp Nov 19, 2021
f42a6b9
Merge pull request #1 from ToonvanStrijp/feature/new_ios_implementation
toonvanstrijp Nov 19, 2021
dbfd803
Remove audiokit
toonvanstrijpwavy Nov 19, 2021
2b01391
Add todo's
toonvanstrijp Nov 19, 2021
a8bf916
Merge branch 'feature/new_ios_implementation' of github.com:wavy-assi…
toonvanstrijp Nov 19, 2021
10a97ce
add volume and speed to audio engine
toonvanstrijp Nov 22, 2021
f616dd4
generic equalizer in dart for android and darwin
toonvanstrijp Nov 30, 2021
6009b97
Merge pull request #2 from ToonvanStrijp/feature/new_ios_implementation
toonvanstrijp Nov 30, 2021
42fbce1
Update pubspec.yaml
toonvanstrijpwavy Nov 30, 2021
b53cfde
Update pubspec.yaml
toonvanstrijpwavy Nov 30, 2021
09a90b4
Update pubspec.yaml
toonvanstrijpwavy Nov 30, 2021
699c054
Update pubspec.yaml
toonvanstrijpwavy Nov 30, 2021
14745c0
export interface
toonvanstrijpwavy Nov 30, 2021
86873c3
fix
toonvanstrijpwavy Nov 30, 2021
e357ec3
add symbolic linking
toonvanstrijpwavy Nov 30, 2021
a4ae09d
IDK what i did
toonvanstrijpwavy Nov 30, 2021
397c319
IDK what i did
toonvanstrijpwavy Nov 30, 2021
3565a36
add import
toonvanstrijpwavy Nov 30, 2021
188d74c
add dispose
toonvanstrijpwavy Dec 1, 2021
5b49f01
stop player to reset current time
toonvanstrijpwavy Dec 1, 2021
6b2d8fa
Fix play song with ipod library
BreX900 Jan 25, 2022
a98309e
fix seek
Jan 25, 2022
c5ac25c
move seek implementation in load method
BreX900 Feb 1, 2022
05bd085
fix pause/play after seek move
BreX900 Feb 1, 2022
3c91dd9
reorganize code
BreX900 Feb 1, 2022
bd619b8
ALign properties to CMTime
BreX900 Feb 1, 2022
1dcfe29
Moved player methods in to Player class
BreX900 Feb 1, 2022
d21bc72
fix seek when use it not from first song
BreX900 Feb 1, 2022
d3325df
fix seek play with paused player
BreX900 Feb 1, 2022
b0b6c9a
fix play next audio when audio is finished
BreX900 Feb 1, 2022
fedf2f8
Equalize the level between ios and android
BreX900 Feb 2, 2022
3eab300
Remove .idea folders and vscode folder
BreX900 Feb 8, 2022
b560b17
fix local audio load
BreX900 Feb 22, 2022
0b1ae5c
Fix playing when device output changed
BreX900 Feb 25, 2022
d318903
fix not work shuffle and loop when song end
BreX900 Feb 25, 2022
d18efd5
Fix load initialIndex
BreX900 Feb 28, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -755,29 +755,39 @@ private void loudnessEnhancerSetTargetGain(double targetGain) {
((LoudnessEnhancer)audioEffectsMap.get("AndroidLoudnessEnhancer")).setTargetGain(targetGainMillibels);
}

// dB = 0.1 bels | 0.8 = Equalize the level between ios and android
private short dbToMillibels(double value) {
return (short)(Math.round(value * 100.0 * 0.8));
}

// dB = 0.1 bels | 0.8 = Equalize the level between ios and android
private double millibelsToDb(int value) {
return (double)(Math.round(value / 100.0 / 0.8));
}

private Map<String, Object> equalizerAudioEffectGetParameters() {
Equalizer equalizer = (Equalizer)audioEffectsMap.get("AndroidEqualizer");
ArrayList<Object> rawBands = new ArrayList<>();
for (short i = 0; i < equalizer.getNumberOfBands(); i++) {
rawBands.add(mapOf(
"index", i,
"lowerFrequency", (double)equalizer.getBandFreqRange(i)[0] / 1000.0,
"upperFrequency", (double)equalizer.getBandFreqRange(i)[1] / 1000.0,
"centerFrequency", (double)equalizer.getCenterFreq(i) / 1000.0,
"gain", equalizer.getBandLevel(i) / 1000.0
"lowerFrequency", millibelsToDb(equalizer.getBandFreqRange(i)[0]),
"upperFrequency", millibelsToDb(equalizer.getBandFreqRange(i)[1]),
"centerFrequency", millibelsToDb(equalizer.getCenterFreq(i)),
"gain", millibelsToDb(equalizer.getBandLevel(i))
));
}
return mapOf(
"parameters", mapOf(
"minDecibels", equalizer.getBandLevelRange()[0] / 1000.0,
"maxDecibels", equalizer.getBandLevelRange()[1] / 1000.0,
"minDecibels", millibelsToDb(equalizer.getBandLevelRange()[0]),
"maxDecibels", millibelsToDb(equalizer.getBandLevelRange()[1]),
"bands", rawBands
)
);
}

private void equalizerBandSetGain(int bandIndex, double gain) {
((Equalizer)audioEffectsMap.get("AndroidEqualizer")).setBandLevel((short)bandIndex, (short)(Math.round(gain * 1000.0)));
((Equalizer)audioEffectsMap.get("AndroidEqualizer")).setBandLevel((short)bandIndex, dbToMillibels(gain));
}

/// Creates an event based on the current state.
Expand Down
1,328 changes: 0 additions & 1,328 deletions just_audio/darwin/Classes/AudioPlayer.m

This file was deleted.

36 changes: 0 additions & 36 deletions just_audio/darwin/Classes/AudioSource.m

This file was deleted.

37 changes: 37 additions & 0 deletions just_audio/darwin/Classes/AudioSource.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import AVFoundation

class AudioSource {
let sourceId: String

init(sid: String) {
sourceId = sid
}

func buildSequence() -> Array<IndexedAudioSource> {
return []
}

func getShuffleIndices() -> [Int] {
return []
}

static func fromListJson(_ data: [[String: Any]]) throws -> [AudioSource] {
return try data.map { item in
try AudioSource.fromJson(item)
}
}

static func fromJson(_ data: [String: Any]) throws -> AudioSource {
let type = data["type"] as! String

switch type {
case "progressive":
return UriAudioSource(sid: data["id"] as! String, uri: data["uri"] as! String)
case "concatenating":
return ConcatenatingAudioSource(sid: data["id"] as! String, audioSources: try AudioSource.fromListJson(data["children"] as! [Dictionary<String, Any>]), shuffleOrder: data["shuffleOrder"] as! Array<Int>)
default:
throw PluginError.notSupported(type, "When decoding audio source")
}
}

}
37 changes: 0 additions & 37 deletions just_audio/darwin/Classes/BetterEventChannel.m

This file was deleted.

30 changes: 30 additions & 0 deletions just_audio/darwin/Classes/BetterEventChannel.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import Flutter

class BetterEventChannel: NSObject, FlutterStreamHandler {
let eventChannel: FlutterEventChannel
var eventSink: FlutterEventSink?

init(name: String, messenger: FlutterBinaryMessenger) {
eventChannel = FlutterEventChannel(name: name, binaryMessenger: messenger)
super.init()
eventChannel.setStreamHandler(self)
}

func onListen(withArguments _: Any?, eventSink events: @escaping FlutterEventSink) -> FlutterError? {
eventSink = events
return nil
}

func onCancel(withArguments _: Any?) -> FlutterError? {
eventSink = nil
return nil
}

func sendEvent(_ event: Any) {
eventSink?(event)
}

func dispose() {
eventChannel.setStreamHandler(nil)
}
}
113 changes: 0 additions & 113 deletions just_audio/darwin/Classes/ClippingAudioSource.m

This file was deleted.

92 changes: 0 additions & 92 deletions just_audio/darwin/Classes/ConcatenatingAudioSource.m

This file was deleted.

Loading