This repository has been archived on 2024-06-21. You can view files and clone it, but cannot push or open issues or pull requests.
CDSAE3/CDSAE3_Lian_Lian_Kan/Sound/Info_Audio_processer.cs

68 lines
2.6 KiB
C#
Raw Normal View History

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;
2024-04-19 02:00:37 +00:00
internal void play_random_break_soundScape(int volume = -1, Action<string, AudioPlayer>? finished = null)
2024-04-02 13:57:04 +00:00
{
Task.Run(() =>
{
2024-04-19 02:00:37 +00:00
if (volume == -1)
volume = Etcs.Info_Volume;
if (finished == null)
finished = (s, player) => player.Dispose();
AudioPlayer audioPlayer = new AudioPlayer(get_random_break_soundScape(), volume, finished);
2024-04-02 13:57:04 +00:00
audioPlayer.resume_song();
});
}
2024-04-19 02:00:37 +00:00
internal void playMusicClip(string s,int volume = -1,Action<string ,AudioPlayer>?finished = null)
{
Task.Run(() =>
{
if (volume == -1)
volume = Etcs.Info_Volume;
if (finished == null)
finished = (s, player) => player.Dispose();
AudioPlayer audioPlayer = new AudioPlayer(s, volume, finished);
audioPlayer.resume_song();
});
}
2024-04-02 13:57:04 +00:00
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;
}
}
}