コード例 #1
0
ファイル: CameraService.cs プロジェクト: dqchess/Linyx
 private void HandleRotation()
 {
     if (_isRotationEnabled && !_isDrawMode && AudioPeerService.HasClip())
     {
         _rotateTransform.Rotate(_rotateAxis.x * _rotateSpeed.x * Time.deltaTime * AudioPeerService.GetAmplitudeBuffer(),
                                 _rotateAxis.y * _rotateSpeed.y * Time.deltaTime * AudioPeerService.GetAmplitudeBuffer(),
                                 _rotateAxis.z * _rotateSpeed.z * Time.deltaTime * AudioPeerService.GetAmplitudeBuffer());
     }
 }
コード例 #2
0
        public override async void Execute()
        {
            await Task.Delay(1000);

            ViewManager.Initialize();
            SaveManager.Initialize();
            ShortcutService.Initialize();
            BrushService.Initialize();
            DrawService.Initialize();
            BackgroundService.Initialize();
            CameraService.Initialize();
            ProjectService.Initialize();
            AudioPeerService.Initialize();
        }
コード例 #3
0
ファイル: ProjectService.cs プロジェクト: dqchess/Linyx
 private void Update()
 {
     if (AudioPeerService.HasClip())
     {
         foreach (KeyValuePair <string, ILineModel> line in _lines)
         {
             if (!line.Value.KochTrailProperty.IsTrailEnabled)
             {
                 EmissionReact(line.Value);
                 ScaleReact(line.Value);
             }
         }
     }
 }
コード例 #4
0
ファイル: ProjectService.cs プロジェクト: dqchess/Linyx
        private void ScaleReact(ILineModel line)
        {
            if (!line.ScaleProperty.IsScaleReactOnAudio)
            {
                return;
            }
            float value;

            switch (line.EmissionProperty.EmissionFrequencyType)
            {
            case AudioFrequencyType.Band:
                value = AudioPeerService.GetAudioBand(line.ScaleProperty.ScaleBandBuffer);
                break;

            case AudioFrequencyType.BandBuffer:
                value = AudioPeerService.GetAudioBandBuffer(line.ScaleProperty.ScaleBandBuffer);
                break;

            case AudioFrequencyType.Amplitude:
                value = AudioPeerService.GetAmplitude();
                break;

            case AudioFrequencyType.AmplitudeBuffer:
                value = AudioPeerService.GetAmplitudeBuffer();
                break;

            case AudioFrequencyType.Frequency:
                value = AudioPeerService.GetFrequencyBand(line.ScaleProperty.ScaleBandBuffer);
                break;

            case AudioFrequencyType.FrequencyBuffer:
                value = AudioPeerService.GetFrequencyBandBuffer(line.ScaleProperty.ScaleBandBuffer);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            if (value > line.ScaleProperty.ScaleThreshold)
            {
                line.LineGameObject.widthMultiplier = value * line.ScaleProperty.ScaleMultiplier;
            }
            else
            {
                line.LineGameObject.widthMultiplier = 1;
            }
        }
コード例 #5
0
ファイル: ProjectService.cs プロジェクト: dqchess/Linyx
        private void EmissionReact(ILineModel line)
        {
            if (!line.EmissionProperty.IsEmissionReactOnAudio || !line.IsEmissionEnabled)
            {
                return;
            }
            float value;

            switch (line.EmissionProperty.EmissionFrequencyType)
            {
            case AudioFrequencyType.Band:
                value = AudioPeerService.GetAudioBand(line.EmissionProperty.EmissionBandBuffer);
                break;

            case AudioFrequencyType.BandBuffer:
                value = AudioPeerService.GetAudioBandBuffer(line.EmissionProperty.EmissionBandBuffer);
                break;

            case AudioFrequencyType.Amplitude:
                value = AudioPeerService.GetAmplitude();
                break;

            case AudioFrequencyType.AmplitudeBuffer:
                value = AudioPeerService.GetAmplitudeBuffer();
                break;

            case AudioFrequencyType.Frequency:
                value = AudioPeerService.GetFrequencyBand(line.EmissionProperty.EmissionBandBuffer);
                break;

            case AudioFrequencyType.FrequencyBuffer:
                value = AudioPeerService.GetFrequencyBandBuffer(line.EmissionProperty.EmissionBandBuffer);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            if (value > line.EmissionProperty.EmissionThreshold)
            {
                line.LineGameObject.sharedMaterial.SetColor("_EmissionColor", line.EmissionIntensity * line.EmissionColor * value);
            }
            else
            {
                line.LineGameObject.sharedMaterial.SetColor("_EmissionColor", Color.black);
            }
        }
コード例 #6
0
ファイル: LoadSongCommand.cs プロジェクト: dqchess/Linyx
        public override async void Execute()
        {
            ExtensionFilter[] extensions =
            {
                new ExtensionFilter("Sound Files", "mp3", "wav"),
            };

            string[] paths = StandaloneFileBrowser.OpenFilePanel("Open File", "", extensions, false);
            if (paths.Length > 0 && !string.IsNullOrEmpty(paths[0]))
            {
                string         filepath = paths[0];
                DialogProgress dialog   = DialogManager.ShowProgressLinear("Loading " + filepath, "Loading music", MaterialIconHelper.GetIcon(MaterialIconEnum.INFO_OUTLINE));
                Tuple <AudioFileReader, float[]> data = await Task.Run(() => ReadAudioFile(filepath));

                AudioClip clip = AudioClip.Create(filepath, (int)(data.Item1.Length / sizeof(float) / data.Item1.WaveFormat.Channels), data.Item1.WaveFormat.Channels, data.Item1.WaveFormat.SampleRate, false);
                clip.SetData(data.Item2, 0);

                dialog.Hide();
                SongLoadedSignal.Dispatch(clip);
                AudioPeerService.SetupAudioSource(clip);
            }
        }
コード例 #7
0
        private void MapServices()
        {
            #region Audio
            AudioPeerService audioPeerService = (contextView as GameObject)?.GetComponentInChildren <AudioPeerService>();
            if (audioPeerService != null)
            {
                injectionBinder.Bind <IAudioPeerService>().ToValue(audioPeerService);
            }
            #endregion

            #region Brush
            BrushService brushService = (contextView as GameObject)?.GetComponentInChildren <BrushService>();
            if (brushService != null)
            {
                injectionBinder.Bind <IBrushService>().ToValue(brushService);
            }
            #endregion

            #region Camera

            CameraService cameraService = (contextView as GameObject)?.GetComponentInChildren <CameraService>();
            if (cameraService != null)
            {
                injectionBinder.Bind <ICameraService>().ToValue(cameraService);
            }

            #endregion

            #region MyRegion

            CurveService curveService = (contextView as GameObject)?.GetComponentInChildren <CurveService>();
            if (curveService != null)
            {
                injectionBinder.Bind <ICurveService>().ToValue(curveService);
            }

            #endregion

            #region Draw

            DrawService drawService = (contextView as GameObject)?.GetComponentInChildren <DrawService>();
            if (drawService != null)
            {
                injectionBinder.Bind <IDrawService>().ToValue(drawService);
            }

            #endregion

            #region ViewManager

            ViewManager viewManager = (contextView as GameObject)?.GetComponentInChildren <ViewManager>();
            if (viewManager != null)
            {
                injectionBinder.Bind <IViewManager>().ToValue(viewManager);
            }

            #endregion

            #region Background

            BackgroundService backgroundService = (contextView as GameObject)?.GetComponentInChildren <BackgroundService>();
            if (cameraService != null)
            {
                injectionBinder.Bind <IBackgroundService>().ToValue(backgroundService);
            }

            #endregion

            #region Project

            ProjectService projectService = (contextView as GameObject)?.GetComponentInChildren <ProjectService>();
            if (cameraService != null)
            {
                injectionBinder.Bind <IProjectService>().ToValue(projectService);
            }

            #endregion

            #region Shortcut

            ShortcutService shortcutService = (contextView as GameObject)?.GetComponentInChildren <ShortcutService>();
            if (shortcutService != null)
            {
                injectionBinder.Bind <IShortcutService>().ToValue(shortcutService);
            }

            #endregion

            #region Save

            SaveManager saveManager = (contextView as GameObject)?.GetComponentInChildren <SaveManager>();
            if (shortcutService != null)
            {
                injectionBinder.Bind <ISaveManager>().ToValue(saveManager);
            }

            #endregion

            #region Recording

            RecordingService recordingService = (contextView as GameObject)?.GetComponentInChildren <RecordingService>();
            if (recordingService != null)
            {
                injectionBinder.Bind <IRecordingService>().ToValue(recordingService);
            }

            #endregion
        }