Post not yet marked as solved
I'm writing a little helper app that sends mouse clicks and keystrokes. It is extremely cumbersome, because whenever I change some code I have to grant it permissions again in the Accessibility section in the "Security & Privacy" system preferences. I have to try out a lot of things to see if and how they work and every time I have to switch to the system preferences, delete the old version of my app, compile and run the new version in Xcode, switch to system preferences again, grant permissions and then I can finally switch to my app to try it out. While this is fine for the finished product, is there any way I can avoid this during development? Otherwise writing such an app would be practically impossible. I really need to be able to just run it after a recompile.
Post not yet marked as solved
I' just installed Xcode 13 and try to run a playground that uses a package (https://github.com/AudioKit/AudioKit). To add it I'm supposd to select "File -> Add Packages...", but when I do this absolutely nothing happens. No window appears, no error message, just nothing. What could be the reason for this?
Post not yet marked as solved
I'm trying to play a sine sound for as long as the user wants it. So my plan is to use two buffers. Fill one buffer, play it and while it plays fill the second buffer and then switch between those two. But I always get audio jumps when switching the buffers, I can't get a continuous sound. Could someone look at my code and tell me what I'm doing wrong? The audio data is correct, when I schedule a bunch of buffers in a row a get a smooth sound.
import Foundation
import AVFoundation
var engine = AVAudioEngine()
var player = AVAudioPlayerNode()
var mixer = engine.mainMixerNode;
var dq = DispatchQueue(label: "Sine")
let sampleRate = mixer.outputFormat(forBus: 0).sampleRate
let samplesOfAudio = UInt32 (10000)
var buffer1 = AVAudioPCMBuffer(pcmFormat: (player.outputFormat(forBus: 0)), frameCapacity: samplesOfAudio)!
var buffer2 = AVAudioPCMBuffer(pcmFormat: (player.outputFormat(forBus: 0)), frameCapacity: samplesOfAudio)!
var f = 440.0
var s = UInt32(0) //current sample
let s2t = 2.0 * Double.pi / sampleRate //sample number to time conversion factor
func fillBuffer(buffer: AVAudioPCMBuffer) {
let leftChannel = buffer.floatChannelData![0]
let rightChannel = buffer.floatChannelData![1]
for i in 0 ..< samplesOfAudio {
let v = sin(f * Double(s) * s2t) * 0.2
leftChannel[Int(i)] = Float(v)
rightChannel[Int(i)] = Float(v)
s = s + 1
}
}
func playSine() {
engine.attach(player)
engine.connect(player, to: mixer, format: player.outputFormat(forBus: 0))
do{
try engine.start()
} catch {
}
buffer1.frameLength = samplesOfAudio
buffer2.frameLength = samplesOfAudio
fillBuffer(buffer: buffer1)
var nextBuffer = buffer1
let semaphore = DispatchSemaphore(value: 0)
dq.async {
while true {
player.scheduleBuffer(nextBuffer) {
semaphore.signal()
}
if(nextBuffer == buffer1) {
nextBuffer = buffer2
} else {
nextBuffer = buffer1
}
fillBuffer(buffer: nextBuffer)
semaphore.wait()
}
}
player.play()
}
Post not yet marked as solved
After I update the height of my view I get the following error message in the console:
2022-03-23 18:38:35.093236+0100 Moiree[10522:931302] [Layout] Unable to simultaneously satisfy constraints:
(
"<NSLayoutConstraint:0x61000008c3f0 NSView:0x6080001201e0.height == 2280 (active)>",
"<NSLayoutConstraint:0x61800008ae60 NSView:0x6080001201e0.height == 2760 (active)>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x61800008ae60 NSView:0x6080001201e0.height == 2760 (active)>
How can there be two different height constraints? I set the height with
self.heightAnchor.constraint(equalToConstant: newValue)
Shouldn't that just update the height constraint that is already there?
Thanks and regards, Sebastian