void OnGUI() { GUILayout.BeginArea( AREA ); GUILayout.Label( "G-Audio I/O examples: Looper" ); GUILayout.Label( "www.G-Audio-Unity.com" ); if( _recState == RecState.InRec ) GUI.enabled = false; GUILayout.Label( "Warning! Live mic, plug headphones or bear the larsen." ); _micMode = ( MicMode )GUILayout.SelectionGrid( ( int )_micMode, __micModes, 3 ); if( GUI.changed ) { switch( _micMode ) { case MicMode.Muted: mic.playThrough = false; streamToTrack.enabled = false; break; case MicMode.PlayThrough: mic.playThrough = true; streamToTrack.enabled = false; break; case MicMode.Track: mic.playThrough = false; streamToTrack.enabled = true; streamToTrack.TargetTrack = _currentTrack; break; } GUI.changed = false; } GUILayout.Space( 5f ); streamToCache.Overdub = GUILayout.Toggle( streamToCache.Overdub, "Overdub" ); GUILayout.Space( 5f ); metronomePattern.enabled = GUILayout.Toggle( metronomePattern.enabled, "Metronome" ); GUILayout.Space( 5f ); if( _recState == RecState.Idle ) { if( GUILayout.Button( "Rec", GUILayout.Width( 310f ) ) && _recState != RecState.InRec ) { _recState = RecState.WillRec; } } else if( _recState == RecState.WillRec ) { GUILayout.Button( ( 4 - _lastPulseIndex ).ToString(), GUILayout.Width( 310f ) ); } else { GUILayout.Button( "Recording", GUILayout.Width( 310f ) ); } GUILayout.Space( 5f ); GUI.changed = false; _currentRecIndex = GUILayout.SelectionGrid( _currentRecIndex, __trackSelection, _numTracks ); if( GUI.changed ) { UpdateCurrentTrack(); } GUILayout.Space( 10f ); GUILayout.Label( "Track Gain: "+_currentTrack.StereoGain.ToString( "0.00" ) ); _currentTrack.StereoGain = GUILayout.HorizontalSlider( _currentTrack.StereoGain, 0f, 2f ); GUILayout.Space( 5f ); GUILayout.Label( "Track Pan " ); _currentTrack.StereoPan = GUILayout.HorizontalSlider( _currentTrack.StereoPan, 0f, 1f ); GUILayout.Space( 10f ); if( GUILayout.Button( "Clear Track" ) ) { _recs[ _currentRecIndex ].data[ 0 ].Clear(); _recs[ _currentRecIndex ].shouldPlay = false; } GUILayout.Space( 10f ); #if UNITY_WEBPLAYER GUI.enabled = false; #endif if( streamToWav.IsWriting == false ) { if( GUILayout.Button( "Start recording to wav" ) ) { streamToWav.StartWriting(); } } else { if( GUILayout.Button( "Stop recording to wav" ) ) { streamToWav.EndWriting(); } } #if UNITY_WEBPLAYER GUILayout.Label( "Recording to disk is disabled in WebPlayers." ); #endif GUILayout.EndArea(); GUI.enabled = true; GUILayout.BeginArea( FILTER_AREA ); GUILayout.Label( "Track " + _recs[ _currentRecIndex ].trackNb + " Filter " ); if( _selectedFilter != null ) { int i; GUILayout.Space( 10f ); GUILayout.Label( _filterName ); GUILayout.Space( 10f ); AGATFilter.FilterProperty prop; for( i = 0; i < _trackFilterProps.Length; i++ ) { prop = _trackFilterProps[ i ]; if( prop.IsGroupToggle ) continue; GUILayout.BeginHorizontal(); GUILayout.Label( prop.LabelString, GUILayout.Width( 100f ) ); prop.SetValue( GUILayout.HorizontalSlider( prop.CurrentValue, prop.Range.Min, prop.Range.Max, GUILayout.Width( 200f ) ) ); GUILayout.EndHorizontal(); } _selectedFilter.Bypass = GUILayout.Toggle( _selectedFilter.Bypass, "Bypass Filter" ); } GUILayout.EndArea(); }
void OnGUI() { GUILayout.BeginArea(AREA); GUILayout.Label("G-Audio I/O examples: Looper"); GUILayout.Label("www.G-Audio-Unity.com"); if (_recState == RecState.InRec) { GUI.enabled = false; } GUILayout.Label("Warning! Live mic, plug headphones or bear the larsen."); _micMode = ( MicMode )GUILayout.SelectionGrid(( int )_micMode, __micModes, 3); if (GUI.changed) { switch (_micMode) { case MicMode.Muted: mic.playThrough = false; streamToTrack.enabled = false; break; case MicMode.PlayThrough: mic.playThrough = true; streamToTrack.enabled = false; break; case MicMode.Track: mic.playThrough = false; streamToTrack.enabled = true; streamToTrack.TargetTrack = _currentTrack; break; } GUI.changed = false; } GUILayout.Space(5f); streamToCache.Overdub = GUILayout.Toggle(streamToCache.Overdub, "Overdub"); GUILayout.Space(5f); metronomePattern.enabled = GUILayout.Toggle(metronomePattern.enabled, "Metronome"); GUILayout.Space(5f); if (_recState == RecState.Idle) { if (GUILayout.Button("Rec", GUILayout.Width(310f)) && _recState != RecState.InRec) { _recState = RecState.WillRec; } } else if (_recState == RecState.WillRec) { GUILayout.Button((4 - _lastPulseIndex).ToString(), GUILayout.Width(310f)); } else { GUILayout.Button("Recording", GUILayout.Width(310f)); } GUILayout.Space(5f); GUI.changed = false; _currentRecIndex = GUILayout.SelectionGrid(_currentRecIndex, __trackSelection, _numTracks); if (GUI.changed) { UpdateCurrentTrack(); } GUILayout.Space(10f); GUILayout.Label("Track Gain: " + _currentTrack.StereoGain.ToString("0.00")); _currentTrack.StereoGain = GUILayout.HorizontalSlider(_currentTrack.StereoGain, 0f, 2f); GUILayout.Space(5f); GUILayout.Label("Track Pan "); _currentTrack.StereoPan = GUILayout.HorizontalSlider(_currentTrack.StereoPan, 0f, 1f); GUILayout.Space(10f); if (GUILayout.Button("Clear Track")) { _recs[_currentRecIndex].data[0].Clear(); _recs[_currentRecIndex].shouldPlay = false; } GUILayout.Space(10f); #if UNITY_WEBPLAYER GUI.enabled = false; #endif if (streamToWav.IsWriting == false) { if (GUILayout.Button("Start recording to wav")) { streamToWav.StartWriting(); } } else { if (GUILayout.Button("Stop recording to wav")) { streamToWav.EndWriting(); } } #if UNITY_WEBPLAYER GUILayout.Label("Recording to disk is disabled in WebPlayers."); #endif GUILayout.EndArea(); GUI.enabled = true; GUILayout.BeginArea(FILTER_AREA); GUILayout.Label("Track " + _recs[_currentRecIndex].trackNb + " Filter "); if (_selectedFilter != null) { int i; GUILayout.Space(10f); GUILayout.Label(_filterName); GUILayout.Space(10f); AGATFilter.FilterProperty prop; for (i = 0; i < _trackFilterProps.Length; i++) { prop = _trackFilterProps[i]; if (prop.IsGroupToggle) { continue; } GUILayout.BeginHorizontal(); GUILayout.Label(prop.LabelString, GUILayout.Width(100f)); prop.SetValue(GUILayout.HorizontalSlider(prop.CurrentValue, prop.Range.Min, prop.Range.Max, GUILayout.Width(200f))); GUILayout.EndHorizontal(); } _selectedFilter.Bypass = GUILayout.Toggle(_selectedFilter.Bypass, "Bypass Filter"); } GUILayout.EndArea(); }