Exemplo n.º 1
0
        public static bool OpenSource(SpectrumVideoFileConfig cfg, out SpectrumVideoSource source)
        {
            //Set default
            source = null;

            //Make sure file exists
            if (!File.Exists(cfg.pathname))
            {
                return(false);
            }

            //Open stream
            FileStream fs = new FileStream(cfg.pathname, FileMode.Open, FileAccess.Read);

            //Attempt to load as a WAV file
            ISampleReader reader;

            try
            {
                reader = new WavFileReader(fs);
            } catch
            {
                //Fall back to loading RAW files
                fs.Position = 0;
                if (cfg.raw_rate == 0)
                {
                    return(false);
                }
                reader = new StreamSampleReader(fs, cfg.raw_format, cfg.raw_rate, 0, 2, 32768);
            }

            //Get source
            source = new SpectrumVideoSource(fs, reader);
            return(true);
        }
Exemplo n.º 2
0
        public BenchmarkData(string filename, int startSeconds, int lengthSeconds)
        {
            //Open file
            this.filename       = filename;
            wav                 = new WavFileReader(new FileStream(filename, FileMode.Open, FileAccess.Read));
            sampleRate          = wav.SampleRate;
            firstSample         = startSeconds * sampleRate;
            sampleCount         = lengthSeconds * sampleRate;
            samplesPerLogUpdate = sampleCount / 10;

            //Open buffer
            buffer = UnsafeBuffer.Create((int)sampleCount, out ptr);
        }
Exemplo n.º 3
0
        public void Compile()
        {
            ParsedPath wavFileName = Target.InputFiles.Where(f => f.Extension == ".wav").First();
            ParsedPath xnbFileName = Target.OutputFiles.Where(f => f.Extension == ".xnb").First();

            WavFile      wavFile = WavFileReader.ReadFile(wavFileName);
            AudioContent ac      = new AudioContent(wavFile);

            if (!Directory.Exists(xnbFileName.VolumeAndDirectory))
            {
                Directory.CreateDirectory(xnbFileName.VolumeAndDirectory);
            }

            XnbFileWriterV5.WriteFile(ac, xnbFileName);
        }
Exemplo n.º 4
0
        protected override SpectrumVideoCanvasConfig CreateNewItem()
        {
            //Show file dialog
            OpenFileDialog fd = new OpenFileDialog();

            fd.Title  = "Open IQ Files";
            fd.Filter = "IQ Files (*.wav, *.*)|*.wav;*.*";
            if (fd.ShowDialog() != DialogResult.OK)
            {
                return(null);
            }

            //Get the file config
            SpectrumVideoFileConfig file;

            if (WavFileReader.IdentifyWavFile(fd.FileName, out WavFileInfo info))
            {
                file = new SpectrumVideoFileConfig
                {
                    pathname = fd.FileName
                };
            }
            else
            {
                SampleFormatPromptForm prompt = new SampleFormatPromptForm();
                if (prompt.ShowDialog() != DialogResult.OK)
                {
                    return(null);
                }
                file = new SpectrumVideoFileConfig
                {
                    pathname   = fd.FileName,
                    raw_format = prompt.SampleFormat,
                    raw_rate   = prompt.SampleRate
                };
            }

            //Create new
            return(new SpectrumVideoCanvasConfig
            {
                source = file
            });
        }
 public RenderingForm(WavFileReader wav, ViewGenerator generator)
 {
     InitializeComponent();
     this.wav       = wav;
     this.generator = generator;
 }