Last active
February 1, 2017 00:25
-
-
Save dangpzanco/0a095ae3a66e826f8af36f431d289955 to your computer and use it in GitHub Desktop.
Sinewave generator based on the second answer of http://dsp.stackexchange.com/questions/971/how-to-create-a-sine-wave-generator-that-can-smoothly-transition-between-frequen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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