public bool isUpdateMetadata() { FMOD.TAG tagdata = new FMOD.TAG(); sound[PlayerController.MainChannel].getTag("TITLE", -1, ref tagdata); return(tagdata.updated); }
public Tag(TAG tag) : this() { Name = tag.name; Type = (TagType)tag.type; DataType = (TagDataType)tag.datatype; Updated = tag.updated; Data = new byte[tag.datalen]; Marshal.Copy(tag.data, Data, 0, (int)tag.datalen); }
private static extern RESULT FMOD_Sound_GetTag(IntPtr sound, string name, int index, ref TAG tag);
public RESULT getTag(string name, int index, ref TAG tag) { return FMOD_Sound_GetTag(soundraw, name, index, ref tag); }
public RESULT getTag (string name, int index, out TAG tag) { return FMOD_Sound_GetTag(rawPtr, name, index, out tag); }
public RESULT getTag(string name, int index, ref TAG tag) { IntPtr ptr = Marshal.AllocCoTaskMem(Marshal.SizeOf(tag)); RESULT result = FMOD_Sound_GetTag(soundraw, name, index, ptr); if(result == RESULT.OK) { tag = (TAG)Marshal.PtrToStructure(ptr, typeof(TAG)); } return result; }
private static extern RESULT FMOD5_Sound_GetTag(IntPtr sound, byte[] name, int index, out TAG tag);
private string GetSoundName(Sound sound) { //original implementation did not return all characters //StringBuilder name = new StringBuilder(0x100); //sound.getName(name, name.Capacity); //begin custom implementation string name = ""; var tagCount = 0; var tagsUpdated = 0; sound.getNumTags(ref tagCount, ref tagsUpdated); TAG tag = new TAG(); for (var i = 0; i < tagCount; i++) { sound.getTag(null, i, ref tag); if (tag.name == "TIT2") { name = Marshal.PtrToStringAnsi(tag.data); break; } } return name; }
private void Update(object sender) { if (sound == null) return; invoke(new SoundDelegate(() => { try { FMODExec(system.update()); TAG tag = new TAG(); int numTags = 0; int numTagsUpdated = 0; var res = sound.getNumTags(ref numTags, ref numTagsUpdated); if (res == RESULT.OK && numTagsUpdated > 0) { for (int i=0; i < numTags; i++) { if (sound.getTag(null, i, ref tag) != RESULT.OK) { continue; } if (tag.type == TAGTYPE.FMOD && tag.name == "Sample Rate Change") { float newfreq = (float)Marshal.PtrToStructure(tag.data, typeof(float)); Logger.DebugLog("New stream frequency: " + newfreq.ToString("F" + 0)); channel.setFrequency(newfreq); } if (tag.datatype != TAGDATATYPE.STRING) continue; // Tell listeners about the Stream tag. This can be // displayed to the user. if (OnStreamInfo != null) OnStreamInfo(this, new StreamInfoArgs(tag.name.ToLower(), Marshal.PtrToStringAnsi(tag.data))); } } } catch (Exception ex) { Logger.DebugLog("Error getting stream tags: " + ex.Message); } })); }
public RESULT getTag(string name, int index, out TAG tag) { return Sound.FMOD5_Sound_GetTag(this.rawPtr, name, index, out tag); }
public RESULT getTag(string name, int index, out TAG tag) { return(Sound.FMOD5_Sound_GetTag(this.rawPtr, name, index, out tag)); }
private void CheckTags(object sender) { if (sound == null) return; invoke(new SoundDelegate(() => { try { TAG tag = new TAG(); while (sound.getTag(null, -1, ref tag) == RESULT.OK) { if (tag.datatype != TAGDATATYPE.STRING) continue; // Tell listeners about the Stream tag. This can be // displayed to the user. if (OnStreamInfo != null) OnStreamInfo(this, new StreamInfoArgs(tag.name.ToLower(), Marshal.PtrToStringAnsi(tag.data))); } } catch (Exception ex) { Logger.DebugLog("Error getting stream tags: " + ex.Message); } })); }
public string GetProgress() { if (sound == null) return null; RESULT result; uint ms = 0; uint lenms = 0; bool playing = false; bool paused = false; if (channel != null) { result = channel.isPlaying(ref playing); if ((result != RESULT.OK) && (result != RESULT.ERR_INVALID_HANDLE)) ERRCHECK(result); result = channel.getPaused(ref paused); if ((result != RESULT.OK) && (result != RESULT.ERR_INVALID_HANDLE)) ERRCHECK(result); result = channel.getPosition(ref ms, TIMEUNIT.MS); if ((result != RESULT.OK) && (result != RESULT.ERR_INVALID_HANDLE)) ERRCHECK(result); result = sound.getLength(ref lenms, TIMEUNIT.MS); if ((result != RESULT.OK) && (result != RESULT.ERR_INVALID_HANDLE)) ERRCHECK(result); } if (system != null) system.update(); var duration = TimeSpan.FromMilliseconds(lenms); var position = TimeSpan.FromMilliseconds(ms); var songName = new StringBuilder(64); sound.getName(songName, songName.Capacity); int numTags = 0; int blah = 0; sound.getNumTags(ref numTags, ref blah); var tags = new StringBuilder(); for (var i = 0; i < numTags; i++) { TAG tag = new TAG(); sound.getTag(null, i, ref tag); tags.AppendFormat("{0} => {1}", tag.name, tag.data).AppendLine(); } var status = string.Format( @"{0:mm\:ss} / {1:mm\:ss} {2} {3} {4} ", position, duration, paused ? "Paused " : playing ? "Playing" : "Stopped", songName, tags ); return status; }