本文整理汇总了C#中FileReader.getLoudnessData方法的典型用法代码示例。如果您正苦于以下问题:C# FileReader.getLoudnessData方法的具体用法?C# FileReader.getLoudnessData怎么用?C# FileReader.getLoudnessData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileReader
的用法示例。
在下文中一共展示了FileReader.getLoudnessData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: initMusic
/// <summary>
/// Initializes the static class.
/// Loads the music, analyzes the music, stores useful information about it.
/// THIS FUNCTION WILL ANALYZE MUSIC UNLESS IT FINDS A CACHE FILE!
/// (analysis takes ages!)
/// </summary>
/// <param name='pathToMusicFile'>
/// Path to music file.
/// </param>
public static IEnumerator initMusic(string pathToMusicFile)
{
// Set flags
songLoaded = false;
tagDataSet = false;
abortSoundProcessing = false;
isWritingCacheFile = false;
loadingProgress = 0;
#if UNITY_WEBPLAYER
// For the WebPlayer: Just get everything from WebPlayerRytData.cs
peaks = WebPlayerRytData.getPeaks(Game.Song);
loudPartTimeStamps = WebPlayerRytData.getLoudFlags(Game.Song);
variationFactor = WebPlayerRytData.getVariationFactor(Game.Song);
songLoaded = true;
currentlyLoadedSong = "xXBACKgroundMUSICXx";
yield break;
#else
// For Tutorial: Just get everything from TutorialRytData.cs
if(Game.GameMode == Game.Mode.Tutorial) {
peaks = TutorialRytData.getPeaks();
loudPartTimeStamps = TutorialRytData.getLoudFlags();
variationFactor = TutorialRytData.getVariationFactor();
audioLength = 213.883f;
frequency = 44100;
channels = 2;
songLoaded = true;
currentlyLoadedSong = "xXBACKgroundMUSICXx";
tagDataSet = true;
yield break;
}
// Initialize file handle
float start = Time.realtimeSinceStartup;
if(freader!=null) {
freader.close();
freader = null;
}
freader = new FileReader (pathToMusicFile);
FileReader.ReadStatus success = freader.read (); // Doesn't really "read" (unless it's a WAV file)
while (freader.isReading()) {
yield return null;
}
// Succeeded reading? (Which means it found the file when we're just streaming)
if (success != FileReader.ReadStatus.SUCCESS)
{
yield break;
}
// Set useful information, like AudioClip,length,etc..
frequency = freader.getFrequency ();
channels = freader.getChannels ();
audioLength = freader.getAudioLengthInSecs ();
currentlyLoadedSong = pathToMusicFile;
artist = freader.getArtist();
title = freader.getTitle();
tagDataSet = true;
start = Time.realtimeSinceStartup;
// Check if we have a cache file of the analyzed data for the current song
string cacheFile = FileWriter.convertToCacheFileName (pathToMusicFile);
System.IO.FileInfo cachedRytData = new System.IO.FileInfo (cacheFile);
if (cachedRytData.Exists) {
// We have a cache file, so we just read the peaks etc from there.
FileReader rytFile = new FileReader (cacheFile);
success = rytFile.read ();
while (rytFile.isReading()) {
yield return 0;
}
if (success != FileReader.ReadStatus.SUCCESS)
{
yield break;
}
peaks = rytFile.getPeaks ();
loudPartTimeStamps = rytFile.getLoudnessData ();
variationFactor = rytFile.getVariationFactor();
rytFile.close ();
rytFile = null;
} else {
// We have no cache file, so do the actual analysis!
soundProcessingThread = new System.Threading.Thread(() => SoundProcessor.analyse(freader));
soundProcessingThread.Start();
while(SoundProcessor.isAnalyzing) {
//.........这里部分代码省略.........