It sounds like you already have some code written...? I assume that you're far enough to be able to grab the amplitude at a point in time in the song?
Basically... You can't just draw the ENTIRE waveform on the screen, and then grab it as one gigantic, long image. I think it would be faster to redraw the waveform every loop (I know that the built in DBPro line commands are very very slow. Look up Cloggy's d3dfunc dll. It has really fast line commands, I've had programs that went from ~10 fps to 100 fps+ using d3d_line). Basically, do something like this (in pseudocode)
total_samples as integer `total samples in the song
left_bound as integer `left bound of where to draw the waveform
right_bound as integer `right bound
scale as float `scale of the waveform in pixels/sample.
vertScale as float `vertical scaling of the waveform
centerLine as integer `center line of the waveform
offset as integer `offset of the waveform for left/right panning.
vertScale=600.0/65535 `the waveform will be 600 pixels in height total.
scale=(right_bound-left_bound)*1.0/total_samples `now the audio fits from left_bound to right_bound.
do
`//however you want to control the variables "scale" and "offset" here//
lastIndex as integer
lastIndex=0
for x=left_bound to right_bound
index=x/scale+offset
if index<total_samples and index>=0
d3d_line x-1,(getSample(lastIndex)-32768)*vertScale+centerLine,x,(getSample(index)-32768)*vertScale+centerLine
endif
`/whatever/
loop
something like that should work fine.