getLength() public method

public getLength ( uint &length, TIMEUNIT lengthtype ) : RESULT
length uint
lengthtype TIMEUNIT
return RESULT
示例#1
0
        public void SetProgress(float Value)
        {
            if (_channel == null || _sound == null)
            {
                return;
            }

            uint len = 0;

            _sound.getLength(out len, TIMEUNIT.MS);
            _channel.setPosition((uint)(len * Value), TIMEUNIT.MS);
        }
示例#2
0
 public TimeSpan GetCurrentLength()
 {
     if (current != null)
     {
         uint length;
         current.getLength(out length, TIMEUNIT.MS);
         return(TimeSpan.FromMilliseconds(length));
     }
     else
     {
         return(TimeSpan.FromMilliseconds(0));
     }
 }
示例#3
0
        public uint GetRunningTime()
        {
            uint len = 0;

            if (sound != null)
            {
                result = sound.getLength(out len, FMOD.TIMEUNIT.MS);
                if (result != FMOD.RESULT.OK)
                {
                    return(0);
                }
            }
            return(len);//return float(len) / 1000.0f;
        }
示例#4
0
 public uint GetLength()
 {
     if (sound != null)
     {
         uint lenms = 0;
         sound.getLength(ref lenms, FMOD.TIMEUNIT.MS);
         return(lenms);
     }
     return(0);
 }
示例#5
0
        public object[] LoadSoundStats(string fileName)
        {
            if (!((fileName != null) && File.Exists(fileName)))
            {
                return(null);
            }
            Sound sound  = null;
            uint  length = 0;

            this.ERRCHECK(this.m_system.createSound(fileName, MODE.ACCURATETIME | MODE._2D | MODE.HARDWARE | MODE.CREATESTREAM,
                                                    ref sound));
            sound.getLength(ref length, TIMEUNIT.MS);
            string soundName = this.GetSoundName(sound);

            sound.release();
            return(new object[] { soundName, length });
        }
示例#6
0
        public object[] LoadSoundStats(string fileName)
        {
            // returns [string name, uint length]
            if (fileName == null || !File.Exists(fileName))
            {
                return(null);
            }

            Sound  sound  = null;
            uint   length = 0;
            string name;

            ERRCHECK(m_system.createSound(fileName, (FMOD.MODE._2D | FMOD.MODE.HARDWARE | FMOD.MODE.CREATESTREAM | MODE.ACCURATETIME), ref sound));
            sound.getLength(ref length, TIMEUNIT.MS);

            name = GetSoundName(sound);

            sound.release();
            return(new object[] { name, length });
        }
        //Loads a song into memory given a sample size and file-path to an audio file.
        //The most commonly used and accurate Sample Size is 1024.
        public void LoadSong(int sSize, string audioString)
        {
            //Take in Aruguments
            sampleSize = sSize;
            songString = audioString;

            stopW.Start();
            areWePlaying = true;
            specFlux = 0.0f;
            timeBetween = 0;
            initialTime = (int)stopW.ElapsedMilliseconds;
            currentTime = 0;
            currentSeconds = 0;
            lastSeconds = 0;
            currentMillis = 0;
            currentMinutes = 0;
            median = 0.0f;
            smoothMedian = 0.0f;
            beatThreshold = 0.6f;
            thresholdSmoother = 0.6f;
            started = false;
            lastBeatRegistered = new TimeStamp();
            audio = new FMOD.Sound();
            songChannel1 = new FMOD.Channel();

            channelMusic = new FMOD.ChannelGroup();

            previousFFT = new float[sampleSize
                / 2 + 1];
            for (int i = 0; i < sampleSize / 2; i++)
            {
                previousFFT[i] = 0;
            }

            //Brute force for testing
            //songString = "Music/drums.wav";

            //Create channel and audio
            FMODErrorCheck(system.createChannelGroup(null, ref channelMusic));
               // CREATESOUNDEXINFO ex = new CREATESOUNDEXINFO();

            FMODErrorCheck(system.createStream(songString, FMOD.MODE.SOFTWARE, ref audio));

            audio.getLength(ref seconds, FMOD.TIMEUNIT.MS);
            audio.getDefaults(ref sampleRate, ref zeroF, ref zeroF, ref zero);
            seconds = ((seconds + 500) / 1000);
            minutes = seconds / 60;
            fullSeconds = (int)seconds;
            seconds = seconds - (minutes * 60);

            FMODErrorCheck(system.playSound(FMOD.CHANNELINDEX.FREE, audio, true, ref songChannel1));

            //hzRange = (sampleRate / 2) / static_cast<float>(sampleSize);
            songChannel1.setChannelGroup(channelMusic);
            songChannel1.setPaused(true);

            Console.WriteLine("Song Length: " + minutes + ":" + seconds);
            Console.WriteLine("Sample Rate: " + sampleRate);

            //std::cout << "Freq Range: " << hzRange << std::endl;
            //songChannel1.setVolume(0);
        }
示例#8
0
        //Loads a song into memory given a sample size and file-path to an audio file.
        //The most commonly used and accurate Sample Size is 1024.
        public void LoadSong(int sSize, string audioString)
        {
            //Take in Aruguments
            sampleSize = sSize;
            songString = audioString;

            stopW.Start();
            areWePlaying       = true;
            specFlux           = 0.0f;
            timeBetween        = 0;
            initialTime        = (int)stopW.ElapsedMilliseconds;
            currentTime        = 0;
            currentSeconds     = 0;
            lastSeconds        = 0;
            currentMillis      = 0;
            currentMinutes     = 0;
            median             = 0.0f;
            smoothMedian       = 0.0f;
            beatThreshold      = 0.6f;
            thresholdSmoother  = 0.6f;
            started            = false;
            lastBeatRegistered = new TimeStamp();
            audio        = new FMOD.Sound();
            songChannel1 = new FMOD.Channel();
            beatWait     = false;
            channelMusic = new FMOD.ChannelGroup();

            previousFFT = new float[sampleSize
                                    / 2 + 1];
            for (int i = 0; i < sampleSize / 2; i++)
            {
                previousFFT[i] = 0;
            }

            //Brute force for testing
            //songString = "Music/drums.wav";

            //Create channel and audio
            FMODErrorCheck(system.createChannelGroup(null, ref channelMusic));
            // CREATESOUNDEXINFO ex = new CREATESOUNDEXINFO();

            FMODErrorCheck(system.createStream(songString, FMOD.MODE.SOFTWARE, ref audio));

            audio.getLength(ref seconds, FMOD.TIMEUNIT.MS);
            audio.getDefaults(ref sampleRate, ref zeroF, ref zeroF, ref zero);
            seconds     = ((seconds + 500) / 1000);
            minutes     = seconds / 60;
            fullSeconds = (int)seconds;
            seconds     = seconds - (minutes * 60);

            FMODErrorCheck(system.playSound(FMOD.CHANNELINDEX.FREE, audio, true, ref songChannel1));

            //hzRange = (sampleRate / 2) / static_cast<float>(sampleSize);
            songChannel1.setChannelGroup(channelMusic);
            songChannel1.setPaused(true);

            Console.WriteLine("Song Length: " + minutes + ":" + seconds);
            Console.WriteLine("Sample Rate: " + sampleRate);

            //std::cout << "Freq Range: " << hzRange << std::endl;
            //songChannel1.setVolume(0);
        }
示例#9
0
        public uint?GetLength(TimeUnit unit)
        {
            uint length;

            return(_fmodSound.getLength(out length, (TIMEUNIT)unit).CheckBox(length, Suppressions()));
        }