Skip to content

Instantly share code, notes, and snippets.

@Xenakios
Created January 13, 2020 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Xenakios/a0a2738e8d751f680f728b352807e313 to your computer and use it in GitHub Desktop.
Save Xenakios/a0a2738e8d751f680f728b352807e313 to your computer and use it in GitHub Desktop.
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