1484 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
1485 |
instrumentProps.signal_changed().connect( |
instrumentProps.signal_changed().connect( |
1486 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
1487 |
|
sampleProps.signal_changed().connect( |
1488 |
|
sigc::mem_fun(*this, &MainWindow::file_changed)); |
1489 |
fileProps.signal_changed().connect( |
fileProps.signal_changed().connect( |
1490 |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
sigc::mem_fun(*this, &MainWindow::file_changed)); |
1491 |
midiRules.signal_changed().connect( |
midiRules.signal_changed().connect( |
3066 |
} |
} |
3067 |
|
|
3068 |
|
|
3069 |
|
SampleProps::SampleProps() : |
3070 |
|
#if HAS_GTKMM_STOCK |
3071 |
|
quitButton(Gtk::Stock::CLOSE), |
3072 |
|
#else |
3073 |
|
quitButton(_("_Close")), |
3074 |
|
#endif |
3075 |
|
table(2,1), |
3076 |
|
eName(_("Name")), |
3077 |
|
eUnityNote(_("Unity Note")), |
3078 |
|
eSampleGroup(_("Sample Group")), |
3079 |
|
eSampleFormatInfo(_("Sample Format")), |
3080 |
|
eSampleID("Sample ID"), |
3081 |
|
eChecksum("Wave Data CRC-32"), |
3082 |
|
eLoopsCount(_("Loops"), 0, 1), // we might support more than 1 loop in future |
3083 |
|
eLoopStart(_("Loop start position"), 0, 9999999), |
3084 |
|
eLoopLength(_("Loop size"), 0, 9999999), |
3085 |
|
eLoopType(_("Loop type")), |
3086 |
|
eLoopPlayCount(_("Playback count")), |
3087 |
|
table2(2,1), |
3088 |
|
eName2(_("Name")), |
3089 |
|
eCreationDate(_("Creation date")), |
3090 |
|
eComments(_("Comments")), |
3091 |
|
eProduct(_("Product")), |
3092 |
|
eCopyright(_("Copyright")), |
3093 |
|
eArtists(_("Artists")), |
3094 |
|
eGenre(_("Genre")), |
3095 |
|
eKeywords(_("Keywords")), |
3096 |
|
eEngineer(_("Engineer")), |
3097 |
|
eTechnician(_("Technician")), |
3098 |
|
eSoftware(_("Software")), |
3099 |
|
eMedium(_("Medium")), |
3100 |
|
eSource(_("Source")), |
3101 |
|
eSourceForm(_("Source form")), |
3102 |
|
eCommissioned(_("Commissioned")), |
3103 |
|
eSubject(_("Subject")) |
3104 |
|
{ |
3105 |
|
if (!Settings::singleton()->autoRestoreWindowDimension) { |
3106 |
|
//set_default_size(470, 390); |
3107 |
|
set_position(Gtk::WIN_POS_MOUSE); |
3108 |
|
} |
3109 |
|
|
3110 |
|
set_title(_("Sample Properties")); |
3111 |
|
|
3112 |
|
tabs.append_page(vbox[1], _("Settings")); |
3113 |
|
tabs.append_page(vbox[2], _("Info")); |
3114 |
|
|
3115 |
|
connect(eName, &SampleProps::set_Name); |
3116 |
|
connect(eUnityNote, &gig::Sample::MIDIUnityNote); |
3117 |
|
connect(eLoopsCount, &gig::Sample::Loops); |
3118 |
|
connectLambda(eLoopStart, [this](uint32_t start){ |
3119 |
|
m->LoopStart = start; |
3120 |
|
m->LoopEnd = start + m->LoopSize; |
3121 |
|
}); |
3122 |
|
connectLambda(eLoopLength, [this](uint32_t length){ |
3123 |
|
m->LoopSize = length; |
3124 |
|
m->LoopEnd = m->LoopStart + length; |
3125 |
|
}); |
3126 |
|
{ |
3127 |
|
const char* choices[] = { _("normal"), _("bidirectional"), _("backward"), 0 }; |
3128 |
|
static const gig::loop_type_t values[] = { |
3129 |
|
gig::loop_type_normal, |
3130 |
|
gig::loop_type_bidirectional, |
3131 |
|
gig::loop_type_backward |
3132 |
|
}; |
3133 |
|
eLoopType.set_choices(choices, values); |
3134 |
|
} |
3135 |
|
connect(eLoopType, &gig::Sample::LoopType); |
3136 |
|
connect(eLoopPlayCount, &gig::Sample::LoopPlayCount); |
3137 |
|
|
3138 |
|
eName.signal_value_changed().connect(sig_name_changed.make_slot()); |
3139 |
|
|
3140 |
|
connect(eName2, &SampleProps::set_Name); |
3141 |
|
connectLambda(eCreationDate, [this](gig::String s) { |
3142 |
|
m->pInfo->CreationDate = s; |
3143 |
|
}); |
3144 |
|
connectLambda(eComments, [this](gig::String s) { |
3145 |
|
m->pInfo->Comments = s; |
3146 |
|
}); |
3147 |
|
connectLambda(eProduct, [this](gig::String s) { |
3148 |
|
m->pInfo->Product = s; |
3149 |
|
}); |
3150 |
|
connectLambda(eCopyright, [this](gig::String s) { |
3151 |
|
m->pInfo->Copyright = s; |
3152 |
|
}); |
3153 |
|
connectLambda(eArtists, [this](gig::String s) { |
3154 |
|
m->pInfo->Artists = s; |
3155 |
|
}); |
3156 |
|
connectLambda(eGenre, [this](gig::String s) { |
3157 |
|
m->pInfo->Genre = s; |
3158 |
|
}); |
3159 |
|
connectLambda(eKeywords, [this](gig::String s) { |
3160 |
|
m->pInfo->Keywords = s; |
3161 |
|
}); |
3162 |
|
connectLambda(eEngineer, [this](gig::String s) { |
3163 |
|
m->pInfo->Engineer = s; |
3164 |
|
}); |
3165 |
|
connectLambda(eTechnician, [this](gig::String s) { |
3166 |
|
m->pInfo->Technician = s; |
3167 |
|
}); |
3168 |
|
connectLambda(eSoftware, [this](gig::String s) { |
3169 |
|
m->pInfo->Software = s; |
3170 |
|
}); |
3171 |
|
connectLambda(eMedium, [this](gig::String s) { |
3172 |
|
m->pInfo->Medium = s; |
3173 |
|
}); |
3174 |
|
connectLambda(eSource, [this](gig::String s) { |
3175 |
|
m->pInfo->Source = s; |
3176 |
|
}); |
3177 |
|
connectLambda(eSourceForm, [this](gig::String s) { |
3178 |
|
m->pInfo->SourceForm = s; |
3179 |
|
}); |
3180 |
|
connectLambda(eCommissioned, [this](gig::String s) { |
3181 |
|
m->pInfo->Commissioned = s; |
3182 |
|
}); |
3183 |
|
connectLambda(eSubject, [this](gig::String s) { |
3184 |
|
m->pInfo->Subject = s; |
3185 |
|
}); |
3186 |
|
|
3187 |
|
// tab 1 |
3188 |
|
#if USE_GTKMM_GRID |
3189 |
|
table.set_column_spacing(5); |
3190 |
|
#else |
3191 |
|
table.set_col_spacings(5); |
3192 |
|
#endif |
3193 |
|
table.add(eName); |
3194 |
|
table.add(eUnityNote); |
3195 |
|
table.add(eSampleGroup); |
3196 |
|
table.add(eSampleFormatInfo); |
3197 |
|
table.add(eSampleID); |
3198 |
|
table.add(eChecksum); |
3199 |
|
table.add(eLoopsCount); |
3200 |
|
table.add(eLoopStart); |
3201 |
|
table.add(eLoopLength); |
3202 |
|
table.add(eLoopType); |
3203 |
|
table.add(eLoopPlayCount); |
3204 |
|
|
3205 |
|
// tab 2 |
3206 |
|
#if USE_GTKMM_GRID |
3207 |
|
table2.set_column_spacing(5); |
3208 |
|
#else |
3209 |
|
table2.set_col_spacings(5); |
3210 |
|
#endif |
3211 |
|
table2.add(eName2); |
3212 |
|
table2.add(eCreationDate); |
3213 |
|
table2.add(eComments); |
3214 |
|
table2.add(eProduct); |
3215 |
|
table2.add(eCopyright); |
3216 |
|
table2.add(eArtists); |
3217 |
|
table2.add(eGenre); |
3218 |
|
table2.add(eKeywords); |
3219 |
|
table2.add(eEngineer); |
3220 |
|
table2.add(eTechnician); |
3221 |
|
table2.add(eSoftware); |
3222 |
|
table2.add(eMedium); |
3223 |
|
table2.add(eSource); |
3224 |
|
table2.add(eSourceForm); |
3225 |
|
table2.add(eCommissioned); |
3226 |
|
table2.add(eSubject); |
3227 |
|
|
3228 |
|
add(vbox[0]); |
3229 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
3230 |
|
table.set_margin(5); |
3231 |
|
#else |
3232 |
|
table.set_border_width(5); |
3233 |
|
#endif |
3234 |
|
vbox[1].pack_start(table); |
3235 |
|
vbox[2].pack_start(table2); |
3236 |
|
table.show(); |
3237 |
|
table2.show(); |
3238 |
|
vbox[0].pack_start(tabs); |
3239 |
|
vbox[0].pack_start(buttonBox, Gtk::PACK_SHRINK); |
3240 |
|
buttonBox.set_layout(Gtk::BUTTONBOX_END); |
3241 |
|
#if GTKMM_MAJOR_VERSION > 3 || (GTKMM_MAJOR_VERSION == 3 && GTKMM_MINOR_VERSION > 24) |
3242 |
|
buttonBox.set_margin(5); |
3243 |
|
#else |
3244 |
|
buttonBox.set_border_width(5); |
3245 |
|
#endif |
3246 |
|
buttonBox.show(); |
3247 |
|
buttonBox.pack_start(quitButton); |
3248 |
|
quitButton.set_can_default(); |
3249 |
|
quitButton.grab_focus(); |
3250 |
|
|
3251 |
|
quitButton.signal_clicked().connect( |
3252 |
|
sigc::mem_fun(*this, &SampleProps::hide)); |
3253 |
|
|
3254 |
|
quitButton.show(); |
3255 |
|
vbox[0].show(); |
3256 |
|
#if HAS_GTKMM_SHOW_ALL_CHILDREN |
3257 |
|
show_all_children(); |
3258 |
|
#endif |
3259 |
|
} |
3260 |
|
|
3261 |
|
void SampleProps::set_sample(gig::Sample* sample) |
3262 |
|
{ |
3263 |
|
update(sample); |
3264 |
|
|
3265 |
|
update_model++; |
3266 |
|
|
3267 |
|
// tab 1 |
3268 |
|
eName.set_value(sample->pInfo->Name); |
3269 |
|
eUnityNote.set_value(sample->MIDIUnityNote); |
3270 |
|
// show sample group name |
3271 |
|
{ |
3272 |
|
Glib::ustring s = "---"; |
3273 |
|
if (sample && sample->GetGroup()) |
3274 |
|
s = sample->GetGroup()->Name; |
3275 |
|
eSampleGroup.text.set_text(s); |
3276 |
|
} |
3277 |
|
// assemble sample format info string |
3278 |
|
{ |
3279 |
|
Glib::ustring s; |
3280 |
|
if (sample) { |
3281 |
|
switch (sample->Channels) { |
3282 |
|
case 1: s = _("Mono"); break; |
3283 |
|
case 2: s = _("Stereo"); break; |
3284 |
|
default: |
3285 |
|
s = ToString(sample->Channels) + _(" audio channels"); |
3286 |
|
break; |
3287 |
|
} |
3288 |
|
s += " " + ToString(sample->BitDepth) + " Bits"; |
3289 |
|
s += " " + ToString(sample->SamplesPerSecond/1000) + "." |
3290 |
|
+ ToString((sample->SamplesPerSecond%1000)/100) + " kHz"; |
3291 |
|
} else { |
3292 |
|
s = _("No sample assigned to this dimension region."); |
3293 |
|
} |
3294 |
|
eSampleFormatInfo.text.set_text(s); |
3295 |
|
} |
3296 |
|
// generate sample's memory address pointer string |
3297 |
|
{ |
3298 |
|
Glib::ustring s; |
3299 |
|
if (sample) { |
3300 |
|
char buf[64] = {}; |
3301 |
|
snprintf(buf, sizeof(buf), "%p", sample); |
3302 |
|
s = buf; |
3303 |
|
} else { |
3304 |
|
s = "---"; |
3305 |
|
} |
3306 |
|
eSampleID.text.set_text(s); |
3307 |
|
} |
3308 |
|
// generate raw wave form data CRC-32 checksum string |
3309 |
|
{ |
3310 |
|
Glib::ustring s = "---"; |
3311 |
|
if (sample) { |
3312 |
|
char buf[64] = {}; |
3313 |
|
snprintf(buf, sizeof(buf), "%x", sample->GetWaveDataCRC32Checksum()); |
3314 |
|
s = buf; |
3315 |
|
} |
3316 |
|
eChecksum.text.set_text(s); |
3317 |
|
} |
3318 |
|
eLoopsCount.set_value(sample->Loops); |
3319 |
|
eLoopStart.set_value(sample->LoopStart); |
3320 |
|
eLoopLength.set_value(sample->LoopSize); |
3321 |
|
eLoopType.set_value(sample->LoopType); |
3322 |
|
eLoopPlayCount.set_value(sample->LoopPlayCount); |
3323 |
|
// tab 2 |
3324 |
|
eName2.set_value(sample->pInfo->Name); |
3325 |
|
eCreationDate.set_value(sample->pInfo->CreationDate); |
3326 |
|
eComments.set_value(sample->pInfo->Comments); |
3327 |
|
eProduct.set_value(sample->pInfo->Product); |
3328 |
|
eCopyright.set_value(sample->pInfo->Copyright); |
3329 |
|
eArtists.set_value(sample->pInfo->Artists); |
3330 |
|
eGenre.set_value(sample->pInfo->Genre); |
3331 |
|
eKeywords.set_value(sample->pInfo->Keywords); |
3332 |
|
eEngineer.set_value(sample->pInfo->Engineer); |
3333 |
|
eTechnician.set_value(sample->pInfo->Technician); |
3334 |
|
eSoftware.set_value(sample->pInfo->Software); |
3335 |
|
eMedium.set_value(sample->pInfo->Medium); |
3336 |
|
eSource.set_value(sample->pInfo->Source); |
3337 |
|
eSourceForm.set_value(sample->pInfo->SourceForm); |
3338 |
|
eCommissioned.set_value(sample->pInfo->Commissioned); |
3339 |
|
eSubject.set_value(sample->pInfo->Subject); |
3340 |
|
|
3341 |
|
update_model--; |
3342 |
|
} |
3343 |
|
|
3344 |
|
void SampleProps::set_Name(const gig::String& name) |
3345 |
|
{ |
3346 |
|
m->pInfo->Name = name; |
3347 |
|
} |
3348 |
|
|
3349 |
|
void SampleProps::update_name() |
3350 |
|
{ |
3351 |
|
update_model++; |
3352 |
|
eName.set_value(m->pInfo->Name); |
3353 |
|
update_model--; |
3354 |
|
} |
3355 |
|
|
3356 |
|
|
3357 |
void MainWindow::file_changed() |
void MainWindow::file_changed() |
3358 |
{ |
{ |
3359 |
if (file && !file_is_changed) { |
if (file && !file_is_changed) { |
3585 |
} |
} |
3586 |
} |
} |
3587 |
|
|
3588 |
|
bool MainWindow::sample_props_set_sample() |
3589 |
|
{ |
3590 |
|
sampleProps.signal_name_changed().clear(); |
3591 |
|
|
3592 |
|
std::vector<Gtk::TreeModel::Path> rows = m_TreeViewSamples.get_selection()->get_selected_rows(); |
3593 |
|
if (rows.empty()) { |
3594 |
|
sampleProps.hide(); |
3595 |
|
return false; |
3596 |
|
} |
3597 |
|
//NOTE: was const_iterator before, which did not compile with GTKMM4 development branch, probably going to be fixed before final GTKMM4 release though. |
3598 |
|
Gtk::TreeModel::iterator it = m_refSamplesTreeModel->get_iter(rows[0]); |
3599 |
|
if (it) { |
3600 |
|
Gtk::TreeModel::Row row = *it; |
3601 |
|
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3602 |
|
|
3603 |
|
sampleProps.set_sample(sample); |
3604 |
|
|
3605 |
|
// make sure sample tree is updated when user changes the |
3606 |
|
// sample name in sample properties window |
3607 |
|
sampleProps.signal_name_changed().connect( |
3608 |
|
sigc::bind( |
3609 |
|
sigc::mem_fun(*this, |
3610 |
|
&MainWindow::sample_name_changed_by_sample_props |
3611 |
|
), it |
3612 |
|
) |
3613 |
|
); |
3614 |
|
} else { |
3615 |
|
sampleProps.hide(); |
3616 |
|
} |
3617 |
|
//NOTE: explicit boolean cast required for GTKMM4 development branch here |
3618 |
|
return it ? true : false; |
3619 |
|
} |
3620 |
|
|
3621 |
|
void MainWindow::show_sample_props() |
3622 |
|
{ |
3623 |
|
if (sample_props_set_sample()) { |
3624 |
|
sampleProps.show(); |
3625 |
|
sampleProps.deiconify(); |
3626 |
|
} |
3627 |
|
} |
3628 |
|
|
3629 |
|
void MainWindow::sample_name_changed_by_sample_props(Gtk::TreeModel::iterator& it) |
3630 |
|
{ |
3631 |
|
Gtk::TreeModel::Row row = *it; |
3632 |
|
Glib::ustring name = row[m_SamplesModel.m_col_name]; |
3633 |
|
|
3634 |
|
gig::Sample* sample = row[m_SamplesModel.m_col_sample]; |
3635 |
|
Glib::ustring gigname(gig_to_utf8(sample->pInfo->Name)); |
3636 |
|
if (gigname != name) { |
3637 |
|
Gtk::TreeModel::Path path(*it); |
3638 |
|
row[m_SamplesModel.m_col_name] = gigname; |
3639 |
|
} |
3640 |
|
} |
3641 |
|
|
3642 |
void MainWindow::show_midi_rules() |
void MainWindow::show_midi_rules() |
3643 |
{ |
{ |
3644 |
if (gig::Instrument* instrument = get_instrument()) |
if (gig::Instrument* instrument = get_instrument()) |
4345 |
} |
} |
4346 |
|
|
4347 |
void MainWindow::on_action_sample_properties() { |
void MainWindow::on_action_sample_properties() { |
4348 |
//TODO: show a dialog where the selected sample's properties can be edited |
show_sample_props(); |
|
Gtk::MessageDialog msg( |
|
|
*this, _("Sorry, yet to be implemented!"), false, Gtk::MESSAGE_INFO |
|
|
); |
|
|
msg.run(); |
|
4349 |
} |
} |
4350 |
|
|
4351 |
void MainWindow::on_action_add_script_group() { |
void MainWindow::on_action_add_script_group() { |
5144 |
file_changed(); |
file_changed(); |
5145 |
} |
} |
5146 |
} |
} |
5147 |
|
// change name in the sample properties window |
5148 |
|
if (sampleProps.get_sample() == sample && sample) { |
5149 |
|
sampleProps.set_sample(sample); |
5150 |
|
} |
5151 |
} |
} |
5152 |
|
|
5153 |
void MainWindow::script_name_changed(const Gtk::TreeModel::Path& path, |
void MainWindow::script_name_changed(const Gtk::TreeModel::Path& path, |