Read custom chunks from a midi file, when chunk header contains no size information
See original GitHub issueHi. I have a midi file which contains one track with some nested chunks. One of the complex chunks (these ones contains multiple simple chunks or complex chunks, in a nested structure) contains information about waveform data, and the waveform data itself. Yes, wave data in midi file structure. The structure is like this:
AWav- ComplexChunk
|- WAVE (no chunk size, only these 4 bytes, as a marker)
|- Afmt SimpleChunk contains chunk size information
|- Sfmt SimpleChunk contains chunk size information
etc...
using this code
public sealed class AWavChunk : ComplexChunk
{
public const string Id = "AWav";
public AWavChunk() :
base(Id, new ChunkTypesCollection
{
{ typeof(WAVEChunk), WAVEChunk.Id },
//{ typeof(AfmtChunk), AfmtChunk.Id },
//{ typeof(SfmtChunk), SfmtChunk.Id },
//{ typeof(SdecChunk), SdecChunk.Id },
//{ typeof(AdatChunk), AdatChunk.Id },
//{ typeof(AInfChunk), AInfChunk.Id }
})
{
}
public override MidiChunk Clone()
{
return new AWavChunk
{
Chunks = Chunks.Select(c => c.Clone()).ToList()
};
}
}
I’m getting an InvalidChunkSizeException
for WAVE chunk. (Actual size (1366657) of a WAVE chunk differs from the one declared in the chunk’s header (1097231732)). But, as I said, WAVE chunks does not have any size, they are only like markers in this midi file structure.
If I comment { typeof(WAVEChunk), WAVEChunk.Id },
in the code above, and uncomment the others I get NotEnoughBytesException
the structure of SimpleChunk and ComplexChunk are the same from #100
Issue Analytics
- State:
- Created a year ago
- Comments:9 (5 by maintainers)
Thank you Maxim. Till I will make all classes which modifies my file to be able to save it, I will close this issue. In theory, it must work!