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

It seems doesn's work #1

Open
Eminlin opened this issue Oct 9, 2021 · 0 comments
Open

It seems doesn's work #1

Eminlin opened this issue Oct 9, 2021 · 0 comments

Comments

@Eminlin
Copy link

Eminlin commented Oct 9, 2021

Thank you for your contribution
This let me understand the operation mechanism of SSTV
Some problems were encountered in the process of using, Looking forward to your reply

Origin Image

image

M1

image

Robot36

image

Here are some codes I refer from sstv-cli/main.go

	f, err := os.Open("./xx.png")
	if err != nil {
		panic(err.Error())
	}
	img, _, err := image.Decode(f)
	if err != nil {
		panic(err.Error())
	}
	format := &audio.Format{
		NumChannels: 1,
		SampleRate:  44100,
	}
	audio := sstv.NewMartin(sstv.Martin1, format)
	fmt.Print("resizing ... ")
	targetRes := audio.Resolution().Size()
	currentRes := img.Bounds().Size()
	if currentRes.X != targetRes.X || currentRes.Y != targetRes.Y {
		img = resize.Resize(uint(targetRes.X), uint(targetRes.Y), img, resize.Lanczos3)
		fmt.Print("ok\n")
	} else {
		fmt.Print("skipped\n")
	}
	fmt.Print("generating ... ")
	buf := audio.Encode(img)
	fmt.Print("ok\n")
	fmt.Print("encoding ... ")
	if wr, err := os.OpenFile("temp.wav", os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm); err == nil {
		defer wr.Close()
		enc := wav.NewEncoder(wr, 44100, sstv.BitDepth, 1, 1)
		defer enc.Close()
		if err = enc.Write(buf.AsIntBuffer()); err != nil {
			fmt.Printf("failed: %s", err)
			os.Exit(2)
		}

		fmt.Print("ok\n")
	} else {
		fmt.Printf("failed: %s\n", err)
		os.Exit(2)
	}
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