65 |
dimreg_all_regions(_("all regions")), |
dimreg_all_regions(_("all regions")), |
66 |
dimreg_all_dimregs(_("all dimension splits")), |
dimreg_all_dimregs(_("all dimension splits")), |
67 |
dimreg_stereo(_("both channels")), |
dimreg_stereo(_("both channels")), |
68 |
|
labelLegend(_("Legend:")), |
69 |
labelNoSample(_(" No Sample")), |
labelNoSample(_(" No Sample")), |
70 |
labelMissingSample(_(" Missing some Sample(s)")), |
labelMissingSample(_(" Missing some Sample(s)")), |
71 |
labelLooped(_(" Looped")), |
labelLooped(_(" Looped")), |
110 |
dimreg_vbox.add(dimreg_edit); |
dimreg_vbox.add(dimreg_edit); |
111 |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
dimreg_vbox.pack_start(dimreg_hbox, Gtk::PACK_SHRINK); |
112 |
{ |
{ |
113 |
|
legend_hbox.add(labelLegend); |
114 |
|
|
115 |
imageNoSample.set(redDot); |
imageNoSample.set(redDot); |
116 |
imageNoSample.set_alignment(Gtk::ALIGN_RIGHT); |
imageNoSample.set_alignment(Gtk::ALIGN_END); |
117 |
labelNoSample.set_alignment(Gtk::ALIGN_LEFT); |
labelNoSample.set_alignment(Gtk::ALIGN_START); |
118 |
legend_hbox.add(imageNoSample); |
legend_hbox.add(imageNoSample); |
119 |
legend_hbox.add(labelNoSample); |
legend_hbox.add(labelNoSample); |
120 |
|
|
121 |
imageMissingSample.set(yellowDot); |
imageMissingSample.set(yellowDot); |
122 |
imageMissingSample.set_alignment(Gtk::ALIGN_RIGHT); |
imageMissingSample.set_alignment(Gtk::ALIGN_END); |
123 |
labelMissingSample.set_alignment(Gtk::ALIGN_LEFT); |
labelMissingSample.set_alignment(Gtk::ALIGN_START); |
124 |
legend_hbox.add(imageMissingSample); |
legend_hbox.add(imageMissingSample); |
125 |
legend_hbox.add(labelMissingSample); |
legend_hbox.add(labelMissingSample); |
126 |
|
|
127 |
imageLooped.set(blackLoop); |
imageLooped.set(blackLoop); |
128 |
imageLooped.set_alignment(Gtk::ALIGN_RIGHT); |
imageLooped.set_alignment(Gtk::ALIGN_END); |
129 |
labelLooped.set_alignment(Gtk::ALIGN_LEFT); |
labelLooped.set_alignment(Gtk::ALIGN_START); |
130 |
legend_hbox.add(imageLooped); |
legend_hbox.add(imageLooped); |
131 |
legend_hbox.add(labelLooped); |
legend_hbox.add(labelLooped); |
132 |
|
|
133 |
imageSomeLoops.set(grayLoop); |
imageSomeLoops.set(grayLoop); |
134 |
imageSomeLoops.set_alignment(Gtk::ALIGN_RIGHT); |
imageSomeLoops.set_alignment(Gtk::ALIGN_END); |
135 |
labelSomeLoops.set_alignment(Gtk::ALIGN_LEFT); |
labelSomeLoops.set_alignment(Gtk::ALIGN_START); |
136 |
legend_hbox.add(imageSomeLoops); |
legend_hbox.add(imageSomeLoops); |
137 |
legend_hbox.add(labelSomeLoops); |
legend_hbox.add(labelSomeLoops); |
138 |
|
|
205 |
|
|
206 |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
actionGroup->add(Gtk::Action::create("MenuEdit", _("_Edit"))); |
207 |
|
|
208 |
|
const Gdk::ModifierType primaryModifierKey = |
209 |
|
#if defined(__APPLE__) |
210 |
|
Gdk::META_MASK; // Cmd key on Mac |
211 |
|
#else |
212 |
|
Gdk::CONTROL_MASK; // Ctrl key on all other OSs |
213 |
|
#endif |
214 |
|
|
215 |
|
actionGroup->add(Gtk::Action::create("SelectPrevRegion", |
216 |
|
_("Select Previous Region")), |
217 |
|
Gtk::AccelKey(GDK_KEY_Left, primaryModifierKey), |
218 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_region)); |
219 |
|
|
220 |
|
actionGroup->add(Gtk::Action::create("SelectNextRegion", |
221 |
|
_("Select Next Region")), |
222 |
|
Gtk::AccelKey(GDK_KEY_Right, primaryModifierKey), |
223 |
|
sigc::mem_fun(*this, &MainWindow::select_next_region)); |
224 |
|
|
225 |
|
actionGroup->add(Gtk::Action::create("SelectPrevDimRgnZone", |
226 |
|
_("Select Previous Dimension Region Zone")), |
227 |
|
Gtk::AccelKey(GDK_KEY_Left, Gdk::MOD1_MASK), |
228 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_dim_rgn_zone)); |
229 |
|
|
230 |
|
actionGroup->add(Gtk::Action::create("SelectNextDimRgnZone", |
231 |
|
_("Select Next Dimension Region Zone")), |
232 |
|
Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK), |
233 |
|
sigc::mem_fun(*this, &MainWindow::select_next_dim_rgn_zone)); |
234 |
|
|
235 |
|
actionGroup->add(Gtk::Action::create("SelectPrevDimension", |
236 |
|
_("Select Previous Dimension")), |
237 |
|
Gtk::AccelKey(GDK_KEY_Up, Gdk::MOD1_MASK), |
238 |
|
sigc::mem_fun(*this, &MainWindow::select_prev_dimension)); |
239 |
|
|
240 |
|
actionGroup->add(Gtk::Action::create("SelectNextDimension", |
241 |
|
_("Select Next Dimension")), |
242 |
|
Gtk::AccelKey(GDK_KEY_Down, Gdk::MOD1_MASK), |
243 |
|
sigc::mem_fun(*this, &MainWindow::select_next_dimension)); |
244 |
|
|
245 |
|
actionGroup->add(Gtk::Action::create("SelectAddPrevDimRgnZone", |
246 |
|
_("Add Previous Dimension Region Zone to Selection")), |
247 |
|
Gtk::AccelKey(GDK_KEY_Left, Gdk::MOD1_MASK | Gdk::SHIFT_MASK), |
248 |
|
sigc::mem_fun(*this, &MainWindow::select_add_prev_dim_rgn_zone)); |
249 |
|
|
250 |
|
actionGroup->add(Gtk::Action::create("SelectAddNextDimRgnZone", |
251 |
|
_("Add Next Dimension Region Zone to Selection")), |
252 |
|
Gtk::AccelKey(GDK_KEY_Right, Gdk::MOD1_MASK | Gdk::SHIFT_MASK), |
253 |
|
sigc::mem_fun(*this, &MainWindow::select_add_next_dim_rgn_zone)); |
254 |
|
|
255 |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
Glib::RefPtr<Gtk::ToggleAction> toggle_action = |
256 |
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note")); |
Gtk::ToggleAction::create("CopySampleUnity", _("Copy Sample's _Unity Note")); |
257 |
toggle_action->set_active(true); |
toggle_action->set_active(true); |
426 |
" <menuitem action='Quit'/>" |
" <menuitem action='Quit'/>" |
427 |
" </menu>" |
" </menu>" |
428 |
" <menu action='MenuEdit'>" |
" <menu action='MenuEdit'>" |
429 |
|
" <menuitem action='SelectPrevRegion'/>" |
430 |
|
" <menuitem action='SelectNextRegion'/>" |
431 |
|
" <separator/>" |
432 |
|
" <menuitem action='SelectPrevDimension'/>" |
433 |
|
" <menuitem action='SelectNextDimension'/>" |
434 |
|
" <menuitem action='SelectPrevDimRgnZone'/>" |
435 |
|
" <menuitem action='SelectNextDimRgnZone'/>" |
436 |
|
" <menuitem action='SelectAddPrevDimRgnZone'/>" |
437 |
|
" <menuitem action='SelectAddNextDimRgnZone'/>" |
438 |
|
" <separator/>" |
439 |
" <menuitem action='CopySampleUnity'/>" |
" <menuitem action='CopySampleUnity'/>" |
440 |
" <menuitem action='CopySampleTune'/>" |
" <menuitem action='CopySampleTune'/>" |
441 |
" <menuitem action='CopySampleLoop'/>" |
" <menuitem action='CopySampleLoop'/>" |
1505 |
std::cout << "Starting sample import\n" << std::flush; |
std::cout << "Starting sample import\n" << std::flush; |
1506 |
Glib::ustring error_files; |
Glib::ustring error_files; |
1507 |
printf("Samples to import: %d\n", int(m_SampleImportQueue.size())); |
printf("Samples to import: %d\n", int(m_SampleImportQueue.size())); |
1508 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
for (std::map<gig::Sample*, SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
1509 |
iter != m_SampleImportQueue.end(); ) { |
iter != m_SampleImportQueue.end(); ) { |
1510 |
printf("Importing sample %s\n",(*iter).sample_path.c_str()); |
printf("Importing sample %s\n",iter->second.sample_path.c_str()); |
1511 |
SF_INFO info; |
SF_INFO info; |
1512 |
info.format = 0; |
info.format = 0; |
1513 |
SNDFILE* hFile = sf_open((*iter).sample_path.c_str(), SFM_READ, &info); |
SNDFILE* hFile = sf_open(iter->second.sample_path.c_str(), SFM_READ, &info); |
1514 |
sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); |
sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); |
1515 |
try { |
try { |
1516 |
if (!hFile) throw std::string(_("could not open file")); |
if (!hFile) throw std::string(_("could not open file")); |
1533 |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
1534 |
} |
} |
1535 |
|
|
1536 |
|
// reset write position for sample |
1537 |
|
iter->first->SetPos(0); |
1538 |
|
|
1539 |
const int bufsize = 10000; |
const int bufsize = 10000; |
1540 |
switch (bitdepth) { |
switch (bitdepth) { |
1541 |
case 16: { |
case 16: { |
1545 |
// libsndfile does the conversion for us (if needed) |
// libsndfile does the conversion for us (if needed) |
1546 |
int n = sf_readf_short(hFile, buffer, bufsize); |
int n = sf_readf_short(hFile, buffer, bufsize); |
1547 |
// write from buffer directly (physically) into .gig file |
// write from buffer directly (physically) into .gig file |
1548 |
iter->gig_sample->Write(buffer, n); |
iter->first->Write(buffer, n); |
1549 |
cnt -= n; |
cnt -= n; |
1550 |
} |
} |
1551 |
delete[] buffer; |
delete[] buffer; |
1565 |
dstbuf[j++] = srcbuf[i] >> 24; |
dstbuf[j++] = srcbuf[i] >> 24; |
1566 |
} |
} |
1567 |
// write from buffer directly (physically) into .gig file |
// write from buffer directly (physically) into .gig file |
1568 |
iter->gig_sample->Write(dstbuf, n); |
iter->first->Write(dstbuf, n); |
1569 |
cnt -= n; |
cnt -= n; |
1570 |
} |
} |
1571 |
delete[] srcbuf; |
delete[] srcbuf; |
1576 |
// cleanup |
// cleanup |
1577 |
sf_close(hFile); |
sf_close(hFile); |
1578 |
// let the sampler re-cache the sample if needed |
// let the sampler re-cache the sample if needed |
1579 |
sample_changed_signal.emit(iter->gig_sample); |
sample_changed_signal.emit(iter->first); |
1580 |
// on success we remove the sample from the import queue, |
// on success we remove the sample from the import queue, |
1581 |
// otherwise keep it, maybe it works the next time ? |
// otherwise keep it, maybe it works the next time ? |
1582 |
std::list<SampleImportItem>::iterator cur = iter; |
std::map<gig::Sample*, SampleImportItem>::iterator cur = iter; |
1583 |
++iter; |
++iter; |
1584 |
m_SampleImportQueue.erase(cur); |
m_SampleImportQueue.erase(cur); |
1585 |
} catch (std::string what) { |
} catch (std::string what) { |
1586 |
// remember the files that made trouble (and their cause) |
// remember the files that made trouble (and their cause) |
1587 |
if (!error_files.empty()) error_files += "\n"; |
if (!error_files.empty()) error_files += "\n"; |
1588 |
error_files += (*iter).sample_path += " (" + what + ")"; |
error_files += iter->second.sample_path += " (" + what + ")"; |
1589 |
++iter; |
++iter; |
1590 |
} |
} |
1591 |
} |
} |
2807 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
2808 |
sched_item.gig_sample = sample; |
sched_item.gig_sample = sample; |
2809 |
sched_item.sample_path = *iter; |
sched_item.sample_path = *iter; |
2810 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue[sample] = sched_item; |
2811 |
// add sample to the tree view |
// add sample to the tree view |
2812 |
if (replace) { |
if (replace) { |
2813 |
row[m_SamplesModel.m_col_name] = gig_to_utf8(sample->pInfo->Name); |
row[m_SamplesModel.m_col_name] = gig_to_utf8(sample->pInfo->Name); |
2917 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
2918 |
sched_item.gig_sample = sample; |
sched_item.gig_sample = sample; |
2919 |
sched_item.sample_path = filename; |
sched_item.sample_path = filename; |
2920 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue[sample] = sched_item; |
2921 |
sf_close(hFile); |
sf_close(hFile); |
2922 |
file_changed(); |
file_changed(); |
2923 |
} |
} |
2969 |
// if sample(s) were just previously added, remove |
// if sample(s) were just previously added, remove |
2970 |
// them from the import queue |
// them from the import queue |
2971 |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
2972 |
member != members.end(); ++member) { |
member != members.end(); ++member) |
2973 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
{ |
2974 |
iter != m_SampleImportQueue.end(); ++iter) { |
if (m_SampleImportQueue.count(*member)) { |
2975 |
if ((*iter).gig_sample == *member) { |
printf("Removing previously added sample '%s' from group '%s'\n", |
2976 |
printf("Removing previously added sample '%s' from group '%s'\n", |
m_SampleImportQueue[sample].sample_path.c_str(), name.c_str()); |
2977 |
(*iter).sample_path.c_str(), name.c_str()); |
m_SampleImportQueue.erase(*member); |
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
2978 |
} |
} |
2979 |
} |
} |
2980 |
file_changed(); |
file_changed(); |
2989 |
samples_removed_signal.emit(); |
samples_removed_signal.emit(); |
2990 |
// if sample was just previously added, remove it from |
// if sample was just previously added, remove it from |
2991 |
// the import queue |
// the import queue |
2992 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
if (m_SampleImportQueue.count(sample)) { |
2993 |
iter != m_SampleImportQueue.end(); ++iter) { |
printf("Removing previously added sample '%s'\n", |
2994 |
if ((*iter).gig_sample == sample) { |
m_SampleImportQueue[sample].sample_path.c_str()); |
2995 |
printf("Removing previously added sample '%s'\n", |
m_SampleImportQueue.erase(sample); |
|
(*iter).sample_path.c_str()); |
|
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
2996 |
} |
} |
2997 |
dimreg_changed(); |
dimreg_changed(); |
2998 |
file_changed(); |
file_changed(); |
3048 |
gig::Sample* sample = *itSample; |
gig::Sample* sample = *itSample; |
3049 |
// remove sample from the .gig file |
// remove sample from the .gig file |
3050 |
file->DeleteSample(sample); |
file->DeleteSample(sample); |
3051 |
// if sample was just previously added, remove it fro the import queue |
// if sample was just previously added, remove it from the import queue |
3052 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
if (m_SampleImportQueue.count(sample)) { |
3053 |
iter != m_SampleImportQueue.end(); ++iter) |
printf("Removing previously added sample '%s'\n", |
3054 |
{ |
m_SampleImportQueue[sample].sample_path.c_str()); |
3055 |
if ((*iter).gig_sample == sample) { |
m_SampleImportQueue.erase(sample); |
|
printf("Removing previously added sample '%s'\n", |
|
|
(*iter).sample_path.c_str()); |
|
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
3056 |
} |
} |
3057 |
} |
} |
3058 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |
3628 |
m_TreeViewNotebook.set_current_page(2); |
m_TreeViewNotebook.set_current_page(2); |
3629 |
} |
} |
3630 |
|
|
3631 |
|
void MainWindow::select_prev_region() { |
3632 |
|
m_RegionChooser.select_prev_region(); |
3633 |
|
} |
3634 |
|
|
3635 |
|
void MainWindow::select_next_region() { |
3636 |
|
m_RegionChooser.select_next_region(); |
3637 |
|
} |
3638 |
|
|
3639 |
|
void MainWindow::select_next_dim_rgn_zone() { |
3640 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3641 |
|
m_DimRegionChooser.select_next_dimzone(); |
3642 |
|
} |
3643 |
|
|
3644 |
|
void MainWindow::select_prev_dim_rgn_zone() { |
3645 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3646 |
|
m_DimRegionChooser.select_prev_dimzone(); |
3647 |
|
} |
3648 |
|
|
3649 |
|
void MainWindow::select_add_next_dim_rgn_zone() { |
3650 |
|
m_DimRegionChooser.select_next_dimzone(true); |
3651 |
|
} |
3652 |
|
|
3653 |
|
void MainWindow::select_add_prev_dim_rgn_zone() { |
3654 |
|
m_DimRegionChooser.select_prev_dimzone(true); |
3655 |
|
} |
3656 |
|
|
3657 |
|
void MainWindow::select_prev_dimension() { |
3658 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3659 |
|
m_DimRegionChooser.select_prev_dimension(); |
3660 |
|
} |
3661 |
|
|
3662 |
|
void MainWindow::select_next_dimension() { |
3663 |
|
if (m_DimRegionChooser.has_focus()) return; // avoid conflict with key stroke handler of DimenionRegionChooser |
3664 |
|
m_DimRegionChooser.select_next_dimension(); |
3665 |
|
} |
3666 |
|
|
3667 |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
sigc::signal<void, gig::File*>& MainWindow::signal_file_structure_to_be_changed() { |
3668 |
return file_structure_to_be_changed_signal; |
return file_structure_to_be_changed_signal; |
3669 |
} |
} |