X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fst_stretch.cc;h=70d7ca1fc799f67b14af7afaefe73b61597a65f6;hb=dec10f2f3c6fffe27e72243d9bf36713d8f084f9;hp=369ed95279a5f9aa94aaf30adf05fe1e0beeee18;hpb=bb9cc45cd22af67ac275a5e73accbe14fee664d8;p=ardour.git diff --git a/libs/ardour/st_stretch.cc b/libs/ardour/st_stretch.cc index 369ed95279..70d7ca1fc7 100644 --- a/libs/ardour/st_stretch.cc +++ b/libs/ardour/st_stretch.cc @@ -28,7 +28,7 @@ #include "ardour/session.h" #include "ardour/audioregion.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace ARDOUR; @@ -47,7 +47,7 @@ STStretch::STStretch (Session& s, TimeFXRequest& req) percentage = -tsr.time_fraction; - st.setSampleRate (s.frame_rate()); + st.setSampleRate (s.sample_rate()); st.setChannels (1); st.setTempoChange (percentage); st.setPitchSemiTones (0); @@ -56,7 +56,6 @@ STStretch::STStretch (Session& s, TimeFXRequest& req) st.setSetting(SETTING_USE_QUICKSEEK, tsr.quick_seek); st.setSetting(SETTING_USE_AA_FILTER, tsr.antialias); - tsr.progress = 0.0f; } STStretch::~STStretch () @@ -64,25 +63,25 @@ STStretch::~STStretch () } int -STStretch::run (boost::shared_ptr a_region) +STStretch::run (boost::shared_ptr a_region, Progress* progress) { SourceList nsrcs; - nframes_t total_frames; - nframes_t done; + samplecnt_t total_samples; + samplecnt_t done; int ret = -1; - const nframes_t bufsize = 16384; + const samplecnt_t bufsize = 16384; gain_t *gain_buffer = 0; Sample *buffer = 0; char suffix[32]; string new_name; string::size_type at; - tsr.progress = 0.0f; + progress->set_progress (0); tsr.done = false; boost::shared_ptr region = boost::dynamic_pointer_cast(a_region); - total_frames = region->length() * region->n_channels(); + total_samples = region->length() * region->n_channels(); done = 0; /* the name doesn't need to be super-precise, but allow for 2 fractional @@ -108,13 +107,13 @@ STStretch::run (boost::shared_ptr a_region) boost::shared_ptr asrc = boost::dynamic_pointer_cast(nsrcs[i]); - nframes_t pos = 0; - nframes_t this_read = 0; + samplepos_t pos = 0; + samplecnt_t this_read = 0; st.clear(); while (!tsr.cancel && pos < region->length()) { - nframes_t this_time; + samplecnt_t this_time; this_time = min (bufsize, region->length() - pos); @@ -131,7 +130,7 @@ STStretch::run (boost::shared_ptr a_region) pos += this_read; done += this_read; - tsr.progress = (float) done / total_frames; + progress->set_progress ((float) done / total_samples); st.putSamples (buffer, this_read); @@ -177,18 +176,18 @@ STStretch::run (boost::shared_ptr a_region) /* now reset ancestral data for each new region */ for (vector >::iterator x = results.begin(); x != results.end(); ++x) { - nframes64_t astart = (*x)->ancestral_start(); - nframes64_t alength = (*x)->ancestral_length(); - nframes_t start; - nframes_t length; + samplepos_t astart = (*x)->ancestral_start(); + samplepos_t alength = (*x)->ancestral_length(); + samplepos_t start; + samplecnt_t length; // note: tsr.fraction is a percentage of original length. 100 = no change, // 50 is half as long, 200 is twice as long, etc. float stretch = (*x)->stretch() * (tsr.time_fraction/100.0); - start = (nframes_t) floor (astart + ((astart - (*x)->start()) / stretch)); - length = (nframes_t) floor (alength / stretch); + start = (samplepos_t) floor (astart + ((astart - (*x)->start()) / stretch)); + length = (samplecnt_t) floor (alength / stretch); (*x)->set_ancestral_data (start, length, stretch, (*x)->shift()); } @@ -204,7 +203,5 @@ STStretch::run (boost::shared_ptr a_region) } } - tsr.done = true; - return ret; }