Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An interesting library, but not working #4

Open
Garik- opened this issue Jun 2, 2020 · 0 comments
Open

An interesting library, but not working #4

Garik- opened this issue Jun 2, 2020 · 0 comments

Comments

@Garik-
Copy link

Garik- commented Jun 2, 2020

I tried decoding and encoding the file twice. Second decoding produces an error error parsing TimeSignature - unexpected data content (0). After I compared the source and the resulting file in vimdiff. They are different :(

func TestDecodeAndEncodeFile(t *testing.T) {
	f, err := os.OpenFile("./remove/test.mid", os.O_RDWR, os.ModeAppend)
	if err != nil {
		t.Fatal(err)
	}
	defer f.Close()

	decoder := NewDecoder(f)
	decoder.Debug = true
	err = decoder.Decode()
	if err != nil {
		t.Fatal(err)
	}
	
	encoder := NewEncoder(f, decoder.Format, decoder.TicksPerQuarterNote)
	encoder.TimeFormat = decoder.TimeFormat

	for _, src := range decoder.Tracks {
		dst := encoder.NewTrack()
		dst.SetName(src.Name())
		dst.Events = src.Events
		dst.Size = src.Size
	}

	encoder.NumTracks = decoder.NumTracks

	f.Seek(0,0)
	encoder.Write()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant