1 |
/* |
/* |
2 |
* Copyright (C) 2006-2016 Andreas Persson |
* Copyright (C) 2006-2017 Andreas Persson |
3 |
* |
* |
4 |
* This program is free software; you can redistribute it and/or |
* This program is free software; you can redistribute it and/or |
5 |
* modify it under the terms of the GNU General Public License as |
* modify it under the terms of the GNU General Public License as |
17 |
* 02110-1301 USA. |
* 02110-1301 USA. |
18 |
*/ |
*/ |
19 |
|
|
20 |
|
#include "global.h" |
21 |
#include "dimregionedit.h" |
#include "dimregionedit.h" |
22 |
|
|
|
#include "global.h" |
|
23 |
#include "compat.h" |
#include "compat.h" |
24 |
|
|
25 |
VelocityCurve::VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t)) : |
VelocityCurve::VelocityCurve(double (gig::DimensionRegion::*getter)(uint8_t)) : |
1315 |
|
|
1316 |
bool DimRegionEdit::set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop) |
bool DimRegionEdit::set_sample(gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop) |
1317 |
{ |
{ |
1318 |
|
bool result = false; |
1319 |
for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimregs.begin(); |
for (std::set<gig::DimensionRegion*>::iterator itDimReg = dimregs.begin(); |
1320 |
itDimReg != dimregs.end(); ++itDimReg) |
itDimReg != dimregs.end(); ++itDimReg) |
1321 |
{ |
{ |
1322 |
set_sample(*itDimReg, sample, copy_sample_unity, copy_sample_tune, copy_sample_loop); |
result |= set_sample(*itDimReg, sample, copy_sample_unity, copy_sample_tune, copy_sample_loop); |
1323 |
} |
} |
1324 |
|
return result; |
1325 |
} |
} |
1326 |
|
|
1327 |
bool DimRegionEdit::set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop) |
bool DimRegionEdit::set_sample(gig::DimensionRegion* dimreg, gig::Sample* sample, bool copy_sample_unity, bool copy_sample_tune, bool copy_sample_loop) |
1330 |
//TODO: we should better move the code from MainWindow::on_sample_label_drop_drag_data_received() here |
//TODO: we should better move the code from MainWindow::on_sample_label_drop_drag_data_received() here |
1331 |
|
|
1332 |
// currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received() |
// currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received() |
1333 |
//dimreg_to_be_changed_signal.emit(dimregion); |
//DimRegionChangeGuard(this, dimregion); |
1334 |
|
|
1335 |
// make sure stereo samples always are the same in both |
// make sure stereo samples always are the same in both |
1336 |
// dimregs in the samplechannel dimension |
// dimregs in the samplechannel dimension |
1400 |
update_model--; |
update_model--; |
1401 |
|
|
1402 |
sample_ref_changed_signal.emit(oldref, sample); |
sample_ref_changed_signal.emit(oldref, sample); |
|
// currently commented because we're sending a similar signal in MainWindow::on_sample_label_drop_drag_data_received() |
|
|
//dimreg_changed_signal.emit(dimreg); |
|
1403 |
return true; |
return true; |
1404 |
} |
} |
1405 |
return false; |
return false; |
1468 |
if (value) { |
if (value) { |
1469 |
// create a new sample loop in case there is none yet |
// create a new sample loop in case there is none yet |
1470 |
if (!d->SampleLoops) { |
if (!d->SampleLoops) { |
1471 |
|
DimRegionChangeGuard(this, d); |
1472 |
|
|
1473 |
DLS::sample_loop_t loop; |
DLS::sample_loop_t loop; |
1474 |
loop.LoopType = gig::loop_type_normal; |
loop.LoopType = gig::loop_type_normal; |
1475 |
// loop the whole sample by default |
// loop the whole sample by default |
1476 |
loop.LoopStart = 0; |
loop.LoopStart = 0; |
1477 |
loop.LoopLength = |
loop.LoopLength = |
1478 |
(d->pSample) ? d->pSample->SamplesTotal : 0; |
(d->pSample) ? d->pSample->SamplesTotal : 0; |
|
dimreg_to_be_changed_signal.emit(d); |
|
1479 |
d->AddSampleLoop(&loop); |
d->AddSampleLoop(&loop); |
|
dimreg_changed_signal.emit(d); |
|
1480 |
} |
} |
1481 |
} else { |
} else { |
1482 |
if (d->SampleLoops) { |
if (d->SampleLoops) { |
1483 |
dimreg_to_be_changed_signal.emit(d); |
DimRegionChangeGuard(this, d); |
1484 |
|
|
1485 |
// delete ALL existing sample loops |
// delete ALL existing sample loops |
1486 |
while (d->SampleLoops) { |
while (d->SampleLoops) { |
1487 |
d->DeleteSampleLoop(&d->pSampleLoops[0]); |
d->DeleteSampleLoop(&d->pSampleLoops[0]); |
1488 |
} |
} |
|
dimreg_changed_signal.emit(d); |
|
1489 |
} |
} |
1490 |
} |
} |
1491 |
} |
} |
1535 |
gig::Sample* oldref = dimregion->pSample; |
gig::Sample* oldref = dimregion->pSample; |
1536 |
if (!oldref) return; |
if (!oldref) return; |
1537 |
|
|
1538 |
dimreg_to_be_changed_signal.emit(dimregion); |
DimRegionChangeGuard(this, dimregion); |
1539 |
|
|
1540 |
// in case currently assigned sample is a stereo one, then remove both |
// in case currently assigned sample is a stereo one, then remove both |
1541 |
// references (expected to be due to a "stereo dimension") |
// references (expected to be due to a "stereo dimension") |
1573 |
set_dim_region(dimregion); |
set_dim_region(dimregion); |
1574 |
|
|
1575 |
sample_ref_changed_signal.emit(oldref, NULL); |
sample_ref_changed_signal.emit(oldref, NULL); |
|
dimreg_changed_signal.emit(dimregion); |
|
1576 |
} |
} |
1577 |
|
|
1578 |
void DimRegionEdit::onButtonSelectSamplePressed() { |
void DimRegionEdit::onButtonSelectSamplePressed() { |