예제 #1
0
		public SampleDataChunk(RiffChunk chunk) 
		{
			string header = chunk.ReadChunkID();
			if(header != "sdta") 
			{
				throw new ApplicationException(String.Format("Not a sample data chunk ({0})",header));
			}
			sampleData = chunk.GetData();
		}
예제 #2
0
        public SampleDataChunk(RiffChunk chunk)
        {
            string text = chunk.ReadChunkID();

            if (text != "sdta")
            {
                throw new InvalidDataException(string.Format("Not a sample data chunk ({0})", text));
            }
            this.sampleData = chunk.GetData();
        }
예제 #3
0
파일: RiffChunk.cs 프로젝트: h4ltYu/EOS
 /// <summary>
 /// creates a new riffchunk from current position checking that we're not
 /// at the end of this chunk first
 /// </summary>
 /// <returns>the new chunk</returns>
 // Token: 0x06000441 RID: 1089 RVA: 0x0000E528 File Offset: 0x0000C728
 public RiffChunk GetNextSubChunk()
 {
     if (this.riffFile.BaseStream.Position + 8L < this.dataOffset + (long)((ulong)this.chunkSize))
     {
         RiffChunk riffChunk = new RiffChunk(this.riffFile);
         riffChunk.ReadChunk();
         return(riffChunk);
     }
     return(null);
 }
예제 #4
0
파일: RiffChunk.cs 프로젝트: malebra/Opyum
 /// <summary>
 /// creates a new riffchunk from current position checking that we're not
 /// at the end of this chunk first
 /// </summary>
 /// <returns>the new chunk</returns>
 public RiffChunk GetNextSubChunk()
 {
     if (riffFile.BaseStream.Position + 8 < dataOffset + chunkSize)
     {
         RiffChunk chunk = new RiffChunk(riffFile);
         chunk.ReadChunk();
         return(chunk);
     }
     //Console.WriteLine("DEBUG Failed to GetNextSubChunk because Position is {0}, dataOffset{1}, chunkSize {2}",riffFile.BaseStream.Position,dataOffset,chunkSize);
     return(null);
 }
예제 #5
0
		/// <summary>
		/// creates a new riffchunk from current position checking that we're not
		/// at the end of this chunk first
		/// </summary>
		/// <returns>the new chunk</returns>
		public RiffChunk GetNextSubChunk() 
		{
			if(riffFile.BaseStream.Position + 8 < dataOffset + chunkSize) 
			{
				RiffChunk chunk = new RiffChunk(riffFile);
				chunk.ReadChunk();
				return chunk;
			}
			//Console.WriteLine("DEBUG Failed to GetNextSubChunk because Position is {0}, dataOffset{1}, chunkSize {2}",riffFile.BaseStream.Position,dataOffset,chunkSize);
			return null;
		}
예제 #6
0
        public SampleDataChunk(RiffChunk chunk) 
		{
			string header = chunk.ReadChunkID();
            if (header != "sdta")
            {
                throw new InvalidDataException(String.Format("Not a sample data chunk ({0})", header));
            }

            var smplChunk = chunk.GetNextSubChunk();
            sampleData = smplChunk.GetData();

            var sm24Chunk = chunk.GetNextSubChunk();
            if (sm24Chunk?.ChunkID == "sm24" && sm24Chunk.ChunkSize == smplChunk.ChunkSize / 2)
            {
                sampleData24 = sm24Chunk.GetData();
            }
            else
            {
                //ignore if next subchunk is not a sm24 chunk or the size is not exactly half of smpl data
            }
		}
예제 #7
0
		public static RiffChunk GetTopLevelChunk(BinaryReader file) 
		{
			RiffChunk r = new RiffChunk(file);
			r.ReadChunk();
			return r;
		}
예제 #8
0
 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");
     }
 }
예제 #9
0
        internal InfoChunk(RiffChunk chunk)
        {
            bool ifilPresent = 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;
                    SoundFontVersion = c.GetDataAsStructure(new SFVersionBuilder());
                    break;

                case "isng":
                    WaveTableSoundEngine = c.GetDataAsString();
                    break;

                case "INAM":
                    inamPresent = true;
                    BankName    = c.GetDataAsString();
                    break;

                case "irom":
                    DataROM = c.GetDataAsString();
                    break;

                case "iver":
                    ROMVersion = 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($"Unknown chunk type {c.ChunkID}");
                }
            }
            if (!ifilPresent)
            {
                throw new InvalidDataException("Missing SoundFont version information");
            }
            // n.b. issue #150 - it is valid for isng not to be present
            if (!inamPresent)
            {
                throw new InvalidDataException("Missing SoundFont name information");
            }
        }
예제 #10
0
파일: InfoChunk.cs 프로젝트: h4ltYu/EOS
        internal InfoChunk(RiffChunk chunk)
        {
            bool flag  = false;
            bool flag2 = false;
            bool flag3 = false;

            if (chunk.ReadChunkID() != "INFO")
            {
                throw new InvalidDataException("Not an INFO chunk");
            }
            RiffChunk nextSubChunk;

            while ((nextSubChunk = chunk.GetNextSubChunk()) != null)
            {
                string chunkID;
                switch (chunkID = nextSubChunk.ChunkID)
                {
                case "ifil":
                    flag = true;
                    this.verSoundFont = nextSubChunk.GetDataAsStructure <SFVersion>(new SFVersionBuilder());
                    continue;

                case "isng":
                    flag2 = true;
                    this.waveTableSoundEngine = nextSubChunk.GetDataAsString();
                    continue;

                case "INAM":
                    flag3         = true;
                    this.bankName = nextSubChunk.GetDataAsString();
                    continue;

                case "irom":
                    this.dataROM = nextSubChunk.GetDataAsString();
                    continue;

                case "iver":
                    this.verROM = nextSubChunk.GetDataAsStructure <SFVersion>(new SFVersionBuilder());
                    continue;

                case "ICRD":
                    this.creationDate = nextSubChunk.GetDataAsString();
                    continue;

                case "IENG":
                    this.author = nextSubChunk.GetDataAsString();
                    continue;

                case "IPRD":
                    this.targetProduct = nextSubChunk.GetDataAsString();
                    continue;

                case "ICOP":
                    this.copyright = nextSubChunk.GetDataAsString();
                    continue;

                case "ICMT":
                    this.comments = nextSubChunk.GetDataAsString();
                    continue;

                case "ISFT":
                    this.tools = nextSubChunk.GetDataAsString();
                    continue;
                }
                throw new InvalidDataException(string.Format("Unknown chunk type {0}", nextSubChunk.ChunkID));
            }
            if (!flag)
            {
                throw new InvalidDataException("Missing SoundFont version information");
            }
            if (!flag2)
            {
                throw new InvalidDataException("Missing wavetable sound engine information");
            }
            if (!flag3)
            {
                throw new InvalidDataException("Missing SoundFont name information");
            }
        }
예제 #11
0
		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");
			}
		}
예제 #12
0
        // Token: 0x06000438 RID: 1080 RVA: 0x0000E058 File Offset: 0x0000C258
        internal PresetsChunk(RiffChunk chunk)
        {
            string text = chunk.ReadChunkID();

            if (text != "pdta")
            {
                throw new InvalidDataException(string.Format("Not a presets data chunk ({0})", text));
            }
            RiffChunk nextSubChunk;

            while ((nextSubChunk = chunk.GetNextSubChunk()) != null)
            {
                string chunkID;
                switch (chunkID = nextSubChunk.ChunkID)
                {
                case "PHDR":
                case "phdr":
                    nextSubChunk.GetDataAsStructureArray <Preset>(this.presetHeaders);
                    continue;

                case "PBAG":
                case "pbag":
                    nextSubChunk.GetDataAsStructureArray <Zone>(this.presetZones);
                    continue;

                case "PMOD":
                case "pmod":
                    nextSubChunk.GetDataAsStructureArray <Modulator>(this.presetZoneModulators);
                    continue;

                case "PGEN":
                case "pgen":
                    nextSubChunk.GetDataAsStructureArray <Generator>(this.presetZoneGenerators);
                    continue;

                case "INST":
                case "inst":
                    nextSubChunk.GetDataAsStructureArray <Instrument>(this.instruments);
                    continue;

                case "IBAG":
                case "ibag":
                    nextSubChunk.GetDataAsStructureArray <Zone>(this.instrumentZones);
                    continue;

                case "IMOD":
                case "imod":
                    nextSubChunk.GetDataAsStructureArray <Modulator>(this.instrumentZoneModulators);
                    continue;

                case "IGEN":
                case "igen":
                    nextSubChunk.GetDataAsStructureArray <Generator>(this.instrumentZoneGenerators);
                    continue;

                case "SHDR":
                case "shdr":
                    nextSubChunk.GetDataAsStructureArray <SampleHeader>(this.sampleHeaders);
                    continue;
                }
                throw new InvalidDataException(string.Format("Unknown chunk type {0}", nextSubChunk.ChunkID));
            }
            this.instrumentZoneGenerators.Load(this.sampleHeaders.SampleHeaders);
            this.instrumentZones.Load(this.instrumentZoneModulators.Modulators, this.instrumentZoneGenerators.Generators);
            this.instruments.LoadZones(this.instrumentZones.Zones);
            this.presetZoneGenerators.Load(this.instruments.Instruments);
            this.presetZones.Load(this.presetZoneModulators.Modulators, this.presetZoneGenerators.Generators);
            this.presetHeaders.LoadZones(this.presetZones.Zones);
            this.sampleHeaders.RemoveEOS();
        }
예제 #13
0
		internal PresetsChunk(RiffChunk chunk) 
		{
			string header = chunk.ReadChunkID();
			if(header != "pdta") 
			{
				throw new InvalidDataException(String.Format("Not a presets data chunk ({0})",header));
			}

			RiffChunk c;
			while((c = chunk.GetNextSubChunk()) != null) 
			{
				switch(c.ChunkID) {
				case "PHDR":
				case "phdr":
					c.GetDataAsStructureArray(presetHeaders);
					break;
				case "PBAG":
				case "pbag":			
					c.GetDataAsStructureArray(presetZones);
					break;
				case "PMOD":
				case "pmod":
					c.GetDataAsStructureArray(presetZoneModulators);
					break;
				case "PGEN":
				case "pgen":
					c.GetDataAsStructureArray(presetZoneGenerators);
					break;
				case "INST":
				case "inst":
					c.GetDataAsStructureArray(instruments);
					break;
				case "IBAG":
				case "ibag":
					c.GetDataAsStructureArray(instrumentZones);
					break;
				case "IMOD":
				case "imod":
					c.GetDataAsStructureArray(instrumentZoneModulators);
					break;
				case "IGEN":
				case "igen":
					c.GetDataAsStructureArray(instrumentZoneGenerators);
					break;
				case "SHDR":
				case "shdr":
					c.GetDataAsStructureArray(sampleHeaders);
					break;
				default:
                    throw new InvalidDataException(String.Format("Unknown chunk type {0}", c.ChunkID));
				}
			}

			// now link things up
			instrumentZoneGenerators.Load(sampleHeaders.SampleHeaders);
			instrumentZones.Load(instrumentZoneModulators.Modulators,instrumentZoneGenerators.Generators);
			instruments.LoadZones(instrumentZones.Zones);
			presetZoneGenerators.Load(instruments.Instruments);
			presetZones.Load(presetZoneModulators.Modulators,presetZoneGenerators.Generators);
			presetHeaders.LoadZones(presetZones.Zones);
			sampleHeaders.RemoveEOS();
		}
예제 #14
0
        internal PresetsChunk(RiffChunk chunk)
        {
            string header = chunk.ReadChunkID();

            if (header != "pdta")
            {
                throw new InvalidDataException(String.Format("Not a presets data chunk ({0})", header));
            }

            RiffChunk c;

            while ((c = chunk.GetNextSubChunk()) != null)
            {
                switch (c.ChunkID)
                {
                case "PHDR":
                case "phdr":
                    c.GetDataAsStructureArray(presetHeaders);
                    break;

                case "PBAG":
                case "pbag":
                    c.GetDataAsStructureArray(presetZones);
                    break;

                case "PMOD":
                case "pmod":
                    c.GetDataAsStructureArray(presetZoneModulators);
                    break;

                case "PGEN":
                case "pgen":
                    c.GetDataAsStructureArray(presetZoneGenerators);
                    break;

                case "INST":
                case "inst":
                    c.GetDataAsStructureArray(instruments);
                    break;

                case "IBAG":
                case "ibag":
                    c.GetDataAsStructureArray(instrumentZones);
                    break;

                case "IMOD":
                case "imod":
                    c.GetDataAsStructureArray(instrumentZoneModulators);
                    break;

                case "IGEN":
                case "igen":
                    c.GetDataAsStructureArray(instrumentZoneGenerators);
                    break;

                case "SHDR":
                case "shdr":
                    c.GetDataAsStructureArray(sampleHeaders);
                    break;

                default:
                    throw new InvalidDataException(String.Format("Unknown chunk type {0}", c.ChunkID));
                }
            }

            // now link things up
            instrumentZoneGenerators.Load(sampleHeaders.SampleHeaders);
            instrumentZones.Load(instrumentZoneModulators.Modulators, instrumentZoneGenerators.Generators);
            instruments.LoadZones(instrumentZones.Zones);
            presetZoneGenerators.Load(instruments.Instruments);
            presetZones.Load(presetZoneModulators.Modulators, presetZoneGenerators.Generators);
            presetHeaders.LoadZones(presetZones.Zones);
            sampleHeaders.RemoveEOS();
        }