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_END); |
imageNoSample.set_alignment(Gtk::ALIGN_END); |
117 |
labelNoSample.set_alignment(Gtk::ALIGN_START); |
labelNoSample.set_alignment(Gtk::ALIGN_START); |
1448 |
std::cout << "Starting sample import\n" << std::flush; |
std::cout << "Starting sample import\n" << std::flush; |
1449 |
Glib::ustring error_files; |
Glib::ustring error_files; |
1450 |
printf("Samples to import: %d\n", int(m_SampleImportQueue.size())); |
printf("Samples to import: %d\n", int(m_SampleImportQueue.size())); |
1451 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
for (std::map<gig::Sample*, SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
1452 |
iter != m_SampleImportQueue.end(); ) { |
iter != m_SampleImportQueue.end(); ) { |
1453 |
printf("Importing sample %s\n",(*iter).sample_path.c_str()); |
printf("Importing sample %s\n",iter->second.sample_path.c_str()); |
1454 |
SF_INFO info; |
SF_INFO info; |
1455 |
info.format = 0; |
info.format = 0; |
1456 |
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); |
1457 |
sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); |
sf_command(hFile, SFC_SET_SCALE_FLOAT_INT_READ, 0, SF_TRUE); |
1458 |
try { |
try { |
1459 |
if (!hFile) throw std::string(_("could not open file")); |
if (!hFile) throw std::string(_("could not open file")); |
1476 |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
throw std::string(_("format not supported")); // unsupported subformat (yet?) |
1477 |
} |
} |
1478 |
|
|
1479 |
|
// reset write position for sample |
1480 |
|
iter->first->SetPos(0); |
1481 |
|
|
1482 |
const int bufsize = 10000; |
const int bufsize = 10000; |
1483 |
switch (bitdepth) { |
switch (bitdepth) { |
1484 |
case 16: { |
case 16: { |
1488 |
// libsndfile does the conversion for us (if needed) |
// libsndfile does the conversion for us (if needed) |
1489 |
int n = sf_readf_short(hFile, buffer, bufsize); |
int n = sf_readf_short(hFile, buffer, bufsize); |
1490 |
// write from buffer directly (physically) into .gig file |
// write from buffer directly (physically) into .gig file |
1491 |
iter->gig_sample->Write(buffer, n); |
iter->first->Write(buffer, n); |
1492 |
cnt -= n; |
cnt -= n; |
1493 |
} |
} |
1494 |
delete[] buffer; |
delete[] buffer; |
1508 |
dstbuf[j++] = srcbuf[i] >> 24; |
dstbuf[j++] = srcbuf[i] >> 24; |
1509 |
} |
} |
1510 |
// write from buffer directly (physically) into .gig file |
// write from buffer directly (physically) into .gig file |
1511 |
iter->gig_sample->Write(dstbuf, n); |
iter->first->Write(dstbuf, n); |
1512 |
cnt -= n; |
cnt -= n; |
1513 |
} |
} |
1514 |
delete[] srcbuf; |
delete[] srcbuf; |
1519 |
// cleanup |
// cleanup |
1520 |
sf_close(hFile); |
sf_close(hFile); |
1521 |
// let the sampler re-cache the sample if needed |
// let the sampler re-cache the sample if needed |
1522 |
sample_changed_signal.emit(iter->gig_sample); |
sample_changed_signal.emit(iter->first); |
1523 |
// on success we remove the sample from the import queue, |
// on success we remove the sample from the import queue, |
1524 |
// otherwise keep it, maybe it works the next time ? |
// otherwise keep it, maybe it works the next time ? |
1525 |
std::list<SampleImportItem>::iterator cur = iter; |
std::map<gig::Sample*, SampleImportItem>::iterator cur = iter; |
1526 |
++iter; |
++iter; |
1527 |
m_SampleImportQueue.erase(cur); |
m_SampleImportQueue.erase(cur); |
1528 |
} catch (std::string what) { |
} catch (std::string what) { |
1529 |
// remember the files that made trouble (and their cause) |
// remember the files that made trouble (and their cause) |
1530 |
if (!error_files.empty()) error_files += "\n"; |
if (!error_files.empty()) error_files += "\n"; |
1531 |
error_files += (*iter).sample_path += " (" + what + ")"; |
error_files += iter->second.sample_path += " (" + what + ")"; |
1532 |
++iter; |
++iter; |
1533 |
} |
} |
1534 |
} |
} |
2750 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
2751 |
sched_item.gig_sample = sample; |
sched_item.gig_sample = sample; |
2752 |
sched_item.sample_path = *iter; |
sched_item.sample_path = *iter; |
2753 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue[sample] = sched_item; |
2754 |
// add sample to the tree view |
// add sample to the tree view |
2755 |
if (replace) { |
if (replace) { |
2756 |
row[m_SamplesModel.m_col_name] = gig_to_utf8(sample->pInfo->Name); |
row[m_SamplesModel.m_col_name] = gig_to_utf8(sample->pInfo->Name); |
2860 |
SampleImportItem sched_item; |
SampleImportItem sched_item; |
2861 |
sched_item.gig_sample = sample; |
sched_item.gig_sample = sample; |
2862 |
sched_item.sample_path = filename; |
sched_item.sample_path = filename; |
2863 |
m_SampleImportQueue.push_back(sched_item); |
m_SampleImportQueue[sample] = sched_item; |
2864 |
sf_close(hFile); |
sf_close(hFile); |
2865 |
file_changed(); |
file_changed(); |
2866 |
} |
} |
2912 |
// if sample(s) were just previously added, remove |
// if sample(s) were just previously added, remove |
2913 |
// them from the import queue |
// them from the import queue |
2914 |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
for (std::list<gig::Sample*>::iterator member = members.begin(); |
2915 |
member != members.end(); ++member) { |
member != members.end(); ++member) |
2916 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
{ |
2917 |
iter != m_SampleImportQueue.end(); ++iter) { |
if (m_SampleImportQueue.count(*member)) { |
2918 |
if ((*iter).gig_sample == *member) { |
printf("Removing previously added sample '%s' from group '%s'\n", |
2919 |
printf("Removing previously added sample '%s' from group '%s'\n", |
m_SampleImportQueue[sample].sample_path.c_str(), name.c_str()); |
2920 |
(*iter).sample_path.c_str(), name.c_str()); |
m_SampleImportQueue.erase(*member); |
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
2921 |
} |
} |
2922 |
} |
} |
2923 |
file_changed(); |
file_changed(); |
2932 |
samples_removed_signal.emit(); |
samples_removed_signal.emit(); |
2933 |
// if sample was just previously added, remove it from |
// if sample was just previously added, remove it from |
2934 |
// the import queue |
// the import queue |
2935 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
if (m_SampleImportQueue.count(sample)) { |
2936 |
iter != m_SampleImportQueue.end(); ++iter) { |
printf("Removing previously added sample '%s'\n", |
2937 |
if ((*iter).gig_sample == sample) { |
m_SampleImportQueue[sample].sample_path.c_str()); |
2938 |
printf("Removing previously added sample '%s'\n", |
m_SampleImportQueue.erase(sample); |
|
(*iter).sample_path.c_str()); |
|
|
m_SampleImportQueue.erase(iter); |
|
|
break; |
|
|
} |
|
2939 |
} |
} |
2940 |
dimreg_changed(); |
dimreg_changed(); |
2941 |
file_changed(); |
file_changed(); |
2991 |
gig::Sample* sample = *itSample; |
gig::Sample* sample = *itSample; |
2992 |
// remove sample from the .gig file |
// remove sample from the .gig file |
2993 |
file->DeleteSample(sample); |
file->DeleteSample(sample); |
2994 |
// if sample was just previously added, remove it fro the import queue |
// if sample was just previously added, remove it from the import queue |
2995 |
for (std::list<SampleImportItem>::iterator iter = m_SampleImportQueue.begin(); |
if (m_SampleImportQueue.count(sample)) { |
2996 |
iter != m_SampleImportQueue.end(); ++iter) |
printf("Removing previously added sample '%s'\n", |
2997 |
{ |
m_SampleImportQueue[sample].sample_path.c_str()); |
2998 |
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; |
|
|
} |
|
2999 |
} |
} |
3000 |
} |
} |
3001 |
} catch (RIFF::Exception e) { |
} catch (RIFF::Exception e) { |