private void load_sstv_audio()
{
string[] audio_file_ext = { "*.wav", "*.ogg", "*.aif", "*.aiff" };
string sstv_sounds_root = AssemblyLoader.loadedAssemblies.GetPathByType(typeof(chatterer)) + "/../../../Sounds/sstv/";
if (Directory.Exists(sstv_sounds_root))
{
sstv_exists = true;
string[] st_array;
foreach (string ext in audio_file_ext)
{
//if (debugging) Debug.Log("[CHATR] checking for " + ext + " files...");
st_array = Directory.GetFiles(sstv_sounds_root, ext);
foreach (string file in st_array)
{
//if (debugging) Debug.Log("[CHATR] sstv file = " + file);
//[CHATR] file = C:/KSP/ksp-win-0-21-1/KSP_win/GameData/RBR/Sounds/apollo11/capcom/capcom_16.ogg
//tear out the whole root + directory + st + one more for final slash
int start_pos = sstv_sounds_root.Length;
string file_name = file.Substring(start_pos);
//end pos to find the pos of the "."
int end_pos = file_name.LastIndexOf(".");
//now need a length between
string short_file_name = file_name.Substring(0, end_pos);
//if (debugging) Debug.Log("[CHATR] file_name = " + file_name);
if (ext == "*.mp3")
{
//GameDatabase won't load MP3
//try old method
string mp3_path = "file://" + AssemblyLoader.loadedAssemblies.GetPathByType(typeof(chatterer)) + "/../../../Sounds/sstv/" + short_file_name + ".mp3";
WWW www_chatter = new WWW(mp3_path);
if (www_chatter != null)
{
all_sstv_clips.Add(www_chatter.GetAudioClip(false));
if (debugging) Debug.Log("[CHATR] " + mp3_path + " loaded OK");
}
else
{
Debug.LogWarning("[CHATR] " + mp3_path + " load FAIL");
}
}
else
{
string gdb_path = "Chatterer/Sounds/sstv/" + short_file_name;
if (GameDatabase.Instance.ExistsAudioClip(gdb_path))
{
//all_beep_clips.Add(GameDatabase.Instance.GetAudioClip(gdb_path));
//dict_probe_samples.Add(short_file_name, GameDatabase.Instance.GetAudioClip(gdb_path));
//dict_probe_samples2.Add(GameDatabase.Instance.GetAudioClip(gdb_path), short_file_name);
all_sstv_clips.Add(GameDatabase.Instance.GetAudioClip(gdb_path));
//if (debugging) Debug.Log("[CHATR] " + gdb_path + " loaded OK");
}
else
{
//no ExistsAudioClip == false
Debug.LogWarning("[CHATR] " + gdb_path + " load FAIL, GameDatabase.Instance.ExistsAudioClip(" + short_file_name + ") == false");
}
}
}
}
}
/*
string path;
int i;
for (i = 1; i <= sstv_search_max; i++)
{
path = "RBR/Sounds/sstv_" + i.ToString("D2");
if (GameDatabase.Instance.ExistsAudioClip(path))
{
all_sstv_clips.Add(GameDatabase.Instance.GetAudioClip(path));
//print(path + " loaded OKAY");
}
//else
//{
//print(path + " load ERROR");
//}
}
*/
if (all_sstv_clips.Count == 0) Debug.LogWarning("[CHATR] No SSTV clips found");
}