示例#1
0
        public void LoadAudioSamples()
        {
            try
            {
                if (Directory.Exists(ApplicationConfiguration.Instance.SoundboardSampleDirectory))
                {
                    foreach (string audioSamplePath in Directory.GetFiles(ApplicationConfiguration.Instance.SoundboardSampleDirectory, "*", SearchOption.AllDirectories))
                    {
                        string   relativePath   = Path.GetRelativePath(ApplicationConfiguration.Instance.SoundboardSampleDirectory, audioSamplePath);
                        string[] directorySplit = relativePath.Split('\\');
                        double   totalSeconds   = AudioAgent.GetFileAudioDuration(audioSamplePath).TotalSeconds;

                        string groupName = "Ungrouped";
                        if (directorySplit.Length > 1)
                        {
                            groupName = directorySplit[0];
                        }

                        _soundboardSampleCollection.Add(new SoundboardSample(audioSamplePath)
                        {
                            GroupName          = groupName,
                            FileTimeMax        = totalSeconds,
                            FileTimeMin        = 0,
                            FileTimeUpperValue = totalSeconds,
                            FileTimeLowerValue = 0,
                            HotkeyId           = _soundboardSampleCollection.Count
                        });
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationLogger.Log(ex.Message, ex.StackTrace);
            }
        }
示例#2
0
    void Awake()
    {
        if (mInstance != null)
        {
            Debug.LogError("Only one instance of AudioAgent allowed. Destroying " + gameObject + " and leaving " + mInstance.gameObject);
            Destroy(gameObject);
            return;
        }

        mInstance = this;

        if (!PlayerPrefs.HasKey(isAudioOnString))
        {
            PlayerPrefs.SetInt(isAudioOnString, 1);
        }

        isAudioOn = (PlayerPrefs.GetInt(isAudioOnString) == 1);

        if (soundsText)
        {
            soundsText.text = (isAudioOn ? "On" : "Off");
        }

        audioSourcesByType = new Dictionary <SoundEffectType, AudioSource>();
        deck = new List <int>();
    }
        private void btnSettings_MouseUp(object sender, MouseButtonEventArgs e)
        {
            SettingsWindow settingsWindow = new SettingsWindow();

            if (settingsWindow.ShowDialog().Value)
            {
                _mainWindowViewModel.RecordHotkeyDisplay = _mainWindowViewModel.RecordHotkey.ToString();

                _mainWindowViewModel.SoundboardSampleCollection.ToList().ForEach(x =>
                {
                    _mainWindowViewModel.RegisterSoundboardSampleHotKey(x.Hotkey, x.HotkeyId);

                    // I know this looks stupid. But it's really just to update the display
                    x.Hotkey = x.Hotkey;
                });

                _mainWindowViewModel.RegisterRecordHotKey(ApplicationConfiguration.Instance.RecordHotkey);

                // Re-intialize capture device
                if (_mainWindowViewModel.SelectedCaptureDevicesCollection.Any())
                {
                    AudioAgent.BeginAudioCapture(_mainWindowViewModel.SelectedCaptureDevicesCollection.First());
                }
            }
        }
示例#4
0
        public async Task DeleteSampleAsync(SoundboardSample soundboardSample)
        {
            try
            {
                // Recursively try to acquire file lock. This can sometimes take a few seconds to release after
                // an audio playback event has ended
                bool success = false;
                while (!success)
                {
                    try
                    {
                        AudioAgent.StopAudioPlayback(SelectedOutputDevicesCollection.ToList());
                        File.Delete(soundboardSample.FilePath);
                        SoundboardSampleCollection.Remove(soundboardSample);

                        success = true;
                    }
                    catch
                    {
                        await Task.Delay(500);
                    }
                }
            }
            catch (Exception ex)
            {
                ApplicationLogger.Log(ex.Message, ex.StackTrace);
            }
        }
    private void OnTouchUp(int fingerIndex, Vector2 fingerPos, float timeHeldDown)
    {
        if (!gameObject.activeInHierarchy || (ignoreOnPopUp && RatingAgent.GetPopUpEnabled()))
        {
            return;
        }

        if (colorController)
        {
            colorController.SetColor(ColorAgent.GetCurrentColorPack().TypeToColor(colorController.colorType));
        }

        if (GameAgent.GetWasHolding())
        {
            return;
        }

        if (RectTransformUtility.RectangleContainsScreenPoint(rectTransform, fingerPos, null))
        {
            if (OnAreaTouch != null)
            {
                OnAreaTouch();
            }

            if (OnAreaTouchWithCallback != null)
            {
                OnAreaTouchWithCallback(this);
            }

            AudioAgent.PlaySoundEffect(AudioAgent.SoundEffectType.ButtonTap);
        }
    }
示例#6
0
        public void SaveSample(SoundboardSample soundboardSample)
        {
            try
            {
                // Trimming
                if (soundboardSample.FileTimeUpperValue != soundboardSample.FileTimeMax || soundboardSample.FileTimeLowerValue != soundboardSample.FileTimeMin)
                {
                    AudioAgent.TrimFile(soundboardSample.FilePath, soundboardSample.FileTimeLowerValue * 1000, soundboardSample.FileTimeUpperValue * 1000);

                    soundboardSample.FileTimeMin        = 0;
                    soundboardSample.FileTimeMax        = AudioAgent.GetFileAudioDuration(soundboardSample.FilePath).TotalSeconds;
                    soundboardSample.FileTimeLowerValue = 0;
                    soundboardSample.FileTimeUpperValue = soundboardSample.FileTimeMax;
                }

                // File name
                if (Path.GetFileNameWithoutExtension(soundboardSample.FilePath) != soundboardSample.Name)
                {
                    string targetDirectory = Path.Combine(ApplicationConfiguration.Instance.SoundboardSampleDirectory, soundboardSample.GroupName == "Ungrouped" ? string.Empty : soundboardSample.GroupName);
                    string newFilePath     = soundboardSample.GetVirtualFilePath();

                    Directory.CreateDirectory(targetDirectory);
                    File.Move(soundboardSample.FilePath, newFilePath);

                    soundboardSample.FilePath = newFilePath;
                }

                soundboardSample.SaveMetadataProperties();
            }
            catch (Exception ex)
            {
                ApplicationLogger.Log(ex.Message, ex.StackTrace);
            }
        }
示例#7
0
        public void OnWindowClosing(object sender, EventArgs e)
        {
            AudioAgent.StopAudioCapture();
            UnregisterHotKeysAndHooks();

            ApplicationConfiguration.Instance.RecordHotkey = RecordHotkey.Value;
            SoundboardSampleCollection.ToList().ForEach(x => x.SaveMetadataProperties());
        }
示例#8
0
    private void FinishPrint()
    {
        AnalyticsAgent.LogAnalyticEvent(AnalyticsAgent.AnalyticEvent.PrintFinished);
        AudioAgent.StopSoundEffect(AudioAgent.SoundEffectType.Print);
        AudioAgent.PlaySoundEffect(AudioAgent.SoundEffectType.PrintFinish);

        ChangeState(State.Finished);
    }
示例#9
0
    protected override void PlayMovement()
    {
        AudioAgent agent = GetComponent <VolumeAudioAgent>();

        if (agent.IsAudioStopped("RockBoiMove"))
        {
            agent.PlaySoundEffect("RockBoiMove");
        }
    }
示例#10
0
    /*
     * void OnGUI()
     * {
     *      GUI.Label( new Rect( 10f, 10f, 1000f, 1000f ), "" + currentState );
     * }
     */

    private void OnRestartAreaTouch()
    {
        wasRestarting = true;

        if (currentState != State.Finished)
        {
            AudioAgent.StopSoundEffect(AudioAgent.SoundEffectType.Print);
            AnalyticsAgent.LogAnalyticEvent(AnalyticsAgent.AnalyticEvent.PrintFinished);
        }

//		ChangeState( State.Advertising );
        ChangeState(State.Ready);
    }
示例#11
0
        public void BeginAudioCapture()
        {
            try
            {
                AudioAgent.StopAudioCapture();

                if (SelectedCaptureDevicesCollection.Any())
                {
                    AudioAgent.BeginAudioCapture(SelectedCaptureDevicesCollection.First());
                }
            }
            catch (Exception ex)
            {
                ApplicationLogger.Log(ex.Message, ex.StackTrace);
            }
        }
示例#12
0
    private void OnDoubleTap(int fingerIndex, Vector2 fingerPos)
    {
        if ((currentState == State.Printing || currentState == State.Paused) && CameraAgent.MainCameraObject.transform.localPosition.x == 0f)
        {
            StopCoroutine("DoPrint");
            AudioAgent.StopSoundEffect(AudioAgent.SoundEffectType.Print);

            while (index < BoardAgent.BoardSize)
            {
                SinglePrint();

                index++;
            }

            FinishPrint();
        }
    }
示例#13
0
        public void PlayAudioSample(SoundboardSample soundboardSample, PlaybackScope playbackScope)
        {
            try
            {
                var outputDevices = SelectedOutputDevicesCollection.Where(x => x.PlaybackScope >= playbackScope).ToList();
                if (outputDevices.Any())
                {
                    outputDevices[0].PlaybackStopped += OnAudioPlaybackStopped;
                    soundboardSample.StartPlaybackTimer();
                }

                outputDevices.ForEach(outputDevice =>
                {
                    AudioAgent.BeginAudioPlayback(soundboardSample.FilePath, outputDevice, (float)soundboardSample.Volume / (float)100, soundboardSample.FileTimeLowerValue, soundboardSample.FileTimeUpperValue);
                });
            }
            catch (Exception ex)
            {
                ApplicationLogger.Log(ex.Message, ex.StackTrace);
            }
        }
示例#14
0
        private void LoadAudioDevices()
        {
            try
            {
                var activeWindowsAudioDevices = AudioAgent.GetWindowsAudioDevices().ToList();

                // Capture Devices
                if (ApplicationConfiguration.Instance.AudioCaptureDevices?.Any() ?? false)
                {
                    var activeCaptureDevices = from activeDevice in activeWindowsAudioDevices
                                               join audioDeviceId in ApplicationConfiguration.Instance.AudioCaptureDevices.Select(x => x.DeviceId)
                                               on activeDevice.DeviceId equals audioDeviceId
                                               select new AudioCaptureDevice(activeDevice)
                    {
                        DeviceActive = true
                    };

                    SelectedCaptureDevicesCollection = new ObservableCollection <AudioCaptureDevice>(activeCaptureDevices);
                }

                // Output Devices
                if (ApplicationConfiguration.Instance.AudioOutputDevices?.Any() ?? false)
                {
                    var activeOutputDevices = from activeDevice in activeWindowsAudioDevices
                                              join audioDeviceId in ApplicationConfiguration.Instance.AudioOutputDevices.Select(x => x.DeviceId)
                                              on activeDevice.DeviceId equals audioDeviceId
                                              select new AudioOutputDevice(activeDevice)
                    {
                        DeviceActive = true, PlaybackScope = ApplicationConfiguration.Instance.AudioOutputDevices.First(x => x.DeviceId == activeDevice.DeviceId).PlaybackScope
                    };

                    SelectedOutputDevicesCollection = new ObservableCollection <AudioOutputDevice>(activeOutputDevices);
                }
            }
            catch (Exception ex)
            {
                ApplicationLogger.Log(ex.Message, ex.StackTrace);
            }
        }
示例#15
0
    private void OnDragUp(int fingerIndex, Vector2 fingerPos)
    {
        if (RatingAgent.GetPopUpEnabled())
        {
            return;
        }

        if (Mathf.Abs(dragDeltaX) > swipeThreshold)
        {
            currentScreenX -= Screen.width * Mathf.Sign(dragDeltaX);
            AudioAgent.PlaySoundEffect(AudioAgent.SoundEffectType.Swipe);
        }
        else
        {
            currentScreenX = Mathf.Round(CameraAgent.MainCameraObject.transform.localPosition.x / Screen.width) * Screen.width;
        }

        currentScreenX = Mathf.Clamp(currentScreenX, Screen.width * -1f, Screen.width);
        StopCoroutine("DoDragNavigation");
        StartCoroutine("DoNavigation", currentScreenX);

        wasDragging = false;
    }
示例#16
0
        public void OnFileWritten(object sender, EventArgs e)
        {
            try
            {
                string filePath     = sender as string;
                double totalSeconds = AudioAgent.GetFileAudioDuration(filePath).TotalSeconds;

                SoundboardSample NewSoundboardSample = new SoundboardSample(filePath)
                {
                    GroupName          = "Ungrouped",
                    FileTimeMax        = totalSeconds,
                    FileTimeMin        = 0,
                    FileTimeUpperValue = totalSeconds,
                    FileTimeLowerValue = 0,
                    HotkeyId           = SoundboardSampleCollection.Count
                };

                SoundboardSampleCollection.Add(NewSoundboardSample);
            }
            catch (Exception ex)
            {
                ApplicationLogger.Log(ex.Message, ex.StackTrace);
            }
        }
示例#17
0
        /// <summary>
        /// Provides application shortcut functions for shortcut events from Windows
        /// </summary>
        /// <param name="hwnd"></param>
        /// <param name="msg"></param>
        /// <param name="wParam"></param>
        /// <param name="lParam"></param>
        /// <param name="handled"></param>
        /// <returns></returns>
        public IntPtr HwndHook(IntPtr hwnd, int msg, IntPtr wParam, IntPtr lParam, ref bool handled)
        {
            const int WM_HOTKEY = 0x0312;

            switch (msg)
            {
            case WM_HOTKEY:

                // Record button
                int virtualKeyParam = (((int)lParam >> 16) & 0xFFFF);
                if (_recordHotKey != null && _recordHotKey != Key.None)
                {
                    uint keyCode = Convert.ToUInt32(KeyInterop.VirtualKeyFromKey(_recordHotKey.Value).ToString("X"), 16);
                    if (_recordHotkeyId == wParam.ToInt32() && virtualKeyParam == keyCode)
                    {
                        AudioAgent.WriteAudioBufferToFile();
                    }
                }

                // Soundboard samples
                var soundboardSample = SoundboardSampleCollection.Where(x => x.HotkeyId == wParam.ToInt32()).FirstOrDefault();
                if (soundboardSample != null && soundboardSample.Hotkey != Key.None)
                {
                    uint keyCode = Convert.ToUInt32(KeyInterop.VirtualKeyFromKey(soundboardSample.Hotkey).ToString("X"), 16);
                    if (soundboardSample.HotkeyId == wParam.ToInt32() && virtualKeyParam == keyCode)
                    {
                        PlayAudioSample(soundboardSample, PlaybackScope.Global);
                    }
                }

                handled = true;
                break;
            }

            return(IntPtr.Zero);
        }
示例#18
0
    void Awake()
    {
        if( mInstance != null )
        {
            Debug.LogError( "Only one instance of AudioAgent allowed. Destroying " + gameObject + " and leaving " + mInstance.gameObject );
            Destroy( gameObject );
            return;
        }

        mInstance = this;

        int numAudioLayers = AudioLayerVolumes.Length;

        for( int i = 0; i < numAudioLayers; i++ )
        {
            if( i == 0 )
            {
                if( PlayerPrefs.HasKey( useSFXString ) )
                    AudioLayerVolumes[i] = (float)PlayerPrefs.GetInt( useSFXString );
                else
                    AudioLayerVolumes[i] = Mathf.Clamp01( AudioLayerVolumes[i] );
            }
            else if( i == 1 )
            {
                if( PlayerPrefs.HasKey( useBackgroundMusicString ) )
                    AudioLayerVolumes[i] = (float)PlayerPrefs.GetInt( useBackgroundMusicString );
                else
                    AudioLayerVolumes[i] = Mathf.Clamp01( AudioLayerVolumes[i] );
            }

            AddAudioLayerVolume( (AudioType) i );
        }
    }
示例#19
0
    private void internalChangeState(State newState)
    {
        if (currentState == newState)
        {
            return;
        }

        currentState = newState;

        switch (currentState)
        {
        case State.Ready:
        {
            showUI = true;
            SetUIEnabled(false);
            TipAgent.ShowFirstTip();
            UpdateNavigationHighlight(true);

            ColorAgent.AdvanceColorPack();

            SpriteAgent.ClearSpriteNames();

            BoardAgent.ResetBoard();
            ShuffleDeck();
            colorOffset = Random.Range(0f, 360f);
            SpriteAgent.Randomize();

            index = 0;
        } break;

        case State.Printing:
        {
            SetUIEnabled(false);

            speed = (float)BoardAgent.BoardSize / fillTime;

            SpriteAgent.LogSpriteName();

            AudioAgent.PlaySoundEffect(AudioAgent.SoundEffectType.Print, fillTime);
            AudioAgent.PitchSoundEffect(AudioAgent.SoundEffectType.Print, 1f);

            if (index == 0)
            {
                StartCoroutine("DoPrint");
            }
        } break;

        case State.Paused:
        {
            TipAgent.ShowNextTip();
            SetUIEnabled(true);

            speed = 0f;

            AudioAgent.PauseSoundEffect(AudioAgent.SoundEffectType.Print);
        } break;

        case State.FastForwarding:
        {
            SetUIEnabled(false);

            speed = (float)BoardAgent.BoardSize / fillTime * 5f;

            AudioAgent.PitchSoundEffect(AudioAgent.SoundEffectType.Print, 2f);

            wasFastForwarding = true;
        } break;

        case State.Finished:
        {
            showUI = true;
            TipAgent.ShowNextTip();
            SetUIEnabled(true);
        } break;

        case State.Advertising:
        {
            SetUIEnabled(false);
            RatingAgent.CheckForPrompt();
            //AdAgent.ShowInterstitialImage();
        } break;
        }
    }
        public AudioCaptureDeviceDialogViewModel(IEnumerable <AudioCaptureDevice> audioCaptureDevices)
        {
            AudioCaptureDevices = new ObservableCollection <AudioCaptureDevice>(audioCaptureDevices);

            var allWindowsAudioDevices = new ObservableCollection <AudioCaptureDevice>(AudioAgent.GetWindowsAudioDevices()
                                                                                       .Select(device => new AudioCaptureDevice(device)));

            allWindowsAudioDevices.Where(device => !AudioCaptureDevices.Any(x => x.DeviceId == device.DeviceId)).ToList().ForEach(device => AudioCaptureDevices.Add(device));
        }
示例#21
0
 public void StopAudioPlayback()
 {
     AudioAgent.StopAudioPlayback(SelectedOutputDevicesCollection.ToList());
 }