Stride

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

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

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

    Play a range within an audio asset

    Intermediate Programmer

    You can have Stride play only certain portions of an audio asset. This means, for example, that you can create multiple samples from a single audio asset by specifying different ranges in different SoundInstance objects.

    Loop points

    You can use the following properties, methods, and structures:

    Property, method, or structure Function
    Sound.TotalLength The total length of the sound.
    SoundInstance.SetRange(PlayRange) Sets the time range to play within the audio asset.
    PlayRange Time information, including the range's starting point and length.
    SoundInstance.Position Gets the current play position as TimeSpan.

    For example:

    //Assume sample length is 5 seconds.
    var length = mySound.TotalLength;
    var begin = TimeSpan.FromSeconds(2);
    var duration = TimeSpan.FromSeconds(2);
    mySoundInstance.SetRange(new PlayRange(begin, duration));
    

    See also

    • Global audio settings
    • Spatialized audio
    • Non-spatialized audio
    • Improve this Doc
    In This Article

    Back to top

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