keijiro / Lasp

Low-latency Audio Signal Processing plugin for Unity
The Unlicense
1.52k stars 118 forks source link

Use file or AudioSource as input? #2

Open ZephyrRaine opened 6 years ago

ZephyrRaine commented 6 years ago

Hello keijiro, thanks for that and all of your work, you're really bringing great and useful features to Unity 🥇

I was wondering if there was any way to use a file as input for Lasp, or if it could be done easily by modifying your source code? It works fine when setting Stereo Mix as a recording device, but it probably won't be enabled for the random user. Not being that much of a savvy guy, I was wondering if you'd have any clue on that for me to get started!

Thanks in advance!

keijiro commented 6 years ago

I was wondering if there was any way to use a file as input for Lasp, or if it could be done easily by modifying your source code?

No, but I have a plan to add "feedback mode" that allows using Unity's Audio Mixer as an input to LASP.

ZephyrRaine commented 6 years ago

Thanks for your answer, looking forward to it. If there's any way we can help let us know :)

AnyMotion commented 6 years ago

Feedback mode sounds exactly like the function I'm looking for. Reading individual channel/group levels and give rms / peak values from C++ function. If that's a possibility, than I'm a happy camper. :)

If only Unity would also allow more script access to the mixer, like creating channels, groups and exposed variables on the fly (and not naming them myexposedreference every time :( ) and give us access to the peak/rms meters already build in Unity. I tried some native audio things, but with no experience in C++ this isn't for me.

keijiro commented 6 years ago

I implemented the loopback feature as a special build.

https://github.com/keijiro/Lasp/tree/loopback

I won't merge it to the master branch for a while because it hasn't been tested enough.

AnyMotion commented 6 years ago

Cool Thx. Will test this soon and let you know the results. Keep up the good work, unity should promote you to chief audio!

Any idea if there will be a possibility to add exposed parameters / effects etc through c# script to the unity mixer anytime soon. It would really optimize my project vr sound engineer and make a lot more possible than the current limited way of using exposed values. (I need about 2000 of them and the dorpdown list in unity mixer is not an easy workflow and quite buggy as some exp values (specially the send effect) tend to lose their reference.)

Regards, Marald Bes AnyMotion.nl

Verstuurd vanaf mijn iPhone

Op 14 sep. 2017 om 20:36 heeft Keijiro Takahashi notifications@github.com het volgende geschreven:

I implemented the loopback feature as a special build.

https://github.com/keijiro/Lasp/tree/loopback

I won't merge it to the master branch for a while because it hasn't been tested enough.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

AnyMotion commented 6 years ago

Hi Kijiro,

It took me a while, but was able to test the Last loopback in Unity 2017.2 today. It seems to work fine (lower cpu usage than reading audiofilter output), but I ran into some limitations.

As the implementation is done using audioinput, it is general for the entire project. I wanted to receive RMS / Peakvalues of each separate channel where the Lasp loopback plugin is inserted and enabled. Is there a way to do this? Is it even possible to use multiple LASP plugins simultaniously?

In the screenshot you can see the current LASP loop effect on the meters of the mixing console. All the meters seem to be using the same Lasp plugin. The only difference you see in levels is because of different filter types which is configured per channel.

Kind regards, Marald Bes www.AnyMotion.nl

On 14 Sep 2017, at 14:36, Keijiro Takahashi notifications@github.com wrote:

I implemented the loopback feature as a special build.

https://github.com/keijiro/Lasp/tree/loopback https://github.com/keijiro/Lasp/tree/loopback I won't merge it to the master branch for a while because it hasn't been tested enough.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/keijiro/Lasp/issues/2#issuecomment-329468285, or mute the thread https://github.com/notifications/unsubscribe-auth/AdcqHOMi78jd-FFrGvlMhPkOKJylGfP9ks5siR3KgaJpZM4OgUXH.

keijiro commented 6 years ago

Is there a way to do this? Is it even possible to use multiple LASP plugins simultaniously?

No. LASP doesn't support multiple channels at the moment. I think it should be supported though.

stefang commented 5 years ago

Wondering if this is in the current new build? Guessing not by the fact it's still an open ticket?

Excited to try this out if it is... Would it be safe to assume that the combo of the above mentioned loopback mode, an audioSource and the Timeline would solve the issue of offline rendering visuals using the Unity Recorder and keeping the rendered files in sync with an source audio file? The not-realtime rendering of an image sequence means live audio input isn't an option.

keijiro commented 5 years ago

@stefang No, it isn't in the current build. My current conclusion is that I can't afford enough time to support it in a proper way. Please understand that my capacity it quite limited.

stefang commented 5 years ago

Of course, I was just checking really! Grateful you make any of this available :-)

Gabana commented 3 years ago

Hi Keijiro,

Any chance to use Unity's Audio Source as a source for LASP in the latest updates you did recently (mid 2020)?? I see you made some attempts but the Loopback branch doesn't work anymore due to a problem in Lasp.bundle (in 2019.4), i wonder if you have a different solution.

I saw one of commentend a possible solution, where i should "create a fake input device and somehow route the sound trough there"... Can you please provide any hint about to do achieve this?

I just want to play a song using LASP to make an audio visualization using VFX Graph...

Any help would be greatly appreciated :)

keijiro commented 3 years ago

@Gabana

i wonder if you have a different solution.

No. There is no solution.

I saw one of commentend a possible solution, where i should "create a fake input device and somehow route the sound trough there"... Can you please provide any hint about to do achieve this?

Virtual audio device like this: https://vac.muzychenko.net/en/

Nolram12345 commented 2 years ago

Still no further update on this ?

Saggex commented 2 years ago

Still no further update on this ?

I just implemented a solution a few minutes ago. It does not yet support the AudioSpectrumAnalyzer Component, but It works with the AudioLevelTracker. It's for now on my google drive, until I find the time to create a fork of the repo, or until I find the time, to create a branch here, or something. You have to remove LASP from your packages and put the contents into your Assets folder.

https://drive.google.com/file/d/1cwjt9mjDGC5CS9wxRHGeQF4q-yBo15d_/view?usp=sharing

Thaina commented 7 months ago

I can easily use raw data from AudioSource and convert to texture easily with this

            if(audioSource && audioSource.isPlaying)
            {
                if(audioData?.Length != _analyzer.resolution)
                    audioData = new float[_analyzer.resolution];

                audioSource.GetOutputData(audioData,0);

                EnsureSize(ref cacheAudioData,audioData.Length);

                cacheAudioData.CopyFrom(audioData);

                if(fft?.Width != audioData.Length * 2)
                {
                    fft?.Dispose();
                    fft = new FftBuffer(audioData.Length * 2);
                }

                fft.Push(cacheAudioData);
                fft.Analyze(-_analyzer.currentGain - _analyzer.dynamicRange, -_analyzer.currentGain);

                if(logScaler == null)
                    logScaler = new LogScaler();

                data = logScaler.Resample(fft.Spectrum);
            }
            else data = _logScale ? _analyzer.logSpectrumArray : _analyzer.spectrumArray;

It require us to made some internal class become public like this https://github.com/keijiro/Lasp/pull/65

I would also suggest disable autogain with audiosource