@@ -5,7 +5,7 @@ using System.IO;
|
||||
using Ichni.Editor;
|
||||
using Ichni.RhythmGame.Beatmap;
|
||||
using UnityEngine;
|
||||
|
||||
using NLayer;
|
||||
namespace Ichni.RhythmGame
|
||||
{
|
||||
public class SongInformation : IBaseElement
|
||||
@@ -35,7 +35,7 @@ namespace Ichni.RhythmGame
|
||||
string extension = Path.GetExtension(songLocation).ToLower();
|
||||
song = extension switch
|
||||
{
|
||||
".mp3" => ES3.LoadAudio(songLocation, AudioType.MPEG),
|
||||
".mp3" => LoadMP3(songLocation),
|
||||
".ogg" => ES3.LoadAudio(songLocation, AudioType.OGGVORBIS),
|
||||
".wav" => ES3.LoadAudio(songLocation, AudioType.WAV),
|
||||
_ => throw new Exception("Unsupported audio format: " + extension)
|
||||
@@ -46,6 +46,22 @@ namespace Ichni.RhythmGame
|
||||
}
|
||||
songLength = song.length;
|
||||
}
|
||||
private AudioClip LoadMP3(string filepath)//猜猜我从哪里偷的
|
||||
{
|
||||
string filename = System.IO.Path.GetFileNameWithoutExtension(filepath);
|
||||
MpegFile mpegFile = new MpegFile(filepath);
|
||||
|
||||
// assign samples into AudioClip
|
||||
AudioClip ac = AudioClip.Create(filename,
|
||||
(int)(mpegFile.Length / sizeof(float) / mpegFile.Channels),
|
||||
mpegFile.Channels,
|
||||
mpegFile.SampleRate,
|
||||
true,
|
||||
data => { int actualReadCount = mpegFile.ReadSamples(data, 0, data.Length); },
|
||||
position => { mpegFile = new MpegFile(filepath); });
|
||||
|
||||
return ac;
|
||||
}
|
||||
|
||||
public void SaveBM()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user