Record and Playback Analog Sound

hej

i was wondering if it is possible to record sound from a microphone ( piezo ) and play it back via a speaker ( also piezo ).

i managed to grab the input from a pre-amplified piezo sensor via a digital in pin and play it back through a digital out. as you can imagine it sound very rough.

has anyone ever done something like that more successfully?
maybe even via the analog input?

int inputPin = 2;
int outputPin = 3;

void setup() {
  pinMode(outputPin, OUTPUT);
  pinMode(inputPin, INPUT);
}

void loop() {
  digitalWrite(outputPin, digitalRead(inputPin));
}

i learned something.

while it is obviously easy to grab analog input from the analog pins, it is not as trivial to actually output the same data through an analog pin. the arduino semantics are a bit confusing here, as the analog out really creates a signal via PVM.

to actually output analog values as voltage between 0 and 5 volts ( or any other range ) a digital analog converter ( DAC ) is necessary. i learned that the easiest way to build a DAC is with a so called Resistor Ladder ( Resistor ladder - Wikipedia ). there are also ICs available.

has anyone any comments on that technique, or maybe even some useful advice or experience to share?

I'd be curious to know if there are any DAC ICs out there that are suitable for accepting low bit rate audio from the Arduino, and having an integrated amp / mixer for outputing said audio directly to a low power output device such as a small speaker. Any thoughts on this? could also do some other interesting things that require a wave form such as... laser control? don't know about this one, mabye it just requires a non inverting signal.