I made something much like this a couple of weeks ago, here is some example code for MatLab or (FreeMat) that generates a sine wave with selectable amplitude and frequency as gcode.
It's a work in progress, I haven't had the time to try i t all out yet!
I used a spring loaded diamond engraver to do the cutting and old vinyl records, anodized aluminium and PCB-material for the actual records.
R0 = 84; % Start radius
dR = -0.5; % Radius step per revolution
R1 = 55; % Stop radius
N = (R1-R0)/dR; % Number of tracks
rpm = 45; % target rotation speed, rotations per minute
rps = rpm/60; % rotations per second
f_sample = 1378; % sampling frequency Hz
dt = 1/f_sample; % delta time between samples
t = (0:dt:(N/rps))'; % time vector from start to end
R = R0 + dR*rps*t; % Radius as a function of time t
fi = 2*pi*rps*t; % Angle as a function of time t
X = R.*cos(fi); % X coordinate as a function of angle and radius
Y = R.*sin(fi); % Y coordinate as a function of angle and radius
Z_max = 0; % antar att alla mÂtt ‰r i mm
Z_min = -0.5;
amplitud = Z_max - Z_min;
offset = (Z_max + Z_min)/2;
Z = (amplitud/2).*sin(2*pi*500*t)+offset; % ny amplitud blir den ˆnskade delat p 2, den fˆr sinus vanliga amplituden
plot3(X,Y,Z);
axis equal
fid = fopen('test5 sjua.txt', 'wt');
fprintf(fid, 'G01 X%0.3f Y%0.3f Z%0.3f\n', [X Y Z]');
fclose(fid);
Here is some untested routines to insert a wave file into the code:
(sorry, comments in Swedish at the moment)
clear
clc
[Z,fs] = wavread('1'); %H‰r l‰ses wav-filen 1.wav in..
Z=Z-max(Z); %alla z-v‰rden flyttas ner under nollan.
RPM = 33; %varvtalet p skivan d den spelas upp.
R0 = 30; %skivans ytterradie
dr = 0.05; %avstÂnd mellan varven
p = .1; %skalning av z
t = [1/fs:1/fs:size(Z,1)/fs]'; %tidsvektor som bet‰mms av samplingsfrekvens och l‰ngd p ljudspÂr
Vt = t*(RPM/60)*2*pi; %Vinkel som funktion av tiden
Rt = R0-(dr*t*(RPM/60)); %radie som funktion av tiden
R= min(Rt); %innre radien
%X=Rt.*cos(Vt); %Freemat: radie och vinkel ˆvers‰tts till X-koordinat.
%Y=Rt.*sin(Vt); %Freemat: radie och vinkel ˆvers‰tts till Y-koordinat.
[X,Y]=pol2cart(Vt,Rt); %Matlab: pol2cart ‰r en funktion i matlab som gˆr det samma som de tv raderna ˆver.
Z = Z*p; %Skalningen av z
%plot3(X,Y,Z);
%fid = fopen('test.txt', 'wt');
%fprintf(fid, 'G01 X%0.3f Y%0.3f Z%0.3f\n', [X Y Z]');
%fclose(fid);