2

I am using Audiokit in my project and recently I updated my Xcode 9.3. It says i need to update Audiokit as well. But when I updated, it seems I need to use try catch to start and stop audio kit. this is fine.

    oscillator = AKFMOscillator()
    oscillator!.amplitude = 0.0
    oscillator!.baseFrequency = Double(calibration.frequency)
    oscillator!.carrierMultiplier = 1.0
    oscillator!.modulatingMultiplier = HolmesMethod.warbleModulationFrequency / Double(calibration.frequency)
    oscillator!.modulationIndex = HolmesMethod.warbleModulationIndex
    oscillator!.rampTime = HolmesMethod.clickMillis / 1000.0


    AudioKit.output = panner
    do {
        try AudioKit.start()
    } catch  {
    }

    oscillator!.start()

    panner = AKPanner(oscillator, pan: calibration.channel == .Right ? 1.0 : -1.0)
    panner?.start()

can anyone please tell me what is wrong with my code? because it's working in the old version but not in the latest version.

Maulik Vekariya
  • 554
  • 7
  • 19

2 Answers2

1

It looks to me like you've set the oscillator's amplitude to zero so I am not sure what you're expecting to hear.

Aurelius Prochazka
  • 4,510
  • 2
  • 11
  • 34
1

After too much effort I found that we need to start oscillator once AudioKit start.

oscillator = AKFMOscillator()
oscillator!.baseFrequency = Double(calibration.frequency)
    oscillator!.carrierMultiplier = 1.0
    oscillator!.modulatingMultiplier = HolmesMethod.warbleModulationFrequency / Double(calibration.frequency)
    oscillator!.modulationIndex = HolmesMethod.warbleModulationIndex
    oscillator!.rampDuration = HolmesMethod.clickMillis / 1000.0


    panner = AKPanner(oscillator, pan: calibration.channel == .Right ? 1.0 : -1.0)
    AudioKit.output = panner
    do {
        try AudioKit.start()
        } catch  {
    }

    oscillator!.start()
    panner?.start()

But here i got some weird sound for once second at the time of AudioKit Start.

Maulik Vekariya
  • 554
  • 7
  • 19