@@ -35,7 +35,7 @@ public static byte[] LoadAndConvertFile(string path, FileType convertToType, boo
3535 case ".ogg" :
3636 case ".wma" :
3737 case ".aac" :
38- return ConvertFile ( ConvertToWav ( read , Path . GetExtension ( path ) . Equals ( ".ogg" , StringComparison . InvariantCultureIgnoreCase ) , padding , forceUseNAudio ) , FileType . Wave , convertToType , loop , encrpytionKey ) ;
38+ return ConvertFile ( ConvertToWav ( read , Path . GetExtension ( path ) . ToLowerInvariant ( ) , padding , forceUseNAudio ) , FileType . Wave , convertToType , loop , encrpytionKey ) ;
3939 case ".hca" :
4040 return ConvertFile ( read , FileType . Hca , convertToType , loop , encrpytionKey ) ;
4141 case ".adx" :
@@ -58,14 +58,15 @@ public static byte[] LoadAndConvertFile(string path, FileType convertToType, boo
5858 throw new InvalidDataException ( $ "Filetype of \" { path } \" is not supported.") ;
5959 }
6060
61- public static Stream ConvertToWav ( Stream src , bool isOgg , float padding = 0 , bool forceUseNAudio = false )
61+ public static Stream ConvertToWav ( Stream src , string extension , float padding = 0 , bool forceUseNAudio = false )
6262 {
63- using WaveStream reader = isOgg
64- ? new NAudio . Vorbis . VorbisWaveReader ( src , true )
65- : ( forceUseNAudio
66- ? new StreamMediaFoundationReader ( src ) // NAudio不支持MP3 Gapless,所以作为一种“兼容模式”提供
67- : new WaveFileReader ( ConvertMp3ToWavViaFfmpeg ( src ) ) ) ; // 默认情况下,优先使用ffmpeg
68- // 关于上述MP3 Gapless问题的影响等具体讨论,详见 https://github.com/MuNET-OSS/MaiChartManager/issues/40
63+ using WaveStream reader = extension switch
64+ {
65+ ".ogg" => new NAudio . Vorbis . VorbisWaveReader ( src , true ) ,
66+ ".mp3" when ! forceUseNAudio => new WaveFileReader ( ConvertMp3ToWavViaFfmpeg ( src ) ) , // 默认情况下,优先使用ffmpeg
67+ _ => new StreamMediaFoundationReader ( src ) , // WAV, WMA, AAC, 以及 MP3+forceUseNAudio,NAudio不支持MP3 Gapless,所以作为一种“兼容模式”提供
68+ } ;
69+ // 关于上述MP3 Gapless问题的影响等具体讨论,详见 https://github.com/MuNET-OSS/MaiChartManager/issues/40
6970 var sample = reader . ToSampleProvider ( ) ;
7071
7172 switch ( padding )
0 commit comments