Search Unity

Question Lower rate audio read to 384kHz sample rate?

Discussion in 'Audio & Video' started by unitedone3D, Mar 25, 2021.

  1. unitedone3D

    unitedone3D

    Joined:
    Jul 29, 2017
    Posts:
    160
    Hi there! Does anyone know how we can 'make' Unity go above its 192khz inspector drop-down selection limit in the audio files when wishing to play at a higher rate (not playing a 384 kHz sound file - Originally/source; but, rather playing any sound files 192kHz or lower - To - the 384 kHz sound rate). When you click in Inspector on an audio file, there is a range of 8,000Hz to 192,000Hz that you can play the sound file; now I know Unity can play a 384 kHz file if you select: ''Preserve Sample Rate''; I tested it, and Unity plays an Original 384 kHz sound file - 384 kHz rate; thus it preserves the rate (I am guessing it would even be the same trying with a 768 kHz sound file, it would play it at this speed/preserve its rate...because the audio player adjusts to the Sound Files Original Sample Rate (whether 8kHz or 768kHz...it will play it whatever sample rate in the file; as long as it is put as ''Preserve Sample Rate'');

    Otherwise, you must select the sample rate using ''Override Sample Rate'' which is limited: 8,000Hz to 192,000Hz;

    there is no 384,000Hz or 768,000Hz possible to select in the list; for example, If I had a 768,000Hz sound file & did Not select ''Preserve Sample Rate'', but selected ''Override Sample Rate'' and checked in inspector, the sound file would be limited to 192,000Hz (because its the last one/max); it would not show 768kHz but rather 192kHz, thus Unity would only play it at 192; not at its original sample rate of 768; Unless, I clicked ''Preserve Sample Rate''; and then, now, it does say ''768 kHz'' and will play at its correct sample rate.

    But, I am wondering about 'lower-sample rate' sound files; that are 192,000Hz or Lower, to be played at higher rate;

    if I bring in a 44kHz sound file in Unity and select a custom sample rate by selecting ''Override Sample Rate''; I can play this 44kHz audio file At up to a 192kHz sample rate - but cannot go above that/cannot select 384 kHz or 768kHz because are not in the list as selectable options.

    What is the file that controls this ''Override Sample Rate'' selections of 8-192 kHz list in the Inspector,
    I would wish to add 384-768kHz as selectable higher sample rates in the list that Lower sample-rate sounds can Play At when selected in Audio Files' Inspector ''; how would one 'add' these sample rates to the list? What is the Inspector Unity file that controls this Override Sample Rate list, to be able to edit it and add those higher sample rates?

    Unity manual:
    Sample Rate Setting PCM and ADPCM compression formats allow automatically optimized or manual sample rate reduction.
    Preserve Sample Rate This setting keeps the sample rate unmodified (default).
    Optimize Sample Rate This setting automatically optimizes the sample rate according to the highest frequency content analyzed.
    *** Override Sample Rate This setting allows manual overriding of the sample rate, so effectively this may be used to discard frequency content.

    Thank you very much for any help!

    PS: I know that 'just use a 384 kHz sound or 768 kHz sound...as original sample rate; and select 'preserve sample rate'...you will obtain 384 ot 768....as it will preserve the sound file's sample rate...
    Though that is not what I am wishing to do, what I wish to do is play a Low sample rate file - at - higher sample rate/speed; but I can't select higher than 192 (when selecting 'override sample rate'). You might be Wondering why even bother 'just use the preserve one and play at Original 384/768'...I know this...I am not looking to do this; I am trying to 'uprate' low sound files..to play at Higher Sample Rate; as said, like playing a 44kHz sound file - At - 384kHz or 768kHz; I can only go to the max of 192 (as last selection in the list of 'override sample rate'; I am wishing to go higher/play lower sample rate sounds - at higher sample rate than 192 limit in that list)..
     
  2. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,407
  3. unitedone3D

    unitedone3D

    Joined:
    Jul 29, 2017
    Posts:
    160
    Dear mgear, thank you very much!

    It does not work, sadly; it works if putting a lower number. I tried putting 1000hz on the meta file: ''sampleRateOverride: 1000''; and in Unity it showed 1000.

    When I did the same thing ''sampleRateOverride: 384000'' on meta file, it did not work, it still showed 192,000 in Unity. It is as if you can put any number, so long as it is in the range 0 to 192,000;

    not above 192,000. It seems like a hard limit (hard coded?). Do you know the editor file/inspector file that contains this 'range of 0 - 192,000'; I think it is refusing to go above 192,000; simply because 0 = minimum and 192 = maximum; so if you put above 192 or below 0 - it doesn't work because the range does not cover that; Unity Reading that script/inspector file unallows it because it is just not there as number. Thus, it would be to tell Unity that the range (min-max coverage) is 0-384 or 0-768...then it would work, just like 1000 worked (because it is still fitting-in 0-192 min-max range).

    Thank you very much again in all cases.

    PS: I tried to click 'debug' (mode) on the audio file (the little icon '3 dots' at the top of inspector just beside the 'lock' icon), then it showed Frequency : 192000; but all the infos are 'greyed out', I can't change them. I read the reason is because it is 'Read-only' (as in this information is only 'read(able)' not modifiable, because it is intrinsic into the audio file). If it wasn't 'read-only' then it could be changed; how do we change to modifitable/not read-only?