# Is there a way to play an Fmod Event backwards, ie. reverse the audio playback?

**URL:** https://qa.fmod.com/t/is-there-a-way-to-play-an-fmod-event-backwards-ie-reverse-the-audio-playback/16351
**Category:** Unity
**Tags:** csharp
**Created:** [October 26, 2020, 1:11pm UTC](https://qa.fmod.com/t/is-there-a-way-to-play-an-fmod-event-backwards-ie-reverse-the-audio-playback/16351 "2020-10-26T13:11:35Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Paalo](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/paalo/32/616_2.png) [@Paalo](https://qa.fmod.com/u/Paalo)
#### Post date: [October 26, 2020, 1:11pm UTC](https://qa.fmod.com/t/is-there-a-way-to-play-an-fmod-event-backwards-ie-reverse-the-audio-playback/16351/1 "2020-10-26T13:11:35Z")

</div>

Is there a way to play an Fmod Event backwards, ie. reverse the audio playback?

In Unity it is possible to do this on an AudioSource by setting the AudioSource’s pitch to `-1f`, see this code:

```auto
// Reverses playback of the audiosource we send in.
// Manually play the AudioSource after calling this method to hear it 
// play the audio in reverse from the end of the AudioClip
public static void ReversePlaybackFromEnd(AudioSource audioSource)
{
	audioSource.timeSamples = audioSource.clip.samples - 1;
	audioSource.pitch *= -1f;
}

```

How would I go about doing this with an Fmod Studio event?

* * *

Use cases where I’d like to use this:

- “Timescroll”-effects where the player can manipulate time and make the game simulate backwards/forwards.
- An easy way of getting more variation out of some types of sound assets, since with this you can basically “duplicate” the amount of sound variations you have in the game, without using actual reversed versions of your pre-existing sound files.
- Probably usable to make cool things with music, where the harmony is changed depending on if the event is playing normally or if it is reversed. Check this video for inspiration:  
[https://www.dropbox.com/s/iyqkch9pglhrc90/2020-09-25%2012-08-32%20-%20More%20DOTween%20Music%20Backwards%20Pitch%20Chaos.mp4?dl=0](https://www.dropbox.com/s/iyqkch9pglhrc90/2020-09-25%2012-08-32%20-%20More%20DOTween%20Music%20Backwards%20Pitch%20Chaos.mp4?dl=0)

---

<div class="post-metadata">

### Author: ![joseph](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joseph/32/264_2.png) [@joseph](https://qa.fmod.com/u/joseph)
#### Post date: [October 27, 2020, 11:47pm UTC](https://qa.fmod.com/t/is-there-a-way-to-play-an-fmod-event-backwards-ie-reverse-the-audio-playback/16351/2 "2020-10-27T23:47:45Z")

</div>

FMOD Studio does not currently support playing sound files backwards. This feature is already on our feature/improvement tracker, but has not yet been scheduled for development.

Other games that feature “timescroll” play a generic rewind sound effect, or pitch down all diagetic sound (or apply some other effect to make the audio sound distorted).

---

<div class="post-metadata">

### Author: ![Paalo](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/paalo/32/616_2.png) [@Paalo](https://qa.fmod.com/u/Paalo)
#### Post date: [October 28, 2020, 12:08am UTC](https://qa.fmod.com/t/is-there-a-way-to-play-an-fmod-event-backwards-ie-reverse-the-audio-playback/16351/3 "2020-10-28T00:08:43Z")

</div>

Alright, so it’s safe to say that that feature will not be available for quite some time?

Yeah, those are all valid “timescroll”-techniques, but I’m mostly interested in the possibilities that (dynamically) reversed audio can bring to a game, especially how that could allow a Sound Designer to create even more interesting sound events, without adding any extra files to the game. Also how it could be used for music (eg. as heard in the video I shared above).

Speaking creating interesting events:  
Are there any plans for Studio to add a “Reverse”-functionality to Instruments within an Fmod Event? Or at least something akin to the “Replace Audio with Trimmed Copy”-command, but replace it with a reversed copy instead (even though we’d lose getting “free” sound assets with this approach)?

![image](https://canada1.discourse-cdn.com/flex036/uploads/fmod/original/2X/a/a91bbed262e006d41df2b5c6bde14b59c550810c.png)

---

<div class="post-metadata">

### Author: ![joseph](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/joseph/32/264_2.png) [@joseph](https://qa.fmod.com/u/joseph)
#### Post date: [October 28, 2020, 4:31am UTC](https://qa.fmod.com/t/is-there-a-way-to-play-an-fmod-event-backwards-ie-reverse-the-audio-playback/16351/4 "2020-10-28T04:31:28Z")

</div>

> [@Paalo](#):
>
> Are there any plans for Studio to add a “Reverse”-functionality to Instruments within an Fmod Event? Or at least something akin to the “Replace Audio with Trimmed Copy”-command, but replace it with a reversed copy instead (even though we’d lose getting “free” sound assets with this approach)?

We generally do not implement features that allow editing of audio files, as FMOD Studio is not a tool for editing audio files, but rather a tool for defining adaptive audio behavior in games. Our intent is that FMOD Studio be used in conjunction with linear audio editing software such as Ableton Live, Logic Pro, or Reaper; the expected workflow is that a sound designer makes their source assets in their linear audio editing tool, then gives them adaptive behavior in FMOD Studio.

Still, we do occasionally add features that allow editing of source audio files in simple ways, if a particular kind of file edit comes up frequently while using FMOD Studio or solves a common adaptive audio problem. “Replace Audio with Trimmed Copy” was one of these. Accordingly, I’ve submitted “Create reversed asset context menu item” to our feature/improvement tracker, and our developers will consider implementing it.

---

<div class="post-metadata">

### Author: ![LucianoMusella](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/lucianomusella/32/3491_2.png) [@LucianoMusella](https://qa.fmod.com/u/LucianoMusella)
#### Post date: [December 12, 2022, 8:32pm UTC](https://qa.fmod.com/t/is-there-a-way-to-play-an-fmod-event-backwards-ie-reverse-the-audio-playback/16351/5 "2022-12-12T20:32:20Z")

</div>

I come from the future! After 2 years, did that feature ever got implemented?

We are basically trying to make the Prince of Persia rewind effect.

---

<div class="post-metadata">

### Author: ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)
#### Post date: [December 14, 2022, 5:03am UTC](https://qa.fmod.com/t/is-there-a-way-to-play-an-fmod-event-backwards-ie-reverse-the-audio-playback/16351/6 "2022-12-14T05:03:55Z")

</div>

Ultimately we have decided not to go ahead with reverse playback as a feature in Studio. I’d recommend using a placeholder reverse-like sound or creating reversed assets in your editor of choice and importing them to Studio.

We have kept the task for a “create reversed” context menu item on sounds, but so far it has not been scheduled for development.

---

<div class="post-metadata">

### Author: ![jiyongman](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@jiyongman](https://qa.fmod.com/u/jiyongman)
#### Post date: [June 12, 2024, 1:23am UTC](https://qa.fmod.com/t/is-there-a-way-to-play-an-fmod-event-backwards-ie-reverse-the-audio-playback/16351/7 "2024-06-12T01:23:56Z")

</div>

Hi Mathew,

I was wondering if there have been any updates or changes regarding the backward playback feature. Has it been revisited, or are there any new alternatives or workarounds that you would recommend? My question is about FMOD Engine, not FMOD Studio, by the way.

Thanks a lot for your help!

---

<div class="post-metadata">

### Author: ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)
#### Post date: [June 12, 2024, 1:50am UTC](https://qa.fmod.com/t/is-there-a-way-to-play-an-fmod-event-backwards-ie-reverse-the-audio-playback/16351/8 "2024-06-12T01:50:16Z")

</div>

FMOD engine had always been able to back an `FMOD::Sound` in reverse.

First, make sure you load it as `FMOD_CREATESAMPLE`, this decompresses the asset up front, which is required as you cannot decompress piecemeal in reverse (that’s not how compression algorithms are designed).

Next, when you play the `FMOD::Sound`, set the frequency of the `FMOD::Channel` to the negative of its sample rate. You can use `FMOD::Channel::getFrequency` to get the current value, then `FMOD::Channel::setFrequency` to apply the negative.

---

<div class="post-metadata">

### Author: ![jiyongman](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@jiyongman](https://qa.fmod.com/u/jiyongman)
#### Post date: [June 12, 2024, 11:03am UTC](https://qa.fmod.com/t/is-there-a-way-to-play-an-fmod-event-backwards-ie-reverse-the-audio-playback/16351/9 "2024-06-12T11:03:09Z")

</div>

Thanks, Mathew!

I can’t believe I missed that part in the Core API Reference page!  
It’s a bit of a bummer that we can only do this with the CREATESAMPLE mode, though.  
Like the original poster, I wanted to implement something that could completely play back in reverse, including long background music.

For short sound effects, it’s not an issue since I always import them with CREATESAMPLE for better performance. However, for background music, it’s not feasible due to the high memory usage when uncompressed. I understand the limitation with the current implementation, but I hope you can consider adding another API to achieve the same effect with longer audio files.

By the way, I noticed something odd while testing. Can you explain why the audio doesn’t play when I call setPosition() with the exact value returned by getLength()? To make it work, I have to subtract a small value, like 1, as shown below:

```
g_System->playSound(mySound, myChannelGroup, true, &mySoundChannel);

float newFrequency;
mySoundChannel->getFrequency(&newFrequency);
newFrequency *= -1;
mySoundChannel->setFrequency(newFrequency);

unsigned int newTimeInMilli;
mySound->getLength(&newTimeInMilli, FMOD_TIMEUNIT_MS);
mySoundChannel->setPosition(newTimeInMilli - 1, FMOD_TIMEUNIT_MS);

mySoundChannel->setPaused(false);

```

Thanks a lot for your help!

---

<div class="post-metadata">

### Author: ![mathew](https://yyz2.discourse-cdn.com/flex036/user_avatar/qa.fmod.com/mathew/32/431_2.png) [@mathew](https://qa.fmod.com/u/mathew)
#### Post date: [June 13, 2024, 5:11am UTC](https://qa.fmod.com/t/is-there-a-way-to-play-an-fmod-event-backwards-ie-reverse-the-audio-playback/16351/10 "2024-06-13T05:11:26Z")

</div>

Most audio compression algorithms have a history, meaning to decode a section of audio, you need to have decoded several sections prior to it (to build up decoding state). When you play audio backwards you don’t have that history available, to do so would require seeking backwards, decoding forwards, then playing the result backwards. This causes a lot of duplicate decoding, since you need to discard (and not play) the history requirement of the file format. To manage expectations, this isn’t something we are considering.

A couple of alternate ideas:

- Encode reversed versions of your audio files and switch when appropriate.
- Create a DSP plugin that saves all the audio that passes through it up to a fixed time and can switch to playing back in reverse for up to that fixed time.
- Open sounds as FMOD\_CREATESAMPLE, save them to disk in reverse, then have FMOD stream them back in.
- Fake the reverse noise with one or more pre-recorded reversed sounds.

With your question regarding `setPosition`, to avoid missing any audio, use `FMOD_TIMEUNIT_PCM` and seek to `length - 1`. You need the minus one because position is “zero based”. For example, at a sample rate of 48kHz, a PCM length of 48000 is exactly one second, the samples that make up that second are 0 to 47999, where 48000 is one past the end.

---

<div class="post-metadata">

### Author: ![jiyongman](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@jiyongman](https://qa.fmod.com/u/jiyongman)
#### Post date: [June 13, 2024, 11:18am UTC](https://qa.fmod.com/t/is-there-a-way-to-play-an-fmod-event-backwards-ie-reverse-the-audio-playback/16351/11 "2024-06-13T11:18:49Z")

</div>

So many great ideas, Mathew!

I actually thought of the first option after writing my previous comment, so thanks for confirming that! I think it’s the most appropriate approach since it doesn’t require many modifications, uses minimal memory, doesn’t limit the length of the backward playback, and allows easy control of other effects like matching the playback speed to the original or adjusting the reverse speed freely.

As for the answer to my question, I now understand why that happened. Thanks for all the detailed explanations!
