Phase PushStreamNode audio format

I am currently building an app using PHASE, and I am using a PUSHStreamNode as an asset since the audio data I am using is coming from a stream. I produce from this stream 1 channel, 48kHz sample rate pcm buffers.

I can create the node and the event, but when I start the engine (without even providing any data to the streams), I get the following error: Fatal Action tree data error: push stream data has invalid audio format, layoutTag = 0x0.

I tried changing the format provided to PHASEPushStreamNodeDefinition, but it didn't help. Is there a specific AVAudioFormat that I need to use?

My code to create the PushStreamNode:

let source = PHASESource(engine: self.engine)

do { try self.engine.rootObject.addChild(source)}
catch { print("Failed to add a source to the scene") }

let mixer = PHASESpatialMixerDefinition(
    spatialPipeline: PHASESpatialPipeline(
        flags: .directPathTransmission)!
    )

let model = PHASEGeometricSpreadingDistanceModelParameters()
model.rolloffFactor = 1.0

mixer.distanceModelParameters = model

let pushStreamNode = PHASEPushStreamNodeDefinition(mixerDefinition: mixer, format: AVAudioFormat(standardFormatWithSampleRate: 48000.0, channels: 1)!)

var soundEventAsset: PHASESoundEventNodeAsset!
do {
    soundEventAsset = try self.engine.assetRegistry.registerSoundEventAsset(
        rootNode: pushStreamNode,
        identifier: "mic_stream"
    )
} catch {
    print("Failed to register the sound event asset")
    return nil
}

let mixerParameters = PHASEMixerParameters()
mixerParameters.addSpatialMixerParameters(
    identifier: mixer.identifier,
    source: source,
    listener: self.listener!
)

var event: PHASESoundEvent!
do {
    event = try PHASESoundEvent(
        engine: self.engine,
        assetIdentifier: soundEventAsset.identifier,
        mixerParameters: mixerParameters
    )
} catch {
    print("Failed to create the sound event \(error)")
    return nil
}
Post not yet marked as solved Up vote post of Thomas-Jld Down vote post of Thomas-Jld
672 views

Replies

Any idea of where I can find an example of how to use PushStreamNode?