Comments (13)
This is very annoying in Linux. If I'm running a music visualization program I'll probably want to run it on the sound being played by the computer, not line in. But SDL makes that impossible without editing and recompiling!
First, SDL will ignore PulseAudio sources which are monitors: https://github.com/spurious/SDL-mirror/blob/cc7a10af3465de5d452a7f3d263ee1f36eeaed71/src/audio/pulseaudio/SDL_pulseaudio.c#L680
Second, SDL will set the DONT_MOVE flag if an audio source name is specified, so you can't move the input to a different source: https://github.com/spurious/SDL-mirror/blob/cc7a10af3465de5d452a7f3d263ee1f36eeaed71/src/audio/pulseaudio/SDL_pulseaudio.c#L632
(pavucontrol will offer you GUI elements for doing the move but not actually move. pactl will unhelpfully say "Failure: Invalid argument".)
Right now I edited the SDL_OpenAudioDevice call to make the audio source name NULL, allowing the source to be moved to the monitor.
Switching to an ALSA driver via SDL_AUDIODRIVER=alsa
in the environment doesn't help either. For some reason the pulse_monitor source defined in ~/.asoundrc
isn't seen by SDL.
from projectm.
Hey, am a new guy, never made any PR, can you assist me.
from projectm.
Or provide me direction. Thanks
from projectm.
Sure... you can come chat in #projectM on freenode IRC if you want
There is some code already for selecting the input device, it needs to be improved.
Read the SDL2 docs for audio input capture
SDL_AudioDeviceID projectMSDL::selectAudioInput(int _count) {
// ask the user which capture device to use
// printf("Please select which audio input to use:\n");
printf("Detected devices:\n");
for (int i = 0; i < _count; i++) {
printf(" %i: 🎤%s\n", i, SDL_GetAudioDeviceName(i, true));
}
return 0;
}
int projectMSDL::openAudioInput() {
// get audio driver name (static)
const char* driver_name = SDL_GetCurrentAudioDriver();
SDL_Log("Using audio driver: %s\n", driver_name);
// get audio input device
unsigned int i, count2 = SDL_GetNumAudioDevices(true); // capture, please
if (count2 == 0) {
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "No audio capture devices found");
SDL_Quit();
}
for (i = 0; i < count2; i++) {
SDL_Log("Found audio capture device %d: %s", i, SDL_GetAudioDeviceName(i, true));
}
SDL_AudioDeviceID selectedAudioDevice = 0; // device to open
if (count2 > 1) {
// need to choose which input device to use
selectedAudioDevice = selectAudioInput(count2);
if (selectedAudioDevice > count2) {
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "No audio input device specified.");
SDL_Quit();
}
}
// params for audio input
SDL_AudioSpec want, have;
// requested format
SDL_zero(want);
want.freq = 48000;
want.format = AUDIO_F32; // float
want.channels = 2;
want.samples = 512;
want.callback = projectMSDL::audioInputCallbackF32;
want.userdata = this;
audioDeviceID = SDL_OpenAudioDevice(SDL_GetAudioDeviceName(selectedAudioDevice, true), true, &want, &have, 0);
if (audioDeviceID == 0) {
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Failed to open audio capture device: %s", SDL_GetError());
SDL_Quit();
}
// read characteristics of opened capture device
SDL_Log("Opened audio capture device %i: %s", audioDeviceID, SDL_GetAudioDeviceName(selectedAudioDevice, true));
SDL_Log("Sample rate: %i, frequency: %i, channels: %i, format: %i", have.samples, have.freq, have.channels, have.format);
audioChannelsCount = have.channels;
audioSampleRate = have.freq;
audioSampleCount = have.samples;
audioFormat = have.format;
audioInputDevice = audioDeviceID;
return 1;
}
is the code in pmSDL.cpp to find the available devices and select them
something more user-friendly would be nice. not sure what.
from projectm.
Lots of thanks for assisting me.
from projectm.
SDL_AudioDeviceID projectMSDL::selectAudioInput(int _count) {
// ask the user which capture device to use
// printf("Please select which audio input to use:\n");
printf("Detected devices:\n");
for (int i = 0; i < _count; i++) {
printf(" %i: 🎤%s\n", i, SDL_GetAudioDeviceName(i, true));
}
return 0;
}
This should return the index of the desired device
from projectm.
ProjectX should allow u to lock in the songs with the effects that u choose when swiped left or right etc.
from projectm.
Up vote this bug
https://bugzilla.libsdl.org/show_bug.cgi?id=4187
from projectm.
Hi !
I am a beginner and i would like to contribute , can you please guide me ?
from projectm.
SDL moved to GitHub, issue as well: libsdl-org/SDL#2917
from projectm.
SDL moved to GitHub, issue as well: libsdl-org/SDL#2917
We just fixed this issue in SDL, which will be in the 2.0.16 release, that we're working on wrapping up right now. If you get a chance, please test the latest in revision control and make sure it meets your needs!
from projectm.
SDL moved to GitHub, issue as well: libsdl-org/SDL#2917
We just fixed this issue in SDL, which will be in the 2.0.16 release, that we're working on wrapping up right now. If you get a chance, please test the latest in revision control and make sure it meets your needs!
Big thanks for fixing it!
Will test it tomorrow or the day after when I'm back home and give feedback whether it worked or not.
from projectm.
Setting the newly added SDL_HINT_AUDIO_INCLUDE_MONITORS
hint works perfectly, PR is open.
from projectm.
Related Issues (20)
- warning: implicit conversion from 'const typename basic_string<char, char_traits<char>, allocator<char>>::size_type' (aka 'const unsigned long') to 'int' changes value from 18446744073709551615 to -1 HOT 5
- Update config.guess to support riscv64 platform HOT 5
- Faulty include in ProjectM.hpp / projectM-4.pc HOT 4
- Support Poweramp Visualizer (PowerMilk) spectrum bars effect HOT 3
- Discussion: Current State of Release tags HOT 2
- Apple TV implementation HOT 4
- Warp/composite mesh U/V coordinates cause issues with some preset shaders HOT 4
- Milkdrop 1.4 presets or only some effects render upside down
- Implement random texture selection
- Shader-based smooth transitions between presets HOT 5
- Add a project GitHub page with extensive Sphinx-generated documentation HOT 1
- Add an error reporting and general logging API
- Support Milkdrop user sprites
- Nintendo Switch Support HOT 3
- Add the ability to control the actual running time from the outside. HOT 1
- Some way to cap how epileptic presets can be HOT 18
- White screen on Soft Cuts HOT 7
- Fix GLES/Emscripten rendering issues HOT 1
- preset soft transitions don't work on Mac
- Try out libniceshade as a replacement for hlslparser
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from projectm.