Beispiel #1
0
        public CUE(WAVFileStream fs, int BPS, int SPS)
        {
            long?tmp;
            long tmpp;

            // Fail safe reading from file - ID, Order and Position
            tmp = fs.FromReadArray(4);
            if (tmp.HasValue)
            {
                ID = tmp.Value;
            }
            else
            {
                return;
            }

            tmp = fs.FromReadArray(4);
            if (tmp.HasValue)
            {
                Order = tmp.Value;
            }
            else
            {
                return;
            }

            //fs.Seek(4, SeekOrigin.Current);
            fs.FromReadArray(4);
            tmp = fs.FromReadArray(4);
            if (tmp.HasValue)
            {
                tmpp = tmp.Value;
            }
            else
            {
                return;
            }
            tmp = fs.FromReadArray(4);
            if (tmp.HasValue)
            {
                tmpp += tmp.Value;
            }
            else
            {
                return;
            }
            tmp = fs.FromReadArray(4);
            if (tmp.HasValue)
            {
                tmpp += tmp.Value;
            }
            else
            {
                return;
            }

            tmpp    *= BPS * SPS;
            Position = tmpp;
        }
Beispiel #2
0
        /// <summary>
        /// Tries to find a suitable number to represent the Length
        /// </summary>
        /// <param name="FileName">Name of the file</param>
        /// <returns>The relative weight</returns>
        public static int Weigth(string FileName)
        {
            if (FileStreams.Keys.Contains(FileName))
            {
                WAVFileStream wfs = FileStreams[FileName];
                int           x   = (int)Math.Log10(wfs.LoopCount * wfs.LoopedLength);
                x += 5;
#if DEBUGSCR
                Console.WriteLine("Stopping X is: " + x.ToString());
#endif
                return(x);
            }
            else
            {
                return(0);
            }
        }
Beispiel #3
0
        /// <summary>
        /// IFileFactory Interface memeber to open the given file
        /// </summary>
        /// <param name="filename">Name of the file</param>
        /// <returns>The opened stream</returns>
        public System.IO.Stream openFile(String filename)
        {
            // Separate SoundCommand UID from filename
            int           sep = filename.LastIndexOf('*');
            WAVFileStream wfs;

            bool isLooping      = false;
            bool isInternalLoop = false;

            // Don't keep the previous instance, release it
            if (sep != 0 && FileStreams.Keys.Contains(filename))
            {
                wfs            = FileStreams[filename];
                isLooping      = wfs.IsLooping;
                isInternalLoop = wfs.IsInternalLoop;
#if DEBUGSCR
                Console.WriteLine("Implicit stopping file: " + filename.Substring(filename.LastIndexOf('\\')));
#endif
                wfs.Release();
            }

            // Create the new Stream
            wfs = new WAVFileStream(sep >= 0 ? filename.Substring(0, sep) : filename);

            wfs.IsLooping      = isLooping;
            wfs.IsInternalLoop = isInternalLoop;

            // Add or replace the Stream in our Dictionary
            if (FileStreams.Keys.Contains(filename))
            {
#if DEBUGSCR
                Console.WriteLine("Replacing file: " + filename.Substring(filename.LastIndexOf('\\')));
#endif
                FileStreams[filename] = wfs;
            }
            else
            {
#if DEBUGSCR
                Console.WriteLine("Adding file: " + filename.Substring(filename.LastIndexOf('\\')));
#endif
                FileStreams.Add(filename, wfs);
            }

            return(wfs);
        }
Beispiel #4
0
        /// <summary>
        /// Provide error free call to BeginLoop on Stream
        /// </summary>
        /// <param name="FileName">Name of the file, also key in dictionary</param>
        public static void StartLoopRelease(string FileName)
        {
            if (!FileStreams.Keys.Contains(FileName))
            {
                int    sep      = FileName.LastIndexOf('*');
                string PureName = sep >= 0 ? FileName.Substring(0, sep) : FileName;
                if (File.Exists(PureName))
                {
                    WAVFileStream wfs = new WAVFileStream(PureName);
                    FileStreams.Add(FileName, wfs);
                }
            }

            if (FileStreams.Keys.Contains(FileName))
            {
#if DEBUGSCR
                Console.WriteLine("Start Loop Release: " + FileName.Substring(FileName.LastIndexOf('\\')));
#endif
                FileStreams[FileName].StartLoop();
            }
        }