예제 #1
0
        public MyInMemoryWave GetRandomWave(MyObjectBuilder_CueDefinition cue)
        {
            int            randomIndex = MyVRageUtils.GetRandomInt(cue.Waves.Length);
            string         waveToPlay  = cue.Waves[randomIndex];
            MyInMemoryWave wave        = m_waveBank.GetWave(waveToPlay);

            if (wave == null)
            {
                return(null);
            }

            return(wave);
        }
 public bool Add(MyObjectBuilder_CueDefinition cue, string waveFilename)
 {
     string filename = Path.Combine(MyAudio.AudioPath, waveFilename);
     bool result = File.Exists(filename);
     if (result)
     {
         MyInMemoryWave wave = new MyInMemoryWave(cue, filename);
         m_waves[waveFilename] = wave;
     }
     else
     {
         MySandboxGame.Log.WriteLine(string.Format("Unable to find audio file: {0}", filename), LoggingOptions.AUDIO);
     }
     return result;
 }
예제 #3
0
        public bool Add(MyObjectBuilder_CueDefinition cue, string waveFilename)
        {
            string filename = Path.Combine(MyAudio.AudioPath, waveFilename);
            bool   result   = File.Exists(filename);

            if (result)
            {
                MyInMemoryWave wave = new MyInMemoryWave(cue, filename);
                m_waves[waveFilename] = wave;
            }
            else
            {
                MySandboxGame.Log.WriteLine(string.Format("Unable to find audio file: {0}", filename), LoggingOptions.AUDIO);
            }
            return(result);
        }
예제 #4
0
        public MySourceVoice GetVoice(MySoundCuesEnum cueEnum)
        {
            MyObjectBuilder_CueDefinition cue = GetCue(cueEnum);

            if ((cue == null) || (cue.Waves == null) || (cue.Waves.Length == 0))
            {
                return(null);
            }

            MyInMemoryWave wave = GetRandomWave(cue);

            if (wave == null)
            {
                return(null);
            }

            MyWaveFormat myWaveFormat = new MyWaveFormat()
            {
                Encoding   = wave.WaveFormat.Encoding,
                Channels   = wave.WaveFormat.Channels,
                SampleRate = wave.WaveFormat.SampleRate,
                WaveFormat = wave.WaveFormat
            };

            MySourceVoice voice = m_voicePools[myWaveFormat].NextAvailable();

            if (voice == null)
            {
                return(null);
            }

            voice.SubmitSourceBuffer(cueEnum, wave.Buffer, wave.Stream.DecodedPacketsInfo, wave.WaveFormat.SampleRate);
            if (m_applyReverb)
            {
                voice.Voice.SetEffectChain(m_effectDescriptor);
                voice.Voice.EnableEffect(0);
            }
            else
            {
                voice.Voice.SetEffectChain(null);
            }

            return(voice);
        }