Esempio n. 1
0
        public Object Generate(System.IO.Stream audioms, ConditionVariables effects, bool ensureaudio)
        {
            try
            {
                audioms.Position = 0;
                IWaveSource s = new CSCore.Codecs.WAV.WaveFileReader(audioms);

                if (ensureaudio)
                {
                    s = s.AppendSource(x => new ExtendWaveSource(x, 100));          // SEEMS to help the click at end..
                }
                ApplyEffects(ref s, effects);
                return(s);
            }
            catch
            {
                if (ensureaudio)
                {
                    return(new NullWaveSource(5));
                }
                else
                {
                    return(null);
                }
            }
        }
Esempio n. 2
0
        // FROM audio stream
        public AudioData Generate(System.IO.Stream audioms, SoundEffectSettings effects, bool ensureaudio)
        {
            try
            {
                audioms.Position = 0;

                IWaveSource s;

                if (audioms.Length == 0)
                {
                    if (ensureaudio)
                    {
                        s = new NullWaveSource(50);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    s = new CSCore.Codecs.WAV.WaveFileReader(audioms);

                    //System.Diagnostics.Debug.WriteLine("oRIGINAL length " + s.Length);
                    if (ensureaudio)
                    {
                        s = s.AppendSource(x => new ExtendWaveSource(x, 100));        // SEEMS to help the click at end..
                    }
                }

                //System.Diagnostics.Debug.WriteLine("Sample length " + s.Length);
                System.Diagnostics.Debug.Assert(s != null);
                ApplyEffects(ref s, effects);
                //System.Diagnostics.Debug.WriteLine(".. to length " + s.Length);
                System.Diagnostics.Debug.Assert(s != null);
                return(new AudioData(s));
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("Exception " + ex.Message);
                if (ensureaudio)
                {
                    IWaveSource s = new NullWaveSource(100);
                    System.Diagnostics.Debug.Assert(s != null);
                    return(new AudioData(s));
                }
                else
                {
                    return(null);
                }
            }
        }