func sample_chromakey(vsw *libvsw.Vsw) { wait := 8000 vsw.CutSub(0) vsw.Cut(1) // You have to insert a writable SD card to LiveWedge. vsw.UploadFile("greenback.jpg") vsw.SetChromaKey(libvsw.CHROMA_KEY_GREEN) vsw.CutSub(4) time.Sleep(time.Duration(wait) * time.Millisecond) vsw.CutSub(0) vsw.UploadFile("blueback.jpg") vsw.SetChromaKey(libvsw.CHROMA_KEY_BLUE) vsw.MixSub(2000, 4) time.Sleep(time.Duration(wait) * time.Millisecond) vsw.MixSub(2000, 0) vsw.UploadFile("purpleback.jpg") vsw.SetChromaKey(libvsw.CHROMA_KEY_PURPLE) vsw.CutSub(4) time.Sleep(time.Duration(wait) * time.Millisecond) vsw.CutSub(0) vsw.UploadFile("redback.jpg") vsw.SetChromaKey(libvsw.CHROMA_KEY_RED) vsw.MixSub(2000, 4) time.Sleep(time.Duration(wait) * time.Millisecond) vsw.MixSub(2000, 0) }
func loop(vsw *libvsw.Vsw, pa Params, notify chan Params) { index := 0 for { select { case pa = <-notify: log.Printf("got from chan\n") saveParams(pa) if pa.StartLiveBroadcast { vsw.ChangeLiveBroadcastState(1) } else { vsw.ChangeLiveBroadcastState(0) } if pa.UploadStillPicture { vsw.UploadFile(pa.Picture) } case <-time.After(time.Second * time.Duration(pa.Interval)): log.Printf("periodic timer\n") } index = (index + 1) % 4 i := 0 for ; i < 4; i++ { if pa.Input[i] == true { break } } if i == 4 { // no input checked pa.Interval = 1000000 continue } for pa.Input[index] == false { index = (index + 1) % 4 } switch pa.Trans & 0xff { case 0: vsw.Cut(index + 1) case 1: vsw.Mix(pa.Rate, index+1) case 2: vsw.Dip(pa.Rate, index+1, ((pa.Trans>>8)&3)+1) case 255: vsw.Wipe(pa.Rate, index+1, random(0, libvsw.WIPE_TYPE_NUM-1)) default: vsw.Wipe(pa.Rate, index+1, pa.Trans-libvsw.TRANSITION_TYPE_WIPE) } } }