Make changes for karaoke server

This commit is contained in:
Neo Anderson committed 2020-02-15 09:14:46 -08:00
1 parent 1d478552bc
commit 2b5a5b3d38
1 file changed
+11 -29
+11 -29
View File
@@ -1,4 +1,4 @@
package main package karaoke
import ( import (
"fmt" "fmt"
@@ -31,6 +31,7 @@ const (
XOR_FONT = 0x26 // XOR 12x6 pixel font with existing VRAM values. XOR_FONT = 0x26 // XOR 12x6 pixel font with existing VRAM values.
SCROLL_PRESET = 0x14 // Update scroll offset, copying if 0x20 or 0x10. SCROLL_PRESET = 0x14 // Update scroll offset, copying if 0x20 or 0x10.
SCROLL_COPY = 0x18 // Update scroll offset, setting color if 0x20 or 0x10. SCROLL_COPY = 0x18 // Update scroll offset, setting color if 0x20 or 0x10.
PACKETS_PER_SEC = 300
) )
var ( var (
@@ -56,41 +57,22 @@ func init() {
internal_rgba_imagedata = internal_rgba_context.Pix internal_rgba_imagedata = internal_rgba_context.Pix
} }
func main() { /** @Return raw PNG buffer **/
func ScreenshotAtTime(cdgBytes []byte, timeInSec int) []byte {
//load data decode_packs(cdgBytes, timeInSec * PACKETS_PER_SEC)
cdg_file_data, err := ioutil.ReadFile("cdg/SC-SBI-REMIX - Billy Idol - Rebel Yell.cdg") redrawCanvas()
if err != nil { return snap()
log.Fatal("Couldn't read .cdg file")
}
fmt.Println("File Length: ", len(cdg_file_data))
//TODO: fix bug, for some reason can't loop over all the bytes of the len(cdg_file_data)
//loop through some bytes
for i := 0; i < 20000; i++ {
decode_packs(cdg_file_data, i)
redrawCanvas()
if i%100 == 0 {
snap(i)
}
}
//This command works, outputting the images as a video //This command works, outputting the images as a video
//ffmpeg.exe -r 1/5 -i blank-%d.png -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4 //ffmpeg.exe -r 1/5 -i blank-%d.png -c:v libx264 -r 30 -pix_fmt yuv420p out.mp4
} }
func snap(count int) { /** @Return raw PNG buffer **/
out_filename := fmt.Sprintf("screenshots/blank-%d.png", imageCount) func snap() []byte {
out_file, err := os.Create(out_filename) buf := new(bytes.Buffer)
if err != nil {
log.Fatal(err)
}
defer out_file.Close()
log.Print("Saving image to: ", out_filename)
png.Encode(out_file, internal_rgba_context) png.Encode(out_file, internal_rgba_context)
imageCount++ return buf.Bytes()
} }
func resetCDGState() { func resetCDGState() {