Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

usfxr, a Unity port of sfxr/as3sfxr

Discussion in 'Works In Progress - Archive' started by zeh, Apr 22, 2013.

  1. zeh

    zeh

    Joined:
    Feb 2, 2013
    Posts:
    28
    Hey guys,

    TL;DR: ported well-known audio effect generator API to Unity. Playable web example is here and open-source code is here. Would love to hear comments and criticism on it since I'm new to the Unity platform.

    --

    Long description:

    I've slowly been learning Unity for the past few months and I finished something that I'd love to have some feedback on.

    In preparation for upcoming Ludum Dare competitions, I decided to convert the sfxr engine for real-time audio generation to Unity/C#. I wanted to be able to play audio inside Unity without static audio assets, and doing little "changes" to the audio during playback, adding some variation to it...

    I ended up porting Thomas Vian's as3sfxr API (which was based on the original sfxr) to Unity. This is a library that lets you play audio with mutations and stuff, as well as create instances of audio that is cached. The difference I suppose is that I made it always generate on a separate thread/cache/etc so it should have near zero impact on gameplay execution (hopefully).

    I have a (horrid) prototype/game thing that attempts to explain what the thing is about:
    http://hosted.zehfernando.com/ludumdare/usfxr/

    Notice this game contains no audio assets, as everything is generated in real time using a parameter string. And since it has "mutated" mode by default, all the audio effects played will be slightly different.. just to make things less repetitive (watch this video for a more inspiring explanation).

    The code for usfxr (and the sample game, and a few other samples), as well as a lengthier description, is here:
    https://github.com/zeh/usfxr

    (Update June 20th 2014) It's also available as a free asset store package, so it's easier to install it from Unity itself (it also comes with a manual):
    https://www.assetstore.unity3d.com/en/#!/content/18619

    I'd love to hear some criticism of... well, anything. Code, example organization, installation instructions. I'm not new to programming, but I don't have that much experience with Unity (and somewhat limited with C# as well), so I might have screwed things up a bit.

    I'll hopefully add it to the asset store (for free) after it's done. Just want to get the thing to be a bit more polished before going "public". So any input is appreciated.

    Thanks!
     
    Last edited: Jun 21, 2014
    riomoko, Demigiant and r618 like this.
  2. Wordsonplay

    Wordsonplay

    Joined:
    Apr 29, 2013
    Posts:
    21
    Great! Just what I was looking for. Thanks for sharing.
     
  3. zeh

    zeh

    Joined:
    Feb 2, 2013
    Posts:
    28
    Updated usfxr with an in-editor generator! Now you can use Unity to generate and preview your audio parameters too!

     
    Demigiant, r618 and Jess-Hewitt like this.
  4. JMcKenna

    JMcKenna

    Joined:
    Feb 25, 2014
    Posts:
    11
    Wow! This looks really awesome. Long time fan of sfxr, but hated exporting/importing to unity.
    I'm excited to try this out, thanks for sharing.
     
    zeh likes this.
  5. Lucanio

    Lucanio

    Joined:
    Dec 22, 2013
    Posts:
    3
    Wow, I was just about to do this myself but you've already done a great job. Thank you!
     
    zeh likes this.
  6. zeh

    zeh

    Joined:
    Feb 2, 2013
    Posts:
    28
    Thanks for the support guys!

    I've done a few further updates for performance, and also uploaded it to the asset store (for free), since a lot of people seem to prefer using it:
    https://www.assetstore.unity3d.com/en/#!/content/18619

    I've updated the original post with this link.
     
    r618 and twitchfactor like this.
  7. zeh

    zeh

    Joined:
    Feb 2, 2013
    Posts:
    28
    Another update: I've started adding the features introduced by BFXR to usfxr. BFXR is another AS3 port of SFXR. The interesting thing about this port is that it introduces new wave form types and filters, so all in all you have a bunch more parameters to work with.

    Right now I'm working on it as a experimental Git branch called bfxr-params. So it's not the main branch, but available for testing if anyone wants to try it. I'll merge them once all the changes are done and not breaking anything, and also update the asset store version then.

    Currently it only supports the new wave form types (triangle, breaker, tan, whistle, and pink noise). The new filter parameters are not supported yet, and copying BFXR param strings directly doesn't work either. In the future it'll support both copying & pasting "standard" SFXR and BFXR param strings, to maintain compatibility with other engines (original sfxr, as3sfxr, etc).
     
    Last edited: Jul 10, 2014
    chelnok likes this.
  8. earrgames

    earrgames

    Joined:
    Jan 27, 2014
    Posts:
    168
    You are my god!;)

    What is better than a random generated game?
    Simple: A random generated game with random sounds!
     
    zeh likes this.
  9. hosepha

    hosepha

    Joined:
    Nov 22, 2012
    Posts:
    22
    Great work, going to give this a go later!
     
    zeh likes this.
  10. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    This is SUPERCOOL!!!!! How could I not notice it before! Thanks for sharing it :)
     
    zeh likes this.
  11. zeh

    zeh

    Joined:
    Feb 2, 2013
    Posts:
    28
    Thanks again for the comments guys!

    I've finished adding all BFXR features to usfxr, just as I get ready for the next Ludum Dare. Now it supports all the basic SFXR features, plus..
    • New filters: compression, harmonics, and bitcrusher
    • Expanded pitch jump effects
    • New waveform types: triangle, breaker, tan, whistle, and pink noise
    • BFXR's parameter strings (standard SFXR parameter strings still work too)
    The new version is 1.2 and is the default on GitHub. A simple zip file is available for download. The asset store version is not updated yet (I'll do so later this week, I need to update the guide and docs).

    The next updates should focus on making the GUI more user-friendly and understandable (copying code, showing the wave data, exporting WAV).

    As usual, criticism is also welcomed!
     
    Demigiant likes this.
  12. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    Fantastic again! I still didn't get to use it so I have no criticism, but I'm gonna spam it around a little :)
     
  13. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,239
    By the way Zeh, I just realized... are you Mr Tweener Zeh? If so, I owe you many many bows of gratitude. Used to love your tween engine when in Flash (and it was partially my inspiration for the Unity one I made)!
     
  14. riomoko

    riomoko

    Joined:
    Mar 4, 2012
    Posts:
    3
    very nice!!!
    I'm waiting for wav generation :)
     
  15. zeh

    zeh

    Joined:
    Feb 2, 2013
    Posts:
    28
    Yup! Thanks! I still do a lot of Flash work professionally (weirdly enough) but Unity is currently my go-to spare time technology for fun. I took a quick look at HOTween... looks great.
     
  16. dbryson

    dbryson

    Joined:
    Nov 9, 2009
    Posts:
    269
    Awesome package! Thanks! Seems like this could be really useful on mobile to reduce the size of the package.

    One suggestion, please put the package into it's own folder so it doesn't overwrite existing scripts. Somebody could easily have a scripts folder containing a main.cs.
     
    zeh likes this.
  17. zeh

    zeh

    Joined:
    Feb 2, 2013
    Posts:
    28
    Well, that's just for the sample projects; usfxr's own scripts have their own unique names and are inside the /usfxr folder in the sample projects, and in the asset store package. But I agree it makes sense, if people are copying from the sample projects instead. I'll do that in the next release. Thanks!
     
    Last edited: Jul 15, 2014
  18. zeh

    zeh

    Joined:
    Feb 2, 2013
    Posts:
    28
    Ohh, I get what you mean now -- the asset store package has a "Main.cs" file in the root folder. That's a no-no. That's my fault; I didn't really know how asset store publishing worked and included the file in the root. That file is just for the example scene... it's unnecessary for usfxr. Thanks for pointing that out.

    I've published the new version (1.2) a couple of days ago, and I made sure there was nothing in the root (everything is under /usfxr), and the scene example source file is clearly marked as so and moved to a separate "samples" folder. Thanks!

    With this version (that should be live either today or early next week) I think this is not just a "WIP" project anymore, so I'll move this conversation to a new message on the asset store sub forum. Thanks for the help and comments guys!