72 lines
3.0 KiB
C#
72 lines
3.0 KiB
C#
|
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;
|
|||
|
public int soundScape_volume { get; set; } = 90;
|
|||
|
string last_break_soundScape = "";
|
|||
|
Random random = new Random();
|
|||
|
class Info_file_processer
|
|||
|
{ }
|
|||
|
|
|||
|
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();
|
|||
|
}
|
|||
|
AudioPlayer audioPlayer = new AudioPlayer(get_random_break_soundScape(), soundScape_volume,finished);
|
|||
|
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;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|