Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Can I write my own Audio Importer?

Discussion in 'Immediate Mode GUI (IMGUI)' started by larku, May 19, 2016.

  1. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Let's say I wanted to create an audio importer for an audio format that is not supported by Unity - can this be done? Does Unity provide an API to allow a custom Audio Importer that would work seamlessly like the other Audio Importers ?

    If so could someone point me to a some starting reference (API docs or example extension).
     
  2. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    I can see that I can intercept the import pipeline by using an AssetPostprocessor but I'm not sure how that will enable me to import the audio and present unity with the WAV data (I expect that's what I'll be storing in the library somewhere?)

    It seems like a simple thing to do, but I can't find any info on how to store the results in the AssetDatabase (I assume that's the destination of my eventual data ?)
     
  3. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Bump - no one has any ideas?

    Can this even be done?
     
  4. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Another bump - someone must have some ideas.

    Unity staff? Anyone?

    @hippocoder ? You know everything, surely this can't be too difficult.
     
  5. IzzySoft

    IzzySoft

    Joined:
    Feb 11, 2013
    Posts:
    376
    in AssetPostprocessor, maybe you might have to Convert it to an audio file type that Unity presently supports, using an existing Audio Library?
     
  6. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Hey IzzySoft - that's what I want to do - the converting of data is the simple bit, but I don't want to create 'another' asset, I want to allow unity to process the asset in the original form (and I'll provide the ability to decode it into standard wav data).

    Essentially I want to provide the codec to unity via a nice API - if Unity has one, or is there is some way to achieve similar results.
     
  7. IzzySoft

    IzzySoft

    Joined:
    Feb 11, 2013
    Posts:
    376
    Sorry, not sure.

    Short of saving the FLAC audio file to a .txt resource (just in name), and later reading the TextAsset's binary data at runtime, cant say there's a better way, yet.

    Well, Saving a ScriptableObject instance as a FLAC asset is doable, and might seem more appealing. It would mean you could Delete the Original FLAC audio file (originally Imported) at the end of the AssetPostprocessor call. Never did it, so can't vouch, just brainstorming. :p
     
    Last edited: May 21, 2016
    larku likes this.
  8. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Thanks IzzSoft, they're some good suggestions, but unless it could be as seamless (and integrated into) Unity's import pipeline then I'll just continue to use wav files.

    Maybe @superpig has some insight?
     
    IzzySoft likes this.
  9. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    Nope, there's no way to do this right now short of licensing the engine source code and adding it to the C++ directly.
     
    larku likes this.
  10. larku

    larku

    Joined:
    Mar 14, 2013
    Posts:
    1,422
    Thanks @superpig a shame, but at least I know to not waste any time trying :)

    This seems like a rather trivial extension for Unity to make that could vastly improve the 3rd party product support that could be added by extensions.

    Perhaps my lack of knowledge about the import piepline and processing pipelines is what's making me think it'd be trivial to allow - I'd have expected all your current audio codecs just implement some interface or expose an API, to add to these via extensions seem almost natural :)
     
    Last edited: May 23, 2016
  11. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    Believe me, it's not as trivial as you might think... but stay tuned, there might be some minor news in this area in the next couple of months.
     
    larku likes this.
  12. ReaktorDave

    ReaktorDave

    Joined:
    May 8, 2014
    Posts:
    139
    Hey @superpig were the "news in this area" you mentioned already revealed?
     
  13. superpig

    superpig

    Drink more water! Unity Technologies

    Joined:
    Jan 16, 2011
    Posts:
    4,649
    No, not yet :)