Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // “Alone” - Edgar Allan Poe
- chdir('home/')
- exec('ADC.sce')
- fs = 10000
- quant_levels = linspace(-1, 1, 200) // we need more quantity levels
- recorded_data = ADC(13, quant_levels, fs)
- recorded_samples = size(recorded_data)(1)
- sin_ampl = 0.1
- // get best value for sin_freq in possible range (120, 210)
- sin_freqs=zeros(1,91)
- for i = 120:210
- step_size = i*(2*%pi)/fs
- samples = [1:recorded_samples]*step_size
- sin_sig = sin_ampl*sin(samples)
- sin_freqs(1, i - 120 + 1) = sum(sin_sig' .* recorded_data)
- end
- sin_freq = 120 + find(sin_freqs==max(sin_freqs)) - 1
- step_size = sin_freq*(2*%pi)/fs;
- samples = [1:recorded_samples]*step_size;
- sin_sig = sin_ampl*sin(samples)
- f = figure(1)
- clf
- plot(recorded_data - sin_sig' + 0.1, '--o') // +0.1 adjusts amplitudes to 0
- gca.data_bounds = [0, -1; fs, 1]
- xlabel('Sample')
- ylabel('Amplitude')
- playsnd(recorded_data, fs)
- savewave('record', recorded_data, fs)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement