const correctness

dev
Oona Räisänen 2015-09-10 20:03:10 +03:00
rodzic e63b8a74be
commit 15a394f3ef
5 zmienionych plików z 47 dodań i 47 usunięć

Wyświetl plik

@ -75,7 +75,7 @@ void readPcm (int numsamples);
void saveCurrentPic();
void setVU (double *Power, int FFTLen, int WinIdx, bool ShowWin);
int startGui (int, char**);
std::tuple<bool,double,double> findMelody (Wave, Melody, double, double, double);
std::tuple<bool,double,double> findMelody (const Wave&, const Melody&, double, double, double);
SSTVMode vis2mode (int);

Wyświetl plik

@ -127,19 +127,19 @@ void DSP::set_fshift (double fshift) {
fshift_ = fshift;
}
int DSP::freq2bin (double freq, int fft_len) {
int DSP::freq2bin (double freq, int fft_len) const {
return (freq / samplerate_ * fft_len);
}
bool DSP::is_open () {
bool DSP::is_open () const {
return is_open_;
}
double DSP::get_t() {
double DSP::get_t() const {
return t_;
}
bool DSP::isLive() {
bool DSP::isLive() const {
return (stream_type_ == STREAM_TYPE_PA);
}
@ -283,7 +283,7 @@ double DSP::peakFreq (double minf, double maxf, WindowType wintype) {
}
Wave DSP::bandPowerPerHz(std::vector<std::vector<double> > bands, WindowType wintype) {
Wave DSP::bandPowerPerHz(const std::vector<std::vector<double>>& bands, WindowType wintype) {
unsigned fft_len = (window_[wintype].size() <= FFT_LEN_SMALL ? FFT_LEN_SMALL : FFT_LEN_BIG);
@ -475,7 +475,7 @@ double complexMag (fftw_complex coeff) {
}
Wave convolve (Wave sig, Wave kernel, bool wrap_around) {
Wave convolve (const Wave& sig, const Wave& kernel, bool wrap_around) {
assert (kernel.size() % 2 == 1);
@ -500,7 +500,7 @@ Wave convolve (Wave sig, Wave kernel, bool wrap_around) {
return result;
}
Wave* upsample (Wave orig, size_t factor, int kern_type) {
Wave upsample (const Wave& orig, size_t factor, int kern_type) {
Wave kern;
if (kern_type == KERNEL_LANCZOS2) {
@ -519,22 +519,22 @@ Wave* upsample (Wave orig, size_t factor, int kern_type) {
padded.insert(padded.begin(), orig[0]);
padded.push_back(orig[orig.size()-1]);
Wave* filtered = new Wave(convolve(padded, kern));
Wave filtered = convolve(padded, kern);
filtered->erase(filtered->begin(), filtered->begin()+factor/2);
filtered->erase(filtered->end()-factor/2, filtered->end());
filtered.erase(filtered.begin(), filtered.begin()+factor/2);
filtered.erase(filtered.end()-factor/2, filtered.end());
return filtered;
}
Wave deriv (Wave wave) {
Wave deriv (const Wave& wave) {
Wave result;
for (size_t i=1; i<wave.size(); i++)
result.push_back(wave[i] - wave[i-1]);
return result;
}
std::vector<double> peaks (Wave wave, size_t n) {
std::vector<double> peaks (const Wave& wave, size_t n) {
std::vector<std::pair<double,double> > peaks;
for (size_t i=0; i<wave.size(); i++) {
double y1 = (i==0 ? wave[0] : wave[i-1]);
@ -558,7 +558,7 @@ std::vector<double> peaks (Wave wave, size_t n) {
}
std::vector<double> derivPeaks (Wave wave, size_t n) {
std::vector<double> derivPeaks (const Wave& wave, size_t n) {
std::vector<double> result = peaks(deriv(wave), n);
for (size_t i=0; i<result.size(); i++) {
result[i] += .5;
@ -575,7 +575,7 @@ std::vector<double> derivPeaks (Wave wave, size_t n) {
* (double) at which frequency shift
* (double) started how many seconds before the last sample
*/
std::tuple<bool,double,double> findMelody (Wave wave, Melody melody, double dt, double min_shift, double max_shift) {
std::tuple<bool,double,double> findMelody (const Wave& wave, const Melody& melody, double dt, double min_shift, double max_shift) {
bool was_found = true;
int start_at = 0;
double avg_fdiff = 0;

Wyświetl plik

@ -44,17 +44,17 @@ class DSP {
void forward_to_time (double);
void set_fshift (double);
void windowedMoment (WindowType, fftw_complex *);
void windowedMoment (WindowType, fftw_complex*);
double peakFreq (double, double, WindowType);
int freq2bin (double, int);
std::vector<double> bandPowerPerHz (std::vector<std::vector<double> >, WindowType wintype=WINDOW_HANN2047);
int freq2bin (double, int) const;
std::vector<double> bandPowerPerHz (const std::vector<std::vector<double>>&, WindowType wintype=WINDOW_HANN2047);
WindowType bestWindowFor (SSTVMode, double SNR=99);
double videoSNR();
double lum(SSTVMode, bool is_adaptive=false);
bool is_open ();
double get_t ();
bool isLive ();
bool is_open () const;
double get_t () const;
bool isLive () const;
double syncPower ();
void setLatestPixbuf(Glib::RefPtr<Gdk::Pixbuf>);
@ -109,12 +109,12 @@ class MyPortaudioClass{
}
};
Wave convolve (Wave, Wave, bool wrap_around=false);
Wave deriv (Wave);
Wave peaks (Wave, size_t);
Wave derivPeaks (Wave, size_t);
Wave rms (Wave, int);
Wave* upsample (Wave orig, size_t factor, int kern_type);
Wave convolve (const Wave&, const Wave&, bool wrap_around=false);
Wave deriv (const Wave&);
Wave peaks (const Wave&, size_t);
Wave derivPeaks (const Wave&, size_t);
Wave rms (const Wave&, int);
Wave upsample (const Wave& orig, size_t factor, int kern_type);
double gaussianPeak (double y1, double y2, double y3);
double power (fftw_complex coeff);
double complexMag (fftw_complex coeff);

Wyświetl plik

@ -10,13 +10,13 @@ void Picture::pushToVideoSignal(double s) {
video_signal_.push_back(s);
}
SSTVMode Picture::getMode () { return mode_; }
double Picture::getDrift () { return drift_; }
double Picture::getStartsAt () { return starts_at_; }
double Picture::getVideoDt () { return video_dt_; }
double Picture::getSyncDt () { return sync_dt_; }
double Picture::getSyncSignalAt (size_t i) { return sync_signal_[i]; }
double Picture::getVideoSignalAt (size_t i) { return video_signal_[i]; }
SSTVMode Picture::getMode () const { return mode_; }
double Picture::getDrift () const { return drift_; }
double Picture::getStartsAt () const { return starts_at_; }
double Picture::getVideoDt () const { return video_dt_; }
double Picture::getSyncDt () const { return sync_dt_; }
double Picture::getSyncSignalAt (size_t i) const { return sync_signal_[i]; }
double Picture::getVideoSignalAt (size_t i) const { return video_signal_[i]; }
Glib::RefPtr<Gdk::Pixbuf> Picture::renderPixbuf(unsigned min_width) {
@ -59,8 +59,8 @@ Glib::RefPtr<Gdk::Pixbuf> Picture::renderPixbuf(unsigned min_width) {
if (mode_ == MODE_R36 || m.family == MODE_PD) {
for (size_t x=0; x < m.scan_pixels; x++) {
Wave column_u, column_v;
Wave* column_u_filtered;
Wave* column_v_filtered;
Wave column_u_filtered;
Wave column_v_filtered;
for (size_t y=0; y < m.num_lines; y+=2) {
column_u.push_back(img[x][y][1]);
column_v.push_back(img[x][y][2]);
@ -68,8 +68,8 @@ Glib::RefPtr<Gdk::Pixbuf> Picture::renderPixbuf(unsigned min_width) {
column_u_filtered = upsample(column_u, 2, KERNEL_TENT);
column_v_filtered = upsample(column_v, 2, KERNEL_TENT);
for (size_t y=0; y < m.num_lines; y++) {
img[x][y][1] = column_u_filtered->at(y+1);
img[x][y][2] = column_v_filtered->at(y+1);
img[x][y][1] = column_u_filtered[y+1];
img[x][y][2] = column_v_filtered[y+1];
}
}
}
@ -157,7 +157,7 @@ void Picture::saveSync () {
pixels = pixbuf_rx->get_pixels();
int rowstride = pixbuf_rx->get_rowstride();
Wave* big_sync = upsample(sync_signal_, 2, KERNEL_TENT);
Wave big_sync = upsample(sync_signal_, 2, KERNEL_TENT);
for (size_t i=1; i<sync_signal_.size(); i++) {
int x = i % line_width;
@ -184,7 +184,7 @@ void Picture::resync () {
int line_width = m.t_period / sync_dt_;
size_t upsample_factor = 2;
Wave* sync_up = upsample(sync_signal_, upsample_factor, KERNEL_TENT);
Wave sync_up = upsample(Wave(sync_signal_), upsample_factor, KERNEL_TENT);
/* slant */
std::vector<double> histogram;

Wyświetl plik

@ -17,13 +17,13 @@ class Picture {
void pushToSyncSignal (double s);
void pushToVideoSignal (double s);
SSTVMode getMode();
double getDrift ();
double getStartsAt ();
double getVideoDt ();
double getSyncDt ();
double getSyncSignalAt(size_t i);
double getVideoSignalAt(size_t i);
SSTVMode getMode() const;
double getDrift () const;
double getStartsAt () const;
double getVideoDt () const;
double getSyncDt () const;
double getSyncSignalAt(size_t i) const;
double getVideoSignalAt(size_t i) const;
Glib::RefPtr<Gdk::Pixbuf> renderPixbuf(unsigned min_width=320);
void resync();