Пример #1
0
 public void Break()
 {
     if(channel == null) return;
     lock (AudioManager.Instance.workWithListMutex)
     {
         channel.Stop();
         channel = null;
     }
 }
Пример #2
0
 /// <summary>
 /// Reads an audio clip from the given stream.
 /// </summary>
 /// <param name="inputStream">The stream to read from.</param>
 public AudioClip(Stream inputStream)
 {
     underlyingStream = inputStream;
     StaticChanel = new AudioChannel(AudioManager.Instance.BuffersPerChannel, AudioManager.Instance.BytesPerBuffer);
     StaticChanel.Init(this);
     //StaticChanel.Prepare();
     AudioManager.Instance.StaticClips.Add(this);
     //rawClip = new VorbisFile(inputStream);
     //Cache(64 * 1024);
 }
Пример #3
0
        /// <summary>
        /// Constructs an audio clip from the given file.
        /// </summary>
        /// <param name="fileName">The file which to read from.</param>
        public AudioClip(string fileName)
        {
            underlyingStream = File.OpenRead(fileName);
            StaticChanel = new AudioChannel(AudioManager.Instance.BuffersPerChannel, AudioManager.Instance.BytesPerBuffer);
            StaticChanel.Init(this);
            //StaticChanel.Prepare();
            AudioManager.Instance.StaticClips.Add(this);
            //rawClip = new VorbisFile(fileName);

            //Cache(64 * 1024);
        }
Пример #4
0
        /// <summary>
        /// Initializes the audio manager.
        /// </summary>
        /// <param name="channels">The number of channels to use.</param>
        /// <param name="buffersPerChannel">The number of buffers each channel will contain.</param>
        /// <param name="bytesPerBuffer">The number of bytes in each buffer.</param>
        private void Init(int channels, int buffersPerChannel, int bytesPerBuffer, bool launchThread)
        {
            BytesPerBuffer = bytesPerBuffer;
            BuffersPerChannel = buffersPerChannel;
            ChannelCount = channels;

            RunUpdates = launchThread;
            ChannelCount = channels;
            Channels = new AudioChannel[channels];
            StaticClips = new List<AudioClip>();

            for (int i = 0; i < channels; i++)
                Channels[i] = new AudioChannel(buffersPerChannel, bytesPerBuffer);

            Instance = this;

            if(launchThread)
            {
                UpdateThread = new Thread(RunUpdateLoop);
                UpdateThread.IsBackground = true;
                UpdateThread.Start();
            }
            else
            {
                UpdateThread = null;
            }
        }
Пример #5
0
 internal void SoftBreak()
 {
     channel = null;
 }
Пример #6
0
 internal AudioRemoteControll(AudioChannel chanell)
 {
     this.channel = chanell;
 }
Пример #7
0
 private void Init(Stream stream, AudioFormat format)
 {
     if(format == AudioFormat.Unknown)
         throw new Exception("Audio format unknown");
     Format = format;
     underlyingStream = stream;
     StaticChanel = new AudioChannel(AudioManager.Instance.BuffersPerChannel, AudioManager.Instance.BytesPerBuffer);
     StaticChanel.Init(this);
     AudioManager.Instance.AddClip(this);
     if(Format == AudioFormat.OGG)
         Cache(AudioManager.Instance.BytesPerBuffer * AudioManager.Instance.BuffersPerChannel);
 }