Skip to content

Instantly share code, notes, and snippets.

@dangpzanco
Last active February 1, 2017 00:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dangpzanco/0a095ae3a66e826f8af36f431d289955 to your computer and use it in GitHub Desktop.
Save dangpzanco/0a095ae3a66e826f8af36f431d289955 to your computer and use it in GitHub Desktop.
clearvars
clc
close all
fs = 8000;
fc = 440;
omega = exp(1j*2*pi*fc/fs);
amplitude = 0.5;
signal_time = 1; % in seconds
signal_length = floor(fs*signal_time);
z = zeros(signal_length,1);
z(1) = amplitude;
exponent = 2;
freq_value = exp(1j*linspace(0,pi^(1/exponent),signal_length).^exponent);
for i=2:signal_length
z(i) = z(i-1)*freq_value(i);
% z(i) = z(i-1)*omega;
end
audiowrite('sinewave.wav',real(z),fs)
% plot(real(z))
% hold on
% plot(imag(z))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment