Created
January 13, 2020 13:58
-
-
Save Xenakios/a0a2738e8d751f680f728b352807e313 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int main(int argc, char* argv[]) | |
{ | |
ScopedJuceInitialiser_GUI gui_init; | |
AudioDeviceManager aman; | |
String err = aman.initialiseWithDefaultDevices(0, 2); | |
if (err.isEmpty()) | |
{ | |
std::cout << "device opened : " << aman.getCurrentAudioDevice()->getName() << "\n"; | |
ToneGeneratorAudioSource tonesource; // Juce provided AudioSource based sine generator | |
tonesource.setFrequency(440.0); | |
tonesource.setAmplitude(0.1); | |
AudioSourcePlayer asplayer; // wraps the tone generator so it can be used as an AudioIODeviceCallback | |
asplayer.setSource(&tonesource); | |
aman.addAudioCallback(&asplayer); | |
while (true) | |
{ | |
double freq = 0.0; | |
std::cin >> freq; | |
if (freq > 0.0) | |
tonesource.setFrequency(freq); | |
else | |
break; | |
} | |
std::cout << "closing device...\n"; | |
} | |
else | |
std::cout << "could not open device : " << err << "\n"; | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment