mirror of
https://github.com/bitgapp/eqMac.git
synced 2024-11-27 02:02:15 +03:00
commit before trying to move volume to Output class
This commit is contained in:
parent
59990df83b
commit
2711dc8d3e
@ -39,3 +39,5 @@ player.scheduleBuffer(buffer, at: AVAudioTime(hostTime: 0), options:.loops, comp
|
|||||||
DispatchQueue.main.asyncAfter(deadline: .now() + 5, execute: {
|
DispatchQueue.main.asyncAfter(deadline: .now() + 5, execute: {
|
||||||
mixer.pan = -1
|
mixer.pan = -1
|
||||||
})
|
})
|
||||||
|
|
||||||
|
let unit = mixer.auAudioUnit.component
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
version = "3.0">
|
version = "3.0">
|
||||||
<TimelineItems>
|
<TimelineItems>
|
||||||
<LoggerValueHistoryTimelineItem
|
<LoggerValueHistoryTimelineItem
|
||||||
documentLocation = "file:///Users/nodeful/Programming/Bitgapp/eqMac/native/app/Sandbox.playground#CharacterRangeLen=57&CharacterRangeLoc=494&EndingColumnNumber=0&EndingLineNumber=19&StartingColumnNumber=32&StartingLineNumber=16&Timestamp=645295599.40888"
|
documentLocation = "file:///Users/nodeful/Programming/Bitgapp/eqMac/native/app/Sandbox.playground#CharacterRangeLen=57&CharacterRangeLoc=494&EndingColumnNumber=0&EndingLineNumber=19&StartingColumnNumber=32&StartingLineNumber=16&Timestamp=645400816.412694"
|
||||||
selectedRepresentationIndex = "0"
|
selectedRepresentationIndex = "0"
|
||||||
shouldTrackSuperviewWidth = "NO">
|
shouldTrackSuperviewWidth = "NO">
|
||||||
</LoggerValueHistoryTimelineItem>
|
</LoggerValueHistoryTimelineItem>
|
||||||
|
@ -115,12 +115,12 @@ class Engine {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func chainVolumeToSink () {
|
private func chainVolumeToSink () {
|
||||||
engine.connect(volume.output, to: engine.mainMixerNode, format: format)
|
engine.connect(volume.booster, to: engine.mainMixerNode, format: format)
|
||||||
}
|
}
|
||||||
|
|
||||||
private func setupRenderCallback () {
|
private func setupRenderCallback () {
|
||||||
Console.log("Setting up Input Render Callback")
|
Console.log("Setting up Input Render Callback")
|
||||||
let lastAVUnit = effects.equalizers.active.eq as AVAudioUnit
|
let lastAVUnit = volume.booster as AVAudioUnit
|
||||||
if let err = checkErr(AudioUnitAddRenderNotify(lastAVUnit.audioUnit,
|
if let err = checkErr(AudioUnitAddRenderNotify(lastAVUnit.audioUnit,
|
||||||
renderCallback,
|
renderCallback,
|
||||||
UnsafeMutableRawPointer(Unmanaged<Engine>.passUnretained(self).toOpaque()))) {
|
UnsafeMutableRawPointer(Unmanaged<Engine>.passUnretained(self).toOpaque()))) {
|
||||||
|
@ -20,8 +20,8 @@ class Volume: StoreSubscriber {
|
|||||||
|
|
||||||
var engine: AVAudioEngine?
|
var engine: AVAudioEngine?
|
||||||
|
|
||||||
|
var booster = AVAudioUnitEQ()
|
||||||
var mixer = AVAudioMixerNode()
|
var mixer = AVAudioMixerNode()
|
||||||
var output = AVAudioUnitEQ()
|
|
||||||
|
|
||||||
// MARK: - Properties
|
// MARK: - Properties
|
||||||
var gain: Double = 1 {
|
var gain: Double = 1 {
|
||||||
@ -33,9 +33,9 @@ class Volume: StoreSubscriber {
|
|||||||
if (gain <= 1) {
|
if (gain <= 1) {
|
||||||
if (volumeSupported) {
|
if (volumeSupported) {
|
||||||
device.setVirtualMasterVolume(Float32(gain), direction: .playback)
|
device.setVirtualMasterVolume(Float32(gain), direction: .playback)
|
||||||
output.globalGain = 0
|
booster.globalGain = 0
|
||||||
} else {
|
} else {
|
||||||
output.globalGain = Float(Utilities.mapValue(value: gain, inMin: 0, inMax: 1, outMin: -96, outMax: 0))
|
booster.globalGain = Float(Utilities.mapValue(value: gain, inMin: 0, inMax: 1, outMin: -96, outMax: 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (balanceSupported) {
|
if (balanceSupported) {
|
||||||
@ -47,11 +47,11 @@ class Volume: StoreSubscriber {
|
|||||||
|
|
||||||
Driver.device!.setVirtualMasterVolume(Float32(gain), direction: .playback)
|
Driver.device!.setVirtualMasterVolume(Float32(gain), direction: .playback)
|
||||||
|
|
||||||
} else {
|
} else { // gain > 1
|
||||||
if (volumeSupported) {
|
if (volumeSupported) {
|
||||||
device.setVirtualMasterVolume(1.0, direction: .playback)
|
device.setVirtualMasterVolume(1.0, direction: .playback)
|
||||||
}
|
}
|
||||||
output.globalGain = Float(Utilities.mapValue(value: gain, inMin: 1, inMax: 2, outMin: 0, outMax: 12))
|
booster.globalGain = Float(Utilities.mapValue(value: gain, inMin: 1, inMax: 2, outMin: 0, outMax: 12))
|
||||||
|
|
||||||
if (balanceSupported) {
|
if (balanceSupported) {
|
||||||
device.setVirtualMasterBalance(Float32(Utilities.mapValue(value: balance, inMin: -1, inMax: 1, outMin: 0, outMax: 1)), direction: .playback)
|
device.setVirtualMasterBalance(Float32(Utilities.mapValue(value: balance, inMin: -1, inMax: 1, outMin: 0, outMax: 1)), direction: .playback)
|
||||||
@ -78,8 +78,7 @@ class Volume: StoreSubscriber {
|
|||||||
Application.ignoreNextVolumeEvent = false
|
Application.ignoreNextVolumeEvent = false
|
||||||
Application.ignoreNextDriverMuteEvent = false
|
Application.ignoreNextDriverMuteEvent = false
|
||||||
|
|
||||||
mixer.pan = Float(gain)
|
Console.log("Boost: \(booster.globalGain) Mix: \(mixer.pan)")
|
||||||
Console.log(mixer.pan)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -172,10 +171,10 @@ class Volume: StoreSubscriber {
|
|||||||
self.engine = engine
|
self.engine = engine
|
||||||
let format = engine.inputNode.inputFormat(forBus: 0)
|
let format = engine.inputNode.inputFormat(forBus: 0)
|
||||||
|
|
||||||
|
engine.attach(booster)
|
||||||
engine.attach(mixer)
|
engine.attach(mixer)
|
||||||
engine.attach(output)
|
|
||||||
|
|
||||||
engine.connect(mixer, to: output, format: format)
|
engine.connect(mixer, to: booster, format: format)
|
||||||
}
|
}
|
||||||
|
|
||||||
func postSetup () {
|
func postSetup () {
|
||||||
|
Loading…
Reference in New Issue
Block a user