determine sound and size of screen
This commit is contained in:
@@ -1,2 +1,2 @@
|
||||
/usr/bin/sleep 5
|
||||
/home/maallyn/sound-scope/sdl2/fft-small-screen/build/scope 900 600
|
||||
/home/maallyn/sound-scope/sdl2/fft-small-screen/build/scope
|
||||
|
||||
40
scope.cpp
40
scope.cpp
@@ -40,15 +40,22 @@ int main(int argc, char *argv[])
|
||||
// function result
|
||||
int main_function_result = 0;
|
||||
|
||||
// Get parameters for size
|
||||
if (argc < 3)
|
||||
// Command line:
|
||||
// scope size from display, auto-detect USB audio
|
||||
// scope <device> size from display, given audio device
|
||||
// scope <x> <y> [device] explicit size override (optional device)
|
||||
const char *device_arg = NULL;
|
||||
if (argc >= 3 && atoi(argv[1]) > 0 && atoi(argv[2]) > 0)
|
||||
{
|
||||
printf ("needs x and y size \n");
|
||||
exit (0);
|
||||
}
|
||||
|
||||
x_window_size = atoi(argv[1]);
|
||||
y_window_size = atoi(argv[2]);
|
||||
if (argc > 3)
|
||||
device_arg = argv[3];
|
||||
}
|
||||
else if (argc >= 2)
|
||||
{
|
||||
device_arg = argv[1];
|
||||
}
|
||||
|
||||
int our_audio_trace_width;
|
||||
int our_audio_trace_height;
|
||||
@@ -61,12 +68,11 @@ int main(int argc, char *argv[])
|
||||
int *return_audio_buffer;
|
||||
int *return_spectrum_buffer;
|
||||
|
||||
printf ("window is %d by %d\n", x_window_size, y_window_size);
|
||||
// Audio device: use argv[3] if given, otherwise the first USB capture device
|
||||
// Audio device: use the command line if given, otherwise the first USB capture device
|
||||
char *device_name = input_our_audio_device_name;
|
||||
if (argc > 3)
|
||||
if (device_arg != NULL)
|
||||
{
|
||||
snprintf(device_name, sizeof(input_our_audio_device_name), "%s", argv[3]);
|
||||
snprintf(device_name, sizeof(input_our_audio_device_name), "%s", device_arg);
|
||||
}
|
||||
else if (alsa_read_class::find_usb_capture_device(device_name,
|
||||
sizeof(input_our_audio_device_name)) != 0)
|
||||
@@ -82,6 +88,20 @@ int main(int argc, char *argv[])
|
||||
printf("error initializing SDL: %s\n", SDL_GetError());
|
||||
}
|
||||
|
||||
// If no size was given, use the size of the display the window opens on
|
||||
if (x_window_size == 0 || y_window_size == 0)
|
||||
{
|
||||
SDL_DisplayMode display_mode;
|
||||
if (SDL_GetDesktopDisplayMode(0, &display_mode) != 0)
|
||||
{
|
||||
printf("error getting display size SDL: %s\n", SDL_GetError());
|
||||
exit(1);
|
||||
}
|
||||
x_window_size = display_mode.w;
|
||||
y_window_size = display_mode.h;
|
||||
}
|
||||
printf ("window is %d by %d\n", x_window_size, y_window_size);
|
||||
|
||||
// returns zero on success else non-zero
|
||||
|
||||
if (TTF_Init() != 0 ){
|
||||
|
||||
Reference in New Issue
Block a user