2024-04-02 13:57:04 +00:00
|
|
|
|
using NAudio.Wave;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Xml.Linq;
|
|
|
|
|
|
|
|
|
|
namespace CDSAE3_Lian_Lian_Kan.Sound
|
|
|
|
|
{
|
|
|
|
|
public class Info_Audio_processer
|
|
|
|
|
{
|
|
|
|
|
Etcs.break_music soundScape_version = Etcs.break_music.breakA;
|
|
|
|
|
string last_break_soundScape = "";
|
|
|
|
|
Random random = new Random();
|
|
|
|
|
internal void set_SoundScape_version(Etcs.break_music version) => soundScape_version = version;
|
|
|
|
|
internal void play_random_break_soundScape()
|
|
|
|
|
{
|
|
|
|
|
Task.Run(() =>
|
|
|
|
|
{
|
|
|
|
|
void finished(string s,AudioPlayer audioPlayer)
|
|
|
|
|
{
|
|
|
|
|
audioPlayer.Dispose();
|
|
|
|
|
}
|
2024-04-18 00:38:59 +00:00
|
|
|
|
AudioPlayer audioPlayer = new AudioPlayer(get_random_break_soundScape(), Etcs.Info_Volume,finished);
|
2024-04-02 13:57:04 +00:00
|
|
|
|
audioPlayer.resume_song();
|
|
|
|
|
//object obj = Settings.res_Manager.GetObject(get_random_break_soundScape(), Settings.res_Culture)!;
|
|
|
|
|
//var infoOutputDevice = new WaveOutEvent();
|
|
|
|
|
//using (var sound = new MemoryStream((byte[])obj))
|
|
|
|
|
//using (var ms = new MemoryStream(StreamToBytes(sound)))
|
|
|
|
|
//using (var ws = new Mp3FileReader(ms))
|
|
|
|
|
//using (var blockAlignReductionStream = new BlockAlignReductionStream(ws))
|
|
|
|
|
//{
|
|
|
|
|
// var wave16ToFloatProvider = new Wave16ToFloatProvider(blockAlignReductionStream);
|
|
|
|
|
// wave16ToFloatProvider.Volume = soundScape_volume / 100f;
|
|
|
|
|
// infoOutputDevice.Init(wave16ToFloatProvider);
|
|
|
|
|
// infoOutputDevice.PlaybackStopped += InfoOutputDevice_PlaybackStopped;
|
|
|
|
|
// infoOutputDevice.Play();
|
|
|
|
|
//}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private string get_random_break_soundScape()
|
|
|
|
|
{
|
|
|
|
|
string name;
|
|
|
|
|
for (; ; )
|
|
|
|
|
{
|
|
|
|
|
name = soundScape_version switch
|
|
|
|
|
{
|
|
|
|
|
Etcs.break_music.breakA => "breakA" + (random.Next(1, 9)).ToString(),
|
|
|
|
|
Etcs.break_music.breakB => throw new NotImplementedException(),
|
|
|
|
|
_ => "breakA" + (random.Next(0, 9)).ToString()
|
|
|
|
|
};
|
|
|
|
|
if (name != last_break_soundScape)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
return name;
|
|
|
|
|
//MemoryStream sound = new MemoryStream((byte[])obj);
|
|
|
|
|
//MemoryStream ms = new MemoryStream(StreamToBytes(sound));
|
|
|
|
|
//var ws = new Mp3FileReader(ms);
|
|
|
|
|
//BlockAlignReductionStream blockAlignReductionStream = new BlockAlignReductionStream(ws);
|
|
|
|
|
//Wave16ToFloatProvider wave16ToFloatProvider = new Wave16ToFloatProvider(blockAlignReductionStream);
|
|
|
|
|
//wave16ToFloatProvider.Volume = soundScape_volume / 100f;
|
|
|
|
|
//return wave16ToFloatProvider;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|