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)) : |
230 |
eMSDecode(_("Decode Mid/Side Recordings")), |
eMSDecode(_("Decode Mid/Side Recordings")), |
231 |
eSampleStartOffset(_("Sample start offset"), 0, 2000), |
eSampleStartOffset(_("Sample start offset"), 0, 2000), |
232 |
eUnityNote(_("Unity note")), |
eUnityNote(_("Unity note")), |
233 |
|
eSampleGroup(_("Sample Group")), |
234 |
eSampleFormatInfo(_("Sample Format")), |
eSampleFormatInfo(_("Sample Format")), |
235 |
eSampleID("Sample ID"), |
eSampleID("Sample ID"), |
236 |
|
eChecksum("Wave Data CRC-32"), |
237 |
eFineTune(_("Fine tune"), -49, 50), |
eFineTune(_("Fine tune"), -49, 50), |
238 |
eGain(_("Gain"), -96, 0, 2, -655360), |
eGain(_("Gain"), -96, 0, 2, -655360), |
239 |
eGainPlus6(_("Gain +6dB"), eGain, 6 * -655360), |
eGainPlus6(_("Gain +6dB"), eGain, 6 * -655360), |
469 |
wSample->set_tooltip_text(_("Drag & drop a sample here")); |
wSample->set_tooltip_text(_("Drag & drop a sample here")); |
470 |
#endif |
#endif |
471 |
addProp(eUnityNote); |
addProp(eUnityNote); |
472 |
|
addProp(eSampleGroup); |
473 |
addProp(eSampleFormatInfo); |
addProp(eSampleFormatInfo); |
474 |
addProp(eSampleID); |
addProp(eSampleID); |
475 |
|
addProp(eChecksum); |
476 |
addRightHandSide(buttonSelectSample); |
addRightHandSide(buttonSelectSample); |
477 |
addHeader(_("Optional Settings")); |
addHeader(_("Optional Settings")); |
478 |
addProp(eSampleStartOffset); |
addProp(eSampleStartOffset); |
1025 |
eMSDecode.set_value(d->MSDecode); |
eMSDecode.set_value(d->MSDecode); |
1026 |
eSampleStartOffset.set_value(d->SampleStartOffset); |
eSampleStartOffset.set_value(d->SampleStartOffset); |
1027 |
eUnityNote.set_value(d->UnityNote); |
eUnityNote.set_value(d->UnityNote); |
1028 |
|
// show sample group name |
1029 |
|
{ |
1030 |
|
Glib::ustring s = "---"; |
1031 |
|
if (d->pSample && d->pSample->GetGroup()) |
1032 |
|
s = d->pSample->GetGroup()->Name; |
1033 |
|
eSampleGroup.text.set_text(s); |
1034 |
|
} |
1035 |
// assemble sample format info string |
// assemble sample format info string |
1036 |
{ |
{ |
1037 |
Glib::ustring s; |
Glib::ustring s; |
1063 |
} |
} |
1064 |
eSampleID.text.set_text(s); |
eSampleID.text.set_text(s); |
1065 |
} |
} |
1066 |
|
// generate raw wave form data CRC-32 checksum string |
1067 |
|
{ |
1068 |
|
Glib::ustring s = "---"; |
1069 |
|
if (d->pSample) { |
1070 |
|
char buf[64] = {}; |
1071 |
|
snprintf(buf, sizeof(buf), "%x", d->pSample->GetWaveDataCRC32Checksum()); |
1072 |
|
s = buf; |
1073 |
|
} |
1074 |
|
eChecksum.text.set_text(s); |
1075 |
|
} |
1076 |
buttonSelectSample.set_sensitive(d && d->pSample); |
buttonSelectSample.set_sensitive(d && d->pSample); |
1077 |
eFineTune.set_value(d->FineTune); |
eFineTune.set_value(d->FineTune); |
1078 |
eGain.set_value(d->Gain); |
eGain.set_value(d->Gain); |
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() { |