有没有一种方法可以减弱AKOperationGenerator发出的声音?
例如,在.start()下面的代码中,单击时会以全幅值开始。
let whiteNoiseGenerator = AKOperationGenerator { _ in
let white = AKOperation.whiteNoise()
return white
}
AudioKit.output = whiteNoiseGenerator
whiteNoiseGenerator.start()
Run Code Online (Sandbox Code Playgroud) 我正在尝试播放声音文件,例如 /Users/NEO/Library/Developer/CoreSimulator/Devices/D21A7767-E6F6-4B43-A76B-DC6E0F628B16/data/Containers/Data/Application/3F8A82F6-739F-40EA-B DF3560D0D8BB/Documents/Remember-When.mp3
我正在使用 AudioKit/Swift 3,这是我的代码:
do {
debugPrint(sound.filePath)
let audioFile = try AKAudioFile(forReading: URL(fileURLWithPath: sound.filePath))
player = try AKAudioPlayer(file: audioFile)
player.play()
}catch let exception {
}
Run Code Online (Sandbox Code Playgroud)
Xcode 崩溃和控制台说:由于未捕获的异常“com.apple.coreaudio.avfaudio”而终止应用程序,原因:“所需条件为假:_engine->IsRunning()”
我尝试过 AVAudioFoundation,所以效果很好。
do {
player = try AVAudioPlayer(contentsOf: URL(fileURLWithPath: sound.filePath))
guard let player = player else { return }
player.prepareToPlay()
player.play()
} catch let error {
print(error.localizedDescription)
}
Run Code Online (Sandbox Code Playgroud)
你能给我一个建议吗?
我正在尝试向我的应用程序添加一项功能,我可以在其中从手机的内置麦克风录制音频,然后同时通过手机的扬声器播放该音频。
首先,我想知道这是否可以通过 AudioKit 实现?
其次,如果可能的话,我可以查看 AudioKit 中的哪些游乐场/示例项目以获取有关如何执行此操作的参考?
我知道可以将音频录制到文件然后播放,我在 Recorder 示例项目中看到了它,但我想要的是实时播放。
感谢您为此提供的任何指导或帮助。
使用AudioKit进行声音管理,我注意到这个非常简单的代码问题(bug?).
import AudioKit
class MainViewController: UIViewController {
var audioFile: AKAudioFile?
var audioPlayer: AKAudioPlayer?
override func viewDidLoad() {
super.viewDidLoad()
}
@IBAction func onPlayButtonClick(_ sender: Any) {
do {
audioFile = try AKAudioFile(forReading: Bundle.main.url(forResource: "3e", withExtension: "mp3")!)
audioPlayer = try AKAudioPlayer(file: audioFile!)
AudioKit.output = audioPlayer
AudioKit.start()
audioPlayer!.play()
} catch {
print(error)
}
}
}
Run Code Online (Sandbox Code Playgroud)
使用play()方法启动播放时,日志和进程中的所有内容都是正常的(播放器持续时间,currentTime).但是我没有听到扬声器中的音频(只有一种风噪声).一旦我插入耳机并再次点击按钮,我通常会听到音频.然后,我拔下我的耳机并点击按钮,我听不到音频(只有风声).
我在iPhone 5S上面对此问题.
我在iPad5上没有面对这个问题,我在模拟器上没有面对这个问题.我没有其他设备尝试重现.
两种设备:iOS 11.1.2和AudioKit:v4.0.4
注意:我的扬声器与任何其他应用程序正常工作,我已经检查了音量.未插入耳机时,默认outputDevice设置为Speakers.
我正在尝试使用receivedMIDINoteOn函数在音序器播放音符时闪烁UILabel.我尝试过使用AKMIDIListener协议但没有成功.我还制作了一个AKMIDISampler子类,并从音序器发送midi.它播放midi但未调用receivedMIDINoteOn.
这就是我在指挥的init()中所拥有的:
init() {
[ahSampler, beeSampler, gooSampler,flasher] >>> samplerMixer
AudioKit.output = samplerMixer
AudioKit.start()
let midi = AKMIDI()
midi.createVirtualPorts()
midi.openInput("Session 1")
midi.addListener(self)
}
Run Code Online (Sandbox Code Playgroud)
导体遵循AKMIDIListener协议
这是功能:永远不会被调用
func receivedMIDINoteOn(noteNumber: MIDINoteNumber, velocity: MIDIVelocity, channel: MIDIChannel)
{
print("got it")
}
Run Code Online (Sandbox Code Playgroud)
这是AKMIDISampler的子类,它获得midi并播放正弦合成器,但是从不调用receivedMIDINoteOn.
class Flasher: AKMIDISampler
{
override func receivedMIDINoteOn(noteNumber: MIDINoteNumber, velocity: MIDIVelocity, channel: MIDIChannel)
{
print("Flasher got it!")
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:我应该使用AKCallbackInstrument类,并覆盖它的start()函数.
我在http://audiokit.io/downloads/上关注Hello World教程视频
一旦我AudioKit.start()在我添加行ViewController.swift我得到错误:
调用可以抛出,但它没有标记'尝试'并且错误未被处理"
我下载了新的AudioKit 4.1并在框架中拖动.
我真的不知道我的节目发生了什么.我曾经在2017年成功运行它.今天它出错了.我尝试更改构建设置,构建阶段.这些都不起作用.


请帮帮我!
有时我需要一些长音符才能在音序器停止后继续播放.
akSequencer.stop() // Need to put some code to ask the question
Run Code Online (Sandbox Code Playgroud)
当AKSequencer停止时,有没有办法保持长音的声音?
这个话题已经被覆盖了无数次,我已经在我以前的应用程序中成功地使用了AKMIDICallbackInstrument旧的AKAppleSequencer。
我开始使用AKSequencer绝对惊人的新功能:优雅的界面,易于使用。但是,我一生都无法弄清楚如何用它处理回调事件。我需要使用回调来触发基于音序器播放的 GUI 事件。
这是我的示例代码:
private func setMetronome(bpm: BPM, beats:Int)
{
sequencer = AKSequencer(targetNode: metronomeSampler)
sequencer.tempo = bpm
sequencer.loopEnabled = false
sequencer.length = Double(beats)
metroCallback.callback = {status, noteNumber, velocity in
if let midiStatus = AKMIDIStatus(byte: status), midiStatus.type != .noteOn { return }
//Do callback stuff here
}
let metroCallbackTrack = sequencer.addTrack(for: metroCallback)
for i in 0..<beats
{
if i == 0
{
sequencer.add(noteNumber: MIDINoteNumber(67), position: Double(i), duration: 1.0)
metroCallbackTrack.add(noteNumber: MIDINoteNumber(67), position: Double(i), …Run Code Online (Sandbox Code Playgroud) 快速摘要:如何将包含Xcode的标头的包含路径添加到.podspec.json文件中?
我正在开发一个Swift项目,我希望将AudioKit作为依赖项包含在内.对于这个项目,我必须添加'use_frameworks!' 在我的Podfile中
所以我在Podfile中添加了我的Pod(主要的repo还没有更新,这就是我直接指向github repo的原因)
pod 'AudioKit', :git => 'https://github.com/niklassaers/AudioKit.git'
Run Code Online (Sandbox Code Playgroud)
并添加我的一个Swift文件
import AudioKit
Run Code Online (Sandbox Code Playgroud)
然后我的编译器会警告我,这CsoundFile.hpp是iostream无法找到的引用.iostream.h在:
/Applications/Xcode62.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/c++/4.2.1/backward/iostream.h
与stdlib.h相比,它位于:
/Applications/Xcode62.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS.sdk/usr/include/stdlib.h
如何将此标头目录添加到AudioKit.podspec.json(我已经分叉)的搜索路径中.
我已经制作了一个示例项目来演示我在上面所写的内容:https://github.com/niklassaers/AudioKitSwiftFrameworkError - 您可以下载并编译它,您将看到错误消息.