Ejemplo n.º 1
0
 public void ClearQueue()
 {
     m_QueuedSegment = null;
     m_QueuedMaster = false;
 }
Ejemplo n.º 2
0
    // Calculate whether we're within SyncRes duration of next loop point, if so play with delay set to countdown time
    void UpdateMasterLoop()
    {
        if ( m_MasterSegment == null || !m_MasterSegment.IsPlaying() )
        {
            m_MasterSegment = GetMasterSegment();
        }

        if ( m_MasterSegment != null )
        {
            m_LoopBeats = m_MasterSegment.m_LoopPoint * m_BPM/60;

            m_loopCountdown = m_MasterSegment.m_LoopPoint - m_MasterSegment.GetTime();

            if ( m_loopCountdown < m_syncRes )
            {
                //Debug.Log ("Loop frame @ " + m_loopCountdown);
                RetriggerSegments(m_loopCountdown);
            }

            m_BPM = m_MasterSegment.m_BPM;
        }
    }
Ejemplo n.º 3
0
 // Toggle (play) functions
 public void ToggleSegment( string segName, Flags flags = Flags.None, EPMusicSegment.CueType cueType = EPMusicSegment.CueType.NONE )
 {
     int i = GetSegmentIndex( segName );
     if ( i >= 0 )
         ToggleSegment ( i, flags, cueType );
 }
Ejemplo n.º 4
0
 public void ToggleSegment( int i, Flags flags = Flags.None, EPMusicSegment.CueType cueType = EPMusicSegment.CueType.NONE )
 {
     if ( !m_Segments[i].IsPlaying() )
         {
             //Debug.Log("Starting");
             PlaySegment(i, flags, cueType);
         }
         else
         {
             StopSegment(i);
         }
 }
Ejemplo n.º 5
0
    public void StopSegment( int i )
    {
        EPMusicSegment seg = m_Segments[i];

        if ( seg != null )
        {
            seg.Stop();
            //Debug.Log("Stop segment " + i );
            if ( seg == m_MasterSegment )
            {
                m_MasterSegment = null;
                ClearQueue();
            }
        }
    }
Ejemplo n.º 6
0
 // Set a segment as MasterSegment
 public void SetMaster( EPMusicSegment seg )
 {
     m_MasterSegment = seg;
 }
Ejemplo n.º 7
0
    // Deal with queued segments
    public void ProcessSegmentQueue()
    {
        if ( m_QueueTime >= 0 )
        {
            //Debug.Log ("m_QueueTime = " + m_QueueTime);
            double now = m_MasterSegment.GetTime();

            // Hi-resolution sync
            double triggerDelta = m_QueueTime - now;

            if ( triggerDelta < m_syncRes )
            {
                if ( m_QueuedSegment.m_CuePointSync == true )
                    m_QueuedSegment.SetTime( m_QueueTime % m_QueuedSegment.m_LoopPoint );

                m_QueuedSegment.PlayScheduled( triggerDelta );

                if ( m_QueuedMaster == true )
                {
                    //Debug.Log ("Stopping master: " + m_MasterSegment + " @ " + AudioSettings.dspTime);
                    m_MasterSegment.Stop();
                    SetMaster(m_QueuedSegment);
                    //Debug.Log ("Master is: " + m_MasterSegment + " @ " + AudioSettings.dspTime);
                }
                m_QueuedSegment = null;
            }
        }
    }
Ejemplo n.º 8
0
    public void PlaySegment( int i, Flags flags = Flags.None, EPMusicSegment.CueType cueType = EPMusicSegment.CueType.NONE )
    {
        EPMusicSegment seg = m_Segments[i];

        if ( seg != null && !seg.IsPlaying() )
        {
            if ( cueType == EPMusicSegment.CueType.NONE )
                cueType = seg.m_CueType;

            if ( m_MasterSegment == null )
            {
                SetMaster(seg);
                seg.Play();
                //Debug.Log("Play Segment: " + i + " @ " + AudioSettings.dspTime);
            }
            else if ( cueType == EPMusicSegment.CueType.INSTANT )
            {
                seg.SetTimeSamples( m_MasterSegment.GetTimeSamples() );

                if ( ( flags & Flags.IsMaster ) == Flags.IsMaster )
                {
                    SetMaster(seg);
                    //Debug.Log("Master Segment");
                }

                seg.Play();
                //Debug.Log("Play Segment: " + i + " @ " + AudioSettings.dspTime);
            }
            else
            {
                if ( cueType == EPMusicSegment.CueType.POINT )
                {
                    m_QueueTime = seg.m_CuePoint;
                }
                else if ( cueType == EPMusicSegment.CueType.GRID )
                {
                    m_QueueTime = GetNextGrid();
                }
                else if ( cueType == EPMusicSegment.CueType.BAR )
                {
                    m_QueueTime = GetNextBar();
                }
                else if ( cueType == EPMusicSegment.CueType.END )
                {
                    m_QueueTime = m_MasterSegment.m_LoopPoint;
                    //Debug.Log ("m_QueueTime = " + m_QueueTime);
                }
                else
                {
                    //Debug.Log("Can't queue segment, no Cue Type defined");
                }

                m_QueuedSegment = seg;

                if ( ( flags & Flags.IsMaster ) == Flags.IsMaster )
                {
                    m_QueuedMaster = true;
                    //Debug.Log("Queued Master to " + m_QueueTime);
                }
                else
                    m_QueuedMaster = false;

                //Debug.Log("Queue segment " + i );
            }
        }
    }
Ejemplo n.º 9
0
 // Play functions
 public void PlaySegment( string segName, Flags flags = Flags.None, EPMusicSegment.CueType cueType = EPMusicSegment.CueType.NONE )
 {
     //Debug.Log("Play Segment: " + segName + " @ " + AudioSettings.dspTime);
     int i = GetSegmentIndex( segName );
     if ( i >= 0 )
         PlaySegment ( i, flags, cueType );
 }