Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a gain argument to altonegen #502

Merged
merged 2 commits into from
Dec 4, 2020
Merged

Add a gain argument to altonegen #502

merged 2 commits into from
Dec 4, 2020

Conversation

eliotmiranda
Copy link
Contributor

Add a gain command-line argument to altonegen.c.
Fix a spelling error in an error message in opensl.cpp
Fix compilation of some of the examples by guarding the include of win_main_utf8.h

Add a gain command-line argument to altonegen.c
if(gain < 0.0 || gain > 1.0)
{
fprintf(stderr, "Invalid gain: %s (min: 0.0, max 1.0)\n", argv[i]);
tone_freq = 1;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a copy-paste error.

@@ -175,6 +181,7 @@ int main(int argc, char *argv[])
ALint tone_freq = 1000;
ALCint dev_rate;
ALenum state;
ALfloat gain = 1.0f;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doesn't seem indented properly.

@@ -144,6 +146,10 @@ static ALuint CreateWave(enum WaveType type, ALuint freq, ALuint srate)
break;
}

if (gain != 1.0)
for(i = 0;i < srate;i++)
data[i] *= gain;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This also seems over-indented.

#include "win_main_utf8.h"
#ifdef _WIN32
# include "win_main_utf8.h"
#endif
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason this was put behind an ifdef, when the header already checks for Windows?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I made a mistake compiling the examples, leaving out an include directory path. But for me I prefer having the logic that include or excludes platform specific files where I can see it rather than going to the header to check. So my steps went something like, “compilation on Mac failed, why? Saw the Windows specific include, ifdef’ed it out, compilation succeeded. Link failed with code in alhelpers.c missing. Found alhelpers, added the directory, compiled and linked altonegen. Didn’t go back to undo ifdefs cuz the code feels more readable that way.

I shall revert if if you prefer.

@kcat kcat merged commit e3179aa into kcat:master Dec 4, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants