/// <summary> /// Writes a SoundFont Version structure /// </summary> public override void Write(BinaryWriter bw, object o) { SFVersion v = (SFVersion)o; bw.Write(v.Major); bw.Write(v.Minor); }
/// <summary> /// Reads a SoundFont Version structure /// </summary> public override object Read(BinaryReader br) { SFVersion v = new SFVersion(); v.Major = br.ReadInt16(); v.Minor = br.ReadInt16(); data.Add(v); return v; }
/// <summary> /// Reads a SoundFont Version structure /// </summary> public override object Read(BinaryReader br) { SFVersion v = new SFVersion(); v.Major = br.ReadInt16(); v.Minor = br.ReadInt16(); data.Add(v); return(v); }
internal InfoChunk(RiffChunk chunk) { bool ifilPresent = false; bool isngPresent = false; bool INAMPresent = false; if(chunk.ReadChunkID() != "INFO") { throw new InvalidDataException("Not an INFO chunk"); } //this.chunk = chunk; RiffChunk c; while((c = chunk.GetNextSubChunk()) != null) { switch(c.ChunkID) { case "ifil": ifilPresent = true; verSoundFont = (SFVersion) c.GetDataAsStructure(new SFVersionBuilder()); break; case "isng": isngPresent = true; waveTableSoundEngine = c.GetDataAsString(); break; case "INAM": INAMPresent = true; bankName = c.GetDataAsString(); break; case "irom": dataROM = c.GetDataAsString(); break; case "iver": verROM = (SFVersion) c.GetDataAsStructure(new SFVersionBuilder()); break; case "ICRD": creationDate = c.GetDataAsString(); break; case "IENG": author = c.GetDataAsString(); break; case "IPRD": targetProduct = c.GetDataAsString(); break; case "ICOP": copyright = c.GetDataAsString(); break; case "ICMT": comments = c.GetDataAsString(); break; case "ISFT": tools = c.GetDataAsString(); break; default: throw new InvalidDataException(String.Format("Unknown chunk type {0}",c.ChunkID)); } } if(!ifilPresent) { throw new InvalidDataException("Missing SoundFont version information"); } if(!isngPresent) { throw new InvalidDataException("Missing wavetable sound engine information"); } if(!INAMPresent) { throw new InvalidDataException("Missing SoundFont name information"); } }
internal InfoChunk(RiffChunk chunk) { bool ifilPresent = false; bool isngPresent = false; bool INAMPresent = false; if(chunk.ReadChunkID() != "INFO") { throw new ApplicationException("Not an INFO chunk"); } //this.chunk = chunk; RiffChunk c; while((c = chunk.GetNextSubChunk()) != null) { switch(c.ChunkID) { case "ifil": ifilPresent = true; verSoundFont = (SFVersion) c.GetDataAsStructure(new SFVersionBuilder()); break; case "isng": isngPresent = true; waveTableSoundEngine = c.GetDataAsString(); break; case "INAM": INAMPresent = true; bankName = c.GetDataAsString(); break; case "irom": dataROM = c.GetDataAsString(); break; case "iver": verROM = (SFVersion) c.GetDataAsStructure(new SFVersionBuilder()); break; case "ICRD": creationDate = c.GetDataAsString(); break; case "IENG": author = c.GetDataAsString(); break; case "IPRD": targetProduct = c.GetDataAsString(); break; case "ICOP": copyright = c.GetDataAsString(); break; case "ICMT": comments = c.GetDataAsString(); break; case "ISFT": tools = c.GetDataAsString(); break; default: throw new ApplicationException(String.Format("Unknown chunk type {0}",c.ChunkID)); } } if(!ifilPresent) { throw new ApplicationException("Missing SoundFont version information"); } if(!isngPresent) { throw new ApplicationException("Missing wavetable sound engine information"); } if(!INAMPresent) { throw new ApplicationException("Missing SoundFont name information"); } }