48 lines · 1.0 KB · C++
RawDownload
/* RTcmix - Copyright (C) 2004  The RTcmix Development Team   See ``AUTHORS'' for a list of contributors. See ``LICENSE'' for   the license to this software and for a DISCLAIMER OF ALL WARRANTIES.*/#include "Ooscil.h" Ooscil::Ooscil(float srate, float freq, float array[], int len)	: _array(array), _length(len){	_lendivSR = (double) _length / srate;	_si = freq * _lendivSR;	_phase = 0.0;} // NB: caller must call setfreq after thisvoid Ooscil::setsrate(float srate){	_lendivSR = (double) _length / srate;} float Ooscil::next(){	int i = (int) _phase;	float output = _array[i]; 	// prepare for next call	_phase += _si;	while (_phase >= (double) _length)		_phase -= (double) _length; 	return output;} float Ooscil::nexti(){	int i = (int) _phase;	int k = (i + 1) % _length;	double frac = _phase - (double) i;	float output = _array[i] + ((_array[k] - _array[i]) * frac); 	// prepare for next call	_phase += _si;	while (_phase >= (double) _length)		_phase -= (double) _length; 	return output;} 

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t