Skip to content

Commit c5533e3

Browse files
authored
Little things (#368)
* Noise not needed - F4 shows if shaders are compiled. * Don't compile native presets by default in Visual Studio * Debug / duplicate info * Missed a debug native preset. * Make texture errors more clear - we failed looking for multiple extensions. * Move images from presets folder to textures folder * Documented missing textures. * Undo Visual Studio version bump. * Renable NativePresetFactory (but the example native presets remain disabled) * Comment * Fixes / updates to audio device toggling. * Stop crashing if there is no input microphone. Make fake audio dynamic so it can be enabled if there is no mic. * Remove debug output. * Document VC++ redist requirement. * F4 missing from SDL help menu. * Windows app instead of Console (no more cmd.exe pop-up when launching). * Fullscreen for built-in settings. * New icon (based on github and idle preset and consistent with Steam) * Change language for loopback / audio changing. * default fullscreen for built-in settings. * Revert "Fullscreen for built-in settings." This reverts commit b1936e7. * Revert "default fullscreen for built-in settings." This reverts commit ea89584. * Revert "9a9151b9" * 9a9151b * fake_audio to fakeAudio
1 parent f2ca861 commit c5533e3

File tree

9 files changed

+126
-91
lines changed

9 files changed

+126
-91
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ Its purpose in life is to read an audio input and to produce mesmerizing visuals
1111
### Available For
1212
* [macOS, Linux (binary)](https://github.com/projectM-visualizer/projectm/releases)
1313
* [Windows Store (PC, XBOX, Phone)](https://www.microsoft.com/store/apps/9NDCVH0VCWJN)
14+
* [Windows (standalone binary)](https://github.com/projectM-visualizer/projectm/releases) (Requires the latest [Visual C++ redistributable](https://support.microsoft.com/en-us/help/2977003/the-latest-supported-visual-c-downloads))
1415
* [Android](https://play.google.com/store/apps/details?id=com.psperl.projectM)
1516
* [iOS](https://itunes.apple.com/us/app/projectm-music-visualizer/id530922227?mt=8&ign-mpt=uo%3D4)
1617
* [iTunes plugin (macOS)](https://github.com/projectM-visualizer/projectm/releases/)

msvc/projectM.ico

98.1 KB
Binary file not shown.

msvc/projectM.sln

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,27 +62,17 @@ Global
6262
{013DE011-EC24-3643-A8EE-F2609E7E4741}.Release|x64.ActiveCfg = Release|x64
6363
{013DE011-EC24-3643-A8EE-F2609E7E4741}.Release|x64.Build.0 = Release|x64
6464
{55A71B6A-5C7E-30D5-8210-302A8D2080DB}.Debug|x64.ActiveCfg = Debug|x64
65-
{55A71B6A-5C7E-30D5-8210-302A8D2080DB}.Debug|x64.Build.0 = Debug|x64
6665
{55A71B6A-5C7E-30D5-8210-302A8D2080DB}.Release|x64.ActiveCfg = Release|x64
67-
{55A71B6A-5C7E-30D5-8210-302A8D2080DB}.Release|x64.Build.0 = Release|x64
6866
{9260C46C-6BC9-396F-9310-6BAAD56A7801}.Debug|x64.ActiveCfg = Debug|x64
6967
{9260C46C-6BC9-396F-9310-6BAAD56A7801}.Release|x64.ActiveCfg = Release|x64
7068
{7A203034-A4D7-3A2B-9138-CB125F9B35E6}.Debug|x64.ActiveCfg = Debug|x64
71-
{7A203034-A4D7-3A2B-9138-CB125F9B35E6}.Debug|x64.Build.0 = Debug|x64
7269
{7A203034-A4D7-3A2B-9138-CB125F9B35E6}.Release|x64.ActiveCfg = Release|x64
73-
{7A203034-A4D7-3A2B-9138-CB125F9B35E6}.Release|x64.Build.0 = Release|x64
7470
{6E418BC8-5407-3A37-96BD-5201D47DE753}.Debug|x64.ActiveCfg = Debug|x64
75-
{6E418BC8-5407-3A37-96BD-5201D47DE753}.Debug|x64.Build.0 = Debug|x64
7671
{6E418BC8-5407-3A37-96BD-5201D47DE753}.Release|x64.ActiveCfg = Release|x64
77-
{6E418BC8-5407-3A37-96BD-5201D47DE753}.Release|x64.Build.0 = Release|x64
7872
{B7C4937F-A36D-3B6C-A8AC-CA99772AE5EC}.Debug|x64.ActiveCfg = Debug|x64
79-
{B7C4937F-A36D-3B6C-A8AC-CA99772AE5EC}.Debug|x64.Build.0 = Debug|x64
8073
{B7C4937F-A36D-3B6C-A8AC-CA99772AE5EC}.Release|x64.ActiveCfg = Release|x64
81-
{B7C4937F-A36D-3B6C-A8AC-CA99772AE5EC}.Release|x64.Build.0 = Release|x64
8274
{27DDCE71-E33B-3521-92B5-9918356D78A1}.Debug|x64.ActiveCfg = Debug|x64
83-
{27DDCE71-E33B-3521-92B5-9918356D78A1}.Debug|x64.Build.0 = Debug|x64
8475
{27DDCE71-E33B-3521-92B5-9918356D78A1}.Release|x64.ActiveCfg = Release|x64
85-
{27DDCE71-E33B-3521-92B5-9918356D78A1}.Release|x64.Build.0 = Release|x64
8676
EndGlobalSection
8777
GlobalSection(SolutionProperties) = preSolution
8878
HideSolutionNode = FALSE

msvc/projectMSDL.vcxproj

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
9090
<ImportLibrary>projectM-sdl/Debug/projectMSDL.lib</ImportLibrary>
9191
<ProgramDataBaseFile>projectM-sdl/Debug/projectMSDL.pdb</ProgramDataBaseFile>
92-
<SubSystem>Console</SubSystem>
92+
<SubSystem>Windows</SubSystem>
9393
</Link>
9494
<ProjectReference>
9595
<LinkLibraryDependencies>false</LinkLibraryDependencies>
@@ -133,7 +133,7 @@
133133
<IgnoreSpecificDefaultLibraries>%(IgnoreSpecificDefaultLibraries)</IgnoreSpecificDefaultLibraries>
134134
<ImportLibrary>projectM-sdl/Release/projectMSDL.lib</ImportLibrary>
135135
<ProgramDataBaseFile>projectM-sdl/Release/projectMSDL.pdb</ProgramDataBaseFile>
136-
<SubSystem>Console</SubSystem>
136+
<SubSystem>Windows</SubSystem>
137137
</Link>
138138
<ProjectReference>
139139
<LinkLibraryDependencies>false</LinkLibraryDependencies>
@@ -176,7 +176,7 @@
176176
<ResourceCompile Include="projectM.rc" />
177177
</ItemGroup>
178178
<ItemGroup>
179-
<Image Include="projectm_qDj_icon.ico">
179+
<Image Include="projectM.ico">
180180
<DeploymentContent>true</DeploymentContent>
181181
</Image>
182182
</ItemGroup>
@@ -208,6 +208,7 @@
208208
<Exec Command="copy /Y &quot;$(MSBuildThisFileDirectory)..\LICENSE.txt&quot; &quot;$(OutDir)LICENSE.txt&quot;" />
209209
<Exec Command="copy /Y &quot;$(MSBuildThisFileDirectory)..\AUTHORS.txt&quot; &quot;$(OutDir)AUTHORS.txt&quot;" />
210210
<Exec Command="copy /Y &quot;$(MSBuildThisFileDirectory)..\README.md&quot; &quot;$(OutDir)README.md&quot;" />
211+
<Exec Command="copy /Y &quot;$(MSBuildThisFileDirectory)projectM.ico&quot; &quot;$(OutDir)projectM.ico&quot;" />
211212
<Exec Command="copy /Y &quot;$(MSBuildThisFileDirectory)projectm_qDj_icon.ico&quot; &quot;$(OutDir)projectm_qDj_icon.ico&quot;" />
212213
<Exec Command="copy /Y &quot;$(MSBuildThisFileDirectory)Setup.iss&quot; &quot;$(OutDir)Setup.iss&quot;" />
213214
<Exec Command="copy /Y &quot;$(MSBuildThisFileDirectory)setup_inno.bmp&quot; &quot;$(OutDir)setup_inno.bmp&quot;" />

src/libprojectM/PresetFactory.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ std::string PresetFactory::protocol(const std::string & url, std::string & path)
1616
else {
1717
path = url.substr(pos + 3, url.length());
1818
// std::cout << "[PresetFactory] path is " << path << std::endl;
19+
#ifdef DEBUG
1920
std::cout << "[PresetFactory] url is " << url << std::endl;
21+
#endif
2022
return url.substr(0, pos);
2123
}
2224

src/libprojectM/Renderer/ShaderEngine.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -765,7 +765,9 @@ GLuint ShaderEngine::compilePresetShader(const PresentShaderType shaderType, Sha
765765
}
766766

767767
if (ret != GL_FALSE) {
768+
#ifdef DEBUG
768769
std::cerr << "Successful compilation of " << shaderTypeString << std::endl;
770+
#endif
769771
} else {
770772
std::cerr << "Compilation error (step3) of " << shaderTypeString << std::endl;
771773

src/projectM-sdl/pmSDL.cpp

Lines changed: 56 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -61,27 +61,45 @@ void projectMSDL::audioInputCallbackS16(void *userdata, unsigned char *stream, i
6161
app->pcm()->addPCM16(pcm16);
6262
}
6363

64-
SDL_AudioDeviceID projectMSDL::selectAudioInput(int _count) {
65-
// TODO: implement some sort of UI allowing the user to select which audio input device they would like to use
66-
67-
68-
// ask the user which capture device to use
69-
// printf("Please select which audio input to use:\n");
70-
printf("Detected devices:\n");
71-
for (int i = 0; i < _count; i++) {
72-
printf(" %i: 🎤%s\n", i, SDL_GetAudioDeviceName(i, true));
73-
}
74-
75-
return 0;
76-
}
77-
7864
int projectMSDL::toggleAudioInput() {
79-
80-
CurAudioDevice++;
81-
if (CurAudioDevice >= NumAudioDevices)
65+
// trigger a toggle with CMD-I or CTRL-I
66+
if (wasapi) { // we are currently on WASAPI, so we are going to revert to a microphone/line-in input.
67+
if (this->openAudioInput())
68+
this->beginAudioCapture();
8269
CurAudioDevice = 0;
83-
selectedAudioDevice = CurAudioDevice;
84-
initAudioInput();
70+
selectedAudioDevice = CurAudioDevice;
71+
this->wasapi = false; // Track wasapi as off so projectMSDL will stop listening to WASAPI loopback in pmSDL_main.
72+
}
73+
else {
74+
this->endAudioCapture(); // end current audio capture.
75+
CurAudioDevice++; // iterate device index
76+
if (CurAudioDevice >= NumAudioDevices) { // We reached outside the boundaries of available audio devices.
77+
CurAudioDevice = 0; // Return to first audio device in the index.
78+
#ifdef WASAPI_LOOPBACK
79+
// If we are at the boundary and WASAPI is enabled then let's load WASAPI instead.
80+
projectM::setToastMessage("Loopback audio selected");
81+
SDL_Log("Loopback audio selected");
82+
this->fakeAudio = false; // disable fakeAudio in case it was enabled.
83+
this->wasapi = true; // Track wasapi as on so projectMSDL will listen to it.
84+
#else
85+
if (NumAudioDevices == 1) // If WASAPI_LOOPBACK was not enabled and there is only one audio device, it's pointless to toggle anything.
86+
{
87+
SDL_Log("There is only one audio capture device. There is nothing to toggle at this time.");
88+
return 1;
89+
}
90+
// If WASAPI_LOOPBACK is not enabled and we have multiple input devices, return to device index 0 and let's listen to that device.
91+
selectedAudioDevice = CurAudioDevice;
92+
initAudioInput();
93+
this->beginAudioCapture();
94+
#endif
95+
}
96+
else {
97+
// This is a normal scenario where we move forward in the audio device index.
98+
selectedAudioDevice = CurAudioDevice;
99+
initAudioInput();
100+
this->beginAudioCapture();
101+
}
102+
}
85103
return 1;
86104
}
87105

@@ -105,15 +123,17 @@ int projectMSDL::initAudioInput() {
105123

106124
if (audioDeviceID == 0) {
107125
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "Failed to open audio capture device: %s", SDL_GetError());
108-
SDL_Quit();
126+
return 0;
109127
}
110128

111129
// read characteristics of opened capture device
112130
SDL_Log("Opened audio capture device index=%i devId=%i: %s", selectedAudioDevice, audioDeviceID, SDL_GetAudioDeviceName(selectedAudioDevice, true));
113-
std::string deviceToast = "Listening to ";
114-
deviceToast += SDL_GetAudioDeviceName(selectedAudioDevice, true);
131+
std::string deviceToast = SDL_GetAudioDeviceName(selectedAudioDevice, true); // Example: Microphone rear
132+
deviceToast += " selected";
115133
projectM::setToastMessage(deviceToast);
134+
#ifdef DEBUG
116135
SDL_Log("Samples: %i, frequency: %i, channels: %i, format: %i", have.samples, have.freq, have.channels, have.format);
136+
#endif
117137
audioChannelsCount = have.channels;
118138
audioSampleRate = have.freq;
119139
audioSampleCount = have.samples;
@@ -124,9 +144,12 @@ int projectMSDL::initAudioInput() {
124144
}
125145

126146
int projectMSDL::openAudioInput() {
147+
fakeAudio = false; // if we are opening an audio input then there is no need for fake audio.
127148
// get audio driver name (static)
149+
#ifdef DEBUG
128150
const char* driver_name = SDL_GetCurrentAudioDriver();
129151
SDL_Log("Using audio driver: %s\n", driver_name);
152+
#endif
130153

131154
// get audio input device
132155
unsigned int i;
@@ -135,23 +158,18 @@ int projectMSDL::openAudioInput() {
135158
CurAudioDevice = 0;
136159
if (NumAudioDevices == 0) {
137160
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "No audio capture devices found");
138-
SDL_Quit();
161+
projectM::setToastMessage("No audio capture devices found: using simulated audio");
162+
fakeAudio = true;
163+
return 0;
139164
}
165+
#ifdef DEBUG
140166
for (i = 0; i < NumAudioDevices; i++) {
141167
SDL_Log("Found audio capture device %d: %s", i, SDL_GetAudioDeviceName(i, true));
142168
}
169+
#endif
143170

144-
// device to open
171+
// default selected Audio Device to 0.
145172
selectedAudioDevice = 0;
146-
if (NumAudioDevices > 1) {
147-
// need to choose which input device to use
148-
selectedAudioDevice = selectAudioInput(CurAudioDevice);
149-
if (selectedAudioDevice > NumAudioDevices) {
150-
SDL_LogCritical(SDL_LOG_CATEGORY_APPLICATION, "No audio input device specified.");
151-
SDL_Quit();
152-
}
153-
}
154-
155173
initAudioInput();
156174

157175
return 1;
@@ -164,6 +182,7 @@ void projectMSDL::beginAudioCapture() {
164182

165183
void projectMSDL::endAudioCapture() {
166184
SDL_PauseAudioDevice(audioDeviceID, true);
185+
SDL_CloseAudioDevice(audioDeviceID);
167186
}
168187

169188
void projectMSDL::setHelpText(const std::string & helpText) {
@@ -465,6 +484,10 @@ void projectMSDL::init(SDL_Window *window, SDL_GLContext *_glCtx, const bool _re
465484
glCtx = _glCtx;
466485
projectM_resetGL(width, height);
467486

487+
#ifdef WASAPI_LOOPBACK
488+
wasapi = true;
489+
#endif
490+
468491
// are we rendering to a texture?
469492
renderToTexture = _renderToTexture;
470493
if (renderToTexture) {

src/projectM-sdl/pmSDL.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,8 @@ class projectMSDL : public projectM {
8888

8989

9090
bool done;
91+
bool wasapi = false; // Used to track if wasapi is currently active. This bool will allow us to run a WASAPI app and still toggle to microphone inputs.
92+
bool fakeAudio = false; // Used to track fake audio, so we can turn it off and on.
9193
projectMSDL(Settings settings, int flags);
9294
projectMSDL(std::string config_file, int flags);
9395
void init(SDL_Window *window, SDL_GLContext *glCtx, const bool renderToTexture = false);
@@ -135,7 +137,6 @@ class projectMSDL : public projectM {
135137
static void audioInputCallbackS16(void *userdata, unsigned char *stream, int len);
136138

137139
void keyHandler(SDL_Event *);
138-
SDL_AudioDeviceID selectAudioInput(int _count);
139140
void renderTexture();
140141
};
141142

0 commit comments

Comments
 (0)