7

I am using AudioKit in my project. By using the process suggested in the mixing nodes playground example, I am playing the multiple audios. My requirement is to upload the mixed audio to the server and displayed and played some other screens. I followed this suggestion. How to get and save the mixed of multiple audios in to single audio in swift but it's not working.

Give suggestions to get the mixed audio output for uploading to the server.

Aurelius Prochazka
  • 4,510
  • 2
  • 11
  • 34
Ajay
  • 185
  • 3
  • 18

1 Answers1

1

AudioKit provides a node recorder that can be attached to any node in your signal chain (though it seems to prefer being connected to mixer nodes).

First set up a place for the recording to be kept:

let file = try AKAudioFile()

Then assign a recorder to record to that file

let recorder = try AKNodeRecorder(node: nodeYouWantToRecord, file: file)

Start recording:

try recorder.record()

Stop recording at a later time:

recorder.stop()

Then save your file:

file.exportAsynchronously(name: "nameString",
                          baseDir: .documents,
                          exportFormat: .caf) { [weak self] _, _ in
          // optional do something after exporting
        }

Check out how this playground saves the AudioKit output: https://audiokit.io/playgrounds/Basics/Mixing%20Nodes/

Aurelius Prochazka
  • 4,510
  • 2
  • 11
  • 34
  • Hi @Aurelius Prochazka, – Ajay Dec 20 '18 at 06:31
  • I want the Mixer output(multiple audios playing at a time output ) as an audio file from the above link. Give suggestions to get that Mixer output as a single audio file to save in local directory. – Ajay Dec 20 '18 at 06:45
  • 1
    @Aure i'm new to AudioKit is there anyway to take multiple files add them to a mixer and export that mixer without having to go through realtime recording? – Sam Bing Jan 07 '19 at 20:04