mirror of
https://github.com/Ardour/ardour.git
synced 2026-01-01 03:17:39 +01:00
Add "session rate" as a possible sample rate for export formats
git-svn-id: svn://localhost/ardour2/branches/3.0@8294 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
parent
850b7d24a9
commit
ffadfff650
8 changed files with 55 additions and 5 deletions
|
|
@ -198,4 +198,30 @@ ExportFormatBase::do_set_operation (ExportFormatBase const & other, SetOperation
|
|||
return result;
|
||||
}
|
||||
|
||||
ExportFormatBase::SampleRate
|
||||
ExportFormatBase::nearest_sample_rate (framecnt_t sample_rate)
|
||||
{
|
||||
int diff = 0;
|
||||
int smallest_diff = INT_MAX;
|
||||
SampleRate best_match = SR_None;
|
||||
|
||||
#define DO_SR_COMPARISON(rate) \
|
||||
diff = std::abs((rate) - sample_rate); \
|
||||
if(diff < smallest_diff) { \
|
||||
smallest_diff = diff; \
|
||||
best_match = (rate); \
|
||||
}
|
||||
|
||||
DO_SR_COMPARISON(SR_22_05);
|
||||
DO_SR_COMPARISON(SR_22_05);
|
||||
DO_SR_COMPARISON(SR_44_1);
|
||||
DO_SR_COMPARISON(SR_48);
|
||||
DO_SR_COMPARISON(SR_88_2);
|
||||
DO_SR_COMPARISON(SR_96);
|
||||
DO_SR_COMPARISON(SR_192);
|
||||
|
||||
return best_match;
|
||||
#undef DO_SR_COMPARISON
|
||||
}
|
||||
|
||||
}; // namespace ARDOUR
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue