void Start() { lineRenderer = gameObject.AddComponent <LineRenderer>(); lineRenderer.SetVertexCount(WindowSize); lineRenderer.SetWidth(.1f, .1f); //musicInstance = FMODUnity.RuntimeManager.CreateInstance("event:/Music/Basic/Random Layered"); //int instanceID = emitter.GetInstanceID(); //musicInstance = FMODUnity.RuntimeManager.StudioSystem.getEventByID(instanceID); if (emitter == null) { emitter = GameObject.Find("Music Emitter").GetComponent <FMODUnity.StudioEventEmitter> (); } musicInstance = emitter.GetInstance(); FMODUnity.RuntimeManager.LowlevelSystem.createDSPByType(FMOD.DSP_TYPE.FFT, out fft); fft.setParameterInt((int)FMOD.DSP_FFT.WINDOWTYPE, (int)FMOD.DSP_FFT_WINDOW.HANNING); fft.setParameterInt((int)FMOD.DSP_FFT.WINDOWSIZE, WindowSize * 2); FMOD.ChannelGroup channelGroup; FMODUnity.RuntimeManager.LowlevelSystem.getMasterChannelGroup(out channelGroup); channelGroup.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, fft); musicInstance.start(); }
void StartFFT() { FMODUnity.RuntimeManager.LowlevelSystem.createDSPByType(FMOD.DSP_TYPE.FFT, out fft); fft.setParameterInt((int)FMOD.DSP_FFT.WINDOWTYPE, (int)FMOD.DSP_FFT_WINDOW.HANNING); fft.setParameterInt((int)FMOD.DSP_FFT.WINDOWSIZE, WindowSize * 2); FMOD.ChannelGroup channelGroup; FMODUnity.RuntimeManager.LowlevelSystem.getMasterChannelGroup(out channelGroup); channelGroup.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, fft); }
private void PrepareFMODeventInstance() { SongPlaylist = FMODUnity.RuntimeManager.CreateInstance(_eventPath); //SongPlaylist.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject.transform)); SongPlaylist.start(); FMODUnity.RuntimeManager.CoreSystem.createDSPByType(FMOD.DSP_TYPE.FFT, out _dsp); _dsp.setParameterInt((int)FMOD.DSP_FFT.WINDOWTYPE, (int)_windowShape); _dsp.setParameterInt((int)FMOD.DSP_FFT.WINDOWSIZE, _windowSize * 2); SongPlaylist.getChannelGroup(out _channelGroup); _channelGroup.addDSP(0, _dsp); }
void Start() { selfLight = GetComponent <Light>(); musicInstance = FMODUnity.RuntimeManager.CreateInstance("event:/01_A_IMPLEMENTER/Walk_01"); musicInstance.set3DAttributes(FMODUnity.RuntimeUtils.To3DAttributes(gameObject)); FMODUnity.RuntimeManager.CoreSystem.createDSPByType(FMOD.DSP_TYPE.FFT, out fft); fft.setParameterInt((int)FMOD.DSP_FFT.WINDOWTYPE, (int)FMOD.DSP_FFT_WINDOW.HANNING); fft.setParameterInt((int)FMOD.DSP_FFT.WINDOWSIZE, WindowSize * 2); FMOD.ChannelGroup channelGroup; FMODUnity.RuntimeManager.CoreSystem.getMasterChannelGroup(out channelGroup); channelGroup.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, fft); }
// Use this for initialization void Start() { //_spectrum = new Array2D(); //lineRenderer = gameObject.AddComponent<LineRenderer>(); lineRenderer.positionCount = WindowSize; lineRenderer.startWidth = .1f; lineRenderer.endWidth = .1f; musicInstance = FMODUnity.RuntimeManager.CreateInstance("event:/Debug/Random Event"); FMODUnity.RuntimeManager.LowlevelSystem.createDSPByType(FMOD.DSP_TYPE.FFT, out fft); fft.setParameterInt((int)FMOD.DSP_FFT.WINDOWTYPE, (int)FMOD.DSP_FFT_WINDOW.HANNING); fft.setParameterInt((int)FMOD.DSP_FFT.WINDOWSIZE, WindowSize * 2); FMOD.ChannelGroup channelGroup; FMODUnity.RuntimeManager.LowlevelSystem.getMasterChannelGroup(out channelGroup); channelGroup.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, fft); musicInstance.start(); }
// Use this for initialization void Start() { frequency = 800; amplitude = 1.0f; sampleGenerator = GenerateSineSample; sampleGenerator2 = GenerateTriangleSample; //referencja do komponentow FMOD - wysokiego poziomu (studio) i niskiego studioSystem = FMODUnity.RuntimeManager.StudioSystem; lowlevelSystem = FMODUnity.RuntimeManager.LowlevelSystem; //odniesienie do glownego kanalu - do niego bedziemy przesylac nasz dzwiek channel = new Channel(); channel1forInstrument = new Channel(); channel2forInstrument = new Channel(); channel3forSoundFile = new Channel(); FMODUnity.RuntimeManager.LowlevelSystem.getMasterChannelGroup(out channelGroup); FMODUnity.RuntimeManager.LowlevelSystem.getMasterChannelGroup(out channelGroupforInstrument); FMODUnity.RuntimeManager.LowlevelSystem.getMasterChannelGroup(out channelGroupforInstrument2); FMODUnity.RuntimeManager.LowlevelSystem.getMasterChannelGroup(out channelGroupforSoundFile); //inicjalizacja FFT (w FMODzie jako komponent DSP) i linerenderera do wyswietlania equalizera FMODUnity.RuntimeManager.LowlevelSystem.createDSPByType(FMOD.DSP_TYPE.FFT, out fft); fft.setParameterInt((int)FMOD.DSP_FFT.WINDOWTYPE, (int)FMOD.DSP_FFT_WINDOW.HANNING); fft.setParameterInt((int)FMOD.DSP_FFT.WINDOWSIZE, windowSize * 2); lineRendererFFT = gameObject.AddComponent <LineRenderer>(); lineRendererFFT.positionCount = windowSize; lineRendererFFT.startWidth = 0.1f; lineRendererFFT.endWidth = 0.1f; channelGroup.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, fft); //channelGroupforInstrument.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, fft); //channelGroupforInstrument2.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, fft); channelGroupforSoundFile.addDSP(FMOD.CHANNELCONTROL_DSP_INDEX.HEAD, fft); lineRendererSamples = lineRendererHolder.AddComponent <LineRenderer>(); lineRendererSamples.positionCount = sampleRate / 100; lineRendererSamples.startWidth = 0.1f; lineRendererSamples.endWidth = 0.1f; //lowPassFilterGraphMarker = GameObject.CreatePrimitive(PrimitiveType.Cube); //lowPassFilterGraphMarker.transform.position = new Vector3(0, lineRendererSamples.transform.position.y, 0.0f); //lowPassFilterGraphMarker.transform.localScale = new Vector3(0.5f, 5.0f, 0.5f); //lowPassFilterGraphMarker.SetActive(false); //lowPassFilterGraphMarker.GetComponent<Renderer>().material.color = Color.red; //Debug - sprawdzamy czy dobrze udalo nam sie zlapac kanal dzwiekowy (nie mamy jeszcze //obslugi bledow FMOD_OK) uint version; lowlevelSystem.getVersion(out version); bool channelIsPlaying; channel.isPlaying(out channelIsPlaying); UnityEngine.Debug.Log(channelIsPlaying); uint bl; int numbuf; lowlevelSystem.getDSPBufferSize(out bl, out numbuf); UnityEngine.Debug.Log("DSP buffer size is: " + bl + ", " + numbuf); //Wczytujemy i odtwarzamy testowy plik do obiektu 'sound' //Przypisujemy nasz kanal do tej samej grupy co glowny kanal dzwieku FMOD.Sound sound; string nametest = ""; lowlevelSystem.createSound("Assets\\Sounds\\test2.mp3", FMOD.MODE.DEFAULT, out sound); sound.getName(out nametest, 20); UnityEngine.Debug.Log(nametest); InitSampleGeneration(); //debug // (sampleCreated) //{ lowlevelSystem.playSound(generatedSound, channelGroup, true, out channel); channel.setLoopCount(-1); channel.setMode(MODE.LOOP_NORMAL); channel.setPosition(0, TIMEUNIT.MS); channel.setPaused(true); //} //else //{ lowlevelSystem.playSound(sound, channelGroupforSoundFile, true, out channel3forSoundFile); channel3forSoundFile.setLoopCount(-1); channel3forSoundFile.setMode(MODE.LOOP_NORMAL); channel3forSoundFile.setPosition(0, TIMEUNIT.MS); channel3forSoundFile.setPaused(false); //} //lowPassFilterGraphMarker.SetActive(false); InitFilters(); filterApplier.InitFilterApplier(); instrument.InitFilterApplier(); }