Exemplo n.º 1
0
        public bool Load(String location)
        {
            Location = location;
            m_Name = location.Split('\\').Last();
            String a = ContentManager.GetFileExtension(location);

            switch(a.ToLower())
            {
                case "wav":
                    m_Stream = CreateWavInputStream(location);
                    break;
                case "mp3":
                    m_Stream = CreateMp3InputStream(location);
                    break;
                case "flac":
                    m_Stream = CreateFlacInputStream(location);
                    break;
                case "ogg":
                    m_Stream = CreateOggInputStream(location);
                    break;
                case "aiff":
                    m_Stream = CreateAiffInputStream(location);
                    break;
                case "wma":
                    m_Stream = CreateWmaInputStream(location);
                    break;
                default:
                    m_Logger.Warn("Failed to find strong type conversion for audio format [{0}] attempting a deep file read!", a.ToLower());
                    m_Stream = DefaultInputStream(location);
                    if (m_Stream == null)
                    {
                        m_Logger.Error("Unable to load audio file {0}!", location);
                    }
                    break;
            }

            return false;
        }
Exemplo n.º 2
0
        protected static AudioStream CreateAiffInputStream(String location)
        {
            AudioStream stream = new AudioStream();
            try
            {
                stream.WaveStream = new AiffFileReader(location);
                stream.DeviceHandle = new WaveOutEvent();
                stream.DeviceHandle.Init(stream.WaveStream);
                stream.VolumeStream = new SampleChannel(stream.WaveStream, true);
            }
            catch (Exception e)
            {
                m_Logger.Error("Failed to load *.aiff Audio Asset - {0}{1}{2}", location, Environment.NewLine, e);
            }

            return stream;
        }
Exemplo n.º 3
0
        protected static AudioStream CreateWavInputStream(String location)
        {
            AudioStream stream = new AudioStream();
            try
            {
                stream.WaveStream = new WaveFileReader(location);
                stream.VolumeStream = new SampleChannel(stream.WaveStream, true);
            }
            catch(Exception e)
            {
                m_Logger.Error("Failed to load *.wav Audio Asset - {0}{1}{2}", location,Environment.NewLine, e);
            }

            return stream;
        }