示例#1
0
        public override void PlaySample(int index, double dspTime)
        {
            if (_sampleBank.IsLoaded == false)
            {
                return;
            }

            PatternSample sampleInfo = _samples[index];

            if (onPatternWillPlay != null)
            {
                onPatternWillPlay(sampleInfo, index, dspTime);
            }

            if (_envelopeModule != null)
            {
                if (sampleInfo.ProcessedSample == null)
                {
                    sampleInfo.ProcessedSample = _sampleBank.GetProcessedSample(sampleInfo.SampleName, _envelopeModule.Envelope, sampleInfo.Pitch);
                }

                sampleInfo.ProcessedSample.PlayScheduled(_player, dspTime, _trackNb, sampleInfo.Gain);
            }
            else
            {
                GATData data = _sampleBank.GetAudioData(sampleInfo.SampleName);
                _player.PlayDataScheduled(data, dspTime, _trackNb, sampleInfo.Gain);
            }
        }
示例#2
0
 void OnPAtternWillPlay( PatternSample info, int indexInPattern, double dspTime )
 {
     if( indexInPattern == observedPatternIndex )
     {
         _lerpFactor = 1f / ( float )( dspTime + ( double )additionalLatency - AudioSettings.dspTime );
         _lerpVal 	= 0f;
         _state 		= State.LerpIn;
     }
 }
示例#3
0
        /// <summary>
        /// Inserts a pre configured PatternSample in the pattern.
        /// </summary>
        public void InsertSample(PatternSample newSample, int index)
        {
            if (index > _samples.Count)
            {
                index = _samples.Count;
            }

            _samples.Insert(index, newSample);
            _sampleCount++;

            if (_sampleCount == 1)
            {
                SubscribeToPulseIfNeeded();
            }
        }
示例#4
0
        /// <summary>
        /// Inserts a pre configured PatternSample in the pattern.
        /// </summary>
        public void InsertSample( PatternSample newSample, int index )
        {
            if( index > _samples.Count )
            {
                index = _samples.Count;
            }

            _samples.Insert( index, newSample );
            _sampleCount ++;

            if( _sampleCount == 1 )
            {
                SubscribeToPulseIfNeeded();
            }
        }
示例#5
0
    bool DrawSampleInfo( PatternSample info, bool canPreview, int index )
    {
        Rect boxRect;
        bool press = false;

        bool isEditing		 = index == _editedSampleIndex;
        bool shouldCollapse	 = isEditing;

        if( isEditing )
        {
            GUI.backgroundColor = __editedBoxColor;
            boxRect 			= EditorGUILayout.BeginVertical();

            GUI.Box( boxRect, "", __boxStyle );
            GUILayout.Space( 5f );
        }

        Rect foldRect = EditorGUILayout.BeginHorizontal();

        if( canPreview )
        {
            GUI.enabled = true;
        }
        else
        {
            GUI.enabled = false;
        }

        GUILayout.Space( 20f );
        GUILayout.Label( index.ToString(), GUILayout.Width( 20f ) );

        isEditing = EditorGUI.Foldout( new Rect( foldRect.x + 15f, foldRect.y, 15f, foldRect.height ), isEditing, "" );

        if( shouldCollapse && isEditing == false )
        {
            _editedSampleIndex = -1;
        }

        GUI.color = __purpleColor;
        if( GUILayout.Button( info.SampleName, GUILayout.Width( 100f ) ) )
        {
            press = true;
        }
        GUI.color = Color.white;

        GUI.enabled = true;

        EditorGUIUtility.labelWidth = 40f;
        EditorGUIUtility.fieldWidth = 25f;
        info.SemiTones = EditorGUILayout.FloatField( __transposeContent, info.SemiTones, GUILayout.ExpandWidth( false ) );
        GUILayout.Space( 5f );
        info.Gain = GUILayout.HorizontalSlider( info.Gain, 0f, 2f, GUILayout.Width( 100f ) );
        if( GUILayout.Button( info.Gain.ToString( "0.00" ), GUILayout.Width( 35f ) ) )
        {
            info.Gain = 1f;
        }

        GUILayout.Space( 5f );

        EditorGUILayout.EndHorizontal();

        if( isEditing )
        {
            if( _editedSampleIndex != index )
            {
                _editedSampleIndex  = index;
                _changedSampleIndex = -1;
            }

            if( _changedSampleIndex == -1 )
                _changedSampleIndex = GetIndexOfSample( info.SampleName );

            GUILayout.Space( 10f );

            GUILayout.BeginHorizontal();
            int cached = _changedSampleIndex;
            _changedSampleIndex = EditorGUILayout.Popup( _changedSampleIndex, _sampleOptions, GUILayout.Width( 100f ) );

            if( _changedSampleIndex != cached )
            {
                info.SampleName = _sampleOptions[ _changedSampleIndex ];
            }

            GUILayout.Space( 10f );

            GUI.color = Color.red;
            if( GUILayout.Button( "Remove", __buttonOptions ) )
            {
                _pulsedPattern.RemoveSampleAt( index );
                _samplesInfo = _pulsedPattern.Samples;
                _changedSampleIndex = -1;
                _editedSampleIndex = -1;
            }
            GUI.color = Color.white;
            GUILayout.EndHorizontal();

            GUILayout.Space( 5f );

            EditorGUILayout.EndVertical();

            GUI.backgroundColor = Color.white;
        }

        GUILayout.Space( 5f );

        return press;
    }