Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    Custom audio data

    Advanced Programmer

    You can generate audio using your own mechanism. To do this, create a subclass of DynamicSoundSource. For an example of how to implement this, see the CompressedSoundSource` source code.

    Example code

    To play a custom DynamicSoundSource at runtime, use:

    int sampleRate = 48000;
    bool mono = false;
    bool spatialized = false;
    DynamicSoundSource myCustomSource = new MyCustomSource(...);
    AudioListener listener = Audio.AudioEngine.DefaultListener;
    AudioEngine audioEngine = Audio.AudioEngine;
    SoundInstance myCustomInstance = new SoundInstance(audioEngine, listener, myCustomSource, sampleRate, mono, spatialized);
    await myCustomInstance.ReadyToPlay();
    myCustomInstance.Play();
    

    See also

    • Global audio settings
    • Improve this Doc
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation