Yes, if you have powered computer monitor speakers that would work great - I did my testing of the Tone melody I use as an alarm doing that.
Then I ran it thru a simple MOSFET amplifier in my built-up design, see below.
I use it to make a nice warble - doesn't sound harsh & buzzy at all.
The switch & 2nd resistor sort of make a volume selector - only the difference is not as big as I thought it would be, so I may change the switch to have 2 in series (136 ohm) and 2 in parallel (34 ohm), that should make it more apparent - need something besides a SPST switch tho.
// presetup code
// info on alarm sound
#include "pitch.h" // this is in a separate tab in the sketch
// notes in the melody to play when a touch is scored:
int thisNote = 0;
int noteDuration = 0;
int pauseBetweenNotes = 0;
int melody[] = {
NOTE_C6, NOTE_A5, NOTE_C6, NOTE_A5, NOTE_C6, NOTE_A5, NOTE_C6};
// note durations: 4 = quarter note, 8 = eighth note, etc.:
int noteDurations[] = {
12,12,12,12,12,12,4};
// code run later in void loop
// create a warble once
for (thisNote = 0; thisNote < 8; thisNote++)
{
// to calculate the note duration, take one second
// divided by the note type.
//e.g. quarter note = 1000 / 4, eighth note = 1000/8, etc.
noteDuration = 1000/noteDurations[thisNote];
noTone(17); //apparent known bug - need this for the tone to play next.
tone(17, melody[thisNote],noteDuration);
// to distinguish the notes, set a minimum time between them.
// using the note's duration + 10%:
pauseBetweenNotes = noteDuration * 1.10;
delay(pauseBetweenNotes);
// stop the tone playing:
noTone(17);
}
digitalWrite (speakerOut, LOW); // turn off the amp -> capacitor coupled & gate pulled low, should not need this now, left over from before installing the series gate cap
delay (500);
// and suitable notes from pitch.h
#define NOTE_A5 880
#define NOTE_C6 1047