Compare commits

..

3 Commits

Author SHA1 Message Date
filifa
2d0a10c645 remove ./ 2024-09-07 21:09:04 -05:00
filifa
38016be3d3 add width and height flags 2024-09-07 20:56:02 -05:00
filifa
d13abec803 add soft cut duration flag 2024-09-07 20:50:06 -05:00
3 changed files with 13 additions and 5 deletions

View File

@@ -20,7 +20,7 @@ milkbucket reads a PCM stream from standard input to generate visualizations.
If you have an audio file and a preset in mind, you can use `ffmpeg` to If you have an audio file and a preset in mind, you can use `ffmpeg` to
generate the PCM stream, then pipe to milkbucket, like so: generate the PCM stream, then pipe to milkbucket, like so:
``` ```
ffmpeg -i $audio -ar 44100 -f s16le - | ./milkbucket $preset ffmpeg -i $audio -ar 44100 -f s16le - | milkbucket $preset
``` ```
Note that you can pass in multiple presets, then use the arrow keys to cycle Note that you can pass in multiple presets, then use the arrow keys to cycle
through the presets while running. through the presets while running.
@@ -29,7 +29,7 @@ Note that neither of these commands (ffmpeg or milkbucket) will output any
audio! If you want to hear the audio at the same time (and assuming your audio! If you want to hear the audio at the same time (and assuming your
machine uses pipewire), run: machine uses pipewire), run:
``` ```
ffmpeg -i $audio -ar 44100 -f s16le - | tee >(pw-play --rate=44100 --format=s16 -) | ./milkbucket $preset ffmpeg -i $audio -ar 44100 -f s16le - | tee >(pw-play --rate=44100 --format=s16 -) | milkbucket $preset
``` ```
(If you don't use pipewire try using `aplay` instead of `pw-play`, or some (If you don't use pipewire try using `aplay` instead of `pw-play`, or some
other command for playing PCM streams.) other command for playing PCM streams.)
@@ -37,5 +37,5 @@ other command for playing PCM streams.)
You can also generate a visualization from your system sound. Assuming pipewire You can also generate a visualization from your system sound. Assuming pipewire
again, and that you have audio coming from Firefox, run: again, and that you have audio coming from Firefox, run:
``` ```
pw-record --target Firefox - | ./milkbucket $preset pw-record --target Firefox - | milkbucket $preset
``` ```

View File

@@ -27,6 +27,9 @@ import (
) )
var transition bool var transition bool
var softCutDuration float64
var width int32
var height int32
/* /*
* checkStdin checks if any data has been passed in through stdin and returns * checkStdin checks if any data has been passed in through stdin and returns
@@ -156,7 +159,7 @@ func milkbucket(cmd *cobra.Command, args []string) {
} }
defer sdl.Quit() defer sdl.Quit()
m, err := newMilkDropWindow(800, 600, args) m, err := newMilkDropWindow(width, height, args, softCutDuration)
if err != nil { if err != nil {
cobra.CheckErr(err) cobra.CheckErr(err)
} }
@@ -203,4 +206,7 @@ func init() {
// Cobra also supports local flags, which will only run // Cobra also supports local flags, which will only run
// when this action is called directly. // when this action is called directly.
rootCmd.Flags().BoolVarP(&transition, "transition", "t", false, "smoothly transition between presets") rootCmd.Flags().BoolVarP(&transition, "transition", "t", false, "smoothly transition between presets")
rootCmd.Flags().Float64VarP(&softCutDuration, "soft-cut-duration", "s", 3, "time in seconds for a soft transition between two presets (use with --transition)")
rootCmd.Flags().Int32Var(&width, "width", 800, "window width")
rootCmd.Flags().Int32Var(&height, "height", 600, "window height")
} }

View File

@@ -88,7 +88,7 @@ func (m *milkDropWindow) prevPreset(smooth bool) {
* newMilkDropWindow returns a new milkDropWindow with the given width and * newMilkDropWindow returns a new milkDropWindow with the given width and
* height, and sets presets available to the window. * height, and sets presets available to the window.
*/ */
func newMilkDropWindow(width, height int32, presets []string) (*milkDropWindow, error) { func newMilkDropWindow(width, height int32, presets []string, softCutDuration float64) (*milkDropWindow, error) {
var m milkDropWindow var m milkDropWindow
var err error var err error
@@ -111,6 +111,8 @@ func newMilkDropWindow(width, height int32, presets []string) (*milkDropWindow,
C.projectm_set_window_size(m.handle, C.ulong(width), C.ulong(height)) C.projectm_set_window_size(m.handle, C.ulong(width), C.ulong(height))
C.projectm_set_soft_cut_duration(m.handle, C.double(softCutDuration))
return &m, nil return &m, nil
} }