Пример #1
0
        void tmr_Tick(object sender, EventArgs e)
        {
            y += 1f;

            if (y >= img.Height)
            {
                y = -this.Height;
            }

            specValue++;

            if (specValue > (customSpectrum.Count - 1))
            {
                specValue = 0;
            }


            soundChannel.getPosition(ref position, FMOD.TIMEUNIT.MS);

            if (position >= 33500 && position <= 33500 + 2500)
            {
                soundChannel.setPosition(position + 2500, FMOD.TIMEUNIT.MS);
            }

            this.Invalidate();
        }
Пример #2
0
 public static void SetPlayPosition(int position)
 {
     if (IsPlaying())
     {
         FMODChannel.setPosition((uint)position, FMOD.TIMEUNIT.MS);
     }
 }
Пример #3
0
        public static void SetPlayPosition(uint position)
        {
            if (channel == null)
            {
                return;
            }

            channel.setPosition(position, FMOD.TIMEUNIT.MS);
        }
Пример #4
0
        /// <summary>
        /// Sets the position of the playing stream
        /// </summary>
        /// <param name="channel"></param>
        /// <param name="position"></param>
        private void SetPostion(uint position)
        {
            FMOD.RESULT result;

            if (_channel != null)
            {
                //set position
                result = _channel.setPosition(position, FMOD.TIMEUNIT.MS);
                CheckError(result);
            }
        }
Пример #5
0
 public override void Seek(ulong Millisecs)
 {
     if (m_bOpened && Millisecs <= m_nLength)
     {
         if (m_bPlaying)
         {
             if (m_FMODChannel != null)
             {
                 m_FMODChannel.setPosition((uint)Millisecs, FMOD.TIMEUNIT.MS);
             }
         }
     }
 }
Пример #6
0
        FMOD.Channel PlaySample(RenderParams rp, RenderCanvas canvas, List <FMOD.DSP> dspList)
        {
            FMOD.Channel channel = null;
            FMOD.RESULT  r       = MusicEngine.AudioEngine.playSound(FMOD.CHANNELINDEX.FREE, _sound, true, ref channel);
            if (r == FMOD.RESULT.OK && channel != null)
            {
                // set regular play properties
                AdaptChannelSettings(channel, rp, canvas);

                // set play position
                uint tMs = (uint)Math.Round(rp.Time * 1000.0);
                if (tMs > 0)
                {  // only set position if there is a need
                    r = channel.setPosition(tMs, FMOD.TIMEUNIT.MS);
#if DEBUG
                    Util.Log("   setPos(" + tMs + ")");
#endif
                }

                // set optional DSP unit(s) on channel
                if (r == FMOD.RESULT.OK)
                {
                    FMOD.DSPConnection conn = null;
                    foreach (FMOD.DSP d in dspList)
                    {
                        r = channel.addDSP(d, ref conn); // TODO errcheck
                    }

                    // go - start playing
                    if (r == FMOD.RESULT.OK)
                    {
                        r = channel.setPaused(false);
                    }
                }
            } // if
            Util.ERRCHECK(r);
            return(channel);
        }
Пример #7
0
 public static void Reset()
 {
     Channel.setPosition(0, FMOD.TIMEUNIT.MS);
 }
Пример #8
0
 public override void Stop()
 {
     FMOD_Audio.CheckFMODResult(mChannel.setPaused(true));
     FMOD_Audio.CheckFMODResult(mChannel.setPosition(0, FMOD.TIMEUNIT.MS));
 }
Пример #9
0
        /**
         * called when this sample/effect should render itself, possibly spawning a new
         * playing instance or modifying an already playing instance.
         */
        internal void Render(RenderParams rp, RenderCanvas canvas, List <FMOD.DSP> dspList, int audioRepeats)
        {
#if DEBUG
            Util.Log("Render HID=" + rp.HierarchyID + " T=" + Math.Round(rp.Time, 3) + " AbsT=" + Math.Round(rp.AbsTime, 3) + " A=" + Math.Round(rp.Ampl, 3) + "\n");
#endif
            // check if duration is not exceeded
            if (rp.Time > _soundDuration * ((double)audioRepeats))
            {
                return;
            }

            bool         wasPlaying = _nowPlayingList.ContainsKey(rp.HierarchyID);
            FMOD.Channel channel    = null;
            FMOD.RESULT  r;

            if (wasPlaying)
            {
                channel = _nowPlayingList[rp.HierarchyID];
                // check if still playing now
                bool isPlayingNow = false;
                r = channel.isPlaying(ref isPlayingNow);
                //Util.ERRCHECK(r); // TODO is this needed?
                if (isPlayingNow)
                {   // if so, adapt sample properties only.
                    AdaptChannelSettings(channel, rp, canvas);

                    // check playing time
                    uint playPosMs      = 0;
                    int  idealPlayPosMs = (int)Math.Round(rp.Time * 1000.0);
                    channel.getPosition(ref playPosMs, FMOD.TIMEUNIT.MS);

                    if (Math.Abs(((int)playPosMs) - idealPlayPosMs) > 5000 && idealPlayPosMs >= 0)  // FIXME specify error margin better, somewhere? configurable per sample?
                    {
                        //FIXME HACK enable tracking when needed !!! below.
                        channel.setPosition((uint)idealPlayPosMs, FMOD.TIMEUNIT.MS);
                        playPosMs = (uint)idealPlayPosMs;
                    }
                    // store current pos on canvas
                    if (canvas.TimeMarker == 0)
                    {
                        canvas.TimeMarker = ((double)playPosMs) / 1000.0;
                    }
                }
                else
                {   // if not anymore, remove from list
                    _nowPlayingList.Remove(rp.HierarchyID);
                }
            }
            else
            {                                         // was not playing but should be rendered - hence, initiate playing now
                if (rp.Time < _soundDuration - 0.050) // extra safety margin - do not start if close to end. TODO configurable time?
                {
                    channel = PlaySample(rp, canvas, dspList);
                    channel.setLoopCount(audioRepeats - 1);
                    if (channel != null)
                    {
#if DEBUG
                        Util.Log("Play   HID=" + rp.HierarchyID + " T=" + Math.Round(rp.Time, 3) + " AbsT=" + Math.Round(rp.AbsTime, 3) + " A=" + Math.Round(rp.Ampl, 3) + "\n");
#endif
                        // store playing sound in the table
                        _nowPlayingList[rp.HierarchyID] = channel;
                    }
                    else
                    {
                        Util.Log("Play FAILED rp.H-ID=" + rp.HierarchyID + " rp.Time=" + rp.Time + " rp.AbsTime=" + rp.AbsTime + "\n");
                    }
                }
            }
        }