Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use file or AudioSource as input? #2

Open
ZephyrRaine opened this issue Jul 23, 2017 · 15 comments
Open

Use file or AudioSource as input? #2

ZephyrRaine opened this issue Jul 23, 2017 · 15 comments
Assignees

Comments

@ZephyrRaine
Copy link

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 keijiro self-assigned this Jul 23, 2017
@keijiro
Copy link
Owner

keijiro commented Jul 23, 2017

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
Copy link
Author

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

@AnyMotion
Copy link

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
Copy link
Owner

keijiro commented Sep 14, 2017

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
Copy link

AnyMotion commented Sep 18, 2017 via email

@AnyMotion
Copy link

AnyMotion commented Nov 24, 2017 via email

@keijiro
Copy link
Owner

keijiro commented Nov 24, 2017

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
Copy link

stefang commented Apr 10, 2019

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
Copy link
Owner

keijiro commented Apr 10, 2019

@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
Copy link

stefang commented Apr 10, 2019

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

@Gabana
Copy link

Gabana commented Jan 7, 2021

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
Copy link
Owner

keijiro commented Jan 7, 2021

@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
Copy link

Still no further update on this ?

@Saggex
Copy link

Saggex commented Mar 16, 2022

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
Copy link

Thaina commented Dec 21, 2023

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 #65

I would also suggest disable autogain with audiosource

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants