how to drive a speaker from a r2r ladder

thanks for the help!!

by using direct port manipulation, it should be something like this:

char Sample[]={/*data stored in a 8bit precision*/};
DDRB = B11111111;
PORTB = 00000000;
for(int i=0; i<SAMPLES_NUMBER;i++)
{
  PORTB = Sample[i];
  delayMicroseconds(32);
}

right?

on the other hand, i could use a shift register to send all the data through a single pin and then obtain an 8-pins parallel output on the other side of the register, right? in this way, the clock sets also the sample rate of the digital audio data coming out from the register, but how can i set it to a determined frequency value? however, this time the code should be something like this (arranged from a playground tutorial):

int latchPin = 8; //storage clock
int clockPin = 12; //register clok
int dataPin = 11; //serial data
char Sample[]={/*data stored in a 8bit precision*/};

void setup()
{
  pinMode(latchPin, OUTPUT);
  pinMode(clockPin, OUTPUT);
  pinMode(dataPin, OUTPUT);
}

void loop()
{
  for (int i= 0; i<SAMPLES_NUMBER; i++)
  {
    digitalWrite(latchPin, LOW);
    shiftOut(dataPin, clockPin, MSBFIRST, Sample[i]);  
    digitalWrite(latchPin, HIGH);
    delayMicroseconds(32);  //not sure about that
  }
}

are those pieces of code exact? which one is more powerful in terms of sample rate respect and speed?