summaryrefslogtreecommitdiff
path: root/attic/muse2-oom/muse2/muse
diff options
context:
space:
mode:
Diffstat (limited to 'attic/muse2-oom/muse2/muse')
-rw-r--r--attic/muse2-oom/muse2/muse/CMakeLists.txt272
-rw-r--r--attic/muse2-oom/muse2/muse/app.cpp4919
-rw-r--r--attic/muse2-oom/muse2/muse/app.cpp.orig4792
-rw-r--r--attic/muse2-oom/muse2/muse/app.h380
-rw-r--r--attic/muse2-oom/muse2/muse/appearance.cpp1120
-rw-r--r--attic/muse2-oom/muse2/muse/appearance.h68
-rw-r--r--attic/muse2-oom/muse2/muse/arranger/CMakeLists.txt82
-rw-r--r--attic/muse2-oom/muse2/muse/arranger/alayout.cpp200
-rw-r--r--attic/muse2-oom/muse2/muse/arranger/alayout.h60
-rw-r--r--attic/muse2-oom/muse2/muse/arranger/arranger.cpp1104
-rw-r--r--attic/muse2-oom/muse2/muse/arranger/arranger.h173
-rw-r--r--attic/muse2-oom/muse2/muse/arranger/pcanvas.cpp2977
-rw-r--r--attic/muse2-oom/muse2/muse/arranger/pcanvas.h139
-rw-r--r--attic/muse2-oom/muse2/muse/arranger/tlist.cpp1595
-rw-r--r--attic/muse2-oom/muse2/muse/arranger/tlist.h115
-rw-r--r--attic/muse2-oom/muse2/muse/arranger/trackautomationview.cpp52
-rw-r--r--attic/muse2-oom/muse2/muse/arranger/trackautomationview.h20
-rw-r--r--attic/muse2-oom/muse2/muse/audio.cpp1439
-rw-r--r--attic/muse2-oom/muse2/muse/audio.h301
-rw-r--r--attic/muse2-oom/muse2/muse/audioconvert.cpp886
-rw-r--r--attic/muse2-oom/muse2/muse/audioconvert.h129
-rw-r--r--attic/muse2-oom/muse2/muse/audioprefetch.cpp262
-rw-r--r--attic/muse2-oom/muse2/muse/audioprefetch.h46
-rw-r--r--attic/muse2-oom/muse2/muse/audiotrack.cpp1652
-rw-r--r--attic/muse2-oom/muse2/muse/cliplist/CMakeLists.txt76
-rw-r--r--attic/muse2-oom/muse2/muse/cliplist/cliplist.cpp260
-rw-r--r--attic/muse2-oom/muse2/muse/cliplist/cliplist.h67
-rw-r--r--attic/muse2-oom/muse2/muse/cobject.cpp68
-rw-r--r--attic/muse2-oom/muse2/muse/cobject.h66
-rw-r--r--attic/muse2-oom/muse2/muse/conf.cpp1634
-rw-r--r--attic/muse2-oom/muse2/muse/conf.h38
-rw-r--r--attic/muse2-oom/muse2/muse/confmport.cpp1026
-rw-r--r--attic/muse2-oom/muse2/muse/confmport.h51
-rw-r--r--attic/muse2-oom/muse2/muse/ctrl.cpp322
-rw-r--r--attic/muse2-oom/muse2/muse/ctrl.h155
-rw-r--r--attic/muse2-oom/muse2/muse/ctrl/CMakeLists.txt85
-rw-r--r--attic/muse2-oom/muse2/muse/ctrl/ctrlcanvas.cpp1629
-rw-r--r--attic/muse2-oom/muse2/muse/ctrl/ctrlcanvas.h165
-rw-r--r--attic/muse2-oom/muse2/muse/ctrl/ctrledit.cpp134
-rw-r--r--attic/muse2-oom/muse2/muse/ctrl/ctrledit.h54
-rw-r--r--attic/muse2-oom/muse2/muse/ctrl/ctrlpanel.cpp709
-rw-r--r--attic/muse2-oom/muse2/muse/ctrl/ctrlpanel.h64
-rw-r--r--attic/muse2-oom/muse2/muse/debug.h31
-rw-r--r--attic/muse2-oom/muse2/muse/default_click.h1213
-rw-r--r--attic/muse2-oom/muse2/muse/device.h46
-rw-r--r--attic/muse2-oom/muse2/muse/driver/CMakeLists.txt73
-rw-r--r--attic/muse2-oom/muse2/muse/driver/alsamidi.cpp917
-rw-r--r--attic/muse2-oom/muse2/muse/driver/alsamidi.h58
-rw-r--r--attic/muse2-oom/muse2/muse/driver/alsatimer.cpp225
-rw-r--r--attic/muse2-oom/muse2/muse/driver/alsatimer.h52
-rw-r--r--attic/muse2-oom/muse2/muse/driver/audiodev.h76
-rw-r--r--attic/muse2-oom/muse2/muse/driver/dummyaudio.cpp453
-rw-r--r--attic/muse2-oom/muse2/muse/driver/jack.cpp2217
-rw-r--r--attic/muse2-oom/muse2/muse/driver/jackaudio.h97
-rw-r--r--attic/muse2-oom/muse2/muse/driver/jackmidi.cpp1732
-rw-r--r--attic/muse2-oom/muse2/muse/driver/jackmidi.h168
-rw-r--r--attic/muse2-oom/muse2/muse/driver/rtctimer.cpp155
-rw-r--r--attic/muse2-oom/muse2/muse/driver/rtctimer.h44
-rw-r--r--attic/muse2-oom/muse2/muse/driver/timerdev.h41
-rw-r--r--attic/muse2-oom/muse2/muse/dssihost.cpp3059
-rw-r--r--attic/muse2-oom/muse2/muse/dssihost.h255
-rw-r--r--attic/muse2-oom/muse2/muse/evdata.h67
-rw-r--r--attic/muse2-oom/muse2/muse/event.cpp328
-rw-r--r--attic/muse2-oom/muse2/muse/event.h151
-rw-r--r--attic/muse2-oom/muse2/muse/eventbase.h97
-rw-r--r--attic/muse2-oom/muse2/muse/eventlist.cpp112
-rw-r--r--attic/muse2-oom/muse2/muse/exportmidi.cpp388
-rw-r--r--attic/muse2-oom/muse2/muse/fastlog.h38
-rw-r--r--attic/muse2-oom/muse2/muse/gconfig.cpp171
-rw-r--r--attic/muse2-oom/muse2/muse/gconfig.h149
-rw-r--r--attic/muse2-oom/muse2/muse/givertcap.c94
-rw-r--r--attic/muse2-oom/muse2/muse/globaldefs.h34
-rw-r--r--attic/muse2-oom/muse2/muse/globals.cpp399
-rw-r--r--attic/muse2-oom/muse2/muse/globals.h191
-rw-r--r--attic/muse2-oom/muse2/muse/gui.h56
-rw-r--r--attic/muse2-oom/muse2/muse/help.cpp94
-rw-r--r--attic/muse2-oom/muse2/muse/helper.cpp40
-rw-r--r--attic/muse2-oom/muse2/muse/helper.h16
-rw-r--r--attic/muse2-oom/muse2/muse/icons.cpp711
-rw-r--r--attic/muse2-oom/muse2/muse/icons.h250
-rw-r--r--attic/muse2-oom/muse2/muse/images/bottom_rack.pngbin0 -> 1683 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/combo_down_arrow.pngbin0 -> 292 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/down_arrow.pngbin0 -> 175 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/down_arrow_disabled.pngbin0 -> 174 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/flagSP.pngbin0 -> 198 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/frame.pngbin0 -> 599 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/frame_clipping.pngbin0 -> 596 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/add_tracks.pngbin0 -> 612 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/blank_record.pngbin0 -> 188 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/delete_track.pngbin0 -> 754 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/down.pngbin0 -> 703 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/eraser.pngbin0 -> 996 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/eventfilter.pngbin0 -> 1318 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/eventlist.pngbin0 -> 941 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/garbage.pngbin0 -> 1147 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/manage-midi-devices.pngbin0 -> 573 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/matrix-percussion.pngbin0 -> 367 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/matrix.pngbin0 -> 315 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/mixer-exit.pngbin0 -> 952 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/mixer-exit_on.pngbin0 -> 993 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/mixer-in.pngbin0 -> 663 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/mixer-mono.pngbin0 -> 856 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/mixer-mute.pngbin0 -> 817 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/mixer-mute_on.pngbin0 -> 841 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/mixer-out.pngbin0 -> 821 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/mixer-pre.pngbin0 -> 743 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/mixer-pre_on.pngbin0 -> 793 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/mixer-record.pngbin0 -> 1302 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/mixer-record_on.pngbin0 -> 1336 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/mixer-solo.pngbin0 -> 810 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/mixer-solo_on.pngbin0 -> 839 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/mixer-stereo.pngbin0 -> 978 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/move.pngbin0 -> 1023 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/move_track_down.pngbin0 -> 755 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/move_track_up.pngbin0 -> 734 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/mute-all.pngbin0 -> 1362 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/pencil.pngbin0 -> 893 bytes
-rwxr-xr-xattic/muse2-oom/muse2/muse/images/icons/programchange.pngbin0 -> 1032 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/quantize.pngbin0 -> 964 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/resize.pngbin0 -> 741 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/select.pngbin0 -> 873 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/split.pngbin0 -> 1067 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/step_by_step.pngbin0 -> 771 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/transport-cursor-to-pointer.pngbin0 -> 1197 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/transport-ffwd-end.pngbin0 -> 1173 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/transport-ffwd.pngbin0 -> 1207 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/transport-panic.pngbin0 -> 1144 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/transport-play.pngbin0 -> 1181 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/transport-pointer-to-cursor.pngbin0 -> 1093 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/transport-record.pngbin0 -> 1163 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/transport-rewind-end.pngbin0 -> 1164 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/transport-rewind.pngbin0 -> 1208 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/transport-solo.pngbin0 -> 1227 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/transport-stop.pngbin0 -> 925 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/transport-tracking.pngbin0 -> 1265 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/un-mute-all.pngbin0 -> 1362 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/up.pngbin0 -> 697 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/icons/velocity.pngbin0 -> 677 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/knob.pngbin0 -> 1659 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/knob_aux.pngbin0 -> 1567 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/slider_thumb.pngbin0 -> 886 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/slider_thumb.xcfbin0 -> 3522 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/slider_thumb_h.pngbin0 -> 903 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/slider_thumb_h.xcfbin0 -> 3527 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/spindown.pngbin0 -> 276 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/spindown_hover.pngbin0 -> 268 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/spindown_off.pngbin0 -> 249 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/spindown_pressed.pngbin0 -> 264 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/spinup.pngbin0 -> 283 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/spinup.png.1bin0 -> 283 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/spinup_hover.pngbin0 -> 277 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/spinup_off.pngbin0 -> 274 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/spinup_pressed.pngbin0 -> 277 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/toolbar_handle.pngbin0 -> 227 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/top_rack.pngbin0 -> 1866 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/up_arrow.pngbin0 -> 197 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/images/up_arrow_disabled.pngbin0 -> 172 bytes
-rw-r--r--attic/muse2-oom/muse2/muse/importmidi.cpp614
-rw-r--r--attic/muse2-oom/muse2/muse/instruments/CMakeLists.txt89
-rw-r--r--attic/muse2-oom/muse2/muse/instruments/ccontrolbase.ui525
-rw-r--r--attic/muse2-oom/muse2/muse/instruments/editinstrument.cpp3588
-rw-r--r--attic/muse2-oom/muse2/muse/instruments/editinstrument.h91
-rw-r--r--attic/muse2-oom/muse2/muse/instruments/editinstrumentbase.ui1649
-rw-r--r--attic/muse2-oom/muse2/muse/instruments/midictrledit.cpp725
-rw-r--r--attic/muse2-oom/muse2/muse/instruments/midictrledit.h56
-rw-r--r--attic/muse2-oom/muse2/muse/instruments/minstrument.cpp927
-rw-r--r--attic/muse2-oom/muse2/muse/instruments/minstrument.h145
-rw-r--r--attic/muse2-oom/muse2/muse/key.cpp35
-rw-r--r--attic/muse2-oom/muse2/muse/key.h54
-rw-r--r--attic/muse2-oom/muse2/muse/ladspa.h599
-rw-r--r--attic/muse2-oom/muse2/muse/liste/CMakeLists.txt97
-rw-r--r--attic/muse2-oom/muse2/muse/liste/editctrlbase.ui875
-rw-r--r--attic/muse2-oom/muse2/muse/liste/editevent.cpp897
-rw-r--r--attic/muse2-oom/muse2/muse/liste/editevent.h198
-rw-r--r--attic/muse2-oom/muse2/muse/liste/listedit.cpp927
-rw-r--r--attic/muse2-oom/muse2/muse/liste/listedit.h79
-rw-r--r--attic/muse2-oom/muse2/muse/main.cpp495
-rw-r--r--attic/muse2-oom/muse2/muse/marker/CMakeLists.txt76
-rw-r--r--attic/muse2-oom/muse2/muse/marker/marker.cpp90
-rw-r--r--attic/muse2-oom/muse2/muse/marker/marker.h53
-rw-r--r--attic/muse2-oom/muse2/muse/marker/markerview.cpp614
-rw-r--r--attic/muse2-oom/muse2/muse/marker/markerview.h91
-rw-r--r--attic/muse2-oom/muse2/muse/master/CMakeLists.txt81
-rw-r--r--attic/muse2-oom/muse2/muse/master/lmaster.cpp750
-rw-r--r--attic/muse2-oom/muse2/muse/master/lmaster.h146
-rw-r--r--attic/muse2-oom/muse2/muse/master/master.cpp338
-rw-r--r--attic/muse2-oom/muse2/muse/master/master.h68
-rw-r--r--attic/muse2-oom/muse2/muse/master/masteredit.cpp406
-rw-r--r--attic/muse2-oom/muse2/muse/master/masteredit.h86
-rw-r--r--attic/muse2-oom/muse2/muse/master/tscale.cpp61
-rw-r--r--attic/muse2-oom/muse2/muse/master/tscale.h35
-rw-r--r--attic/muse2-oom/muse2/muse/memory.cpp100
-rw-r--r--attic/muse2-oom/muse2/muse/memory.h180
-rw-r--r--attic/muse2-oom/muse2/muse/midi.cpp1550
-rw-r--r--attic/muse2-oom/muse2/muse/midi.h73
-rw-r--r--attic/muse2-oom/muse2/muse/midictrl.cpp780
-rw-r--r--attic/muse2-oom/muse2/muse/midictrl.h256
-rw-r--r--attic/muse2-oom/muse2/muse/mididev.cpp549
-rw-r--r--attic/muse2-oom/muse2/muse/mididev.h162
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/CMakeLists.txt105
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/cmd.h28
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/dcanvas.cpp1351
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/dcanvas.h90
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/dlist.cpp752
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/dlist.h106
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/drumedit.cpp1225
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/drumedit.h128
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/drummap.cpp503
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/drummap.h47
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/ecanvas.cpp541
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/ecanvas.h94
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/piano.cpp554
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/piano.h62
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/pianoroll.cpp1501
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/pianoroll.h204
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/prcanvas.cpp1864
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/prcanvas.h110
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/quantconfig.cpp79
-rw-r--r--attic/muse2-oom/muse2/muse/midiedit/quantconfig.h32
-rw-r--r--attic/muse2-oom/muse2/muse/midieditor.cpp243
-rw-r--r--attic/muse2-oom/muse2/muse/midieditor.h89
-rw-r--r--attic/muse2-oom/muse2/muse/midievent.cpp176
-rw-r--r--attic/muse2-oom/muse2/muse/midievent.h62
-rw-r--r--attic/muse2-oom/muse2/muse/midifile.cpp678
-rw-r--r--attic/muse2-oom/muse2/muse/midifile.h113
-rw-r--r--attic/muse2-oom/muse2/muse/midiport.cpp1033
-rw-r--r--attic/muse2-oom/muse2/muse/midiport.h135
-rw-r--r--attic/muse2-oom/muse2/muse/midiseq.cpp766
-rw-r--r--attic/muse2-oom/muse2/muse/midiseq.h102
-rw-r--r--attic/muse2-oom/muse2/muse/miditransform.cpp1743
-rw-r--r--attic/muse2-oom/muse2/muse/miditransform.h105
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/CMakeLists.txt101
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/amixer.cpp732
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/amixer.h132
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/astrip.cpp1996
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/astrip.h105
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/auxknob.cpp40
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/auxknob.h33
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/meter.cpp298
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/meter.h53
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/mstrip.cpp1087
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/mstrip.h86
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/panknob.cpp32
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/panknob.h32
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/rack.cpp588
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/rack.h63
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/routedialog.cpp186
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/routedialog.h44
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/routedialogbase.ui174
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/strip.cpp298
-rw-r--r--attic/muse2-oom/muse2/muse/mixer/strip.h79
-rw-r--r--attic/muse2-oom/muse2/muse/mpevent.cpp160
-rw-r--r--attic/muse2-oom/muse2/muse/mpevent.h183
-rw-r--r--attic/muse2-oom/muse2/muse/mplugins/.cvsignore2
-rw-r--r--attic/muse2-oom/muse2/muse/mplugins/CMakeLists.txt109
-rw-r--r--attic/muse2-oom/muse2/muse/mplugins/midifilter.ui730
-rw-r--r--attic/muse2-oom/muse2/muse/mplugins/midifilterimpl.cpp130
-rw-r--r--attic/muse2-oom/muse2/muse/mplugins/midifilterimpl.h92
-rw-r--r--attic/muse2-oom/muse2/muse/mplugins/midiitransform.cpp1722
-rw-r--r--attic/muse2-oom/muse2/muse/mplugins/midiitransform.h102
-rw-r--r--attic/muse2-oom/muse2/muse/mplugins/mitplugin.cpp156
-rw-r--r--attic/muse2-oom/muse2/muse/mplugins/mitplugin.h39
-rw-r--r--attic/muse2-oom/muse2/muse/mplugins/mittranspose.cpp178
-rw-r--r--attic/muse2-oom/muse2/muse/mplugins/mittranspose.h70
-rw-r--r--attic/muse2-oom/muse2/muse/mplugins/mrconfig.cpp71
-rw-r--r--attic/muse2-oom/muse2/muse/mplugins/mrconfig.h41
-rw-r--r--attic/muse2-oom/muse2/muse/mplugins/mrconfigbase.ui191
-rw-r--r--attic/muse2-oom/muse2/muse/mplugins/random.cpp758
-rw-r--r--attic/muse2-oom/muse2/muse/mplugins/random.h192
-rw-r--r--attic/muse2-oom/muse2/muse/mplugins/rhythm.cpp514
-rw-r--r--attic/muse2-oom/muse2/muse/mplugins/rhythm.h198
-rw-r--r--attic/muse2-oom/muse2/muse/mplugins/rhythmbase.ui1095
-rw-r--r--attic/muse2-oom/muse2/muse/mtc.cpp130
-rw-r--r--attic/muse2-oom/muse2/muse/mtc.h56
-rw-r--r--attic/muse2-oom/muse2/muse/muse.log1875
-rw-r--r--attic/muse2-oom/muse2/muse/muse.pro371
-rw-r--r--attic/muse2-oom/muse2/muse/muse.qrc80
-rw-r--r--attic/muse2-oom/muse2/muse/muse.qrc.ORIG85
-rw-r--r--attic/muse2-oom/muse2/muse/node.cpp1911
-rw-r--r--attic/muse2-oom/muse2/muse/node.h131
-rw-r--r--attic/muse2-oom/muse2/muse/osc.cpp1401
-rw-r--r--attic/muse2-oom/muse2/muse/osc.h213
-rw-r--r--attic/muse2-oom/muse2/muse/part.cpp1433
-rw-r--r--attic/muse2-oom/muse2/muse/part.h175
-rw-r--r--attic/muse2-oom/muse2/muse/plugin.cpp3880
-rw-r--r--attic/muse2-oom/muse2/muse/plugin.h565
-rw-r--r--attic/muse2-oom/muse2/muse/pos.cpp568
-rw-r--r--attic/muse2-oom/muse2/muse/pos.h99
-rw-r--r--attic/muse2-oom/muse2/muse/remote/CMakeLists.txt58
-rw-r--r--attic/muse2-oom/muse2/muse/remote/pyapi.cpp1140
-rw-r--r--attic/muse2-oom/muse2/muse/remote/pyapi.h40
-rw-r--r--attic/muse2-oom/muse2/muse/route.cpp1685
-rw-r--r--attic/muse2-oom/muse2/muse/route.h103
-rw-r--r--attic/muse2-oom/muse2/muse/seqmsg.cpp1269
-rw-r--r--attic/muse2-oom/muse2/muse/shortcuts.cpp359
-rw-r--r--attic/muse2-oom/muse2/muse/shortcuts.h326
-rw-r--r--attic/muse2-oom/muse2/muse/sig.cpp439
-rw-r--r--attic/muse2-oom/muse2/muse/sig.h79
-rw-r--r--attic/muse2-oom/muse2/muse/song.cpp3911
-rw-r--r--attic/muse2-oom/muse2/muse/song.h429
-rw-r--r--attic/muse2-oom/muse2/muse/songfile.cpp1542
-rw-r--r--attic/muse2-oom/muse2/muse/stringparam.cpp112
-rw-r--r--attic/muse2-oom/muse2/muse/stringparam.h49
-rw-r--r--attic/muse2-oom/muse2/muse/style.qss814
-rw-r--r--attic/muse2-oom/muse2/muse/sync.cpp1395
-rw-r--r--attic/muse2-oom/muse2/muse/sync.h154
-rw-r--r--attic/muse2-oom/muse2/muse/synth.cpp953
-rw-r--r--attic/muse2-oom/muse2/muse/synth.h294
-rw-r--r--attic/muse2-oom/muse2/muse/tempo.cpp503
-rw-r--r--attic/muse2-oom/muse2/muse/tempo.h89
-rw-r--r--attic/muse2-oom/muse2/muse/thread.cpp455
-rw-r--r--attic/muse2-oom/muse2/muse/thread.h104
-rw-r--r--attic/muse2-oom/muse2/muse/ticksynth.cpp215
-rw-r--r--attic/muse2-oom/muse2/muse/ticksynth.h22
-rw-r--r--attic/muse2-oom/muse2/muse/track.cpp982
-rw-r--r--attic/muse2-oom/muse2/muse/track.h681
-rw-r--r--attic/muse2-oom/muse2/muse/trackview.cpp119
-rw-r--r--attic/muse2-oom/muse2/muse/trackview.h178
-rw-r--r--attic/muse2-oom/muse2/muse/transport.cpp799
-rw-r--r--attic/muse2-oom/muse2/muse/transport.h136
-rw-r--r--attic/muse2-oom/muse2/muse/transpose.cpp100
-rw-r--r--attic/muse2-oom/muse2/muse/transpose.h26
-rw-r--r--attic/muse2-oom/muse2/muse/undo.cpp976
-rw-r--r--attic/muse2-oom/muse2/muse/undo.h110
-rw-r--r--attic/muse2-oom/muse2/muse/value.cpp62
-rw-r--r--attic/muse2-oom/muse2/muse/value.h61
-rw-r--r--attic/muse2-oom/muse2/muse/vst.cpp633
-rw-r--r--attic/muse2-oom/muse2/muse/vst.h83
-rw-r--r--attic/muse2-oom/muse2/muse/wave.cpp1176
-rw-r--r--attic/muse2-oom/muse2/muse/wave.h265
-rw-r--r--attic/muse2-oom/muse2/muse/waveedit/CMakeLists.txt87
-rw-r--r--attic/muse2-oom/muse2/muse/waveedit/editgain.cpp91
-rw-r--r--attic/muse2-oom/muse2/muse/waveedit/editgain.h39
-rw-r--r--attic/muse2-oom/muse2/muse/waveedit/editgainbase.ui262
-rw-r--r--attic/muse2-oom/muse2/muse/waveedit/waveedit.cpp462
-rw-r--r--attic/muse2-oom/muse2/muse/waveedit/waveedit.h83
-rw-r--r--attic/muse2-oom/muse2/muse/waveedit/waveview.cpp946
-rw-r--r--attic/muse2-oom/muse2/muse/waveedit/waveview.h99
-rw-r--r--attic/muse2-oom/muse2/muse/waveevent.cpp453
-rw-r--r--attic/muse2-oom/muse2/muse/waveevent.h64
-rw-r--r--attic/muse2-oom/muse2/muse/wavetrack.cpp360
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/CMakeLists.txt236
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/aboutbox.ui108
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/aboutbox_impl.cpp12
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/aboutbox_impl.h16
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/action.h33
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/appearancebase.ui1890
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/bigtime.cpp448
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/bigtime.h53
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/canvas.cpp1463
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/canvas.h185
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/checkbox.cpp59
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/checkbox.h44
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/citem.cpp93
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/citem.h90
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/cliplisteditorbase.ui167
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/comboQuant.cpp94
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/comboQuant.h39
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/combobox.cpp80
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/combobox.h46
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/comment.cpp89
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/comment.h53
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/commentbase.ui90
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/configmidifilebase.ui238
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/ctrlcombo.cpp56
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/ctrlcombo.cw22
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/ctrlcombo.h22
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/dentry.cpp242
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/dentry.h73
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/didyouknow.h37
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/didyouknow.ui91
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/dimap.cpp308
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/dimap.h55
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/doublelabel.cpp193
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/doublelabel.h61
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/drange.cpp265
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/drange.h69
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/editnotedialogbase.ui223
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/editsysexdialogbase.ui196
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/fdialogbuttons.ui159
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/filedialog.cpp546
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/filedialog.h110
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/gatetime.cpp51
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/gatetime.h40
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/gatetimebase.ui213
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/genset.cpp464
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/genset.h44
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/gensetbase.ui1268
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/header.cpp111
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/header.h32
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/hitscale.cpp133
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/hitscale.h46
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/intlabel.cpp140
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/intlabel.h46
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/itransformbase.ui1170
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/knob.cpp540
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/knob.h79
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/lcombo.cpp51
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/lcombo.h43
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/menutitleitem.h25
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/metronome.cpp183
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/metronome.h36
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/metronomebase.ui568
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/midisync.ui409
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/midisyncimpl.cpp1252
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/midisyncimpl.h119
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/mittransposebase.ui114
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/mixdowndialog.cpp105
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/mixdowndialog.h38
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/mixdowndialogbase.ui217
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/mktest5
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/mlabel.cpp15
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/mlabel.h37
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/mmath.cpp300
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/mmath.h77
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/moc_ttoolbar.cpp0
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/mtrackinfo.cpp1831
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/mtrackinfo.h91
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/mtrackinfobase.ui1077
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/mtscale.cpp424
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/mtscale.h49
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/musewidgetsplug.cpp572
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/nentry.cpp401
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/nentry.h84
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/noteinfo.cpp210
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/noteinfo.h59
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/pcscale.cpp337
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/pcscale.h58
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/pctable.cpp124
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/pctable.h31
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/pctablemodel.cpp18
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/pctablemodel.h16
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/pitchedit.cpp64
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/pitchedit.h33
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/pitchlabel.cpp97
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/pitchlabel.h41
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/popupmenu.cpp137
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/popupmenu.h59
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/posedit.cpp854
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/posedit.h104
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/poslabel.cpp156
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/poslabel.h45
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/projectcreate.ui145
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/projectcreateimpl.cpp65
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/projectcreateimpl.h26
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/scldiv.cpp655
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/scldiv.h56
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/scldraw.cpp881
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/scldraw.h86
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/sclif.cpp205
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/sclif.h50
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/scrollscale.cpp509
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/scrollscale.h85
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/section.h19
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialog.cpp99
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialog.h35
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialogbase.ui123
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/shortcutconfig.cpp127
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/shortcutconfig.h60
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/shortcutconfigbase.ui177
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/sigedit.cpp739
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/sigedit.h88
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/siglabel.cpp164
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/siglabel.h47
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/sigscale.cpp152
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/sigscale.h46
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/slider.cpp975
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/slider.h96
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/sliderbase.cpp726
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/sliderbase.h101
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/songinfo.h37
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/songinfo.ui108
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/spinbox.cpp84
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/spinbox.h43
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/spinboxFP.cpp172
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/spinboxFP.h53
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/splitter.cpp79
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/splitter.h29
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/swidget.cpp20
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/swidget.h31
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/synthconfigbase.ui168
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/tb1.cpp268
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/tb1.h61
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/tempolabel.cpp123
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/tempolabel.h61
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/tools.cpp142
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/tools.h58
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/trackvieweditorbase.ui282
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/transformbase.ui1068
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/transposebase.ui228
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/ttoolbar.cpp24
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/ttoolbar.h9
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/ttoolbutton.cpp29
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/ttoolbutton.h28
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/tvieweditor.cpp196
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/tvieweditor.h67
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/utils.cpp356
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/utils.h29
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/velocity.cpp46
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/velocity.h39
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/velocitybase.ui211
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/view.cpp639
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/view.h107
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/vscale.cpp28
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/vscale.h29
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/wtscale.cpp286
-rw-r--r--attic/muse2-oom/muse2/muse/widgets/wtscale.h46
-rw-r--r--attic/muse2-oom/muse2/muse/xml.cpp734
-rw-r--r--attic/muse2-oom/muse2/muse/xml.h96
509 files changed, 165200 insertions, 0 deletions
diff --git a/attic/muse2-oom/muse2/muse/CMakeLists.txt b/attic/muse2-oom/muse2/muse/CMakeLists.txt
new file mode 100644
index 00000000..107135af
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/CMakeLists.txt
@@ -0,0 +1,272 @@
+#=============================================================================
+# MusE
+# Linux Music Editor
+# $Id:$
+#
+# Copyright (C) 2002-2008 by Werner Schweer and others
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#=============================================================================
+
+include(${PROJECT_SOURCE_DIR}/pch.txt)
+
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}
+ )
+
+set (SubDirs
+ arranger
+ cliplist
+ ctrl
+ driver
+ instruments
+ liste
+ marker
+ master
+ midiedit
+ mixer
+ mplugins
+ waveedit
+ widgets
+ )
+
+if (ENABLE_PYTHON)
+ set ( PYREM_CPP_FLAGS "-DENABLE_PYTHON" )
+ set ( PYLIBS ${PYTHON_LIB} remote)
+ set ( SubDirs ${SubDirs} remote )
+endif (ENABLE_PYTHON)
+
+subdirs (${SubDirs})
+
+##
+## Expand Qt macros in source files
+##
+QT4_WRAP_CPP ( muse_moc_headers
+ app.h
+ appearance.h
+ cobject.h
+ conf.h
+ confmport.h
+ midieditor.h
+ miditransform.h
+ plugin.h
+ song.h
+ transport.h
+ transpose.h
+ value.h
+ )
+
+##
+## Resource files
+##
+QT4_ADD_RESOURCES (muse_qrc_files
+ muse.qrc
+ )
+
+file (GLOB core_source_files
+ app.cpp
+ appearance.cpp
+ audio.cpp
+ audioconvert.cpp
+ audioprefetch.cpp
+ audiotrack.cpp
+ cobject.cpp
+ conf.cpp
+ confmport.cpp
+ ctrl.cpp
+ dssihost.cpp
+ event.cpp
+ eventlist.cpp
+ exportmidi.cpp
+ gconfig.cpp
+ globals.cpp
+ help.cpp
+ helper.cpp
+ importmidi.cpp
+ key.cpp
+ memory.cpp
+ midi.cpp
+ midictrl.cpp
+ mididev.cpp
+ midieditor.cpp
+ midievent.cpp
+ midifile.cpp
+ midiport.cpp
+ midiseq.cpp
+ miditransform.cpp
+ mpevent.cpp
+ mtc.cpp
+ node.cpp
+ osc.cpp
+ part.cpp
+ plugin.cpp
+ pos.cpp
+ route.cpp
+ seqmsg.cpp
+ shortcuts.cpp
+ sig.cpp
+ song.cpp
+ songfile.cpp
+ stringparam.cpp
+ sync.cpp
+ synth.cpp
+ tempo.cpp
+ thread.cpp
+ ticksynth.cpp
+ track.cpp
+ trackview.cpp
+ transport.cpp
+ transpose.cpp
+ undo.cpp
+ value.cpp
+ vst.cpp
+ wave.cpp
+ waveevent.cpp
+ wavetrack.cpp
+ xml.cpp
+ )
+file (GLOB main_source_files
+ main.cpp
+ )
+file (GLOB icons_source_files
+ icons.cpp
+ )
+
+##
+## Define target
+##
+add_library ( core SHARED
+ ${muse_qrc_files}
+ ${muse_moc_headers}
+ ${core_source_files}
+ )
+add_executable ( muse
+ ${main_source_files}
+ )
+add_library ( icons SHARED
+ ${icons_source_files}
+ )
+
+set (FILES_TO_TRANSLATE
+ ${FILES_TO_TRANSLATE}
+ ${main_source_files}
+ ${core_source_files}
+ CACHE INTERNAL ""
+ )
+
+##
+## Directories that will be passed to the compiler with -I flag
+##
+include_directories (
+ arranger
+ driver
+ instruments
+ liste
+ midiedit
+ mixer
+ mplugins
+ remote
+ waveedit
+ widgets
+ )
+
+# Make sure to include the uic generated headers paths.
+include_directories(
+ ${CMAKE_CURRENT_BINARY_DIR}/arranger
+ ${CMAKE_CURRENT_BINARY_DIR}/driver
+ ${CMAKE_CURRENT_BINARY_DIR}/instruments
+ ${CMAKE_CURRENT_BINARY_DIR}/liste
+ ${CMAKE_CURRENT_BINARY_DIR}/midiedit
+ ${CMAKE_CURRENT_BINARY_DIR}/mixer
+ ${CMAKE_CURRENT_BINARY_DIR}/mplugins
+ ${CMAKE_CURRENT_BINARY_DIR}/remote
+ ${CMAKE_CURRENT_BINARY_DIR}/waveedit
+ ${CMAKE_CURRENT_BINARY_DIR}/widgets
+ )
+
+##
+## Compilation flags and target name
+##
+set_target_properties( core
+ # PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h"
+ # PROPERTIES COMPILE_FLAGS "-Imidiedit -Iarranger -Iliste -Iwidgets -Imixer -Idriver -Iwaveedit -Implugins -Iinstruments -Iremote ${PYREM_CPP_FLAGS} -include ${PROJECT_BINARY_DIR}/all.h "
+ # PROPERTIES COMPILE_FLAGS "${PYREM_CPP_FLAGS} -DINSTPREFIX='\"${CMAKE_INSTALL_PREFIX}\"' -DINSTLIBDIR='\"${LIBRARY_OUTPUT_DIRECTORY}\"' -include ${PROJECT_BINARY_DIR}/all.h "
+ PROPERTIES COMPILE_FLAGS "${PYREM_CPP_FLAGS} -include ${PROJECT_BINARY_DIR}/all.h -fPIC"
+ OUTPUT_NAME muse_core
+ )
+set_target_properties( muse
+ PROPERTIES OUTPUT_NAME ${MusE_EXEC_NAME}
+ )
+set_target_properties( icons
+ PROPERTIES OUTPUT_NAME muse_icons
+ )
+
+##
+## Linkage
+##
+target_link_libraries(core
+ al
+ arranger
+ awl
+ cliplist
+ ctrl
+ driver
+ icons
+ instruments
+ liste
+ marker
+ master
+ midiedit
+ mixer
+ mplugins
+ synti
+ waveedit
+ widgets
+
+ ${QT_LIBRARIES}
+ ${SNDFILE_LIBRARIES}
+ ${SAMPLERATE_LIBRARIES}
+ ${UUID_LIBRARIES}
+ ${PYLIBS}
+ ${FST_LIB}
+ dl
+ )
+
+if(HAVE_LASH)
+ target_link_libraries(core ${LASH_LIBRARIES})
+endif(HAVE_LASH)
+
+if(OSC_SUPPORT)
+ target_link_libraries(core ${LIBLO_LIBRARIES})
+endif(OSC_SUPPORT)
+
+target_link_libraries(muse
+ midiedit
+ core
+ )
+
+target_link_libraries(icons
+ ${QT_LIBRARIES}
+ )
+
+##
+## Install location
+##
+install( TARGETS muse
+ RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX}/bin/
+ )
+install(TARGETS core icons
+ DESTINATION
+ ${MusE_MODULES_DIR}
+ )
+
diff --git a/attic/muse2-oom/muse2/muse/app.cpp b/attic/muse2-oom/muse2/muse/app.cpp
new file mode 100644
index 00000000..1f2edc1a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/app.cpp
@@ -0,0 +1,4919 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: app.cpp,v 1.113.2.68 2009/12/21 14:51:51 spamatica Exp $
+//
+// (C) Copyright 1999-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QClipboard>
+#include <QMessageBox>
+#include <QShortcut>
+#include <QSignalMapper>
+#include <QTimer>
+#include <QWhatsThis>
+
+#include "app.h"
+#include "master/lmaster.h"
+#include "al/dsp.h"
+#include "amixer.h"
+#include "appearance.h"
+#include "arranger.h"
+#include "audio.h"
+#include "audiodev.h"
+#include "audioprefetch.h"
+#include "bigtime.h"
+#include "cliplist/cliplist.h"
+#include "conf.h"
+#include "debug.h"
+#include "didyouknow.h"
+#include "drumedit.h"
+#include "filedialog.h"
+#include "gatetime.h"
+#include "gconfig.h"
+#include "gui.h"
+#include "icons.h"
+#include "instruments/editinstrument.h"
+#include "listedit.h"
+#include "marker/markerview.h"
+#include "master/masteredit.h"
+#include "metronome.h"
+#include "midiseq.h"
+#include "mixdowndialog.h"
+#include "pianoroll.h"
+#include "popupmenu.h"
+#include "shortcutconfig.h"
+#include "songinfo.h"
+#include "ticksynth.h"
+#include "transport.h"
+#include "transpose.h"
+#include "waveedit.h"
+#include "widgets/projectcreateimpl.h"
+
+#ifdef DSSI_SUPPORT
+#include "dssihost.h"
+#endif
+
+#ifdef VST_SUPPORT
+#include "vst.h"
+#endif
+
+//extern void cacheJackRouteNames();
+
+static pthread_t watchdogThread;
+//ErrorHandler *error;
+static const char* fileOpenText =
+ QT_TRANSLATE_NOOP("@default", "Click this button to open a <em>new song</em>.<br>"
+ "You can also select the <b>Open command</b> from the File menu.");
+static const char* fileSaveText =
+ QT_TRANSLATE_NOOP("@default", "Click this button to save the song you are "
+ "editing. You will be prompted for a file name.\n"
+ "You can also select the Save command from the File menu.");
+static const char* fileNewText = QT_TRANSLATE_NOOP("@default", "Create New Song");
+
+static const char* infoLoopButton = QT_TRANSLATE_NOOP("@default", "loop between left mark and right mark");
+static const char* infoPunchinButton = QT_TRANSLATE_NOOP("@default", "record starts at left mark");
+static const char* infoPunchoutButton = QT_TRANSLATE_NOOP("@default", "record stops at right mark");
+static const char* infoStartButton = QT_TRANSLATE_NOOP("@default", "rewind to start position");
+static const char* infoRewindButton = QT_TRANSLATE_NOOP("@default", "rewind current position");
+static const char* infoForwardButton = QT_TRANSLATE_NOOP("@default", "move current position");
+static const char* infoStopButton = QT_TRANSLATE_NOOP("@default", "stop sequencer");
+static const char* infoPlayButton = QT_TRANSLATE_NOOP("@default", "start sequencer play");
+static const char* infoRecordButton = QT_TRANSLATE_NOOP("@default", "to record press record and then play");
+static const char* infoPanicButton = QT_TRANSLATE_NOOP("@default", "send note off to all midi channels");
+
+#define PROJECT_LIST_LEN 6
+static QString* projectList[PROJECT_LIST_LEN];
+
+extern void initMidiSynth();
+extern void exitJackAudio();
+extern void exitDummyAudio();
+// p3.3.39
+extern void exitOSC();
+
+#ifdef HAVE_LASH
+#include <lash/lash.h>
+lash_client_t * lash_client = 0;
+extern snd_seq_t * alsaSeq;
+#endif /* HAVE_LASH */
+
+int watchAudio, watchAudioPrefetch, watchMidi;
+pthread_t splashThread;
+
+
+//PyScript *pyscript;
+// void MusE::runPythonScript()
+// {
+// QString script("test.py");
+// // pyscript->runPythonScript(script);
+// }
+
+//---------------------------------------------------------
+// sleep function
+//---------------------------------------------------------
+void microSleep(long msleep)
+{
+ bool sleepOk=-1;
+
+ while(sleepOk==-1)
+ sleepOk=usleep(msleep);
+}
+
+// Removed p3.3.17
+/*
+//---------------------------------------------------------
+// watchdog thread
+//---------------------------------------------------------
+
+static void* watchdog(void*)
+ {
+ doSetuid();
+
+ struct sched_param rt_param;
+ memset(&rt_param, 0, sizeof(rt_param));
+ rt_param.sched_priority = sched_get_priority_max(SCHED_FIFO);
+ int rv = pthread_setschedparam(pthread_self(), SCHED_FIFO, &rt_param);
+ if (rv != 0)
+ perror("Set realtime scheduler");
+
+ int policy;
+ if (pthread_getschedparam(pthread_self(), &policy, &rt_param)!= 0) {
+ printf("Cannot get current client scheduler: %s\n", strerror(errno));
+ }
+ if (policy != SCHED_FIFO)
+ printf("watchdog process %d _NOT_ running SCHED_FIFO\n", getpid());
+ else if (debugMsg)
+ printf("watchdog set to SCHED_FIFO priority %d\n",
+ sched_get_priority_max(SCHED_FIFO));
+
+ undoSetuid();
+ int fatal = 0;
+ for (;;) {
+ watchAudio = 0;
+ watchMidi = 0;
+ static const int WD_TIMEOUT = 3;
+
+ // sleep can be interrpted by signals:
+ int to = WD_TIMEOUT;
+ while (to > 0)
+ to = sleep(to);
+
+ bool timeout = false;
+ if (midiSeqRunning && watchMidi == 0)
+ {
+ printf("midiSeqRunning = %i watchMidi %i\n", midiSeqRunning, watchMidi);
+ timeout = true;
+ }
+ if (watchAudio == 0)
+ timeout = true;
+ if (watchAudio > 500000)
+ timeout = true;
+ if (timeout)
+ ++fatal;
+ else
+ fatal = 0;
+ if (fatal >= 3) {
+ printf("WatchDog: fatal error, realtime task timeout\n");
+ printf(" (%d,%d-%d) - stopping all services\n",
+ watchMidi, watchAudio, fatal);
+ break;
+ }
+// printf("wd %d %d %d\n", watchMidi, watchAudio, fatal);
+ }
+ audio->stop(true);
+ audioPrefetch->stop(true);
+ printf("watchdog exit\n");
+ exit(-1);
+ }
+*/
+
+//---------------------------------------------------------
+// seqStart
+//---------------------------------------------------------
+
+bool MusE::seqStart()
+ {
+ // Changed by Tim. p3.3.17
+
+ /*
+ if (audio->isRunning()) {
+ printf("seqStart(): already running\n");
+ return true;
+ }
+
+ if (realTimeScheduling) {
+ //
+ // create watchdog thread with max priority
+ //
+ doSetuid();
+ struct sched_param rt_param;
+ memset(&rt_param, 0, sizeof(rt_param));
+ rt_param.sched_priority = realTimePriority +1;//sched_get_priority_max(SCHED_FIFO);
+
+ pthread_attr_t* attributes = (pthread_attr_t*) malloc(sizeof(pthread_attr_t));
+ pthread_attr_init(attributes);
+
+// if (pthread_attr_setschedpolicy(attributes, SCHED_FIFO)) {
+// printf("MusE: cannot set FIFO scheduling class for RT thread\n");
+// }
+// if (pthread_attr_setschedparam (attributes, &rt_param)) {
+// // printf("Cannot set scheduling priority for RT thread (%s)\n", strerror(errno));
+// }
+// if (pthread_attr_setscope (attributes, PTHREAD_SCOPE_SYSTEM)) {
+// printf("MusE: Cannot set scheduling scope for RT thread\n");
+// }
+ if (pthread_create(&watchdogThread, attributes, ::watchdog, 0))
+ perror("MusE: creating watchdog thread failed:");
+ pthread_attr_destroy(attributes);
+ undoSetuid();
+ }
+ audioPrefetch->start();
+ audioPrefetch->msgSeek(0, true); // force
+ midiSeqRunning = !midiSeq->start();
+
+ if (!audio->start()) {
+ QMessageBox::critical( muse, tr(QString("Failed to start audio!")),
+ tr(QString("Was not able to start audio, check if jack is running.\n")));
+ return false;
+ }
+
+ return true;
+ */
+
+ if (audio->isRunning()) {
+ printf("seqStart(): already running\n");
+ return true;
+ }
+
+ if (!audio->start()) {
+ QMessageBox::critical( muse, tr("Failed to start audio!"),
+ tr("Was not able to start audio, check if jack is running.\n"));
+ return false;
+ }
+
+ //
+ // wait for jack callback
+ //
+ for(int i = 0; i < 60; ++i)
+ {
+ //if (audioState == AUDIO_START2)
+ if(audio->isRunning())
+ break;
+ sleep(1);
+ }
+ //if (audioState != AUDIO_START2) {
+ if(!audio->isRunning())
+ {
+ QMessageBox::critical( muse, tr("Failed to start audio!"),
+ tr("Timeout waiting for audio to run. Check if jack is running.\n"));
+ }
+ //
+ // now its safe to ask the driver for realtime
+ // priority
+
+ realTimePriority = audioDevice->realtimePriority();
+ if(debugMsg)
+ printf("MusE::seqStart: getting audio driver realTimePriority:%d\n", realTimePriority);
+
+ // Disabled by Tim. p3.3.22
+ /*
+ if(realTimeScheduling)
+ {
+ //
+ // create watchdog thread with max priority
+ //
+ doSetuid();
+ struct sched_param rt_param;
+ memset(&rt_param, 0, sizeof(rt_param));
+ rt_param.sched_priority = realTimePriority + 1;//sched_get_priority_max(SCHED_FIFO);
+
+ pthread_attr_t* attributes = (pthread_attr_t*) malloc(sizeof(pthread_attr_t));
+ pthread_attr_init(attributes);
+
+// if (pthread_attr_setschedpolicy(attributes, SCHED_FIFO)) {
+// printf("MusE: cannot set FIFO scheduling class for RT thread\n");
+// }
+// if (pthread_attr_setschedparam (attributes, &rt_param)) {
+// // printf("Cannot set scheduling priority for RT thread (%s)\n", strerror(errno));
+// }
+// if (pthread_attr_setscope (attributes, PTHREAD_SCOPE_SYSTEM)) {
+// printf("MusE: Cannot set scheduling scope for RT thread\n");
+// }
+ if (pthread_create(&watchdogThread, attributes, ::watchdog, 0))
+ perror("MusE: creating watchdog thread failed");
+ pthread_attr_destroy(attributes);
+ undoSetuid();
+ }
+ */
+
+ //int policy;
+ //if ((policy = sched_getscheduler (0)) < 0) {
+ // printf("Cannot get current client scheduler: %s\n", strerror(errno));
+ // }
+ //if (policy != SCHED_FIFO)
+ // printf("midi thread %d _NOT_ running SCHED_FIFO\n", getpid());
+
+
+ //audioState = AUDIO_RUNNING;
+ // Changed by Tim. p3.3.22
+ /*
+ //if(realTimePriority)
+ if(realTimeScheduling)
+ {
+ int pr = realTimePriority;
+ if(pr > 5)
+ pr -= 5;
+ else
+ pr = 0;
+ audioPrefetch->start(pr);
+ //audioWriteback->start(realTimePriority - 5);
+ }
+ else
+ {
+ audioPrefetch->start(0);
+ //audioWriteback->start(0);
+ }
+ */
+
+ int pfprio = 0;
+ int midiprio = 0;
+
+ // NOTE: realTimeScheduling can be true (gotten using jack_is_realtime()),
+ // while the determined realTimePriority can be 0.
+ // realTimePriority is gotten using pthread_getschedparam() on the client thread
+ // in JackAudioDevice::realtimePriority() which is a bit flawed - it reports there's no RT...
+ if(realTimeScheduling)
+ {
+ //if(realTimePriority < 5)
+ // printf("MusE: WARNING: Recommend setting audio realtime priority to a higher value!\n");
+ /*
+ if(realTimePriority == 0)
+ {
+ pfprio = 1;
+ midiprio = 2;
+ }
+ else
+ if(realTimePriority == 1)
+ {
+ pfprio = 2;
+ midiprio = 3;
+ }
+ else
+ if(realTimePriority == 2)
+ {
+ pfprio = 1;
+ midiprio = 3;
+ }
+ else
+ if(realTimePriority == 3)
+ {
+ pfprio = 1;
+ //midiprio = 2;
+ // p3.3.37
+ midiprio = 4;
+ }
+ else
+ if(realTimePriority == 4)
+ {
+ pfprio = 1;
+ //midiprio = 3;
+ // p3.3.37
+ midiprio = 5;
+ }
+ else
+ if(realTimePriority == 5)
+ {
+ pfprio = 1;
+ //midiprio = 3;
+ // p3.3.37
+ midiprio = 6;
+ }
+ else
+ */
+ {
+ //pfprio = realTimePriority - 5;
+ // p3.3.40
+ pfprio = realTimePriority + 1;
+
+ //midiprio = realTimePriority - 2;
+ // p3.3.37
+ //midiprio = realTimePriority + 1;
+ // p3.3.40
+ midiprio = realTimePriority + 2;
+ }
+ }
+
+ if(midiRTPrioOverride > 0)
+ midiprio = midiRTPrioOverride;
+
+ // FIXME FIXME: The realTimePriority of the Jack thread seems to always be 5 less than the value passed to jackd command.
+ //if(midiprio == realTimePriority)
+ // printf("MusE: WARNING: Midi realtime priority %d is the same as audio realtime priority %d. Try a different setting.\n",
+ // midiprio, realTimePriority);
+ //if(midiprio == pfprio)
+ // printf("MusE: WARNING: Midi realtime priority %d is the same as audio prefetch realtime priority %d. Try a different setting.\n",
+ // midiprio, pfprio);
+
+ audioPrefetch->start(pfprio);
+
+ audioPrefetch->msgSeek(0, true); // force
+
+ //midiSeqRunning = !midiSeq->start(realTimeScheduling ? realTimePriority : 0);
+ // Changed by Tim. p3.3.22
+ //midiSeq->start(realTimeScheduling ? realTimePriority : 0);
+ midiSeq->start(midiprio);
+
+ int counter=0;
+ while (++counter) {
+ //if (counter > 10) {
+ if (counter > 1000) {
+ fprintf(stderr,"midi sequencer thread does not start!? Exiting...\n");
+ exit(33);
+ }
+ midiSeqRunning = midiSeq->isRunning();
+ if (midiSeqRunning)
+ break;
+ usleep(1000);
+ printf("looping waiting for sequencer thread to start\n");
+ }
+ if(!midiSeqRunning)
+ {
+ fprintf(stderr, "midiSeq is not running! Exiting...\n");
+ exit(33);
+ }
+ return true;
+ }
+
+//---------------------------------------------------------
+// stop
+//---------------------------------------------------------
+
+void MusE::seqStop()
+ {
+ // label sequencer as disabled before it actually happened to minimize race condition
+ midiSeqRunning = false;
+
+ song->setStop(true);
+ song->setStopPlay(false);
+ midiSeq->stop(true);
+ audio->stop(true);
+ audioPrefetch->stop(true);
+ if (realTimeScheduling && watchdogThread)
+ pthread_cancel(watchdogThread);
+ }
+
+//---------------------------------------------------------
+// seqRestart
+//---------------------------------------------------------
+
+bool MusE::seqRestart()
+{
+ bool restartSequencer = audio->isRunning();
+ if (restartSequencer) {
+ if (audio->isPlaying()) {
+ audio->msgPlay(false);
+ while (audio->isPlaying())
+ qApp->processEvents();
+ }
+ seqStop();
+ }
+ if(!seqStart())
+ return false;
+
+ audioDevice->graphChanged();
+ return true;
+}
+
+//---------------------------------------------------------
+// addProject
+//---------------------------------------------------------
+
+void addProject(const QString& name)
+ {
+ for (int i = 0; i < PROJECT_LIST_LEN; ++i) {
+ if (projectList[i] == 0)
+ break;
+ if (name == *projectList[i]) {
+ int dst = i;
+ int src = i+1;
+ int n = PROJECT_LIST_LEN - i - 1;
+ delete projectList[i];
+ for (int k = 0; k < n; ++k)
+ projectList[dst++] = projectList[src++];
+ projectList[dst] = 0;
+ break;
+ }
+ }
+ QString** s = &projectList[PROJECT_LIST_LEN - 2];
+ QString** d = &projectList[PROJECT_LIST_LEN - 1];
+ if (*d)
+ delete *d;
+ for (int i = 0; i < PROJECT_LIST_LEN-1; ++i)
+ *d-- = *s--;
+ projectList[0] = new QString(name);
+ }
+
+//---------------------------------------------------------
+// populateAddSynth
+//---------------------------------------------------------
+
+/*
+struct addSynth_cmp_str
+{
+ bool operator()(std::string a, std::string b)
+ {
+ return (a < b);
+ }
+};
+*/
+
+// ORCAN - CHECK
+QMenu* populateAddSynth(QWidget* parent)
+{
+ QMenu* synp = new QMenu(parent);
+
+ //typedef std::multimap<std::string, int, addSynth_cmp_str > asmap;
+ typedef std::multimap<std::string, int > asmap;
+
+ //typedef std::multimap<std::string, int, addSynth_cmp_str >::iterator imap;
+ typedef std::multimap<std::string, int >::iterator imap;
+
+ MessSynth* synMESS = 0;
+ QMenu* synpMESS = 0;
+ asmap mapMESS;
+
+ #ifdef DSSI_SUPPORT
+ DssiSynth* synDSSI = 0;
+ QMenu* synpDSSI = 0;
+ asmap mapDSSI;
+ #endif
+
+ #ifdef VST_SUPPORT
+ VstSynth* synVST = 0;
+ QMenu* synpVST = 0;
+ asmap mapVST;
+ #endif
+
+ // Not necessary, but what the heck.
+ QMenu* synpOther = 0;
+ asmap mapOther;
+
+ //const int synth_base_id = 0x1000;
+ int ii = 0;
+ for(std::vector<Synth*>::iterator i = synthis.begin(); i != synthis.end(); ++i)
+ {
+ synMESS = dynamic_cast<MessSynth*>(*i);
+ if(synMESS)
+ {
+ mapMESS.insert( std::pair<std::string, int> (std::string(synMESS->description().toLower().toLatin1().constData()), ii) );
+ }
+ else
+ {
+
+ #ifdef DSSI_SUPPORT
+ synDSSI = dynamic_cast<DssiSynth*>(*i);
+ if(synDSSI)
+ {
+ mapDSSI.insert( std::pair<std::string, int> (std::string(synDSSI->description().toLower().toLatin1().constData()), ii) );
+ }
+ else
+ #endif
+
+ {
+ #ifdef VST_SUPPORT
+ synVST = dynamic_cast<VstSynth*>(*i);
+ if(synVST)
+ {
+ mapVST.insert( std::pair<std::string, int> (std::string(synVST->description().toLower().toLatin1().constData()), ii) );
+ }
+ else
+ #endif
+
+ {
+ mapOther.insert( std::pair<std::string, int> (std::string((*i)->description().toLower().toLatin1().constData()), ii) );
+ }
+ }
+ }
+
+ ++ii;
+ }
+
+ int sz = synthis.size();
+ for(imap i = mapMESS.begin(); i != mapMESS.end(); ++i)
+ {
+ int idx = i->second;
+ if(idx > sz) // Sanity check
+ continue;
+ Synth* s = synthis[idx];
+ if(s)
+ {
+ // No MESS sub-menu yet? Create it now.
+ if(!synpMESS)
+ synpMESS = new QMenu(parent);
+ QAction* sM = synpMESS->addAction(QT_TRANSLATE_NOOP("@default", s->description()) + " <" + QT_TRANSLATE_NOOP("@default", s->name()) + ">");
+ sM->setData(MENU_ADD_SYNTH_ID_BASE + idx);
+ }
+ }
+
+ #ifdef DSSI_SUPPORT
+ for(imap i = mapDSSI.begin(); i != mapDSSI.end(); ++i)
+ {
+ int idx = i->second;
+ if(idx > sz)
+ continue;
+ Synth* s = synthis[idx];
+ if(s)
+ {
+ // No DSSI sub-menu yet? Create it now.
+ if(!synpDSSI)
+ synpDSSI = new QMenu(parent);
+ //synpDSSI->insertItem(QT_TRANSLATE_NOOP("@default", s->description()) + " <" + QT_TRANSLATE_NOOP("@default", s->name()) + ">", MENU_ADD_SYNTH_ID_BASE + idx);
+ QAction* sD = synpDSSI->addAction(QT_TRANSLATE_NOOP("@default", s->description()) + " <" + QT_TRANSLATE_NOOP("@default", s->name()) + ">");
+ sD->setData(MENU_ADD_SYNTH_ID_BASE + idx);
+ }
+ }
+ #endif
+
+ #ifdef VST_SUPPORT
+ for(imap i = mapVST.begin(); i != mapVST.end(); ++i)
+ {
+ int idx = i->second;
+ if(idx > sz)
+ continue;
+ Synth* s = synthis[idx];
+ if(s)
+ {
+ // No VST sub-menu yet? Create it now.
+ if(!synpVST)
+ synpVST = new QMenu(parent);
+ QAction* sV = synpVST->addAction(QT_TRANSLATE_NOOP("@default", s->description()) + " <" + QT_TRANSLATE_NOOP("@default", s->name()) + ">");
+ sV->setData(MENU_ADD_SYNTH_ID_BASE + idx);
+ }
+ }
+ #endif
+
+ for(imap i = mapOther.begin(); i != mapOther.end(); ++i)
+ {
+ int idx = i->second;
+ if(idx > sz)
+ continue;
+ Synth* s = synthis[idx];
+ // No Other sub-menu yet? Create it now.
+ if(!synpOther)
+ synpOther = new QMenu(parent);
+ //synpOther->insertItem(QT_TRANSLATE_NOOP("@default", s->description()) + " <" + QT_TRANSLATE_NOOP("@default", s->name()) + ">", MENU_ADD_SYNTH_ID_BASE + idx);
+ QAction* sO = synpOther->addAction(QT_TRANSLATE_NOOP("@default", s->description()) + " <" + QT_TRANSLATE_NOOP("@default", s->name()) + ">");
+ sO->setData(MENU_ADD_SYNTH_ID_BASE + idx);
+ }
+
+ if(synpMESS)
+ {
+ synpMESS->setIcon(*synthIcon);
+ synpMESS->setTitle(QT_TRANSLATE_NOOP("@default", "MESS"));
+ synp->addMenu(synpMESS);
+ }
+
+ #ifdef DSSI_SUPPORT
+ if(synpDSSI)
+ {
+ synpDSSI->setIcon(*synthIcon);
+ synpDSSI->setTitle(QT_TRANSLATE_NOOP("@default", "DSSI"));
+ synp->addMenu(synpDSSI);
+ }
+ #endif
+
+ #ifdef VST_SUPPORT
+ if(synpVST)
+ {
+ synpVST->setIcon(*synthIcon);
+ synpVST->setTitle(QT_TRANSLATE_NOOP("@default", "FST"));
+ synp->addMenu(synpVST);
+ }
+ #endif
+
+ if(synpOther)
+ {
+ synpOther->setIcon(*synthIcon);
+ synpOther->setTitle(QObject::tr("Other"));
+ synp->addMenu(synpOther);
+ }
+
+ return synp;
+}
+
+//---------------------------------------------------------
+// populateAddTrack
+// this is also used in "mixer"
+//---------------------------------------------------------
+
+QActionGroup* populateAddTrack(QMenu* addTrack)
+ {
+ QActionGroup* grp = new QActionGroup(addTrack);
+
+ QAction* midi = addTrack->addAction(QIcon(*addtrack_addmiditrackIcon),
+ QT_TRANSLATE_NOOP("@default", "Add Midi Track"));
+ midi->setData(Track::MIDI);
+ grp->addAction(midi);
+ QAction* drum = addTrack->addAction(QIcon(*addtrack_drumtrackIcon),
+ QT_TRANSLATE_NOOP("@default", "Add Drum Track"));
+ drum->setData(Track::DRUM);
+ grp->addAction(drum);
+ QAction* wave = addTrack->addAction(QIcon(*addtrack_wavetrackIcon),
+ QT_TRANSLATE_NOOP("@default", "Add Wave Track"));
+ wave->setData(Track::WAVE);
+ grp->addAction(wave);
+ QAction* aoutput = addTrack->addAction(QIcon(*addtrack_audiooutputIcon),
+ QT_TRANSLATE_NOOP("@default", "Add Audio Output"));
+ aoutput->setData(Track::AUDIO_OUTPUT);
+ grp->addAction(aoutput);
+ QAction* agroup = addTrack->addAction(QIcon(*addtrack_audiogroupIcon),
+ QT_TRANSLATE_NOOP("@default", "Add Audio Group"));
+ agroup->setData(Track::AUDIO_GROUP);
+ grp->addAction(agroup);
+ QAction* ainput = addTrack->addAction(QIcon(*addtrack_audioinputIcon),
+ QT_TRANSLATE_NOOP("@default", "Add Audio Input"));
+ ainput->setData(Track::AUDIO_INPUT);
+ grp->addAction(ainput);
+ QAction* aaux = addTrack->addAction(QIcon(*addtrack_auxsendIcon),
+ QT_TRANSLATE_NOOP("@default", "Add Aux Send"));
+ aaux->setData(Track::AUDIO_AUX);
+ grp->addAction(aaux);
+
+ // Create a sub-menu and fill it with found synth types. Make addTrack the owner.
+ QMenu* synp = populateAddSynth(addTrack);
+ synp->setIcon(*synthIcon);
+ synp->setTitle(QT_TRANSLATE_NOOP("@default", "Add Synth"));
+
+ // Add the sub-menu to the given menu.
+ addTrack->addMenu(synp);
+
+ QObject::connect(addTrack, SIGNAL(triggered(QAction *)), song, SLOT(addNewTrack(QAction *)));
+
+ return grp;
+ }
+
+//---------------------------------------------------------
+// MusE
+//---------------------------------------------------------
+
+//MusE::MusE(int argc, char** argv) : QMainWindow(0, "mainwindow")
+MusE::MusE(int argc, char** argv) : QMainWindow()
+ {
+ // By T356. For LADSPA plugins in plugin.cpp
+ // QWidgetFactory::addWidgetFactory( new PluginWidgetFactory ); ddskrjo
+
+ setIconSize(ICON_SIZE);
+ setFocusPolicy(Qt::WheelFocus);
+ //setFocusPolicy(Qt::NoFocus);
+ muse = this; // hack
+ clipListEdit = 0;
+ midiSyncConfig = 0;
+ midiRemoteConfig = 0;
+ midiPortConfig = 0;
+ metronomeConfig = 0;
+ audioConfig = 0;
+ midiFileConfig = 0;
+ midiFilterConfig = 0;
+ midiInputTransform = 0;
+ midiRhythmGenerator = 0;
+ globalSettingsConfig = 0;
+ markerView = 0;
+ softSynthesizerConfig = 0;
+ midiTransformerDialog = 0;
+ shortcutConfig = 0;
+ appearance = 0;
+ //audioMixer = 0;
+ mixer1 = 0;
+ mixer2 = 0;
+ watchdogThread = 0;
+ editInstrument = 0;
+ routingPopupMenu = 0;
+ //routingPopupView = 0;
+
+ appName = QString("MusE");
+ setWindowTitle(appName);
+ editSignalMapper = new QSignalMapper(this);
+ midiPluginSignalMapper = new QSignalMapper(this);
+ followSignalMapper = new QSignalMapper(this);
+
+ song = new Song("song");
+ song->blockSignals(true);
+ heartBeatTimer = new QTimer(this);
+ heartBeatTimer->setObjectName("timer");
+ connect(heartBeatTimer, SIGNAL(timeout()), song, SLOT(beat()));
+
+#ifdef ENABLE_PYTHON
+ //---------------------------------------------------
+ // Python bridge
+ //---------------------------------------------------
+ // Uncomment in order to enable MusE Python bridge:
+ if (usePythonBridge) {
+ printf("Initializing python bridge!\n");
+ if (initPythonBridge() == false) {
+ printf("Could not initialize Python bridge\n");
+ exit(1);
+ }
+ }
+#endif
+
+ //---------------------------------------------------
+ // undo/redo
+ //---------------------------------------------------
+
+ undoRedo = new QActionGroup(this);
+ undoRedo->setExclusive(false);
+ undoAction = new QAction(QIcon(*undoIconS), tr("Und&o"),
+ undoRedo);
+ redoAction = new QAction(QIcon(*redoIconS), tr("Re&do"),
+ undoRedo);
+
+ undoAction->setWhatsThis(tr("undo last change to song"));
+ redoAction->setWhatsThis(tr("redo last undo"));
+ undoAction->setEnabled(false);
+ redoAction->setEnabled(false);
+ connect(redoAction, SIGNAL(activated()), song, SLOT(redo()));
+ connect(undoAction, SIGNAL(activated()), song, SLOT(undo()));
+
+ //---------------------------------------------------
+ // Transport
+ //---------------------------------------------------
+
+ transportAction = new QActionGroup(this);
+ transportAction->setExclusive(false);
+
+ loopAction = new QAction(QIcon(*loop1Icon),
+ tr("Loop"), transportAction);
+ loopAction->setCheckable(true);
+
+ loopAction->setWhatsThis(tr(infoLoopButton));
+ connect(loopAction, SIGNAL(toggled(bool)), song, SLOT(setLoop(bool)));
+
+ punchinAction = new QAction(QIcon(*punchin1Icon),
+ tr("Punchin"), transportAction);
+ punchinAction->setCheckable(true);
+
+ punchinAction->setWhatsThis(tr(infoPunchinButton));
+ connect(punchinAction, SIGNAL(toggled(bool)), song, SLOT(setPunchin(bool)));
+
+ punchoutAction = new QAction(QIcon(*punchout1Icon),
+ tr("Punchout"), transportAction);
+ punchoutAction->setCheckable(true);
+
+ punchoutAction->setWhatsThis(tr(infoPunchoutButton));
+ connect(punchoutAction, SIGNAL(toggled(bool)), song, SLOT(setPunchout(bool)));
+
+ QAction *tseparator = new QAction(this);
+ tseparator->setSeparator(true);
+ transportAction->addAction(tseparator);
+
+ startAction = new QAction(QIcon(*startIcon),
+ tr("Start"), transportAction);
+
+ startAction->setWhatsThis(tr(infoStartButton));
+ connect(startAction, SIGNAL(activated()), song, SLOT(rewindStart()));
+
+ rewindAction = new QAction(QIcon(*frewindIcon),
+ tr("Rewind"), transportAction);
+
+ rewindAction->setWhatsThis(tr(infoRewindButton));
+ connect(rewindAction, SIGNAL(activated()), song, SLOT(rewind()));
+
+ forwardAction = new QAction(QIcon(*fforwardIcon),
+ tr("Forward"), transportAction);
+
+ forwardAction->setWhatsThis(tr(infoForwardButton));
+ connect(forwardAction, SIGNAL(activated()), song, SLOT(forward()));
+
+ stopAction = new QAction(QIcon(*stopIcon),
+ tr("Stop"), transportAction);
+ stopAction->setCheckable(true);
+
+ stopAction->setWhatsThis(tr(infoStopButton));
+ stopAction->setChecked(true);
+ connect(stopAction, SIGNAL(toggled(bool)), song, SLOT(setStop(bool)));
+
+ playAction = new QAction(QIcon(*playIcon),
+ tr("Play"), transportAction);
+ playAction->setCheckable(true);
+
+ playAction->setWhatsThis(tr(infoPlayButton));
+ playAction->setChecked(false);
+ connect(playAction, SIGNAL(toggled(bool)), song, SLOT(setPlay(bool)));
+
+ recordAction = new QAction(QIcon(*recordIcon),
+ tr("Record"), transportAction);
+ recordAction->setCheckable(true);
+ recordAction->setWhatsThis(tr(infoRecordButton));
+ connect(recordAction, SIGNAL(toggled(bool)), song, SLOT(setRecord(bool)));
+
+ panicAction = new QAction(QIcon(*panicIcon),
+ tr("Panic"), this);
+
+ panicAction->setWhatsThis(tr(infoPanicButton));
+ connect(panicAction, SIGNAL(activated()), song, SLOT(panic()));
+
+ initMidiInstruments();
+ initMidiPorts();
+ ::initMidiDevices();
+
+ //----Actions
+ //-------- File Actions
+
+ fileNewAction = new QAction(QIcon(*filenewIcon), tr("&New"), this);
+ fileNewAction->setToolTip(tr(fileNewText));
+ fileNewAction->setWhatsThis(tr(fileNewText));
+
+ fileOpenAction = new QAction(QIcon(*openIcon), tr("&Open"), this);
+
+ fileOpenAction->setToolTip(tr(fileOpenText));
+ fileOpenAction->setWhatsThis(tr(fileOpenText));
+
+ openRecent = new QMenu(tr("Open &Recent"), this);
+
+ fileSaveAction = new QAction(QIcon(*saveIcon), tr("&Save"), this);
+
+ fileSaveAction->setToolTip(tr(fileSaveText));
+ fileSaveAction->setWhatsThis(tr(fileSaveText));
+
+ fileSaveAsAction = new QAction(tr("Save &As"), this);
+
+ fileImportMidiAction = new QAction(tr("Import Midifile"), this);
+ fileExportMidiAction = new QAction(tr("Export Midifile"), this);
+ fileImportPartAction = new QAction(tr("Import Part"), this);
+
+ fileImportWaveAction = new QAction(tr("Import Wave File"), this);
+
+ quitAction = new QAction(tr("&Quit"), this);
+
+ //-------- Edit Actions
+ editCutAction = new QAction(QIcon(*editcutIconSet), tr("C&ut"), this);
+ editCopyAction = new QAction(QIcon(*editcopyIconSet), tr("&Copy"), this);
+ editPasteAction = new QAction(QIcon(*editpasteIconSet), tr("&Paste"), this);
+ editInsertAction = new QAction(QIcon(*editpasteIconSet), tr("&Insert"), this);
+ editPasteCloneAction = new QAction(QIcon(*editpasteCloneIconSet), tr("Paste c&lone"), this);
+ editPaste2TrackAction = new QAction(QIcon(*editpaste2TrackIconSet), tr("Paste to &track"), this);
+ editPasteC2TAction = new QAction(QIcon(*editpasteClone2TrackIconSet), tr("Paste clone to trac&k"), this);
+ editInsertEMAction = new QAction(QIcon(*editpasteIconSet), tr("&Insert Empty Measure"), this);
+ editDeleteSelectedAction = new QAction(QIcon(*edit_track_delIcon), tr("Delete Selected Tracks"), this);
+
+
+ addTrack = new QMenu(tr("Add Track"), this);
+ addTrack->setIcon(QIcon(*edit_track_addIcon));
+ select = new QMenu(tr("Select"), this);
+ select->setIcon(QIcon(*selectIcon));
+
+ editSelectAllAction = new QAction(QIcon(*select_allIcon), tr("Select &All"), this);
+ editDeselectAllAction = new QAction(QIcon(*select_deselect_allIcon), tr("&Deselect All"), this);
+ editInvertSelectionAction = new QAction(QIcon(*select_invert_selectionIcon), tr("Invert &Selection"), this);
+ editInsideLoopAction = new QAction(QIcon(*select_inside_loopIcon), tr("&Inside Loop"), this);
+ editOutsideLoopAction = new QAction(QIcon(*select_outside_loopIcon), tr("&Outside Loop"), this);
+ editAllPartsAction = new QAction( QIcon(*select_all_parts_on_trackIcon), tr("All &Parts on Track"), this);
+
+ startPianoEditAction = new QAction(*pianoIconSet, tr("Pianoroll"), this);
+ startDrumEditAction = new QAction(QIcon(*edit_drummsIcon), tr("Drums"), this);
+ startListEditAction = new QAction(QIcon(*edit_listIcon), tr("List"), this);
+ startWaveEditAction = new QAction(QIcon(*edit_waveIcon), tr("Wave"), this);
+
+ master = new QMenu(tr("Mastertrack"), this);
+ master->setIcon(QIcon(*edit_mastertrackIcon));
+ masterGraphicAction = new QAction(QIcon(*mastertrack_graphicIcon),tr("Graphic"), this);
+ masterListAction = new QAction(QIcon(*mastertrack_listIcon),tr("List"), this);
+
+ midiEdit = new QMenu(tr("Midi"), this);
+ midiEdit->setIcon(QIcon(*edit_midiIcon));
+
+ midiTransposeAction = new QAction(QIcon(*midi_transposeIcon), tr("Transpose"), this);
+ midiTransformerAction = new QAction(QIcon(*midi_transformIcon), tr("Midi &Transform"), this);
+
+ editSongInfoAction = new QAction(QIcon(*edit_listIcon), tr("Song Info"), this);
+
+ //-------- View Actions
+ viewTransportAction = new QAction(QIcon(*view_transport_windowIcon), tr("Transport Panel"), this);
+ viewTransportAction->setCheckable(true);
+ viewBigtimeAction = new QAction(QIcon(*view_bigtime_windowIcon), tr("Bigtime Window"), this);
+ viewBigtimeAction->setCheckable(true);
+ viewMixerAAction = new QAction(QIcon(*mixerSIcon), tr("Mixer A"), this);
+ viewMixerAAction->setCheckable(true);
+ viewMixerBAction = new QAction(QIcon(*mixerSIcon), tr("Mixer B"), this);
+ viewMixerBAction->setCheckable(true);
+ viewCliplistAction = new QAction(QIcon(*cliplistSIcon), tr("Cliplist"), this);
+ viewCliplistAction->setCheckable(true);
+ viewMarkerAction = new QAction(QIcon(*view_markerIcon), tr("Marker View"), this);
+ viewMarkerAction->setCheckable(true);
+
+ //-------- Structure Actions
+ strGlobalCutAction = new QAction(tr("Global Cut"), this);
+ strGlobalInsertAction = new QAction(tr("Global Insert"), this);
+ strGlobalSplitAction = new QAction(tr("Global Split"), this);
+ strCopyRangeAction = new QAction(tr("Copy Range"), this);
+ strCopyRangeAction->setEnabled(false);
+ strCutEventsAction = new QAction(tr("Cut Events"), this);
+ strCutEventsAction->setEnabled(false);
+
+ //-------- Midi Actions
+ menuScriptPlugins = new QMenu(tr("&Plugins"), this);
+ midiEditInstAction = new QAction(QIcon(*midi_edit_instrumentIcon), tr("Edit Instrument"), this);
+ midiInputPlugins = new QMenu(tr("Input Plugins"), this);
+ midiInputPlugins->setIcon(QIcon(*midi_inputpluginsIcon));
+ midiTrpAction = new QAction(QIcon(*midi_inputplugins_transposeIcon), tr("Transpose"), this);
+ midiInputTrfAction = new QAction(QIcon(*midi_inputplugins_midi_input_transformIcon), tr("Midi Input Transform"), this);
+ midiInputFilterAction = new QAction(QIcon(*midi_inputplugins_midi_input_filterIcon), tr("Midi Input Filter"), this);
+ midiRemoteAction = new QAction(QIcon(*midi_inputplugins_remote_controlIcon), tr("Midi Remote Control"), this);
+#ifdef BUILD_EXPERIMENTAL
+ midiRhythmAction = new QAction(QIcon(*midi_inputplugins_random_rhythm_generatorIcon), tr("Rhythm Generator"), this);
+#endif
+ midiResetInstAction = new QAction(QIcon(*midi_reset_instrIcon), tr("Reset Instr."), this);
+ midiInitInstActions = new QAction(QIcon(*midi_init_instrIcon), tr("Init Instr."), this);
+ midiLocalOffAction = new QAction(QIcon(*midi_local_offIcon), tr("Local Off"), this);
+
+ //-------- Audio Actions
+ audioBounce2TrackAction = new QAction(QIcon(*audio_bounce_to_trackIcon), tr("Bounce to Track"), this);
+ audioBounce2FileAction = new QAction(QIcon(*audio_bounce_to_fileIcon), tr("Bounce to File"), this);
+ audioRestartAction = new QAction(QIcon(*audio_restartaudioIcon), tr("Restart Audio"), this);
+
+ //-------- Automation Actions
+ autoMixerAction = new QAction(QIcon(*automation_mixerIcon), tr("Mixer Automation"), this);
+ autoMixerAction->setCheckable(true);
+ autoSnapshotAction = new QAction(QIcon(*automation_take_snapshotIcon), tr("Take Snapshot"), this);
+ autoClearAction = new QAction(QIcon(*automation_clear_dataIcon), tr("Clear Automation Data"), this);
+ autoClearAction->setEnabled(false);
+
+ //-------- Settings Actions
+ settingsGlobalAction = new QAction(QIcon(*settings_globalsettingsIcon), tr("Global Settings"), this);
+ settingsShortcutsAction = new QAction(QIcon(*settings_configureshortcutsIcon), tr("Configure Shortcuts"), this);
+ follow = new QMenu(tr("Follow Song"), this);
+ dontFollowAction = new QAction(tr("Don't Follow Song"), this);
+ dontFollowAction->setCheckable(true);
+ followPageAction = new QAction(tr("Follow Page"), this);
+ followPageAction->setCheckable(true);
+ followPageAction->setChecked(true);
+ followCtsAction = new QAction(tr("Follow Continuous"), this);
+ followCtsAction->setCheckable(true);
+
+ settingsMetronomeAction = new QAction(QIcon(*settings_metronomeIcon), tr("Metronome"), this);
+ settingsMidiSyncAction = new QAction(QIcon(*settings_midisyncIcon), tr("Midi Sync"), this);
+ settingsMidiIOAction = new QAction(QIcon(*settings_midifileexportIcon), tr("Midi File Import/Export"), this);
+ settingsAppearanceAction = new QAction(QIcon(*settings_appearance_settingsIcon), tr("Appearance Settings"), this);
+ settingsMidiPortAction = new QAction(QIcon(*settings_midiport_softsynthsIcon), tr("Midi Ports / Soft Synth"), this);
+
+ //-------- Help Actions
+ helpManualAction = new QAction(tr("&Manual"), this);
+ helpHomepageAction = new QAction(tr("&MusE Homepage"), this);
+ helpReportAction = new QAction(tr("&Report Bug..."), this);
+ helpAboutAction = new QAction(tr("&About MusE"), this);
+
+
+ //---- Connections
+ //-------- File connections
+
+ connect(fileNewAction, SIGNAL(activated()), SLOT(loadTemplate()));
+ connect(fileOpenAction, SIGNAL(activated()), SLOT(loadProject()));
+ connect(openRecent, SIGNAL(aboutToShow()), SLOT(openRecentMenu()));
+ connect(openRecent, SIGNAL(triggered(QAction*)), SLOT(selectProject(QAction*)));
+
+ connect(fileSaveAction, SIGNAL(activated()), SLOT(save()));
+ connect(fileSaveAsAction, SIGNAL(activated()), SLOT(saveAs()));
+
+ connect(fileImportMidiAction, SIGNAL(activated()), SLOT(importMidi()));
+ connect(fileExportMidiAction, SIGNAL(activated()), SLOT(exportMidi()));
+ connect(fileImportPartAction, SIGNAL(activated()), SLOT(importPart()));
+
+ connect(fileImportWaveAction, SIGNAL(activated()), SLOT(importWave()));
+ connect(quitAction, SIGNAL(activated()), SLOT(quitDoc()));
+
+ //-------- Edit connections
+ connect(editCutAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ connect(editCopyAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ connect(editPasteAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ connect(editInsertAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ connect(editPasteCloneAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ connect(editPaste2TrackAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ connect(editPasteC2TAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ connect(editInsertEMAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ connect(editDeleteSelectedAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+
+ connect(editSelectAllAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ connect(editDeselectAllAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ connect(editInvertSelectionAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ connect(editInsideLoopAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ connect(editOutsideLoopAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ connect(editAllPartsAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+
+ editSignalMapper->setMapping(editCutAction, CMD_CUT);
+ editSignalMapper->setMapping(editCopyAction, CMD_COPY);
+ editSignalMapper->setMapping(editPasteAction, CMD_PASTE);
+ editSignalMapper->setMapping(editInsertAction, CMD_INSERT);
+ editSignalMapper->setMapping(editPasteCloneAction, CMD_PASTE_CLONE);
+ editSignalMapper->setMapping(editPaste2TrackAction, CMD_PASTE_TO_TRACK);
+ editSignalMapper->setMapping(editPasteC2TAction, CMD_PASTE_CLONE_TO_TRACK);
+ editSignalMapper->setMapping(editInsertEMAction, CMD_INSERTMEAS);
+ editSignalMapper->setMapping(editDeleteSelectedAction, CMD_DELETE_TRACK);
+ editSignalMapper->setMapping(editSelectAllAction, CMD_SELECT_ALL);
+ editSignalMapper->setMapping(editDeselectAllAction, CMD_SELECT_NONE);
+ editSignalMapper->setMapping(editInvertSelectionAction, CMD_SELECT_INVERT);
+ editSignalMapper->setMapping(editInsideLoopAction, CMD_SELECT_ILOOP);
+ editSignalMapper->setMapping(editOutsideLoopAction, CMD_SELECT_OLOOP);
+ editSignalMapper->setMapping(editAllPartsAction, CMD_SELECT_PARTS);
+
+ connect(editSignalMapper, SIGNAL(mapped(int)), this, SLOT(cmd(int)));
+
+ connect(startPianoEditAction, SIGNAL(activated()), SLOT(startPianoroll()));
+ connect(startDrumEditAction, SIGNAL(activated()), SLOT(startDrumEditor()));
+ connect(startListEditAction, SIGNAL(activated()), SLOT(startListEditor()));
+ connect(startWaveEditAction, SIGNAL(activated()), SLOT(startWaveEditor()));
+
+ connect(masterGraphicAction, SIGNAL(activated()), SLOT(startMasterEditor()));
+ connect(masterListAction, SIGNAL(activated()), SLOT(startLMasterEditor()));
+
+ connect(midiTransposeAction, SIGNAL(activated()), SLOT(transpose()));
+ connect(midiTransformerAction, SIGNAL(activated()), SLOT(startMidiTransformer()));
+
+ connect(editSongInfoAction, SIGNAL(activated()), SLOT(startSongInfo()));
+
+ //-------- View connections
+ connect(viewTransportAction, SIGNAL(toggled(bool)), SLOT(toggleTransport(bool)));
+ connect(viewBigtimeAction, SIGNAL(toggled(bool)), SLOT(toggleBigTime(bool)));
+ connect(viewMixerAAction, SIGNAL(toggled(bool)),SLOT(toggleMixer1(bool)));
+ connect(viewMixerBAction, SIGNAL(toggled(bool)), SLOT(toggleMixer2(bool)));
+ connect(viewCliplistAction, SIGNAL(toggled(bool)), SLOT(startClipList(bool)));
+ connect(viewMarkerAction, SIGNAL(toggled(bool)), SLOT(toggleMarker(bool)));
+
+ //-------- Structure connections
+ connect(strGlobalCutAction, SIGNAL(activated()), SLOT(globalCut()));
+ connect(strGlobalInsertAction, SIGNAL(activated()), SLOT(globalInsert()));
+ connect(strGlobalSplitAction, SIGNAL(activated()), SLOT(globalSplit()));
+ connect(strCopyRangeAction, SIGNAL(activated()), SLOT(copyRange()));
+ connect(strCutEventsAction, SIGNAL(activated()), SLOT(cutEvents()));
+
+ //-------- Midi connections
+ connect(midiEditInstAction, SIGNAL(activated()), SLOT(startEditInstrument()));
+ connect(midiResetInstAction, SIGNAL(activated()), SLOT(resetMidiDevices()));
+ connect(midiInitInstActions, SIGNAL(activated()), SLOT(initMidiDevices()));
+ connect(midiLocalOffAction, SIGNAL(activated()), SLOT(localOff()));
+
+ connect(midiTrpAction, SIGNAL(triggered()), midiPluginSignalMapper, SLOT(map()));
+ connect(midiInputTrfAction, SIGNAL(triggered()), midiPluginSignalMapper, SLOT(map()));
+ connect(midiInputFilterAction, SIGNAL(triggered()), midiPluginSignalMapper, SLOT(map()));
+ connect(midiRemoteAction, SIGNAL(triggered()), midiPluginSignalMapper, SLOT(map()));
+
+ midiPluginSignalMapper->setMapping(midiTrpAction, 0);
+ midiPluginSignalMapper->setMapping(midiInputTrfAction, 1);
+ midiPluginSignalMapper->setMapping(midiInputFilterAction, 2);
+ midiPluginSignalMapper->setMapping(midiRemoteAction, 3);
+
+#ifdef BUILD_EXPERIMENTAL
+ connect(midiRhythmAction, SIGNAL(triggered()), midiPluginSignalMapper, SLOT(map()));
+ midiPluginSignalMapper->setMapping(midiRhythmAction, 4);
+#endif
+
+ connect(midiPluginSignalMapper, SIGNAL(mapped(int)), this, SLOT(startMidiInputPlugin(int)));
+
+ //-------- Audio connections
+ connect(audioBounce2TrackAction, SIGNAL(activated()), SLOT(bounceToTrack()));
+ connect(audioBounce2FileAction, SIGNAL(activated()), SLOT(bounceToFile()));
+ connect(audioRestartAction, SIGNAL(activated()), SLOT(seqRestart()));
+
+ //-------- Automation connections
+ connect(autoMixerAction, SIGNAL(activated()), SLOT(switchMixerAutomation()));
+ connect(autoSnapshotAction, SIGNAL(activated()), SLOT(takeAutomationSnapshot()));
+ connect(autoClearAction, SIGNAL(activated()), SLOT(clearAutomation()));
+
+ //-------- Settings connections
+ connect(settingsGlobalAction, SIGNAL(activated()), SLOT(configGlobalSettings()));
+ connect(settingsShortcutsAction, SIGNAL(activated()), SLOT(configShortCuts()));
+ connect(settingsMetronomeAction, SIGNAL(activated()), SLOT(configMetronome()));
+ connect(settingsMidiSyncAction, SIGNAL(activated()), SLOT(configMidiSync()));
+ connect(settingsMidiIOAction, SIGNAL(activated()), SLOT(configMidiFile()));
+ connect(settingsAppearanceAction, SIGNAL(activated()), SLOT(configAppearance()));
+ connect(settingsMidiPortAction, SIGNAL(activated()), SLOT(configMidiPorts()));
+
+ connect(dontFollowAction, SIGNAL(triggered()), followSignalMapper, SLOT(map()));
+ connect(followPageAction, SIGNAL(triggered()), followSignalMapper, SLOT(map()));
+ connect(followCtsAction, SIGNAL(triggered()), followSignalMapper, SLOT(map()));
+
+ followSignalMapper->setMapping(dontFollowAction, CMD_FOLLOW_NO);
+ followSignalMapper->setMapping(followPageAction, CMD_FOLLOW_JUMP);
+ followSignalMapper->setMapping(followCtsAction, CMD_FOLLOW_CONTINUOUS);
+
+ connect(followSignalMapper, SIGNAL(mapped(int)), this, SLOT(cmd(int)));
+
+ //-------- Help connections
+ connect(helpManualAction, SIGNAL(activated()), SLOT(startHelpBrowser()));
+ connect(helpHomepageAction, SIGNAL(activated()), SLOT(startHomepageBrowser()));
+ connect(helpReportAction, SIGNAL(activated()), SLOT(startBugBrowser()));
+ connect(helpAboutAction, SIGNAL(activated()), SLOT(about()));
+
+ //--------------------------------------------------
+ // Miscellaneous shortcuts
+ //--------------------------------------------------
+
+ QShortcut* sc = new QShortcut(shortcuts[SHRT_DELETE].key, this);
+ sc->setContext(Qt::WindowShortcut);
+ connect(sc, SIGNAL(activated()), editSignalMapper, SLOT(map()));
+ editSignalMapper->setMapping(sc, CMD_DELETE);
+
+ //--------------------------------------------------
+ // Toolbar
+ //--------------------------------------------------
+
+ tools = addToolBar(tr("File Buttons"));
+ tools->addAction(fileNewAction);
+ tools->addAction(fileOpenAction);
+ tools->addAction(fileSaveAction);
+
+ //
+ // Whats This
+ //
+ tools->addAction(QWhatsThis::createAction(this));
+
+ tools->addSeparator();
+ tools->addActions(undoRedo->actions());
+
+ tools1 = new EditToolBar(this, arrangerTools);
+ addToolBar(tools1);
+
+ QToolBar* transportToolbar = addToolBar(tr("Transport"));
+ transportToolbar->addActions(transportAction->actions());
+
+ QToolBar* panicToolbar = addToolBar(tr("Panic"));
+ panicToolbar->addAction(panicAction);
+
+ if (realTimePriority < sched_get_priority_min(SCHED_FIFO))
+ realTimePriority = sched_get_priority_min(SCHED_FIFO);
+ else if (realTimePriority > sched_get_priority_max(SCHED_FIFO))
+ realTimePriority = sched_get_priority_max(SCHED_FIFO);
+
+ // If we requested to force the midi thread priority...
+ if(midiRTPrioOverride > 0)
+ {
+ if (midiRTPrioOverride < sched_get_priority_min(SCHED_FIFO))
+ midiRTPrioOverride = sched_get_priority_min(SCHED_FIFO);
+ else if (midiRTPrioOverride > sched_get_priority_max(SCHED_FIFO))
+ midiRTPrioOverride = sched_get_priority_max(SCHED_FIFO);
+ }
+
+ // Changed by Tim. p3.3.17
+ //midiSeq = new MidiSeq(realTimeScheduling ? realTimePriority : 0, "Midi");
+ midiSeq = new MidiSeq("Midi");
+ audio = new Audio();
+ //audioPrefetch = new AudioPrefetch(0, "Disc");
+ audioPrefetch = new AudioPrefetch("Prefetch");
+
+ //---------------------------------------------------
+ // Popups
+ //---------------------------------------------------
+
+// QPopupMenu *foo = new QPopupMenu(this);
+// testAction = new QAction(foo,"testPython");
+// testAction->addTo(foo);
+// menuBar()->insertItem(tr("&testpython"), foo);
+// connect(testAction, SIGNAL(activated()), this, SLOT(runPythonScript()));
+
+
+ //-------------------------------------------------------------
+ // popup File
+ //-------------------------------------------------------------
+
+ menu_file = menuBar()->addMenu(tr("&File"));
+ menu_file->addAction(fileNewAction);
+ menu_file->addAction(fileOpenAction);
+ menu_file->addMenu(openRecent);
+ menu_file->addSeparator();
+ menu_file->addAction(fileSaveAction);
+ menu_file->addAction(fileSaveAsAction);
+ menu_file->addSeparator();
+ menu_file->addAction(fileImportMidiAction);
+ menu_file->addAction(fileExportMidiAction);
+ menu_file->addAction(fileImportPartAction);
+ menu_file->addSeparator();
+ menu_file->addAction(fileImportWaveAction);
+ menu_file->addSeparator();
+ menu_file->addAction(quitAction);
+ menu_file->addSeparator();
+
+ //-------------------------------------------------------------
+ // popup Edit
+ //-------------------------------------------------------------
+
+ menuEdit = menuBar()->addMenu(tr("&Edit"));
+ menuEdit->addActions(undoRedo->actions());
+ menuEdit->addSeparator();
+
+ menuEdit->addAction(editCutAction);
+ menuEdit->addAction(editCopyAction);
+ menuEdit->addAction(editPasteAction);
+ menuEdit->addAction(editInsertAction);
+ menuEdit->addAction(editPasteCloneAction);
+ menuEdit->addAction(editPaste2TrackAction);
+ menuEdit->addAction(editPasteC2TAction);
+ menuEdit->addAction(editInsertEMAction);
+ menuEdit->addSeparator();
+ menuEdit->addAction(editDeleteSelectedAction);
+
+ // Moved below. Have to wait until synths are available...
+ //populateAddTrack(addTrack);
+ menuEdit->addMenu(addTrack);
+ menuEdit->addMenu(select);
+ select->addAction(editSelectAllAction);
+ select->addAction(editDeselectAllAction);
+ select->addAction(editInvertSelectionAction);
+ select->addAction(editInsideLoopAction);
+ select->addAction(editOutsideLoopAction);
+ select->addAction(editAllPartsAction);
+ menuEdit->addSeparator();
+
+ menuEdit->addAction(startPianoEditAction);
+ menuEdit->addAction(startDrumEditAction);
+ menuEdit->addAction(startListEditAction);
+ menuEdit->addAction(startWaveEditAction);
+
+ menuEdit->addMenu(master);
+ master->addAction(masterGraphicAction);
+ master->addAction(masterListAction);
+ menuEdit->addSeparator();
+
+
+ menuEdit->addMenu(midiEdit);
+#if 0 // TODO
+ midiEdit->insertItem(tr("Modify Gate Time"), this, SLOT(modifyGateTime()));
+ midiEdit->insertItem(tr("Modify Velocity"), this, SLOT(modifyVelocity()));
+ midiEdit->insertItem(tr("Crescendo"), this, SLOT(crescendo()));
+ midiEdit->insertItem(tr("Transpose"), this, SLOT(transpose()));
+ midiEdit->insertItem(tr("Thin Out"), this, SLOT(thinOut()));
+ midiEdit->insertItem(tr("Erase Event"), this, SLOT(eraseEvent()));
+ midiEdit->insertItem(tr("Note Shift"), this, SLOT(noteShift()));
+ midiEdit->insertItem(tr("Move Clock"), this, SLOT(moveClock()));
+ midiEdit->insertItem(tr("Copy Measure"), this, SLOT(copyMeasure()));
+ midiEdit->insertItem(tr("Erase Measure"), this, SLOT(eraseMeasure()));
+ midiEdit->insertItem(tr("Delete Measure"), this, SLOT(deleteMeasure()));
+ midiEdit->insertItem(tr("Create Measure"), this, SLOT(createMeasure()));
+ midiEdit->insertItem(tr("Mix Track"), this, SLOT(mixTrack()));
+#endif
+ midiEdit->addAction(midiTransposeAction);
+ midiEdit->addAction(midiTransformerAction);
+
+ menuEdit->addAction(editSongInfoAction);
+
+ //-------------------------------------------------------------
+ // popup View
+ //-------------------------------------------------------------
+
+ menuView = menuBar()->addMenu(tr("View"));
+ //menuView->setCheckable(true);// not necessary with Qt4
+
+ menuView->addAction(viewTransportAction);
+ menuView->addAction(viewBigtimeAction);
+ menuView->addAction(viewMixerAAction);
+ menuView->addAction(viewMixerBAction);
+ menuView->addAction(viewCliplistAction);
+ menuView->addAction(viewMarkerAction);
+
+
+ //-------------------------------------------------------------
+ // popup Structure
+ //-------------------------------------------------------------
+
+ menuStructure = menuBar()->addMenu(tr("&Structure"));
+ menuStructure->addAction(strGlobalCutAction);
+ menuStructure->addAction(strGlobalInsertAction);
+ menuStructure->addAction(strGlobalSplitAction);
+ menuStructure->addAction(strCopyRangeAction);
+ menuStructure->addSeparator();
+ menuStructure->addAction(strCutEventsAction);
+
+ //-------------------------------------------------------------
+ // popup Midi
+ //-------------------------------------------------------------
+
+ menu_functions = menuBar()->addMenu(tr("&Midi"));
+ song->populateScriptMenu(menuScriptPlugins, this);
+ menu_functions->addMenu(menuScriptPlugins);
+ menu_functions->addAction(midiEditInstAction);
+ menu_functions->addMenu(midiInputPlugins);
+ midiInputPlugins->addAction(midiTrpAction);
+ midiInputPlugins->addAction(midiInputTrfAction);
+ midiInputPlugins->addAction(midiInputFilterAction);
+ midiInputPlugins->addAction(midiRemoteAction);
+#ifdef BUILD_EXPERIMENTAL
+ midiInputPlugins->addAction(midiRhythmAction);
+#endif
+
+ menu_functions->addSeparator();
+ menu_functions->addAction(midiResetInstAction);
+ menu_functions->addAction(midiInitInstActions);
+ menu_functions->addAction(midiLocalOffAction);
+ /*
+ ** mpid4 = midiInputPlugins->insertItem(
+ ** QIconSet(*midi_inputplugins_random_rhythm_generatorIcon), tr("Random Rhythm Generator"), 4);
+ */
+
+ //-------------------------------------------------------------
+ // popup Audio
+ //-------------------------------------------------------------
+
+ menu_audio = menuBar()->addMenu(tr("&Audio"));
+ menu_audio->addAction(audioBounce2TrackAction);
+ menu_audio->addAction(audioBounce2FileAction);
+ menu_audio->addSeparator();
+ menu_audio->addAction(audioRestartAction);
+
+
+ //-------------------------------------------------------------
+ // popup Automation
+ //-------------------------------------------------------------
+
+ menuAutomation = menuBar()->addMenu(tr("Automation"));
+ menuAutomation->addAction(autoMixerAction);
+ menuAutomation->addSeparator();
+ menuAutomation->addAction(autoSnapshotAction);
+ menuAutomation->addAction(autoClearAction);
+
+ //-------------------------------------------------------------
+ // popup Settings
+ //-------------------------------------------------------------
+
+ menuSettings = menuBar()->addMenu(tr("Settings"));
+ menuSettings->addAction(settingsGlobalAction);
+ menuSettings->addAction(settingsShortcutsAction);
+ menuSettings->addMenu(follow);
+ follow->addAction(dontFollowAction);
+ follow->addAction(followPageAction);
+ follow->addAction(followCtsAction);
+ menuSettings->addAction(settingsMetronomeAction);
+ menuSettings->addSeparator();
+ menuSettings->addAction(settingsMidiSyncAction);
+ menuSettings->addAction(settingsMidiIOAction);
+ menuSettings->addSeparator();
+ menuSettings->addAction(settingsAppearanceAction);
+ menuSettings->addSeparator();
+ menuSettings->addAction(settingsMidiPortAction);
+
+ //---------------------------------------------------
+ // popup Help
+ //---------------------------------------------------
+
+ menu_help = menuBar()->addMenu(tr("&Help"));
+ menu_help->addAction(helpManualAction);
+ menu_help->addAction(helpHomepageAction);
+ menu_help->addSeparator();
+ menu_help->addAction(helpReportAction);
+ menu_help->addSeparator();
+ menu_help->addAction(helpAboutAction);
+
+ //menu_help->insertItem(tr("About&Qt"), this, SLOT(aboutQt()));
+ //menu_help->addSeparator();
+ //menu_ids[CMD_START_WHATSTHIS] = menu_help->insertItem(tr("What's &This?"), this, SLOT(whatsThis()), 0);
+
+ //---------------------------------------------------
+ // Central Widget
+ //---------------------------------------------------
+
+ arranger = new Arranger(this, "arranger");
+ setCentralWidget(arranger);
+
+ connect(tools1, SIGNAL(toolChanged(int)), arranger, SLOT(setTool(int)));
+ connect(arranger, SIGNAL(editPart(Track*)), SLOT(startEditor(Track*)));
+ connect(arranger, SIGNAL(dropSongFile(const QString&)), SLOT(loadProjectFile(const QString&)));
+ connect(arranger, SIGNAL(dropMidiFile(const QString&)), SLOT(importMidi(const QString&)));
+ connect(arranger, SIGNAL(startEditor(PartList*,int)), SLOT(startEditor(PartList*,int)));
+ connect(arranger, SIGNAL(toolChanged(int)), tools1, SLOT(set(int)));
+ connect(this, SIGNAL(configChanged()), arranger, SLOT(configChanged()));
+
+ connect(arranger, SIGNAL(setUsedTool(int)), SLOT(setUsedTool(int)));
+
+ //---------------------------------------------------
+ // read list of "Recent Projects"
+ //---------------------------------------------------
+
+ QString prjPath(configPath);
+ prjPath += QString("/projects");
+ FILE* f = fopen(prjPath.toLatin1().constData(), "r");
+ if (f == 0) {
+ perror("open projectfile");
+ for (int i = 0; i < PROJECT_LIST_LEN; ++i)
+ projectList[i] = 0;
+ }
+ else {
+ for (int i = 0; i < PROJECT_LIST_LEN; ++i) {
+ char buffer[256];
+ if (fgets(buffer, 256, f)) {
+ int n = strlen(buffer);
+ if (n && buffer[n-1] == '\n')
+ buffer[n-1] = 0;
+ projectList[i] = *buffer ? new QString(buffer) : 0;
+ }
+ else
+ break;
+ }
+ fclose(f);
+ }
+
+ initMidiSynth();
+
+ QActionGroup *grp = populateAddTrack(addTrack);
+
+ trackMidiAction = grp->actions()[0];
+ trackDrumAction = grp->actions()[1];
+ trackWaveAction = grp->actions()[2];
+ trackAOutputAction = grp->actions()[3];
+ trackAGroupAction = grp->actions()[4];
+ trackAInputAction = grp->actions()[5];
+ trackAAuxAction = grp->actions()[6];
+
+ transport = new Transport(this, "transport");
+ bigtime = 0;
+
+ QClipboard* cb = QApplication::clipboard();
+ connect(cb, SIGNAL(dataChanged()), SLOT(clipboardChanged()));
+ connect(cb, SIGNAL(selectionChanged()), SLOT(clipboardChanged()));
+ connect(arranger, SIGNAL(selectionChanged()), SLOT(selectionChanged()));
+
+ //---------------------------------------------------
+ // load project
+ // if no songname entered on command line:
+ // startMode: 0 - load last song
+ // 1 - load default template
+ // 2 - load configured start song
+ //---------------------------------------------------
+
+ QString name;
+ bool useTemplate = false;
+ if (argc >= 2)
+ name = argv[0];
+ else if (config.startMode == 0) {
+ if (argc < 2)
+ name = projectList[0] ? *projectList[0] : QString("untitled");
+ else
+ name = argv[0];
+ printf("starting with selected song %s\n", config.startSong.toLatin1().constData());
+ }
+ else if (config.startMode == 1) {
+ printf("starting with default template\n");
+ name = museGlobalShare + QString("/templates/default.med");
+ useTemplate = true;
+ }
+ else if (config.startMode == 2) {
+ printf("starting with pre configured song %s\n", config.startSong.toLatin1().constData());
+ name = config.startSong;
+ }
+ song->blockSignals(false);
+ loadProjectFile(name, useTemplate, true);
+ changeConfig(false);
+
+ song->update();
+ }
+
+MusE::~MusE()
+{
+ //printf("MusE::~MusE\n");
+ //if(transport)
+ // delete transport;
+}
+
+//---------------------------------------------------------
+// setHeartBeat
+//---------------------------------------------------------
+
+void MusE::setHeartBeat()
+ {
+ heartBeatTimer->start(1000/config.guiRefresh);
+ }
+
+//---------------------------------------------------------
+// resetDevices
+//---------------------------------------------------------
+
+void MusE::resetMidiDevices()
+ {
+ audio->msgResetMidiDevices();
+ }
+
+//---------------------------------------------------------
+// initMidiDevices
+//---------------------------------------------------------
+
+void MusE::initMidiDevices()
+ {
+ // Added by T356
+ //audio->msgIdle(true);
+
+ audio->msgInitMidiDevices();
+
+ // Added by T356
+ //audio->msgIdle(false);
+ }
+
+//---------------------------------------------------------
+// localOff
+//---------------------------------------------------------
+
+void MusE::localOff()
+ {
+ audio->msgLocalOff();
+ }
+
+//---------------------------------------------------------
+// loadProjectFile
+// load *.med, *.mid, *.kar
+//
+// template - if true, load file but do not change
+// project name
+//---------------------------------------------------------
+
+// for drop:
+void MusE::loadProjectFile(const QString& name)
+ {
+ loadProjectFile(name, false, false);
+ }
+
+void MusE::loadProjectFile(const QString& name, bool songTemplate, bool loadAll)
+ {
+ QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
+ //
+ // stop audio threads if running
+ //
+ bool restartSequencer = audio->isRunning();
+ if (restartSequencer) {
+ if (audio->isPlaying()) {
+ audio->msgPlay(false);
+ while (audio->isPlaying())
+ qApp->processEvents();
+ }
+ seqStop();
+ }
+ microSleep(100000);
+ loadProjectFile1(name, songTemplate, loadAll);
+ microSleep(100000);
+ if (restartSequencer)
+ seqStart();
+
+ if (song->getSongInfo().length()>0)
+ startSongInfo(false);
+ QApplication::restoreOverrideCursor();
+ }
+
+//---------------------------------------------------------
+// loadProjectFile
+// load *.med, *.mid, *.kar
+//
+// template - if true, load file but do not change
+// project name
+// loadAll - load song data + configuration data
+//---------------------------------------------------------
+
+void MusE::loadProjectFile1(const QString& name, bool songTemplate, bool loadAll)
+ {
+ //if (audioMixer)
+ // audioMixer->clear();
+ if (mixer1)
+ mixer1->clear();
+ if (mixer2)
+ mixer2->clear();
+ arranger->clear(); // clear track info
+ if (clearSong())
+ return;
+
+ QFileInfo fi(name);
+ if (songTemplate) {
+ if (!fi.isReadable()) {
+ QMessageBox::critical(this, QString("MusE"),
+ tr("Cannot read template"));
+ return;
+ }
+ project.setFile("untitled");
+ museProject = museProjectInitPath;
+ }
+ else {
+ printf("Setting project path to %s\n", fi.absolutePath().toLatin1().constData());
+ museProject = fi.absolutePath();
+ project.setFile(name);
+ }
+ // Changed by T356. 01/19/2010. We want the complete extension here.
+ //QString ex = fi.extension(false).toLower();
+ //if (ex.length() == 3)
+ // ex += ".";
+ //ex = ex.left(4);
+ QString ex = fi.completeSuffix().toLower();
+ QString mex = ex.section('.', -1, -1);
+ if((mex == "gz") || (mex == "bz2"))
+ mex = ex.section('.', -2, -2);
+
+ //if (ex.isEmpty() || ex == "med.") {
+ if (ex.isEmpty() || mex == "med") {
+ //
+ // read *.med file
+ //
+ bool popenFlag;
+ FILE* f = fileOpen(this, fi.filePath(), QString(".med"), "r", popenFlag, true);
+ if (f == 0) {
+ if (errno != ENOENT) {
+ QMessageBox::critical(this, QString("MusE"),
+ tr("File open error"));
+ setUntitledProject();
+ }
+ else
+ setConfigDefaults();
+ }
+ else {
+ Xml xml(f);
+ read(xml, !loadAll);
+ bool fileError = ferror(f);
+ popenFlag ? pclose(f) : fclose(f);
+ if (fileError) {
+ QMessageBox::critical(this, QString("MusE"),
+ tr("File read error"));
+ setUntitledProject();
+ }
+ }
+ }
+ //else if (ex == "mid." || ex == "kar.") {
+ else if (mex == "mid" || mex == "kar") {
+ setConfigDefaults();
+ if (!importMidi(name, false))
+ setUntitledProject();
+ }
+ else {
+ QMessageBox::critical(this, QString("MusE"),
+ tr("Unknown File Format: ") + ex);
+ setUntitledProject();
+ }
+ if (!songTemplate) {
+ addProject(project.absoluteFilePath());
+ setWindowTitle(QString("MusE: Song: ") + project.completeBaseName());
+ }
+ song->dirty = false;
+
+ viewTransportAction->setChecked(config.transportVisible);
+ viewBigtimeAction->setChecked(config.bigTimeVisible);
+ viewMarkerAction->setChecked(config.markerVisible);
+
+ autoMixerAction->setChecked(automation);
+
+ if (loadAll) {
+ showBigtime(config.bigTimeVisible);
+ //showMixer(config.mixerVisible);
+ showMixer1(config.mixer1Visible);
+ showMixer2(config.mixer2Visible);
+
+ // Added p3.3.43 Make sure the geometry is correct because showMixerX() will NOT
+ // set the geometry if the mixer has already been created.
+ if(mixer1)
+ {
+ //if(mixer1->geometry().size() != config.mixer1.geometry.size()) // p3.3.53 Moved below
+ // mixer1->resize(config.mixer1.geometry.size());
+
+ if(mixer1->geometry().topLeft() != config.mixer1.geometry.topLeft())
+ mixer1->move(config.mixer1.geometry.topLeft());
+ }
+ if(mixer2)
+ {
+ //if(mixer2->geometry().size() != config.mixer2.geometry.size()) // p3.3.53 Moved below
+ // mixer2->resize(config.mixer2.geometry.size());
+
+ if(mixer2->geometry().topLeft() != config.mixer2.geometry.topLeft())
+ mixer2->move(config.mixer2.geometry.topLeft());
+ }
+
+ //showMarker(config.markerVisible); // Moved below. Tim.
+ resize(config.geometryMain.size());
+ move(config.geometryMain.topLeft());
+
+ if (config.transportVisible)
+ transport->show();
+ transport->move(config.geometryTransport.topLeft());
+ showTransport(config.transportVisible);
+ }
+
+ transport->setMasterFlag(song->masterFlag());
+ punchinAction->setChecked(song->punchin());
+ punchoutAction->setChecked(song->punchout());
+ loopAction->setChecked(song->loop());
+ song->update();
+ song->updatePos();
+ clipboardChanged(); // enable/disable "Paste"
+ selectionChanged(); // enable/disable "Copy" & "Paste"
+
+ // p3.3.53 Try this AFTER the song update above which does a mixer update... Tested OK - mixers resize properly now.
+ if (loadAll)
+ {
+ if(mixer1)
+ {
+ if(mixer1->geometry().size() != config.mixer1.geometry.size())
+ {
+ //printf("MusE::loadProjectFile1 resizing mixer1 x:%d y:%d w:%d h:%d\n", config.mixer1.geometry.x(),
+ // config.mixer1.geometry.y(),
+ // config.mixer1.geometry.width(),
+ // config.mixer1.geometry.height()
+ // );
+ mixer1->resize(config.mixer1.geometry.size());
+ }
+ }
+ if(mixer2)
+ {
+ if(mixer2->geometry().size() != config.mixer2.geometry.size())
+ {
+ //printf("MusE::loadProjectFile1 resizing mixer2 x:%d y:%d w:%d h:%d\n", config.mixer2.geometry.x(),
+ // config.mixer2.geometry.y(),
+ // config.mixer2.geometry.width(),
+ // config.mixer2.geometry.height()
+ // );
+ mixer2->resize(config.mixer2.geometry.size());
+ }
+ }
+
+ // Moved here from above due to crash with a song loaded and then File->New.
+ // Marker view list was not updated, had non-existent items from marker list (cleared in ::clear()).
+ showMarker(config.markerVisible);
+ }
+
+ }
+
+//---------------------------------------------------------
+// setUntitledProject
+//---------------------------------------------------------
+
+void MusE::setUntitledProject()
+ {
+ setConfigDefaults();
+ QString name("untitled");
+ museProject = "./"; //QFileInfo(name).absolutePath();
+ project.setFile(name);
+ setWindowTitle(tr("MusE: Song: ") + project.completeBaseName());
+ }
+
+//---------------------------------------------------------
+// setConfigDefaults
+//---------------------------------------------------------
+
+void MusE::setConfigDefaults()
+ {
+ readConfiguration(); // used for reading midi files
+#if 0
+ if (readConfiguration()) {
+ //
+ // failed to load config file
+ // set buildin defaults
+ //
+ configTransportVisible = false;
+ configBigTimeVisible = false;
+
+ for (int channel = 0; channel < 2; ++channel)
+ song->addTrack(Track::AUDIO_GROUP);
+ AudioTrack* out = (AudioTrack*)song->addTrack(Track::AUDIO_OUTPUT);
+ AudioTrack* in = (AudioTrack*)song->addTrack(Track::AUDIO_INPUT);
+
+ // set some default routes
+ std::list<QString> il = audioDevice->inputPorts();
+ int channel = 0;
+ for (std::list<QString>::iterator i = il.begin(); i != il.end(); ++i, ++channel) {
+ if (channel == 2)
+ break;
+ audio->msgAddRoute(Route(out,channel), Route(*i,channel));
+ }
+ channel = 0;
+ std::list<QString> ol = audioDevice->outputPorts();
+ for (std::list<QString>::iterator i = ol.begin(); i != ol.end(); ++i, ++channel) {
+ if (channel == 2)
+ break;
+ audio->msgAddRoute(Route(*i, channel), Route(in,channel));
+ }
+ }
+#endif
+ song->dirty = false;
+ }
+
+//---------------------------------------------------------
+// setFollow
+//---------------------------------------------------------
+
+void MusE::setFollow()
+ {
+ Song::FollowMode fm = song->follow();
+
+ dontFollowAction->setChecked(fm == Song::NO);
+ followPageAction->setChecked(fm == Song::JUMP);
+ followCtsAction->setChecked(fm == Song::CONTINUOUS);
+ }
+
+//---------------------------------------------------------
+// MusE::loadProject
+//---------------------------------------------------------
+
+void MusE::loadProject()
+ {
+ bool loadAll;
+ QString fn = getOpenFileName(QString(""), med_file_pattern, this,
+ tr("MusE: load project"), &loadAll);
+ if (!fn.isEmpty()) {
+ museProject = QFileInfo(fn).absolutePath();
+ loadProjectFile(fn, false, loadAll);
+ }
+ }
+
+//---------------------------------------------------------
+// loadTemplate
+//---------------------------------------------------------
+
+void MusE::loadTemplate()
+ {
+ QString fn = getOpenFileName(QString("templates"), med_file_pattern, this,
+ tr("MusE: load template"), 0, MFileDialog::GLOBAL_VIEW);
+ if (!fn.isEmpty()) {
+ // museProject = QFileInfo(fn).absolutePath();
+ loadProjectFile(fn, true, true);
+ setUntitledProject();
+ }
+ }
+
+//---------------------------------------------------------
+// save
+//---------------------------------------------------------
+
+bool MusE::save()
+ {
+ if (project.completeBaseName() == "untitled")
+ return saveAs();
+ else
+ return save(project.filePath(), false);
+ }
+
+//---------------------------------------------------------
+// save
+//---------------------------------------------------------
+
+bool MusE::save(const QString& name, bool overwriteWarn)
+ {
+ QString backupCommand;
+
+ // By T356. Cache the jack in/out route names BEFORE saving.
+ // Because jack often shuts down during save, causing the routes to be lost in the file.
+ // Not required any more...
+ //cacheJackRouteNames();
+
+ if (QFile::exists(name)) {
+ backupCommand.sprintf("cp \"%s\" \"%s.backup\"", name.toLatin1().constData(), name.toLatin1().constData());
+ }
+ else if (QFile::exists(name + QString(".med"))) {
+ backupCommand.sprintf("cp \"%s.med\" \"%s.med.backup\"", name.toLatin1().constData(), name.toLatin1().constData());
+ }
+ if (!backupCommand.isEmpty())
+ system(backupCommand.toLatin1().constData());
+
+ bool popenFlag;
+ FILE* f = fileOpen(this, name, QString(".med"), "w", popenFlag, false, overwriteWarn);
+ if (f == 0)
+ return false;
+ Xml xml(f);
+ write(xml);
+ if (ferror(f)) {
+ QString s = "Write File\n" + name + "\nfailed: "
+ //+ strerror(errno);
+ + QString(strerror(errno)); // p4.0.0
+ QMessageBox::critical(this,
+ tr("MusE: Write File failed"), s);
+ popenFlag? pclose(f) : fclose(f);
+ unlink(name.toLatin1().constData());
+ return false;
+ }
+ else {
+ popenFlag? pclose(f) : fclose(f);
+ song->dirty = false;
+ return true;
+ }
+ }
+
+//---------------------------------------------------------
+// quitDoc
+//---------------------------------------------------------
+
+void MusE::quitDoc()
+ {
+ close();
+ }
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void MusE::closeEvent(QCloseEvent* event)
+ {
+ song->setStop(true);
+ //
+ // wait for sequencer
+ //
+ while (audio->isPlaying()) {
+ qApp->processEvents();
+ }
+ if (song->dirty) {
+ int n = 0;
+ n = QMessageBox::warning(this, appName,
+ tr("The current Project contains unsaved data\n"
+ "Save Current Project?"),
+ tr("&Save"), tr("&Skip"), tr("&Abort"), 0, 2);
+ if (n == 0) {
+ if (!save()) // dont quit if save failed
+ {
+ event->ignore();
+ return;
+ }
+ }
+ else if (n == 2)
+ {
+ event->ignore();
+ return;
+ }
+ }
+ seqStop();
+
+ WaveTrackList* wt = song->waves();
+ for (iWaveTrack iwt = wt->begin(); iwt != wt->end(); ++iwt) {
+ WaveTrack* t = *iwt;
+ if (t->recFile() && t->recFile()->samples() == 0) {
+ t->recFile()->remove();
+ }
+ }
+
+ // save "Open Recent" list
+ QString prjPath(configPath);
+ prjPath += "/projects";
+ FILE* f = fopen(prjPath.toLatin1().constData(), "w");
+ if (f) {
+ for (int i = 0; i < PROJECT_LIST_LEN; ++i) {
+ fprintf(f, "%s\n", projectList[i] ? projectList[i]->toLatin1().constData() : "");
+ }
+ fclose(f);
+ }
+ if(debugMsg)
+ printf("Muse: Exiting JackAudio\n");
+ exitJackAudio();
+ if(debugMsg)
+ printf("Muse: Exiting DummyAudio\n");
+ exitDummyAudio();
+ if(debugMsg)
+ printf("Muse: Exiting Metronome\n");
+ exitMetronome();
+
+ // p3.3.47
+ // Make sure to clear the menu, which deletes any sub menus.
+ if(routingPopupMenu)
+ routingPopupMenu->clear();
+ #if 0
+ if(routingPopupView)
+ {
+ routingPopupView->clear();
+ delete routingPopupView;
+ }
+ #endif
+
+ // Changed by Tim. p3.3.14
+ //SynthIList* sl = song->syntis();
+ //for (iSynthI i = sl->begin(); i != sl->end(); ++i)
+ // delete *i;
+ song->cleanupForQuit();
+
+ if(debugMsg)
+ printf("Muse: Cleaning up temporary wavefiles + peakfiles\n");
+ // Cleanup temporary wavefiles + peakfiles used for undo
+ for (std::list<QString>::iterator i = temporaryWavFiles.begin(); i != temporaryWavFiles.end(); i++) {
+ QString filename = *i;
+ QFileInfo f(filename);
+ QDir d = f.dir();
+ d.remove(filename);
+ d.remove(f.completeBaseName() + ".wca");
+ }
+
+ // Added by Tim. p3.3.14
+
+#ifdef HAVE_LASH
+ // Disconnect gracefully from LASH.
+ if(lash_client)
+ {
+ if(debugMsg)
+ printf("Muse: Disconnecting from LASH\n");
+ lash_event_t* lashev = lash_event_new_with_type (LASH_Quit);
+ lash_send_event(lash_client, lashev);
+ }
+#endif
+
+ if(debugMsg)
+ printf("Muse: Exiting Dsp\n");
+ AL::exitDsp();
+
+ if(debugMsg)
+ printf("Muse: Exiting OSC\n");
+ exitOSC();
+
+ // p3.3.47
+ delete audioPrefetch;
+ delete audio;
+ delete midiSeq;
+ delete song;
+
+ qApp->quit();
+ }
+
+//---------------------------------------------------------
+// toggleMarker
+//---------------------------------------------------------
+
+void MusE::toggleMarker(bool checked)
+ {
+ showMarker(checked);
+ }
+
+//---------------------------------------------------------
+// showMarker
+//---------------------------------------------------------
+
+void MusE::showMarker(bool flag)
+ {
+ //printf("showMarker %d\n",flag);
+ if (markerView == 0) {
+ markerView = new MarkerView(this);
+
+ // Removed p3.3.43
+ // Song::addMarker() already emits a 'markerChanged'.
+ //connect(arranger, SIGNAL(addMarker(int)), markerView, SLOT(addMarker(int)));
+
+ connect(markerView, SIGNAL(closed()), SLOT(markerClosed()));
+ toplevels.push_back(Toplevel(Toplevel::MARKER, (unsigned long)(markerView), markerView));
+ markerView->show();
+ }
+ markerView->setVisible(flag);
+ viewMarkerAction->setChecked(flag);
+ }
+
+//---------------------------------------------------------
+// markerClosed
+//---------------------------------------------------------
+
+void MusE::markerClosed()
+ {
+ viewMarkerAction->setChecked(false);
+ }
+
+//---------------------------------------------------------
+// toggleTransport
+//---------------------------------------------------------
+
+void MusE::toggleTransport(bool checked)
+ {
+ showTransport(checked);
+ }
+
+//---------------------------------------------------------
+// showTransport
+//---------------------------------------------------------
+
+void MusE::showTransport(bool flag)
+ {
+ transport->setVisible(flag);
+ viewTransportAction->setChecked(flag);
+ }
+
+//---------------------------------------------------------
+// getRoutingPopupMenu
+//---------------------------------------------------------
+
+PopupMenu* MusE::getRoutingPopupMenu()
+{
+ if(!routingPopupMenu)
+ routingPopupMenu = new PopupMenu(this);
+ return routingPopupMenu;
+}
+
+//---------------------------------------------------------
+// updateRouteMenus
+//---------------------------------------------------------
+
+void MusE::updateRouteMenus(Track* track, QObject* master)
+{
+ // NOTE: The puropse of this routine is to make sure the items actually reflect
+ // the routing status. And with MusE-1 QT3, it was also required to actually
+ // check the items since QT3 didn't do it for us.
+ // But now with MusE-2 and QT4, QT4 checks an item when it is clicked.
+ // So this routine is less important now, since 99% of the time, the items
+ // will be in the right checked state.
+ // But we still need this in case for some reason a route could not be
+ // added (or removed). Then the item will be properly un-checked (or checked) here.
+
+ //if(!track || track != gRoutingPopupMenuMaster || track->type() == Track::AUDIO_AUX)
+ //if(!track || track->type() == Track::AUDIO_AUX)
+ if(!track || gRoutingPopupMenuMaster != master) // p3.3.50
+ return;
+
+ PopupMenu* pup = getRoutingPopupMenu();
+
+ if(pup->actions().isEmpty())
+ return;
+
+ if(!pup->isVisible())
+ return;
+
+ //AudioTrack* t = (AudioTrack*)track;
+ RouteList* rl = gIsOutRoutingPopupMenu ? track->outRoutes() : track->inRoutes();
+
+ iRouteMenuMap imm = gRoutingMenuMap.begin();
+ for(; imm != gRoutingMenuMap.end(); ++imm)
+ {
+ // p3.3.50 Ignore the 'toggle' items.
+ if(imm->second.type == Route::MIDI_PORT_ROUTE &&
+ imm->first >= (MIDI_PORTS * MIDI_CHANNELS) && imm->first < (MIDI_PORTS * MIDI_CHANNELS + MIDI_PORTS))
+ continue;
+
+ //bool found = false;
+ iRoute irl = rl->begin();
+ for(; irl != rl->end(); ++irl)
+ {
+ if(imm->second.type == Route::MIDI_PORT_ROUTE) // p3.3.50 Is the map route a midi port route?
+ {
+ if(irl->type == Route::MIDI_PORT_ROUTE && irl->midiPort == imm->second.midiPort // Is the track route a midi port route?
+ && (irl->channel & imm->second.channel) == imm->second.channel) // Is the exact channel mask bit(s) set?
+ {
+ //found = true;
+ break;
+ }
+ }
+ else
+ if(*irl == imm->second)
+ {
+ //found = true;
+ break;
+ }
+ }
+ //pup->setItemChecked(imm->first, found);
+ //printf("MusE::updateRouteMenus setItemChecked\n");
+ // TODO: MusE-2: Convert this, fastest way is to change the routing map, otherwise this requires a lookup.
+ //if(pup->isItemChecked(imm->first) != (irl != rl->end()))
+ // pup->setItemChecked(imm->first, irl != rl->end());
+ QAction* act = pup->findActionFromData(imm->first);
+ if(act && act->isChecked() != (irl != rl->end()))
+ act->setChecked(irl != rl->end());
+ }
+}
+
+//---------------------------------------------------------
+// routingPopupMenuActivated
+//---------------------------------------------------------
+
+void MusE::routingPopupMenuActivated(Track* track, int n)
+{
+ //if(!track || (track != gRoutingPopupMenuMaster))
+ if(!track)
+ return;
+
+ if(track->isMidiTrack())
+ {
+ PopupMenu* pup = getRoutingPopupMenu();
+
+ if(pup->actions().isEmpty())
+ return;
+
+ //MidiTrack* t = (MidiTrack*)track;
+ RouteList* rl = gIsOutRoutingPopupMenu ? track->outRoutes() : track->inRoutes();
+
+ if(n == -1)
+ return;
+
+ iRouteMenuMap imm = gRoutingMenuMap.find(n);
+ if(imm == gRoutingMenuMap.end())
+ return;
+ if(imm->second.type != Route::MIDI_PORT_ROUTE)
+ return;
+ Route &aRoute = imm->second;
+ int chbit = aRoute.channel;
+ Route bRoute(track, chbit);
+ int mdidx = aRoute.midiPort;
+
+ MidiPort* mp = &midiPorts[mdidx];
+ MidiDevice* md = mp->device();
+ if(!md)
+ return;
+
+ //if(!(md->rwFlags() & 2))
+ if(!(md->rwFlags() & (gIsOutRoutingPopupMenu ? 1 : 2)))
+ return;
+
+ int chmask = 0;
+ iRoute iir = rl->begin();
+ for (; iir != rl->end(); ++iir)
+ {
+ //if(*iir == (dst ? bRoute : aRoute))
+ //if(*iir == aRoute)
+ if(iir->type == Route::MIDI_PORT_ROUTE && iir->midiPort == mdidx) // p3.3.50 Is there already a route to this port?
+ {
+ chmask = iir->channel; // p3.3.50 Grab the channel mask.
+ break;
+ }
+ }
+ //if (iir != rl->end())
+ if ((chmask & chbit) == chbit) // p3.3.50 Is the channel's bit(s) set?
+ {
+ // disconnect
+ if(gIsOutRoutingPopupMenu)
+ audio->msgRemoveRoute(bRoute, aRoute);
+ else
+ audio->msgRemoveRoute(aRoute, bRoute);
+ }
+ else
+ {
+ // connect
+ if(gIsOutRoutingPopupMenu)
+ audio->msgAddRoute(bRoute, aRoute);
+ else
+ audio->msgAddRoute(aRoute, bRoute);
+ }
+
+ audio->msgUpdateSoloStates();
+ song->update(SC_ROUTE);
+ }
+ else
+ {
+ // TODO: Try to move code from AudioStrip::routingPopupMenuActivated into here.
+
+ /*
+ PopupMenu* pup = getRoutingPopupMenu();
+
+ printf("MusE::routingPopupMenuActivated audio n:%d count:%d\n", n, pup->count());
+
+ if(pup->count() == 0)
+ return;
+
+ AudioTrack* t = (AudioTrack*)track;
+ RouteList* rl = gIsOutRoutingPopupMenu ? t->outRoutes() : t->inRoutes();
+
+ //QPoint ppt = QCursor::pos();
+
+ if(n == -1)
+ {
+ //printf("MusE::routingPopupMenuActivated audio n = -1 deleting popup...\n");
+ printf("MusE::routingPopupMenuActivated audio n = -1\n");
+ ///delete pup;
+ ///pup = 0;
+ return;
+ }
+ else
+ //if(n == 0)
+ //{
+ //printf("MusE::routingPopupMenuActivated audio n = 0 = tearOffHandle\n");
+ //oR->setDown(false);
+ // return;
+ //}
+ //else
+ {
+ if(gIsOutRoutingPopupMenu)
+ {
+ QString s(pup->text(n));
+
+ //printf("AudioStrip::routingPopupMenuActivated audio text:%s\n", s.toLatin1().constData());
+
+ if(track->type() == Track::AUDIO_OUTPUT)
+ {
+ ///delete orpup;
+
+ int chan = n & 0xf;
+
+ //Route srcRoute(t, -1);
+ //Route srcRoute(t, chan, chans);
+ //Route srcRoute(t, chan, 1);
+ Route srcRoute(t, chan);
+
+ //Route dstRoute(s, true, -1);
+ Route dstRoute(s, true, -1, Route::JACK_ROUTE);
+ //Route dstRoute(s, true, 0, Route::JACK_ROUTE);
+
+ //srcRoute.channel = dstRoute.channel = chan;
+ dstRoute.channel = chan;
+ //dstRoute.channels = 1;
+
+ // check if route src->dst exists:
+ iRoute irl = rl->begin();
+ for (; irl != rl->end(); ++irl) {
+ if (*irl == dstRoute)
+ break;
+ }
+ if (irl != rl->end()) {
+ // disconnect if route exists
+ audio->msgRemoveRoute(srcRoute, dstRoute);
+ }
+ else {
+ // connect if route does not exist
+ audio->msgAddRoute(srcRoute, dstRoute);
+ }
+ audio->msgUpdateSoloStates();
+ song->update(SC_ROUTE);
+
+ // p3.3.47
+ //pup->popup(ppt, 0);
+
+ //oR->setDown(false);
+ return;
+
+ // p3.3.46
+ ///goto _redisplay;
+ }
+
+ iRouteMenuMap imm = gRoutingMenuMap.find(n);
+ if(imm == gRoutingMenuMap.end())
+ {
+ ///delete orpup;
+ //oR->setDown(false); // orpup->exec() catches mouse release event
+ return;
+ }
+
+ //int chan = n >> 16;
+ //int chans = (chan >> 15) + 1; // Bit 31 MSB: Mono or stereo.
+ //chan &= 0xffff;
+ //int chan = imm->second.channel;
+ //int chans = imm->second.channels;
+
+ //Route srcRoute(t, -1);
+ //srcRoute.remoteChannel = chan;
+ //Route srcRoute(t, chan, chans);
+ Route srcRoute(t, imm->second.channel, imm->second.channels);
+ //Route srcRoute(t, imm->second.channel);
+ srcRoute.remoteChannel = imm->second.remoteChannel;
+
+ //Route dstRoute(s, true, -1);
+ //Route dstRoute(s, true, -1, Route::TRACK_ROUTE);
+ Route &dstRoute = imm->second;
+
+ // check if route src->dst exists:
+ iRoute irl = rl->begin();
+ for (; irl != rl->end(); ++irl) {
+ if (*irl == dstRoute)
+ break;
+ }
+ if (irl != rl->end()) {
+ // disconnect if route exists
+ audio->msgRemoveRoute(srcRoute, dstRoute);
+ }
+ else {
+ // connect if route does not exist
+ audio->msgAddRoute(srcRoute, dstRoute);
+ }
+ audio->msgUpdateSoloStates();
+ song->update(SC_ROUTE);
+
+ // p3.3.46
+ //oR->setDown(false);
+ ///goto _redisplay;
+
+ // p3.3.47
+ //pup->popup(ppt, 0);
+ }
+ else
+ {
+ QString s(pup->text(n));
+
+ if(track->type() == Track::AUDIO_INPUT)
+ {
+ ///delete pup;
+ int chan = n & 0xf;
+
+ Route srcRoute(s, false, -1, Route::JACK_ROUTE);
+ Route dstRoute(t, chan);
+
+ srcRoute.channel = chan;
+
+ iRoute irl = rl->begin();
+ for(; irl != rl->end(); ++irl)
+ {
+ if(*irl == srcRoute)
+ break;
+ }
+ if(irl != rl->end())
+ // disconnect
+ audio->msgRemoveRoute(srcRoute, dstRoute);
+ else
+ // connect
+ audio->msgAddRoute(srcRoute, dstRoute);
+
+ audio->msgUpdateSoloStates();
+ song->update(SC_ROUTE);
+ //iR->setDown(false); // pup->exec() catches mouse release event
+ return;
+
+ // p3.3.46
+ ///goto _redisplay;
+ }
+
+ iRouteMenuMap imm = gRoutingMenuMap.find(n);
+ if(imm == gRoutingMenuMap.end())
+ {
+ //delete pup;
+ //iR->setDown(false); // pup->exec() catches mouse release event
+ return;
+ }
+
+ //int chan = n >> 16;
+ //int chans = (chan >> 15) + 1; // Bit 31 MSB: Mono or stereo.
+ //chan &= 0xffff;
+ //int chan = imm->second.channel;
+ //int chans = imm->second.channels;
+
+ //Route srcRoute(s, false, -1);
+ //Route srcRoute(s, false, -1, Route::TRACK_ROUTE);
+ Route &srcRoute = imm->second;
+
+ //Route dstRoute(t, -1);
+ //Route dstRoute(t, chan, chans);
+ Route dstRoute(t, imm->second.channel, imm->second.channels);
+ //Route dstRoute(t, imm->second.channel);
+ dstRoute.remoteChannel = imm->second.remoteChannel;
+
+ iRoute irl = rl->begin();
+ for (; irl != rl->end(); ++irl) {
+ if (*irl == srcRoute)
+ break;
+ }
+ if (irl != rl->end()) {
+ // disconnect
+ audio->msgRemoveRoute(srcRoute, dstRoute);
+ }
+ else {
+ // connect
+ audio->msgAddRoute(srcRoute, dstRoute);
+ }
+ audio->msgUpdateSoloStates();
+ song->update(SC_ROUTE);
+
+ // p3.3.46
+ //iR->setDown(false);
+ ///goto _redisplay;
+
+
+
+
+ }
+
+ }
+ */
+
+ }
+ //else
+ //{
+ //}
+}
+
+//---------------------------------------------------------
+// routingPopupMenuAboutToHide
+//---------------------------------------------------------
+
+void MusE::routingPopupMenuAboutToHide()
+{
+ // Hmm, can't do this? Sub-menus stay open with this. Re-arranged, testing... Nope.
+ //PopupMenu* pup = muse->getRoutingPopupMenu();
+ //pup->disconnect();
+ //pup->clear();
+
+ gRoutingMenuMap.clear();
+ gRoutingPopupMenuMaster = 0;
+}
+
+//---------------------------------------------------------
+// prepareRoutingPopupMenu
+//---------------------------------------------------------
+
+PopupMenu* MusE::prepareRoutingPopupMenu(Track* track, bool dst)
+{
+ if(!track)
+ return 0;
+
+ //QPoint ppt = QCursor::pos();
+
+ if(track->isMidiTrack())
+ {
+
+ //QPoint ppt = parent->rect().bottomLeft();
+
+ //if(dst)
+ //{
+ // TODO
+
+ //}
+ //else
+ //{
+ RouteList* rl = dst ? track->outRoutes() : track->inRoutes();
+ //Route dst(track, -1);
+
+ PopupMenu* pup = getRoutingPopupMenu();
+ pup->disconnect();
+ //connect(pup, SIGNAL(activated(int)), SLOT(routingPopupMenuActivated(int)));
+ //connect(pup, SIGNAL(aboutToHide()), SLOT(routingPopupMenuAboutToHide()));
+
+ int gid = 0;
+ //int n;
+ QAction* act = 0;
+
+ // Routes can't be re-read until the message sent from msgAddRoute1()
+ // has had time to be sent and actually affected the routes.
+ ///_redisplay:
+
+ pup->clear();
+ gRoutingMenuMap.clear();
+ gid = 0;
+
+ //MidiInPortList* tl = song->midiInPorts();
+ //for(iMidiInPort i = tl->begin();i != tl->end(); ++i)
+ for(int i = 0; i < MIDI_PORTS; ++i)
+ {
+ //MidiInPort* track = *i;
+ // NOTE: Could possibly list all devices, bypassing ports, but no, let's stick with ports.
+ MidiPort* mp = &midiPorts[i];
+ MidiDevice* md = mp->device();
+ if(!md)
+ continue;
+
+ if(!(md->rwFlags() & (dst ? 1 : 2)))
+ continue;
+
+ //printf("MusE::prepareRoutingPopupMenu adding submenu portnum:%d\n", i);
+
+ //QMenu* m = menu->addMenu(track->name());
+ //QPopupMenu* subp = new QPopupMenu(parent);
+ //PopupMenu* subp = new PopupMenu(this);
+ //PopupMenu* subp = new PopupMenu();
+ PopupMenu* subp = new PopupMenu(pup);
+ subp->setTitle(md->name());
+
+ // MusE-2: Check this - needed with QMenu? Help says no. No - verified, it actually causes double triggers!
+ //connect(subp, SIGNAL(triggered(QAction*)), pup, SIGNAL(triggered(QAction*)));
+ //connect(subp, SIGNAL(aboutToHide()), pup, SIGNAL(aboutToHide()));
+
+ int chanmask = 0;
+ // p3.3.50 To reduce number of routes required, from one per channel to just one containing a channel mask.
+ // Look for the first route to this midi port. There should always be only a single route for each midi port, now.
+ for(iRoute ir = rl->begin(); ir != rl->end(); ++ir)
+ {
+ if(ir->type == Route::MIDI_PORT_ROUTE && ir->midiPort == i)
+ {
+ // We have a route to the midi port. Grab the channel mask.
+ chanmask = ir->channel;
+ break;
+ }
+ }
+
+ for(int ch = 0; ch < MIDI_CHANNELS; ++ch)
+ {
+ //QAction* a = m->addAction(QString("Channel %1").arg(ch+1));
+ //subp->insertItem(QT_TRANSLATE_NOOP("@default", QString("Channel %1").arg(ch+1)), i * MIDI_CHANNELS + ch);
+ gid = i * MIDI_CHANNELS + ch;
+
+ //printf("MusE::prepareRoutingPopupMenu inserting gid:%d\n", gid);
+
+ act = subp->addAction(QString("Channel %1").arg(ch+1));
+ act->setCheckable(true);
+ act->setData(gid);
+ //a->setCheckable(true);
+ //Route src(track, ch, RouteNode::TRACK);
+ //Route src(md, ch);
+ //Route r = Route(src, dst);
+ //a->setData(QVariant::fromValue(r));
+ //a->setChecked(rl->indexOf(r) != -1);
+
+ //Route srcRoute(md, ch);
+ //Route srcRoute(i, ch); // p3.3.49 New: Midi port route.
+ int chbit = 1 << ch;
+ Route srcRoute(i, chbit); // p3.3.50 In accordance with new channel mask, use the bit position.
+
+ gRoutingMenuMap.insert( pRouteMenuMap(gid, srcRoute) );
+
+ //for(iRoute ir = rl->begin(); ir != rl->end(); ++ir) // p3.3.50 Removed.
+ //{
+ //if(*ir == dst)
+ // if(*ir == srcRoute)
+ // {
+ // subp->setItemChecked(id, true);
+ // break;
+ // }
+ //}
+ if(chanmask & chbit) // p3.3.50 Is the channel already set? Show item check mark.
+ act->setChecked(true);
+ }
+ //subp->insertItem(QString("Toggle all"), 1000+i);
+ // p3.3.50 One route with all channel bits set.
+ gid = MIDI_PORTS * MIDI_CHANNELS + i; // Make sure each 'toggle' item gets a unique id.
+ act = subp->addAction(QString("Toggle all"));
+ //act->setCheckable(true);
+ act->setData(gid);
+ Route togRoute(i, (1 << MIDI_CHANNELS) - 1); // Set all channel bits.
+ gRoutingMenuMap.insert( pRouteMenuMap(gid, togRoute) );
+
+ pup->addMenu(subp);
+ }
+
+ /*
+ QPopupMenu* pup = new QPopupMenu(iR);
+ pup->setCheckable(true);
+ //MidiTrack* t = (MidiTrack*)track;
+ RouteList* irl = track->inRoutes();
+
+ MidiTrack* t = (MidiTrack*)track;
+ int gid = 0;
+ for (int i = 0; i < channel; ++i)
+ {
+ char buffer[128];
+ snprintf(buffer, 128, "%s %d", tr("Channel").toLatin1().constData(), i+1);
+ MenuTitleItem* titel = new MenuTitleItem(QString(buffer));
+ pup->insertItem(titel);
+
+ if (!checkAudioDevice()) return;
+ std::list<QString> ol = audioDevice->outputPorts();
+ for (std::list<QString>::iterator ip = ol.begin(); ip != ol.end(); ++ip) {
+ int id = pup->insertItem(*ip, (gid * 16) + i);
+ Route dst(*ip, true, i);
+ ++gid;
+ for (iRoute ir = irl->begin(); ir != irl->end(); ++ir) {
+ if (*ir == dst) {
+ pup->setItemChecked(id, true);
+ break;
+ }
+ }
+ }
+ if (i+1 != channel)
+ pup->addSeparator();
+ }
+ */
+
+ if(pup->actions().isEmpty())
+ {
+ gRoutingPopupMenuMaster = 0;
+ //pup->clear();
+ //pup->disconnect();
+ gRoutingMenuMap.clear();
+ //oR->setDown(false);
+ return 0;
+ }
+
+ gIsOutRoutingPopupMenu = dst;
+ return pup;
+ }
+
+ return 0;
+}
+
+#if 0
+//---------------------------------------------------------
+// getRoutingPopupView
+//---------------------------------------------------------
+
+PopupView* MusE::getRoutingPopupView()
+{
+ if(!routingPopupView)
+ //routingPopupView = new PopupView(this);
+ routingPopupView = new PopupView();
+ return routingPopupView;
+}
+
+//---------------------------------------------------------
+// routingPopupViewActivated
+//---------------------------------------------------------
+
+void MusE::routingPopupViewActivated(Track* track, int n)
+{
+ //if(!track || (track != gRoutingPopupMenuMaster))
+ if(!track)
+ return;
+
+ if(track->isMidiTrack())
+ {
+ PopupView* pup = getRoutingPopupView();
+
+ //printf("MusE::routingPopupMenuActivated midi n:%d count:%d\n", n, pup->count());
+
+ if(pup->model()->rowCount() == 0)
+ return;
+
+ //MidiTrack* t = (MidiTrack*)track;
+ RouteList* rl = gIsOutRoutingPopupMenu ? track->outRoutes() : track->inRoutes();
+
+ if(n == -1)
+ return;
+
+ iRouteMenuMap imm = gRoutingMenuMap.find(n);
+ if(imm == gRoutingMenuMap.end())
+ return;
+ if(imm->second.type != Route::MIDI_PORT_ROUTE)
+ return;
+ Route &aRoute = imm->second;
+ int chbit = aRoute.channel;
+ Route bRoute(track, chbit);
+ int mdidx = aRoute.midiPort;
+
+ MidiPort* mp = &midiPorts[mdidx];
+ MidiDevice* md = mp->device();
+ if(!md)
+ return;
+
+ //if(!(md->rwFlags() & 2))
+ if(!(md->rwFlags() & (gIsOutRoutingPopupMenu ? 1 : 2)))
+ return;
+
+ int chmask = 0;
+ iRoute iir = rl->begin();
+ for (; iir != rl->end(); ++iir)
+ {
+ //if(*iir == (dst ? bRoute : aRoute))
+ //if(*iir == aRoute)
+ if(iir->type == Route::MIDI_PORT_ROUTE && iir->midiPort == mdidx) // p3.3.50 Is there already a route to this port?
+ {
+ chmask = iir->channel; // p3.3.50 Grab the channel mask.
+ break;
+ }
+ }
+ //if (iir != rl->end())
+ if ((chmask & chbit) == chbit) // p3.3.50 Is the channel's bit(s) set?
+ {
+ // disconnect
+ if(gIsOutRoutingPopupMenu)
+ audio->msgRemoveRoute(bRoute, aRoute);
+ else
+ audio->msgRemoveRoute(aRoute, bRoute);
+ }
+ else
+ {
+ // connect
+ if(gIsOutRoutingPopupMenu)
+ audio->msgAddRoute(bRoute, aRoute);
+ else
+ audio->msgAddRoute(aRoute, bRoute);
+ }
+
+ audio->msgUpdateSoloStates();
+ song->update(SC_ROUTE);
+ }
+ else
+ {
+ // TODO: Try to move code from AudioStrip::routingPopupMenuActivated into here.
+ }
+ //else
+ //{
+ //}
+}
+
+//---------------------------------------------------------
+// prepareRoutingPopupView
+//---------------------------------------------------------
+
+PopupView* MusE::prepareRoutingPopupView(Track* track, bool dst)
+{
+ if(!track)
+ return 0;
+
+ //QPoint ppt = QCursor::pos();
+
+ if(track->isMidiTrack())
+ {
+
+ //QPoint ppt = parent->rect().bottomLeft();
+
+ //if(dst)
+ //{
+ // TODO
+
+ //}
+ //else
+ //{
+ RouteList* rl = dst ? track->outRoutes() : track->inRoutes();
+ //Route dst(track, -1);
+
+ ///QPopupMenu* pup = new QPopupMenu(parent);
+
+ PopupView* pup = getRoutingPopupView();
+ pup->disconnect();
+ //connect(pup, SIGNAL(activated(int)), SLOT(routingPopupMenuActivated(int)));
+ //connect(pup, SIGNAL(aboutToHide()), SLOT(routingPopupMenuAboutToHide()));
+
+ ///pup->setCheckable(true);
+
+ int gid = 0;
+ //int n;
+
+ // Routes can't be re-read until the message sent from msgAddRoute1()
+ // has had time to be sent and actually affected the routes.
+ ///_redisplay:
+
+ pup->clear();
+ gRoutingMenuMap.clear();
+ gid = 0;
+
+ //MidiInPortList* tl = song->midiInPorts();
+ //for(iMidiInPort i = tl->begin();i != tl->end(); ++i)
+ for(int i = 0; i < MIDI_PORTS; ++i)
+ {
+ //MidiInPort* track = *i;
+ // NOTE: Could possibly list all devices, bypassing ports, but no, let's stick with ports.
+ MidiPort* mp = &midiPorts[i];
+ MidiDevice* md = mp->device();
+ if(!md)
+ continue;
+
+ if(!(md->rwFlags() & (dst ? 1 : 2)))
+ continue;
+
+ //printf("MusE::prepareRoutingPopupMenu adding submenu portnum:%d\n", i);
+
+ //QMenu* m = menu->addMenu(track->name());
+ //QPopupMenu* subp = new QPopupMenu(parent);
+ //PopupMenu* subp = new PopupMenu(this);
+ QStandardItem* subp = new QStandardItem(QT_TRANSLATE_NOOP("@default", md->name()));
+/// connect(subp, SIGNAL(activated(int)), pup, SIGNAL(activated(int)));
+ //connect(subp, SIGNAL(aboutToHide()), pup, SIGNAL(aboutToHide()));
+
+ int chanmask = 0;
+ // p3.3.50 To reduce number of routes required, from one per channel to just one containing a channel mask.
+ // Look for the first route to this midi port. There should always be only a single route for each midi port, now.
+ for(iRoute ir = rl->begin(); ir != rl->end(); ++ir)
+ {
+ if(ir->type == Route::MIDI_PORT_ROUTE && ir->midiPort == i)
+ {
+ // We have a route to the midi port. Grab the channel mask.
+ chanmask = ir->channel;
+ break;
+ }
+ }
+
+ for(int ch = 0; ch < MIDI_CHANNELS; ++ch)
+ {
+ //QAction* a = m->addAction(QString("Channel %1").arg(ch+1));
+ //subp->insertItem(QT_TRANSLATE_NOOP("@default", QString("Channel %1").arg(ch+1)), i * MIDI_CHANNELS + ch);
+ gid = i * MIDI_CHANNELS + ch;
+
+ //printf("MusE::prepareRoutingPopupMenu inserting gid:%d\n", gid);
+
+/// subp->insertItem(QString("Channel %1").arg(ch+1), gid);
+ QStandardItem* sti = new QStandardItem(QString("Channel %1").arg(ch+1));
+ sti->setCheckable(true);
+ sti->setData(gid);
+ subp->appendRow(sti);
+
+ //a->setCheckable(true);
+ //Route src(track, ch, RouteNode::TRACK);
+ //Route src(md, ch);
+ //Route r = Route(src, dst);
+ //a->setData(QVariant::fromValue(r));
+ //a->setChecked(rl->indexOf(r) != -1);
+
+ //Route srcRoute(md, ch);
+ //Route srcRoute(i, ch); // p3.3.49 New: Midi port route.
+ int chbit = 1 << ch;
+ Route srcRoute(i, chbit); // p3.3.50 In accordance with new channel mask, use the bit position.
+
+ gRoutingMenuMap.insert( pRouteMenuMap(gid, srcRoute) );
+
+ //for(iRoute ir = rl->begin(); ir != rl->end(); ++ir) // p3.3.50 Removed.
+ //{
+ //if(*ir == dst)
+ // if(*ir == srcRoute)
+ // {
+ // subp->setItemChecked(id, true);
+ // break;
+ // }
+ //}
+ if(chanmask & chbit) // p3.3.50 Is the channel already set? Show item check mark.
+/// subp->setItemChecked(gid, true);
+ sti->setCheckState(Qt::Checked);
+ }
+ //subp->insertItem(QString("Toggle all"), 1000+i);
+ // p3.3.50 One route with all channel bits set.
+ gid = MIDI_PORTS * MIDI_CHANNELS + i; // Make sure each 'toggle' item gets a unique id.
+/// subp->insertItem(QString("Toggle all"), gid);
+ QStandardItem* sti = new QStandardItem(QString("Toggle all"));
+ sti->setData(gid);
+ subp->appendRow(sti);
+
+ Route togRoute(i, (1 << MIDI_CHANNELS) - 1); // Set all channel bits.
+ gRoutingMenuMap.insert( pRouteMenuMap(gid, togRoute) );
+
+/// pup->insertItem(QT_TRANSLATE_NOOP("@default", md->name()), subp);
+ pup->model()->appendRow(subp);
+ pup->updateView();
+ }
+
+ /*
+ QPopupMenu* pup = new QPopupMenu(iR);
+ pup->setCheckable(true);
+ //MidiTrack* t = (MidiTrack*)track;
+ RouteList* irl = track->inRoutes();
+
+ MidiTrack* t = (MidiTrack*)track;
+ int gid = 0;
+ for (int i = 0; i < channel; ++i)
+ {
+ char buffer[128];
+ snprintf(buffer, 128, "%s %d", tr("Channel").toLatin1().constData(), i+1);
+ MenuTitleItem* titel = new MenuTitleItem(QString(buffer));
+ pup->insertItem(titel);
+
+ if (!checkAudioDevice()) return;
+ std::list<QString> ol = audioDevice->outputPorts();
+ for (std::list<QString>::iterator ip = ol.begin(); ip != ol.end(); ++ip) {
+ int id = pup->insertItem(*ip, (gid * 16) + i);
+ Route dst(*ip, true, i);
+ ++gid;
+ for (iRoute ir = irl->begin(); ir != irl->end(); ++ir) {
+ if (*ir == dst) {
+ pup->setItemChecked(id, true);
+ break;
+ }
+ }
+ }
+ if (i+1 != channel)
+ pup->addSeparator();
+ }
+ */
+
+/// if(pup->count() == 0)
+ if(pup->model()->rowCount() == 0)
+ {
+ ///delete pup;
+ gRoutingPopupMenuMaster = 0;
+ //pup->clear();
+ //pup->disconnect();
+ gRoutingMenuMap.clear();
+ //oR->setDown(false);
+ return 0;
+ }
+
+ gIsOutRoutingPopupMenu = dst;
+ return pup;
+ }
+
+ return 0;
+}
+#endif
+
+//---------------------------------------------------------
+// saveAs
+//---------------------------------------------------------
+
+bool MusE::saveAs()
+ {
+ QString name;
+ if (museProject == museProjectInitPath ) {
+ ProjectCreateImpl pci(muse);
+ if (pci.exec() == QDialog::Rejected) {
+ return false;
+ }
+
+ name = pci.getProjectPath();
+ song->setSongInfo(pci.getSongInfo());
+ museProject = QFileInfo(name).absolutePath();
+ QDir dirmanipulator;
+ if (!dirmanipulator.mkpath(museProject)) {
+ QMessageBox::warning(this,"Path error","Can't create project path", QMessageBox::Ok);
+ return false;
+ }
+ }
+ else {
+ name = getSaveFileName(QString(""), med_file_save_pattern, this, tr("MusE: Save As"));
+ }
+ bool ok = false;
+ if (!name.isEmpty()) {
+ QString tempOldProj = museProject;
+ museProject = QFileInfo(name).absolutePath();
+ ok = save(name, true);
+ if (ok) {
+ project.setFile(name);
+ setWindowTitle(tr("MusE: Song: ") + project.completeBaseName());
+ addProject(name);
+ }
+ else
+ museProject = tempOldProj;
+ }
+
+ return ok;
+ }
+
+//---------------------------------------------------------
+// startEditor
+//---------------------------------------------------------
+
+void MusE::startEditor(PartList* pl, int type)
+ {
+ switch (type) {
+ case 0: startPianoroll(pl, true); break;
+ case 1: startListEditor(pl); break;
+ case 3: startDrumEditor(pl, true); break;
+ case 4: startWaveEditor(pl); break;
+ }
+ }
+
+//---------------------------------------------------------
+// startEditor
+//---------------------------------------------------------
+
+void MusE::startEditor(Track* t)
+ {
+ switch (t->type()) {
+ case Track::MIDI: startPianoroll(); break;
+ case Track::DRUM: startDrumEditor(); break;
+ case Track::WAVE: startWaveEditor(); break;
+ default:
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// getMidiPartsToEdit
+//---------------------------------------------------------
+
+PartList* MusE::getMidiPartsToEdit()
+ {
+ PartList* pl = song->getSelectedMidiParts();
+ if (pl->empty()) {
+ QMessageBox::critical(this, QString("MusE"), tr("Nothing to edit"));
+ return 0;
+ }
+ return pl;
+ }
+
+//---------------------------------------------------------
+// startPianoroll
+//---------------------------------------------------------
+
+void MusE::startPianoroll()
+ {
+ PartList* pl = getMidiPartsToEdit();
+ if (pl == 0)
+ return;
+ startPianoroll(pl, true);
+ }
+
+void MusE::startPianoroll(PartList* pl, bool showDefaultCtrls)
+ {
+
+ PianoRoll* pianoroll = new PianoRoll(pl, this, 0, arranger->cursorValue());
+ pianoroll->show();
+ if(showDefaultCtrls) // p4.0.12
+ pianoroll->addCtrl();
+ toplevels.push_back(Toplevel(Toplevel::PIANO_ROLL, (unsigned long)(pianoroll), pianoroll));
+ connect(pianoroll, SIGNAL(deleted(unsigned long)), SLOT(toplevelDeleted(unsigned long)));
+ connect(muse, SIGNAL(configChanged()), pianoroll, SLOT(configChanged()));
+ }
+
+//---------------------------------------------------------
+// startListenEditor
+//---------------------------------------------------------
+
+void MusE::startListEditor()
+ {
+ PartList* pl = getMidiPartsToEdit();
+ if (pl == 0)
+ return;
+ startListEditor(pl);
+ }
+
+void MusE::startListEditor(PartList* pl)
+ {
+ ListEdit* listEditor = new ListEdit(pl);
+ listEditor->show();
+ toplevels.push_back(Toplevel(Toplevel::LISTE, (unsigned long)(listEditor), listEditor));
+ connect(listEditor, SIGNAL(deleted(unsigned long)), SLOT(toplevelDeleted(unsigned long)));
+ connect(muse,SIGNAL(configChanged()), listEditor, SLOT(configChanged()));
+ }
+
+//---------------------------------------------------------
+// startMasterEditor
+//---------------------------------------------------------
+
+void MusE::startMasterEditor()
+ {
+ MasterEdit* masterEditor = new MasterEdit();
+ masterEditor->show();
+ toplevels.push_back(Toplevel(Toplevel::MASTER, (unsigned long)(masterEditor), masterEditor));
+ connect(masterEditor, SIGNAL(deleted(unsigned long)), SLOT(toplevelDeleted(unsigned long)));
+ }
+
+//---------------------------------------------------------
+// startLMasterEditor
+//---------------------------------------------------------
+
+void MusE::startLMasterEditor()
+ {
+ LMaster* lmaster = new LMaster();
+ lmaster->show();
+ toplevels.push_back(Toplevel(Toplevel::LMASTER, (unsigned long)(lmaster), lmaster));
+ connect(lmaster, SIGNAL(deleted(unsigned long)), SLOT(toplevelDeleted(unsigned long)));
+ connect(muse, SIGNAL(configChanged()), lmaster, SLOT(configChanged()));
+ }
+
+//---------------------------------------------------------
+// startDrumEditor
+//---------------------------------------------------------
+
+void MusE::startDrumEditor()
+ {
+ PartList* pl = getMidiPartsToEdit();
+ if (pl == 0)
+ return;
+ startDrumEditor(pl, true);
+ }
+
+void MusE::startDrumEditor(PartList* pl, bool showDefaultCtrls)
+ {
+
+ DrumEdit* drumEditor = new DrumEdit(pl, this, 0, arranger->cursorValue());
+ drumEditor->show();
+ if(showDefaultCtrls) // p4.0.12
+ drumEditor->addCtrl();
+ toplevels.push_back(Toplevel(Toplevel::DRUM, (unsigned long)(drumEditor), drumEditor));
+ connect(drumEditor, SIGNAL(deleted(unsigned long)), SLOT(toplevelDeleted(unsigned long)));
+ connect(muse, SIGNAL(configChanged()), drumEditor, SLOT(configChanged()));
+ }
+
+//---------------------------------------------------------
+// startWaveEditor
+//---------------------------------------------------------
+
+void MusE::startWaveEditor()
+ {
+ PartList* pl = song->getSelectedWaveParts();
+ if (pl->empty()) {
+ QMessageBox::critical(this, QString("MusE"), tr("Nothing to edit"));
+ return;
+ }
+ startWaveEditor(pl);
+ }
+
+void MusE::startWaveEditor(PartList* pl)
+ {
+ WaveEdit* waveEditor = new WaveEdit(pl);
+ waveEditor->show();
+ connect(muse, SIGNAL(configChanged()), waveEditor, SLOT(configChanged()));
+ toplevels.push_back(Toplevel(Toplevel::WAVE, (unsigned long)(waveEditor), waveEditor));
+ connect(waveEditor, SIGNAL(deleted(unsigned long)), SLOT(toplevelDeleted(unsigned long)));
+ }
+
+
+//---------------------------------------------------------
+// startSongInfo
+//---------------------------------------------------------
+void MusE::startSongInfo(bool editable)
+ {
+ printf("startSongInfo!!!!\n");
+ SongInfoWidget info;
+ info.songInfoText->setPlainText(song->getSongInfo());
+ info.songInfoText->setReadOnly(!editable);
+ info.show();
+ if( info.exec() == QDialog::Accepted) {
+ if (editable)
+ song->setSongInfo(info.songInfoText->toPlainText());
+ }
+
+ }
+
+//---------------------------------------------------------
+// showDidYouKnowDialog
+//---------------------------------------------------------
+void MusE::showDidYouKnowDialog()
+ {
+ if ((bool)config.showDidYouKnow == true) {
+ printf("show did you know dialog!!!!\n");
+ DidYouKnowWidget dyk;
+ dyk.tipText->setText("To get started with MusE why don't you try some demo songs available at http://demos.muse-sequencer.org/");
+ dyk.show();
+ if( dyk.exec()) {
+ if (dyk.dontShowCheckBox->isChecked()) {
+ printf("disables dialog!\n");
+ config.showDidYouKnow=false;
+ muse->changeConfig(true); // save settings
+ }
+ }
+ }
+ }
+//---------------------------------------------------------
+// startDefineController
+//---------------------------------------------------------
+
+
+//---------------------------------------------------------
+// startClipList
+//---------------------------------------------------------
+
+void MusE::startClipList(bool checked)
+ {
+ if (clipListEdit == 0) {
+ //clipListEdit = new ClipListEdit();
+ clipListEdit = new ClipListEdit(this);
+ toplevels.push_back(Toplevel(Toplevel::CLIPLIST, (unsigned long)(clipListEdit), clipListEdit));
+ connect(clipListEdit, SIGNAL(deleted(unsigned long)), SLOT(toplevelDeleted(unsigned long)));
+ }
+ clipListEdit->show();
+ viewCliplistAction->setChecked(checked);
+ }
+
+//---------------------------------------------------------
+// fileMenu
+//---------------------------------------------------------
+
+void MusE::openRecentMenu()
+ {
+ openRecent->clear();
+ for (int i = 0; i < PROJECT_LIST_LEN; ++i) {
+ if (projectList[i] == 0)
+ break;
+ QByteArray ba = projectList[i]->toLatin1();
+ const char* path = ba.constData();
+ const char* p = strrchr(path, '/');
+ if (p == 0)
+ p = path;
+ else
+ ++p;
+ QAction *act = openRecent->addAction(QString(p));
+ act->setData(i);
+ }
+ }
+
+//---------------------------------------------------------
+// selectProject
+//---------------------------------------------------------
+
+void MusE::selectProject(QAction* act)
+ {
+ if (!act)
+ return;
+ int id = act->data().toInt();
+ assert(id < PROJECT_LIST_LEN);
+ QString* name = projectList[id];
+ if (name == 0)
+ return;
+ loadProjectFile(*name, false, true);
+ }
+
+//---------------------------------------------------------
+// toplevelDeleted
+//---------------------------------------------------------
+
+void MusE::toplevelDeleted(unsigned long tl)
+ {
+ for (iToplevel i = toplevels.begin(); i != toplevels.end(); ++i) {
+ if (i->object() == tl) {
+ switch(i->type()) {
+ case Toplevel::MARKER:
+ break;
+ case Toplevel::CLIPLIST:
+ // ORCAN: This needs to be verified. aid2 used to correspond to Cliplist:
+ //menu_audio->setItemChecked(aid2, false);
+ viewCliplistAction->setChecked(false);
+ return;
+ //break;
+ // the followin editors can exist in more than
+ // one instantiation:
+ case Toplevel::PIANO_ROLL:
+ case Toplevel::LISTE:
+ case Toplevel::DRUM:
+ case Toplevel::MASTER:
+ case Toplevel::WAVE:
+ case Toplevel::LMASTER:
+ break;
+ }
+ toplevels.erase(i);
+ return;
+ }
+ }
+ printf("topLevelDeleted: top level %lx not found\n", tl);
+ //assert(false);
+ }
+
+//---------------------------------------------------------
+// ctrlChanged
+// midi ctrl value changed
+//---------------------------------------------------------
+
+#if 0
+void MusE::ctrlChanged()
+ {
+ arranger->updateInspector();
+ }
+#endif
+
+//---------------------------------------------------------
+// keyPressEvent
+//---------------------------------------------------------
+
+void MusE::keyPressEvent(QKeyEvent* event)
+ {
+ // Pass it on to arranger part canvas.
+ arranger->getCanvas()->redirKeypress(event);
+ }
+
+//---------------------------------------------------------
+// kbAccel
+//---------------------------------------------------------
+
+void MusE::kbAccel(int key)
+ {
+ if (key == shortcuts[SHRT_TOGGLE_METRO].key) {
+ song->setClick(!song->click());
+ }
+ else if (key == shortcuts[SHRT_PLAY_TOGGLE].key) {
+ if (audio->isPlaying())
+ //song->setStopPlay(false);
+ song->setStop(true);
+ else if (!config.useOldStyleStopShortCut)
+ song->setPlay(true);
+ else if (song->cpos() != song->lpos())
+ song->setPos(0, song->lPos());
+ else {
+ Pos p(0, true);
+ song->setPos(0, p);
+ }
+ }
+ else if (key == shortcuts[SHRT_STOP].key) {
+ //song->setPlay(false);
+ song->setStop(true);
+ }
+ else if (key == shortcuts[SHRT_GOTO_START].key) {
+ Pos p(0, true);
+ song->setPos(0, p);
+ }
+ else if (key == shortcuts[SHRT_PLAY_SONG].key ) {
+ song->setPlay(true);
+ }
+
+ // p4.0.10 Tim. Normally each editor window handles these, to inc by the editor's raster snap value.
+ // But users were asking for a global version - "they don't work when I'm in mixer or transport".
+ // Since no editor claimed the key event, we don't know a specific editor's snap setting,
+ // so adopt a policy where the arranger is the 'main' raster reference, I guess...
+ else if (key == shortcuts[SHRT_POS_DEC].key) {
+ int spos = song->cpos();
+ if(spos > 0)
+ {
+ spos -= 1; // Nudge by -1, then snap down with raster1.
+ spos = AL::sigmap.raster1(spos, song->arrangerRaster());
+ }
+ if(spos < 0)
+ spos = 0;
+ Pos p(spos,true);
+ song->setPos(0, p, true, true, true);
+ return;
+ }
+ else if (key == shortcuts[SHRT_POS_INC].key) {
+ int spos = AL::sigmap.raster2(song->cpos() + 1, song->arrangerRaster()); // Nudge by +1, then snap up with raster2.
+ Pos p(spos,true);
+ song->setPos(0, p, true, true, true); //CDW
+ return;
+ }
+ else if (key == shortcuts[SHRT_POS_DEC_NOSNAP].key) {
+ int spos = song->cpos() - AL::sigmap.rasterStep(song->cpos(), song->arrangerRaster());
+ if(spos < 0)
+ spos = 0;
+ Pos p(spos,true);
+ song->setPos(0, p, true, true, true);
+ return;
+ }
+ else if (key == shortcuts[SHRT_POS_INC_NOSNAP].key) {
+ Pos p(song->cpos() + AL::sigmap.rasterStep(song->cpos(), song->arrangerRaster()), true);
+ song->setPos(0, p, true, true, true);
+ return;
+ }
+
+ else if (key == shortcuts[SHRT_GOTO_LEFT].key) {
+ if (!song->record())
+ song->setPos(0, song->lPos());
+ }
+ else if (key == shortcuts[SHRT_GOTO_RIGHT].key) {
+ if (!song->record())
+ song->setPos(0, song->rPos());
+ }
+ else if (key == shortcuts[SHRT_TOGGLE_LOOP].key) {
+ song->setLoop(!song->loop());
+ }
+ else if (key == shortcuts[SHRT_START_REC].key) {
+ if (!audio->isPlaying()) {
+ song->setRecord(!song->record());
+ }
+ }
+ else if (key == shortcuts[SHRT_REC_CLEAR].key) {
+ if (!audio->isPlaying()) {
+ song->clearTrackRec();
+ }
+ }
+ else if (key == shortcuts[SHRT_OPEN_TRANSPORT].key) {
+ toggleTransport(!viewTransportAction->isChecked());
+ }
+ else if (key == shortcuts[SHRT_OPEN_BIGTIME].key) {
+ toggleBigTime(!viewBigtimeAction->isChecked());
+ }
+ //else if (key == shortcuts[SHRT_OPEN_MIXER].key) {
+ // toggleMixer();
+ // }
+ else if (key == shortcuts[SHRT_OPEN_MIXER].key) {
+ toggleMixer1(!viewMixerAAction->isChecked());
+ }
+ else if (key == shortcuts[SHRT_OPEN_MIXER2].key) {
+ toggleMixer2(!viewMixerBAction->isChecked());
+ }
+ else if (key == shortcuts[SHRT_NEXT_MARKER].key) {
+ if (markerView)
+ markerView->nextMarker();
+ }
+ else if (key == shortcuts[SHRT_PREV_MARKER].key) {
+ if (markerView)
+ markerView->prevMarker();
+ }
+ else {
+ if (debugMsg)
+ printf("unknown kbAccel 0x%x\n", key);
+ }
+ }
+
+//---------------------------------------------------------
+// catchSignal
+// only for debugging
+//---------------------------------------------------------
+
+#if 0
+static void catchSignal(int sig)
+ {
+ if (debugMsg)
+ fprintf(stderr, "MusE: signal %d catched\n", sig);
+ if (sig == SIGSEGV) {
+ fprintf(stderr, "MusE: segmentation fault\n");
+ abort();
+ }
+ if (sig == SIGCHLD) {
+ M_DEBUG("caught SIGCHLD - child died\n");
+ int status;
+ int n = waitpid (-1, &status, WNOHANG);
+ if (n > 0) {
+ fprintf(stderr, "SIGCHLD for unknown process %d received\n", n);
+ }
+ }
+ }
+#endif
+
+#if 0
+//---------------------------------------------------------
+// configPart
+//---------------------------------------------------------
+
+void MusE::configPart(int id)
+ {
+ if (id < 3) {
+ partConfig->setItemChecked(0, id == 0);
+ partConfig->setItemChecked(1, id == 1);
+ partConfig->setItemChecked(2, id == 2);
+ arranger->setShowPartType(id);
+ for (int i = 3; i < 10; ++i) {
+ partConfig->setItemEnabled(i, id == 2);
+ }
+ }
+ else {
+ bool flag = !partConfig->isItemChecked(id);
+ partConfig->setItemChecked(id, flag);
+ int val = arranger->showPartEvent();
+ if (flag) {
+ val |= 1 << (id-3);
+ }
+ else {
+ val &= ~(1 << (id-3));
+ }
+ arranger->setShowPartEvent(val);
+ }
+ }
+#endif
+
+//---------------------------------------------------------
+// cmd
+// some cmd's from pulldown menu
+//---------------------------------------------------------
+
+void MusE::cmd(int cmd)
+ {
+ TrackList* tracks = song->tracks();
+ int l = song->lpos();
+ int r = song->rpos();
+
+ switch(cmd) {
+ case CMD_CUT:
+ arranger->cmd(Arranger::CMD_CUT_PART);
+ break;
+ case CMD_COPY:
+ arranger->cmd(Arranger::CMD_COPY_PART);
+ break;
+ case CMD_PASTE:
+ arranger->cmd(Arranger::CMD_PASTE_PART);
+ break;
+ case CMD_PASTE_CLONE:
+ arranger->cmd(Arranger::CMD_PASTE_CLONE_PART);
+ break;
+ case CMD_PASTE_TO_TRACK:
+ arranger->cmd(Arranger::CMD_PASTE_PART_TO_TRACK);
+ break;
+ case CMD_PASTE_CLONE_TO_TRACK:
+ arranger->cmd(Arranger::CMD_PASTE_CLONE_PART_TO_TRACK);
+ break;
+ case CMD_INSERT:
+ arranger->cmd(Arranger::CMD_INSERT_PART);
+ break;
+ case CMD_INSERTMEAS:
+ arranger->cmd(Arranger::CMD_INSERT_EMPTYMEAS);
+ break;
+ case CMD_DELETE:
+ song->startUndo();
+ if (song->msgRemoveParts()) {
+ song->endUndo(SC_PART_REMOVED);
+ break;
+ }
+ else
+ audio->msgRemoveTracks();
+ song->endUndo(SC_TRACK_REMOVED);
+ break;
+ case CMD_DELETE_TRACK:
+ song->startUndo();
+ audio->msgRemoveTracks();
+ song->endUndo(SC_TRACK_REMOVED);
+ audio->msgUpdateSoloStates();
+ break;
+
+ case CMD_SELECT_ALL:
+ case CMD_SELECT_NONE:
+ case CMD_SELECT_INVERT:
+ case CMD_SELECT_ILOOP:
+ case CMD_SELECT_OLOOP:
+ for (iTrack i = tracks->begin(); i != tracks->end(); ++i) {
+ PartList* parts = (*i)->parts();
+ for (iPart p = parts->begin(); p != parts->end(); ++p) {
+ bool f = false;
+ int t1 = p->second->tick();
+ int t2 = t1 + p->second->lenTick();
+ bool inside =
+ ((t1 >= l) && (t1 < r))
+ || ((t2 > l) && (t2 < r))
+ || ((t1 <= l) && (t2 > r));
+ switch(cmd) {
+ case CMD_SELECT_INVERT:
+ f = !p->second->selected();
+ break;
+ case CMD_SELECT_NONE:
+ f = false;
+ break;
+ case CMD_SELECT_ALL:
+ f = true;
+ break;
+ case CMD_SELECT_ILOOP:
+ f = inside;
+ break;
+ case CMD_SELECT_OLOOP:
+ f = !inside;
+ break;
+ }
+ p->second->setSelected(f);
+ }
+ }
+ song->update();
+ break;
+
+ case CMD_SELECT_PARTS:
+ for (iTrack i = tracks->begin(); i != tracks->end(); ++i) {
+ if (!(*i)->selected())
+ continue;
+ PartList* parts = (*i)->parts();
+ for (iPart p = parts->begin(); p != parts->end(); ++p)
+ p->second->setSelected(true);
+ }
+ song->update();
+ break;
+ case CMD_FOLLOW_NO:
+ song->setFollow(Song::NO);
+ setFollow();
+ break;
+ case CMD_FOLLOW_JUMP:
+ song->setFollow(Song::JUMP);
+ setFollow();
+ break;
+ case CMD_FOLLOW_CONTINUOUS:
+ song->setFollow(Song::CONTINUOUS);
+ setFollow();
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// clipboardChanged
+//---------------------------------------------------------
+
+void MusE::clipboardChanged()
+ {
+/*
+ //Q3CString subtype("partlist");
+ //QString subtype("partlist");
+ QMimeSource* ms = QApplication::clipboard()->data(QClipboard::Clipboard);
+ if (ms == 0)
+ return;
+ bool flag = false;
+ for (int i = 0; ms->format(i); ++i) {
+// printf("Format <%s\n", ms->format(i));
+ if ((strncmp(ms->format(i), "text/midipartlist", 17) == 0)
+ || (strncmp(ms->format(i), "text/wavepartlist", 17) == 0)
+ // Added by T356. Support mixed .mpt files.
+ || (strncmp(ms->format(i), "text/mixedpartlist", 18) == 0)) {
+ flag = true;
+ break;
+ }
+ }
+*/
+
+ bool flag = false;
+ if(QApplication::clipboard()->mimeData()->hasFormat(QString("text/x-muse-midipartlist")) ||
+ QApplication::clipboard()->mimeData()->hasFormat(QString("text/x-muse-wavepartlist")) ||
+ QApplication::clipboard()->mimeData()->hasFormat(QString("text/x-muse-mixedpartlist")))
+ flag = true;
+
+ //bool flag = false;
+ //if(!QApplication::clipboard()->text(QString("x-muse-midipartlist"), QClipboard::Clipboard).isEmpty() ||
+ // !QApplication::clipboard()->text(QString("x-muse-wavepartlist"), QClipboard::Clipboard).isEmpty() ||
+ // !QApplication::clipboard()->text(QString("x-muse-mixedpartlist"), QClipboard::Clipboard).isEmpty())
+ // flag = true;
+
+ editPasteAction->setEnabled(flag);
+ editInsertAction->setEnabled(flag);
+ editPasteCloneAction->setEnabled(flag);
+ editPaste2TrackAction->setEnabled(flag);
+ editPasteC2TAction->setEnabled(flag);
+ }
+
+//---------------------------------------------------------
+// selectionChanged
+//---------------------------------------------------------
+
+void MusE::selectionChanged()
+ {
+ //bool flag = arranger->isSingleSelection(); // -- Hmm, why only single?
+ bool flag = arranger->selectionSize() > 0; // -- Test OK cut and copy. For muse2. Tim.
+ editCutAction->setEnabled(flag);
+ editCopyAction->setEnabled(flag);
+ }
+
+//---------------------------------------------------------
+// transpose
+//---------------------------------------------------------
+
+void MusE::transpose()
+ {
+ Transpose *w = new Transpose();
+ w->show();
+ }
+
+//---------------------------------------------------------
+// modifyGateTime
+//---------------------------------------------------------
+
+void MusE::modifyGateTime()
+ {
+ GateTime* w = new GateTime(this);
+ w->show();
+ }
+
+//---------------------------------------------------------
+// modifyVelocity
+//---------------------------------------------------------
+
+void MusE::modifyVelocity()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// crescendo
+//---------------------------------------------------------
+
+void MusE::crescendo()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// thinOut
+//---------------------------------------------------------
+
+void MusE::thinOut()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// eraseEvent
+//---------------------------------------------------------
+
+void MusE::eraseEvent()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// noteShift
+//---------------------------------------------------------
+
+void MusE::noteShift()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// moveClock
+//---------------------------------------------------------
+
+void MusE::moveClock()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// copyMeasure
+//---------------------------------------------------------
+
+void MusE::copyMeasure()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// eraseMeasure
+//---------------------------------------------------------
+
+void MusE::eraseMeasure()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// deleteMeasure
+//---------------------------------------------------------
+
+void MusE::deleteMeasure()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// createMeasure
+//---------------------------------------------------------
+
+void MusE::createMeasure()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// mixTrack
+//---------------------------------------------------------
+
+void MusE::mixTrack()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// configAppearance
+//---------------------------------------------------------
+
+void MusE::configAppearance()
+ {
+ if (!appearance)
+ appearance = new Appearance(arranger);
+ appearance->resetValues();
+ if(appearance->isVisible()) {
+ appearance->raise();
+ appearance->activateWindow();
+ }
+ else
+ appearance->show();
+ }
+
+//---------------------------------------------------------
+// loadTheme
+//---------------------------------------------------------
+
+void MusE::loadTheme(const QString& s)
+ {
+ if (style()->objectName() != s)
+ QApplication::setStyle(s);
+ }
+
+//---------------------------------------------------------
+// loadStyleSheetFile
+//---------------------------------------------------------
+
+void MusE::loadStyleSheetFile(const QString& s)
+{
+ if(s.isEmpty())
+ {
+ qApp->setStyleSheet(s);
+ return;
+ }
+
+ QFile cf(s);
+ if (cf.open(QIODevice::ReadOnly)) {
+ QByteArray ss = cf.readAll();
+ QString sheet(QString::fromUtf8(ss.data()));
+ qApp->setStyleSheet(sheet);
+ cf.close();
+ }
+ else
+ printf("loading style sheet <%s> failed\n", qPrintable(s));
+}
+
+//---------------------------------------------------------
+// configChanged
+// - called whenever configuration has changed
+// - when configuration has changed by user, call with
+// writeFlag=true to save configuration in ~/.MusE
+//---------------------------------------------------------
+
+void MusE::changeConfig(bool writeFlag)
+ {
+ if (writeFlag)
+ writeGlobalConfiguration();
+
+ //loadStyleSheetFile(config.styleSheetFile);
+ loadTheme(config.style);
+ QApplication::setFont(config.fonts[0]);
+ loadStyleSheetFile(config.styleSheetFile);
+
+ emit configChanged();
+ updateConfiguration();
+ }
+
+//---------------------------------------------------------
+// configMetronome
+//---------------------------------------------------------
+
+void MusE::configMetronome()
+ {
+ if (!metronomeConfig)
+ metronomeConfig = new MetronomeConfig;
+
+ if(metronomeConfig->isVisible()) {
+ metronomeConfig->raise();
+ metronomeConfig->activateWindow();
+ }
+ else
+ metronomeConfig->show();
+ }
+
+
+//---------------------------------------------------------
+// configShortCuts
+//---------------------------------------------------------
+
+void MusE::configShortCuts()
+ {
+ if (!shortcutConfig)
+ shortcutConfig = new ShortcutConfig(this);
+ shortcutConfig->_config_changed = false;
+ if (shortcutConfig->exec())
+ changeConfig(true);
+ }
+
+//---------------------------------------------------------
+// globalCut
+// - remove area between left and right locator
+// - do not touch muted track
+// - cut master track
+//---------------------------------------------------------
+
+void MusE::globalCut()
+ {
+ int lpos = song->lpos();
+ int rpos = song->rpos();
+ if ((lpos - rpos) >= 0)
+ return;
+
+ song->startUndo();
+ TrackList* tracks = song->tracks();
+ for (iTrack it = tracks->begin(); it != tracks->end(); ++it) {
+ MidiTrack* track = dynamic_cast<MidiTrack*>(*it);
+ if (track == 0 || track->mute())
+ continue;
+ PartList* pl = track->parts();
+ for (iPart p = pl->begin(); p != pl->end(); ++p) {
+ Part* part = p->second;
+ int t = part->tick();
+ int l = part->lenTick();
+ if (t + l <= lpos)
+ continue;
+ if ((t >= lpos) && ((t+l) <= rpos)) {
+ audio->msgRemovePart(part, false);
+ }
+ else if ((t < lpos) && ((t+l) > lpos) && ((t+l) <= rpos)) {
+ // remove part tail
+ int len = lpos - t;
+ MidiPart* nPart = new MidiPart(*(MidiPart*)part);
+ nPart->setLenTick(len);
+ //
+ // cut Events in nPart
+ EventList* el = nPart->events();
+ iEvent ie = el->lower_bound(t + len);
+ for (; ie != el->end();) {
+ iEvent i = ie;
+ ++ie;
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgDeleteEvent(i->second, nPart, false);
+ audio->msgDeleteEvent(i->second, nPart, false, false, false);
+ }
+ // Indicate no undo, and do port controller values and clone parts.
+ //audio->msgChangePart(part, nPart, false);
+ audio->msgChangePart(part, nPart, false, true, true);
+ }
+ else if ((t < lpos) && ((t+l) > lpos) && ((t+l) > rpos)) {
+ //----------------------
+ // remove part middle
+ //----------------------
+
+ MidiPart* nPart = new MidiPart(*(MidiPart*)part);
+ EventList* el = nPart->events();
+ iEvent is = el->lower_bound(lpos);
+ iEvent ie = el->upper_bound(rpos);
+ for (iEvent i = is; i != ie;) {
+ iEvent ii = i;
+ ++i;
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgDeleteEvent(ii->second, nPart, false);
+ audio->msgDeleteEvent(ii->second, nPart, false, false, false);
+ }
+
+ ie = el->lower_bound(rpos);
+ for (; ie != el->end();) {
+ iEvent i = ie;
+ ++ie;
+ Event event = i->second;
+ Event nEvent = event.clone();
+ nEvent.setTick(nEvent.tick() - (rpos-lpos));
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(event, nEvent, nPart, false);
+ audio->msgChangeEvent(event, nEvent, nPart, false, false, false);
+ }
+ nPart->setLenTick(l - (rpos-lpos));
+ // Indicate no undo, and do port controller values and clone parts.
+ //audio->msgChangePart(part, nPart, false);
+ audio->msgChangePart(part, nPart, false, true, true);
+ }
+ else if ((t >= lpos) && (t < rpos) && (t+l) > rpos) {
+ // TODO: remove part head
+ }
+ else if (t >= rpos) {
+ MidiPart* nPart = new MidiPart(*(MidiPart*)part);
+ int nt = part->tick();
+ nPart->setTick(nt - (rpos -lpos));
+ // Indicate no undo, and do port controller values but not clone parts.
+ //audio->msgChangePart(part, nPart, false);
+ audio->msgChangePart(part, nPart, false, true, false);
+ }
+ }
+ }
+ // TODO: cut tempo track
+ // TODO: process marker
+ song->endUndo(SC_TRACK_MODIFIED | SC_PART_MODIFIED | SC_PART_REMOVED);
+ }
+
+//---------------------------------------------------------
+// globalInsert
+// - insert empty space at left locator position upto
+// right locator
+// - do not touch muted track
+// - insert in master track
+//---------------------------------------------------------
+
+void MusE::globalInsert()
+ {
+ unsigned lpos = song->lpos();
+ unsigned rpos = song->rpos();
+ if (lpos >= rpos)
+ return;
+
+ song->startUndo();
+ TrackList* tracks = song->tracks();
+ for (iTrack it = tracks->begin(); it != tracks->end(); ++it) {
+ MidiTrack* track = dynamic_cast<MidiTrack*>(*it);
+ //
+ // process only non muted midi tracks
+ //
+ if (track == 0 || track->mute())
+ continue;
+ PartList* pl = track->parts();
+ for (iPart p = pl->begin(); p != pl->end(); ++p) {
+ Part* part = p->second;
+ unsigned t = part->tick();
+ int l = part->lenTick();
+ if (t + l <= lpos)
+ continue;
+ if (lpos >= t && lpos < (t+l)) {
+ MidiPart* nPart = new MidiPart(*(MidiPart*)part);
+ nPart->setLenTick(l + (rpos-lpos));
+ EventList* el = nPart->events();
+
+ iEvent i = el->end();
+ while (i != el->begin()) {
+ --i;
+ if (i->first < lpos)
+ break;
+ Event event = i->second;
+ Event nEvent = i->second.clone();
+ nEvent.setTick(nEvent.tick() + (rpos-lpos));
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(event, nEvent, nPart, false);
+ audio->msgChangeEvent(event, nEvent, nPart, false, false, false);
+ }
+ // Indicate no undo, and do port controller values and clone parts.
+ //audio->msgChangePart(part, nPart, false);
+ audio->msgChangePart(part, nPart, false, true, true);
+ }
+ else if (t > lpos) {
+ MidiPart* nPart = new MidiPart(*(MidiPart*)part);
+ nPart->setTick(t + (rpos -lpos));
+ // Indicate no undo, and do port controller values but not clone parts.
+ //audio->msgChangePart(part, nPart, false);
+ audio->msgChangePart(part, nPart, false, true, false);
+ }
+ }
+ }
+ // TODO: process tempo track
+ // TODO: process marker
+ song->endUndo(SC_TRACK_MODIFIED | SC_PART_MODIFIED | SC_PART_REMOVED);
+ }
+
+//---------------------------------------------------------
+// globalSplit
+// - split all parts at the song position pointer
+// - do not touch muted track
+//---------------------------------------------------------
+
+void MusE::globalSplit()
+ {
+ int pos = song->cpos();
+ song->startUndo();
+ TrackList* tracks = song->tracks();
+ for (iTrack it = tracks->begin(); it != tracks->end(); ++it) {
+ Track* track = *it;
+ PartList* pl = track->parts();
+ for (iPart p = pl->begin(); p != pl->end(); ++p) {
+ Part* part = p->second;
+ int p1 = part->tick();
+ int l0 = part->lenTick();
+ if (pos > p1 && pos < (p1+l0)) {
+ Part* p1;
+ Part* p2;
+ track->splitPart(part, pos, p1, p2);
+ // Indicate no undo, and do port controller values but not clone parts.
+ //audio->msgChangePart(part, p1, false);
+ audio->msgChangePart(part, p1, false, true, false);
+ audio->msgAddPart(p2, false);
+ break;
+ }
+ }
+ }
+ song->endUndo(SC_TRACK_MODIFIED | SC_PART_MODIFIED | SC_PART_INSERTED);
+ }
+
+//---------------------------------------------------------
+// copyRange
+// - copy space between left and right locator position
+// to song position pointer
+// - dont process muted tracks
+// - create a new part for every track containing the
+// copied events
+//---------------------------------------------------------
+
+void MusE::copyRange()
+ {
+ QMessageBox::critical(this,
+ tr("MusE: Copy Range"),
+ tr("not implemented")
+ );
+ }
+
+//---------------------------------------------------------
+// cutEvents
+// - make sure that all events in a part end where the
+// part ends
+// - process only marked parts
+//---------------------------------------------------------
+
+void MusE::cutEvents()
+ {
+ QMessageBox::critical(this,
+ tr("MusE: Cut Events"),
+ tr("not implemented")
+ );
+ }
+
+//---------------------------------------------------------
+// checkRegionNotNull
+// return true if (rPos - lPos) <= 0
+//---------------------------------------------------------
+
+bool MusE::checkRegionNotNull()
+ {
+ int start = song->lPos().frame();
+ int end = song->rPos().frame();
+ if (end - start <= 0) {
+ QMessageBox::critical(this,
+ tr("MusE: Bounce"),
+ tr("set left/right marker for bounce range")
+ );
+ return true;
+ }
+ return false;
+ }
+
+#if 0
+//---------------------------------------------------------
+// openAudioFileManagement
+//---------------------------------------------------------
+void MusE::openAudioFileManagement()
+ {
+ if (!audioFileManager) {
+ audioFileManager = new AudioFileManager(this, "audiofilemanager", false);
+ audioFileManager->show();
+ }
+ audioFileManager->setVisible(true);
+ }
+#endif
+//---------------------------------------------------------
+// bounceToTrack
+//---------------------------------------------------------
+
+void MusE::bounceToTrack()
+ {
+ if(audio->bounce())
+ return;
+
+ song->bounceOutput = 0;
+
+ if(song->waves()->empty())
+ {
+ QMessageBox::critical(this,
+ tr("MusE: Bounce to Track"),
+ tr("No wave tracks found")
+ );
+ return;
+ }
+
+ OutputList* ol = song->outputs();
+ if(ol->empty())
+ {
+ QMessageBox::critical(this,
+ tr("MusE: Bounce to Track"),
+ tr("No audio output tracks found")
+ );
+ return;
+ }
+
+ if(checkRegionNotNull())
+ return;
+
+ AudioOutput* out = 0;
+ // If only one output, pick it, else pick the first selected.
+ if(ol->size() == 1)
+ out = ol->front();
+ else
+ {
+ for(iAudioOutput iao = ol->begin(); iao != ol->end(); ++iao)
+ {
+ AudioOutput* o = *iao;
+ if(o->selected())
+ {
+ if(out)
+ {
+ out = 0;
+ break;
+ }
+ out = o;
+ }
+ }
+ if(!out)
+ {
+ QMessageBox::critical(this,
+ tr("MusE: Bounce to Track"),
+ tr("Select one audio output track,\nand one target wave track")
+ );
+ return;
+ }
+ }
+
+ // search target track
+ TrackList* tl = song->tracks();
+ WaveTrack* track = 0;
+
+ for (iTrack it = tl->begin(); it != tl->end(); ++it) {
+ Track* t = *it;
+ if (t->selected()) {
+ if(t->type() != Track::WAVE && t->type() != Track::AUDIO_OUTPUT) {
+ track = 0;
+ break;
+ }
+ if(t->type() == Track::WAVE)
+ {
+ if(track)
+ {
+ track = 0;
+ break;
+ }
+ track = (WaveTrack*)t;
+ }
+
+ }
+ }
+
+ if (track == 0) {
+ if(ol->size() == 1) {
+ QMessageBox::critical(this,
+ tr("MusE: Bounce to Track"),
+ tr("Select one target wave track")
+ );
+ return;
+ }
+ else
+ {
+ QMessageBox::critical(this,
+ tr("MusE: Bounce to Track"),
+ tr("Select one target wave track,\nand one audio output track")
+ );
+ return;
+ }
+ }
+ song->bounceOutput = out;
+ song->bounceTrack = track;
+ song->setRecord(true);
+ song->setRecordFlag(track, true);
+ audio->msgBounce();
+ }
+
+//---------------------------------------------------------
+// bounceToFile
+//---------------------------------------------------------
+
+void MusE::bounceToFile(AudioOutput* ao)
+ {
+ if(audio->bounce())
+ return;
+ song->bounceOutput = 0;
+ if(!ao)
+ {
+ OutputList* ol = song->outputs();
+ if(ol->empty())
+ {
+ QMessageBox::critical(this,
+ tr("MusE: Bounce to Track"),
+ tr("No audio output tracks found")
+ );
+ return;
+ }
+ // If only one output, pick it, else pick the first selected.
+ if(ol->size() == 1)
+ ao = ol->front();
+ else
+ {
+ for(iAudioOutput iao = ol->begin(); iao != ol->end(); ++iao)
+ {
+ AudioOutput* o = *iao;
+ if(o->selected())
+ {
+ if(ao)
+ {
+ ao = 0;
+ break;
+ }
+ ao = o;
+ }
+ }
+ if (ao == 0) {
+ QMessageBox::critical(this,
+ tr("MusE: Bounce to File"),
+ tr("Select one audio output track")
+ );
+ return;
+ }
+ }
+ }
+
+ if (checkRegionNotNull())
+ return;
+
+ SndFile* sf = getSndFile(0, this);
+ if (sf == 0)
+ return;
+
+ song->bounceOutput = ao;
+ ao->setRecFile(sf);
+ song->setRecord(true, false);
+ song->setRecordFlag(ao, true);
+ audio->msgBounce();
+ }
+
+#ifdef HAVE_LASH
+//---------------------------------------------------------
+// lash_idle_cb
+//---------------------------------------------------------
+#include <iostream>
+void
+MusE::lash_idle_cb ()
+{
+ lash_event_t * event;
+ if (!lash_client)
+ return;
+
+ while ( (event = lash_get_event (lash_client)) )
+ {
+ switch (lash_event_get_type (event))
+ {
+ case LASH_Save_File:
+ {
+ /* save file */
+ QString ss = QString(lash_event_get_string(event)) + QString("/lash-project-muse.med");
+ int ok = save (ss.toAscii(), false);
+ if (ok) {
+ project.setFile(ss.toAscii());
+ setWindowTitle(tr("MusE: Song: ") + project.completeBaseName());
+ addProject(ss.toAscii());
+ museProject = QFileInfo(ss.toAscii()).absolutePath();
+ }
+ lash_send_event (lash_client, event);
+ }
+ break;
+
+ case LASH_Restore_File:
+ {
+ /* load file */
+ QString sr = QString(lash_event_get_string(event)) + QString("/lash-project-muse.med");
+ loadProjectFile(sr.toAscii(), false, true);
+ lash_send_event (lash_client, event);
+ }
+ break;
+
+ case LASH_Quit:
+ {
+ /* quit muse */
+ std::cout << "MusE::lash_idle_cb Received LASH_Quit"
+ << std::endl;
+ lash_event_destroy (event);
+ }
+ break;
+
+ default:
+ {
+ std::cout << "MusE::lash_idle_cb Received unknown LASH event of type "
+ << lash_event_get_type (event)
+ << std::endl;
+ lash_event_destroy (event);
+ }
+ break;
+ }
+ }
+}
+#endif /* HAVE_LASH */
+
+//---------------------------------------------------------
+// clearSong
+// return true if operation aborted
+// called with sequencer stopped
+//---------------------------------------------------------
+
+bool MusE::clearSong()
+ {
+ if (song->dirty) {
+ int n = 0;
+ n = QMessageBox::warning(this, appName,
+ tr("The current Project contains unsaved data\n"
+ "Load overwrites current Project:\n"
+ "Save Current Project?"),
+ tr("&Save"), tr("&Skip"), tr("&Abort"), 0, 2);
+ switch (n) {
+ case 0:
+ if (!save()) // abort if save failed
+ return true;
+ break;
+ case 1:
+ break;
+ case 2:
+ return true;
+ default:
+ printf("InternalError: gibt %d\n", n);
+ }
+ }
+ if (audio->isPlaying()) {
+ audio->msgPlay(false);
+ while (audio->isPlaying())
+ qApp->processEvents();
+ }
+ microSleep(100000);
+
+again:
+ for (iToplevel i = toplevels.begin(); i != toplevels.end(); ++i) {
+ Toplevel tl = *i;
+ unsigned long obj = tl.object();
+ switch (tl.type()) {
+ case Toplevel::CLIPLIST:
+ case Toplevel::MARKER:
+ break;
+ case Toplevel::PIANO_ROLL:
+ case Toplevel::LISTE:
+ case Toplevel::DRUM:
+ case Toplevel::MASTER:
+ case Toplevel::WAVE:
+ case Toplevel::LMASTER:
+ ((QWidget*)(obj))->close();
+ goto again;
+ }
+ }
+ microSleep(100000);
+ song->clear(false);
+ microSleep(100000);
+ return false;
+ }
+
+//---------------------------------------------------------
+// startEditInstrument
+//---------------------------------------------------------
+
+void MusE::startEditInstrument()
+ {
+ if(editInstrument == 0)
+ {
+ editInstrument = new EditInstrument(this);
+ editInstrument->show();
+ }
+ else
+ {
+ if(! editInstrument->isHidden())
+ editInstrument->hide();
+ else
+ editInstrument->show();
+ }
+
+ }
+
+//---------------------------------------------------------
+// switchMixerAutomation
+//---------------------------------------------------------
+
+void MusE::switchMixerAutomation()
+ {
+ automation = !automation;
+ // Clear all pressed and touched and rec event lists.
+ song->clearRecAutomation(true);
+
+// printf("automation = %d\n", automation);
+ autoMixerAction->setChecked(automation);
+ }
+
+//---------------------------------------------------------
+// clearAutomation
+//---------------------------------------------------------
+
+void MusE::clearAutomation()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// takeAutomationSnapshot
+//---------------------------------------------------------
+
+void MusE::takeAutomationSnapshot()
+ {
+ int frame = song->cPos().frame();
+ TrackList* tracks = song->tracks();
+ for (iTrack i = tracks->begin(); i != tracks->end(); ++i) {
+ if ((*i)->isMidiTrack())
+ continue;
+ AudioTrack* track = (AudioTrack*)*i;
+ CtrlListList* cll = track->controller();
+ for (iCtrlList icl = cll->begin(); icl != cll->end(); ++icl) {
+ double val = icl->second->curVal();
+ icl->second->add(frame, val);
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// updateConfiguration
+// called whenever the configuration has changed
+//---------------------------------------------------------
+
+void MusE::updateConfiguration()
+ {
+ fileOpenAction->setShortcut(shortcuts[SHRT_OPEN].key);
+ fileNewAction->setShortcut(shortcuts[SHRT_NEW].key);
+ fileSaveAction->setShortcut(shortcuts[SHRT_SAVE].key);
+ fileSaveAsAction->setShortcut(shortcuts[SHRT_SAVE_AS].key);
+
+ //menu_file->setShortcut(shortcuts[SHRT_OPEN_RECENT].key, menu_ids[CMD_OPEN_RECENT]); // Not used.
+ fileImportMidiAction->setShortcut(shortcuts[SHRT_IMPORT_MIDI].key);
+ fileExportMidiAction->setShortcut(shortcuts[SHRT_EXPORT_MIDI].key);
+ fileImportPartAction->setShortcut(shortcuts[SHRT_IMPORT_PART].key);
+ fileImportWaveAction->setShortcut(shortcuts[SHRT_IMPORT_AUDIO].key);
+ quitAction->setShortcut(shortcuts[SHRT_QUIT].key);
+
+ //menu_file->setShortcut(shortcuts[SHRT_LOAD_TEMPLATE].key, menu_ids[CMD_LOAD_TEMPLATE]); // Not used.
+
+ undoAction->setShortcut(shortcuts[SHRT_UNDO].key);
+ redoAction->setShortcut(shortcuts[SHRT_REDO].key);
+
+ editCutAction->setShortcut(shortcuts[SHRT_CUT].key);
+ editCopyAction->setShortcut(shortcuts[SHRT_COPY].key);
+ editPasteAction->setShortcut(shortcuts[SHRT_PASTE].key);
+ editInsertAction->setShortcut(shortcuts[SHRT_INSERT].key);
+ editPasteCloneAction->setShortcut(shortcuts[SHRT_PASTE_CLONE].key);
+ editPaste2TrackAction->setShortcut(shortcuts[SHRT_PASTE_TO_TRACK].key);
+ editPasteC2TAction->setShortcut(shortcuts[SHRT_PASTE_CLONE_TO_TRACK].key);
+ editInsertEMAction->setShortcut(shortcuts[SHRT_INSERTMEAS].key);
+
+ //editDeleteSelectedAction has no acceleration
+
+ trackMidiAction->setShortcut(shortcuts[SHRT_ADD_MIDI_TRACK].key);
+ trackDrumAction->setShortcut(shortcuts[SHRT_ADD_DRUM_TRACK].key);
+ trackWaveAction->setShortcut(shortcuts[SHRT_ADD_WAVE_TRACK].key);
+ trackAOutputAction->setShortcut(shortcuts[SHRT_ADD_AUDIO_OUTPUT].key);
+ trackAGroupAction->setShortcut(shortcuts[SHRT_ADD_AUDIO_GROUP].key);
+ trackAInputAction->setShortcut(shortcuts[SHRT_ADD_AUDIO_INPUT].key);
+ trackAAuxAction->setShortcut(shortcuts[SHRT_ADD_AUDIO_AUX].key);
+
+ editSelectAllAction->setShortcut(shortcuts[SHRT_SELECT_NONE].key);
+ editDeselectAllAction->setShortcut(shortcuts[SHRT_SELECT_NONE].key);
+ editInvertSelectionAction->setShortcut(shortcuts[SHRT_SELECT_INVERT].key);
+ editInsideLoopAction->setShortcut(shortcuts[SHRT_SELECT_OLOOP].key);
+ editOutsideLoopAction->setShortcut(shortcuts[SHRT_SELECT_OLOOP].key);
+ editAllPartsAction->setShortcut(shortcuts[SHRT_SELECT_PRTSTRACK].key);
+
+ startPianoEditAction->setShortcut(shortcuts[SHRT_OPEN_PIANO].key);
+ startDrumEditAction->setShortcut(shortcuts[SHRT_OPEN_DRUMS].key);
+ startListEditAction->setShortcut(shortcuts[SHRT_OPEN_LIST].key);
+ startWaveEditAction->setShortcut(shortcuts[SHRT_OPEN_WAVE].key);
+
+ masterGraphicAction->setShortcut(shortcuts[SHRT_OPEN_GRAPHIC_MASTER].key);
+ masterListAction->setShortcut(shortcuts[SHRT_OPEN_LIST_MASTER].key);
+
+ midiTransposeAction->setShortcut(shortcuts[SHRT_TRANSPOSE].key);
+ midiTransformerAction->setShortcut(shortcuts[SHRT_OPEN_MIDI_TRANSFORM].key);
+ //editSongInfoAction has no acceleration
+
+ viewTransportAction->setShortcut(shortcuts[SHRT_OPEN_TRANSPORT].key);
+ viewBigtimeAction->setShortcut(shortcuts[SHRT_OPEN_BIGTIME].key);
+ viewMixerAAction->setShortcut(shortcuts[SHRT_OPEN_MIXER].key);
+ viewMixerBAction->setShortcut(shortcuts[SHRT_OPEN_MIXER2].key);
+ //viewCliplistAction has no acceleration
+ viewMarkerAction->setShortcut(shortcuts[SHRT_OPEN_MARKER].key);
+
+ strGlobalCutAction->setShortcut(shortcuts[SHRT_GLOBAL_CUT].key);
+ strGlobalInsertAction->setShortcut(shortcuts[SHRT_GLOBAL_INSERT].key);
+ strGlobalSplitAction->setShortcut(shortcuts[SHRT_GLOBAL_SPLIT].key);
+ strCopyRangeAction->setShortcut(shortcuts[SHRT_COPY_RANGE].key);
+ strCutEventsAction->setShortcut(shortcuts[SHRT_CUT_EVENTS].key);
+
+ // midiEditInstAction does not have acceleration
+ midiResetInstAction->setShortcut(shortcuts[SHRT_MIDI_RESET].key);
+ midiInitInstActions->setShortcut(shortcuts[SHRT_MIDI_INIT].key);
+ midiLocalOffAction->setShortcut(shortcuts[SHRT_MIDI_LOCAL_OFF].key);
+ midiTrpAction->setShortcut(shortcuts[SHRT_MIDI_INPUT_TRANSPOSE].key);
+ midiInputTrfAction->setShortcut(shortcuts[SHRT_MIDI_INPUT_TRANSFORM].key);
+ midiInputFilterAction->setShortcut(shortcuts[SHRT_MIDI_INPUT_FILTER].key);
+ midiRemoteAction->setShortcut(shortcuts[SHRT_MIDI_REMOTE_CONTROL].key);
+#ifdef BUILD_EXPERIMENTAL
+ midiRhythmAction->setShortcut(shortcuts[SHRT_RANDOM_RHYTHM_GENERATOR].key);
+#endif
+
+ audioBounce2TrackAction->setShortcut(shortcuts[SHRT_AUDIO_BOUNCE_TO_TRACK].key);
+ audioBounce2FileAction->setShortcut(shortcuts[SHRT_AUDIO_BOUNCE_TO_FILE].key);
+ audioRestartAction->setShortcut(shortcuts[SHRT_AUDIO_RESTART].key);
+
+ autoMixerAction->setShortcut(shortcuts[SHRT_MIXER_AUTOMATION].key);
+ autoSnapshotAction->setShortcut(shortcuts[SHRT_MIXER_SNAPSHOT].key);
+ autoClearAction->setShortcut(shortcuts[SHRT_MIXER_AUTOMATION_CLEAR].key);
+
+ settingsGlobalAction->setShortcut(shortcuts[SHRT_GLOBAL_CONFIG].key);
+ settingsShortcutsAction->setShortcut(shortcuts[SHRT_CONFIG_SHORTCUTS].key);
+ settingsMetronomeAction->setShortcut(shortcuts[SHRT_CONFIG_METRONOME].key);
+ settingsMidiSyncAction->setShortcut(shortcuts[SHRT_CONFIG_MIDISYNC].key);
+ // settingsMidiIOAction does not have acceleration
+ settingsAppearanceAction->setShortcut(shortcuts[SHRT_APPEARANCE_SETTINGS].key);
+ settingsMidiPortAction->setShortcut(shortcuts[SHRT_CONFIG_MIDI_PORTS].key);
+
+
+ dontFollowAction->setShortcut(shortcuts[SHRT_FOLLOW_NO].key);
+ followPageAction->setShortcut(shortcuts[SHRT_FOLLOW_JUMP].key);
+ followCtsAction->setShortcut(shortcuts[SHRT_FOLLOW_CONTINUOUS].key);
+
+ helpManualAction->setShortcut(shortcuts[SHRT_OPEN_HELP].key);
+
+ // Orcan: Old stuff, needs to be converted. These aren't used anywhere so I commented them out
+ //menuSettings->setAccel(shortcuts[SHRT_CONFIG_AUDIO_PORTS].key, menu_ids[CMD_CONFIG_AUDIO_PORTS]);
+ //menu_help->setAccel(menu_ids[CMD_START_WHATSTHIS], shortcuts[SHRT_START_WHATSTHIS].key);
+
+ // Just in case, but no, app kb handler takes care of these.
+ /*
+ loopAction->setShortcut(shortcuts[].key);
+ punchinAction->setShortcut(shortcuts[].key);
+ punchoutAction->setShortcut(shortcuts[].key);
+ startAction->setShortcut(shortcuts[].key);
+ rewindAction->setShortcut(shortcuts[].key);
+ forwardAction->setShortcut(shortcuts[].key);
+ stopAction->setShortcut(shortcuts[].key);
+ playAction->setShortcut(shortcuts[].key);
+ recordAction->setShortcut(shortcuts[].key);
+ panicAction->setShortcut(shortcuts[].key);
+ */
+ }
+
+//---------------------------------------------------------
+// showBigtime
+//---------------------------------------------------------
+
+void MusE::showBigtime(bool on)
+ {
+ if (on && bigtime == 0) {
+ bigtime = new BigTime(0);
+ bigtime->setPos(0, song->cpos(), false);
+ connect(song, SIGNAL(posChanged(int, unsigned, bool)), bigtime, SLOT(setPos(int, unsigned, bool)));
+ connect(muse, SIGNAL(configChanged()), bigtime, SLOT(configChanged()));
+ connect(bigtime, SIGNAL(closed()), SLOT(bigtimeClosed()));
+ bigtime->resize(config.geometryBigTime.size());
+ bigtime->move(config.geometryBigTime.topLeft());
+ }
+ if (bigtime)
+ bigtime->setVisible(on);
+ viewBigtimeAction->setChecked(on);
+ }
+
+//---------------------------------------------------------
+// toggleBigTime
+//---------------------------------------------------------
+
+void MusE::toggleBigTime(bool checked)
+ {
+ showBigtime(checked);
+ }
+
+//---------------------------------------------------------
+// bigtimeClosed
+//---------------------------------------------------------
+
+void MusE::bigtimeClosed()
+ {
+ viewBigtimeAction->setChecked(false);
+ }
+
+//---------------------------------------------------------
+// showMixer
+//---------------------------------------------------------
+
+/*
+void MusE::showMixer(bool on)
+ {
+ if (on && audioMixer == 0) {
+ audioMixer = new AudioMixerApp(this);
+ connect(audioMixer, SIGNAL(closed()), SLOT(mixerClosed()));
+ audioMixer->resize(config.geometryMixer.size());
+ audioMixer->move(config.geometryMixer.topLeft());
+ }
+ if (audioMixer)
+ audioMixer->setVisible(on);
+ menuView->setItemChecked(aid1, on);
+ }
+*/
+
+//---------------------------------------------------------
+// showMixer1
+//---------------------------------------------------------
+
+void MusE::showMixer1(bool on)
+ {
+ if (on && mixer1 == 0) {
+ mixer1 = new AudioMixerApp(this, &(config.mixer1));
+ connect(mixer1, SIGNAL(closed()), SLOT(mixer1Closed()));
+ mixer1->resize(config.mixer1.geometry.size());
+ mixer1->move(config.mixer1.geometry.topLeft());
+ }
+ if (mixer1)
+ mixer1->setVisible(on);
+ viewMixerAAction->setChecked(on);
+ }
+
+//---------------------------------------------------------
+// showMixer2
+//---------------------------------------------------------
+
+void MusE::showMixer2(bool on)
+ {
+ if (on && mixer2 == 0) {
+ mixer2 = new AudioMixerApp(this, &(config.mixer2));
+ connect(mixer2, SIGNAL(closed()), SLOT(mixer2Closed()));
+ mixer2->resize(config.mixer2.geometry.size());
+ mixer2->move(config.mixer2.geometry.topLeft());
+ }
+ if (mixer2)
+ mixer2->setVisible(on);
+ viewMixerBAction->setChecked(on);
+ }
+
+//---------------------------------------------------------
+// toggleMixer
+//---------------------------------------------------------
+
+/*
+void MusE::toggleMixer()
+ {
+ showMixer(!menuView->isItemChecked(aid1));
+ }
+*/
+
+//---------------------------------------------------------
+// toggleMixer1
+//---------------------------------------------------------
+
+void MusE::toggleMixer1(bool checked)
+ {
+ showMixer1(checked);
+ }
+
+//---------------------------------------------------------
+// toggleMixer2
+//---------------------------------------------------------
+
+void MusE::toggleMixer2(bool checked)
+ {
+ showMixer2(checked);
+ }
+
+//---------------------------------------------------------
+// mixerClosed
+//---------------------------------------------------------
+
+/*
+void MusE::mixerClosed()
+ {
+ menuView->setItemChecked(aid1, false);
+ }
+*/
+
+//---------------------------------------------------------
+// mixer1Closed
+//---------------------------------------------------------
+
+void MusE::mixer1Closed()
+ {
+ viewMixerAAction->setChecked(false);
+ }
+
+//---------------------------------------------------------
+// mixer2Closed
+//---------------------------------------------------------
+
+void MusE::mixer2Closed()
+ {
+ viewMixerBAction->setChecked(false);
+ }
+
+
+//QWidget* MusE::mixerWindow() { return audioMixer; }
+QWidget* MusE::mixer1Window() { return mixer1; }
+QWidget* MusE::mixer2Window() { return mixer2; }
+
+QWidget* MusE::transportWindow() { return transport; }
+QWidget* MusE::bigtimeWindow() { return bigtime; }
+
+//---------------------------------------------------------
+// focusInEvent
+//---------------------------------------------------------
+
+void MusE::focusInEvent(QFocusEvent* ev)
+ {
+ //if (audioMixer)
+ // audioMixer->raise();
+ if (mixer1)
+ mixer1->raise();
+ if (mixer2)
+ mixer2->raise();
+ raise();
+ QMainWindow::focusInEvent(ev);
+ }
+
+//---------------------------------------------------------
+// setUsedTool
+//---------------------------------------------------------
+
+void MusE::setUsedTool(int tool)
+ {
+ tools1->set(tool);
+ }
+
+
+//---------------------------------------------------------
+// execDeliveredScript
+//---------------------------------------------------------
+void MusE::execDeliveredScript(int id)
+{
+ //QString scriptfile = QString(INSTPREFIX) + SCRIPTSSUFFIX + deliveredScriptNames[id];
+ song->executeScript(song->getScriptPath(id, true).toLatin1().constData(), song->getSelectedMidiParts(), 0, false); // TODO: get quant from arranger
+}
+//---------------------------------------------------------
+// execUserScript
+//---------------------------------------------------------
+void MusE::execUserScript(int id)
+{
+ song->executeScript(song->getScriptPath(id, false).toLatin1().constData(), song->getSelectedMidiParts(), 0, false); // TODO: get quant from arranger
+}
diff --git a/attic/muse2-oom/muse2/muse/app.cpp.orig b/attic/muse2-oom/muse2/muse/app.cpp.orig
new file mode 100644
index 00000000..4a3d79a3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/app.cpp.orig
@@ -0,0 +1,4792 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: app.cpp,v 1.113.2.68 2009/12/21 14:51:51 spamatica Exp $
+//
+// (C) Copyright 1999-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "config.h"
+
+#include <string>
+#include <map>
+#include <assert.h>
+#include <getopt.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <sys/wait.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <time.h>
+#include <signal.h>
+#include <stdarg.h>
+
+#include <q3buttongroup.h>
+#include <q3popupmenu.h>
+#include <qmessagebox.h>
+#include <qclipboard.h>
+#include <qsocketnotifier.h>
+#include <qtextcodec.h>
+#include <qstylefactory.h>
+#include <qmenubar.h>
+#include <qapplication.h>
+#include <qtimer.h>
+#include <qstyle.h>
+#include <qsplashscreen.h>
+#include <qobject.h>
+//Added by qt3to4:
+#include <QTimerEvent>
+#include <Q3CString>
+#include <QFocusEvent>
+#include <QTranslator>
+#include <QKeyEvent>
+#include <QEvent>
+#include <Q3ActionGroup>
+#include <QPixmap>
+#include <QCloseEvent>
+
+#include "app.h"
+#include "popupmenu.h"
+#include "transport.h"
+#include "bigtime.h"
+#include "arranger.h"
+#include "pianoroll.h"
+#include "xml.h"
+#include "midi.h"
+#include "conf.h"
+#include "listedit.h"
+#include "master/masteredit.h"
+#include "master/lmaster.h"
+#include "drumedit.h"
+#include "ttoolbar.h"
+#include "amixer.h"
+#include "cliplist/cliplist.h"
+#include "midiport.h"
+#include "audiodev.h"
+#include "mididev.h"
+#include "waveedit.h"
+#include "icons.h"
+#include "minstrument.h"
+#include "mixdowndialog.h"
+#include "midictrl.h"
+#include "filedialog.h"
+#include "plugin.h"
+#include "marker/markerview.h"
+#include "transpose.h"
+#include "appearance.h"
+#include "gatetime.h"
+#include "metronome.h"
+#include "debug.h"
+#include "event.h"
+#include "audio.h"
+#include "midiseq.h"
+#include "audioprefetch.h"
+#include "wave.h"
+#include "shortcutconfig.h"
+#include "gconfig.h"
+#include "driver/jackaudio.h"
+#include "track.h"
+#include "ticksynth.h"
+#include "instruments/editinstrument.h"
+#include "synth.h"
+#include "remote/pyapi.h"
+#include "al/dsp.h"
+
+#ifdef DSSI_SUPPORT
+#include "dssihost.h"
+#endif
+
+#ifdef VST_SUPPORT
+#include "vst.h"
+#endif
+
+#include <alsa/asoundlib.h>
+#include "songinfo.h"
+#include "didyouknow.h"
+#include <q3textedit.h>
+
+//extern void cacheJackRouteNames();
+
+static pthread_t watchdogThread;
+//ErrorHandler *error;
+static const char* fileOpenText =
+ QT_TR_NOOP("Click this button to open a <em>new song</em>.<br>"
+ "You can also select the <b>Open command</b> from the File menu.");
+static const char* fileSaveText =
+ QT_TR_NOOP("Click this button to save the song you are "
+ "editing. You will be prompted for a file name.\n"
+ "You can also select the Save command from the File menu.");
+static const char* fileNewText = QT_TR_NOOP("Create New Song");
+
+static const char* infoLoopButton = QT_TR_NOOP("loop between left mark and right mark");
+static const char* infoPunchinButton = QT_TR_NOOP("record starts at left mark");
+static const char* infoPunchoutButton = QT_TR_NOOP("record stops at right mark");
+static const char* infoStartButton = QT_TR_NOOP("rewind to start position");
+static const char* infoRewindButton = QT_TR_NOOP("rewind current position");
+static const char* infoForwardButton = QT_TR_NOOP("move current position");
+static const char* infoStopButton = QT_TR_NOOP("stop sequencer");
+static const char* infoPlayButton = QT_TR_NOOP("start sequencer play");
+static const char* infoRecordButton = QT_TR_NOOP("to record press record and then play");
+static const char* infoPanicButton = QT_TR_NOOP("send note off to all midi channels");
+
+#define PROJECT_LIST_LEN 6
+static QString* projectList[PROJECT_LIST_LEN];
+
+extern void initIcons();
+extern void initMidiSynth();
+extern bool initJackAudio();
+extern void exitJackAudio();
+extern bool initDummyAudio();
+extern void exitDummyAudio();
+extern void initVST_fst_init();
+extern void initVST();
+extern void initDSSI();
+// p3.3.39
+extern void initOSC();
+extern void exitOSC();
+
+#ifdef HAVE_LASH
+#include <lash/lash.h>
+lash_client_t * lash_client = 0;
+extern snd_seq_t * alsaSeq;
+#endif /* HAVE_LASH */
+
+int watchAudio, watchAudioPrefetch, watchMidi;
+pthread_t splashThread;
+
+
+//PyScript *pyscript;
+// void MusE::runPythonScript()
+// {
+// QString script("test.py");
+// // pyscript->runPythonScript(script);
+// }
+
+//---------------------------------------------------------
+// getCapabilities
+//---------------------------------------------------------
+
+static void getCapabilities()
+ {
+#ifdef RTCAP
+#ifdef __linux__
+ const char* napp = getenv("GIVERTCAP");
+ if (napp == 0)
+ napp = "givertcap";
+ int pid = fork();
+ if (pid == 0) {
+ if (execlp(napp, napp, 0) == -1)
+ perror("exec givertcap failed");
+ }
+ else if (pid == -1) {
+ perror("fork givertcap failed");
+ }
+ else {
+ waitpid(pid, 0, 0);
+ }
+#endif // __linux__
+#endif
+ }
+
+
+//---------------------------------------------------------
+// sleep function
+//---------------------------------------------------------
+void microSleep(long msleep)
+{
+ bool sleepOk=-1;
+
+ while(sleepOk==-1)
+ sleepOk=usleep(msleep);
+}
+
+// Removed p3.3.17
+/*
+//---------------------------------------------------------
+// watchdog thread
+//---------------------------------------------------------
+
+static void* watchdog(void*)
+ {
+ doSetuid();
+
+ struct sched_param rt_param;
+ memset(&rt_param, 0, sizeof(rt_param));
+ rt_param.sched_priority = sched_get_priority_max(SCHED_FIFO);
+ int rv = pthread_setschedparam(pthread_self(), SCHED_FIFO, &rt_param);
+ if (rv != 0)
+ perror("Set realtime scheduler");
+
+ int policy;
+ if (pthread_getschedparam(pthread_self(), &policy, &rt_param)!= 0) {
+ printf("Cannot get current client scheduler: %s\n", strerror(errno));
+ }
+ if (policy != SCHED_FIFO)
+ printf("watchdog process %d _NOT_ running SCHED_FIFO\n", getpid());
+ else if (debugMsg)
+ printf("watchdog set to SCHED_FIFO priority %d\n",
+ sched_get_priority_max(SCHED_FIFO));
+
+ undoSetuid();
+ int fatal = 0;
+ for (;;) {
+ watchAudio = 0;
+ watchMidi = 0;
+ static const int WD_TIMEOUT = 3;
+
+ // sleep can be interrpted by signals:
+ int to = WD_TIMEOUT;
+ while (to > 0)
+ to = sleep(to);
+
+ bool timeout = false;
+ if (midiSeqRunning && watchMidi == 0)
+ {
+ printf("midiSeqRunning = %i watchMidi %i\n", midiSeqRunning, watchMidi);
+ timeout = true;
+ }
+ if (watchAudio == 0)
+ timeout = true;
+ if (watchAudio > 500000)
+ timeout = true;
+ if (timeout)
+ ++fatal;
+ else
+ fatal = 0;
+ if (fatal >= 3) {
+ printf("WatchDog: fatal error, realtime task timeout\n");
+ printf(" (%d,%d-%d) - stopping all services\n",
+ watchMidi, watchAudio, fatal);
+ break;
+ }
+// printf("wd %d %d %d\n", watchMidi, watchAudio, fatal);
+ }
+ audio->stop(true);
+ audioPrefetch->stop(true);
+ printf("watchdog exit\n");
+ exit(-1);
+ }
+*/
+
+//---------------------------------------------------------
+// seqStart
+//---------------------------------------------------------
+
+bool MusE::seqStart()
+ {
+ // Changed by Tim. p3.3.17
+
+ /*
+ if (audio->isRunning()) {
+ printf("seqStart(): already running\n");
+ return true;
+ }
+
+ if (realTimeScheduling) {
+ //
+ // create watchdog thread with max priority
+ //
+ doSetuid();
+ struct sched_param rt_param;
+ memset(&rt_param, 0, sizeof(rt_param));
+ rt_param.sched_priority = realTimePriority +1;//sched_get_priority_max(SCHED_FIFO);
+
+ pthread_attr_t* attributes = (pthread_attr_t*) malloc(sizeof(pthread_attr_t));
+ pthread_attr_init(attributes);
+
+// if (pthread_attr_setschedpolicy(attributes, SCHED_FIFO)) {
+// printf("MusE: cannot set FIFO scheduling class for RT thread\n");
+// }
+// if (pthread_attr_setschedparam (attributes, &rt_param)) {
+// // printf("Cannot set scheduling priority for RT thread (%s)\n", strerror(errno));
+// }
+// if (pthread_attr_setscope (attributes, PTHREAD_SCOPE_SYSTEM)) {
+// printf("MusE: Cannot set scheduling scope for RT thread\n");
+// }
+ if (pthread_create(&watchdogThread, attributes, ::watchdog, 0))
+ perror("MusE: creating watchdog thread failed:");
+ pthread_attr_destroy(attributes);
+ undoSetuid();
+ }
+ audioPrefetch->start();
+ audioPrefetch->msgSeek(0, true); // force
+ midiSeqRunning = !midiSeq->start();
+
+ if (!audio->start()) {
+ QMessageBox::critical( muse, tr(QString("Failed to start audio!")),
+ tr(QString("Was not able to start audio, check if jack is running.\n")));
+ return false;
+ }
+
+ return true;
+ */
+
+ if (audio->isRunning()) {
+ printf("seqStart(): already running\n");
+ return true;
+ }
+
+ if (!audio->start()) {
+ QMessageBox::critical( muse, tr(QString("Failed to start audio!")),
+ tr(QString("Was not able to start audio, check if jack is running.\n")));
+ return false;
+ }
+
+ //
+ // wait for jack callback
+ //
+ for(int i = 0; i < 60; ++i)
+ {
+ //if (audioState == AUDIO_START2)
+ if(audio->isRunning())
+ break;
+ sleep(1);
+ }
+ //if (audioState != AUDIO_START2) {
+ if(!audio->isRunning())
+ {
+ QMessageBox::critical( muse, tr("Failed to start audio!"),
+ tr("Timeout waiting for audio to run. Check if jack is running.\n"));
+ }
+ //
+ // now its safe to ask the driver for realtime
+ // priority
+
+ realTimePriority = audioDevice->realtimePriority();
+ if(debugMsg)
+ printf("MusE::seqStart: getting audio driver realTimePriority:%d\n", realTimePriority);
+
+ // Disabled by Tim. p3.3.22
+ /*
+ if(realTimeScheduling)
+ {
+ //
+ // create watchdog thread with max priority
+ //
+ doSetuid();
+ struct sched_param rt_param;
+ memset(&rt_param, 0, sizeof(rt_param));
+ rt_param.sched_priority = realTimePriority + 1;//sched_get_priority_max(SCHED_FIFO);
+
+ pthread_attr_t* attributes = (pthread_attr_t*) malloc(sizeof(pthread_attr_t));
+ pthread_attr_init(attributes);
+
+// if (pthread_attr_setschedpolicy(attributes, SCHED_FIFO)) {
+// printf("MusE: cannot set FIFO scheduling class for RT thread\n");
+// }
+// if (pthread_attr_setschedparam (attributes, &rt_param)) {
+// // printf("Cannot set scheduling priority for RT thread (%s)\n", strerror(errno));
+// }
+// if (pthread_attr_setscope (attributes, PTHREAD_SCOPE_SYSTEM)) {
+// printf("MusE: Cannot set scheduling scope for RT thread\n");
+// }
+ if (pthread_create(&watchdogThread, attributes, ::watchdog, 0))
+ perror("MusE: creating watchdog thread failed");
+ pthread_attr_destroy(attributes);
+ undoSetuid();
+ }
+ */
+
+ //int policy;
+ //if ((policy = sched_getscheduler (0)) < 0) {
+ // printf("Cannot get current client scheduler: %s\n", strerror(errno));
+ // }
+ //if (policy != SCHED_FIFO)
+ // printf("midi thread %d _NOT_ running SCHED_FIFO\n", getpid());
+
+
+ //audioState = AUDIO_RUNNING;
+ // Changed by Tim. p3.3.22
+ /*
+ //if(realTimePriority)
+ if(realTimeScheduling)
+ {
+ int pr = realTimePriority;
+ if(pr > 5)
+ pr -= 5;
+ else
+ pr = 0;
+ audioPrefetch->start(pr);
+ //audioWriteback->start(realTimePriority - 5);
+ }
+ else
+ {
+ audioPrefetch->start(0);
+ //audioWriteback->start(0);
+ }
+ */
+
+ int pfprio = 0;
+ int midiprio = 0;
+
+ // NOTE: realTimeScheduling can be true (gotten using jack_is_realtime()),
+ // while the determined realTimePriority can be 0.
+ // realTimePriority is gotten using pthread_getschedparam() on the client thread
+ // in JackAudioDevice::realtimePriority() which is a bit flawed - it reports there's no RT...
+ if(realTimeScheduling)
+ {
+ //if(realTimePriority < 5)
+ // printf("MusE: WARNING: Recommend setting audio realtime priority to a higher value!\n");
+ /*
+ if(realTimePriority == 0)
+ {
+ pfprio = 1;
+ midiprio = 2;
+ }
+ else
+ if(realTimePriority == 1)
+ {
+ pfprio = 2;
+ midiprio = 3;
+ }
+ else
+ if(realTimePriority == 2)
+ {
+ pfprio = 1;
+ midiprio = 3;
+ }
+ else
+ if(realTimePriority == 3)
+ {
+ pfprio = 1;
+ //midiprio = 2;
+ // p3.3.37
+ midiprio = 4;
+ }
+ else
+ if(realTimePriority == 4)
+ {
+ pfprio = 1;
+ //midiprio = 3;
+ // p3.3.37
+ midiprio = 5;
+ }
+ else
+ if(realTimePriority == 5)
+ {
+ pfprio = 1;
+ //midiprio = 3;
+ // p3.3.37
+ midiprio = 6;
+ }
+ else
+ */
+ {
+ //pfprio = realTimePriority - 5;
+ // p3.3.40
+ pfprio = realTimePriority + 1;
+
+ //midiprio = realTimePriority - 2;
+ // p3.3.37
+ //midiprio = realTimePriority + 1;
+ // p3.3.40
+ midiprio = realTimePriority + 2;
+ }
+ }
+
+ if(midiRTPrioOverride > 0)
+ midiprio = midiRTPrioOverride;
+
+ // FIXME FIXME: The realTimePriority of the Jack thread seems to always be 5 less than the value passed to jackd command.
+ //if(midiprio == realTimePriority)
+ // printf("MusE: WARNING: Midi realtime priority %d is the same as audio realtime priority %d. Try a different setting.\n",
+ // midiprio, realTimePriority);
+ //if(midiprio == pfprio)
+ // printf("MusE: WARNING: Midi realtime priority %d is the same as audio prefetch realtime priority %d. Try a different setting.\n",
+ // midiprio, pfprio);
+
+ audioPrefetch->start(pfprio);
+
+ audioPrefetch->msgSeek(0, true); // force
+
+ //midiSeqRunning = !midiSeq->start(realTimeScheduling ? realTimePriority : 0);
+ // Changed by Tim. p3.3.22
+ //midiSeq->start(realTimeScheduling ? realTimePriority : 0);
+ midiSeq->start(midiprio);
+
+ int counter=0;
+ while (++counter) {
+ //if (counter > 10) {
+ if (counter > 1000) {
+ fprintf(stderr,"midi sequencer thread does not start!? Exiting...\n");
+ exit(33);
+ }
+ midiSeqRunning = midiSeq->isRunning();
+ if (midiSeqRunning)
+ break;
+ usleep(1000);
+ printf("looping waiting for sequencer thread to start\n");
+ }
+ if(!midiSeqRunning)
+ {
+ fprintf(stderr, "midiSeq is not running! Exiting...\n");
+ exit(33);
+ }
+ return true;
+ }
+
+//---------------------------------------------------------
+// stop
+//---------------------------------------------------------
+
+void MusE::seqStop()
+ {
+ // label sequencer as disabled before it actually happened to minimize race condition
+ midiSeqRunning = false;
+
+ song->setStop(true);
+ song->setStopPlay(false);
+ midiSeq->stop(true);
+ audio->stop(true);
+ audioPrefetch->stop(true);
+ if (realTimeScheduling && watchdogThread)
+ pthread_cancel(watchdogThread);
+ }
+
+//---------------------------------------------------------
+// seqRestart
+//---------------------------------------------------------
+
+bool MusE::seqRestart()
+{
+ bool restartSequencer = audio->isRunning();
+ if (restartSequencer) {
+ if (audio->isPlaying()) {
+ audio->msgPlay(false);
+ while (audio->isPlaying())
+ qApp->processEvents();
+ }
+ seqStop();
+ }
+ if(!seqStart())
+ return false;
+
+ audioDevice->graphChanged();
+ return true;
+}
+
+//---------------------------------------------------------
+// addProject
+//---------------------------------------------------------
+
+void addProject(const QString& name)
+ {
+ for (int i = 0; i < PROJECT_LIST_LEN; ++i) {
+ if (projectList[i] == 0)
+ break;
+ if (name == *projectList[i]) {
+ int dst = i;
+ int src = i+1;
+ int n = PROJECT_LIST_LEN - i - 1;
+ delete projectList[i];
+ for (int k = 0; k < n; ++k)
+ projectList[dst++] = projectList[src++];
+ projectList[dst] = 0;
+ break;
+ }
+ }
+ QString** s = &projectList[PROJECT_LIST_LEN - 2];
+ QString** d = &projectList[PROJECT_LIST_LEN - 1];
+ if (*d)
+ delete *d;
+ for (int i = 0; i < PROJECT_LIST_LEN-1; ++i)
+ *d-- = *s--;
+ projectList[0] = new QString(name);
+ }
+
+//---------------------------------------------------------
+// populateAddSynth
+//---------------------------------------------------------
+
+/*
+struct addSynth_cmp_str
+{
+ bool operator()(std::string a, std::string b)
+ {
+ return (a < b);
+ }
+};
+*/
+
+Q3PopupMenu* populateAddSynth(QWidget* parent, QObject* obj = 0, const char* slot = 0)
+{
+ Q3PopupMenu* synp = new Q3PopupMenu(parent);
+
+ //typedef std::multimap<std::string, int, addSynth_cmp_str > asmap;
+ typedef std::multimap<std::string, int > asmap;
+
+ //typedef std::multimap<std::string, int, addSynth_cmp_str >::iterator imap;
+ typedef std::multimap<std::string, int >::iterator imap;
+
+ MessSynth* synMESS = 0;
+ Q3PopupMenu* synpMESS = 0;
+ asmap mapMESS;
+
+ #ifdef DSSI_SUPPORT
+ DssiSynth* synDSSI = 0;
+ Q3PopupMenu* synpDSSI = 0;
+ asmap mapDSSI;
+ #endif
+
+ #ifdef VST_SUPPORT
+ VstSynth* synVST = 0;
+ Q3PopupMenu* synpVST = 0;
+ asmap mapVST;
+ #endif
+
+ // Not necessary, but what the heck.
+ Q3PopupMenu* synpOther = 0;
+ asmap mapOther;
+
+ //const int synth_base_id = 0x1000;
+ int ii = 0;
+ for(std::vector<Synth*>::iterator i = synthis.begin(); i != synthis.end(); ++i)
+ {
+ synMESS = dynamic_cast<MessSynth*>(*i);
+ if(synMESS)
+ {
+ mapMESS.insert( std::pair<std::string, int> (std::string(synMESS->description().lower().latin1()), ii) );
+ }
+ else
+ {
+
+ #ifdef DSSI_SUPPORT
+ synDSSI = dynamic_cast<DssiSynth*>(*i);
+ if(synDSSI)
+ {
+ mapDSSI.insert( std::pair<std::string, int> (std::string(synDSSI->description().lower().latin1()), ii) );
+ }
+ else
+ #endif
+
+ {
+ #ifdef VST_SUPPORT
+ synVST = dynamic_cast<VstSynth*>(*i);
+ if(synVST)
+ {
+ mapVST.insert( std::pair<std::string, int> (std::string(synVST->description().lower().latin1()), ii) );
+ }
+ else
+ #endif
+
+ {
+ mapOther.insert( std::pair<std::string, int> (std::string((*i)->description().lower().latin1()), ii) );
+ }
+ }
+ }
+
+ ++ii;
+ }
+
+ int sz = synthis.size();
+ for(imap i = mapMESS.begin(); i != mapMESS.end(); ++i)
+ {
+ int idx = i->second;
+ if(idx > sz) // Sanity check
+ continue;
+ Synth* s = synthis[idx];
+ if(s)
+ {
+ // No MESS sub-menu yet? Create it now.
+ if(!synpMESS)
+ synpMESS = new Q3PopupMenu(parent);
+ synpMESS->insertItem(QT_TR_NOOP(s->description()) + " <" + QT_TR_NOOP(s->name()) + ">", MENU_ADD_SYNTH_ID_BASE + idx);
+ }
+ }
+
+ #ifdef DSSI_SUPPORT
+ for(imap i = mapDSSI.begin(); i != mapDSSI.end(); ++i)
+ {
+ int idx = i->second;
+ if(idx > sz)
+ continue;
+ Synth* s = synthis[idx];
+ if(s)
+ {
+ // No DSSI sub-menu yet? Create it now.
+ if(!synpDSSI)
+ synpDSSI = new Q3PopupMenu(parent);
+ synpDSSI->insertItem(QT_TR_NOOP(s->description()) + " <" + QT_TR_NOOP(s->name()) + ">", MENU_ADD_SYNTH_ID_BASE + idx);
+ }
+ }
+ #endif
+
+ #ifdef VST_SUPPORT
+ for(imap i = mapVST.begin(); i != mapVST.end(); ++i)
+ {
+ int idx = i->second;
+ if(idx > sz)
+ continue;
+ Synth* s = synthis[idx];
+ if(s)
+ {
+ // No VST sub-menu yet? Create it now.
+ if(!synpVST)
+ synpVST = new Q3PopupMenu(parent);
+ synpVST->insertItem(QT_TR_NOOP(s->description()) + " <" + QT_TR_NOOP(s->name()) + ">", MENU_ADD_SYNTH_ID_BASE + idx);
+ }
+ }
+ #endif
+
+ for(imap i = mapOther.begin(); i != mapOther.end(); ++i)
+ {
+ int idx = i->second;
+ if(idx > sz)
+ continue;
+ Synth* s = synthis[idx];
+ // No Other sub-menu yet? Create it now.
+ if(!synpOther)
+ synpOther = new Q3PopupMenu(parent);
+ synpOther->insertItem(QT_TR_NOOP(s->description()) + " <" + QT_TR_NOOP(s->name()) + ">", MENU_ADD_SYNTH_ID_BASE + idx);
+ }
+
+ if(synpMESS)
+ {
+ synp->insertItem(*synthIcon, QT_TR_NOOP("MESS"), synpMESS, Track::AUDIO_SOFTSYNTH);
+ if(obj && slot)
+ QObject::connect(synpMESS, SIGNAL(activated(int)), obj, slot);
+ }
+
+ #ifdef DSSI_SUPPORT
+ if(synpDSSI)
+ {
+ synp->insertItem(*synthIcon, QT_TR_NOOP("DSSI"), synpDSSI, Track::AUDIO_SOFTSYNTH);
+ if(obj && slot)
+ QObject::connect(synpDSSI, SIGNAL(activated(int)), obj, slot);
+ }
+ #endif
+
+ #ifdef VST_SUPPORT
+ if(synpVST)
+ {
+ synp->insertItem(*synthIcon, QT_TR_NOOP("FST"), synpVST, Track::AUDIO_SOFTSYNTH);
+ if(obj && slot)
+ QObject::connect(synpVST, SIGNAL(activated(int)), obj, slot);
+ }
+ #endif
+
+ if(synpOther)
+ {
+ synp->insertItem(*synthIcon, QObject::tr("Other"), synpOther, Track::AUDIO_SOFTSYNTH);
+ if(obj && slot)
+ QObject::connect(synpOther, SIGNAL(activated(int)), obj, slot);
+ }
+
+ return synp;
+}
+
+//---------------------------------------------------------
+// populateAddTrack
+// this is also used in "mixer"
+//---------------------------------------------------------
+
+void populateAddTrack(Q3PopupMenu* addTrack)
+ {
+ addTrack->insertItem(QIcon(*addtrack_addmiditrackIcon),
+ QT_TR_NOOP("Add Midi Track"), Track::MIDI);
+ addTrack->insertItem(QIcon(*addtrack_drumtrackIcon),
+ QT_TR_NOOP("Add Drum Track"), Track::DRUM);
+ addTrack->insertItem(QIcon(*addtrack_wavetrackIcon),
+ QT_TR_NOOP("Add Wave Track"), Track::WAVE);
+ addTrack->insertItem(QIcon(*addtrack_audiooutputIcon),
+ QT_TR_NOOP("Add Audio Output"), Track::AUDIO_OUTPUT);
+ addTrack->insertItem(QIcon(*addtrack_audiogroupIcon),
+ QT_TR_NOOP("Add Audio Group"), Track::AUDIO_GROUP);
+ addTrack->insertItem(QIcon(*addtrack_audioinputIcon),
+ QT_TR_NOOP("Add Audio Input"), Track::AUDIO_INPUT);
+ addTrack->insertItem(QIcon(*addtrack_auxsendIcon),
+ QT_TR_NOOP("Add Aux Send"), Track::AUDIO_AUX);
+
+ // Create a sub-menu and fill it with found synth types. Make addTrack the owner.
+ Q3PopupMenu* synp = populateAddSynth(addTrack, song, SLOT(addNewTrack(int)));
+ // Add the sub-menu to the given menu.
+ addTrack->insertItem(*synthIcon, QT_TR_NOOP("Add Synth"), synp, Track::AUDIO_SOFTSYNTH);
+
+ //addTrack->connect(addTrack, SIGNAL(activated(int)), song, SLOT(addTrack(int)));
+ addTrack->connect(addTrack, SIGNAL(activated(int)), song, SLOT(addNewTrack(int)));
+ //synp->connect(synp, SIGNAL(activated(int)), song, SLOT(addNewTrack(int)));
+ }
+
+//---------------------------------------------------------
+// MusE
+//---------------------------------------------------------
+
+MusE::MusE(int argc, char** argv) : Q3MainWindow(0, "mainwindow")
+ {
+ // By T356. For LADSPA plugins in plugin.cpp
+ // QWidgetFactory::addWidgetFactory( new PluginWidgetFactory ); ddskrjo
+
+ setFocusPolicy(Qt::WheelFocus);
+ muse = this; // hack
+ clipListEdit = 0;
+ midiSyncConfig = 0;
+ midiRemoteConfig = 0;
+ midiPortConfig = 0;
+ metronomeConfig = 0;
+ audioConfig = 0;
+ midiFileConfig = 0;
+ midiFilterConfig = 0;
+ midiInputTransform = 0;
+ midiRhythmGenerator = 0;
+ globalSettingsConfig = 0;
+ markerView = 0;
+ softSynthesizerConfig = 0;
+ midiTransformerDialog = 0;
+ shortcutConfig = 0;
+ appearance = 0;
+ //audioMixer = 0;
+ mixer1 = 0;
+ mixer2 = 0;
+ watchdogThread = 0;
+ editInstrument = 0;
+ routingPopupMenu = 0;
+
+ appName = QString("MusE");
+
+ song = new Song("song");
+ song->blockSignals(true);
+ heartBeatTimer = new QTimer(this, "timer");
+ connect(heartBeatTimer, SIGNAL(timeout()), song, SLOT(beat()));
+
+#ifdef ENABLE_PYTHON
+ //---------------------------------------------------
+ // Python bridge
+ //---------------------------------------------------
+ // Uncomment in order to enable MusE Python bridge:
+ if (usePythonBridge) {
+ printf("Initializing python bridge!\n");
+ if (initPythonBridge() == false) {
+ printf("Could not initialize Python bridge\n");
+ exit(1);
+ }
+ }
+#endif
+
+ //---------------------------------------------------
+ // undo/redo
+ //---------------------------------------------------
+ undoRedo = new Q3ActionGroup(this, tr("UndoRedo"), false);
+ undoAction = new Q3Action(tr("undo"), QIcon(*undoIconS), tr("Und&o"), // ddskrjo
+ Qt::CTRL+Qt::Key_Z, undoRedo, "undo");
+ redoAction = new Q3Action(tr("redo"), QIcon(*redoIconS), tr("Re&do"), // ddskrjo
+ Qt::CTRL+Qt::Key_Y, undoRedo, "redo");
+ undoAction->setWhatsThis(tr("undo last change to song"));
+ redoAction->setWhatsThis(tr("redo last undo"));
+ undoAction->setEnabled(false);
+ redoAction->setEnabled(false);
+ connect(redoAction, SIGNAL(activated()), song, SLOT(redo()));
+ connect(undoAction, SIGNAL(activated()), song, SLOT(undo()));
+
+ //---------------------------------------------------
+ // Transport
+ //---------------------------------------------------
+
+ transportAction = new Q3ActionGroup(this, tr("Transport"), false);
+
+ loopAction = new Q3Action(tr("loop"), QIcon(*loop1Icon),
+ tr("Loop"), 0, transportAction, "loop", true);
+ loopAction->setWhatsThis(tr(infoLoopButton));
+ connect(loopAction, SIGNAL(toggled(bool)), song, SLOT(setLoop(bool)));
+
+ punchinAction = new Q3Action(tr("punchin"), QIcon(*punchin1Icon),
+ tr("Punchin"), 0, transportAction, "Punchin", true);
+ punchinAction->setWhatsThis(tr(infoPunchinButton));
+ connect(punchinAction, SIGNAL(toggled(bool)), song, SLOT(setPunchin(bool)));
+
+ punchoutAction = new Q3Action(tr("punchout"), QIcon(*punchout1Icon),
+ tr("Punchout"), 0, transportAction, "punchout", true);
+ punchoutAction->setWhatsThis(tr(infoPunchoutButton));
+ connect(punchoutAction, SIGNAL(toggled(bool)), song, SLOT(setPunchout(bool)));
+
+ transportAction->addSeparator();
+
+ startAction = new Q3Action(tr("start"), QIcon(*startIcon),
+ tr("Start"), 0, transportAction, "start");
+ startAction->setWhatsThis(tr(infoStartButton));
+ connect(startAction, SIGNAL(activated()), song, SLOT(rewindStart()));
+
+ rewindAction = new Q3Action(tr("rewind"), QIcon(*frewindIcon),
+ tr("Rewind"), 0, transportAction, "rewind");
+ rewindAction->setWhatsThis(tr(infoRewindButton));
+ connect(rewindAction, SIGNAL(activated()), song, SLOT(rewind()));
+
+ forwardAction = new Q3Action(tr("forward"), QIcon(*fforwardIcon),
+ tr("Forward"), 0, transportAction, "forward");
+ forwardAction->setWhatsThis(tr(infoForwardButton));
+ connect(forwardAction, SIGNAL(activated()), song, SLOT(forward()));
+
+ stopAction = new Q3Action(tr("stop"), QIcon(*stopIcon),
+ tr("Stop"), 0, transportAction, "stop", true);
+ stopAction->setWhatsThis(tr(infoStopButton));
+ stopAction->setOn(true);
+ connect(stopAction, SIGNAL(toggled(bool)), song, SLOT(setStop(bool)));
+
+ playAction = new Q3Action(tr("play"), QIcon(*playIcon),
+ tr("Play"), 0, transportAction, "play", true);
+ playAction->setWhatsThis(tr(infoPlayButton));
+ playAction->setOn(false);
+ connect(playAction, SIGNAL(toggled(bool)), song, SLOT(setPlay(bool)));
+
+ recordAction = new Q3Action(tr("record"), QIcon(*recordIcon),
+ tr("Record"), 0, transportAction, "record", true);
+ recordAction->setWhatsThis(tr(infoRecordButton));
+ connect(recordAction, SIGNAL(toggled(bool)), song, SLOT(setRecord(bool)));
+
+ panicAction = new Q3Action(tr("panic"), QIcon(*panicIcon),
+ tr("Panic"), 0, 0, "panic", false);
+ panicAction->setWhatsThis(tr(infoPanicButton));
+ connect(panicAction, SIGNAL(activated()), song, SLOT(panic()));
+
+ initMidiInstruments();
+ initMidiPorts();
+ ::initMidiDevices();
+
+ //----Actions
+
+ fileNewAction = new Q3Action(tr("new"),
+ QIcon(*filenewIcon), tr("&New"), 0, this, "new"); // ddskrjo
+ fileNewAction->setToolTip(tr(fileNewText));
+ fileNewAction->setWhatsThis(tr(fileNewText));
+
+ fileOpenAction = new Q3Action(tr("open"),
+ QIcon(*openIcon), tr("&Open"), 0, this, "open"); // ddskrjo
+ fileOpenAction->setToolTip(tr(fileOpenText));
+ fileOpenAction->setWhatsThis(tr(fileOpenText));
+
+ fileSaveAction = new Q3Action(tr("save"),
+ QIcon(*saveIcon), tr("&Save"), 0, this, "save"); // ddskrjo
+ fileSaveAction->setToolTip(tr(fileSaveText));
+ fileSaveAction->setWhatsThis(tr(fileSaveText));
+
+ pianoAction = new Q3Action(tr("pianoroll"),
+ *pianoIconSet, tr("Pianoroll"), 0, this, "pianoroll");
+ connect(pianoAction, SIGNAL(activated()), SLOT(startPianoroll()));
+
+// markerAction = new QAction(tr("marker"), QIconSet(*view_markerIcon), tr("Marker"),
+// 0, this, "marker");
+// connect(markerAction, SIGNAL(activated()), SLOT(startMarkerView()));
+
+ connect(fileNewAction, SIGNAL(activated()), SLOT(loadTemplate()));
+ connect(fileOpenAction, SIGNAL(activated()), SLOT(loadProject()));
+ connect(fileSaveAction, SIGNAL(activated()), SLOT(save()));
+
+ //--------------------------------------------------
+ // Toolbar
+ //--------------------------------------------------
+
+ tools = new Q3ToolBar(tr("File Buttons"), this);
+ fileNewAction->addTo(tools);
+ fileOpenAction->addTo(tools);
+ fileSaveAction->addTo(tools);
+
+ //
+ // Whats This
+ //
+ Q3WhatsThis::whatsThisButton(tools);
+
+ tools->addSeparator();
+ undoRedo->addTo(tools);
+
+ tools1 = new EditToolBar(this, arrangerTools);
+
+ Q3ToolBar* transportToolbar = new Q3ToolBar(this);
+ transportAction->addTo(transportToolbar);
+
+ Q3ToolBar* panicToolbar = new Q3ToolBar(this);
+ panicAction->addTo(panicToolbar);
+
+ if (realTimePriority < sched_get_priority_min(SCHED_FIFO))
+ realTimePriority = sched_get_priority_min(SCHED_FIFO);
+ else if (realTimePriority > sched_get_priority_max(SCHED_FIFO))
+ realTimePriority = sched_get_priority_max(SCHED_FIFO);
+
+ // If we requested to force the midi thread priority...
+ if(midiRTPrioOverride > 0)
+ {
+ if (midiRTPrioOverride < sched_get_priority_min(SCHED_FIFO))
+ midiRTPrioOverride = sched_get_priority_min(SCHED_FIFO);
+ else if (midiRTPrioOverride > sched_get_priority_max(SCHED_FIFO))
+ midiRTPrioOverride = sched_get_priority_max(SCHED_FIFO);
+ }
+
+ // Changed by Tim. p3.3.17
+ //midiSeq = new MidiSeq(realTimeScheduling ? realTimePriority : 0, "Midi");
+ midiSeq = new MidiSeq("Midi");
+ audio = new Audio();
+ //audioPrefetch = new AudioPrefetch(0, "Disc");
+ audioPrefetch = new AudioPrefetch("Prefetch");
+
+ //---------------------------------------------------
+ // Popups
+ //---------------------------------------------------
+
+// QPopupMenu *foo = new QPopupMenu(this);
+// testAction = new QAction(foo,"testPython");
+// testAction->addTo(foo);
+// menuBar()->insertItem(tr("&testpython"), foo);
+// connect(testAction, SIGNAL(activated()), this, SLOT(runPythonScript()));
+
+
+ //-------------------------------------------------------------
+ // popup File
+ //-------------------------------------------------------------
+
+ menu_file = new Q3PopupMenu(this);
+ menuBar()->insertItem(tr("&File"), menu_file);
+ fileNewAction->addTo(menu_file);
+ fileOpenAction->addTo(menu_file);
+ openRecent = new Q3PopupMenu(menu_file);
+ connect(openRecent, SIGNAL(aboutToShow()), this, SLOT(openRecentMenu()));
+ connect(openRecent, SIGNAL(activated(int)), this, SLOT(selectProject(int)));
+ menu_ids[CMD_OPEN_RECENT] = menu_file->insertItem(tr("Open &Recent"), openRecent, 0);
+ menu_file->insertSeparator();
+ fileSaveAction->addTo(menu_file);
+ menu_ids[CMD_SAVE_AS] = menu_file->insertItem(tr("Save &As"), this, SLOT(saveAs()), 0, -2);
+ menu_file->insertSeparator();
+ menu_ids[CMD_IMPORT_MIDI] = menu_file->insertItem(*openIconS, tr("Import Midifile"), this, SLOT(importMidi()), 0, -2);
+ menu_ids[CMD_EXPORT_MIDI] = menu_file->insertItem(*saveIconS, tr("Export Midifile"), this, SLOT(exportMidi()), 0, -2);
+ menu_ids[CMD_IMPORT_PART] = menu_file->insertItem(*openIconS, tr("Import Part"), this, SLOT(importPart()), 0, -2);
+ menu_file->insertSeparator();
+ menu_ids[CMD_IMPORT_AUDIO] = menu_file->insertItem(*openIconS, tr("Import Wave File"), this, SLOT(importWave()), 0, -2);
+
+
+ menu_file->insertSeparator();
+ menu_ids[CMD_QUIT] = menu_file->insertItem(*exitIconS, tr("&Quit"), this, SLOT(quitDoc()), 0, -2);
+ menu_file->insertSeparator();
+
+ //-------------------------------------------------------------
+ // popup Edit
+ //-------------------------------------------------------------
+
+ menuEdit = new Q3PopupMenu(this);
+ undoRedo->addTo(menuEdit);
+ menuEdit->insertSeparator();
+ menuBar()->insertItem(tr("&Edit"), menuEdit);
+
+ menuEdit->insertItem(*editcutIconSet, tr("C&ut"), CMD_CUT);
+ menuEdit->setAccel(Qt::CTRL+Qt::Key_X, CMD_CUT);
+ menuEdit->insertItem(*editcopyIconSet, tr("&Copy"), CMD_COPY);
+ menuEdit->setAccel(Qt::CTRL+Qt::Key_C, CMD_COPY);
+ menuEdit->insertItem(*editpasteIconSet, tr("&Paste"), CMD_PASTE);
+ menuEdit->setAccel(Qt::CTRL+Qt::Key_V, CMD_PASTE);
+ menuEdit->insertItem(*editpasteIconSet, tr("&Insert"), CMD_INSERT);
+ menuEdit->setAccel(Qt::CTRL+Qt::SHIFT+Qt::Key_I, CMD_INSERT);
+ menuEdit->insertItem(*editpasteCloneIconSet, tr("Paste c&lone"), CMD_PASTE_CLONE);
+ menuEdit->setAccel(Qt::CTRL+Qt::SHIFT+Qt::Key_V, CMD_PASTE_CLONE);
+ menuEdit->insertItem(*editpaste2TrackIconSet, tr("Paste to &track"), CMD_PASTE_TO_TRACK);
+ menuEdit->setAccel(Qt::CTRL+Qt::Key_B, CMD_PASTE_TO_TRACK);
+ menuEdit->insertItem(*editpasteClone2TrackIconSet, tr("Paste clone to trac&k"), CMD_PASTE_CLONE_TO_TRACK);
+ menuEdit->setAccel(Qt::CTRL+Qt::SHIFT+Qt::Key_B, CMD_PASTE_CLONE_TO_TRACK);
+
+ menuEdit->insertItem(*editpasteIconSet, tr("&Insert empty measure"), CMD_INSERTMEAS);
+ menuEdit->setAccel(Qt::CTRL+Qt::SHIFT+Qt::Key_X, CMD_INSERTMEAS);
+ menuEdit->insertSeparator();
+ menuEdit->insertItem(QIcon(*edit_track_delIcon),
+ tr("Delete Selected Tracks"), CMD_DELETE_TRACK);
+
+ addTrack = new Q3PopupMenu(this);
+ // Moved below. Have to wait until synths are available...
+ //populateAddTrack(addTrack);
+
+ menuEdit->insertItem(QIcon(*edit_track_addIcon),
+ tr("Add Track"), addTrack);
+
+ select = new Q3PopupMenu(this);
+ select->insertItem(QIcon(*select_allIcon),
+ tr("Select &All"), CMD_SELECT_ALL);
+ select->insertItem(QIcon(*select_deselect_allIcon),
+ tr("&Deselect All"), CMD_SELECT_NONE);
+ menuEdit->insertSeparator();
+ select->insertItem(QIcon(*select_invert_selectionIcon),
+ tr("Invert &Selection"), CMD_SELECT_INVERT);
+ select->insertItem(QIcon(*select_inside_loopIcon),
+ tr("&Inside Loop"), CMD_SELECT_ILOOP);
+ select->insertItem(QIcon(*select_outside_loopIcon),
+ tr("&Outside Loop"), CMD_SELECT_OLOOP);
+ select->insertItem(QIcon(*select_all_parts_on_trackIcon),
+ tr("All &Parts on Track"), CMD_SELECT_PARTS);
+ menuEdit->insertItem(QIcon(*selectIcon),
+ tr("Select"), select);
+ menuEdit->insertSeparator();
+
+ pianoAction->addTo(menuEdit);
+ menu_ids[CMD_OPEN_DRUMS] = menuEdit->insertItem(
+ QIcon(*edit_drummsIcon), tr("Drums"), this, SLOT(startDrumEditor()), 0);
+ menu_ids[CMD_OPEN_LIST] = menuEdit->insertItem(
+ QIcon(*edit_listIcon), tr("List"), this, SLOT(startListEditor()), 0);
+ menu_ids[CMD_OPEN_WAVE] = menuEdit->insertItem(
+ QIcon(*edit_waveIcon), tr("Wave"), this, SLOT(startWaveEditor()), 0);
+
+ master = new Q3PopupMenu(this);
+ master->setCheckable(false);
+ menu_ids[CMD_OPEN_GRAPHIC_MASTER] = master->insertItem(
+ QIcon(*mastertrack_graphicIcon),tr("Graphic"), this, SLOT(startMasterEditor()), 0);
+ menu_ids[CMD_OPEN_LIST_MASTER] = master->insertItem(
+ QIcon(*mastertrack_listIcon),tr("List"), this, SLOT(startLMasterEditor()), 0);
+ menuEdit->insertItem(QIcon(*edit_mastertrackIcon),
+ tr("Mastertrack"), master, Qt::Key_F);
+
+ menuEdit->insertSeparator();
+ connect(menuEdit, SIGNAL(activated(int)), SLOT(cmd(int)));
+ connect(select, SIGNAL(activated(int)), SLOT(cmd(int)));
+
+ midiEdit = new Q3PopupMenu(this);
+ midiEdit->setCheckable(false);
+#if 0 // TODO
+ menu_ids[CMD_OPEN_MIDI_TRANSFORM] = midiEdit->insertItem(
+ QIcon(*midi_transformIcon), tr("Midi &Transform"), this, SLOT(startMidiTransformer()), 0);
+ midiEdit->insertItem(tr("Modify Gate Time"), this, SLOT(modifyGateTime()));
+ midiEdit->insertItem(tr("Modify Velocity"), this, SLOT(modifyVelocity()));
+ midiEdit->insertItem(tr("Crescendo"), this, SLOT(crescendo()));
+ midiEdit->insertItem(tr("Transpose"), this, SLOT(transpose()));
+ midiEdit->insertItem(tr("Thin Out"), this, SLOT(thinOut()));
+ midiEdit->insertItem(tr("Erase Event"), this, SLOT(eraseEvent()));
+ midiEdit->insertItem(tr("Note Shift"), this, SLOT(noteShift()));
+ midiEdit->insertItem(tr("Move Clock"), this, SLOT(moveClock()));
+ midiEdit->insertItem(tr("Copy Measure"), this, SLOT(copyMeasure()));
+ midiEdit->insertItem(tr("Erase Measure"), this, SLOT(eraseMeasure()));
+ midiEdit->insertItem(tr("Delete Measure"), this, SLOT(deleteMeasure()));
+ midiEdit->insertItem(tr("Create Measure"), this, SLOT(createMeasure()));
+ midiEdit->insertItem(tr("Mix Track"), this, SLOT(mixTrack()));
+#endif
+ menu_ids[CMD_TRANSPOSE] = midiEdit->insertItem(
+ QIcon(*midi_transposeIcon), tr("Transpose"), this, SLOT(transpose()), 0);
+ menuEdit->insertItem(
+ QIcon(*edit_midiIcon), tr("Midi"), midiEdit);
+
+ menuEdit->insertSeparator();
+ menuEdit->insertItem(
+ QIcon(*edit_listIcon), tr("Song info"), this, SLOT(startSongInfo()), 0);
+ //-------------------------------------------------------------
+ // popup View
+ //-------------------------------------------------------------
+
+ menuView = new Q3PopupMenu(this);
+ menuView->setCheckable(true);
+ menuBar()->insertItem(tr("View"), menuView);
+
+ tr_id = menuView->insertItem(
+ QIcon(*view_transport_windowIcon), tr("Transport Panel"), this, SLOT(toggleTransport()), 0);
+ bt_id = menuView->insertItem(
+ QIcon(*view_bigtime_windowIcon), tr("Bigtime window"), this, SLOT(toggleBigTime()), 0);
+ //aid1 = menuView->insertItem(
+ // QIconSet(*mixerSIcon), tr("Mixer"), this, SLOT(toggleMixer()), 0);
+ aid1a = menuView->insertItem(
+ QIcon(*mixerSIcon), tr("Mixer A"), this, SLOT(toggleMixer1()), 0);
+ aid1b = menuView->insertItem(
+ QIcon(*mixerSIcon), tr("Mixer B"), this, SLOT(toggleMixer2()), 0);
+ // p3.2.24
+ aid2 = menuView->insertItem(
+ QIcon(*cliplistSIcon), tr("Cliplist"), this, SLOT(startClipList()), 0);
+ mr_id = menuView->insertItem(
+ QIcon(*view_markerIcon), tr("Marker View"), this, SLOT(toggleMarker()), 0);
+ //markerAction->addTo(menuView);
+
+
+ //-------------------------------------------------------------
+ // popup Structure
+ //-------------------------------------------------------------
+
+ menuStructure = new Q3PopupMenu(this);
+ menuStructure->setCheckable(false);
+ menuBar()->insertItem(tr("&Structure"), menuStructure);
+ menu_ids[CMD_GLOBAL_CUT] = menuStructure->insertItem(tr("Global Cut"), this, SLOT(globalCut()), 0);
+ menu_ids[CMD_GLOBAL_INSERT] = menuStructure->insertItem(tr("Global Insert"), this, SLOT(globalInsert()), 0);
+ menu_ids[CMD_GLOBAL_SPLIT] = menuStructure->insertItem(tr("Global Split"), this, SLOT(globalSplit()), 0);
+ menu_ids[CMD_COPY_RANGE] = menuStructure->insertItem(tr("Copy Range"), this, SLOT(copyRange()), 0);
+ menuStructure->setItemEnabled(menu_ids[CMD_COPY_RANGE], false);
+ menuStructure->insertSeparator();
+ menu_ids[CMD_CUT_EVENTS] = menuStructure->insertItem(tr("Cut Events"), this, SLOT(cutEvents()), 0);
+ menuStructure->setItemEnabled(menu_ids[CMD_CUT_EVENTS], false);
+
+ //-------------------------------------------------------------
+ // popup Midi
+ //-------------------------------------------------------------
+
+ midiInputPlugins = new Q3PopupMenu(this);
+ midiInputPlugins->setCheckable(false);
+ mpid0 = midiInputPlugins->insertItem(
+ QIcon(*midi_inputplugins_transposeIcon), tr("Transpose"), 0);
+ mpid1 = midiInputPlugins->insertItem(
+ QIcon(*midi_inputplugins_midi_input_transformIcon), tr("Midi Input Transform"), 1);
+ mpid2 = midiInputPlugins->insertItem(
+ QIcon(*midi_inputplugins_midi_input_filterIcon), tr("Midi Input Filter"), 2);
+ mpid3 = midiInputPlugins->insertItem(
+ QIcon(*midi_inputplugins_remote_controlIcon), tr("Midi Remote Control"), 3);
+/*
+** mpid4 = midiInputPlugins->insertItem(
+** QIconSet(*midi_inputplugins_random_rhythm_generatorIcon), tr("Random Rhythm Generator"), 4);
+*/
+ connect(midiInputPlugins, SIGNAL(activated(int)), SLOT(startMidiInputPlugin(int)));
+
+// midiInputPlugins->setItemEnabled(mpid4, false);
+
+ menu_functions = new Q3PopupMenu(this);
+ menu_functions->setCheckable(true);
+ menuBar()->insertItem(tr("&Midi"), menu_functions);
+ menu_functions->setCaption(tr("Midi"));
+
+ menuScriptPlugins = new Q3PopupMenu(this);
+ song->populateScriptMenu(menuScriptPlugins, this);
+ menu_functions->insertItem(tr("&Plugins"), menuScriptPlugins);
+
+ menu_ids[CMD_MIDI_EDIT_INSTRUMENTS] = menu_functions->insertItem(
+ QIcon(*midi_edit_instrumentIcon), tr("Edit Instrument"), this, SLOT(startEditInstrument()), 0);
+ menu_functions->insertItem(
+ QIcon(*midi_inputpluginsIcon), tr("Input Plugins"), midiInputPlugins, Qt::Key_P);
+ menu_functions->insertSeparator();
+ menu_ids[CMD_MIDI_RESET] = menu_functions->insertItem(
+ QIcon(*midi_reset_instrIcon), tr("Reset Instr."), this, SLOT(resetMidiDevices()), 0);
+ menu_ids[CMD_MIDI_INIT] = menu_functions->insertItem(
+ QIcon(*midi_init_instrIcon), tr("Init Instr."), this, SLOT(initMidiDevices()), 0);
+ menu_ids[CMD_MIDI_LOCAL_OFF] = menu_functions->insertItem(
+ QIcon(*midi_local_offIcon), tr("local off"), this, SLOT(localOff()), 0);
+
+ //-------------------------------------------------------------
+ // popup Audio
+ //-------------------------------------------------------------
+
+ menu_audio = new Q3PopupMenu(this);
+ menu_audio->setCheckable(true);
+ menuBar()->insertItem(tr("&Audio"), menu_audio);
+ menu_ids[CMD_AUDIO_BOUNCE_TO_TRACK] = menu_audio->insertItem(
+ QIcon(*audio_bounce_to_trackIcon), tr("Bounce to Track"), this, SLOT(bounceToTrack()), 0);
+ menu_ids[CMD_AUDIO_BOUNCE_TO_FILE] = menu_audio->insertItem(
+ QIcon(*audio_bounce_to_fileIcon), tr("Bounce to File"), this, SLOT(bounceToFile()), 0);
+ menu_audio->insertSeparator();
+ menu_ids[CMD_AUDIO_RESTART] = menu_audio->insertItem(
+ QIcon(*audio_restartaudioIcon), tr("Restart Audio"), this, SLOT(seqRestart()), 0);
+
+ //-------------------------------------------------------------
+ // popup Automation
+ //-------------------------------------------------------------
+
+ menuAutomation = new Q3PopupMenu(this);
+ menuAutomation->setCheckable(true);
+ menuBar()->insertItem(tr("Automation"), menuAutomation);
+ autoId = menuAutomation->insertItem(
+ QIcon(*automation_mixerIcon), tr("Mixer Automation"), this, SLOT(switchMixerAutomation()), 0);
+ menuAutomation->insertSeparator();
+ menu_ids[CMD_MIXER_SNAPSHOT] = menuAutomation->insertItem(
+ QIcon(*automation_take_snapshotIcon), tr("Take Snapshot"), this, SLOT(takeAutomationSnapshot()), 0);
+ menu_ids[CMD_MIXER_AUTOMATION_CLEAR] = menuAutomation->insertItem(
+ QIcon(*automation_clear_dataIcon), tr("Clear Automation Data"), this, SLOT(clearAutomation()), 0);
+ menuAutomation->setItemEnabled(menu_ids[CMD_MIXER_AUTOMATION_CLEAR], false);
+
+ //-------------------------------------------------------------
+ // popup Settings
+ //-------------------------------------------------------------
+
+ follow = new Q3PopupMenu(this);
+ follow->setCheckable(false);
+ fid0 = follow->insertItem(tr("dont follow Song"), CMD_FOLLOW_NO);
+ fid1 = follow->insertItem(tr("follow page"), CMD_FOLLOW_JUMP);
+ fid2 = follow->insertItem(tr("follow continuous"), CMD_FOLLOW_CONTINUOUS);
+ follow->setItemChecked(fid1, true);
+ connect(follow, SIGNAL(activated(int)), SLOT(cmd(int)));
+
+ menuSettings = new Q3PopupMenu(this);
+ menuSettings->setCheckable(false);
+ menuBar()->insertItem(tr("Settings"), menuSettings);
+ menu_ids[CMD_GLOBAL_CONFIG] = menuSettings->insertItem(
+ QIcon(*settings_globalsettingsIcon), tr("Global Settings"), this, SLOT(configGlobalSettings()),0);
+ menu_ids[CMD_CONFIG_SHORTCUTS] = menuSettings->insertItem(
+ QIcon(*settings_configureshortcutsIcon), tr("Configure shortcuts"), this, SLOT(configShortCuts()), 0);
+ menuSettings->insertItem(
+ QIcon(*settings_follow_songIcon), tr("follow song"), follow, Qt::Key_F);
+ menu_ids[CMD_CONFIG_METRONOME] = menuSettings->insertItem(
+ QIcon(*settings_metronomeIcon), tr("Metronome"), this, SLOT(configMetronome()), 0);
+ menuSettings->insertSeparator();
+ menu_ids[CMD_CONFIG_MIDISYNC] = menuSettings->insertItem(
+ QIcon(*settings_midisyncIcon), tr("Midi Sync"), this, SLOT(configMidiSync()), 0);
+ menu_ids[CMD_MIDI_FILE_CONFIG] = menuSettings->insertItem(
+ QIcon(*settings_midifileexportIcon), tr("Midi File Import/Export"), this, SLOT(configMidiFile()), 0);
+ menuSettings->insertSeparator();
+ menu_ids[CMD_APPEARANCE_SETTINGS] = menuSettings->insertItem(
+ QIcon(*settings_appearance_settingsIcon), tr("Appearance settings"), this, SLOT(configAppearance()), 0);
+ menuSettings->insertSeparator();
+ menu_ids[CMD_CONFIG_MIDI_PORTS] = menuSettings->insertItem(
+ QIcon(*settings_midiport_softsynthsIcon), tr("Midi Ports / Soft Synth"), this, SLOT(configMidiPorts()), 0);
+
+ //---------------------------------------------------
+ // popup Help
+ //---------------------------------------------------
+
+ menuBar()->insertSeparator();
+ menu_help = new Q3PopupMenu(this);
+ menu_help->setCheckable(false);
+ menuBar()->insertItem(tr("&Help"), menu_help);
+
+ menu_ids[CMD_OPEN_HELP] = menu_help->insertItem(tr("&Manual"), this, SLOT(startHelpBrowser()), 0);
+ menu_ids[CMD_OPEN_HOMEPAGE] = menu_help->insertItem(tr("&MusE homepage"), this, SLOT(startHomepageBrowser()), 0);
+ menu_help->insertSeparator();
+ menu_ids[CMD_OPEN_BUG] = menu_help->insertItem(tr("&Report Bug..."), this, SLOT(startBugBrowser()), 0);
+ menu_help->insertSeparator();
+ menu_help->insertItem(tr("&About MusE"), this, SLOT(about()));
+ //menu_help->insertItem(tr("About&Qt"), this, SLOT(aboutQt()));
+ //menu_help->insertSeparator();
+ //menu_ids[CMD_START_WHATSTHIS] = menu_help->insertItem(tr("What's &This?"), this, SLOT(whatsThis()), 0);
+
+ //---------------------------------------------------
+ // Central Widget
+ //---------------------------------------------------
+
+ arranger = new Arranger(this, "arranger");
+ setCentralWidget(arranger);
+
+ connect(tools1, SIGNAL(toolChanged(int)), arranger, SLOT(setTool(int)));
+ connect(arranger, SIGNAL(editPart(Track*)), SLOT(startEditor(Track*)));
+ connect(arranger, SIGNAL(dropSongFile(const QString&)), SLOT(loadProjectFile(const QString&)));
+ connect(arranger, SIGNAL(dropMidiFile(const QString&)), SLOT(importMidi(const QString&)));
+ connect(arranger, SIGNAL(startEditor(PartList*,int)), SLOT(startEditor(PartList*,int)));
+ connect(arranger, SIGNAL(toolChanged(int)), tools1, SLOT(set(int)));
+ connect(this, SIGNAL(configChanged()), arranger, SLOT(configChanged()));
+
+ connect(arranger, SIGNAL(setUsedTool(int)), SLOT(setUsedTool(int)));
+
+ //---------------------------------------------------
+ // read list of "Recent Projects"
+ //---------------------------------------------------
+
+ QString prjPath(getenv("HOME"));
+ prjPath += QString("/.musePrj");
+ FILE* f = fopen(prjPath.latin1(), "r");
+ if (f == 0) {
+ perror("open projectfile");
+ for (int i = 0; i < PROJECT_LIST_LEN; ++i)
+ projectList[i] = 0;
+ }
+ else {
+ for (int i = 0; i < PROJECT_LIST_LEN; ++i) {
+ char buffer[256];
+ if (fgets(buffer, 256, f)) {
+ int n = strlen(buffer);
+ if (n && buffer[n-1] == '\n')
+ buffer[n-1] = 0;
+ projectList[i] = *buffer ? new QString(buffer) : 0;
+ }
+ else
+ break;
+ }
+ fclose(f);
+ }
+
+ initMidiSynth();
+
+ populateAddTrack(addTrack);
+
+ transport = new Transport(this, "transport");
+ bigtime = 0;
+
+ QClipboard* cb = QApplication::clipboard();
+ connect(cb, SIGNAL(dataChanged()), SLOT(clipboardChanged()));
+ connect(cb, SIGNAL(selectionChanged()), SLOT(clipboardChanged()));
+ connect(arranger, SIGNAL(selectionChanged()), SLOT(selectionChanged()));
+
+ //---------------------------------------------------
+ // load project
+ // if no songname entered on command line:
+ // startMode: 0 - load last song
+ // 1 - load default template
+ // 2 - load configured start song
+ //---------------------------------------------------
+
+ QString name;
+ bool useTemplate = false;
+ if (argc >= 2)
+ name = argv[0];
+ else if (config.startMode == 0) {
+ if (argc < 2)
+ name = projectList[0] ? *projectList[0] : QString("untitled");
+ else
+ name = argv[0];
+ printf("starting with selected song %s\n", config.startSong.latin1());
+ }
+ else if (config.startMode == 1) {
+ printf("starting with default template\n");
+ name = museGlobalShare + QString("/templates/default.med");
+ useTemplate = true;
+ }
+ else if (config.startMode == 2) {
+ printf("starting with pre configured song %s\n", config.startSong.latin1());
+ name = config.startSong;
+ }
+ song->blockSignals(false);
+ loadProjectFile(name, useTemplate, true);
+ changeConfig(false);
+
+ song->update();
+ }
+
+//---------------------------------------------------------
+// setHeartBeat
+//---------------------------------------------------------
+
+void MusE::setHeartBeat()
+ {
+ heartBeatTimer->start(1000/config.guiRefresh);
+ }
+
+//---------------------------------------------------------
+// resetDevices
+//---------------------------------------------------------
+
+void MusE::resetMidiDevices()
+ {
+ audio->msgResetMidiDevices();
+ }
+
+//---------------------------------------------------------
+// initMidiDevices
+//---------------------------------------------------------
+
+void MusE::initMidiDevices()
+ {
+ // Added by T356
+ //audio->msgIdle(true);
+
+ audio->msgInitMidiDevices();
+
+ // Added by T356
+ //audio->msgIdle(false);
+ }
+
+//---------------------------------------------------------
+// localOff
+//---------------------------------------------------------
+
+void MusE::localOff()
+ {
+ audio->msgLocalOff();
+ }
+
+//---------------------------------------------------------
+// loadProjectFile
+// load *.med, *.mid, *.kar
+//
+// template - if true, load file but do not change
+// project name
+//---------------------------------------------------------
+
+// for drop:
+void MusE::loadProjectFile(const QString& name)
+ {
+ loadProjectFile(name, false, false);
+ }
+
+void MusE::loadProjectFile(const QString& name, bool songTemplate, bool loadAll)
+ {
+ //
+ // stop audio threads if running
+ //
+ bool restartSequencer = audio->isRunning();
+ if (restartSequencer) {
+ if (audio->isPlaying()) {
+ audio->msgPlay(false);
+ while (audio->isPlaying())
+ qApp->processEvents();
+ }
+ seqStop();
+ }
+ microSleep(200000);
+ loadProjectFile1(name, songTemplate, loadAll);
+ microSleep(200000);
+ if (restartSequencer)
+ seqStart();
+
+ if (song->getSongInfo().length()>0)
+ startSongInfo(false);
+ }
+
+//---------------------------------------------------------
+// loadProjectFile
+// load *.med, *.mid, *.kar
+//
+// template - if true, load file but do not change
+// project name
+// loadAll - load song data + configuration data
+//---------------------------------------------------------
+
+void MusE::loadProjectFile1(const QString& name, bool songTemplate, bool loadAll)
+ {
+ //if (audioMixer)
+ // audioMixer->clear();
+ if (mixer1)
+ mixer1->clear();
+ if (mixer2)
+ mixer2->clear();
+ arranger->clear(); // clear track info
+ if (clearSong())
+ return;
+
+ QFileInfo fi(name);
+ if (songTemplate) {
+ if (!fi.isReadable()) {
+ QMessageBox::critical(this, QString("MusE"),
+ tr("Cannot read template"));
+ return;
+ }
+ project.setFile("untitled");
+ }
+ else {
+ printf("Setting project path to %s\n", fi.dirPath(true).latin1());
+ museProject = fi.dirPath(true);
+ project.setFile(name);
+ }
+ // Changed by T356. 01/19/2010. We want the complete extension here.
+ //QString ex = fi.extension(false).lower();
+ //if (ex.length() == 3)
+ // ex += ".";
+ //ex = ex.left(4);
+ QString ex = fi.extension(true).lower();
+ QString mex = ex.section('.', -1, -1);
+ if((mex == "gz") || (mex == "bz2"))
+ mex = ex.section('.', -2, -2);
+
+ //if (ex.isEmpty() || ex == "med.") {
+ if (ex.isEmpty() || mex == "med") {
+ //
+ // read *.med file
+ //
+ bool popenFlag;
+ FILE* f = fileOpen(this, fi.filePath(), QString(".med"), "r", popenFlag, true);
+ if (f == 0) {
+ if (errno != ENOENT) {
+ QMessageBox::critical(this, QString("MusE"),
+ tr("File open error"));
+ setUntitledProject();
+ }
+ else
+ setConfigDefaults();
+ }
+ else {
+ Xml xml(f);
+ read(xml, !loadAll);
+ bool fileError = ferror(f);
+ popenFlag ? pclose(f) : fclose(f);
+ if (fileError) {
+ QMessageBox::critical(this, QString("MusE"),
+ tr("File read error"));
+ setUntitledProject();
+ }
+ }
+ }
+ //else if (ex == "mid." || ex == "kar.") {
+ else if (mex == "mid" || mex == "kar") {
+ setConfigDefaults();
+ if (!importMidi(name, false))
+ setUntitledProject();
+ }
+ else {
+ QMessageBox::critical(this, QString("MusE"),
+ tr("Unknown File Format: ") + ex);
+ setUntitledProject();
+ }
+ if (!songTemplate) {
+ addProject(project.absFilePath());
+ setCaption(QString("MusE: Song: ") + project.baseName(true));
+ }
+ song->dirty = false;
+
+ menuView->setItemChecked(tr_id, config.transportVisible);
+ menuView->setItemChecked(bt_id, config.bigTimeVisible);
+ menuView->setItemChecked(mr_id, config.markerVisible);
+ menuAutomation->setItemChecked(autoId, automation);
+
+ if (loadAll) {
+ showBigtime(config.bigTimeVisible);
+ //showMixer(config.mixerVisible);
+ showMixer1(config.mixer1Visible);
+ showMixer2(config.mixer2Visible);
+
+ // Added p3.3.43 Make sure the geometry is correct because showMixerX() will NOT
+ // set the geometry if the mixer has already been created.
+ if(mixer1)
+ {
+ //if(mixer1->geometry().size() != config.mixer1.geometry.size()) // p3.3.53 Moved below
+ // mixer1->resize(config.mixer1.geometry.size());
+
+ if(mixer1->geometry().topLeft() != config.mixer1.geometry.topLeft())
+ mixer1->move(config.mixer1.geometry.topLeft());
+ }
+ if(mixer2)
+ {
+ //if(mixer2->geometry().size() != config.mixer2.geometry.size()) // p3.3.53 Moved below
+ // mixer2->resize(config.mixer2.geometry.size());
+
+ if(mixer2->geometry().topLeft() != config.mixer2.geometry.topLeft())
+ mixer2->move(config.mixer2.geometry.topLeft());
+ }
+
+ showMarker(config.markerVisible);
+ resize(config.geometryMain.size());
+ move(config.geometryMain.topLeft());
+
+ if (config.transportVisible)
+ transport->show();
+ transport->move(config.geometryTransport.topLeft());
+ showTransport(config.transportVisible);
+ }
+
+ transport->setMasterFlag(song->masterFlag());
+ punchinAction->setOn(song->punchin());
+ punchoutAction->setOn(song->punchout());
+ loopAction->setOn(song->loop());
+ song->update();
+ song->updatePos();
+ clipboardChanged(); // enable/disable "Paste"
+ selectionChanged(); // enable/disable "Copy" & "Paste"
+
+ // p3.3.53 Try this AFTER the song update above which does a mixer update... Tested OK - mixers resize properly now.
+ if (loadAll)
+ {
+ if(mixer1)
+ {
+ if(mixer1->geometry().size() != config.mixer1.geometry.size())
+ {
+ //printf("MusE::loadProjectFile1 resizing mixer1 x:%d y:%d w:%d h:%d\n", config.mixer1.geometry.x(),
+ // config.mixer1.geometry.y(),
+ // config.mixer1.geometry.width(),
+ // config.mixer1.geometry.height()
+ // );
+ mixer1->resize(config.mixer1.geometry.size());
+ }
+ }
+ if(mixer2)
+ {
+ if(mixer2->geometry().size() != config.mixer2.geometry.size())
+ {
+ //printf("MusE::loadProjectFile1 resizing mixer2 x:%d y:%d w:%d h:%d\n", config.mixer2.geometry.x(),
+ // config.mixer2.geometry.y(),
+ // config.mixer2.geometry.width(),
+ // config.mixer2.geometry.height()
+ // );
+ mixer2->resize(config.mixer2.geometry.size());
+ }
+ }
+ }
+
+ }
+
+//---------------------------------------------------------
+// setUntitledProject
+//---------------------------------------------------------
+
+void MusE::setUntitledProject()
+ {
+ setConfigDefaults();
+ QString name("untitled");
+ museProject = QFileInfo(name).dirPath(true);
+ project.setFile(name);
+ setCaption(tr("MusE: Song: ") + project.baseName(true));
+ }
+
+//---------------------------------------------------------
+// setConfigDefaults
+//---------------------------------------------------------
+
+void MusE::setConfigDefaults()
+ {
+ readConfiguration(); // used for reading midi files
+#if 0
+ if (readConfiguration()) {
+ //
+ // failed to load config file
+ // set buildin defaults
+ //
+ configTransportVisible = false;
+ configBigTimeVisible = false;
+
+ for (int channel = 0; channel < 2; ++channel)
+ song->addTrack(Track::AUDIO_GROUP);
+ AudioTrack* out = (AudioTrack*)song->addTrack(Track::AUDIO_OUTPUT);
+ AudioTrack* in = (AudioTrack*)song->addTrack(Track::AUDIO_INPUT);
+
+ // set some default routes
+ std::list<QString> il = audioDevice->inputPorts();
+ int channel = 0;
+ for (std::list<QString>::iterator i = il.begin(); i != il.end(); ++i, ++channel) {
+ if (channel == 2)
+ break;
+ audio->msgAddRoute(Route(out,channel), Route(*i,channel));
+ }
+ channel = 0;
+ std::list<QString> ol = audioDevice->outputPorts();
+ for (std::list<QString>::iterator i = ol.begin(); i != ol.end(); ++i, ++channel) {
+ if (channel == 2)
+ break;
+ audio->msgAddRoute(Route(*i, channel), Route(in,channel));
+ }
+ }
+#endif
+ song->dirty = false;
+ }
+
+//---------------------------------------------------------
+// setFollow
+//---------------------------------------------------------
+
+void MusE::setFollow()
+ {
+ Song::FollowMode fm = song->follow();
+ follow->setItemChecked(fid0, fm == Song::NO);
+ follow->setItemChecked(fid1, fm == Song::JUMP);
+ follow->setItemChecked(fid2, fm == Song::CONTINUOUS);
+ }
+
+//---------------------------------------------------------
+// MusE::loadProject
+//---------------------------------------------------------
+
+void MusE::loadProject()
+ {
+ bool loadAll;
+ QString fn = getOpenFileName(QString(""), med_file_pattern, this,
+ tr("MusE: load project"), &loadAll);
+ if (!fn.isEmpty()) {
+ museProject = QFileInfo(fn).dirPath(true);
+ loadProjectFile(fn, false, loadAll);
+ }
+ }
+
+//---------------------------------------------------------
+// loadTemplate
+//---------------------------------------------------------
+
+void MusE::loadTemplate()
+ {
+ QString fn = getOpenFileName(QString("templates"), med_file_pattern, this,
+ tr("MusE: load template"), 0);
+ if (!fn.isEmpty()) {
+ // museProject = QFileInfo(fn).dirPath(true);
+ loadProjectFile(fn, true, true);
+ setUntitledProject();
+ }
+ }
+
+//---------------------------------------------------------
+// save
+//---------------------------------------------------------
+
+bool MusE::save()
+ {
+ if (project.baseName(true) == "untitled")
+ return saveAs();
+ else
+ return save(project.filePath(), false);
+ }
+
+//---------------------------------------------------------
+// save
+//---------------------------------------------------------
+
+bool MusE::save(const QString& name, bool overwriteWarn)
+ {
+ QString backupCommand;
+
+ // By T356. Cache the jack in/out route names BEFORE saving.
+ // Because jack often shuts down during save, causing the routes to be lost in the file.
+ // Not required any more...
+ //cacheJackRouteNames();
+
+ if (QFile::exists(name)) {
+ backupCommand.sprintf("cp \"%s\" \"%s.backup\"", name.latin1(), name.latin1());
+ }
+ else if (QFile::exists(name + QString(".med"))) {
+ backupCommand.sprintf("cp \"%s.med\" \"%s.med.backup\"", name.latin1(), name.latin1());
+ }
+ if (!backupCommand.isEmpty())
+ system(backupCommand.latin1());
+
+ bool popenFlag;
+ FILE* f = fileOpen(this, name, QString(".med"), "w", popenFlag, false, overwriteWarn);
+ if (f == 0)
+ return false;
+ Xml xml(f);
+ write(xml);
+ if (ferror(f)) {
+ QString s = "Write File\n" + name + "\nfailed: "
+ //+ strerror(errno);
+ + QString(strerror(errno)); // p4.0.0
+ QMessageBox::critical(this,
+ tr("MusE: Write File failed"), s);
+ popenFlag? pclose(f) : fclose(f);
+ unlink(name.latin1());
+ return false;
+ }
+ else {
+ popenFlag? pclose(f) : fclose(f);
+ song->dirty = false;
+ return true;
+ }
+ }
+
+//---------------------------------------------------------
+// quitDoc
+//---------------------------------------------------------
+
+void MusE::quitDoc()
+ {
+ close(true);
+ }
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void MusE::closeEvent(QCloseEvent*)
+ {
+ song->setStop(true);
+ //
+ // wait for sequencer
+ //
+ while (audio->isPlaying()) {
+ qApp->processEvents();
+ }
+ if (song->dirty) {
+ int n = 0;
+ n = QMessageBox::warning(this, appName,
+ tr("The current Project contains unsaved data\n"
+ "Save Current Project?"),
+ tr("&Save"), tr("&Skip"), tr("&Abort"), 0, 2);
+ if (n == 0) {
+ if (!save()) // dont quit if save failed
+ return;
+ }
+ else if (n == 2)
+ return;
+ }
+ seqStop();
+
+ WaveTrackList* wt = song->waves();
+ for (iWaveTrack iwt = wt->begin(); iwt != wt->end(); ++iwt) {
+ WaveTrack* t = *iwt;
+ if (t->recFile() && t->recFile()->samples() == 0) {
+ t->recFile()->remove();
+ }
+ }
+
+ // save "Open Recent" list
+ QString prjPath(getenv("HOME"));
+ prjPath += "/.musePrj";
+ FILE* f = fopen(prjPath.latin1(), "w");
+ if (f) {
+ for (int i = 0; i < PROJECT_LIST_LEN; ++i) {
+ fprintf(f, "%s\n", projectList[i] ? projectList[i]->latin1() : "");
+ }
+ fclose(f);
+ }
+ if(debugMsg)
+ printf("Muse: Exiting JackAudio\n");
+ exitJackAudio();
+ if(debugMsg)
+ printf("Muse: Exiting DummyAudio\n");
+ exitDummyAudio();
+ if(debugMsg)
+ printf("Muse: Exiting Metronome\n");
+ exitMetronome();
+
+ // p3.3.47
+ // Make sure to clear the menu, which deletes any sub menus.
+ if(routingPopupMenu)
+ routingPopupMenu->clear();
+
+ // Changed by Tim. p3.3.14
+ //SynthIList* sl = song->syntis();
+ //for (iSynthI i = sl->begin(); i != sl->end(); ++i)
+ // delete *i;
+ song->cleanupForQuit();
+
+ if(debugMsg)
+ printf("Muse: Cleaning up temporary wavefiles + peakfiles\n");
+ // Cleanup temporary wavefiles + peakfiles used for undo
+ for (std::list<QString>::iterator i = temporaryWavFiles.begin(); i != temporaryWavFiles.end(); i++) {
+ QString filename = *i;
+ QFileInfo f(filename);
+ QDir d = f.dir();
+ d.remove(filename);
+ d.remove(f.baseName(true) + ".wca");
+ }
+
+ // Added by Tim. p3.3.14
+
+#ifdef HAVE_LASH
+ // Disconnect gracefully from LASH.
+ if(lash_client)
+ {
+ if(debugMsg)
+ printf("Muse: Disconnecting from LASH\n");
+ lash_event_t* lashev = lash_event_new_with_type (LASH_Quit);
+ lash_send_event(lash_client, lashev);
+ }
+#endif
+
+ if(debugMsg)
+ printf("Muse: Exiting Dsp\n");
+ AL::exitDsp();
+
+ if(debugMsg)
+ printf("Muse: Exiting OSC\n");
+ exitOSC();
+
+ // p3.3.47
+ delete audioPrefetch;
+ delete audio;
+ delete midiSeq;
+ delete song;
+
+ qApp->quit();
+ }
+
+//---------------------------------------------------------
+// toggleMarker
+//---------------------------------------------------------
+
+void MusE::toggleMarker()
+ {
+ showMarker(!menuView->isItemChecked(mr_id));
+ }
+
+//---------------------------------------------------------
+// showMarker
+//---------------------------------------------------------
+
+void MusE::showMarker(bool flag)
+ {
+ //printf("showMarker %d\n",flag);
+ if (markerView == 0) {
+ markerView = new MarkerView(this);
+
+ // Removed p3.3.43
+ // Song::addMarker() already emits a 'markerChanged'.
+ //connect(arranger, SIGNAL(addMarker(int)), markerView, SLOT(addMarker(int)));
+
+ connect(markerView, SIGNAL(closed()), SLOT(markerClosed()));
+ toplevels.push_back(Toplevel(Toplevel::MARKER, (unsigned long)(markerView), markerView));
+ markerView->show();
+ }
+
+ markerView->setShown(flag);
+ menuView->setItemChecked(mr_id, flag);
+ }
+
+//---------------------------------------------------------
+// markerClosed
+//---------------------------------------------------------
+
+void MusE::markerClosed()
+ {
+ menuView->setItemChecked(mr_id, false);
+ }
+
+//---------------------------------------------------------
+// toggleTransport
+//---------------------------------------------------------
+
+void MusE::toggleTransport()
+ {
+ showTransport(!menuView->isItemChecked(tr_id));
+ }
+
+//---------------------------------------------------------
+// showTransport
+//---------------------------------------------------------
+
+void MusE::showTransport(bool flag)
+ {
+ transport->setShown(flag);
+ menuView->setItemChecked(tr_id, flag);
+ }
+
+//---------------------------------------------------------
+// getRoutingPopupMenu
+//---------------------------------------------------------
+
+PopupMenu* MusE::getRoutingPopupMenu()
+{
+ if(!routingPopupMenu)
+ routingPopupMenu = new PopupMenu(this);
+ return routingPopupMenu;
+}
+
+//---------------------------------------------------------
+// updateRouteMenus
+//---------------------------------------------------------
+
+//void MusE::updateRouteMenus(Track* track)
+void MusE::updateRouteMenus(Track* track, QObject* master) // p3.3.50
+{
+ //if(!track || track != gRoutingPopupMenuMaster || track->type() == Track::AUDIO_AUX)
+ //if(!track || track->type() == Track::AUDIO_AUX)
+ if(!track || gRoutingPopupMenuMaster != master) // p3.3.50
+ return;
+
+ //QPopupMenu* pup = muse->getORoutesPopup();
+ PopupMenu* pup = getRoutingPopupMenu();
+
+ if(pup->count() == 0)
+ return;
+
+ // p4.0.1 Protection since reverting to regular (self-extinguishing) menu behaviour here in muse2.
+ if(!pup->isVisible())
+ {
+ //printf("MusE::updateRouteMenus menu is not visible\n");
+ return;
+ }
+
+ //AudioTrack* t = (AudioTrack*)track;
+ RouteList* rl = gIsOutRoutingPopupMenu ? track->outRoutes() : track->inRoutes();
+
+ /*
+ iRoute iorl = orl->begin();
+ for(; iorl != orl->end(); ++iorl)
+ {
+ iRouteMenuMap imm = ormm->begin();
+ for(; imm != ormm->end(); ++imm)
+ {
+ if(*iorl == imm->second)
+ {
+ orpup->setItemChecked(imm->first, true);
+ break;
+ }
+ }
+ //if(imm == ormm->end())
+ //{
+ //}
+
+ }
+ //if (iorl == orl->end())
+ //{
+ //}
+ */
+
+ iRouteMenuMap imm = gRoutingMenuMap.begin();
+ for(; imm != gRoutingMenuMap.end(); ++imm)
+ {
+ // p3.3.50 Ignore the 'toggle' items.
+ if(imm->second.type == Route::MIDI_PORT_ROUTE &&
+ imm->first >= (MIDI_PORTS * MIDI_CHANNELS) && imm->first < (MIDI_PORTS * MIDI_CHANNELS + MIDI_PORTS))
+ continue;
+
+ //bool found = false;
+ iRoute irl = rl->begin();
+ for(; irl != rl->end(); ++irl)
+ {
+ if(imm->second.type == Route::MIDI_PORT_ROUTE) // p3.3.50 Is the map route a midi port route?
+ {
+ if(irl->type == Route::MIDI_PORT_ROUTE && irl->midiPort == imm->second.midiPort // Is the track route a midi port route?
+ && (irl->channel & imm->second.channel) == imm->second.channel) // Is the exact channel mask bit(s) set?
+ {
+ //found = true;
+ break;
+ }
+ }
+ else
+ if(*irl == imm->second)
+ {
+ //found = true;
+ break;
+ }
+ }
+ //pup->setItemChecked(imm->first, found);
+ pup->setItemChecked(imm->first, irl != rl->end());
+ }
+
+
+ return;
+}
+
+//---------------------------------------------------------
+// routingPopupMenuActivated
+//---------------------------------------------------------
+
+void MusE::routingPopupMenuActivated(Track* track, int n)
+{
+ //if(!track || (track != gRoutingPopupMenuMaster))
+ if(!track)
+ return;
+
+ if(track->isMidiTrack())
+ {
+ PopupMenu* pup = getRoutingPopupMenu();
+
+ //printf("MusE::routingPopupMenuActivated midi n:%d count:%d\n", n, pup->count());
+
+ if(pup->count() == 0)
+ return;
+
+ //MidiTrack* t = (MidiTrack*)track;
+ RouteList* rl = gIsOutRoutingPopupMenu ? track->outRoutes() : track->inRoutes();
+
+ if(n == -1)
+ {
+ //printf("MusE::routingPopupMenuActivated midi n = -1\n");
+ ///delete pup;
+ ///pup = 0;
+ return;
+ }
+ else
+ {
+ //int mdidx = n / MIDI_CHANNELS;
+ //int ch = n % MIDI_CHANNELS;
+ //int chbit = 1 << ch; // p3.3.50
+ //int chmask = 0;
+
+ //if(n >= MIDI_PORTS * MIDI_CHANNELS) // p3.3.50 Toggle channels.
+ //{
+ //for (int i = 0; i < MIDI_CHANNELS; i++)
+ //muse->routingPopupMenuActivated(selected, i + MIDI_CHANNELS * (n-1000));
+ //muse->routingPopupMenuActivated(selected, i + MIDI_CHANNELS * (n - MIDI_PORTS * MIDI_CHANNELS)); // p3.3.50
+ // chbit = (1 << MIDI_CHANNELS) - 1;
+ //}
+ //if(debugMsg)
+ //printf("MusE::routingPopupMenuActivated mdidx:%d ch:%d\n", mdidx, ch);
+
+ // p3.3.50
+ iRouteMenuMap imm = gRoutingMenuMap.find(n);
+ if(imm == gRoutingMenuMap.end())
+ return;
+ if(imm->second.type != Route::MIDI_PORT_ROUTE)
+ return;
+ Route &aRoute = imm->second;
+ int chbit = aRoute.channel;
+ Route bRoute(track, chbit);
+ int mdidx = aRoute.midiPort;
+
+ MidiPort* mp = &midiPorts[mdidx];
+ MidiDevice* md = mp->device();
+ if(!md)
+ {
+ ///delete pup;
+ return;
+ }
+
+ //if(!(md->rwFlags() & 2))
+ if(!(md->rwFlags() & (gIsOutRoutingPopupMenu ? 1 : 2)))
+ {
+ ///delete pup;
+ return;
+ }
+
+ //QString s(pup->text(n));
+ //QT_TR_NOOP(md->name())
+
+ //Route srcRoute(s, false, -1);
+
+ //Route aRoute(md, ch);
+ //Route aRoute(mdidx, ch); // p3.3.49
+ //Route aRoute(mdidx, chbit); // p3.3.50 In accordance with new channel mask, use the bit position.
+
+ //Route srcRoute(md, -1);
+ //Route dstRoute(track, -1);
+ //Route bRoute(track, ch);
+ //Route bRoute(track, chbit); // p3.3.50
+
+ //if (track->type() == Track::AUDIO_INPUT)
+ // srcRoute.channel = dstRoute.channel = n & 0xf;
+
+ int chmask = 0;
+ iRoute iir = rl->begin();
+ for (; iir != rl->end(); ++iir)
+ {
+ //if(*iir == (dst ? bRoute : aRoute))
+ //if(*iir == aRoute)
+ if(iir->type == Route::MIDI_PORT_ROUTE && iir->midiPort == mdidx) // p3.3.50 Is there already a route to this port?
+ {
+ chmask = iir->channel; // p3.3.50 Grab the channel mask.
+ break;
+ }
+ }
+ //if (iir != rl->end())
+ if ((chmask & chbit) == chbit) // p3.3.50 Is the channel's bit(s) set?
+ {
+ // disconnect
+ if(gIsOutRoutingPopupMenu)
+ {
+ //printf("MusE::routingPopupMenuActivated removing route src track name: %s dst device name: %s\n", track->name().latin1(), md->name().latin1());
+ audio->msgRemoveRoute(bRoute, aRoute);
+ }
+ else
+ {
+ //printf("MusE::routingPopupMenuActivated removing route src device name: %s dst track name: %s\n", md->name().latin1(), track->name().latin1());
+ audio->msgRemoveRoute(aRoute, bRoute);
+ }
+ }
+ else
+ {
+ // connect
+ if(gIsOutRoutingPopupMenu)
+ {
+ //printf("MusE::routingPopupMenuActivated adding route src track name: %s dst device name: %s\n", track->name().latin1(), md->name().latin1());
+ audio->msgAddRoute(bRoute, aRoute);
+ }
+ else
+ {
+ //printf("MusE::routingPopupMenuActivated adding route src device name: %s dst track name: %s\n", md->name().latin1(), track->name().latin1());
+ audio->msgAddRoute(aRoute, bRoute);
+ }
+ }
+
+ //printf("MusE::routingPopupMenuActivated calling msgUpdateSoloStates\n");
+ audio->msgUpdateSoloStates();
+ //printf("MusE::routingPopupMenuActivated calling song->update\n");
+ song->update(SC_ROUTE);
+ }
+ }
+ else
+ {
+ // TODO: Try to move code from AudioStrip::routingPopupMenuActivated into here.
+
+ /*
+ PopupMenu* pup = getRoutingPopupMenu();
+
+ printf("MusE::routingPopupMenuActivated audio n:%d count:%d\n", n, pup->count());
+
+ if(pup->count() == 0)
+ return;
+
+ AudioTrack* t = (AudioTrack*)track;
+ RouteList* rl = gIsOutRoutingPopupMenu ? t->outRoutes() : t->inRoutes();
+
+ //QPoint ppt = QCursor::pos();
+
+ if(n == -1)
+ {
+ //printf("MusE::routingPopupMenuActivated audio n = -1 deleting popup...\n");
+ printf("MusE::routingPopupMenuActivated audio n = -1\n");
+ ///delete pup;
+ ///pup = 0;
+ return;
+ }
+ else
+ //if(n == 0)
+ //{
+ //printf("MusE::routingPopupMenuActivated audio n = 0 = tearOffHandle\n");
+ //oR->setDown(false);
+ // return;
+ //}
+ //else
+ {
+ if(gIsOutRoutingPopupMenu)
+ {
+ QString s(pup->text(n));
+
+ //printf("AudioStrip::routingPopupMenuActivated audio text:%s\n", s.latin1());
+
+ if(track->type() == Track::AUDIO_OUTPUT)
+ {
+ ///delete orpup;
+
+ int chan = n & 0xf;
+
+ //Route srcRoute(t, -1);
+ //Route srcRoute(t, chan, chans);
+ //Route srcRoute(t, chan, 1);
+ Route srcRoute(t, chan);
+
+ //Route dstRoute(s, true, -1);
+ Route dstRoute(s, true, -1, Route::JACK_ROUTE);
+ //Route dstRoute(s, true, 0, Route::JACK_ROUTE);
+
+ //srcRoute.channel = dstRoute.channel = chan;
+ dstRoute.channel = chan;
+ //dstRoute.channels = 1;
+
+ // check if route src->dst exists:
+ iRoute irl = rl->begin();
+ for (; irl != rl->end(); ++irl) {
+ if (*irl == dstRoute)
+ break;
+ }
+ if (irl != rl->end()) {
+ // disconnect if route exists
+ audio->msgRemoveRoute(srcRoute, dstRoute);
+ }
+ else {
+ // connect if route does not exist
+ audio->msgAddRoute(srcRoute, dstRoute);
+ }
+ audio->msgUpdateSoloStates();
+ song->update(SC_ROUTE);
+
+ // p3.3.47
+ //pup->popup(ppt, 0);
+
+ //oR->setDown(false);
+ return;
+
+ // p3.3.46
+ ///goto _redisplay;
+ }
+
+ iRouteMenuMap imm = gRoutingMenuMap.find(n);
+ if(imm == gRoutingMenuMap.end())
+ {
+ ///delete orpup;
+ //oR->setDown(false); // orpup->exec() catches mouse release event
+ return;
+ }
+
+ //int chan = n >> 16;
+ //int chans = (chan >> 15) + 1; // Bit 31 MSB: Mono or stereo.
+ //chan &= 0xffff;
+ //int chan = imm->second.channel;
+ //int chans = imm->second.channels;
+
+ //Route srcRoute(t, -1);
+ //srcRoute.remoteChannel = chan;
+ //Route srcRoute(t, chan, chans);
+ Route srcRoute(t, imm->second.channel, imm->second.channels);
+ //Route srcRoute(t, imm->second.channel);
+ srcRoute.remoteChannel = imm->second.remoteChannel;
+
+ //Route dstRoute(s, true, -1);
+ //Route dstRoute(s, true, -1, Route::TRACK_ROUTE);
+ Route &dstRoute = imm->second;
+
+ // check if route src->dst exists:
+ iRoute irl = rl->begin();
+ for (; irl != rl->end(); ++irl) {
+ if (*irl == dstRoute)
+ break;
+ }
+ if (irl != rl->end()) {
+ // disconnect if route exists
+ audio->msgRemoveRoute(srcRoute, dstRoute);
+ }
+ else {
+ // connect if route does not exist
+ audio->msgAddRoute(srcRoute, dstRoute);
+ }
+ audio->msgUpdateSoloStates();
+ song->update(SC_ROUTE);
+
+ // p3.3.46
+ //oR->setDown(false);
+ ///goto _redisplay;
+
+ // p3.3.47
+ //pup->popup(ppt, 0);
+ }
+ else
+ {
+ QString s(pup->text(n));
+
+ if(track->type() == Track::AUDIO_INPUT)
+ {
+ ///delete pup;
+ int chan = n & 0xf;
+
+ Route srcRoute(s, false, -1, Route::JACK_ROUTE);
+ Route dstRoute(t, chan);
+
+ srcRoute.channel = chan;
+
+ iRoute irl = rl->begin();
+ for(; irl != rl->end(); ++irl)
+ {
+ if(*irl == srcRoute)
+ break;
+ }
+ if(irl != rl->end())
+ // disconnect
+ audio->msgRemoveRoute(srcRoute, dstRoute);
+ else
+ // connect
+ audio->msgAddRoute(srcRoute, dstRoute);
+
+ audio->msgUpdateSoloStates();
+ song->update(SC_ROUTE);
+ //iR->setDown(false); // pup->exec() catches mouse release event
+ return;
+
+ // p3.3.46
+ ///goto _redisplay;
+ }
+
+ iRouteMenuMap imm = gRoutingMenuMap.find(n);
+ if(imm == gRoutingMenuMap.end())
+ {
+ //delete pup;
+ //iR->setDown(false); // pup->exec() catches mouse release event
+ return;
+ }
+
+ //int chan = n >> 16;
+ //int chans = (chan >> 15) + 1; // Bit 31 MSB: Mono or stereo.
+ //chan &= 0xffff;
+ //int chan = imm->second.channel;
+ //int chans = imm->second.channels;
+
+ //Route srcRoute(s, false, -1);
+ //Route srcRoute(s, false, -1, Route::TRACK_ROUTE);
+ Route &srcRoute = imm->second;
+
+ //Route dstRoute(t, -1);
+ //Route dstRoute(t, chan, chans);
+ Route dstRoute(t, imm->second.channel, imm->second.channels);
+ //Route dstRoute(t, imm->second.channel);
+ dstRoute.remoteChannel = imm->second.remoteChannel;
+
+ iRoute irl = rl->begin();
+ for (; irl != rl->end(); ++irl) {
+ if (*irl == srcRoute)
+ break;
+ }
+ if (irl != rl->end()) {
+ // disconnect
+ audio->msgRemoveRoute(srcRoute, dstRoute);
+ }
+ else {
+ // connect
+ audio->msgAddRoute(srcRoute, dstRoute);
+ }
+ audio->msgUpdateSoloStates();
+ song->update(SC_ROUTE);
+
+ // p3.3.46
+ //iR->setDown(false);
+ ///goto _redisplay;
+
+
+
+
+ }
+
+ }
+ */
+
+ }
+ //else
+ //{
+ //}
+
+ ///delete pup;
+ //oR->setDown(false);
+}
+
+//---------------------------------------------------------
+// routingPopupMenuAboutToHide
+//---------------------------------------------------------
+
+void MusE::routingPopupMenuAboutToHide()
+{
+ // p3.3.47
+ //printf("MusE::routingPopupMenuAboutToHide\n");
+ //if(track)
+ // printf("%s", track->name().latin1());
+ //printf("\n");
+
+ // Hmm, can't do this? Sub-menus stay open with this. Re-arranged, testing... Nope.
+ //PopupMenu* pup = muse->getRoutingPopupMenu();
+ //pup->disconnect();
+ //pup->clear();
+
+ // p4.0.1 Removed. IIRC These lines were not strictly necessary in muse-1,
+ // and here in muse-2 we reverted back to regular Q3PopupMenu behaviour for now,
+ // which is self-extinguishing, so these lines cannot be enabled -
+ // gRoutingPopupMenuMaster and gRoutingMenuMap are required for routingPopupMenuActivated().
+ //gRoutingMenuMap.clear();
+ //gRoutingPopupMenuMaster = 0;
+}
+
+//---------------------------------------------------------
+// prepareRoutingPopupMenu
+//---------------------------------------------------------
+
+PopupMenu* MusE::prepareRoutingPopupMenu(Track* track, bool dst)
+{
+ if(!track)
+ return 0;
+
+ //QPoint ppt = QCursor::pos();
+
+ if(track->isMidiTrack())
+ {
+
+ //QPoint ppt = parent->rect().bottomLeft();
+
+ //if(dst)
+ //{
+ // TODO
+
+ //}
+ //else
+ //{
+ RouteList* rl = dst ? track->outRoutes() : track->inRoutes();
+ //Route dst(track, -1);
+
+ ///QPopupMenu* pup = new QPopupMenu(parent);
+
+ PopupMenu* pup = getRoutingPopupMenu();
+ pup->disconnect();
+ //connect(pup, SIGNAL(activated(int)), SLOT(routingPopupMenuActivated(int)));
+ //connect(pup, SIGNAL(aboutToHide()), SLOT(routingPopupMenuAboutToHide()));
+
+ pup->setCheckable(true);
+
+ int gid = 0;
+ //int n;
+
+ // Routes can't be re-read until the message sent from msgAddRoute1()
+ // has had time to be sent and actually affected the routes.
+ ///_redisplay:
+
+ pup->clear();
+ gRoutingMenuMap.clear();
+ gid = 0;
+
+ //MidiInPortList* tl = song->midiInPorts();
+ //for(iMidiInPort i = tl->begin();i != tl->end(); ++i)
+ for(int i = 0; i < MIDI_PORTS; ++i)
+ {
+ //MidiInPort* track = *i;
+ // NOTE: Could possibly list all devices, bypassing ports, but no, let's stick with ports.
+ MidiPort* mp = &midiPorts[i];
+ MidiDevice* md = mp->device();
+ if(!md)
+ continue;
+
+ if(!(md->rwFlags() & (dst ? 1 : 2)))
+ continue;
+
+ //printf("MusE::prepareRoutingPopupMenu adding submenu portnum:%d\n", i);
+
+ //QMenu* m = menu->addMenu(track->name());
+ //QPopupMenu* subp = new QPopupMenu(parent);
+ //PopupMenu* subp = new PopupMenu(this);
+ PopupMenu* subp = new PopupMenu();
+ connect(subp, SIGNAL(activated(int)), pup, SIGNAL(activated(int)));
+ //connect(subp, SIGNAL(aboutToHide()), pup, SIGNAL(aboutToHide()));
+
+ int chanmask = 0;
+ // p3.3.50 To reduce number of routes required, from one per channel to just one containing a channel mask.
+ // Look for the first route to this midi port. There should always be only a single route for each midi port, now.
+ for(iRoute ir = rl->begin(); ir != rl->end(); ++ir)
+ {
+ if(ir->type == Route::MIDI_PORT_ROUTE && ir->midiPort == i)
+ {
+ // We have a route to the midi port. Grab the channel mask.
+ chanmask = ir->channel;
+ break;
+ }
+ }
+
+ for(int ch = 0; ch < MIDI_CHANNELS; ++ch)
+ {
+ //QAction* a = m->addAction(QString("Channel %1").arg(ch+1));
+ //subp->insertItem(QT_TR_NOOP(QString("Channel %1").arg(ch+1)), i * MIDI_CHANNELS + ch);
+ gid = i * MIDI_CHANNELS + ch;
+
+ //printf("MusE::prepareRoutingPopupMenu inserting gid:%d\n", gid);
+
+ subp->insertItem(QString("Channel %1").arg(ch+1), gid);
+ //a->setCheckable(true);
+ //Route src(track, ch, RouteNode::TRACK);
+ //Route src(md, ch);
+ //Route r = Route(src, dst);
+ //a->setData(QVariant::fromValue(r));
+ //a->setChecked(rl->indexOf(r) != -1);
+
+ //Route srcRoute(md, ch);
+ //Route srcRoute(i, ch); // p3.3.49 New: Midi port route.
+ int chbit = 1 << ch;
+ Route srcRoute(i, chbit); // p3.3.50 In accordance with new channel mask, use the bit position.
+
+ gRoutingMenuMap.insert( pRouteMenuMap(gid, srcRoute) );
+
+ //for(iRoute ir = rl->begin(); ir != rl->end(); ++ir) // p3.3.50 Removed.
+ //{
+ //if(*ir == dst)
+ // if(*ir == srcRoute)
+ // {
+ // subp->setItemChecked(id, true);
+ // break;
+ // }
+ //}
+ if(chanmask & chbit) // p3.3.50 Is the channel already set? Show item check mark.
+ subp->setItemChecked(gid, true);
+ }
+ //subp->insertItem(QString("Toggle all"), 1000+i);
+ // p3.3.50 One route with all channel bits set.
+ gid = MIDI_PORTS * MIDI_CHANNELS + i; // Make sure each 'toggle' item gets a unique id.
+ subp->insertItem(QString("Toggle all"), gid);
+ Route togRoute(i, (1 << MIDI_CHANNELS) - 1); // Set all channel bits.
+ gRoutingMenuMap.insert( pRouteMenuMap(gid, togRoute) );
+
+ pup->insertItem(QT_TR_NOOP(md->name()), subp);
+ }
+
+ /*
+ QPopupMenu* pup = new QPopupMenu(iR);
+ pup->setCheckable(true);
+ //MidiTrack* t = (MidiTrack*)track;
+ RouteList* irl = track->inRoutes();
+
+ MidiTrack* t = (MidiTrack*)track;
+ int gid = 0;
+ for (int i = 0; i < channel; ++i)
+ {
+ char buffer[128];
+ snprintf(buffer, 128, "%s %d", tr("Channel").latin1(), i+1);
+ MenuTitleItem* titel = new MenuTitleItem(QString(buffer));
+ pup->insertItem(titel);
+
+ if (!checkAudioDevice()) return;
+ std::list<QString> ol = audioDevice->outputPorts();
+ for (std::list<QString>::iterator ip = ol.begin(); ip != ol.end(); ++ip) {
+ int id = pup->insertItem(*ip, (gid * 16) + i);
+ Route dst(*ip, true, i);
+ ++gid;
+ for (iRoute ir = irl->begin(); ir != irl->end(); ++ir) {
+ if (*ir == dst) {
+ pup->setItemChecked(id, true);
+ break;
+ }
+ }
+ }
+ if (i+1 != channel)
+ pup->insertSeparator();
+ }
+ */
+
+ if(pup->count() == 0)
+ {
+ ///delete pup;
+ gRoutingPopupMenuMaster = 0;
+ //pup->clear();
+ //pup->disconnect();
+ gRoutingMenuMap.clear();
+ //oR->setDown(false);
+ return 0;
+ }
+
+ gIsOutRoutingPopupMenu = dst;
+ return pup;
+ }
+
+ return 0;
+}
+
+//---------------------------------------------------------
+// saveAs
+//---------------------------------------------------------
+
+bool MusE::saveAs()
+ {
+// QString name = getSaveFileName(museProject, med_file_pattern, this,
+// QString name = getSaveFileName(QString(""), med_file_pattern, this,
+ QString name = getSaveFileName(QString(""), med_file_save_pattern, this,
+ tr("MusE: Save As"));
+ bool ok = false;
+ if (!name.isEmpty()) {
+ QString tempOldProj = museProject;
+ museProject = QFileInfo(name).dirPath(true);
+ ok = save(name, true);
+ if (ok) {
+ project.setFile(name);
+ setCaption(tr("MusE: Song: ") + project.baseName(true));
+ addProject(name);
+ }
+ else
+ museProject = tempOldProj;
+ }
+
+ return ok;
+ }
+
+//---------------------------------------------------------
+// printVersion
+//---------------------------------------------------------
+
+static void printVersion(const char* prog)
+ {
+ fprintf(stderr, "%s: Linux Music Editor; Version %s, (svn revision %s)\n", prog, VERSION, SVNVERSION);
+ }
+
+//---------------------------------------------------------
+// startEditor
+//---------------------------------------------------------
+
+void MusE::startEditor(PartList* pl, int type)
+ {
+ switch (type) {
+ case 0: startPianoroll(pl); break;
+ case 1: startListEditor(pl); break;
+ case 3: startDrumEditor(pl); break;
+ case 4: startWaveEditor(pl); break;
+ }
+ }
+
+//---------------------------------------------------------
+// startEditor
+//---------------------------------------------------------
+
+void MusE::startEditor(Track* t)
+ {
+ switch (t->type()) {
+ case Track::MIDI: startPianoroll(); break;
+ case Track::DRUM: startDrumEditor(); break;
+ case Track::WAVE: startWaveEditor(); break;
+ default:
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// getMidiPartsToEdit
+//---------------------------------------------------------
+
+PartList* MusE::getMidiPartsToEdit()
+ {
+ PartList* pl = song->getSelectedMidiParts();
+ if (pl->empty()) {
+ QMessageBox::critical(this, QString("MusE"), tr("Nothing to edit"));
+ return 0;
+ }
+ return pl;
+ }
+
+//---------------------------------------------------------
+// startPianoroll
+//---------------------------------------------------------
+
+void MusE::startPianoroll()
+ {
+ PartList* pl = getMidiPartsToEdit();
+ if (pl == 0)
+ return;
+ startPianoroll(pl);
+ }
+
+void MusE::startPianoroll(PartList* pl)
+ {
+
+ PianoRoll* pianoroll = new PianoRoll(pl, this, 0, arranger->cursorValue());
+ pianoroll->show();
+ toplevels.push_back(Toplevel(Toplevel::PIANO_ROLL, (unsigned long)(pianoroll), pianoroll));
+ connect(pianoroll, SIGNAL(deleted(unsigned long)), SLOT(toplevelDeleted(unsigned long)));
+ connect(muse, SIGNAL(configChanged()), pianoroll, SLOT(configChanged()));
+ }
+
+//---------------------------------------------------------
+// startListenEditor
+//---------------------------------------------------------
+
+void MusE::startListEditor()
+ {
+ PartList* pl = getMidiPartsToEdit();
+ if (pl == 0)
+ return;
+ startListEditor(pl);
+ }
+
+void MusE::startListEditor(PartList* pl)
+ {
+ ListEdit* listEditor = new ListEdit(pl);
+ listEditor->show();
+ toplevels.push_back(Toplevel(Toplevel::LISTE, (unsigned long)(listEditor), listEditor));
+ connect(listEditor, SIGNAL(deleted(unsigned long)), SLOT(toplevelDeleted(unsigned long)));
+ connect(muse,SIGNAL(configChanged()), listEditor, SLOT(configChanged()));
+ }
+
+//---------------------------------------------------------
+// startMasterEditor
+//---------------------------------------------------------
+
+void MusE::startMasterEditor()
+ {
+ MasterEdit* masterEditor = new MasterEdit();
+ masterEditor->show();
+ toplevels.push_back(Toplevel(Toplevel::MASTER, (unsigned long)(masterEditor), masterEditor));
+ connect(masterEditor, SIGNAL(deleted(unsigned long)), SLOT(toplevelDeleted(unsigned long)));
+ }
+
+//---------------------------------------------------------
+// startLMasterEditor
+//---------------------------------------------------------
+
+void MusE::startLMasterEditor()
+ {
+ LMaster* lmaster = new LMaster();
+ lmaster->show();
+ toplevels.push_back(Toplevel(Toplevel::LMASTER, (unsigned long)(lmaster), lmaster));
+ connect(lmaster, SIGNAL(deleted(unsigned long)), SLOT(toplevelDeleted(unsigned long)));
+ connect(muse, SIGNAL(configChanged()), lmaster, SLOT(configChanged()));
+ }
+
+//---------------------------------------------------------
+// startDrumEditor
+//---------------------------------------------------------
+
+void MusE::startDrumEditor()
+ {
+ PartList* pl = getMidiPartsToEdit();
+ if (pl == 0)
+ return;
+ startDrumEditor(pl);
+ }
+
+void MusE::startDrumEditor(PartList* pl)
+ {
+
+ DrumEdit* drumEditor = new DrumEdit(pl, this, 0, arranger->cursorValue());
+ drumEditor->show();
+ toplevels.push_back(Toplevel(Toplevel::DRUM, (unsigned long)(drumEditor), drumEditor));
+ connect(drumEditor, SIGNAL(deleted(unsigned long)), SLOT(toplevelDeleted(unsigned long)));
+ connect(muse, SIGNAL(configChanged()), drumEditor, SLOT(configChanged()));
+ }
+
+//---------------------------------------------------------
+// startWaveEditor
+//---------------------------------------------------------
+
+void MusE::startWaveEditor()
+ {
+ PartList* pl = song->getSelectedWaveParts();
+ if (pl->empty()) {
+ QMessageBox::critical(this, QString("MusE"), tr("Nothing to edit"));
+ return;
+ }
+ startWaveEditor(pl);
+ }
+
+void MusE::startWaveEditor(PartList* pl)
+ {
+ WaveEdit* waveEditor = new WaveEdit(pl);
+ waveEditor->show();
+ connect(muse, SIGNAL(configChanged()), waveEditor, SLOT(configChanged()));
+ toplevels.push_back(Toplevel(Toplevel::WAVE, (unsigned long)(waveEditor), waveEditor));
+ connect(waveEditor, SIGNAL(deleted(unsigned long)), SLOT(toplevelDeleted(unsigned long)));
+ }
+
+
+//---------------------------------------------------------
+// startSongInfo
+//---------------------------------------------------------
+void MusE::startSongInfo(bool editable)
+ {
+ printf("startSongInfo!!!!\n");
+ SongInfo info;
+ info.songInfoText->setText(song->getSongInfo());
+ info.songInfoText->setReadOnly(!editable);
+ info.show();
+ if( info.exec() == QDialog::Accepted) {
+ if (editable)
+ song->setSongInfo(info.songInfoText->text());
+ }
+
+ }
+
+//---------------------------------------------------------
+// showDidYouKnowDialog
+//---------------------------------------------------------
+void MusE::showDidYouKnowDialog()
+ {
+ if ((bool)config.showDidYouKnow == true) {
+ printf("show did you know dialog!!!!\n");
+ DidYouKnow dyk;
+ dyk.tipText->setText("To get started with MusE why don't you try some demo songs available at http://demos.muse-sequencer.org/");
+ dyk.show();
+ if( dyk.exec()) {
+ if (dyk.dontShowCheckBox->isChecked()) {
+ printf("disables dialog!\n");
+ config.showDidYouKnow=false;
+ muse->changeConfig(true); // save settings
+ }
+ }
+ }
+ }
+//---------------------------------------------------------
+// startDefineController
+//---------------------------------------------------------
+
+
+//---------------------------------------------------------
+// startClipList
+//---------------------------------------------------------
+
+void MusE::startClipList()
+ {
+ if (clipListEdit == 0) {
+ clipListEdit = new ClipListEdit();
+ toplevels.push_back(Toplevel(Toplevel::CLIPLIST, (unsigned long)(clipListEdit), clipListEdit));
+ connect(clipListEdit, SIGNAL(deleted(unsigned long)), SLOT(toplevelDeleted(unsigned long)));
+ }
+ clipListEdit->show();
+ menu_audio->setItemChecked(aid2, true);
+ }
+
+//---------------------------------------------------------
+// fileMenu
+//---------------------------------------------------------
+
+void MusE::openRecentMenu()
+ {
+ openRecent->clear();
+ for (int i = 0; i < PROJECT_LIST_LEN; ++i) {
+ if (projectList[i] == 0)
+ break;
+ const char* path = projectList[i]->latin1();
+ const char* p = strrchr(path, '/');
+ if (p == 0)
+ p = path;
+ else
+ ++p;
+ openRecent->insertItem(QString(p), i);
+ }
+ }
+
+//---------------------------------------------------------
+// selectProject
+//---------------------------------------------------------
+
+void MusE::selectProject(int id)
+ {
+ if (id < 0)
+ return;
+ assert(id < PROJECT_LIST_LEN);
+ QString* name = projectList[id];
+ if (name == 0)
+ return;
+ loadProjectFile(*name, false, true);
+ }
+
+//---------------------------------------------------------
+// toplevelDeleted
+//---------------------------------------------------------
+
+void MusE::toplevelDeleted(unsigned long tl)
+ {
+ for (iToplevel i = toplevels.begin(); i != toplevels.end(); ++i) {
+ if (i->object() == tl) {
+ switch(i->type()) {
+ case Toplevel::MARKER:
+ break;
+ case Toplevel::CLIPLIST:
+ menu_audio->setItemChecked(aid2, false);
+ return;
+ // the followin editors can exist in more than
+ // one instantiation:
+ case Toplevel::PIANO_ROLL:
+ case Toplevel::LISTE:
+ case Toplevel::DRUM:
+ case Toplevel::MASTER:
+ case Toplevel::WAVE:
+ case Toplevel::LMASTER:
+ break;
+ }
+ toplevels.erase(i);
+ return;
+ }
+ }
+ printf("topLevelDeleted: top level %lx not found\n", tl);
+ //assert(false);
+ }
+
+//---------------------------------------------------------
+// ctrlChanged
+// midi ctrl value changed
+//---------------------------------------------------------
+
+#if 0
+void MusE::ctrlChanged()
+ {
+ arranger->updateInspector();
+ }
+#endif
+
+//---------------------------------------------------------
+// kbAccel
+//---------------------------------------------------------
+
+void MusE::kbAccel(int key)
+ {
+ if (key == shortcuts[SHRT_TOGGLE_METRO].key) {
+ song->setClick(!song->click());
+ }
+ else if (key == shortcuts[SHRT_PLAY_TOGGLE].key) {
+ if (audio->isPlaying())
+ //song->setStopPlay(false);
+ song->setStop(true);
+ else if (!config.useOldStyleStopShortCut)
+ song->setPlay(true);
+ else if (song->cpos() != song->lpos())
+ song->setPos(0, song->lPos());
+ else {
+ Pos p(0, true);
+ song->setPos(0, p);
+ }
+ }
+ else if (key == shortcuts[SHRT_STOP].key) {
+ //song->setPlay(false);
+ song->setStop(true);
+ }
+ else if (key == shortcuts[SHRT_GOTO_START].key) {
+ Pos p(0, true);
+ song->setPos(0, p);
+ }
+ else if (key == shortcuts[SHRT_PLAY_SONG].key ) {
+ song->setPlay(true);
+ }
+ else if (key == shortcuts[SHRT_GOTO_LEFT].key) {
+ if (!song->record())
+ song->setPos(0, song->lPos());
+ }
+ else if (key == shortcuts[SHRT_GOTO_RIGHT].key) {
+ if (!song->record())
+ song->setPos(0, song->rPos());
+ }
+ else if (key == shortcuts[SHRT_TOGGLE_LOOP].key) {
+ song->setLoop(!song->loop());
+ }
+ else if (key == shortcuts[SHRT_START_REC].key) {
+ if (!audio->isPlaying()) {
+ song->setRecord(!song->record());
+ }
+ }
+ else if (key == shortcuts[SHRT_REC_CLEAR].key) {
+ if (!audio->isPlaying()) {
+ song->clearTrackRec();
+ }
+ }
+ else if (key == shortcuts[SHRT_OPEN_TRANSPORT].key) {
+ toggleTransport();
+ }
+ else if (key == shortcuts[SHRT_OPEN_BIGTIME].key) {
+ toggleBigTime();
+ }
+ //else if (key == shortcuts[SHRT_OPEN_MIXER].key) {
+ // toggleMixer();
+ // }
+ else if (key == shortcuts[SHRT_OPEN_MIXER].key) {
+ toggleMixer1();
+ }
+ else if (key == shortcuts[SHRT_OPEN_MIXER2].key) {
+ toggleMixer2();
+ }
+ else if (key == shortcuts[SHRT_NEXT_MARKER].key) {
+ if (markerView)
+ markerView->nextMarker();
+ }
+ else if (key == shortcuts[SHRT_PREV_MARKER].key) {
+ if (markerView)
+ markerView->prevMarker();
+ }
+ else {
+ if (debugMsg)
+ printf("unknown kbAccel 0x%x\n", key);
+ }
+ }
+
+//---------------------------------------------------------
+// MuseApplication
+//---------------------------------------------------------
+
+class MuseApplication : public QApplication {
+ MusE* muse;
+
+ public:
+ MuseApplication(int& argc, char** argv)
+ : QApplication(argc, argv)
+ {
+ muse = 0;
+ }
+
+
+ void setMuse(MusE* m) {
+ muse = m;
+#ifdef HAVE_LASH
+ if(useLASH)
+ startTimer (300);
+#endif
+ }
+
+ bool notify(QObject* receiver, QEvent* event) {
+ bool flag = QApplication::notify(receiver, event);
+ if (event->type() == QEvent::KeyPress) {
+ QKeyEvent* ke = (QKeyEvent*)event;
+ globalKeyState = ke->stateAfter();
+ bool accepted = ke->isAccepted();
+ if (!accepted) {
+ int key = ke->key();
+ if (ke->state() & Qt::ShiftModifier)
+ key += Qt::SHIFT;
+ if (ke->state() & Qt::AltModifier)
+ key += Qt::ALT;
+ if (ke->state() & Qt::ControlModifier)
+ key+= Qt::CTRL;
+ muse->kbAccel(key);
+ return true;
+ }
+ }
+ if (event->type() == QEvent::KeyRelease) {
+ QKeyEvent* ke = (QKeyEvent*)event;
+ globalKeyState = ke->stateAfter();
+ }
+
+ return flag;
+ }
+
+#ifdef HAVE_LASH
+ virtual void timerEvent (QTimerEvent * /* e */) {
+ if(useLASH)
+ muse->lash_idle_cb ();
+ }
+#endif /* HAVE_LASH */
+
+ };
+
+//---------------------------------------------------------
+// usage
+//---------------------------------------------------------
+
+static void usage(const char* prog, const char* txt)
+ {
+ fprintf(stderr, "%s: %s\nusage: %s flags midifile\n Flags:\n",
+ prog, txt, prog);
+ fprintf(stderr, " -h this help\n");
+ fprintf(stderr, " -v print version\n");
+ fprintf(stderr, " -d debug mode: no threads, no RT\n");
+ fprintf(stderr, " -D debug mode: enable some debug messages\n");
+ fprintf(stderr, " -m debug mode: trace midi Input\n");
+ fprintf(stderr, " -M debug mode: trace midi Output\n");
+ fprintf(stderr, " -s debug mode: trace sync\n");
+ fprintf(stderr, " -a no audio\n");
+ //fprintf(stderr, " -P n set real time priority to n (default: 50)\n");
+ fprintf(stderr, " -P n set audio driver real time priority to n (Dummy only, default 40. Else fixed by Jack.)\n");
+ fprintf(stderr, " -Y n force midi real time priority to n (default: audio driver prio +2)\n");
+ fprintf(stderr, " -p don't load LADSPA plugins\n");
+#ifdef ENABLE_PYTHON
+ fprintf(stderr, " -y enable Python control support\n");
+#endif
+#ifdef VST_SUPPORT
+ fprintf(stderr, " -V don't load VST plugins\n");
+#endif
+#ifdef DSSI_SUPPORT
+ fprintf(stderr, " -I don't load DSSI plugins\n");
+#endif
+#ifdef HAVE_LASH
+ fprintf(stderr, " -L don't use LASH\n");
+#endif
+ fprintf(stderr, "useful environment variables:\n");
+ fprintf(stderr, " MUSE override library and shared directories location\n");
+ fprintf(stderr, " MUSEHOME override user home directory (HOME/)\n");
+ fprintf(stderr, " MUSEINSTRUMENTS override user instrument directory (MUSEHOME/muse_instruments)\n");
+ }
+
+//---------------------------------------------------------
+// catchSignal
+// only for debugging
+//---------------------------------------------------------
+
+#if 0
+static void catchSignal(int sig)
+ {
+ if (debugMsg)
+ fprintf(stderr, "MusE: signal %d catched\n", sig);
+ if (sig == SIGSEGV) {
+ fprintf(stderr, "MusE: segmentation fault\n");
+ abort();
+ }
+ if (sig == SIGCHLD) {
+ M_DEBUG("caught SIGCHLD - child died\n");
+ int status;
+ int n = waitpid (-1, &status, WNOHANG);
+ if (n > 0) {
+ fprintf(stderr, "SIGCHLD for unknown process %d received\n", n);
+ }
+ }
+ }
+#endif
+
+//---------------------------------------------------------
+// main
+//---------------------------------------------------------
+
+int main(int argc, char* argv[])
+ {
+
+// error = ErrorHandler::create(argv[0]);
+ ruid = getuid();
+ euid = geteuid();
+ undoSetuid();
+ getCapabilities();
+ int noAudio = false;
+
+ const char* mu = getenv("MUSEHOME");
+ if(mu)
+ museUser = QString(mu);
+ if(museUser.isEmpty())
+ museUser = QString(getenv("HOME"));
+
+ QString museGlobal;
+ const char* p = getenv("MUSE");
+ if (p)
+ museGlobal = p;
+
+ if (museGlobal.isEmpty()) {
+ //QString museGlobal(INSTPREFIX);
+ //QString museGlobalLibDir(INSTLIBDIR);
+ //QString museGlobalLibDir(LIBINSTPREFIX); // This has no prefix.
+ //museGlobalLib = museGlobalLibDir + "/muse";
+ //museGlobalShare = museGlobal + "/share/muse";
+
+ // p4.0.7
+ museGlobalLib = QString(INSTPREFIX) + QString("/") +
+ QString(LIBINSTPREFIX) + QString("/") +
+ QString(INSTALL_NAME);
+ //museGlobalShare = museGlobal + QString("/share/") + QString(INSTALL_NAME);
+ museGlobalShare = QString(INSTPREFIX) + QString("/") +
+ QString(SHAREINSTPREFIX) + QString("/") + // This has no prefix. Default is "share", set in top cmake script.
+ QString(INSTALL_NAME);
+ }
+ else {
+ //museGlobalLib = museGlobal + "/lib";
+ //museGlobalShare = museGlobal + "/share";
+ museGlobalLib = museGlobal + QString("/") + QString(LIBINSTPREFIX); // p4.0.7
+ museGlobalShare = museGlobal + QString("/") + QString(SHAREINSTPREFIX);
+ }
+ museProject = museProjectInitPath; //getcwd(0, 0);
+ configName = QString(getenv("HOME")) + QString("/.MusE");
+
+ museInstruments = museGlobalShare + QString("/instruments");
+
+ const char* ins = getenv("MUSEINSTRUMENTS");
+ if(ins)
+ museUserInstruments = QString(ins);
+ if(museUserInstruments.isEmpty())
+ museUserInstruments = museUser + QString("/muse_instruments");
+
+#ifdef HAVE_LASH
+ lash_args_t * lash_args = 0;
+ if(useLASH)
+ lash_args = lash_extract_args (&argc, &argv);
+#endif
+
+ srand(time(0)); // initialize random number generator
+// signal(SIGCHLD, catchSignal); // interferes with initVST()
+ initMidiController();
+ QApplication::setColorSpec(QApplication::ManyColor);
+ MuseApplication app(argc, argv);
+
+ initShortCuts();
+ readConfiguration();
+
+ if (config.useDenormalBias)
+ printf("Denormal protection enabled.\n");
+ // SHOW MUSE SPLASH SCREEN
+ if (config.showSplashScreen) {
+ QPixmap splsh(museGlobalShare + "/splash.png");
+
+ if (!splsh.isNull()) {
+ QSplashScreen* muse_splash = new QSplashScreen(splsh,
+ Qt::WStyle_StaysOnTop | Qt::WDestructiveClose);
+ muse_splash->show();
+ QTimer* stimer = new QTimer(0);
+ muse_splash->connect(stimer, SIGNAL(timeout()), muse_splash, SLOT(close()));
+ stimer->start(6000, true);
+ }
+ }
+ int i;
+
+ QString optstr("ahvdDmMsP:Y:py");
+#ifdef VST_SUPPORT
+ optstr += QString("V");
+#endif
+#ifdef DSSI_SUPPORT
+ optstr += QString("I");
+#endif
+#ifdef HAVE_LASH
+ optstr += QString("L");
+#endif
+
+//#ifdef VST_SUPPORT
+// while ((i = getopt(argc, argv, "ahvdDmMsVP:py")) != EOF) {
+//#else
+// while ((i = getopt(argc, argv, "ahvdDmMsP:py")) != EOF) {
+//#endif
+
+ while ((i = getopt(argc, argv, optstr.latin1())) != EOF) {
+ char c = (char)i;
+ switch (c) {
+ case 'v': printVersion(argv[0]); return 0;
+ case 'd':
+ debugMode = true;
+ realTimeScheduling = false;
+ break;
+ case 'a':
+ noAudio = true;
+ break;
+ case 'D': debugMsg = true; break;
+ case 'm': midiInputTrace = true; break;
+ case 'M': midiOutputTrace = true; break;
+ case 's': debugSync = true; break;
+ case 'P': realTimePriority = atoi(optarg); break;
+ case 'Y': midiRTPrioOverride = atoi(optarg); break;
+ case 'p': loadPlugins = false; break;
+ case 'V': loadVST = false; break;
+ case 'I': loadDSSI = false; break;
+ case 'L': useLASH = false; break;
+ case 'y': usePythonBridge = true; break;
+ case 'h': usage(argv[0], argv[1]); return -1;
+ default: usage(argv[0], "bad argument"); return -1;
+ }
+ }
+
+ AL::initDsp();
+
+ if (debugMsg)
+ printf("Start euid: %d ruid: %d, Now euid %d\n",
+ euid, ruid, geteuid());
+ if (debugMode) {
+ initDummyAudio();
+ realTimeScheduling = false;
+ }
+ else if (noAudio) {
+ initDummyAudio();
+ realTimeScheduling = true;
+ //if (debugMode) { // ??
+ // realTimeScheduling = false;
+ // }
+ }
+ else if (initJackAudio()) {
+ if (!debugMode)
+ {
+ QMessageBox::critical(NULL, "MusE fatal error", "MusE <b>failed</b> to find a <b>Jack audio server</b>.<br><br>"
+ "<i>MusE will continue without audio support (-a switch)!</i><br><br>"
+ "If this was not intended check that Jack was started. "
+ "If Jack <i>was</i> started check that it was\n"
+ "started as the same user as MusE.\n");
+
+ initDummyAudio();
+ noAudio = true;
+ realTimeScheduling = true;
+ if (debugMode) {
+ realTimeScheduling = false;
+ }
+ }
+ else
+ {
+ fprintf(stderr, "fatal error: no JACK audio server found\n");
+ fprintf(stderr, "no audio functions available\n");
+ fprintf(stderr, "*** experimental mode -- no play possible ***\n");
+ initDummyAudio();
+ //realTimeScheduling = audioDevice->isRealtime();
+ }
+ realTimeScheduling = true;
+ }
+ else
+ realTimeScheduling = audioDevice->isRealtime();
+
+ useJackTransport.setValue(true);
+ // setup the prefetch fifo length now that the segmentSize is known
+ // Changed by Tim. p3.3.17
+ // Changed to 4 *, JUST FOR TEST!!!
+ fifoLength = 131072/segmentSize;
+ //fifoLength = (131072/segmentSize) * 4;
+
+
+ argc -= optind;
+ ++argc;
+
+ if (debugMsg) {
+ printf("global lib: <%s>\n", museGlobalLib.latin1());
+ printf("global share: <%s>\n", museGlobalShare.latin1());
+ printf("muse home: <%s>\n", museUser.latin1());
+ printf("project dir: <%s>\n", museProject.latin1());
+ printf("user instruments: <%s>\n", museUserInstruments.latin1());
+ }
+
+ static QTranslator translator(0);
+ QString locale(QTextCodec::locale());
+ if (locale != "C") {
+ QString loc("muse_");
+ loc += QString(QTextCodec::locale());
+ if (translator.load(loc, QString(".")) == false) {
+ QString lp(museGlobalShare);
+ lp += QString("/locale");
+ if (translator.load(loc, lp) == false) {
+ printf("no locale <%s>/<%s>\n", loc.latin1(), lp.latin1());
+ }
+ }
+ app.installTranslator(&translator);
+ }
+
+ if (locale == "de") {
+ printf("locale de\n");
+ hIsB = false;
+ }
+
+ if (loadPlugins)
+ initPlugins();
+
+ if (loadVST)
+ initVST();
+
+ if(loadDSSI)
+ initDSSI();
+
+ // p3.3.39
+ initOSC();
+
+ initIcons();
+
+ initMetronome();
+ //QApplication::clipboard()->setSelectionMode(false); ddskrjo
+
+ QApplication::addLibraryPath(museGlobalLib + "/qtplugins");
+ if (debugMsg) {
+ QStringList list = app.libraryPaths();
+ QStringList::Iterator it = list.begin();
+ printf("QtLibraryPath:\n");
+ while(it != list.end()) {
+ printf(" <%s>\n", (*it).latin1());
+ ++it;
+ }
+ }
+
+ muse = new MusE(argc, &argv[optind]);
+ app.setMuse(muse);
+ muse->setIcon(*museIcon);
+ // Added by Tim. p3.3.22
+ if (!debugMode) {
+ if (mlockall(MCL_CURRENT | MCL_FUTURE))
+ perror("WARNING: Cannot lock memory:");
+ }
+
+ muse->show();
+ muse->seqStart();
+
+#ifdef HAVE_LASH
+ {
+ if(useLASH)
+ {
+ int lash_flags = LASH_Config_File;
+ const char *muse_name = PACKAGE_NAME;
+ lash_client = lash_init (lash_args, muse_name, lash_flags, LASH_PROTOCOL(2,0));
+ lash_alsa_client_id (lash_client, snd_seq_client_id (alsaSeq));
+ if (!noAudio) {
+ // p3.3.38
+ //char *jack_name = ((JackAudioDevice*)audioDevice)->getJackName();
+ const char *jack_name = audioDevice->clientName();
+ lash_jack_client_name (lash_client, jack_name);
+ }
+ }
+ }
+#endif /* HAVE_LASH */
+ QTimer::singleShot(100, muse, SLOT(showDidYouKnowDialog()));
+
+ return app.exec();
+ // p3.3.47
+ //int rv = app.exec();
+ // FIXME: Can't do, seg fault at MarkerView::~MarkerView()
+ // due to already deleted undoRedo.
+ //delete muse;
+ //return rv;
+
+ }
+
+#if 0
+//---------------------------------------------------------
+// configPart
+//---------------------------------------------------------
+
+void MusE::configPart(int id)
+ {
+ if (id < 3) {
+ partConfig->setItemChecked(0, id == 0);
+ partConfig->setItemChecked(1, id == 1);
+ partConfig->setItemChecked(2, id == 2);
+ arranger->setShowPartType(id);
+ for (int i = 3; i < 10; ++i) {
+ partConfig->setItemEnabled(i, id == 2);
+ }
+ }
+ else {
+ bool flag = !partConfig->isItemChecked(id);
+ partConfig->setItemChecked(id, flag);
+ int val = arranger->showPartEvent();
+ if (flag) {
+ val |= 1 << (id-3);
+ }
+ else {
+ val &= ~(1 << (id-3));
+ }
+ arranger->setShowPartEvent(val);
+ }
+ }
+#endif
+
+//---------------------------------------------------------
+// cmd
+// some cmd's from pulldown menu
+//---------------------------------------------------------
+
+void MusE::cmd(int cmd)
+ {
+ TrackList* tracks = song->tracks();
+ int l = song->lpos();
+ int r = song->rpos();
+
+ switch(cmd) {
+ case CMD_CUT:
+ arranger->cmd(Arranger::CMD_CUT_PART);
+ break;
+ case CMD_COPY:
+ arranger->cmd(Arranger::CMD_COPY_PART);
+ break;
+ case CMD_PASTE:
+ arranger->cmd(Arranger::CMD_PASTE_PART);
+ break;
+ case CMD_PASTE_CLONE:
+ arranger->cmd(Arranger::CMD_PASTE_CLONE_PART);
+ break;
+ case CMD_PASTE_TO_TRACK:
+ arranger->cmd(Arranger::CMD_PASTE_PART_TO_TRACK);
+ break;
+ case CMD_PASTE_CLONE_TO_TRACK:
+ arranger->cmd(Arranger::CMD_PASTE_CLONE_PART_TO_TRACK);
+ break;
+ case CMD_INSERT:
+ arranger->cmd(Arranger::CMD_INSERT_PART);
+ break;
+ case CMD_INSERTMEAS:
+ arranger->cmd(Arranger::CMD_INSERT_EMPTYMEAS);
+ break;
+ case CMD_DELETE:
+ song->startUndo();
+ if (song->msgRemoveParts()) {
+ song->endUndo(SC_PART_REMOVED);
+ break;
+ }
+ else
+ audio->msgRemoveTracks();
+ song->endUndo(SC_TRACK_REMOVED);
+ break;
+ case CMD_DELETE_TRACK:
+ song->startUndo();
+ audio->msgRemoveTracks();
+ song->endUndo(SC_TRACK_REMOVED);
+ audio->msgUpdateSoloStates();
+ break;
+
+ case CMD_SELECT_ALL:
+ case CMD_SELECT_NONE:
+ case CMD_SELECT_INVERT:
+ case CMD_SELECT_ILOOP:
+ case CMD_SELECT_OLOOP:
+ for (iTrack i = tracks->begin(); i != tracks->end(); ++i) {
+ PartList* parts = (*i)->parts();
+ for (iPart p = parts->begin(); p != parts->end(); ++p) {
+ bool f = false;
+ int t1 = p->second->tick();
+ int t2 = t1 + p->second->lenTick();
+ bool inside =
+ ((t1 >= l) && (t1 < r))
+ || ((t2 > l) && (t2 < r))
+ || ((t1 <= l) && (t2 > r));
+ switch(cmd) {
+ case CMD_SELECT_INVERT:
+ f = !p->second->selected();
+ break;
+ case CMD_SELECT_NONE:
+ f = false;
+ break;
+ case CMD_SELECT_ALL:
+ f = true;
+ break;
+ case CMD_SELECT_ILOOP:
+ f = inside;
+ break;
+ case CMD_SELECT_OLOOP:
+ f = !inside;
+ break;
+ }
+ p->second->setSelected(f);
+ }
+ }
+ song->update();
+ break;
+
+ case CMD_SELECT_PARTS:
+ for (iTrack i = tracks->begin(); i != tracks->end(); ++i) {
+ if (!(*i)->selected())
+ continue;
+ PartList* parts = (*i)->parts();
+ for (iPart p = parts->begin(); p != parts->end(); ++p)
+ p->second->setSelected(true);
+ }
+ song->update();
+ break;
+ case CMD_FOLLOW_NO:
+ song->setFollow(Song::NO);
+ setFollow();
+ break;
+ case CMD_FOLLOW_JUMP:
+ song->setFollow(Song::JUMP);
+ setFollow();
+ break;
+ case CMD_FOLLOW_CONTINUOUS:
+ song->setFollow(Song::CONTINUOUS);
+ setFollow();
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// clipboardChanged
+//---------------------------------------------------------
+
+void MusE::clipboardChanged()
+ {
+ Q3CString subtype("partlist");
+ QMimeSource* ms = QApplication::clipboard()->data(QClipboard::Clipboard);
+ if (ms == 0)
+ return;
+ bool flag = false;
+ for (int i = 0; ms->format(i); ++i) {
+// printf("Format <%s\n", ms->format(i));
+ if ((strncmp(ms->format(i), "text/midipartlist", 17) == 0)
+ || (strncmp(ms->format(i), "text/wavepartlist", 17) == 0)
+ // Added by T356. Support mixed .mpt files.
+ || (strncmp(ms->format(i), "text/mixedpartlist", 18) == 0)) {
+ flag = true;
+ break;
+ }
+ }
+ menuEdit->setItemEnabled(CMD_PASTE, flag);
+ menuEdit->setItemEnabled(CMD_INSERT, flag);
+ menuEdit->setItemEnabled(CMD_PASTE_CLONE, flag);
+ menuEdit->setItemEnabled(CMD_PASTE_TO_TRACK, flag);
+ menuEdit->setItemEnabled(CMD_PASTE_CLONE_TO_TRACK, flag);
+ }
+
+//---------------------------------------------------------
+// selectionChanged
+//---------------------------------------------------------
+
+void MusE::selectionChanged()
+ {
+ bool flag = arranger->isSingleSelection();
+ menuEdit->setItemEnabled(CMD_CUT, flag);
+ //menuEdit->setItemEnabled(CMD_COPY, flag); // Now possible
+ }
+
+//---------------------------------------------------------
+// transpose
+//---------------------------------------------------------
+
+void MusE::transpose()
+ {
+ Transpose *w = new Transpose();
+ w->show();
+ }
+
+//---------------------------------------------------------
+// modifyGateTime
+//---------------------------------------------------------
+
+void MusE::modifyGateTime()
+ {
+ GateTime* w = new GateTime(this);
+ w->show();
+ }
+
+//---------------------------------------------------------
+// modifyVelocity
+//---------------------------------------------------------
+
+void MusE::modifyVelocity()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// crescendo
+//---------------------------------------------------------
+
+void MusE::crescendo()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// thinOut
+//---------------------------------------------------------
+
+void MusE::thinOut()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// eraseEvent
+//---------------------------------------------------------
+
+void MusE::eraseEvent()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// noteShift
+//---------------------------------------------------------
+
+void MusE::noteShift()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// moveClock
+//---------------------------------------------------------
+
+void MusE::moveClock()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// copyMeasure
+//---------------------------------------------------------
+
+void MusE::copyMeasure()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// eraseMeasure
+//---------------------------------------------------------
+
+void MusE::eraseMeasure()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// deleteMeasure
+//---------------------------------------------------------
+
+void MusE::deleteMeasure()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// createMeasure
+//---------------------------------------------------------
+
+void MusE::createMeasure()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// mixTrack
+//---------------------------------------------------------
+
+void MusE::mixTrack()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// configAppearance
+//---------------------------------------------------------
+
+void MusE::configAppearance()
+ {
+ if (!appearance)
+ appearance = new Appearance(arranger);
+ appearance->resetValues();
+ if(appearance->isVisible()) {
+ appearance->raise();
+ appearance->setActiveWindow();
+ }
+ else
+ appearance->show();
+ }
+
+//---------------------------------------------------------
+// loadTheme
+//---------------------------------------------------------
+
+void MusE::loadTheme(QString s)
+ {
+ if (style()->name() != s)
+ QApplication::setStyle(s);
+ }
+
+//---------------------------------------------------------
+// configChanged
+// - called whenever configuration has changed
+// - when configuration has changed by user, call with
+// writeFlag=true to save configuration in ~/.MusE
+//---------------------------------------------------------
+
+void MusE::changeConfig(bool writeFlag)
+ {
+ if (writeFlag)
+ writeGlobalConfiguration();
+ loadTheme(config.style);
+ QApplication::setFont(config.fonts[0], true);
+ // Added by Tim. p3.3.6
+ //printf("MusE::changeConfig writeFlag:%d emitting configChanged\n", writeFlag);
+
+ emit configChanged();
+ updateConfiguration();
+ }
+
+//---------------------------------------------------------
+// configMetronome
+//---------------------------------------------------------
+
+void MusE::configMetronome()
+ {
+ if (!metronomeConfig)
+ metronomeConfig = new MetronomeConfig(this, "metronome");
+
+ if(metronomeConfig->isVisible()) {
+ metronomeConfig->raise();
+ metronomeConfig->setActiveWindow();
+ }
+ else
+ metronomeConfig->show();
+ }
+
+
+//---------------------------------------------------------
+// configShortCuts
+//---------------------------------------------------------
+
+void MusE::configShortCuts()
+ {
+ if (!shortcutConfig)
+ shortcutConfig = new ShortcutConfig(this, "shortcutconfig");
+ shortcutConfig->_config_changed = false;
+ if (shortcutConfig->exec())
+ changeConfig(true);
+ }
+
+//---------------------------------------------------------
+// globalCut
+// - remove area between left and right locator
+// - do not touch muted track
+// - cut master track
+//---------------------------------------------------------
+
+void MusE::globalCut()
+ {
+ int lpos = song->lpos();
+ int rpos = song->rpos();
+ if ((lpos - rpos) >= 0)
+ return;
+
+ song->startUndo();
+ TrackList* tracks = song->tracks();
+ for (iTrack it = tracks->begin(); it != tracks->end(); ++it) {
+ MidiTrack* track = dynamic_cast<MidiTrack*>(*it);
+ if (track == 0 || track->mute())
+ continue;
+ PartList* pl = track->parts();
+ for (iPart p = pl->begin(); p != pl->end(); ++p) {
+ Part* part = p->second;
+ int t = part->tick();
+ int l = part->lenTick();
+ if (t + l <= lpos)
+ continue;
+ if ((t >= lpos) && ((t+l) <= rpos)) {
+ audio->msgRemovePart(part, false);
+ }
+ else if ((t < lpos) && ((t+l) > lpos) && ((t+l) <= rpos)) {
+ // remove part tail
+ int len = lpos - t;
+ MidiPart* nPart = new MidiPart(*(MidiPart*)part);
+ nPart->setLenTick(len);
+ //
+ // cut Events in nPart
+ EventList* el = nPart->events();
+ iEvent ie = el->lower_bound(t + len);
+ for (; ie != el->end();) {
+ iEvent i = ie;
+ ++ie;
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgDeleteEvent(i->second, nPart, false);
+ audio->msgDeleteEvent(i->second, nPart, false, false, false);
+ }
+ // Indicate no undo, and do port controller values and clone parts.
+ //audio->msgChangePart(part, nPart, false);
+ audio->msgChangePart(part, nPart, false, true, true);
+ }
+ else if ((t < lpos) && ((t+l) > lpos) && ((t+l) > rpos)) {
+ //----------------------
+ // remove part middle
+ //----------------------
+
+ MidiPart* nPart = new MidiPart(*(MidiPart*)part);
+ EventList* el = nPart->events();
+ iEvent is = el->lower_bound(lpos);
+ iEvent ie = el->upper_bound(rpos);
+ for (iEvent i = is; i != ie;) {
+ iEvent ii = i;
+ ++i;
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgDeleteEvent(ii->second, nPart, false);
+ audio->msgDeleteEvent(ii->second, nPart, false, false, false);
+ }
+
+ ie = el->lower_bound(rpos);
+ for (; ie != el->end();) {
+ iEvent i = ie;
+ ++ie;
+ Event event = i->second;
+ Event nEvent = event.clone();
+ nEvent.setTick(nEvent.tick() - (rpos-lpos));
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(event, nEvent, nPart, false);
+ audio->msgChangeEvent(event, nEvent, nPart, false, false, false);
+ }
+ nPart->setLenTick(l - (rpos-lpos));
+ // Indicate no undo, and do port controller values and clone parts.
+ //audio->msgChangePart(part, nPart, false);
+ audio->msgChangePart(part, nPart, false, true, true);
+ }
+ else if ((t >= lpos) && (t < rpos) && (t+l) > rpos) {
+ // TODO: remove part head
+ }
+ else if (t >= rpos) {
+ MidiPart* nPart = new MidiPart(*(MidiPart*)part);
+ int nt = part->tick();
+ nPart->setTick(nt - (rpos -lpos));
+ // Indicate no undo, and do port controller values but not clone parts.
+ //audio->msgChangePart(part, nPart, false);
+ audio->msgChangePart(part, nPart, false, true, false);
+ }
+ }
+ }
+ // TODO: cut tempo track
+ // TODO: process marker
+ song->endUndo(SC_TRACK_MODIFIED | SC_PART_MODIFIED | SC_PART_REMOVED);
+ }
+
+//---------------------------------------------------------
+// globalInsert
+// - insert empty space at left locator position upto
+// right locator
+// - do not touch muted track
+// - insert in master track
+//---------------------------------------------------------
+
+void MusE::globalInsert()
+ {
+ unsigned lpos = song->lpos();
+ unsigned rpos = song->rpos();
+ if (lpos >= rpos)
+ return;
+
+ song->startUndo();
+ TrackList* tracks = song->tracks();
+ for (iTrack it = tracks->begin(); it != tracks->end(); ++it) {
+ MidiTrack* track = dynamic_cast<MidiTrack*>(*it);
+ //
+ // process only non muted midi tracks
+ //
+ if (track == 0 || track->mute())
+ continue;
+ PartList* pl = track->parts();
+ for (iPart p = pl->begin(); p != pl->end(); ++p) {
+ Part* part = p->second;
+ unsigned t = part->tick();
+ int l = part->lenTick();
+ if (t + l <= lpos)
+ continue;
+ if (lpos >= t && lpos < (t+l)) {
+ MidiPart* nPart = new MidiPart(*(MidiPart*)part);
+ nPart->setLenTick(l + (rpos-lpos));
+ EventList* el = nPart->events();
+
+ iEvent i = el->end();
+ while (i != el->begin()) {
+ --i;
+ if (i->first < lpos)
+ break;
+ Event event = i->second;
+ Event nEvent = i->second.clone();
+ nEvent.setTick(nEvent.tick() + (rpos-lpos));
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(event, nEvent, nPart, false);
+ audio->msgChangeEvent(event, nEvent, nPart, false, false, false);
+ }
+ // Indicate no undo, and do port controller values and clone parts.
+ //audio->msgChangePart(part, nPart, false);
+ audio->msgChangePart(part, nPart, false, true, true);
+ }
+ else if (t > lpos) {
+ MidiPart* nPart = new MidiPart(*(MidiPart*)part);
+ nPart->setTick(t + (rpos -lpos));
+ // Indicate no undo, and do port controller values but not clone parts.
+ //audio->msgChangePart(part, nPart, false);
+ audio->msgChangePart(part, nPart, false, true, false);
+ }
+ }
+ }
+ // TODO: process tempo track
+ // TODO: process marker
+ song->endUndo(SC_TRACK_MODIFIED | SC_PART_MODIFIED | SC_PART_REMOVED);
+ }
+
+//---------------------------------------------------------
+// globalSplit
+// - split all parts at the song position pointer
+// - do not touch muted track
+//---------------------------------------------------------
+
+void MusE::globalSplit()
+ {
+ int pos = song->cpos();
+ song->startUndo();
+ TrackList* tracks = song->tracks();
+ for (iTrack it = tracks->begin(); it != tracks->end(); ++it) {
+ Track* track = *it;
+ PartList* pl = track->parts();
+ for (iPart p = pl->begin(); p != pl->end(); ++p) {
+ Part* part = p->second;
+ int p1 = part->tick();
+ int l0 = part->lenTick();
+ if (pos > p1 && pos < (p1+l0)) {
+ Part* p1;
+ Part* p2;
+ track->splitPart(part, pos, p1, p2);
+ // Indicate no undo, and do port controller values but not clone parts.
+ //audio->msgChangePart(part, p1, false);
+ audio->msgChangePart(part, p1, false, true, false);
+ audio->msgAddPart(p2, false);
+ break;
+ }
+ }
+ }
+ song->endUndo(SC_TRACK_MODIFIED | SC_PART_MODIFIED | SC_PART_INSERTED);
+ }
+
+//---------------------------------------------------------
+// copyRange
+// - copy space between left and right locator position
+// to song position pointer
+// - dont process muted tracks
+// - create a new part for every track containing the
+// copied events
+//---------------------------------------------------------
+
+void MusE::copyRange()
+ {
+ QMessageBox::critical(this,
+ tr("MusE: Copy Range"),
+ tr("not implemented")
+ );
+ }
+
+//---------------------------------------------------------
+// cutEvents
+// - make sure that all events in a part end where the
+// part ends
+// - process only marked parts
+//---------------------------------------------------------
+
+void MusE::cutEvents()
+ {
+ QMessageBox::critical(this,
+ tr("MusE: Cut Events"),
+ tr("not implemented")
+ );
+ }
+
+//---------------------------------------------------------
+// checkRegionNotNull
+// return true if (rPos - lPos) <= 0
+//---------------------------------------------------------
+
+bool MusE::checkRegionNotNull()
+ {
+ int start = song->lPos().frame();
+ int end = song->rPos().frame();
+ if (end - start <= 0) {
+ QMessageBox::critical(this,
+ tr("MusE: Bounce"),
+ tr("set left/right marker for bounce range")
+ );
+ return true;
+ }
+ return false;
+ }
+
+#if 0
+//---------------------------------------------------------
+// openAudioFileManagement
+//---------------------------------------------------------
+void MusE::openAudioFileManagement()
+ {
+ if (!audioFileManager) {
+ audioFileManager = new AudioFileManager(this, "audiofilemanager", false);
+ audioFileManager->show();
+ }
+ audioFileManager->setShown(true);
+ }
+#endif
+//---------------------------------------------------------
+// bounceToTrack
+//---------------------------------------------------------
+
+void MusE::bounceToTrack()
+ {
+ if(audio->bounce())
+ return;
+
+ song->bounceOutput = 0;
+
+ if(song->waves()->empty())
+ {
+ QMessageBox::critical(this,
+ tr("MusE: Bounce to Track"),
+ tr("No wave tracks found")
+ );
+ return;
+ }
+
+ OutputList* ol = song->outputs();
+ if(ol->empty())
+ {
+ QMessageBox::critical(this,
+ tr("MusE: Bounce to Track"),
+ tr("No audio output tracks found")
+ );
+ return;
+ }
+
+ if(checkRegionNotNull())
+ return;
+
+ AudioOutput* out = 0;
+ // If only one output, pick it, else pick the first selected.
+ if(ol->size() == 1)
+ out = ol->front();
+ else
+ {
+ for(iAudioOutput iao = ol->begin(); iao != ol->end(); ++iao)
+ {
+ AudioOutput* o = *iao;
+ if(o->selected())
+ {
+ if(out)
+ {
+ out = 0;
+ break;
+ }
+ out = o;
+ }
+ }
+ if(!out)
+ {
+ QMessageBox::critical(this,
+ tr("MusE: Bounce to Track"),
+ tr("Select one audio output track,\nand one target wave track")
+ );
+ return;
+ }
+ }
+
+ // search target track
+ TrackList* tl = song->tracks();
+ WaveTrack* track = 0;
+
+ for (iTrack it = tl->begin(); it != tl->end(); ++it) {
+ Track* t = *it;
+ if (t->selected()) {
+ if(t->type() != Track::WAVE && t->type() != Track::AUDIO_OUTPUT) {
+ track = 0;
+ break;
+ }
+ if(t->type() == Track::WAVE)
+ {
+ if(track)
+ {
+ track = 0;
+ break;
+ }
+ track = (WaveTrack*)t;
+ }
+
+ }
+ }
+
+ if (track == 0) {
+ if(ol->size() == 1) {
+ QMessageBox::critical(this,
+ tr("MusE: Bounce to Track"),
+ tr("Select one target wave track")
+ );
+ return;
+ }
+ else
+ {
+ QMessageBox::critical(this,
+ tr("MusE: Bounce to Track"),
+ tr("Select one target wave track,\nand one audio output track")
+ );
+ return;
+ }
+ }
+ song->bounceOutput = out;
+ song->bounceTrack = track;
+ song->setRecord(true);
+ song->setRecordFlag(track, true);
+ audio->msgBounce();
+ }
+
+//---------------------------------------------------------
+// bounceToFile
+//---------------------------------------------------------
+
+void MusE::bounceToFile(AudioOutput* ao)
+ {
+ if(audio->bounce())
+ return;
+ song->bounceOutput = 0;
+ if(!ao)
+ {
+ OutputList* ol = song->outputs();
+ if(ol->empty())
+ {
+ QMessageBox::critical(this,
+ tr("MusE: Bounce to Track"),
+ tr("No audio output tracks found")
+ );
+ return;
+ }
+ // If only one output, pick it, else pick the first selected.
+ if(ol->size() == 1)
+ ao = ol->front();
+ else
+ {
+ for(iAudioOutput iao = ol->begin(); iao != ol->end(); ++iao)
+ {
+ AudioOutput* o = *iao;
+ if(o->selected())
+ {
+ if(ao)
+ {
+ ao = 0;
+ break;
+ }
+ ao = o;
+ }
+ }
+ if (ao == 0) {
+ QMessageBox::critical(this,
+ tr("MusE: Bounce to File"),
+ tr("Select one audio output track")
+ );
+ return;
+ }
+ }
+ }
+
+ if (checkRegionNotNull())
+ return;
+
+ SndFile* sf = getSndFile(0, this, 0);
+ if (sf == 0)
+ return;
+
+ song->bounceOutput = ao;
+ ao->setRecFile(sf);
+ song->setRecord(true, false);
+ song->setRecordFlag(ao, true);
+ audio->msgBounce();
+ }
+
+#ifdef HAVE_LASH
+//---------------------------------------------------------
+// lash_idle_cb
+//---------------------------------------------------------
+#include <iostream>
+void
+MusE::lash_idle_cb ()
+{
+ lash_event_t * event;
+ if (!lash_client)
+ return;
+
+ while ( (event = lash_get_event (lash_client)) )
+ {
+ switch (lash_event_get_type (event))
+ {
+ case LASH_Save_File:
+ {
+ /* save file */
+ QString ss = QString(lash_event_get_string(event)) + QString("/lash-project-muse.med");
+ int ok = save (ss.ascii(), false);
+ if (ok) {
+ project.setFile(ss.ascii());
+ setCaption(tr("MusE: Song: ") + project.baseName(true));
+ addProject(ss.ascii());
+ museProject = QFileInfo(ss.ascii()).dirPath(true);
+ }
+ lash_send_event (lash_client, event);
+ }
+ break;
+
+ case LASH_Restore_File:
+ {
+ /* load file */
+ QString sr = QString(lash_event_get_string(event)) + QString("/lash-project-muse.med");
+ loadProjectFile(sr.ascii(), false, true);
+ lash_send_event (lash_client, event);
+ }
+ break;
+
+ case LASH_Quit:
+ {
+ /* quit muse */
+ std::cout << "MusE::lash_idle_cb Received LASH_Quit"
+ << std::endl;
+ lash_event_destroy (event);
+ }
+ break;
+
+ default:
+ {
+ std::cout << "MusE::lash_idle_cb Received unknown LASH event of type "
+ << lash_event_get_type (event)
+ << std::endl;
+ lash_event_destroy (event);
+ }
+ break;
+ }
+ }
+}
+#endif /* HAVE_LASH */
+
+//---------------------------------------------------------
+// clearSong
+// return true if operation aborted
+// called with sequencer stopped
+//---------------------------------------------------------
+
+bool MusE::clearSong()
+ {
+ if (song->dirty) {
+ int n = 0;
+ n = QMessageBox::warning(this, appName,
+ tr("The current Project contains unsaved data\n"
+ "Load overwrites current Project:\n"
+ "Save Current Project?"),
+ tr("&Save"), tr("&Skip"), tr("&Abort"), 0, 2);
+ switch (n) {
+ case 0:
+ if (!save()) // abort if save failed
+ return true;
+ break;
+ case 1:
+ break;
+ case 2:
+ return true;
+ default:
+ printf("InternalError: gibt %d\n", n);
+ }
+ }
+ if (audio->isPlaying()) {
+ audio->msgPlay(false);
+ while (audio->isPlaying())
+ qApp->processEvents();
+ }
+
+again:
+ for (iToplevel i = toplevels.begin(); i != toplevels.end(); ++i) {
+ Toplevel tl = *i;
+ unsigned long obj = tl.object();
+ switch (tl.type()) {
+ case Toplevel::CLIPLIST:
+ case Toplevel::MARKER:
+ break;
+ case Toplevel::PIANO_ROLL:
+ case Toplevel::LISTE:
+ case Toplevel::DRUM:
+ case Toplevel::MASTER:
+ case Toplevel::WAVE:
+ case Toplevel::LMASTER:
+ ((QWidget*)(obj))->close(true);
+ goto again;
+ }
+ }
+ song->clear(false);
+ return false;
+ }
+
+//---------------------------------------------------------
+// startEditInstrument
+//---------------------------------------------------------
+
+void MusE::startEditInstrument()
+ {
+ if(editInstrument == 0)
+ {
+ editInstrument = new EditInstrument(this);
+ editInstrument->show();
+ }
+ else
+ {
+ if(editInstrument->isShown())
+ editInstrument->hide();
+ else
+ editInstrument->show();
+ }
+
+ }
+
+//---------------------------------------------------------
+// switchMixerAutomation
+//---------------------------------------------------------
+
+void MusE::switchMixerAutomation()
+ {
+ automation = !automation;
+ // Clear all pressed and touched and rec event lists.
+ song->clearRecAutomation(true);
+
+printf("automation = %d\n", automation);
+ menuAutomation->setItemChecked(autoId, automation);
+ }
+
+//---------------------------------------------------------
+// clearAutomation
+//---------------------------------------------------------
+
+void MusE::clearAutomation()
+ {
+ printf("not implemented\n");
+ }
+
+//---------------------------------------------------------
+// takeAutomationSnapshot
+//---------------------------------------------------------
+
+void MusE::takeAutomationSnapshot()
+ {
+ int frame = song->cPos().frame();
+ TrackList* tracks = song->tracks();
+ for (iTrack i = tracks->begin(); i != tracks->end(); ++i) {
+ if ((*i)->isMidiTrack())
+ continue;
+ AudioTrack* track = (AudioTrack*)*i;
+ CtrlListList* cll = track->controller();
+ for (iCtrlList icl = cll->begin(); icl != cll->end(); ++icl) {
+ double val = icl->second->curVal();
+ icl->second->add(frame, val);
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// updateConfiguration
+// called whenever the configuration has changed
+//---------------------------------------------------------
+
+void MusE::updateConfiguration()
+ {
+ fileOpenAction->setAccel(shortcuts[SHRT_OPEN].key);
+ fileNewAction->setAccel(shortcuts[SHRT_NEW].key);
+ fileSaveAction->setAccel(shortcuts[SHRT_SAVE].key);
+
+ menu_file->setAccel(shortcuts[SHRT_OPEN_RECENT].key, menu_ids[CMD_OPEN_RECENT]);
+ menu_file->setAccel(shortcuts[SHRT_LOAD_TEMPLATE].key, menu_ids[CMD_LOAD_TEMPLATE]);
+ menu_file->setAccel(shortcuts[SHRT_SAVE_AS].key, menu_ids[CMD_SAVE_AS]);
+ menu_file->setAccel(shortcuts[SHRT_IMPORT_MIDI].key, menu_ids[CMD_IMPORT_MIDI]);
+ menu_file->setAccel(shortcuts[SHRT_EXPORT_MIDI].key, menu_ids[CMD_EXPORT_MIDI]);
+ menu_file->setAccel(shortcuts[SHRT_IMPORT_PART].key, menu_ids[CMD_IMPORT_PART]);
+ menu_file->setAccel(shortcuts[SHRT_IMPORT_AUDIO].key, menu_ids[CMD_IMPORT_AUDIO]);
+ menu_file->setAccel(shortcuts[SHRT_QUIT].key, menu_ids[CMD_QUIT]);
+
+ menuEdit->setAccel(Qt::Key_Delete, CMD_DELETE);
+ menuEdit->setAccel(shortcuts[SHRT_OPEN_DRUMS].key, menu_ids[CMD_OPEN_DRUMS]);
+ menuEdit->setAccel(shortcuts[SHRT_OPEN_LIST].key, menu_ids[CMD_OPEN_LIST]);
+ menuEdit->setAccel(shortcuts[SHRT_OPEN_WAVE].key, menu_ids[CMD_OPEN_WAVE]);
+ menuEdit->setAccel(shortcuts[SHRT_OPEN_MIDI_TRANSFORM].key, menu_ids[CMD_OPEN_MIDI_TRANSFORM]);
+
+ midiEdit->setAccel(shortcuts[SHRT_TRANSPOSE].key, menu_ids[CMD_TRANSPOSE]);
+
+ master->setAccel(shortcuts[SHRT_OPEN_GRAPHIC_MASTER].key, menu_ids[CMD_OPEN_GRAPHIC_MASTER]);
+ master->setAccel(shortcuts[SHRT_OPEN_LIST_MASTER].key, menu_ids[CMD_OPEN_LIST_MASTER]);
+
+ menuStructure->setAccel(shortcuts[SHRT_GLOBAL_CUT].key, menu_ids[CMD_GLOBAL_CUT]);
+ menuStructure->setAccel(shortcuts[SHRT_GLOBAL_INSERT].key, menu_ids[CMD_GLOBAL_INSERT]);
+ menuStructure->setAccel(shortcuts[SHRT_GLOBAL_SPLIT].key, menu_ids[CMD_GLOBAL_SPLIT]);
+ menuStructure->setAccel(shortcuts[SHRT_COPY_RANGE].key, menu_ids[CMD_COPY_RANGE]);
+ menuStructure->setAccel(shortcuts[SHRT_CUT_EVENTS].key, menu_ids[CMD_CUT_EVENTS]);
+
+ menuView->setAccel(shortcuts[SHRT_OPEN_TRANSPORT].key, tr_id);
+ menuView->setAccel(shortcuts[SHRT_OPEN_BIGTIME].key, bt_id);
+ //menuView->setAccel(shortcuts[SHRT_OPEN_MIXER].key, aid1);
+ menuView->setAccel(shortcuts[SHRT_OPEN_MIXER].key, aid1a);
+ menuView->setAccel(shortcuts[SHRT_OPEN_MIXER2].key, aid1b);
+// menuView->setAccel(shortcuts[SHRT_OPEN_CLIPS].key, aid2);
+// markerAction->setAccel(shortcuts[SHRT_OPEN_MARKER].key );
+ menuView->setAccel(shortcuts[SHRT_OPEN_MARKER].key, mr_id );
+
+ menuSettings->setAccel(shortcuts[SHRT_GLOBAL_CONFIG].key, menu_ids[CMD_GLOBAL_CONFIG]);
+ menuSettings->setAccel(shortcuts[SHRT_CONFIG_SHORTCUTS].key, menu_ids[CMD_CONFIG_SHORTCUTS]);
+ menuSettings->setAccel(shortcuts[SHRT_CONFIG_METRONOME].key, menu_ids[CMD_CONFIG_METRONOME]);
+ menuSettings->setAccel(shortcuts[SHRT_CONFIG_MIDISYNC].key, menu_ids[CMD_CONFIG_MIDISYNC]);
+ menuSettings->setAccel(shortcuts[SHRT_APPEARANCE_SETTINGS].key, menu_ids[CMD_APPEARANCE_SETTINGS]);
+ menuSettings->setAccel(shortcuts[SHRT_CONFIG_MIDI_PORTS].key, menu_ids[CMD_CONFIG_MIDI_PORTS]);
+ menuSettings->setAccel(shortcuts[SHRT_CONFIG_AUDIO_PORTS].key, menu_ids[CMD_CONFIG_AUDIO_PORTS]);
+
+// menu_functions->setAccel(shortcuts[SHRT_MIDI_EDIT_INSTRUMENTS].key, menu_ids[CMD_MIDI_EDIT_INSTRUMENTS]);
+ menu_functions->setAccel(shortcuts[SHRT_MIDI_RESET].key, menu_ids[CMD_MIDI_RESET]);
+ menu_functions->setAccel(shortcuts[SHRT_MIDI_INIT].key, menu_ids[CMD_MIDI_INIT]);
+ menu_functions->setAccel(shortcuts[SHRT_MIDI_LOCAL_OFF].key, menu_ids[CMD_MIDI_LOCAL_OFF]);
+
+ menu_audio->setAccel(shortcuts[SHRT_AUDIO_BOUNCE_TO_TRACK].key, menu_ids[CMD_AUDIO_BOUNCE_TO_TRACK]);
+ menu_audio->setAccel(shortcuts[SHRT_AUDIO_BOUNCE_TO_FILE].key , menu_ids[CMD_AUDIO_BOUNCE_TO_FILE]);
+ menu_audio->setAccel(shortcuts[SHRT_AUDIO_RESTART].key, menu_ids[CMD_AUDIO_RESTART]);
+
+ menuAutomation->setAccel(shortcuts[SHRT_MIXER_AUTOMATION].key, autoId);
+ menuAutomation->setAccel(shortcuts[SHRT_MIXER_SNAPSHOT].key, menu_ids[CMD_MIXER_SNAPSHOT]);
+ menuAutomation->setAccel(shortcuts[SHRT_MIXER_AUTOMATION_CLEAR].key, menu_ids[CMD_MIXER_AUTOMATION_CLEAR]);
+
+ menu_help->setAccel(menu_ids[CMD_OPEN_HELP], shortcuts[SHRT_OPEN_HELP].key);
+ menu_help->setAccel(menu_ids[CMD_START_WHATSTHIS], shortcuts[SHRT_START_WHATSTHIS].key);
+ pianoAction->setAccel(shortcuts[SHRT_OPEN_PIANO].key);
+
+ select->setAccel(shortcuts[SHRT_SELECT_ALL].key, CMD_SELECT_ALL);
+
+// select->setAccel(shortcuts[SHRT_DESEL_PARTS].key, CMD_SELECT_NONE);
+ select->setAccel(shortcuts[SHRT_SELECT_NONE].key, CMD_SELECT_NONE);
+
+ select->setAccel(shortcuts[SHRT_SELECT_INVERT].key, CMD_SELECT_INVERT);
+ select->setAccel(shortcuts[SHRT_SELECT_ILOOP].key, CMD_SELECT_ILOOP);
+ select->setAccel(shortcuts[SHRT_SELECT_OLOOP].key, CMD_SELECT_OLOOP);
+ select->setAccel(shortcuts[SHRT_SELECT_PRTSTRACK].key, CMD_SELECT_PARTS);
+ follow->setAccel(shortcuts[SHRT_FOLLOW_JUMP].key, CMD_FOLLOW_JUMP);
+ follow->setAccel(shortcuts[SHRT_FOLLOW_NO].key, CMD_FOLLOW_NO);
+ follow->setAccel(shortcuts[SHRT_FOLLOW_CONTINUOUS].key, CMD_FOLLOW_CONTINUOUS);
+ midiInputPlugins->setAccel(shortcuts[SHRT_MIDI_INPUT_TRANSPOSE].key, 0);
+ midiInputPlugins->setAccel(shortcuts[SHRT_MIDI_INPUT_TRANSFORM].key, 1);
+ midiInputPlugins->setAccel(shortcuts[SHRT_MIDI_INPUT_FILTER].key, 2);
+ midiInputPlugins->setAccel(shortcuts[SHRT_MIDI_REMOTE_CONTROL].key, 3);
+ midiInputPlugins->setAccel(shortcuts[SHRT_RANDOM_RHYTHM_GENERATOR].key, 4);
+
+ addTrack->setAccel(shortcuts[SHRT_ADD_MIDI_TRACK].key, Track::MIDI);
+ addTrack->setAccel(shortcuts[SHRT_ADD_DRUM_TRACK].key, Track::DRUM);
+ addTrack->setAccel(shortcuts[SHRT_ADD_WAVE_TRACK].key, Track::WAVE);
+ addTrack->setAccel(shortcuts[SHRT_ADD_AUDIO_OUTPUT].key, Track::AUDIO_OUTPUT);
+ addTrack->setAccel(shortcuts[SHRT_ADD_AUDIO_GROUP].key, Track::AUDIO_GROUP);
+ addTrack->setAccel(shortcuts[SHRT_ADD_AUDIO_INPUT].key, Track::AUDIO_INPUT);
+ addTrack->setAccel(shortcuts[SHRT_ADD_AUDIO_AUX].key, Track::AUDIO_AUX);
+ }
+
+//---------------------------------------------------------
+// showBigtime
+//---------------------------------------------------------
+
+void MusE::showBigtime(bool on)
+ {
+ if (on && bigtime == 0) {
+ bigtime = new BigTime(0);
+ bigtime->setPos(0, song->cpos(), false);
+ connect(song, SIGNAL(posChanged(int, unsigned, bool)), bigtime, SLOT(setPos(int, unsigned, bool)));
+ connect(muse, SIGNAL(configChanged()), bigtime, SLOT(configChanged()));
+ connect(bigtime, SIGNAL(closed()), SLOT(bigtimeClosed()));
+ bigtime->resize(config.geometryBigTime.size());
+ bigtime->move(config.geometryBigTime.topLeft());
+ }
+ if (bigtime)
+ bigtime->setShown(on);
+ menuView->setItemChecked(bt_id, on);
+ }
+
+//---------------------------------------------------------
+// toggleBigTime
+//---------------------------------------------------------
+
+void MusE::toggleBigTime()
+ {
+ showBigtime(!menuView->isItemChecked(bt_id));
+ }
+
+//---------------------------------------------------------
+// bigtimeClosed
+//---------------------------------------------------------
+
+void MusE::bigtimeClosed()
+ {
+ menuView->setItemChecked(bt_id, false);
+ }
+
+//---------------------------------------------------------
+// showMixer
+//---------------------------------------------------------
+
+/*
+void MusE::showMixer(bool on)
+ {
+ if (on && audioMixer == 0) {
+ audioMixer = new AudioMixerApp(this);
+ connect(audioMixer, SIGNAL(closed()), SLOT(mixerClosed()));
+ audioMixer->resize(config.geometryMixer.size());
+ audioMixer->move(config.geometryMixer.topLeft());
+ }
+ if (audioMixer)
+ audioMixer->setShown(on);
+ menuView->setItemChecked(aid1, on);
+ }
+*/
+
+//---------------------------------------------------------
+// showMixer1
+//---------------------------------------------------------
+
+void MusE::showMixer1(bool on)
+ {
+ if (on && mixer1 == 0) {
+ mixer1 = new AudioMixerApp(this, &(config.mixer1));
+ connect(mixer1, SIGNAL(closed()), SLOT(mixer1Closed()));
+ mixer1->resize(config.mixer1.geometry.size());
+ mixer1->move(config.mixer1.geometry.topLeft());
+ }
+ if (mixer1)
+ mixer1->setShown(on);
+ menuView->setItemChecked(aid1a, on);
+ }
+
+//---------------------------------------------------------
+// showMixer2
+//---------------------------------------------------------
+
+void MusE::showMixer2(bool on)
+ {
+ if (on && mixer2 == 0) {
+ mixer2 = new AudioMixerApp(this, &(config.mixer2));
+ connect(mixer2, SIGNAL(closed()), SLOT(mixer2Closed()));
+ mixer2->resize(config.mixer2.geometry.size());
+ mixer2->move(config.mixer2.geometry.topLeft());
+ }
+ if (mixer2)
+ mixer2->setShown(on);
+ menuView->setItemChecked(aid1b, on);
+ }
+
+//---------------------------------------------------------
+// toggleMixer
+//---------------------------------------------------------
+
+/*
+void MusE::toggleMixer()
+ {
+ showMixer(!menuView->isItemChecked(aid1));
+ }
+*/
+
+//---------------------------------------------------------
+// toggleMixer1
+//---------------------------------------------------------
+
+void MusE::toggleMixer1()
+ {
+ printf("toggle mixer1\n");
+ //showMixer1(!menuView->isItemChecked(aid1a));
+ showMixer1(true);
+ }
+
+//---------------------------------------------------------
+// toggleMixer2
+//---------------------------------------------------------
+
+void MusE::toggleMixer2()
+ {
+ showMixer2(!menuView->isItemChecked(aid1b));
+ }
+
+//---------------------------------------------------------
+// mixerClosed
+//---------------------------------------------------------
+
+/*
+void MusE::mixerClosed()
+ {
+ menuView->setItemChecked(aid1, false);
+ }
+*/
+
+//---------------------------------------------------------
+// mixer1Closed
+//---------------------------------------------------------
+
+void MusE::mixer1Closed()
+ {
+ //aid1a->setChecked(false);
+ menuView->setItemChecked(aid1a, false);
+ }
+
+//---------------------------------------------------------
+// mixer2Closed
+//---------------------------------------------------------
+
+void MusE::mixer2Closed()
+ {
+ //aid1b->setChecked(false);
+ menuView->setItemChecked(aid1b, false);
+ }
+
+
+//QWidget* MusE::mixerWindow() { return audioMixer; }
+QWidget* MusE::mixer1Window() { return mixer1; }
+QWidget* MusE::mixer2Window() { return mixer2; }
+
+QWidget* MusE::transportWindow() { return transport; }
+QWidget* MusE::bigtimeWindow() { return bigtime; }
+
+//---------------------------------------------------------
+// focusInEvent
+//---------------------------------------------------------
+
+void MusE::focusInEvent(QFocusEvent* ev)
+ {
+ //if (audioMixer)
+ // audioMixer->raise();
+ if (mixer1)
+ mixer1->raise();
+ if (mixer2)
+ mixer2->raise();
+ raise();
+ Q3MainWindow::focusInEvent(ev);
+ }
+
+//---------------------------------------------------------
+// setUsedTool
+//---------------------------------------------------------
+
+void MusE::setUsedTool(int tool)
+ {
+ tools1->set(tool);
+ }
+
+
+//---------------------------------------------------------
+// execDeliveredScript
+//---------------------------------------------------------
+void MusE::execDeliveredScript(int id)
+{
+ //QString scriptfile = QString(INSTPREFIX) + SCRIPTSSUFFIX + deliveredScriptNames[id];
+ song->executeScript(song->getScriptPath(id, true), song->getSelectedMidiParts(), 0, false); // TODO: get quant from arranger
+}
+//---------------------------------------------------------
+// execUserScript
+//---------------------------------------------------------
+void MusE::execUserScript(int id)
+{
+ song->executeScript(song->getScriptPath(id, false), song->getSelectedMidiParts(), 0, false); // TODO: get quant from arranger
+}
+
diff --git a/attic/muse2-oom/muse2/muse/app.h b/attic/muse2-oom/muse2/muse/app.h
new file mode 100644
index 00000000..013f6efc
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/app.h
@@ -0,0 +1,380 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: app.h,v 1.34.2.14 2009/11/16 11:29:33 lunar_shuttle Exp $
+//
+// (C) Copyright 1999-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __APP_H__
+#define __APP_H__
+
+#include "config.h"
+#include "cobject.h"
+#include "tools.h"
+
+#include <QFileInfo>
+
+class QCloseEvent;
+class QFocusEvent;
+class QMainWindow;
+class QMenu;
+class QPoint;
+class QRect;
+class QScrollArea;
+class QSignalMapper;
+class QString;
+class QToolBar;
+class QToolButton;
+
+class Part;
+class PartList;
+class Transport;
+class BigTime;
+class Arranger;
+class Instrument;
+class PopupMenu;
+class PopupView;
+class Track;
+class PrinterConfig;
+class MidiSyncConfig;
+class MRConfig;
+class MetronomeConfig;
+class AudioConf;
+class Xml;
+class AudioMixerApp;
+class ClipListEdit;
+class AudioRecord;
+class MidiFileConfig;
+class MidiFilterConfig;
+class MarkerView;
+class GlobalSettingsConfig;
+class MidiControllerEditDialog;
+class MidiInputTransformDialog;
+class MidiTransformerDialog;
+class SynthI;
+class RhythmGen;
+class MidiTrack;
+class MidiInstrument;
+class MidiPort;
+class ShortcutConfig;
+class Appearance;
+class WaveTrack;
+class AudioOutput;
+class EditInstrument;
+
+#define MENU_ADD_SYNTH_ID_BASE 0x1000
+
+//---------------------------------------------------------
+// MusE
+//---------------------------------------------------------
+
+class MusE : public QMainWindow
+ {
+ Q_OBJECT
+ enum {CMD_CUT, CMD_COPY, CMD_PASTE, CMD_INSERT, CMD_INSERTMEAS, CMD_PASTE_CLONE,
+ CMD_PASTE_TO_TRACK, CMD_PASTE_CLONE_TO_TRACK, CMD_DELETE,
+ CMD_SELECT_ALL, CMD_SELECT_NONE, CMD_SELECT_INVERT,
+ CMD_SELECT_ILOOP, CMD_SELECT_OLOOP, CMD_SELECT_PARTS,
+ CMD_FOLLOW_NO, CMD_FOLLOW_JUMP, CMD_FOLLOW_CONTINUOUS ,
+ CMD_DELETE_TRACK
+ };
+
+ //File menu items:
+ enum { CMD_OPEN_RECENT=0, CMD_LOAD_TEMPLATE, CMD_SAVE_AS, CMD_IMPORT_MIDI,
+ CMD_EXPORT_MIDI, CMD_IMPORT_PART, CMD_IMPORT_AUDIO, CMD_QUIT, CMD_OPEN_DRUMS, CMD_OPEN_WAVE,
+ CMD_OPEN_LIST, CMD_OPEN_LIST_MASTER, CMD_GLOBAL_CONFIG,
+ CMD_OPEN_GRAPHIC_MASTER, CMD_OPEN_MIDI_TRANSFORM, CMD_TRANSPOSE,
+ CMD_GLOBAL_CUT, CMD_GLOBAL_INSERT, CMD_GLOBAL_SPLIT, CMD_COPY_RANGE,
+ CMD_CUT_EVENTS, CMD_CONFIG_SHORTCUTS, CMD_CONFIG_METRONOME, CMD_CONFIG_MIDISYNC,
+ CMD_MIDI_FILE_CONFIG, CMD_APPEARANCE_SETTINGS, CMD_CONFIG_MIDI_PORTS, CMD_CONFIG_AUDIO_PORTS,
+ CMD_MIDI_EDIT_INSTRUMENTS, CMD_MIDI_RESET, CMD_MIDI_INIT, CMD_MIDI_LOCAL_OFF,
+ CMD_MIXER_SNAPSHOT, CMD_MIXER_AUTOMATION_CLEAR, CMD_OPEN_HELP, CMD_OPEN_HOMEPAGE,
+ CMD_OPEN_BUG, CMD_START_WHATSTHIS,
+ CMD_AUDIO_BOUNCE_TO_FILE, CMD_AUDIO_BOUNCE_TO_TRACK, CMD_AUDIO_RESTART,
+ CMD_LAST };
+
+ //int menu_ids[CMD_LAST];
+
+ // File menu actions
+ QAction *fileSaveAction, *fileOpenAction, *fileNewAction, *testAction;
+ QAction *fileSaveAsAction, *fileImportMidiAction, *fileExportMidiAction, *fileImportPartAction, *fileImportWaveAction, *quitAction;
+
+ // Edit Menu actions
+ QAction *editCutAction, *editCopyAction, *editPasteAction, *editInsertAction, *editPasteCloneAction, *editPaste2TrackAction;
+ QAction *editPasteC2TAction, *editInsertEMAction, *editDeleteSelectedAction, *editSelectAllAction, *editDeselectAllAction;
+ QAction *editInvertSelectionAction, *editInsideLoopAction, *editOutsideLoopAction, *editAllPartsAction;
+ QAction *trackMidiAction, *trackDrumAction, *trackWaveAction, *trackAOutputAction, *trackAGroupAction;
+ QAction *trackAInputAction, *trackAAuxAction;
+ QAction *startPianoEditAction, *startDrumEditAction, *startListEditAction, *startWaveEditAction;
+ QAction *masterGraphicAction, *masterListAction;
+ QAction *midiTransposeAction;
+ QAction *midiTransformerAction;
+ QAction *editSongInfoAction;
+
+ // View Menu actions
+ QAction *viewTransportAction, *viewBigtimeAction, *viewMixerAAction, *viewMixerBAction, *viewCliplistAction, *viewMarkerAction;
+
+ // Structure Menu actions
+ QAction *strGlobalCutAction, *strGlobalInsertAction, *strGlobalSplitAction, *strCopyRangeAction, *strCutEventsAction;
+
+ // Midi Menu Actions
+ QAction *midiEditInstAction, *midiResetInstAction, *midiInitInstActions, *midiLocalOffAction;
+ QAction *midiTrpAction, *midiInputTrfAction, *midiInputFilterAction, *midiRemoteAction;
+#ifdef BUILD_EXPERIMENTAL
+ QAction *midiRhythmAction;
+#endif
+
+ // Audio Menu Actions
+ QAction *audioBounce2TrackAction, *audioBounce2FileAction, *audioRestartAction;
+
+ // Automation Menu Actions
+ QAction *autoMixerAction, *autoSnapshotAction, *autoClearAction;
+
+ // Settings Menu Actions
+ QAction *settingsGlobalAction, *settingsShortcutsAction, *settingsMetronomeAction, *settingsMidiSyncAction;
+ QAction *settingsMidiIOAction, *settingsAppearanceAction, *settingsMidiPortAction;
+ QAction *dontFollowAction, *followPageAction, *followCtsAction;
+
+ // Help Menu Actions
+ QAction *helpManualAction, *helpHomepageAction, *helpReportAction, *helpAboutAction;
+
+ QString appName;
+
+ QFileInfo project;
+ QToolBar *tools;
+ EditToolBar *tools1;
+
+ Transport* transport;
+ BigTime* bigtime;
+ EditInstrument* editInstrument;
+
+ QMenu *menu_file, *menuView, *menuSettings, *menu_help;
+ QMenu *menuEdit, *menuStructure;
+ QMenu* menu_audio, *menuAutomation;
+ QMenu* menu_functions, *menuScriptPlugins;
+ QMenu* select, *master, *midiEdit, *addTrack;
+
+ // Special 'stay-open' menu for routes.
+ PopupMenu* routingPopupMenu;
+ //PopupView* routingPopupView;
+
+
+ QMenu* follow;
+ QMenu* midiInputPlugins;
+
+ QWidget* midiPortConfig;
+ QWidget* softSynthesizerConfig;
+ MidiSyncConfig* midiSyncConfig;
+ MRConfig* midiRemoteConfig;
+ RhythmGen* midiRhythmGenerator;
+ MetronomeConfig* metronomeConfig;
+ AudioConf* audioConfig;
+ MidiFileConfig* midiFileConfig;
+ GlobalSettingsConfig* globalSettingsConfig;
+ MidiFilterConfig* midiFilterConfig;
+ MidiInputTransformDialog* midiInputTransform;
+ ShortcutConfig* shortcutConfig;
+ Appearance* appearance;
+ AudioMixerApp* mixer1;
+ AudioMixerApp* mixer2;
+
+ ToplevelList toplevels;
+ ClipListEdit* clipListEdit;
+ MarkerView* markerView;
+ MidiTransformerDialog* midiTransformerDialog;
+ QMenu* openRecent;
+
+ bool readMidi(FILE*);
+ void read(Xml& xml, bool skipConfig);
+ void processTrack(MidiTrack* track);
+
+ void write(Xml& xml) const;
+ bool clearSong();
+ bool save(const QString&, bool);
+ void setUntitledProject();
+ void setConfigDefaults();
+
+ void setFollow();
+ void readConfigParts(Xml& xml);
+ void readMidiport(Xml& xml);
+ void readMidichannel(Xml& xml, int port);
+ void readCtrl(Xml& xml, int port, int channel);
+ void readToplevels(Xml& xml);
+ PartList* getMidiPartsToEdit();
+ Part* readPart(Xml& xml);
+ bool checkRegionNotNull();
+ void loadProjectFile1(const QString&, bool songTemplate, bool loadAll);
+ void writeGlobalConfiguration(int level, Xml&) const;
+ void writeConfiguration(int level, Xml&) const;
+ void updateConfiguration();
+
+ virtual void focusInEvent(QFocusEvent*);
+ virtual void keyPressEvent(QKeyEvent*); // p4.0.10 Tim.
+
+ QSignalMapper *editSignalMapper;
+ QSignalMapper *midiPluginSignalMapper;
+ QSignalMapper *followSignalMapper;
+
+ signals:
+ void configChanged();
+
+ private slots:
+ //void runPythonScript();
+ void loadProject();
+ bool save();
+ void configGlobalSettings();
+ void quitDoc();
+ void about();
+ void aboutQt();
+ void startHelpBrowser();
+ void startHomepageBrowser();
+ void startBugBrowser();
+ void launchBrowser(QString &whereTo);
+ void importMidi();
+ void importWave();
+ void importPart();
+ void exportMidi();
+
+ void toggleTransport(bool);
+ void toggleMarker(bool);
+ void toggleBigTime(bool);
+ //void toggleMixer();
+ void toggleMixer1(bool);
+ void toggleMixer2(bool);
+
+ void configMidiSync();
+ void configMidiFile();
+ void configShortCuts();
+ void configMetronome();
+ void configAppearance();
+ void startEditor(PartList*, int);
+ void startMasterEditor();
+ void startLMasterEditor();
+ void startListEditor();
+ void startListEditor(PartList*);
+ void startDrumEditor();
+ void startDrumEditor(PartList* /*pl*/, bool /*showDefaultCtrls*/ = false);
+ void startEditor(Track*);
+ void startPianoroll();
+ void startPianoroll(PartList* /*pl*/, bool /*showDefaultCtrls*/ = false);
+ void startWaveEditor();
+ void startWaveEditor(PartList*);
+ void startSongInfo(bool editable=true);
+
+ void startMidiTransformer();
+ void writeGlobalConfiguration() const;
+ void startEditInstrument();
+ void startClipList(bool);
+
+ void openRecentMenu();
+ void selectProject(QAction* act);
+ void cmd(int);
+ void clipboardChanged();
+ void selectionChanged();
+ void transpose();
+ void modifyGateTime();
+ void modifyVelocity();
+ void crescendo();
+ void thinOut();
+ void eraseEvent();
+ void noteShift();
+ void moveClock();
+ void copyMeasure();
+ void eraseMeasure();
+ void deleteMeasure();
+ void createMeasure();
+ void mixTrack();
+ void startMidiInputPlugin(int);
+ void hideMitPluginTranspose();
+ void hideMidiInputTransform();
+ void hideMidiFilterConfig();
+ void hideMidiRemoteConfig();
+#ifdef BUILD_EXPERIMENTAL
+ void hideMidiRhythmGenerator();
+#endif
+ void globalCut();
+ void globalInsert();
+ void globalSplit();
+ void copyRange();
+ void cutEvents();
+ void bounceToTrack();
+ void resetMidiDevices();
+ void initMidiDevices();
+ void localOff();
+ void switchMixerAutomation();
+ void takeAutomationSnapshot();
+ void clearAutomation();
+ void bigtimeClosed();
+ //void mixerClosed();
+ void mixer1Closed();
+ void mixer2Closed();
+ void markerClosed();
+
+ void execDeliveredScript(int);
+ void execUserScript(int);
+
+ public slots:
+ bool saveAs();
+ void bounceToFile(AudioOutput* ao = 0);
+ void closeEvent(QCloseEvent*e);
+ void loadProjectFile(const QString&);
+ void loadProjectFile(const QString&, bool songTemplate, bool loadAll);
+ void toplevelDeleted(unsigned long tl);
+ void loadTheme(const QString&);
+ void loadStyleSheetFile(const QString&);
+ bool seqRestart();
+ void loadTemplate();
+ void showBigtime(bool);
+ //void showMixer(bool);
+ void showMixer1(bool);
+ void showMixer2(bool);
+ void showMarker(bool);
+ void importMidi(const QString &file);
+ void setUsedTool(int);
+ void showDidYouKnowDialog();
+
+ void routingPopupMenuAboutToHide();
+ void configMidiPorts();
+
+ public:
+ MusE(int argc, char** argv);
+ ~MusE();
+ Arranger* arranger;
+ QRect configGeometryMain;
+ bool importMidi(const QString name, bool merge);
+ void kbAccel(int);
+ void changeConfig(bool writeFlag);
+
+ void seqStop();
+ bool seqStart();
+ void setHeartBeat();
+ void importController(int, MidiPort*, int);
+ //QWidget* mixerWindow();
+ QWidget* mixer1Window();
+ QWidget* mixer2Window();
+ QWidget* transportWindow();
+ QWidget* bigtimeWindow();
+ bool importWaveToTrack(QString& name, unsigned tick=0, Track* track=NULL);
+ void importPartToTrack(QString& filename, unsigned tick, Track* track);
+
+ void showTransport(bool flag);
+
+ // Special 'stay-open' menu for routes.
+ PopupMenu* getRoutingPopupMenu();
+ PopupMenu* prepareRoutingPopupMenu(Track* /*track*/, bool /*dst*/);
+ void routingPopupMenuActivated(Track* /*track*/, int /*id*/);
+ void updateRouteMenus(Track* /*track*/, QObject* /*master*/);
+ // Testing...
+ //PopupView* getRoutingPopupView();
+ //PopupView* prepareRoutingPopupView(Track* /*track*/, bool /*dst*/);
+ //void routingPopupViewActivated(Track* /*track*/, int /*id*/);
+
+#ifdef HAVE_LASH
+ void lash_idle_cb ();
+#endif
+ };
+
+extern void addProject(const QString& name);
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/appearance.cpp b/attic/muse2-oom/muse2/muse/appearance.cpp
new file mode 100644
index 00000000..618445ab
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/appearance.cpp
@@ -0,0 +1,1120 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: appearance.cpp,v 1.11.2.5 2009/11/14 03:37:48 terminator356 Exp $
+//=========================================================
+
+#include <QAbstractButton>
+#include <QButtonGroup>
+#include <QColor>
+#include <QFontDialog>
+#include <QStyleFactory>
+#include <QToolTip>
+#include <QByteArray>
+#include <QFile>
+#include <QFileDialog>
+#include <QFileInfo>
+#include <QPainter>
+#include <QtGlobal>
+
+#include "icons.h"
+#include "appearance.h"
+#include "track.h"
+#include "app.h"
+#include "song.h"
+#include "event.h"
+#include "arranger.h"
+#include "widgets/filedialog.h"
+#include "waveedit/waveedit.h"
+#include "globals.h"
+#include "conf.h"
+#include "gconfig.h"
+
+int BG_ITEM_HEIGHT = 30;
+
+class BgPreviewWidget : public QWidget {
+ QPixmap pixmap;
+ QString imagefile;
+ QTreeWidget* t_widget;
+ int text_h;
+ int text_w;
+
+ protected:
+ void paintEvent(QPaintEvent* event)
+ {
+ QPainter p(this);
+ int w = t_widget->width() - 65;
+ p.drawTiledPixmap(1,1,w,BG_ITEM_HEIGHT-2, pixmap);
+
+ const QPalette& pal = palette();
+ QColor dark = pal.dark().color();
+ // We can also draw a rectangle behind the text:
+ //p.fillRect(QRect(w/2 - text_w/2,6,text_w + 20,text_h+4), dark);
+
+ QFontMetrics fm = p.fontMetrics();
+ text_w = fm.width(imagefile);
+ text_h = fm.height();
+
+ // Do the text shadow first
+ p.save();
+ p.setPen(dark);
+ p.drawText(w/2 - text_w/2 + 1, 7, text_w + 20, text_h+4, Qt::AlignCenter, imagefile);
+ p.restore();
+
+ p.drawText(w/2 - text_w/2,6, text_w + 20, text_h+4, Qt::AlignCenter, imagefile);
+ QWidget::paintEvent(event);
+ }
+ public:
+ BgPreviewWidget(QString imagepath, QTreeWidget *treewidget)
+ {
+ pixmap = QPixmap(imagepath);
+ imagefile = imagepath.right(imagepath.length() - imagepath.lastIndexOf("/") - 1 );
+ t_widget = treewidget;
+ }
+ };
+
+//---------------------------------------------------------
+// IdListViewItem
+//---------------------------------------------------------
+
+class IdListViewItem : public QTreeWidgetItem {
+ int _id;
+
+ public:
+ IdListViewItem(int id, QTreeWidgetItem* parent, QString s)
+ : QTreeWidgetItem(parent, QStringList(s))
+ {
+ _id = id;
+ }
+ IdListViewItem(int id, QTreeWidget* parent, QString s)
+ : QTreeWidgetItem(parent, QStringList(s))
+ {
+ _id = id;
+ }
+ int id() const { return _id; }
+ };
+
+//---------------------------------------------------------
+// Appearance
+//---------------------------------------------------------
+
+Appearance::Appearance(Arranger* a, QWidget* parent)
+ : QDialog(parent, Qt::Window)
+ {
+ setupUi(this);
+ arr = a;
+ color = 0;
+ config = new GlobalConfigValues;
+
+ lastSelectedColorItem = 0;
+ lastSelectedBgItem = 0;
+
+ fontName0->setToolTip(tr("Main application font, and default font for any\n controls not defined here."));
+ fontName1->setToolTip(tr("For small controls like mixer strips.\nAlso timescale small numbers, arranger part name overlay,\n and effects rack."));
+ fontName2->setToolTip(tr("Midi track info panel. Transport controls."));
+ fontName3->setToolTip(tr("Controller graph and S/X buttons. Large numbers for time\n and tempo scale, and time signature."));
+ fontName4->setToolTip(tr("Time scale markers."));
+ fontName5->setToolTip(tr("List editor: meta event edit dialog multi-line edit box."));
+ fontName6->setToolTip(tr("Mixer label font. Auto-font-sizing up to chosen font size.\nWord-breaking but only with spaces."));
+ fontSize6->setToolTip(tr("Maximum mixer label auto-font-sizing font size."));
+
+ globalAlphaSlider->setToolTip(tr("Global opacity (opposite of transparency)."));
+
+ // ARRANGER
+
+ global_bg = new QTreeWidgetItem(backgroundTree, QStringList(tr("Standard")), 0);
+ global_bg->setFlags(Qt::ItemIsEnabled);
+ user_bg = new QTreeWidgetItem(backgroundTree, QStringList(tr("Custom")), 0);
+ user_bg->setFlags(Qt::ItemIsEnabled);
+ /*
+ partShownames->setChecked(config->canvasShowPartType & 1);
+ partShowevents->setChecked(config->canvasShowPartType & 2);
+ partShowCakes->setChecked(!(config->canvasShowPartType & 2));
+
+ eventNoteon->setChecked(config->canvasShowPartEvent & (1 << 0));
+ eventPolypressure->setChecked(config->canvasShowPartEvent & (1 << 1));
+ eventController->setChecked(config->canvasShowPartEvent & (1 << 2));
+ eventProgramchange->setChecked(config->canvasShowPartEvent & (1 << 3));
+ eventAftertouch->setChecked(config->canvasShowPartEvent & (1 << 4));
+ eventPitchbend->setChecked(config->canvasShowPartEvent & (1 << 5));
+ eventSpecial->setChecked(config->canvasShowPartEvent & (1 << 6));
+ eventButtonGroup->setEnabled(config->canvasShowPartType == 2);
+ arrGrid->setChecked(config->canvasShowGrid);
+ */
+ colorframe->setAutoFillBackground(true);
+ aPalette = new QButtonGroup(aPaletteBox);
+
+ // There must be an easier way to do this by a for loop. No? :
+ aPalette->addButton(palette0, 0);
+ aPalette->addButton(palette1, 1);
+ aPalette->addButton(palette2, 2);
+ aPalette->addButton(palette3, 3);
+ aPalette->addButton(palette4, 4);
+ aPalette->addButton(palette5, 5);
+ aPalette->addButton(palette6, 6);
+ aPalette->addButton(palette7, 7);
+ aPalette->addButton(palette8, 8);
+ aPalette->addButton(palette9, 9);
+ aPalette->addButton(palette10, 10);
+ aPalette->addButton(palette11, 11);
+ aPalette->addButton(palette12, 12);
+ aPalette->addButton(palette13, 13);
+ aPalette->addButton(palette14, 14);
+ aPalette->addButton(palette15, 15);
+ aPalette->setExclusive(true);
+
+ // COLORS
+ IdListViewItem* id;
+ IdListViewItem* aid;
+ itemList->clear();
+ aid = new IdListViewItem(0, itemList, "Arranger");
+ id = new IdListViewItem(0, aid, "PartColors");
+ // Names moved into global config by Tim.
+ /*
+ new IdListViewItem(0x400, id, "Default");
+ new IdListViewItem(0x401, id, "Refrain");
+ new IdListViewItem(0x402, id, "Bridge");
+ new IdListViewItem(0x403, id, "Intro");
+ new IdListViewItem(0x404, id, "Coda");
+ new IdListViewItem(0x405, id, "Chorus");
+ new IdListViewItem(0x406, id, "Solo");
+ new IdListViewItem(0x407, id, "Brass");
+ new IdListViewItem(0x408, id, "Percussion");
+ new IdListViewItem(0x409, id, "Drums");
+ new IdListViewItem(0x40a, id, "Guitar");
+ new IdListViewItem(0x40b, id, "Bass");
+ new IdListViewItem(0x40c, id, "Flute");
+ new IdListViewItem(0x40d, id, "Strings");
+ new IdListViewItem(0x40e, id, "Keyboard");
+ new IdListViewItem(0x40f, id, "Piano");
+ new IdListViewItem(0x410, id, "Saxophon");
+ */
+ for(int i = 0; i < NUM_PARTCOLORS; ++i)
+ new IdListViewItem(0x400 + i, id, ::config.partColorNames[i]);
+
+ new IdListViewItem(0x41c, aid, "part canvas background");
+ id = new IdListViewItem(0, aid, "Track List");
+ new IdListViewItem(0x411, id, "background");
+ new IdListViewItem(0x412, id, "midi background");
+ new IdListViewItem(0x413, id, "drum background");
+ new IdListViewItem(0x414, id, "wave background");
+ new IdListViewItem(0x415, id, "output background");
+ new IdListViewItem(0x416, id, "input background");
+ new IdListViewItem(0x417, id, "group background");
+ new IdListViewItem(0x418, id, "aux background");
+ new IdListViewItem(0x419, id, "synth background");
+ new IdListViewItem(0x41a, id, "selected track background");
+ new IdListViewItem(0x41b, id, "selected track foreground");
+ id = new IdListViewItem(0, itemList, "BigTime");
+ new IdListViewItem(0x100, id, "background");
+ new IdListViewItem(0x101, id, "foreground");
+ id = new IdListViewItem(0, itemList, "Transport");
+ new IdListViewItem(0x200, id, "handle");
+ id = new IdListViewItem(0, itemList, "Midi Editor");
+ new IdListViewItem(0x41d, id, "controller graph");
+ id = new IdListViewItem(0, itemList, "Wave Editor");
+ new IdListViewItem(0x300, id, "background");
+ id = new IdListViewItem(0, itemList, "Mixer");
+ new IdListViewItem(0x500, id, "background");
+ new IdListViewItem(0x501, id, "midi label");
+ new IdListViewItem(0x502, id, "drum label");
+ new IdListViewItem(0x503, id, "wave label");
+ new IdListViewItem(0x504, id, "audio output label");
+ new IdListViewItem(0x505, id, "audio input label");
+ new IdListViewItem(0x506, id, "group label");
+ new IdListViewItem(0x507, id, "aux label");
+ new IdListViewItem(0x508, id, "synth label");
+
+ colorNameLineEdit->setEnabled(false);
+
+ connect(colorNameLineEdit, SIGNAL(editingFinished()), SLOT(colorNameEditFinished()));
+ connect(itemList, SIGNAL(itemSelectionChanged()), SLOT(colorItemSelectionChanged()));
+ connect(aPalette, SIGNAL(buttonClicked(int)), SLOT(paletteClicked(int)));
+ connect(globalAlphaSlider, SIGNAL(valueChanged(int)), SLOT(asliderChanged(int)));
+ connect(rslider, SIGNAL(valueChanged(int)), SLOT(rsliderChanged(int)));
+ connect(gslider, SIGNAL(valueChanged(int)), SLOT(gsliderChanged(int)));
+ connect(bslider, SIGNAL(valueChanged(int)), SLOT(bsliderChanged(int)));
+ connect(hslider, SIGNAL(valueChanged(int)), SLOT(hsliderChanged(int)));
+ connect(sslider, SIGNAL(valueChanged(int)), SLOT(ssliderChanged(int)));
+ connect(vslider, SIGNAL(valueChanged(int)), SLOT(vsliderChanged(int)));
+
+ connect(globalAlphaVal, SIGNAL(valueChanged(int)), SLOT(aValChanged(int)));
+ connect(rval, SIGNAL(valueChanged(int)), SLOT(rsliderChanged(int)));
+ connect(gval, SIGNAL(valueChanged(int)), SLOT(gsliderChanged(int)));
+ connect(bval, SIGNAL(valueChanged(int)), SLOT(bsliderChanged(int)));
+ connect(hval, SIGNAL(valueChanged(int)), SLOT(hsliderChanged(int)));
+ connect(sval, SIGNAL(valueChanged(int)), SLOT(ssliderChanged(int)));
+ connect(vval, SIGNAL(valueChanged(int)), SLOT(vsliderChanged(int)));
+
+ connect(addToPalette, SIGNAL(clicked()), SLOT(addToPaletteClicked()));
+
+ //---------------------------------------------------
+ // STYLE
+ //---------------------------------------------------
+
+ /*
+ themeComboBox->clear();
+ QString cs = muse->style().name();
+ cs = cs.lower();
+
+ themeComboBox->insertStringList(QStyleFactory::keys());
+ for (int i = 0; i < themeComboBox->count(); ++i) {
+ if (themeComboBox->text(i).lower() == cs) {
+ themeComboBox->setCurrentItem(i);
+ }
+ }
+ */
+
+ openStyleSheet->setIcon(*openIcon);
+ connect(openStyleSheet, SIGNAL(clicked()), SLOT(browseStyleSheet()));
+ defaultStyleSheet->setIcon(*undoIcon);
+ connect(defaultStyleSheet, SIGNAL(clicked()), SLOT(setDefaultStyleSheet()));
+
+ //---------------------------------------------------
+ // Fonts
+ //---------------------------------------------------
+
+ fontBrowse0->setIcon(QIcon(*openIcon));
+ fontBrowse1->setIcon(QIcon(*openIcon));
+ fontBrowse2->setIcon(QIcon(*openIcon));
+ fontBrowse3->setIcon(QIcon(*openIcon));
+ fontBrowse4->setIcon(QIcon(*openIcon));
+ fontBrowse5->setIcon(QIcon(*openIcon));
+ fontBrowse6->setIcon(QIcon(*openIcon));
+ connect(fontBrowse0, SIGNAL(clicked()), SLOT(browseFont0()));
+ connect(fontBrowse1, SIGNAL(clicked()), SLOT(browseFont1()));
+ connect(fontBrowse2, SIGNAL(clicked()), SLOT(browseFont2()));
+ connect(fontBrowse3, SIGNAL(clicked()), SLOT(browseFont3()));
+ connect(fontBrowse4, SIGNAL(clicked()), SLOT(browseFont4()));
+ connect(fontBrowse5, SIGNAL(clicked()), SLOT(browseFont5()));
+ connect(fontBrowse6, SIGNAL(clicked()), SLOT(browseFont6()));
+
+ connect(applyButton, SIGNAL(clicked()), SLOT(apply()));
+ connect(okButton, SIGNAL(clicked()), SLOT(ok()));
+ connect(cancelButton, SIGNAL(clicked()), SLOT(cancel()));
+ connect(addBgButton, SIGNAL(clicked()), SLOT(addBackground()));
+ connect(removeBgButton, SIGNAL(clicked()), SLOT(removeBackground()));
+ connect(clearBgButton, SIGNAL(clicked()), SLOT(clearBackground()));
+ connect(partShowevents, SIGNAL(toggled(bool)), eventButtonGroup, SLOT(setEnabled(bool)));
+ //updateColor();
+ }
+
+//---------------------------------------------------------
+// resetValues
+//---------------------------------------------------------
+
+void Appearance::resetValues()
+ {
+ *config = ::config; // init with global config values
+ styleSheetPath->setText(config->styleSheetFile);
+ updateFonts();
+
+ QPalette pal;
+
+ /*
+ pal.setColor(palette0->backgroundRole(), config->palette[0]);
+ palette0->setPalette(pal);
+ pal.setColor(palette1->backgroundRole(), config->palette[1]);
+ palette1->setPalette(pal);
+ pal.setColor(palette2->backgroundRole(), config->palette[2]);
+ palette2->setPalette(pal);
+ pal.setColor(palette3->backgroundRole(), config->palette[3]);
+ palette3->setPalette(pal);
+ pal.setColor(palette4->backgroundRole(), config->palette[4]);
+ palette4->setPalette(pal);
+ pal.setColor(palette5->backgroundRole(), config->palette[5]);
+ palette5->setPalette(pal);
+ pal.setColor(palette6->backgroundRole(), config->palette[6]);
+ palette6->setPalette(pal);
+ pal.setColor(palette7->backgroundRole(), config->palette[7]);
+ palette7->setPalette(pal);
+ pal.setColor(palette8->backgroundRole(), config->palette[8]);
+ palette8->setPalette(pal);
+ pal.setColor(palette9->backgroundRole(), config->palette[9]);
+ palette9->setPalette(pal);
+ pal.setColor(palette10->backgroundRole(), config->palette[10]);
+ palette10->setPalette(pal);
+ pal.setColor(palette11->backgroundRole(), config->palette[11]);
+ palette11->setPalette(pal);
+ pal.setColor(palette12->backgroundRole(), config->palette[12]);
+ palette12->setPalette(pal);
+ pal.setColor(palette13->backgroundRole(), config->palette[13]);
+ palette13->setPalette(pal);
+ pal.setColor(palette14->backgroundRole(), config->palette[14]);
+ palette14->setPalette(pal);
+ pal.setColor(palette15->backgroundRole(), config->palette[15]);
+ palette15->setPalette(pal);
+ */
+
+ /*
+ pal.setColor(QPalette::Window, config->palette[0]);
+ palette0->setPalette(pal);
+ pal.setColor(QPalette::Window, config->palette[1]);
+ palette1->setPalette(pal);
+ pal.setColor(QPalette::Window, config->palette[2]);
+ palette2->setPalette(pal);
+ pal.setColor(QPalette::Window, config->palette[3]);
+ palette3->setPalette(pal);
+ pal.setColor(QPalette::Window, config->palette[4]);
+ palette4->setPalette(pal);
+ pal.setColor(QPalette::Window, config->palette[5]);
+ palette5->setPalette(pal);
+ pal.setColor(QPalette::Window, config->palette[6]);
+ palette6->setPalette(pal);
+ pal.setColor(QPalette::Window, config->palette[7]);
+ palette7->setPalette(pal);
+ pal.setColor(QPalette::Window, config->palette[8]);
+ palette8->setPalette(pal);
+ pal.setColor(QPalette::Window, config->palette[9]);
+ palette9->setPalette(pal);
+ pal.setColor(QPalette::Window, config->palette[10]);
+ palette10->setPalette(pal);
+ pal.setColor(QPalette::Window, config->palette[11]);
+ palette11->setPalette(pal);
+ pal.setColor(QPalette::Window, config->palette[12]);
+ palette12->setPalette(pal);
+ pal.setColor(QPalette::Window, config->palette[13]);
+ palette13->setPalette(pal);
+ pal.setColor(QPalette::Window, config->palette[14]);
+ palette14->setPalette(pal);
+ pal.setColor(QPalette::Window, config->palette[15]);
+ palette15->setPalette(pal);
+ */
+
+ /*
+ pal.setColor(QPalette::Button, config->palette[0]);
+ palette0->setPalette(pal);
+ pal.setColor(QPalette::Button, config->palette[1]);
+ palette1->setPalette(pal);
+ pal.setColor(QPalette::Button, config->palette[2]);
+ palette2->setPalette(pal);
+ pal.setColor(QPalette::Button, config->palette[3]);
+ palette3->setPalette(pal);
+ pal.setColor(QPalette::Button, config->palette[4]);
+ palette4->setPalette(pal);
+ pal.setColor(QPalette::Button, config->palette[5]);
+ palette5->setPalette(pal);
+ pal.setColor(QPalette::Button, config->palette[6]);
+ palette6->setPalette(pal);
+ pal.setColor(QPalette::Button, config->palette[7]);
+ palette7->setPalette(pal);
+ pal.setColor(QPalette::Button, config->palette[8]);
+ palette8->setPalette(pal);
+ pal.setColor(QPalette::Button, config->palette[9]);
+ palette9->setPalette(pal);
+ pal.setColor(QPalette::Button, config->palette[10]);
+ palette10->setPalette(pal);
+ pal.setColor(QPalette::Button, config->palette[11]);
+ palette11->setPalette(pal);
+ pal.setColor(QPalette::Button, config->palette[12]);
+ palette12->setPalette(pal);
+ pal.setColor(QPalette::Button, config->palette[13]);
+ palette13->setPalette(pal);
+ pal.setColor(QPalette::Button, config->palette[14]);
+ palette14->setPalette(pal);
+ pal.setColor(QPalette::Button, config->palette[15]);
+ palette15->setPalette(pal);
+ */
+
+ palette0->setStyleSheet(QString("background-color: ") + config->palette[0].name());
+ palette1->setStyleSheet(QString("background-color: ") + config->palette[1].name());
+ palette2->setStyleSheet(QString("background-color: ") + config->palette[2].name());
+ palette3->setStyleSheet(QString("background-color: ") + config->palette[3].name());
+ palette4->setStyleSheet(QString("background-color: ") + config->palette[4].name());
+ palette5->setStyleSheet(QString("background-color: ") + config->palette[5].name());
+ palette6->setStyleSheet(QString("background-color: ") + config->palette[6].name());
+ palette7->setStyleSheet(QString("background-color: ") + config->palette[7].name());
+ palette8->setStyleSheet(QString("background-color: ") + config->palette[8].name());
+ palette9->setStyleSheet(QString("background-color: ") + config->palette[9].name());
+ palette10->setStyleSheet(QString("background-color: ") + config->palette[10].name());
+ palette11->setStyleSheet(QString("background-color: ") + config->palette[11].name());
+ palette12->setStyleSheet(QString("background-color: ") + config->palette[12].name());
+ palette13->setStyleSheet(QString("background-color: ") + config->palette[13].name());
+ palette14->setStyleSheet(QString("background-color: ") + config->palette[14].name());
+ palette15->setStyleSheet(QString("background-color: ") + config->palette[15].name());
+
+ global_bg->takeChildren();
+ user_bg->takeChildren();
+
+ QDir bgdir = museGlobalShare + "/wallpapers/";
+ QStringList filters;
+ filters << "*.jpg" << "*.jpeg" << "*.png" << "*.gif";
+ bgdir.setNameFilters(filters);
+ backgroundTree->model()->setData(backgroundTree->model()->index(0,0),
+ QVariant(QSize(200,BG_ITEM_HEIGHT)),
+ Qt::SizeHintRole);
+ QStringList bglist = bgdir.entryList(QDir::Files, QDir::Name);
+ foreach (const QString &bgfile, bglist)
+ {
+ QTreeWidgetItem* item = new QTreeWidgetItem(global_bg, 0);
+ item->setData(0, Qt::UserRole, QVariant(museGlobalShare + "/wallpapers/" + bgfile));
+ BgPreviewWidget* bgw = new BgPreviewWidget(museGlobalShare + "/wallpapers/" + bgfile, backgroundTree);
+ backgroundTree->setItemWidget(item, 0, bgw);
+ if (config->canvasBgPixmap == museGlobalShare + "/wallpapers/" + bgfile)
+ backgroundTree->setCurrentItem(item);
+ }
+
+ foreach (const QString &bgfile, config->canvasCustomBgList)
+ {
+ QTreeWidgetItem* item = new QTreeWidgetItem(user_bg, 0);
+ BgPreviewWidget* bgw = new BgPreviewWidget(bgfile, backgroundTree);
+ backgroundTree->setItemWidget(item, 0, bgw);
+ item->setData(0, Qt::UserRole, QVariant(bgfile));
+ if (config->canvasBgPixmap == bgfile)
+ backgroundTree->setCurrentItem(item);
+ }
+
+ removeBgButton->setEnabled(false);
+
+ backgroundTree->expandAll();
+ connect(backgroundTree,
+ SIGNAL(itemClicked(QTreeWidgetItem*, int )),
+ SLOT(bgSelectionChanged(QTreeWidgetItem*)));
+
+ partShownames->setChecked(config->canvasShowPartType & 1);
+ partShowevents->setChecked(config->canvasShowPartType & 2);
+ partShowCakes->setChecked(!(config->canvasShowPartType & 2));
+
+ eventNoteon->setChecked(config->canvasShowPartEvent & (1 << 0));
+ eventPolypressure->setChecked(config->canvasShowPartEvent & (1 << 1));
+ eventController->setChecked(config->canvasShowPartEvent & (1 << 2));
+ eventProgramchange->setChecked(config->canvasShowPartEvent & (1 << 3));
+ eventAftertouch->setChecked(config->canvasShowPartEvent & (1 << 4));
+ eventPitchbend->setChecked(config->canvasShowPartEvent & (1 << 5));
+ eventSpecial->setChecked(config->canvasShowPartEvent & (1 << 6));
+ //eventButtonGroup->setEnabled(config->canvasShowPartType == 2);
+ eventButtonGroup->setEnabled(config->canvasShowPartType & 2);
+ arrGrid->setChecked(config->canvasShowGrid);
+
+ //themeComboBox->clear();
+ QString cs = muse->style()->objectName();
+ //printf("Appearance::resetValues style:%s\n", cs.toAscii().data()); // REMOVE Tim
+ //printf("Appearance::resetValues App styleSheet:%s\n", qApp->styleSheet().toAscii().data()); // REMOVE Tim
+ cs = cs.toLower();
+
+ //themeComboBox->insertItems(0, QStyleFactory::keys());
+ /*for (int i = 0; i < themeComboBox->count(); ++i) {
+ if (themeComboBox->itemText(i).toLower() == cs) {
+ themeComboBox->setCurrentIndex(i);
+ }
+ }
+ */
+ globalAlphaSlider->blockSignals(true);
+ globalAlphaVal->blockSignals(true);
+ globalAlphaSlider->setValue(config->globalAlphaBlend);
+ globalAlphaVal->setValue(config->globalAlphaBlend);
+ globalAlphaSlider->blockSignals(false);
+ globalAlphaVal->blockSignals(false);
+
+ updateColor();
+
+ }
+
+
+//---------------------------------------------------------
+// bgSelectionChanged
+//---------------------------------------------------------
+
+void Appearance::bgSelectionChanged(QTreeWidgetItem* item)
+ {
+ if (item->text(0).length() && lastSelectedBgItem)
+ {
+ backgroundTree->setCurrentItem(lastSelectedBgItem);
+ item = lastSelectedBgItem;
+ }
+
+ removeBgButton->setEnabled(false);
+
+ QTreeWidgetItem* parent = item->parent();
+ if (parent)
+ if (parent->text(0) == user_bg->text(0))
+ removeBgButton->setEnabled(true);
+
+ lastSelectedBgItem = item;
+ muse->arranger->getCanvas()->setBg(QPixmap(item->data(0, Qt::UserRole).toString()));
+ }
+
+//---------------------------------------------------------
+// Appearance
+//---------------------------------------------------------
+
+Appearance::~Appearance()
+ {
+ delete config;
+ }
+
+//---------------------------------------------------------
+// updateFonts
+//---------------------------------------------------------
+
+void Appearance::updateFonts()
+ {
+ fontSize0->setValue(config->fonts[0].pointSize());
+ fontName0->setText(config->fonts[0].family());
+ italic0->setChecked(config->fonts[0].italic());
+ bold0->setChecked(config->fonts[0].bold());
+
+ fontSize1->setValue(config->fonts[1].pointSize());
+ fontName1->setText(config->fonts[1].family());
+ italic1->setChecked(config->fonts[1].italic());
+ bold1->setChecked(config->fonts[1].bold());
+
+ fontSize2->setValue(config->fonts[2].pointSize());
+ fontName2->setText(config->fonts[2].family());
+ italic2->setChecked(config->fonts[2].italic());
+ bold2->setChecked(config->fonts[2].bold());
+
+ fontSize3->setValue(config->fonts[3].pointSize());
+ fontName3->setText(config->fonts[3].family());
+ italic3->setChecked(config->fonts[3].italic());
+ bold3->setChecked(config->fonts[3].bold());
+
+ fontSize4->setValue(config->fonts[4].pointSize());
+ fontName4->setText(config->fonts[4].family());
+ italic4->setChecked(config->fonts[4].italic());
+ bold4->setChecked(config->fonts[4].bold());
+
+ fontSize5->setValue(config->fonts[5].pointSize());
+ fontName5->setText(config->fonts[5].family());
+ italic5->setChecked(config->fonts[5].italic());
+ bold5->setChecked(config->fonts[5].bold());
+
+ fontSize6->setValue(config->fonts[6].pointSize());
+ fontName6->setText(config->fonts[6].family());
+ italic6->setChecked(config->fonts[6].italic());
+ bold6->setChecked(config->fonts[6].bold());
+ }
+
+//---------------------------------------------------------
+// apply
+//---------------------------------------------------------
+
+void Appearance::apply()
+ {
+ int showPartEvent = 0;
+ int showPartType = 0;
+
+ if (partShownames->isChecked())
+ showPartType |= 1;
+ if (partShowevents->isChecked())
+ showPartType |= 2;
+ //if (partShowCakes->isChecked())
+ // showPartType |= 4;
+
+ config->canvasShowPartType = showPartType;
+
+ if (eventNoteon->isChecked())
+ showPartEvent |= (1 << 0);
+ if (eventPolypressure->isChecked())
+ showPartEvent |= (1 << 1);
+ if (eventController->isChecked())
+ showPartEvent |= (1 << 2);
+ if (eventProgramchange->isChecked())
+ showPartEvent |= (1 << 3);
+ if (eventAftertouch->isChecked())
+ showPartEvent |= (1 << 4);
+ if (eventPitchbend->isChecked())
+ showPartEvent |= (1 << 5);
+ if (eventSpecial->isChecked())
+ showPartEvent |= (1 << 6);
+
+ config->canvasShowPartEvent = showPartEvent;
+
+ QTreeWidgetItem* cbgitem = backgroundTree->currentItem();
+
+ if (cbgitem)
+ config->canvasBgPixmap = cbgitem->data(0, Qt::UserRole).toString();
+ else
+ config->canvasBgPixmap = QString();
+
+ config->canvasCustomBgList = QStringList();
+ for (int i = 0; i < user_bg->childCount(); ++i)
+ config->canvasCustomBgList << user_bg->child(i)->data(0, Qt::UserRole).toString();
+
+ config->styleSheetFile = styleSheetPath->text();
+
+ config->fonts[0].setFamily(fontName0->text());
+
+ config->fonts[0].setPointSize(fontSize0->value());
+ config->fonts[0].setItalic(italic0->isChecked());
+ config->fonts[0].setBold(bold0->isChecked());
+ QApplication::setFont(config->fonts[0]);
+
+ config->fonts[1].setFamily(fontName1->text());
+ config->fonts[1].setPointSize(fontSize1->value());
+ config->fonts[1].setItalic(italic1->isChecked());
+ config->fonts[1].setBold(bold1->isChecked());
+
+ config->fonts[2].setFamily(fontName2->text());
+ config->fonts[2].setPointSize(fontSize2->value());
+ config->fonts[2].setItalic(italic2->isChecked());
+ config->fonts[2].setBold(bold2->isChecked());
+
+ config->fonts[3].setFamily(fontName3->text());
+ config->fonts[3].setPointSize(fontSize3->value());
+ config->fonts[3].setItalic(italic3->isChecked());
+ config->fonts[3].setBold(bold3->isChecked());
+
+ config->fonts[4].setFamily(fontName4->text());
+ config->fonts[4].setPointSize(fontSize4->value());
+ config->fonts[4].setItalic(italic4->isChecked());
+ config->fonts[4].setBold(bold4->isChecked());
+
+ config->fonts[5].setFamily(fontName5->text());
+ config->fonts[5].setPointSize(fontSize5->value());
+ config->fonts[5].setItalic(italic5->isChecked());
+ config->fonts[5].setBold(bold5->isChecked());
+
+ config->fonts[6].setFamily(fontName6->text());
+ config->fonts[6].setPointSize(fontSize6->value());
+ config->fonts[6].setItalic(italic6->isChecked());
+ config->fonts[6].setBold(bold6->isChecked());
+
+ //config->style = themeComboBox->currentText();
+ // setting up a new theme might change the fontsize, so re-read
+ fontSize0->setValue(QApplication::font().pointSize());
+
+ config->canvasShowGrid = arrGrid->isChecked();
+
+ config->globalAlphaBlend = globalAlphaVal->value();
+
+ // set colors...
+ ::config = *config;
+ muse->changeConfig(true);
+ }
+
+//---------------------------------------------------------
+// colorNameEditFinished
+//---------------------------------------------------------
+
+void Appearance::colorNameEditFinished()
+{
+ if(!lastSelectedColorItem)
+ return;
+
+ IdListViewItem* item = (IdListViewItem*)lastSelectedColorItem;
+ int id = item->id();
+ if(id == 0)
+ return;
+
+ QString etxt = colorNameLineEdit->text();
+ QString txt = item->text(0);
+ // We only support part color names, for now.
+ if(id >= 0x400 && id < (0x400 + NUM_PARTCOLORS))
+ config->partColorNames[id & 0xff] = etxt;
+ if(etxt != txt)
+ item->setText(0, etxt);
+}
+
+//---------------------------------------------------------
+// ok
+//---------------------------------------------------------
+
+void Appearance::ok()
+ {
+ apply();
+ close();
+ }
+
+//---------------------------------------------------------
+// cancel
+//---------------------------------------------------------
+
+void Appearance::cancel()
+ {
+ muse->arranger->getCanvas()->setBg(QPixmap(config->canvasBgPixmap));
+ close();
+ }
+
+//---------------------------------------------------------
+// removeBackground
+//---------------------------------------------------------
+
+void Appearance::removeBackground()
+ {
+ QTreeWidgetItem* item = backgroundTree->currentItem();
+ muse->arranger->getCanvas()->setBg(QPixmap());
+ user_bg->takeChild(user_bg->indexOfChild(item));
+ backgroundTree->setCurrentItem (0);
+ removeBgButton->setEnabled(false);
+ }
+
+//---------------------------------------------------------
+// addBackground
+//---------------------------------------------------------
+
+void Appearance::addBackground()
+ {
+ QString cur = getenv("HOME");
+ QString user_bgfile = getImageFileName(cur, image_file_pattern, this,
+ tr("MusE: load image"));
+
+ bool image_exists = false;
+ for (int i = 0; i < global_bg->childCount(); ++i)
+ if (global_bg->child(i)->data(0, Qt::UserRole).toString() == user_bgfile)
+ image_exists = true;
+ for (int i = 0; i < user_bg->childCount(); ++i)
+ if (user_bg->child(i)->data(0, Qt::UserRole).toString() == user_bgfile)
+ image_exists = true;
+
+ if (! image_exists)
+ {
+ QTreeWidgetItem* item = new QTreeWidgetItem(user_bg, 0);
+ item->setData(0, Qt::UserRole, QVariant(user_bgfile));
+ BgPreviewWidget* bgw = new BgPreviewWidget(user_bgfile, backgroundTree);
+ backgroundTree->setItemWidget(item, 0, bgw);
+ }
+ }
+
+//---------------------------------------------------------
+// clearBackground
+//---------------------------------------------------------
+
+void Appearance::clearBackground()
+ {
+ muse->arranger->getCanvas()->setBg(QPixmap());
+ backgroundTree->setCurrentItem (0);
+ removeBgButton->setEnabled(false);
+ }
+
+//---------------------------------------------------------
+// selectionChanged
+//---------------------------------------------------------
+
+void Appearance::colorItemSelectionChanged()
+ {
+ IdListViewItem* item = (IdListViewItem*)itemList->selectedItems()[0];
+ lastSelectedColorItem = 0;
+ QString txt = item->text(0);
+ int id = item->id();
+ if (id == 0) {
+ color = 0;
+ lastSelectedColorItem = 0;
+ colorNameLineEdit->setEnabled(false);
+ return;
+ }
+ bool enle = false;
+ switch(id) {
+ case 0x400: // "Default"
+ case 0x401: // "Refrain"
+ case 0x402: // "Bridge"
+ case 0x403: // "Intro"
+ case 0x404: // "Coda"
+ case 0x405: // "Chorus"
+ case 0x406: // "Solo"
+ case 0x407: // "Brass"
+ case 0x408: // "Percussion"
+ case 0x409: // "Drums"
+ case 0x40a: // "Guitar"
+ case 0x40b: // "Bass"
+ case 0x40c: // "Flute"
+ case 0x40d: // "Strings
+ case 0x40e: // "Keyboard
+ case 0x40f: // "Piano
+ case 0x410: // "Saxophon
+ lastSelectedColorItem = item;
+ color = &config->partColors[id & 0xff];
+ enle = true;
+ break;
+ case 0x100: color = &config->bigTimeBackgroundColor; break;
+ case 0x101: color = &config->bigTimeForegroundColor; break;
+ case 0x200: color = &config->transportHandleColor; break;
+ case 0x300: color = &config->waveEditBackgroundColor; break;
+ case 0x411: color = &config->trackBg; break;
+ case 0x412: color = &config->midiTrackBg; break;
+ case 0x413: color = &config->drumTrackBg; break;
+ case 0x414: color = &config->waveTrackBg; break;
+ case 0x415: color = &config->outputTrackBg; break;
+ case 0x416: color = &config->inputTrackBg; break;
+ case 0x417: color = &config->groupTrackBg; break;
+ case 0x418: color = &config->auxTrackBg; break;
+ case 0x419: color = &config->synthTrackBg; break;
+ case 0x41a: color = &config->selectTrackBg; break;
+ case 0x41b: color = &config->selectTrackFg; break;
+ case 0x41c: color = &config->partCanvasBg; break;
+ case 0x41d: color = &config->ctrlGraphFg; break;
+
+ case 0x500: color = &config->mixerBg; break;
+ case 0x501: color = &config->midiTrackLabelBg; break;
+ case 0x502: color = &config->drumTrackLabelBg; break;
+ case 0x503: color = &config->waveTrackLabelBg; break;
+ case 0x504: color = &config->outputTrackLabelBg; break;
+ case 0x505: color = &config->inputTrackLabelBg; break;
+ case 0x506: color = &config->groupTrackLabelBg; break;
+ case 0x507: color = &config->auxTrackLabelBg; break;
+ case 0x508: color = &config->synthTrackLabelBg; break;
+
+ default:
+ color = 0;
+ break;
+ }
+ colorNameLineEdit->setEnabled(enle);
+ QString s;
+ if(enle)
+ s = config->partColorNames[id & 0xff];
+ colorNameLineEdit->setText(s);
+ updateColor();
+ }
+
+void Appearance::updateColor()
+ {
+ int r, g, b, h, s, v;
+ //globalAlphaSlider->setEnabled(color);
+ rslider->setEnabled(color);
+ gslider->setEnabled(color);
+ bslider->setEnabled(color);
+ hslider->setEnabled(color);
+ sslider->setEnabled(color);
+ vslider->setEnabled(color);
+ //globalAlphaVal->setEnabled(color);
+ rval->setEnabled(color);
+ gval->setEnabled(color);
+ bval->setEnabled(color);
+ hval->setEnabled(color);
+ sval->setEnabled(color);
+ vval->setEnabled(color);
+ if (color == 0)
+ return;
+ QPalette pal;
+ QColor cfc(*color);
+
+ // Oops can't do this - affects all colour items. Need to filter.
+ ///cfc.setAlpha(globalAlphaVal->value());
+
+ pal.setColor(colorframe->backgroundRole(), cfc);
+ colorframe->setPalette(pal);
+ color->getRgb(&r, &g, &b);
+ color->getHsv(&h, &s, &v);
+ //a = color->alpha();
+ //a = config->globalAlphaBlend;
+
+ rslider->blockSignals(true);
+ gslider->blockSignals(true);
+ bslider->blockSignals(true);
+ hslider->blockSignals(true);
+ sslider->blockSignals(true);
+ vslider->blockSignals(true);
+ rval->blockSignals(true);
+ gval->blockSignals(true);
+ bval->blockSignals(true);
+ hval->blockSignals(true);
+ sval->blockSignals(true);
+ vval->blockSignals(true);
+
+ rslider->setValue(r);
+ gslider->setValue(g);
+ bslider->setValue(b);
+ hslider->setValue(h);
+ sslider->setValue(s);
+ vslider->setValue(v);
+ rval->setValue(r);
+ gval->setValue(g);
+ bval->setValue(b);
+ hval->setValue(h);
+ sval->setValue(s);
+ vval->setValue(v);
+
+ rslider->blockSignals(false);
+ gslider->blockSignals(false);
+ bslider->blockSignals(false);
+ hslider->blockSignals(false);
+ sslider->blockSignals(false);
+ vslider->blockSignals(false);
+ rval->blockSignals(false);
+ gval->blockSignals(false);
+ bval->blockSignals(false);
+ hval->blockSignals(false);
+ sval->blockSignals(false);
+ vval->blockSignals(false);
+ }
+
+void Appearance::asliderChanged(int val)
+ {
+ globalAlphaVal->blockSignals(true);
+ globalAlphaVal->setValue(val);
+ globalAlphaVal->blockSignals(false);
+ updateColor();
+ }
+
+void Appearance::aValChanged(int val)
+ {
+ globalAlphaSlider->blockSignals(true);
+ globalAlphaSlider->setValue(val);
+ globalAlphaSlider->blockSignals(false);
+ updateColor();
+ }
+
+void Appearance::rsliderChanged(int val)
+ {
+ int r, g, b;
+ if (color) {
+ color->getRgb(&r, &g, &b);
+ color->setRgb(val, g, b);
+ }
+ updateColor();
+ }
+
+void Appearance::gsliderChanged(int val)
+ {
+ int r, g, b;
+ if (color) {
+ color->getRgb(&r, &g, &b);
+ color->setRgb(r, val, b);
+ }
+ updateColor();
+ }
+
+void Appearance::bsliderChanged(int val)
+ {
+ int r, g, b;
+ if (color) {
+ color->getRgb(&r, &g, &b);
+ color->setRgb(r, g, val);
+ }
+ updateColor();
+ }
+
+void Appearance::hsliderChanged(int val)
+ {
+ int h, s, v;
+ if (color) {
+ color->getHsv(&h, &s, &v);
+ color->setHsv(val, s, v);
+ }
+ updateColor();
+ }
+
+void Appearance::ssliderChanged(int val)
+ {
+ int h, s, v;
+ if (color) {
+ color->getHsv(&h, &s, &v);
+ color->setHsv(h, val, v);
+ }
+ updateColor();
+ }
+
+void Appearance::vsliderChanged(int val)
+ {
+ int h, s, v;
+ if (color) {
+ color->getHsv(&h, &s, &v);
+ color->setHsv(h, s, val);
+ }
+ updateColor();
+ }
+
+//---------------------------------------------------------
+// addToPaletteClicked
+//---------------------------------------------------------
+
+void Appearance::addToPaletteClicked()
+ {
+ if (!color)
+ return;
+ QAbstractButton* button = (QAbstractButton*)aPalette->checkedButton(); // ddskrjo
+
+ int r, g, b;
+ QColor c;
+ if (button) {
+ int id = aPalette->id(button);
+ c = config->palette[id];
+ c.getRgb(&r, &g, &b);
+ }
+ if (button == 0 || r != 0xff || g != 0xff || b != 0xff) {
+ for (int i = 0; i < 16; ++i) {
+ c = config->palette[i];
+ c.getRgb(&r, &g, &b);
+ if (r == 0xff && g == 0xff && b == 0xff) {
+ // found empty slot
+ aPalette->button(i)->toggle();
+ //aPalette->moveFocus(i); ddskrjo
+ button = (QAbstractButton*)aPalette->button(i); // ddskrjo
+ break;
+ }
+ }
+ }
+ if (button) {
+ int id = aPalette->id(button);
+ config->palette[id] = *color;
+ //QPalette pal;
+ //pal.setColor(button->backgroundRole(), *color);
+ //pal.setColor(QPalette::Window, *color);
+ //pal.setColor(QPalette::Button, *color);
+ //button->setPalette(pal);
+ button->setStyleSheet(QString("background-color: ") + color->name());
+ button->update(); //??
+ }
+ }
+
+//---------------------------------------------------------
+// paletteClicked
+//---------------------------------------------------------
+
+void Appearance::paletteClicked(int id)
+ {
+ if (!color)
+ return;
+ QAbstractButton* button = (QAbstractButton*)aPalette->button(id); // ddskrjo
+ if (button) {
+ QColor c = button->palette().color(QPalette::Window);
+ //QColor c = button->palette().color(button->backgroundRole());
+ int r, g, b;
+ c.getRgb(&r, &g, &b);
+ if (r == 0xff && g == 0xff && b == 0xff)
+ return; // interpret palette slot as empty
+ *color = c;
+ updateColor();
+ }
+ }
+
+//---------------------------------------------------------
+// browseStyleSheet
+//---------------------------------------------------------
+
+void Appearance::browseStyleSheet()
+{
+ QString path;
+ if(!config->styleSheetFile.isEmpty())
+ {
+ QFileInfo info(config->styleSheetFile);
+ path = info.absolutePath();
+ }
+
+ QString file = QFileDialog::getOpenFileName(this, tr("Select style sheet"), path, tr("Qt style sheets (*.qss)"));
+ styleSheetPath->setText(file);
+}
+
+
+//---------------------------------------------------------
+// setDefaultStyleSheet
+//---------------------------------------------------------
+
+void Appearance::setDefaultStyleSheet()
+{
+ // Set the style sheet to the default compiled-in resource :/style.qss
+ styleSheetPath->setText(QString(":/style.qss"));
+}
+
+//---------------------------------------------------------
+// browseFont
+//---------------------------------------------------------
+
+void Appearance::browseFont0() { browseFont(0); }
+void Appearance::browseFont1() { browseFont(1); }
+void Appearance::browseFont2() { browseFont(2); }
+void Appearance::browseFont3() { browseFont(3); }
+void Appearance::browseFont4() { browseFont(4); }
+void Appearance::browseFont5() { browseFont(5); }
+void Appearance::browseFont6() { browseFont(6); }
+
+void Appearance::browseFont(int n)
+ {
+ bool ok;
+ QFont font = QFontDialog::getFont(&ok, config->fonts[n], this, "browseFont");
+ if (ok) {
+ config->fonts[n] = font;
+ updateFonts();
+ }
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/appearance.h b/attic/muse2-oom/muse2/muse/appearance.h
new file mode 100644
index 00000000..ef99adbe
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/appearance.h
@@ -0,0 +1,68 @@
+#ifndef __APPEARANCE_H__
+#define __APPEARANCE_H__
+
+#include "ui_appearancebase.h"
+
+class QColor;
+class QDialog;
+
+class MusE;
+class Arranger;
+class GlobalConfigValues;
+
+//---------------------------------------------------------
+// Appearance Dialog
+//---------------------------------------------------------
+
+class Appearance : public QDialog, public Ui::AppearanceDialogBase {
+ Arranger* arr;
+ QColor* color;
+ GlobalConfigValues* config;
+ QButtonGroup* aPalette;
+ QTreeWidgetItem* user_bg;
+ QTreeWidgetItem* global_bg;
+ QTreeWidgetItem* lastSelectedBgItem;
+ QTreeWidgetItem* lastSelectedColorItem;
+
+ Q_OBJECT
+ void updateFonts();
+ void updateColor();
+
+ private slots:
+ void apply();
+ void ok();
+ void cancel();
+ void addBackground();
+ void removeBackground();
+ void clearBackground();
+ void colorItemSelectionChanged();
+ void browseStyleSheet();
+ void setDefaultStyleSheet();
+ void browseFont(int);
+ void browseFont0();
+ void browseFont1();
+ void browseFont2();
+ void browseFont3();
+ void browseFont4();
+ void browseFont5();
+ void browseFont6();
+ void asliderChanged(int);
+ void aValChanged(int);
+ void rsliderChanged(int);
+ void gsliderChanged(int);
+ void bsliderChanged(int);
+ void hsliderChanged(int);
+ void ssliderChanged(int);
+ void vsliderChanged(int);
+ void addToPaletteClicked();
+ void paletteClicked(int);
+ void bgSelectionChanged(QTreeWidgetItem*);
+ void colorNameEditFinished();
+
+ public:
+ Appearance(Arranger*, QWidget* parent=0);
+ ~Appearance();
+ void resetValues();
+ };
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/arranger/CMakeLists.txt b/attic/muse2-oom/muse2/muse/arranger/CMakeLists.txt
new file mode 100644
index 00000000..21a06698
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/arranger/CMakeLists.txt
@@ -0,0 +1,82 @@
+#=============================================================================
+# MusE
+# Linux Music Editor
+# $Id:$
+#
+# Copyright (C) 2002-2006 by Werner Schweer and others
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#=============================================================================
+
+#
+# Expand Qt macros
+#
+QT4_WRAP_CPP (arranger_mocs
+ alayout.h
+ arranger.h
+ pcanvas.h
+ tlist.h
+ )
+
+#
+# List of source files to compile
+#
+file (GLOB arranger_source_files
+ alayout.cpp
+ arranger.cpp
+ pcanvas.cpp
+ tlist.cpp
+ )
+
+#
+# Define target
+#
+add_library ( arranger SHARED
+ ${arranger_source_files}
+ ${arranger_mocs}
+ )
+
+#
+# Append to the list of translations
+#
+set (FILES_TO_TRANSLATE
+ ${FILES_TO_TRANSLATE}
+ ${arranger_source_files}
+ CACHE INTERNAL ""
+ )
+
+#
+# Compilation flags and target name
+#
+set_target_properties( arranger
+ PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h -fPIC"
+ OUTPUT_NAME muse_arranger
+ )
+
+#
+# Linkage
+#
+target_link_libraries ( arranger
+ ${QT_LIBRARIES}
+ awl
+ mixer
+ widgets
+ )
+
+#
+# Install location
+#
+install(TARGETS arranger
+ DESTINATION ${MusE_MODULES_DIR}
+ )
+
diff --git a/attic/muse2-oom/muse2/muse/arranger/alayout.cpp b/attic/muse2-oom/muse2/muse/arranger/alayout.cpp
new file mode 100644
index 00000000..c7e1e4e3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/arranger/alayout.cpp
@@ -0,0 +1,200 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: alayout.cpp,v 1.8 2004/02/28 14:58:24 wschweer Exp $
+// (C) Copyright 2002 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "alayout.h"
+#include "arranger.h"
+
+#include <QScrollBar>
+
+//---------------------------------------------------------
+// wadd
+//---------------------------------------------------------
+
+void TLLayout::wadd(int idx, QWidget* w)
+ {
+ li[idx] = new QWidgetItem(w);
+ if (idx == 0)
+ stack = (WidgetStack*)w;
+ if (idx == 1)
+ sb = (QScrollBar*)w;
+ addItem(li[idx]);
+ }
+
+#if 0
+//---------------------------------------------------------
+// TLLayoutIterator
+//---------------------------------------------------------
+
+class TLLayoutIterator // : public QGLayoutIterator ddskrjo
+ {
+ int idx;
+ QList<QLayoutItem*> list;
+
+ public:
+ TLLayoutIterator(QList<QLayoutItem*> l) : idx(0), list(l) {}
+ QLayoutItem *current() { return idx < int(list->count()) ? list->at(idx) : 0; }
+ QLayoutItem *next() { idx++; return current(); }
+ QLayoutItem *takeCurrent() { return list->take( idx ); }
+ };
+
+//---------------------------------------------------------
+// iterator
+//---------------------------------------------------------
+
+QLayoutIterator TLLayout::iterator()
+ {
+ return QLayoutIterator(0); //new TLLayoutIterator(&ilist)); ddskrjo
+ }
+
+void TLLayout::addItem(QLayoutItem *item)
+ {
+ ilist.append(item);
+ }
+
+TLLayout::~TLLayout()
+ {
+ deleteAllItems();
+ }
+
+#endif
+
+//---------------------------------------------------------
+// setGeometry
+// perform geometry management for tracklist:
+//
+// 0 1 2
+// +-----------+--------+---------+
+// | Trackinfo | scroll | header 2|
+// | | bar +---------+ y1
+// | ^ | | ^ |
+// | | | <list> |
+// | 0 | 1 | 3 |
+// +-----------+--------+---------+ y2
+// | hline 4 |
+// +----------+-------------------+ y3
+// | button 5 | |
+// +----------+-------------------+
+//---------------------------------------------------------
+
+void TLLayout::setGeometry(const QRect &rect)
+ {
+ //if(_inSetGeometry) // p4.0.11 Tim
+ // return;
+ //_inSetGeometry = true;
+
+ int w = rect.width();
+ int h = rect.height();
+
+ QSize s0;
+ if (stack->visibleWidget()) {
+ s0 = stack->visibleWidget()->minimumSizeHint();
+ if (!s0.isValid()) // widget has no geometry management
+ s0 = stack->visibleWidget()->size();
+ }
+ else
+ s0 = stack->minimumSizeHint();
+
+ QSize s1 = li[1]->sizeHint();
+ QSize s2 = li[2]->sizeHint();
+ QSize s3 = li[3]->sizeHint();
+ QSize s4 = li[4]->sizeHint();
+ QSize s5 = li[5]->sizeHint();
+
+ int y1 = 30; // fixed header height
+ int ah = h - s5.height() - s4.height() - y1; // list height
+ int aw = w - s1.width() - s0.width(); // list width
+
+ int y2 = ah + s2.height();
+ int y3 = y2 + s4.height();
+ int x1 = s0.width();
+ int x2 = x1 + s1.width();
+
+ li[0]->setGeometry(QRect(0, 0, s0.width(), y2));
+
+ QWidget* widget = stack->visibleWidget();
+ int range = s0.height() - y2;
+ if (range < 0)
+ range = 0;
+ // Note this appears to cause a single recursive call to this function - jumps to beginning,
+ // because now the scroll bar wants to be put in the layout.
+ sb->setVisible(range != 0);
+ if (range)
+ sb->setMaximum(range);
+
+ if (widget) {
+ //QSize r(s0.width(), y2);
+ QSize r(s0.width(), y2 < s0.height() ? s0.height() : y2); // p4.0.11 Tim
+ widget->setGeometry(0, 0, r.width(), r.height());
+ }
+
+ li[1]->setGeometry(QRect(x1, 0, s1.width(), y2));
+ li[2]->setGeometry(QRect(x2, 0, aw, s2.height()));
+ li[3]->setGeometry(QRect(x2, y1, aw, ah));
+ li[4]->setGeometry(QRect(0, y2, w, s4.height()));
+ li[5]->setGeometry(QRect(3, y3, s5.width(), s5.height()));
+
+ //_inSetGeometry = false;
+ }
+
+//---------------------------------------------------------
+// sizeHint
+//---------------------------------------------------------
+
+QSize TLLayout::sizeHint() const
+ {
+ return QSize(150, 100);
+ // p4.0.11 Tim. 100 was allowing vertically shrunk trackinfo widgets. Nope, no help.
+ //return minimumSize();
+ }
+
+//---------------------------------------------------------
+// minimumSize
+//---------------------------------------------------------
+
+QSize TLLayout::minimumSize() const
+ {
+ int w = stack->minimumSizeHint().width();
+ w += li[1]->sizeHint().width();
+
+ return QSize(w, 50);
+ // p4.0.11 Tim. 50 was allowing vertically shrunk trackinfo widgets. Nope, no help.
+ //return QSize(w, stack->minimumSizeHint().height());
+ }
+
+//---------------------------------------------------------
+// maximumSize
+//---------------------------------------------------------
+
+QSize TLLayout::maximumSize() const
+ {
+ return QSize(440, 100000);
+ }
+
+//---------------------------------------------------------
+// takeAt
+//---------------------------------------------------------
+
+QLayoutItem* TLLayout::takeAt(int i)
+ {
+ if (i >= 0 && i < ilist.size())
+ return ilist.takeAt(i);
+ else
+ return 0;
+ }
+
+//---------------------------------------------------------
+// clear
+//---------------------------------------------------------
+
+void TLLayout::clear()
+ {
+ QLayoutItem* child;
+ while ((child = takeAt(0)) != 0) {
+ delete child->widget();
+ delete child;
+ }
+ }
diff --git a/attic/muse2-oom/muse2/muse/arranger/alayout.h b/attic/muse2-oom/muse2/muse/arranger/alayout.h
new file mode 100644
index 00000000..8ba1a829
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/arranger/alayout.h
@@ -0,0 +1,60 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: alayout.h,v 1.3.2.1 2008/01/19 13:33:46 wschweer Exp $
+// (C) Copyright 2002 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __ALAYOUT_H__
+#define __ALAYOUT_H__
+
+#include <QLayout>
+#include <QList>
+
+class QLayoutItem;
+class QScrollBar;
+
+class WidgetStack;
+
+//---------------------------------------------------------
+// TLLayout
+// arranger trackList layout manager
+//---------------------------------------------------------
+
+class TLLayout : public QLayout
+ {
+ Q_OBJECT
+
+ bool _inSetGeometry;
+ QList<QLayoutItem*> ilist;
+ QLayoutItem* li[6];
+ QScrollBar* sb;
+ WidgetStack* stack;
+
+ public:
+ //TLLayout(QWidget *parent) : QLayout(parent, 0, -1) {}
+ TLLayout(QWidget *parent) : QLayout(parent) { _inSetGeometry = false; setContentsMargins(0, 0, 0, 0); setSpacing(-1); }
+ ~TLLayout() { clear(); }
+
+ void addItem(QLayoutItem *item) { ilist.append(item); }
+ virtual Qt::Orientations expandingDirections() const { return 0; }
+ virtual bool hasHeightForWidth() const { return false; }
+ virtual int count() const { return ilist.size(); }
+ void clear();
+
+ void wadd(int idx, QWidget* w);
+ virtual QSize sizeHint() const;
+ virtual QSize minimumSize() const;
+ virtual QSize maximumSize() const;
+ //QSize sizeHint() const;
+ //QSize minimumSize() const;
+ //QSize maximumSize() const;
+ ///QLayoutIterator iterator();
+ virtual void setGeometry(const QRect &rect);
+
+ //virtual QLayoutItem* itemAt(int) const { return 0;} // ddskrjo, is pure virtual, overridden
+ virtual QLayoutItem* itemAt(int i) const { return ilist.value(i);}
+ virtual QLayoutItem* takeAt(int); // { return 0;} // ddskrjo, is pure virtual, overridden
+ ///virtual int count() const { return ilist.count(); } // ddskrjo, is pure virtual, overridden
+ };
+#endif
diff --git a/attic/muse2-oom/muse2/muse/arranger/arranger.cpp b/attic/muse2-oom/muse2/muse/arranger/arranger.cpp
new file mode 100644
index 00000000..134465b9
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/arranger/arranger.cpp
@@ -0,0 +1,1104 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: arranger.cpp,v 1.33.2.21 2009/11/17 22:08:22 terminator356 Exp $
+// (C) Copyright 1999-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "config.h"
+
+#include <stdio.h>
+#include <values.h>
+
+#include <QComboBox>
+#include <QGridLayout>
+#include <QKeyEvent>
+#include <QLabel>
+#include <QList>
+#include <QMainWindow>
+#include <QScrollBar>
+#include <QToolBar>
+#include <QToolButton>
+#include <QVBoxLayout>
+#include <QWheelEvent>
+#include <QPainter>
+//#include <QStackedWidget>
+
+#include "arranger.h"
+#include "song.h"
+#include "app.h"
+#include "mtscale.h"
+#include "scrollscale.h"
+#include "pcanvas.h"
+#include "poslabel.h"
+#include "xml.h"
+#include "splitter.h"
+#include "lcombo.h"
+#include "mtrackinfo.h"
+#include "midiport.h"
+#include "mididev.h"
+#include "utils.h"
+#include "globals.h"
+#include "tlist.h"
+#include "icons.h"
+#include "header.h"
+#include "utils.h"
+#include "alayout.h"
+#include "audio.h"
+#include "event.h"
+#include "midiseq.h"
+#include "midictrl.h"
+#include "mpevent.h"
+#include "gconfig.h"
+#include "mixer/astrip.h"
+#include "spinbox.h"
+#include "tvieweditor.h"
+
+//---------------------------------------------------------
+// Arranger::setHeaderToolTips
+//---------------------------------------------------------
+
+void Arranger::setHeaderToolTips()
+ {
+ header->setToolTip(COL_RECORD, tr("Enable Recording"));
+ header->setToolTip(COL_MUTE, tr("Mute/Off Indicator"));
+ header->setToolTip(COL_SOLO, tr("Solo Indicator"));
+ header->setToolTip(COL_CLASS, tr("Track Type"));
+ header->setToolTip(COL_NAME, tr("Track Name"));
+ header->setToolTip(COL_OCHANNEL, tr("Midi output channel number or audio channels"));
+ header->setToolTip(COL_OPORT, tr("Midi output port or synth midi port"));
+ header->setToolTip(COL_TIMELOCK, tr("Time Lock"));
+ header->setToolTip(COL_AUTOMATION, tr("Automation parameter selection"));
+ }
+
+
+
+//---------------------------------------------------------
+// Arranger::setHeaderWhatsThis
+//---------------------------------------------------------
+
+void Arranger::setHeaderWhatsThis()
+ {
+ header->setWhatsThis(COL_RECORD, tr("Enable recording. Click to toggle."));
+ header->setWhatsThis(COL_MUTE, tr("Mute indicator. Click to toggle.\nRight-click to toggle track on/off.\nMute is designed for rapid, repeated action.\nOn/Off is not!"));
+ header->setWhatsThis(COL_SOLO, tr("Solo indicator. Click to toggle.\nConnected tracks are also 'phantom' soloed,\n indicated by a dark square."));
+ header->setWhatsThis(COL_CLASS, tr("Track type. Right-click to change\n midi and drum track types."));
+ header->setWhatsThis(COL_NAME, tr("Track name. Double-click to edit.\nRight-click for more options."));
+ header->setWhatsThis(COL_OCHANNEL, tr("Midi/drum track: Output channel number.\nAudio track: Channels.\nMid/right-click to change."));
+ header->setWhatsThis(COL_OPORT, tr("Midi/drum track: Output port.\nSynth track: Assigned midi port.\nLeft-click to change.\nRight-click to show GUI."));
+ header->setWhatsThis(COL_TIMELOCK, tr("Time lock"));
+ }
+
+//---------------------------------------------------------
+// Arranger
+// is the central widget in app
+//---------------------------------------------------------
+
+Arranger::Arranger(QMainWindow* parent, const char* name)
+ : QWidget(parent)
+ {
+ setObjectName(name);
+ _raster = 0; // measure
+ selected = 0;
+ // Since program covers 3 controls at once, it is in 'midi controller' units rather than 'gui control' units.
+ //program = -1;
+ ///program = CTRL_VAL_UNKNOWN;
+ ///pan = -65;
+ ///volume = -1;
+ setMinimumSize(600, 50);
+ showTrackinfoFlag = true;
+
+ cursVal = MAXINT;
+
+ //setFocusPolicy(Qt::StrongFocus);
+
+ //---------------------------------------------------
+ // ToolBar
+ // create toolbar in toplevel widget
+ //---------------------------------------------------
+
+ parent->addToolBarBreak();
+ QToolBar* toolbar = parent->addToolBar(tr("Arranger"));
+
+ QLabel* label = new QLabel(tr("Cursor"));
+ label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+ label->setIndent(3);
+ //toolbar->addWidget(label);
+ cursorPos = new PosLabel(0);
+ cursorPos->setEnabled(false);
+ cursorPos->setFixedHeight(22);
+ cursorPos->setObjectName("arrangerCursor");
+ toolbar->addWidget(cursorPos);
+
+ /*QToolButton* testView = new QToolButton();
+ testView->setText(QString("TG"));
+ toolbar->addWidget(testView);
+ connect(testView, SIGNAL(clicked()), SLOT(showTrackViews()));
+ */
+
+ const char* rastval[] = {
+ QT_TRANSLATE_NOOP("@default", "Off"), QT_TRANSLATE_NOOP("@default", "Bar"), "1/2", "1/4", "1/8", "1/16"
+ };
+ label = new QLabel(tr("Snap"));
+ label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+ label->setIndent(3);
+ toolbar->addWidget(label);
+ QComboBox* raster = new QComboBox();
+ for (int i = 0; i < 6; i++)
+ raster->insertItem(i, tr(rastval[i]));
+ raster->setCurrentIndex(1);
+ // Set the audio record part snapping. Set to 0 (bar), the same as this combo box intial raster.
+ song->setArrangerRaster(0);
+ toolbar->addWidget(raster);
+ connect(raster, SIGNAL(activated(int)), SLOT(_setRaster(int)));
+ ///raster->setFocusPolicy(Qt::NoFocus);
+ raster->setFocusPolicy(Qt::TabFocus);
+
+ // Song len
+ label = new QLabel(tr("Len"));
+ label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+ label->setIndent(3);
+ toolbar->addWidget(label);
+
+ // song length is limited to 10000 bars; the real song len is limited
+ // by overflows in tick computations
+ //
+ lenEntry = new SpinBox(1, 10000, 1);
+ lenEntry->setValue(song->len());
+ lenEntry->setToolTip(tr("song length - bars"));
+ lenEntry->setWhatsThis(tr("song length - bars"));
+ toolbar->addWidget(lenEntry);
+ connect(lenEntry, SIGNAL(valueChanged(int)), SLOT(songlenChanged(int)));
+
+ typeBox = new LabelCombo(tr("Type"), 0);
+ typeBox->insertItem(0, tr("NO"));
+ typeBox->insertItem(1, tr("GM"));
+ typeBox->insertItem(2, tr("GS"));
+ typeBox->insertItem(3, tr("XG"));
+ typeBox->setCurrentIndex(0);
+ typeBox->setToolTip(tr("midi song type"));
+ typeBox->setWhatsThis(tr("midi song type"));
+ ///typeBox->setFocusPolicy(Qt::NoFocus);
+ typeBox->setFocusPolicy(Qt::TabFocus);
+ toolbar->addWidget(typeBox);
+ connect(typeBox, SIGNAL(activated(int)), SLOT(modeChange(int)));
+
+ label = new QLabel(tr("Pitch"));
+ label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+ label->setIndent(3);
+ toolbar->addWidget(label);
+
+ globalPitchSpinBox = new SpinBox(-127, 127, 1);
+ globalPitchSpinBox->setValue(song->globalPitchShift());
+ globalPitchSpinBox->setToolTip(tr("midi pitch"));
+ globalPitchSpinBox->setWhatsThis(tr("global midi pitch shift"));
+ toolbar->addWidget(globalPitchSpinBox);
+ connect(globalPitchSpinBox, SIGNAL(valueChanged(int)), SLOT(globalPitchChanged(int)));
+
+ label = new QLabel(tr("Tempo"));
+ label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+ label->setIndent(3);
+ toolbar->addWidget(label);
+
+ globalTempoSpinBox = new SpinBox(50, 200, 1, toolbar);
+ globalTempoSpinBox->setSuffix(QString("%"));
+ globalTempoSpinBox->setValue(tempomap.globalTempo());
+ globalTempoSpinBox->setToolTip(tr("midi tempo"));
+ globalTempoSpinBox->setWhatsThis(tr("midi tempo"));
+ toolbar->addWidget(globalTempoSpinBox);
+ connect(globalTempoSpinBox, SIGNAL(valueChanged(int)), SLOT(globalTempoChanged(int)));
+
+ QToolButton* tempo50 = new QToolButton();
+ tempo50->setText(QString("50%"));
+ toolbar->addWidget(tempo50);
+ connect(tempo50, SIGNAL(clicked()), SLOT(setTempo50()));
+
+ QToolButton* tempo100 = new QToolButton();
+ tempo100->setText(tr("N"));
+ toolbar->addWidget(tempo100);
+ connect(tempo100, SIGNAL(clicked()), SLOT(setTempo100()));
+
+ QToolButton* tempo200 = new QToolButton();
+ tempo200->setText(QString("200%"));
+ toolbar->addWidget(tempo200);
+ connect(tempo200, SIGNAL(clicked()), SLOT(setTempo200()));
+
+ QVBoxLayout* box = new QVBoxLayout(this);
+ box->setContentsMargins(0, 0, 0, 0);
+ box->setSpacing(0);
+ box->addWidget(hLine(this), Qt::AlignTop);
+ //QFrame* hline = hLine(this);
+ //hline->setLineWidth(0);
+ //box->addWidget(hline, Qt::AlignTop);
+
+ //---------------------------------------------------
+ // Tracklist
+ //---------------------------------------------------
+
+ int xscale = -100;
+ int yscale = 1;
+
+ split = new Splitter(Qt::Horizontal, this, "split");
+ split->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
+ box->addWidget(split, 1000);
+ //split->setHandleWidth(10);
+
+ QWidget* tracklist = new QWidget(split);
+
+ split->setStretchFactor(split->indexOf(tracklist), 0);
+ //tracklist->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding, 0, 100));
+ QSizePolicy tpolicy = QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
+ tpolicy.setHorizontalStretch(0);
+ tpolicy.setVerticalStretch(100);
+ tracklist->setSizePolicy(tpolicy);
+
+ QWidget* editor = new QWidget(split);
+ split->setStretchFactor(split->indexOf(editor), 1);
+ //editor->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding,
+ // Changed by T356. Was causing "large int implicitly truncated" warning. These are UCHAR values...
+ //1000, 100));
+ //232, 100)); // 232 is what it was being truncated to, but what is the right value?...
+ //255, 100));
+ QSizePolicy epolicy = QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
+ epolicy.setHorizontalStretch(255);
+ epolicy.setVerticalStretch(100);
+ editor->setSizePolicy(epolicy);
+
+ //---------------------------------------------------
+ // Track Info
+ //---------------------------------------------------
+
+ infoScroll = new QScrollBar(Qt::Vertical, tracklist);
+ infoScroll->setObjectName("infoScrollBar");
+ //genTrackInfo(tracklist); // Moved below
+
+ // Track-Info Button
+ ib = new QToolButton(tracklist);
+ ib->setText(tr("TrackInfo"));
+ ib->setCheckable(true);
+ ib->setChecked(showTrackinfoFlag);
+ ib->setFocusPolicy(Qt::NoFocus);
+ connect(ib, SIGNAL(toggled(bool)), SLOT(showTrackInfo(bool)));
+
+ header = new Header(tracklist, "header");
+
+ header->setFixedHeight(30);
+
+ QFontMetrics fm1(header->font());
+ int fw = 8;
+
+ header->setColumnLabel(tr("R"), COL_RECORD, fm1.width('R')+fw);
+ header->setColumnLabel(tr("M"), COL_MUTE, fm1.width('M')+fw);
+ header->setColumnLabel(tr("S"), COL_SOLO, fm1.width('S')+fw);
+ header->setColumnLabel(tr("C"), COL_CLASS, fm1.width('C')+fw);
+ header->setColumnLabel(tr("Track"), COL_NAME, 100);
+ header->setColumnLabel(tr("Port"), COL_OPORT, 60);
+ header->setColumnLabel(tr("Ch"), COL_OCHANNEL, 30);
+ header->setColumnLabel(tr("T"), COL_TIMELOCK, fm1.width('T')+fw);
+ header->setColumnLabel(tr("Automation"), COL_AUTOMATION, 75);
+ header->setResizeMode(COL_RECORD, QHeaderView::Fixed);
+ header->setResizeMode(COL_MUTE, QHeaderView::Fixed);
+ header->setResizeMode(COL_SOLO, QHeaderView::Fixed);
+ header->setResizeMode(COL_CLASS, QHeaderView::Fixed);
+ header->setResizeMode(COL_NAME, QHeaderView::Interactive);
+ header->setResizeMode(COL_OPORT, QHeaderView::Interactive);
+ header->setResizeMode(COL_OCHANNEL, QHeaderView::Fixed);
+ header->setResizeMode(COL_TIMELOCK, QHeaderView::Fixed);
+ header->setResizeMode(COL_AUTOMATION, QHeaderView::Interactive);
+
+ setHeaderToolTips();
+ setHeaderWhatsThis();
+ header->setMovable (true );
+ list = new TList(header, tracklist, "tracklist");
+
+ // Do this now that the list is available.
+ genTrackInfo(tracklist);
+
+ ///connect(list, SIGNAL(selectionChanged()), SLOT(trackSelectionChanged()));
+ connect(list, SIGNAL(selectionChanged(Track*)), SLOT(trackSelectionChanged()));
+ connect(list, SIGNAL(selectionChanged(Track*)), midiTrackInfo, SLOT(setTrack(Track*)));
+ connect(header, SIGNAL(sectionResized(int,int,int)), list, SLOT(redraw()));
+ connect(header, SIGNAL(sectionMoved(int,int,int)), list, SLOT(redraw()));
+ connect(header, SIGNAL(sectionMoved(int,int,int)), this, SLOT(headerMoved()));
+
+ // tracklist:
+ //
+ // 0 1 2
+ // +-----------+--------+---------+
+ // | Trackinfo | scroll | Header | 0
+ // | | bar +---------+
+ // | | | TList | 1
+ // +-----------+--------+---------+
+ // | hline | 2
+ // +-----+------------------------+
+ // | ib | | 3
+ // +-----+------------------------+
+
+ connect(infoScroll, SIGNAL(valueChanged(int)), SLOT(trackInfoScroll(int)));
+ tgrid = new TLLayout(tracklist); // layout manager for this
+ tgrid->wadd(0, trackInfo);
+ tgrid->wadd(1, infoScroll);
+ tgrid->wadd(2, header);
+ tgrid->wadd(3, list);
+ tgrid->wadd(4, hLine(tracklist));
+ tgrid->wadd(5, ib);
+
+ //---------------------------------------------------
+ // Editor
+ //---------------------------------------------------
+
+ int offset = AL::sigmap.ticksMeasure(0);
+ hscroll = new ScrollScale(-1000, -10, xscale, song->len(), Qt::Horizontal, editor, -offset);
+ hscroll->setFocusPolicy(Qt::NoFocus);
+ ib->setFixedHeight(hscroll->sizeHint().height());
+
+ // Changed p3.3.43 Too small steps for me...
+ //vscroll = new QScrollBar(1, 20*20, 1, 5, 0, Vertical, editor);
+ //vscroll = new QScrollBar(1, 20*20, 5, 25, 0, Qt::Vertical, editor);
+ vscroll = new QScrollBar(editor);
+ ///vscroll->setMinimum(1);
+ vscroll->setMinimum(0); // Tim.
+ vscroll->setMaximum(20*20);
+ vscroll->setSingleStep(5);
+ vscroll->setPageStep(25);
+ vscroll->setValue(0);
+ vscroll->setOrientation(Qt::Vertical);
+
+ list->setScroll(vscroll);
+
+ QList<int> vallist;
+ vallist.append(tgrid->maximumSize().width());
+ split->setSizes(vallist);
+
+ QGridLayout* egrid = new QGridLayout(editor);
+ egrid->setColumnStretch(0, 50);
+ egrid->setRowStretch(2, 50);
+ egrid->setContentsMargins(0, 0, 0, 0);
+ egrid->setSpacing(0);
+
+ time = new MTScale(&_raster, editor, xscale);
+ time->setOrigin(-offset, 0);
+ canvas = new PartCanvas(&_raster, editor, xscale, yscale);
+ canvas->setBg(config.partCanvasBg);
+ canvas->setCanvasTools(arrangerTools);
+ canvas->setOrigin(-offset, 0);
+ canvas->setFocus();
+ //parent->setFocusProxy(canvas); // Tim.
+
+ connect(canvas, SIGNAL(setUsedTool(int)), this, SIGNAL(setUsedTool(int)));
+ connect(canvas, SIGNAL(trackChanged(Track*)), list, SLOT(selectTrack(Track*)));
+ connect(list, SIGNAL(keyPressExt(QKeyEvent*)), canvas, SLOT(redirKeypress(QKeyEvent*)));
+ connect(canvas, SIGNAL(selectTrackAbove()), list, SLOT(selectTrackAbove()));
+ connect(canvas, SIGNAL(selectTrackBelow()), list, SLOT(selectTrackBelow()));
+
+ connect(this, SIGNAL(redirectWheelEvent(QWheelEvent*)), canvas, SLOT(redirectedWheelEvent(QWheelEvent*)));
+ connect(list, SIGNAL(redirectWheelEvent(QWheelEvent*)), canvas, SLOT(redirectedWheelEvent(QWheelEvent*)));
+
+ //egrid->addMultiCellWidget(time, 0, 0, 0, 1);
+ //egrid->addMultiCellWidget(hLine(editor), 1, 1, 0, 1);
+ egrid->addWidget(time, 0, 0, 1, 2);
+ egrid->addWidget(hLine(editor), 1, 0, 1, 2);
+
+ egrid->addWidget(canvas, 2, 0);
+ egrid->addWidget(vscroll, 2, 1);
+ egrid->addWidget(hscroll, 3, 0, Qt::AlignBottom);
+
+ connect(vscroll, SIGNAL(valueChanged(int)), canvas, SLOT(setYPos(int)));
+ connect(hscroll, SIGNAL(scrollChanged(int)), canvas, SLOT(setXPos(int)));
+ connect(hscroll, SIGNAL(scaleChanged(int)), canvas, SLOT(setXMag(int)));
+ connect(vscroll, SIGNAL(valueChanged(int)), list, SLOT(setYPos(int)));
+ connect(hscroll, SIGNAL(scrollChanged(int)), time, SLOT(setXPos(int))); //
+ connect(hscroll, SIGNAL(scaleChanged(int)), time, SLOT(setXMag(int)));
+ connect(canvas, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
+ connect(canvas, SIGNAL(verticalScroll(unsigned)),SLOT(verticalScrollSetYpos(unsigned)));
+ connect(canvas, SIGNAL(horizontalScroll(unsigned)),hscroll, SLOT(setPos(unsigned)));
+ connect(canvas, SIGNAL(horizontalScrollNoLimit(unsigned)),hscroll, SLOT(setPosNoLimit(unsigned)));
+ connect(time, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
+
+ connect(canvas, SIGNAL(tracklistChanged()), list, SLOT(tracklistChanged()));
+ connect(canvas, SIGNAL(dclickPart(Track*)), SIGNAL(editPart(Track*)));
+ connect(canvas, SIGNAL(startEditor(PartList*,int)), SIGNAL(startEditor(PartList*, int)));
+
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+ //connect(song, SIGNAL(mTypeChanged(MType)), SLOT(setMode((int)MType))); // p4.0.7 Tim.
+ connect(canvas, SIGNAL(followEvent(int)), hscroll, SLOT(setOffset(int)));
+ connect(canvas, SIGNAL(selectionChanged()), SIGNAL(selectionChanged()));
+ connect(canvas, SIGNAL(dropSongFile(const QString&)), SIGNAL(dropSongFile(const QString&)));
+ connect(canvas, SIGNAL(dropMidiFile(const QString&)), SIGNAL(dropMidiFile(const QString&)));
+
+ connect(canvas, SIGNAL(toolChanged(int)), SIGNAL(toolChanged(int)));
+// connect(song, SIGNAL(posChanged(int, unsigned, bool)), SLOT(seek()));
+
+ // Removed p3.3.43
+ // Song::addMarker() already emits a 'markerChanged'.
+ //connect(time, SIGNAL(addMarker(int)), SIGNAL(addMarker(int)));
+
+ configChanged(); // set configuration values
+ if(canvas->part())
+ midiTrackInfo->setTrack(canvas->part()->track()); // Tim.
+ showTrackInfo(showTrackinfoFlag);
+
+ // Take care of some tabbies!
+ setTabOrder(tempo200, trackInfo);
+ setTabOrder(trackInfo, infoScroll);
+ setTabOrder(infoScroll, list);
+ setTabOrder(list, canvas);
+ //setTabOrder(canvas, ib);
+ //setTabOrder(ib, hscroll);
+ }
+
+//---------------------------------------------------------
+// updateHScrollRange
+//---------------------------------------------------------
+
+//void Arranger::updateHScrollRange()
+//{
+// int s = 0, e = song->len();
+ // Show one more measure.
+// e += AL::sigmap.ticksMeasure(e);
+ // Show another quarter measure due to imprecise drawing at canvas end point.
+// e += AL::sigmap.ticksMeasure(e) / 4;
+ // Compensate for the fixed vscroll width.
+// e += canvas->rmapxDev(-vscroll->width());
+// int s1, e1;
+// hscroll->range(&s1, &e1);
+// if(s != s1 || e != e1)
+// hscroll->setRange(s, e);
+//}
+
+//---------------------------------------------------------
+// headerMoved
+//---------------------------------------------------------
+
+void Arranger::headerMoved()
+ {
+ //header->setResizeMode(COL_NAME, QHeaderView::Stretch);
+ }
+
+//---------------------------------------------------------
+// setTime
+//---------------------------------------------------------
+
+void Arranger::setTime(unsigned tick)
+ {
+ if (tick == MAXINT)
+ cursorPos->setEnabled(false);
+ else {
+ cursVal = tick;
+ cursorPos->setEnabled(true);
+ cursorPos->setValue(tick);
+ time->setPos(3, tick, false);
+ }
+ }
+
+//---------------------------------------------------------
+// toolChange
+//---------------------------------------------------------
+
+void Arranger::setTool(int t)
+ {
+ canvas->setTool(t);
+ }
+
+//---------------------------------------------------------
+// dclickPart
+//---------------------------------------------------------
+
+void Arranger::dclickPart(Track* t)
+ {
+ emit editPart(t);
+ }
+
+//---------------------------------------------------------
+// configChanged
+//---------------------------------------------------------
+
+void Arranger::configChanged()
+ {
+ //printf("Arranger::configChanged\n");
+
+ if (config.canvasBgPixmap.isEmpty()) {
+ canvas->setBg(config.partCanvasBg);
+ canvas->setBg(QPixmap());
+ //printf("Arranger::configChanged - no bitmap!\n");
+ }
+ else {
+
+ //printf("Arranger::configChanged - bitmap %s!\n", config.canvasBgPixmap.ascii());
+ canvas->setBg(QPixmap(config.canvasBgPixmap));
+ }
+ ///midiTrackInfo->setFont(config.fonts[2]);
+ //updateTrackInfo(type);
+ }
+
+//---------------------------------------------------------
+// songlenChanged
+//---------------------------------------------------------
+
+void Arranger::songlenChanged(int n)
+ {
+ int newLen = AL::sigmap.bar2tick(n, 0, 0);
+ song->setLen(newLen);
+ }
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void Arranger::songChanged(int type)
+ {
+ // Is it simply a midi controller value adjustment? Forget it.
+ if(type != SC_MIDI_CONTROLLER)
+ {
+ unsigned endTick = song->len();
+ int offset = AL::sigmap.ticksMeasure(endTick);
+ hscroll->setRange(-offset, endTick + offset); //DEBUG
+ canvas->setOrigin(-offset, 0);
+ time->setOrigin(-offset, 0);
+
+ int bar, beat;
+ unsigned tick;
+ AL::sigmap.tickValues(endTick, &bar, &beat, &tick);
+ if (tick || beat)
+ ++bar;
+ lenEntry->blockSignals(true);
+ lenEntry->setValue(bar);
+ lenEntry->blockSignals(false);
+
+ if(type & SC_SONG_TYPE) // p4.0.7 Tim.
+ setMode(song->mtype());
+
+ trackSelectionChanged();
+ canvas->partsChanged();
+ typeBox->setCurrentIndex(int(song->mtype()));
+ if (type & SC_SIG)
+ time->redraw();
+ if (type & SC_TEMPO)
+ setGlobalTempo(tempomap.globalTempo());
+
+ if(type & SC_TRACK_REMOVED)
+ {
+ AudioStrip* w = (AudioStrip*)(trackInfo->getWidget(2));
+ //AudioStrip* w = (AudioStrip*)(trackInfo->widget(2));
+ if(w)
+ {
+ Track* t = w->getTrack();
+ if(t)
+ {
+ TrackList* tl = song->tracks();
+ iTrack it = tl->find(t);
+ if(it == tl->end())
+ {
+ delete w;
+ trackInfo->addWidget(0, 2);
+ //trackInfo->insertWidget(2, 0);
+ selected = 0;
+ }
+ }
+ }
+ }
+ }
+
+ updateTrackInfo(type);
+ }
+
+//---------------------------------------------------------
+// trackSelectionChanged
+//---------------------------------------------------------
+
+void Arranger::trackSelectionChanged()
+ {
+ TrackList* tracks = song->tracks();
+ Track* track = 0;
+ for (iTrack t = tracks->begin(); t != tracks->end(); ++t) {
+ if ((*t)->selected()) {
+ track = *t;
+ break;
+ }
+ }
+ if (track == selected)
+ return;
+ selected = track;
+ updateTrackInfo(-1);
+ }
+
+//---------------------------------------------------------
+// modeChange
+//---------------------------------------------------------
+
+void Arranger::modeChange(int mode)
+ {
+ song->setMType(MType(mode));
+ updateTrackInfo(-1);
+ }
+
+//---------------------------------------------------------
+// setMode
+//---------------------------------------------------------
+
+void Arranger::setMode(int mode)
+ {
+ typeBox->blockSignals(true); //
+ // This will only set if different.
+ typeBox->setCurrentIndex(mode);
+ typeBox->blockSignals(false); //
+ }
+
+void Arranger::showTrackViews()
+{
+ TrackViewEditor* ted = new TrackViewEditor(this);
+ ted->show();
+}
+//---------------------------------------------------------
+// writeStatus
+//---------------------------------------------------------
+
+void Arranger::writeStatus(int level, Xml& xml)
+ {
+ xml.tag(level++, "arranger");
+ xml.intTag(level, "info", ib->isChecked());
+ split->writeStatus(level, xml);
+ list->writeStatus(level, xml, "list");
+
+ xml.intTag(level, "xpos", hscroll->pos());
+ xml.intTag(level, "xmag", hscroll->mag());
+ xml.intTag(level, "ypos", vscroll->value());
+ xml.etag(level, "arranger");
+ }
+
+//---------------------------------------------------------
+// readStatus
+//---------------------------------------------------------
+
+void Arranger::readStatus(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token(xml.parse());
+ const QString& tag(xml.s1());
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "info")
+ showTrackinfoFlag = xml.parseInt();
+ else if (tag == split->objectName())
+ split->readStatus(xml);
+ else if (tag == "list")
+ list->readStatus(xml, "list");
+ else if (tag == "xmag")
+ hscroll->setMag(xml.parseInt());
+ else if (tag == "xpos") {
+ int hpos = xml.parseInt();
+ hscroll->setPos(hpos);
+ }
+ else if (tag == "ypos")
+ vscroll->setValue(xml.parseInt());
+ else
+ xml.unknown("Arranger");
+ break;
+ case Xml::TagEnd:
+ if (tag == "arranger") {
+ ib->setChecked(showTrackinfoFlag);
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// setRaster
+//---------------------------------------------------------
+
+void Arranger::_setRaster(int index)
+ {
+ static int rasterTable[] = {
+ 1, 0, 768, 384, 192, 96
+ };
+ _raster = rasterTable[index];
+ // Set the audio record part snapping.
+ song->setArrangerRaster(_raster);
+ canvas->redraw();
+ }
+
+//---------------------------------------------------------
+// reset
+//---------------------------------------------------------
+
+void Arranger::reset()
+ {
+ canvas->setXPos(0);
+ canvas->setYPos(0);
+ hscroll->setPos(0);
+ vscroll->setValue(0);
+ time->setXPos(0);
+ time->setYPos(0);
+ }
+
+//---------------------------------------------------------
+// cmd
+//---------------------------------------------------------
+
+void Arranger::cmd(int cmd)
+ {
+ int ncmd;
+ switch (cmd) {
+ case CMD_CUT_PART:
+ ncmd = PartCanvas::CMD_CUT_PART;
+ break;
+ case CMD_COPY_PART:
+ ncmd = PartCanvas::CMD_COPY_PART;
+ break;
+ case CMD_PASTE_PART:
+ ncmd = PartCanvas::CMD_PASTE_PART;
+ break;
+ case CMD_PASTE_CLONE_PART:
+ ncmd = PartCanvas::CMD_PASTE_CLONE_PART;
+ break;
+ case CMD_PASTE_PART_TO_TRACK:
+ ncmd = PartCanvas::CMD_PASTE_PART_TO_TRACK;
+ break;
+ case CMD_PASTE_CLONE_PART_TO_TRACK:
+ ncmd = PartCanvas::CMD_PASTE_CLONE_PART_TO_TRACK;
+ break;
+ case CMD_INSERT_PART:
+ ncmd = PartCanvas::CMD_INSERT_PART;
+ break;
+ case CMD_INSERT_EMPTYMEAS:
+ ncmd = PartCanvas::CMD_INSERT_EMPTYMEAS;
+ break;
+ default:
+ return;
+ }
+ canvas->cmd(ncmd);
+ }
+
+//---------------------------------------------------------
+// globalPitchChanged
+//---------------------------------------------------------
+
+void Arranger::globalPitchChanged(int val)
+ {
+ song->setGlobalPitchShift(val);
+ }
+
+//---------------------------------------------------------
+// globalTempoChanged
+//---------------------------------------------------------
+
+void Arranger::globalTempoChanged(int val)
+ {
+ audio->msgSetGlobalTempo(val);
+ song->tempoChanged();
+ }
+
+//---------------------------------------------------------
+// setTempo50
+//---------------------------------------------------------
+
+void Arranger::setTempo50()
+ {
+ setGlobalTempo(50);
+ }
+
+//---------------------------------------------------------
+// setTempo100
+//---------------------------------------------------------
+
+void Arranger::setTempo100()
+ {
+ setGlobalTempo(100);
+ }
+
+//---------------------------------------------------------
+// setTempo200
+//---------------------------------------------------------
+
+void Arranger::setTempo200()
+ {
+ setGlobalTempo(200);
+ }
+
+//---------------------------------------------------------
+// setGlobalTempo
+//---------------------------------------------------------
+
+void Arranger::setGlobalTempo(int val)
+ {
+ if(val != globalTempoSpinBox->value())
+ globalTempoSpinBox->setValue(val);
+ }
+
+//---------------------------------------------------------
+// verticalScrollSetYpos
+//---------------------------------------------------------
+void Arranger::verticalScrollSetYpos(unsigned ypos)
+ {
+ vscroll->setValue(ypos);
+ }
+
+//---------------------------------------------------------
+// trackInfoScroll
+//---------------------------------------------------------
+
+void Arranger::trackInfoScroll(int y)
+ {
+ if (trackInfo->visibleWidget())
+ trackInfo->visibleWidget()->move(0, -y);
+ }
+
+//---------------------------------------------------------
+// WidgetStack
+//---------------------------------------------------------
+
+WidgetStack::WidgetStack(QWidget* parent, const char* name)
+ : QWidget(parent)
+ {
+ setObjectName(name);
+ top = -1;
+ }
+
+//---------------------------------------------------------
+// raiseWidget
+//---------------------------------------------------------
+
+void WidgetStack::raiseWidget(int idx)
+ {
+ if (top != -1) {
+ if (stack[top])
+ stack[top]->hide();
+ }
+ top = idx;
+ if (idx == -1)
+ return;
+ int n = stack.size();
+ if (idx >= n)
+ return;
+ if (stack[idx])
+ stack[idx]->show();
+ }
+
+//---------------------------------------------------------
+// addWidget
+//---------------------------------------------------------
+
+void WidgetStack::addWidget(QWidget* w, unsigned int n)
+ {
+ if (w)
+ w->hide();
+ if (stack.size() <= n )
+ stack.push_back(w);
+ else
+ stack[n] = w;
+ }
+
+QWidget* WidgetStack::getWidget(unsigned int n)
+ {
+ if (stack.size() <= n )
+ return 0;
+ return stack[n];
+ }
+
+//---------------------------------------------------------
+// visibleWidget
+//---------------------------------------------------------
+
+QWidget* WidgetStack::visibleWidget() const
+ {
+ if (top != -1)
+ return stack[top];
+ return 0;
+ }
+
+//---------------------------------------------------------
+// minimumSizeHint
+//---------------------------------------------------------
+
+QSize WidgetStack::minimumSizeHint() const
+ {
+ if (top == -1)
+ {
+ //printf("WidgetStack::minimumSizeHint top is -1\n");
+ return (QSize(0, 0));
+ }
+ QSize s(0,0);
+ for (unsigned int i = 0; i < stack.size(); ++i) {
+ if (stack[i]) {
+ QSize ss = stack[i]->minimumSizeHint();
+ if (!ss.isValid())
+ ss = stack[i]->minimumSize();
+ s = s.expandedTo(ss);
+ }
+ }
+ //printf("WidgetStack::minimumSizeHint width:%d height:%d\n", s.width(), s.height()); // REMOVE Tim.
+ return s;
+ }
+
+//---------------------------------------------------------
+// clear
+//---------------------------------------------------------
+
+void Arranger::clear()
+ {
+ AudioStrip* w = (AudioStrip*)(trackInfo->getWidget(2));
+ if (w)
+ delete w;
+ trackInfo->addWidget(0, 2);
+ selected = 0;
+ }
+
+void Arranger::wheelEvent(QWheelEvent* ev)
+ {
+ emit redirectWheelEvent(ev);
+ }
+
+void Arranger::controllerChanged(Track *t)
+{
+ canvas->controllerChanged(t);
+}
+
+//---------------------------------------------------------
+// showTrackInfo
+//---------------------------------------------------------
+
+void Arranger::showTrackInfo(bool flag)
+ {
+ showTrackinfoFlag = flag;
+ trackInfo->setVisible(flag);
+ infoScroll->setVisible(flag);
+ updateTrackInfo(-1);
+ }
+
+//---------------------------------------------------------
+// genTrackInfo
+//---------------------------------------------------------
+
+void Arranger::genTrackInfo(QWidget* parent)
+ {
+ trackInfo = new WidgetStack(parent, "trackInfoStack");
+ //trackInfo->setFocusPolicy(Qt::TabFocus); // p4.0.9
+ //trackInfo->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
+
+ noTrackInfo = new QWidget(trackInfo);
+ noTrackInfo->setAutoFillBackground(true);
+ QPixmap *noInfoPix = new QPixmap(160, 1000); //muse_leftside_logo_xpm);
+ const QPixmap *logo = new QPixmap(*museLeftSideLogo);
+ noInfoPix->fill(noTrackInfo->palette().color(QPalette::Window) );
+ QPainter p(noInfoPix);
+ p.drawPixmap(10, 0, *logo, 0,0, logo->width(), logo->height());
+
+ QPalette palette;
+ palette.setBrush(noTrackInfo->backgroundRole(), QBrush(*noInfoPix));
+ noTrackInfo->setPalette(palette);
+ noTrackInfo->setGeometry(0, 0, 65, 200);
+ noTrackInfo->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding));
+
+ midiTrackInfo = new MidiTrackInfo(trackInfo);
+ //midiTrackInfo->setFocusPolicy(Qt::TabFocus); // p4.0.9
+ //midiTrackInfo->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum));
+ trackInfo->addWidget(noTrackInfo, 0);
+ trackInfo->addWidget(midiTrackInfo, 1);
+ trackInfo->addWidget(0, 2);
+
+/// genMidiTrackInfo();
+ }
+
+//---------------------------------------------------------
+// updateTrackInfo
+//---------------------------------------------------------
+
+void Arranger::updateTrackInfo(int flags)
+ {
+ if (!showTrackinfoFlag) {
+ switchInfo(-1);
+ return;
+ }
+ if (selected == 0) {
+ switchInfo(0);
+ return;
+ }
+ if (selected->isMidiTrack()) {
+ switchInfo(1);
+ // If a new part was selected, and only if it's different.
+ if((flags & SC_SELECTION) && midiTrackInfo->track() != selected)
+ // Set a new track and do a complete update.
+ midiTrackInfo->setTrack(selected);
+ else
+ // Otherwise just regular update with specific flags.
+ midiTrackInfo->updateTrackInfo(flags);
+ }
+ else {
+ switchInfo(2);
+ }
+ }
+
+//---------------------------------------------------------
+// switchInfo
+//---------------------------------------------------------
+
+void Arranger::switchInfo(int n)
+ {
+ if (n == 2) {
+ AudioStrip* w = (AudioStrip*)(trackInfo->getWidget(2));
+ if (w == 0 || selected != w->getTrack()) {
+ if (w)
+ delete w;
+ w = new AudioStrip(trackInfo, (AudioTrack*)selected);
+ switch(selected->type()) {/*{{{*/
+ case Track::AUDIO_OUTPUT:
+ w->setObjectName("MixerAudioOutStrip");
+ break;
+ case Track::AUDIO_GROUP:
+ w->setObjectName("MixerAudioGroupStrip");
+ break;
+ case Track::AUDIO_AUX:
+ w->setObjectName("MixerAuxStrip");
+ break;
+ case Track::WAVE:
+ w->setObjectName("MixerWaveStrip");
+ break;
+ case Track::AUDIO_INPUT:
+ w->setObjectName("MixerAudioInStrip");
+ break;
+ case Track::AUDIO_SOFTSYNTH:
+ w->setObjectName("MixerSynthStrip");
+ break;
+ case Track::MIDI:
+ case Track::DRUM:
+ {
+ w->setObjectName("MidiTrackStrip");
+ }
+ break;
+ }/*}}}*/
+ //w->setFocusPolicy(Qt::TabFocus); // p4.0.9
+ connect(song, SIGNAL(songChanged(int)), w, SLOT(songChanged(int)));
+ connect(muse, SIGNAL(configChanged()), w, SLOT(configChanged()));
+ w->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
+ trackInfo->addWidget(w, 2);
+ w->show();
+ //setTabOrder(midiTrackInfo, w); // p4.0.9
+ tgrid->activate();
+ tgrid->update(); // muse-2 Qt4
+ }
+ }
+ if (trackInfo->curIdx() == n)
+ return;
+ trackInfo->raiseWidget(n);
+ tgrid->activate();
+ tgrid->update(); // muse-2 Qt4
+ }
+
+/*
+QSize WidgetStack::minimumSize() const
+{
+ printf("WidgetStack::minimumSize\n"); // REMOVE Tim.
+ return minimumSizeHint();
+}
+
+int WidgetStack::minimumHeight() const
+{
+ printf("WidgetStack::minimumHeight\n"); // REMOVE Tim.
+ return minimumSizeHint().height();
+}
+*/
diff --git a/attic/muse2-oom/muse2/muse/arranger/arranger.h b/attic/muse2-oom/muse2/muse/arranger/arranger.h
new file mode 100644
index 00000000..dde7c48a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/arranger/arranger.h
@@ -0,0 +1,173 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: arranger.h,v 1.17.2.15 2009/11/14 03:37:48 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __ARRANGER_H__
+#define __ARRANGER_H__
+
+#include <vector>
+
+#include "midieditor.h"
+#include "pcanvas.h"
+#include "trackautomationview.h"
+
+class QAction;
+class QCheckBox;
+class QMainWindow;
+class QMenu;
+class QScrollBar;
+class QToolButton;
+class QWheelEvent;
+class QKeyEvent;
+//class QStackedWidget;
+
+class Header;
+class TList;
+class ScrollScale;
+class MTScale;
+class Track;
+class Xml;
+class Splitter;
+class LabelCombo;
+class PosLabel;
+class MidiTrackInfo;
+class TLLayout;
+class WidgetStack;
+class AudioStrip;
+class SpinBox;
+
+//---------------------------------------------------------
+// WidgetStack
+//---------------------------------------------------------
+
+class WidgetStack : public QWidget {
+ Q_OBJECT
+ std::vector<QWidget*> stack;
+ int top;
+
+ public:
+ WidgetStack(QWidget* parent, const char* name = 0);
+ void raiseWidget(int idx);
+ void addWidget(QWidget* w, unsigned int idx);
+ QWidget* getWidget(unsigned int idx);
+ QWidget* visibleWidget() const;
+ int curIdx() const { return top; }
+ virtual QSize minimumSizeHint() const;
+ //QSize minimumSize() const;
+ //int minimumHeight() const;
+ };
+
+//---------------------------------------------------------
+// Arranger
+//---------------------------------------------------------
+
+class Arranger : public QWidget {
+ Q_OBJECT
+
+ int _quant, _raster;
+ PartCanvas* canvas;
+ ScrollScale* hscroll;
+ QScrollBar* vscroll;
+ TList* list;
+ Header* header;
+ MTScale* time;
+ SpinBox* lenEntry;
+ bool showTrackinfoFlag;
+ WidgetStack* trackInfo;
+ //QStackedWidget* trackInfo;
+ QScrollBar* infoScroll;
+ //MidiTrackInfoBase* midiTrackInfo;
+ MidiTrackInfo* midiTrackInfo;
+ AudioStrip* waveTrackInfo;
+ QWidget* noTrackInfo;
+ TLLayout* tgrid;
+
+ Track* selected;
+
+ LabelCombo* typeBox;
+ QToolButton* ib;
+ int trackInfoType;
+ Splitter* split;
+ ///QMenu* pop;
+ int songType;
+ PosLabel* cursorPos;
+ SpinBox* globalTempoSpinBox;
+ SpinBox* globalPitchSpinBox;
+
+ unsigned cursVal;
+ void genTrackInfo(QWidget* parent);
+ void genMidiTrackInfo();
+ void genWaveTrackInfo();
+ void switchInfo(int);
+ void setHeaderToolTips();
+ void setHeaderWhatsThis();
+
+ private slots:
+ void _setRaster(int);
+ void songlenChanged(int);
+ void showTrackInfo(bool);
+ void trackSelectionChanged();
+ void trackInfoScroll(int);
+ void songChanged(int);
+ void modeChange(int);
+ void setTime(unsigned);
+ void headerMoved();
+ void globalPitchChanged(int);
+ void globalTempoChanged(int);
+ void setTempo50();
+ void setTempo100();
+ void setTempo200();
+ //void seek();
+ void verticalScrollSetYpos(unsigned);
+ void showTrackViews();
+
+ signals:
+ void redirectWheelEvent(QWheelEvent*);
+ void editPart(Track*);
+ void selectionChanged();
+ void dropSongFile(const QString&);
+ void dropMidiFile(const QString&);
+ void startEditor(PartList*, int);
+ void toolChanged(int);
+ //void addMarker(int);
+ void setUsedTool(int);
+
+
+ protected:
+ virtual void wheelEvent(QWheelEvent* e);
+
+ public slots:
+ void dclickPart(Track*);
+ void setTool(int);
+ void updateTrackInfo(int flags);
+ void configChanged();
+ void controllerChanged(Track *t);
+
+ public:
+ enum { CMD_CUT_PART, CMD_COPY_PART, CMD_PASTE_PART, CMD_PASTE_CLONE_PART, CMD_PASTE_PART_TO_TRACK, CMD_PASTE_CLONE_PART_TO_TRACK,
+ CMD_INSERT_PART, CMD_INSERT_EMPTYMEAS };
+
+ Arranger(QMainWindow* parent, const char* name = 0);
+
+ PartCanvas* getCanvas() { return canvas; }
+ void setMode(int);
+ void reset();
+
+ void writeStatus(int level, Xml&);
+ void readStatus(Xml&);
+
+ Track* curTrack() const { return selected; }
+ void cmd(int);
+ bool isSingleSelection() { return canvas->isSingleSelection(); }
+ int selectionSize() { return canvas->selectionSize(); }
+ void setGlobalTempo(int);
+ void clear();
+
+ unsigned cursorValue() { return cursVal; }
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/arranger/pcanvas.cpp b/attic/muse2-oom/muse2/muse/arranger/pcanvas.cpp
new file mode 100644
index 00000000..3e6919a7
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/arranger/pcanvas.cpp
@@ -0,0 +1,2977 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: pcanvas.cpp,v 1.48.2.26 2009/11/22 11:08:33 spamatica Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <sys/stat.h>
+#include <sys/mman.h>
+#include <errno.h>
+#include <values.h>
+#include <uuid/uuid.h>
+#include <math.h>
+
+#include <QClipboard>
+#include <QLineEdit>
+#include <QMenu>
+#include <QMessageBox>
+#include <QPainter>
+#include <QUrl>
+
+#include "widgets/tools.h"
+#include "pcanvas.h"
+#include "midieditor.h"
+#include "globals.h"
+#include "icons.h"
+#include "event.h"
+#include "xml.h"
+#include "wave.h"
+#include "audio.h"
+#include "shortcuts.h"
+#include "gconfig.h"
+#include "app.h"
+#include "filedialog.h"
+#include "marker/marker.h"
+
+// Moved into global config by Tim.
+/*
+const char* partColorNames[] = {
+ "Default",
+ "Refrain",
+ "Bridge",
+ "Intro",
+ "Coda",
+ "Chorus",
+ "Solo",
+ "Brass",
+ "Percussion",
+ "Drums",
+ "Guitar",
+ "Bass",
+ "Flute",
+ "Strings",
+ "Keyboard",
+ "Piano",
+ "Saxophon",
+ };
+*/
+
+/*
+//---------------------------------------------------------
+// ColorListItem
+//---------------------------------------------------------
+
+class ColorListItem { //: public QCustomMenuItem { ddskrjo
+ QColor color;
+ int h;
+ int fontheight;
+ QString label;
+ virtual QSize sizeHint() { return QSize(80, h); }
+ virtual void paint(QPainter* p, const QColorGroup&, bool act, bool enabled, int x, int y, int w, int h)
+ {
+ p->fillRect(x+5, y+2, h-4, h-4, QBrush(color));
+ p->drawText(x+5 + h - 4 + 3, y+(fontheight * 3) / 4, label);
+ }
+
+ public:
+ ColorListItem(const QColor& c, int _h, int _fh, const char* txt)
+ : color(c), h(_h), fontheight(_fh), label(txt) {
+ }
+ QString text() const { return QString("PartColor"); }
+ };
+*/
+// ORCAN : colorRect does the same job as the above class.
+// Shall we get rid of the class?
+
+//---------------------------------------------------------
+// colorRect
+// paints a rectangular icon with a given color
+//---------------------------------------------------------
+
+QIcon colorRect(const QColor& color, int width, int height) {
+ QPainter painter;
+ QPixmap image(width, height);
+ painter.begin(&image);
+ painter.setBrush(color);
+ QRect rectangle(0, 0, width, height);
+ painter.drawRect(rectangle);
+ painter.end();
+ QIcon icon(image);
+ return icon;
+}
+
+//---------------------------------------------------------
+// NPart
+//---------------------------------------------------------
+
+NPart::NPart(Part* e) : CItem(Event(), e)
+ {
+ int th = track()->height();
+ int y = track()->y();
+ //printf("NPart::NPart track name:%s, y:%d h:%d\n", track()->name().toLatin1().constData(), y, th);
+
+ ///setPos(QPoint(e->tick(), y + 1));
+ setPos(QPoint(e->tick(), y));
+
+ ///setBBox(QRect(e->tick(), y + 1, e->lenTick(), th));
+ // NOTE: For adjustable border size: If using a two-pixel border width while drawing, use second line.
+ // If one-pixel width, use first line. Tim.
+ //setBBox(QRect(e->tick(), y, e->lenTick(), th));
+ setBBox(QRect(e->tick(), y + 1, e->lenTick(), th));
+ }
+
+//---------------------------------------------------------
+// PartCanvas
+//---------------------------------------------------------
+
+PartCanvas::PartCanvas(int* r, QWidget* parent, int sx, int sy)
+ : Canvas(parent, sx, sy)
+ {
+ setAcceptDrops(true);
+ _raster = r;
+
+ setFocusPolicy(Qt::StrongFocus);
+ // Defaults:
+ lineEditor = 0;
+ editMode = false;
+
+ tracks = song->tracks();
+ setMouseTracking(true);
+ drag = DRAG_OFF;
+ curColorIndex = 0;
+ partsChanged();
+ }
+
+//---------------------------------------------------------
+// y2pitch
+//---------------------------------------------------------
+
+int PartCanvas::y2pitch(int y) const
+ {
+ TrackList* tl = song->tracks();
+ int yy = 0;
+ int idx = 0;
+ for (iTrack it = tl->begin(); it != tl->end(); ++it, ++idx) {
+ int h = (*it)->height();
+ // if ((y >= yy) && (y < yy+h))
+ if (y < yy+h)
+ break;
+ yy += h;
+ }
+ return idx;
+ }
+
+//---------------------------------------------------------
+// pitch2y
+//---------------------------------------------------------
+
+int PartCanvas::pitch2y(int p) const
+ {
+ TrackList* tl = song->tracks();
+ int yy = 0;
+ int idx = 0;
+ for (iTrack it = tl->begin(); it != tl->end(); ++it, ++idx) {
+ if (idx == p)
+ break;
+ yy += (*it)->height();
+ }
+ return yy;
+ }
+
+//---------------------------------------------------------
+// leaveEvent
+//---------------------------------------------------------
+
+void PartCanvas::leaveEvent(QEvent*)
+ {
+ emit timeChanged(MAXINT);
+ }
+
+//---------------------------------------------------------
+// returnPressed
+//---------------------------------------------------------
+
+void PartCanvas::returnPressed()
+ {
+ lineEditor->hide();
+ Part* oldPart = editPart->part();
+ Part* newPart = oldPart->clone();
+ //printf("PartCanvas::returnPressed before msgChangePart oldPart refs:%d Arefs:%d newPart refs:%d Arefs:%d\n", oldPart->events()->refCount(), oldPart->events()->arefCount(), newPart->events()->refCount(), newPart->events()->arefCount());
+
+ newPart->setName(lineEditor->text());
+ // Indicate do undo, and do port controller values but not clone parts.
+ //audio->msgChangePart(oldPart, newPart);
+ audio->msgChangePart(oldPart, newPart, true, true, false);
+ //printf("PartCanvas::returnPressed after msgChangePart oldPart refs:%d Arefs:%d newPart refs:%d Arefs:%d\n", oldPart->events()->refCount(), oldPart->events()->arefCount(), newPart->events()->refCount(), newPart->events()->arefCount());
+
+ editMode = false;
+ }
+
+//---------------------------------------------------------
+// viewMouseDoubleClick
+//---------------------------------------------------------
+
+void PartCanvas::viewMouseDoubleClickEvent(QMouseEvent* event)
+ {
+ if (_tool != PointerTool) {
+ viewMousePressEvent(event);
+ return;
+ }
+ QPoint cpos = event->pos();
+ curItem = items.find(cpos);
+ bool shift = event->modifiers() & Qt::ShiftModifier;
+ if (curItem) {
+ if (event->button() == Qt::LeftButton && shift) {
+ editPart = (NPart*)curItem;
+ QRect r = map(curItem->bbox());
+ if (lineEditor == 0) {
+ lineEditor = new QLineEdit(this);
+ lineEditor->setFrame(true);
+ }
+ editMode = true;
+ lineEditor->setGeometry(r);
+ lineEditor->setText(editPart->name());
+ lineEditor->setFocus();
+ lineEditor->show();
+ }
+ else if (event->button() == Qt::LeftButton) {
+ deselectAll();
+ selectItem(curItem, true);
+ emit dclickPart(((NPart*)(curItem))->track());
+ }
+ }
+ //
+ // double click creates new part between left and
+ // right mark
+
+ else {
+ TrackList* tl = song->tracks();
+ iTrack it;
+ int yy = 0;
+ int y = event->y();
+ for (it = tl->begin(); it != tl->end(); ++it) {
+ int h = (*it)->height();
+ if (y >= yy && y < (yy + h))
+ break;
+ yy += h;
+ }
+ if (pos[2] - pos[1] > 0 && it != tl->end()) {
+ Track* track = *it;
+ switch(track->type()) {
+ case Track::MIDI:
+ case Track::DRUM:
+ {
+ MidiPart* part = new MidiPart((MidiTrack*)track);
+ part->setTick(pos[1]);
+ part->setLenTick(pos[2]-pos[1]);
+ part->setName(track->name());
+ NPart* np = new NPart(part);
+ items.add(np);
+ deselectAll();
+ part->setSelected(true);
+ audio->msgAddPart(part);
+ }
+ break;
+ case Track::WAVE:
+ case Track::AUDIO_OUTPUT:
+ case Track::AUDIO_INPUT:
+ case Track::AUDIO_GROUP:
+ case Track::AUDIO_AUX:
+ case Track::AUDIO_SOFTSYNTH:
+ break;
+ }
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// startUndo
+//---------------------------------------------------------
+
+void PartCanvas::startUndo(DragType)
+ {
+ song->startUndo();
+ }
+
+//---------------------------------------------------------
+// endUndo
+//---------------------------------------------------------
+
+void PartCanvas::endUndo(DragType t, int flags)
+ {
+ song->endUndo(flags | ((t == MOVE_COPY || t == MOVE_CLONE)
+ ? SC_PART_INSERTED : SC_PART_MODIFIED));
+ }
+
+//---------------------------------------------------------
+// moveCanvasItems
+//---------------------------------------------------------
+
+void PartCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtype, int*)
+{
+ /*
+ if(editor->parts()->empty())
+ return;
+
+ //struct p2c
+ //{
+ // Part* newp;
+ // int xdiff;
+ //}
+
+ //std::set<Part*> parts2change;
+ //typedef std::set<Part*>::iterator iptc;
+ std::map<Part*, Part*> parts2change;
+ typedef std::map<Part*, Part*>::iterator iP2C;
+
+ int modified = 0;
+ for(iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip)
+ {
+ Part* part = ip->second;
+ if(!part)
+ continue;
+
+ int npartoffset = 0;
+ for(iCItem ici = items.begin(); ici != items.end(); ++ici)
+ {
+ CItem* ci = ici->second;
+ //Part* pt = ci->part();
+ //if(!pt)
+ if(ci->part() != part)
+ continue;
+
+ int x = ci->pos().x() + dx;
+ int y = pitch2y(y2pitch(ci->pos().y()) + dp);
+ QPoint newpos = raster(QPoint(x, y));
+
+ // Test moving the item...
+
+ //int offset = testMoveItem(ci, newpos, dragtype);
+ NEvent* nevent = (NEvent*) ci;
+ Event event = nevent->event();
+ //int npitch = y2pitch(newpos.y());
+ x = newpos.x();
+ if (x < 0)
+ x = 0;
+
+ int ntick = editor->rasterVal(x) - part->tick();
+ if (ntick < 0)
+ ntick = 0;
+ int diff = ntick + event.lenTick() - part->lenTick();
+
+ // If moving the item would require a new part size...
+ if(diff > npartoffset)
+ npartoffset = diff;
+ }
+
+ if(npartoffset > 0)
+ {
+ // Create new part...
+ // if there are several events that are moved outside the part, it will be recreated for each
+ // so the part _in_ the event will not be valid, ask the authority.
+ Part* newPart = part->clone();
+ //Part* newPart = Canvas::part()->clone();
+
+ newPart->setLenTick(newPart->lenTick() + npartoffset);
+ audio->msgChangePart(part, newPart,false);
+
+ modified = SC_PART_MODIFIED;
+
+ // BUG FIX: #1650953
+ // Added by T356.
+ // Fixes posted "select and drag past end of part - crashing" bug
+ for(iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip)
+ {
+ if(ip->second == part)
+ {
+ editor->parts()->erase(ip);
+ break;
+ }
+ }
+
+ editor->parts()->add(newPart);
+ if(parts2change.find(part) == parts2change.end())
+ parts2change.insert(std::pair<Part*, Part*> (part, newPart));
+
+// part = newPart; // reassign
+// item->setPart(part);
+// item->setEvent(newEvent);
+// curPart = part;
+// curPartId = curPart->sn();
+
+ }
+ }
+*/
+
+// int modified = 0;
+ for(iCItem ici = items.begin(); ici != items.end(); ++ici)
+ {
+ CItem* ci = ici->second;
+
+ // If this item's part is in the parts2change list, change the item's part to the new part.
+ //Part* pt = ci->part();
+ //iP2C ip2c = parts2change.find(pt);
+ //if(ip2c != parts2change.end())
+ // ci->setPart(ip2c->second);
+
+ int x = ci->pos().x();
+ int y = ci->pos().y();
+ int nx = x + dx;
+ int ny = pitch2y(y2pitch(y) + dp);
+ QPoint newpos = raster(QPoint(nx, ny));
+ selectItem(ci, true);
+
+ if(moveItem(ci, newpos, dtype))
+ ci->move(newpos);
+ if(moving.size() == 1) {
+ itemReleased(curItem, newpos);
+ }
+ if(dtype == MOVE_COPY || dtype == MOVE_CLONE)
+ selectItem(ci, false);
+ }
+
+
+ //if(pflags)
+ // *pflags = modified;
+}
+
+//---------------------------------------------------------
+// moveItem
+// return false, if copy/move not allowed
+//---------------------------------------------------------
+
+// Changed by T356.
+//bool PartCanvas::moveItem(CItem* item, const QPoint& newpos, DragType t, int*)
+bool PartCanvas::moveItem(CItem* item, const QPoint& newpos, DragType t)
+ {
+ NPart* npart = (NPart*) item;
+ Part* spart = npart->part();
+ Track* track = npart->track();
+ unsigned dtick = newpos.x();
+ unsigned ntrack = y2pitch(item->mp().y());
+ Track::TrackType type = track->type();
+ if (tracks->index(track) == ntrack && (dtick == spart->tick())) {
+ return false;
+ }
+ if (ntrack >= tracks->size()) {
+ ntrack = tracks->size();
+ Track* newTrack = song->addTrack(int(type));
+ if (type == Track::WAVE) {
+ WaveTrack* st = (WaveTrack*) track;
+ WaveTrack* dt = (WaveTrack*) newTrack;
+ dt->setChannels(st->channels());
+ }
+ emit tracklistChanged();
+ }
+ Track* dtrack = tracks->index(ntrack);
+
+ if (dtrack->type() != type) {
+ QMessageBox::critical(this, QString("MusE"),
+ tr("Cannot copy/move/clone to different Track-Type"));
+ return false;
+ }
+
+ Part* dpart;
+ //bool clone = (t == MOVE_CLONE) || (spart->events()->arefCount() > 1);
+ //bool clone = (t == MOVE_CLONE);
+ bool clone = (t == MOVE_CLONE || (t == MOVE_COPY && spart->events()->arefCount() > 1));
+
+ if(t == MOVE_MOVE)
+ {
+ // This doesn't increment aref count, and doesn't chain clones.
+ // It also gives the new part a new serial number, but it is
+ // overwritten with the old one by Song::changePart(), from Audio::msgChangePart() below.
+ dpart = spart->clone();
+ dpart->setTrack(dtrack);
+ }
+ else
+ // This increments aref count if cloned, and chains clones.
+ // It also gives the new part a new serial number.
+ dpart = dtrack->newPart(spart, clone);
+
+ dpart->setTick(dtick);
+
+ //printf("PartCanvas::moveItem before add/changePart clone:%d spart:%p events:%p refs:%d Arefs:%d sn:%d dpart:%p events:%p refs:%d Arefs:%d sn:%d\n", clone, spart, spart->events(), spart->events()->refCount(), spart->events()->arefCount(), spart->sn(), dpart, dpart->events(), dpart->events()->refCount(), dpart->events()->arefCount(), dpart->sn());
+
+ if(t == MOVE_MOVE)
+ item->setPart(dpart);
+ //if (!clone) {
+ if (t == MOVE_COPY && !clone) {
+ //
+ // Copy Events
+ //
+ EventList* se = spart->events();
+ EventList* de = dpart->events();
+ for (iEvent i = se->begin(); i != se->end(); ++i) {
+ Event oldEvent = i->second;
+ Event ev = oldEvent.clone();
+ de->add(ev);
+ }
+ }
+ if (t == MOVE_COPY || t == MOVE_CLONE) {
+ // These will not increment ref count, and will not chain clones...
+ if (dtrack->type() == Track::WAVE)
+ audio->msgAddPart((WavePart*)dpart,false);
+ else
+ audio->msgAddPart(dpart,false);
+ }
+ else if (t == MOVE_MOVE) {
+ dpart->setSelected(spart->selected());
+ // These will increment ref count if not a clone, and will chain clones...
+ if (dtrack->type() == Track::WAVE)
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangePart((WavePart*)spart, (WavePart*)dpart,false);
+ audio->msgChangePart((WavePart*)spart, (WavePart*)dpart, false, false, false);
+ else
+ // Indicate no undo, and do port controller values but not clone parts.
+ //audio->msgChangePart(spart, dpart, false);
+ audio->msgChangePart(spart, dpart, false, true, false);
+
+ spart->setSelected(false);
+ }
+ //printf("PartCanvas::moveItem after add/changePart spart:%p events:%p refs:%d Arefs:%d dpart:%p events:%p refs:%d Arefs:%d\n", spart, spart->events(), spart->events()->refCount(), spart->events()->arefCount(), dpart, dpart->events(), dpart->events()->refCount(), dpart->events()->arefCount());
+
+ if (song->len() < (dpart->lenTick() + dpart->tick()))
+ song->setLen(dpart->lenTick() + dpart->tick());
+ //endUndo(t);
+ return true;
+ }
+
+//---------------------------------------------------------
+// raster
+//---------------------------------------------------------
+
+QPoint PartCanvas::raster(const QPoint& p) const
+ {
+ int y = pitch2y(y2pitch(p.y()));
+ int x = p.x();
+ if (x < 0)
+ x = 0;
+ x = AL::sigmap.raster(x, *_raster);
+ if (x < 0)
+ x = 0;
+ return QPoint(x, y);
+ }
+
+//---------------------------------------------------------
+// partsChanged
+//---------------------------------------------------------
+
+void PartCanvas::partsChanged()
+ {
+ items.clear();
+ int idx = 0;
+ for (iTrack t = tracks->begin(); t != tracks->end(); ++t) {
+ PartList* pl = (*t)->parts();
+ for (iPart i = pl->begin(); i != pl->end(); ++i) {
+ NPart* np = new NPart(i->second);
+ items.add(np);
+ if (i->second->selected()) {
+ selectItem(np, true);
+ }
+ }
+ ++idx;
+ }
+ redraw();
+ }
+
+//---------------------------------------------------------
+// updateSelection
+//---------------------------------------------------------
+
+void PartCanvas::updateSelection()
+ {
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ NPart* part = (NPart*)(i->second);
+ part->part()->setSelected(i->second->isSelected());
+ }
+ emit selectionChanged();
+ redraw();
+ }
+
+//---------------------------------------------------------
+// resizeItem
+//---------------------------------------------------------
+
+void PartCanvas::resizeItem(CItem* i, bool noSnap)
+ {
+ Track* t = ((NPart*)(i))->track();
+ Part* p = ((NPart*)(i))->part();
+
+ int pos = p->tick() + i->width();
+ int snappedpos = p->tick();
+ if (!noSnap) {
+ snappedpos = AL::sigmap.raster(pos, *_raster);
+ }
+ unsigned int newwidth = snappedpos - p->tick();
+ if (newwidth == 0)
+ newwidth = AL::sigmap.rasterStep(p->tick(), *_raster);
+
+ song->cmdResizePart(t, p, newwidth);
+ }
+
+//---------------------------------------------------------
+// newItem
+// first create local Item
+//---------------------------------------------------------
+
+CItem* PartCanvas::newItem(const QPoint& pos, int)
+ {
+ int x = pos.x();
+ if (x < 0)
+ x = 0;
+ x = AL::sigmap.raster(x, *_raster);
+ unsigned trackIndex = y2pitch(pos.y());
+ if (trackIndex >= tracks->size())
+ return 0;
+ Track* track = tracks->index(trackIndex);
+ if(!track)
+ return 0;
+
+ Part* pa = 0;
+ NPart* np = 0;
+ switch(track->type()) {
+ case Track::MIDI:
+ case Track::DRUM:
+ pa = new MidiPart((MidiTrack*)track);
+ pa->setTick(x);
+ pa->setLenTick(0);
+ break;
+ case Track::WAVE:
+ pa = new WavePart((WaveTrack*)track);
+ pa->setTick(x);
+ pa->setLenTick(0);
+ break;
+ case Track::AUDIO_OUTPUT:
+ case Track::AUDIO_INPUT:
+ case Track::AUDIO_GROUP:
+ case Track::AUDIO_AUX:
+ case Track::AUDIO_SOFTSYNTH:
+ return 0;
+ }
+ pa->setName(track->name());
+ pa->setColorIndex(curColorIndex);
+ np = new NPart(pa);
+ return np;
+ }
+
+//---------------------------------------------------------
+// newItem
+//---------------------------------------------------------
+
+void PartCanvas::newItem(CItem* i, bool noSnap)
+ {
+ Part* p = ((NPart*)(i))->part();
+
+ int len = i->width();
+ if (!noSnap)
+ len = AL::sigmap.raster(len, *_raster);
+ if (len == 0)
+ len = AL::sigmap.rasterStep(p->tick(), *_raster);
+ p->setLenTick(len);
+ p->setSelected(true);
+ audio->msgAddPart(p);
+ }
+
+//---------------------------------------------------------
+// deleteItem
+//---------------------------------------------------------
+
+bool PartCanvas::deleteItem(CItem* i)
+ {
+ Part* p = ((NPart*)(i))->part();
+ audio->msgRemovePart(p); //Invokes songChanged which calls partsChanged which makes it difficult to delete them there
+ return true;
+ }
+
+//---------------------------------------------------------
+// splitItem
+//---------------------------------------------------------
+
+void PartCanvas::splitItem(CItem* item, const QPoint& pt)
+ {
+ NPart* np = (NPart*) item;
+ Track* t = np->track();
+ Part* p = np->part();
+ int x = pt.x();
+ if (x < 0)
+ x = 0;
+ song->cmdSplitPart(t, p, AL::sigmap.raster(x, *_raster));
+ }
+
+//---------------------------------------------------------
+// glueItem
+//---------------------------------------------------------
+
+void PartCanvas::glueItem(CItem* item)
+ {
+ NPart* np = (NPart*) item;
+ Track* t = np->track();
+ Part* p = np->part();
+ song->cmdGluePart(t, p);
+ }
+
+//---------------------------------------------------------
+// genItemPopup
+//---------------------------------------------------------
+
+QMenu* PartCanvas::genItemPopup(CItem* item)
+ {
+ NPart* npart = (NPart*) item;
+ Track::TrackType trackType = npart->track()->type();
+
+ QMenu* partPopup = new QMenu(this);
+
+ QAction *act_cut = partPopup->addAction(*editcutIconSet, tr("C&ut"));
+ act_cut->setData(4);
+ act_cut->setShortcut(Qt::CTRL+Qt::Key_X);
+
+ QAction *act_copy = partPopup->addAction(*editcopyIconSet, tr("&Copy"));
+ act_copy->setData(5);
+ act_copy->setShortcut(Qt::CTRL+Qt::Key_C);
+
+ partPopup->addSeparator();
+ int rc = npart->part()->events()->arefCount();
+ QString st = QString(tr("s&elect "));
+ if(rc > 1)
+ st += (QString().setNum(rc) + QString(" "));
+ st += QString(tr("clones"));
+ QAction *act_select = partPopup->addAction(st);
+ act_select->setData(18);
+
+ partPopup->addSeparator();
+ QAction *act_rename = partPopup->addAction(tr("rename"));
+ act_rename->setData(0);
+
+ QMenu* colorPopup = partPopup->addMenu(tr("color"));
+
+ // part color selection
+ //const QFontMetrics& fm = colorPopup->fontMetrics();
+ //int h = fm.lineSpacing();
+
+ for (int i = 0; i < NUM_PARTCOLORS; ++i) {
+ //ColorListItem* item = new ColorListItem(config.partColors[i], h, fontMetrics().height(), partColorNames[i]); //ddskrjo
+ QAction *act_color = colorPopup->addAction(colorRect(config.partColors[i], 80, 80), config.partColorNames[i]);
+ act_color->setData(20+i);
+ }
+
+ QAction *act_delete = partPopup->addAction(QIcon(*deleteIcon), tr("delete")); // ddskrjo added QIcon to all
+ act_delete->setData(1);
+ QAction *act_split = partPopup->addAction(QIcon(*cutIcon), tr("split"));
+ act_split->setData(2);
+ QAction *act_glue = partPopup->addAction(QIcon(*glueIcon), tr("glue"));
+ act_glue->setData(3);
+ QAction *act_declone = partPopup->addAction(tr("de-clone"));
+ act_declone->setData(15);
+
+ partPopup->addSeparator();
+ switch(trackType) {
+ case Track::MIDI: {
+ QAction *act_pianoroll = partPopup->addAction(QIcon(*pianoIconSet), tr("pianoroll"));
+ act_pianoroll->setData(10);
+ QAction *act_mlist = partPopup->addAction(QIcon(*edit_listIcon), tr("list"));
+ act_mlist->setData(12);
+ QAction *act_mexport = partPopup->addAction(tr("export"));
+ act_mexport->setData(16);
+ }
+ break;
+ case Track::DRUM: {
+ QAction *act_dlist = partPopup->addAction(QIcon(*edit_listIcon), tr("list"));
+ act_dlist->setData(12);
+ QAction *act_drums = partPopup->addAction(QIcon(*edit_drummsIcon), tr("drums"));
+ act_drums->setData(13);
+ QAction *act_dexport = partPopup->addAction(tr("export"));
+ act_dexport->setData(16);
+ }
+ break;
+ case Track::WAVE: {
+ QAction *act_wedit = partPopup->addAction(QIcon(*edit_waveIcon), tr("wave edit"));
+ act_wedit->setData(14);
+ QAction *act_wexport = partPopup->addAction(tr("export"));
+ act_wexport->setData(16);
+ QAction *act_wfinfo = partPopup->addAction(tr("file info"));
+ act_wfinfo->setData(17);
+ }
+ break;
+ case Track::AUDIO_OUTPUT:
+ case Track::AUDIO_INPUT:
+ case Track::AUDIO_GROUP:
+ case Track::AUDIO_AUX:
+ case Track::AUDIO_SOFTSYNTH:
+ break;
+ }
+
+ act_select->setEnabled( rc > 1);
+ act_delete->setEnabled( true);
+ act_cut->setEnabled( true);
+ act_declone->setEnabled( rc > 1);
+
+ return partPopup;
+ }
+
+//---------------------------------------------------------
+// itemPopup
+//---------------------------------------------------------
+
+void PartCanvas::itemPopup(CItem* item, int n, const QPoint& pt)
+ {
+ PartList* pl = new PartList;
+ NPart* npart = (NPart*)(item);
+ pl->add(npart->part());
+ switch(n) {
+ case 0: // rename
+ {
+ editPart = npart;
+ QRect r = map(curItem->bbox());
+ if (lineEditor == 0) {
+ lineEditor = new QLineEdit(this);
+ lineEditor->setFrame(true);
+ }
+ lineEditor->setText(editPart->name());
+ lineEditor->setFocus();
+ lineEditor->show();
+ lineEditor->setGeometry(r);
+ editMode = true;
+ }
+ break;
+ case 1: // delete
+ deleteItem(item);
+ break;
+ case 2: // split
+ splitItem(item, pt);
+ break;
+ case 3: // glue
+ glueItem(item);
+ break;
+ case 4:
+ copy(pl);
+ audio->msgRemovePart(npart->part());
+ break;
+ case 5:
+ copy(pl);
+ break;
+ case 10: // pianoroll edit
+ emit startEditor(pl, 0);
+ return;
+ case 12: // list edit
+ emit startEditor(pl, 1);
+ return;
+ case 13: // drum edit
+ emit startEditor(pl, 3);
+ return;
+ case 14: // wave edit
+ {
+ // Changed to allow multiple selected parts to be shown. By T356
+ // Slightly inefficient to add (above), then clear here.
+ // Should really only add npart->part() to pl only if NOT here.
+ // Removed. Added wave editor menu item instead.
+ //pl->clear();
+ //PartList* ptl = npart->track()->parts();
+ //for(ciPart pi = ptl->begin(); pi != ptl->end(); pi++)
+ //{
+ // if(pi->second->selected())
+ // pl->add(pi->second);
+ //}
+ emit startEditor(pl, 4);
+ }
+ return;
+ case 15: // declone
+ {
+ Part* spart = npart->part();
+ Track* track = npart->track();
+ Part* dpart = track->newPart(spart, false);
+ //printf("PartCanvas::itemPopup: #1 spart %s %p next:%s %p prev:%s %p\n", spart->name().toLatin1().constData(), spart, spart->nextClone()->name().toLatin1().constData(), spart->nextClone(), spart->prevClone()->name().toLatin1().constData(), spart->prevClone());
+ //printf("PartCanvas::itemPopup: #1 dpart %s %p next:%s %p prev:%s %p\n", dpart->name().toLatin1().constData(), dpart, dpart->nextClone()->name().toLatin1().constData(), dpart->nextClone(), dpart->prevClone()->name().toLatin1().constData(), dpart->prevClone());
+
+ EventList* se = spart->events();
+ EventList* de = dpart->events();
+ for (iEvent i = se->begin(); i != se->end(); ++i) {
+ Event oldEvent = i->second;
+ Event ev = oldEvent.clone();
+ de->add(ev);
+ }
+ song->startUndo();
+ // Indicate no undo, and do port controller values but not clone parts.
+ //audio->msgChangePart(spart, dpart, false);
+ audio->msgChangePart(spart, dpart, false, true, false);
+ //printf("PartCanvas::itemPopup: #2 spart %s %p next:%s %p prev:%s %p\n", spart->name().toLatin1().constData(), spart, spart->nextClone()->name().toLatin1().constData(), spart->nextClone(), spart->prevClone()->name().toLatin1().constData(), spart->prevClone());
+ //printf("PartCanvas::itemPopup: #2 dpart %s %p next:%s %p prev:%s %p\n", dpart->name().toLatin1().constData(), dpart, dpart->nextClone()->name().toLatin1().constData(), dpart->nextClone(), dpart->prevClone()->name().toLatin1().constData(), dpart->prevClone());
+
+ song->endUndo(SC_PART_MODIFIED);
+ break; // Has to be break here, right?
+ }
+ case 16: // Export to file
+ {
+ const Part* part = item->part();
+ bool popenFlag = false;
+ //QString fn = getSaveFileName(QString(""), part_file_pattern, this, tr("MusE: save part"));
+ QString fn = getSaveFileName(QString(""), part_file_save_pattern, this, tr("MusE: save part"));
+ if (!fn.isEmpty()) {
+ FILE* fp = fileOpen(this, fn, ".mpt", "w", popenFlag, false, false);
+ if (fp) {
+ Xml tmpXml = Xml(fp);
+ //part->write(0, tmpXml);
+ // Write the part. Indicate that it's a copy operation - to add special markers,
+ // and force full wave paths.
+ part->write(0, tmpXml, true, true);
+ fclose(fp);
+ }
+ }
+ break;
+ }
+
+ case 17: // File info
+ {
+ Part* p = item->part();
+ EventList* el = p->events();
+ QString str = tr("Part name") + ": " + p->name() + "\n" + tr("Files") + ":";
+ for (iEvent e = el->begin(); e != el->end(); ++e)
+ {
+ Event event = e->second;
+ SndFileR f = event.sndFile();
+ if (f.isNull())
+ continue;
+ //str.append("\n" + f.path());
+ str.append(QString("\n@") + QString().setNum(event.tick()) + QString(" len:") +
+ QString().setNum(event.lenTick()) + QString(" ") + f.path());
+ }
+ QMessageBox::information(this, "File info", str, "Ok", 0);
+ break;
+ }
+ case 18: // Select clones
+ {
+ Part* part = item->part();
+
+ // Traverse and process the clone chain ring until we arrive at the same part again.
+ // The loop is a safety net.
+ Part* p = part;
+ int j = part->cevents()->arefCount();
+ if(j > 0)
+ {
+ for(int i = 0; i < j; ++i)
+ {
+ //printf("PartCanvas::itemPopup i:%d %s %p events %p refs:%d arefs:%d\n", i, p->name().toLatin1().constData(), p, part->cevents(), part->cevents()->refCount(), j);
+
+ p->setSelected(true);
+ p = p->nextClone();
+ if(p == part)
+ break;
+ }
+ //song->update();
+ song->update(SC_SELECTION);
+ }
+
+ break;
+ }
+ case 20 ... NUM_PARTCOLORS+20:
+ {
+ curColorIndex = n - 20;
+ bool selfound = false;
+ //Loop through all parts and set color on selected:
+ for (iCItem i = items.begin(); i != items.end(); i++) {
+ if (i->second->isSelected()) {
+ selfound = true;
+ i->second->part()->setColorIndex(curColorIndex);
+ }
+ }
+
+ // If no items selected, use the one clicked on.
+ if(!selfound)
+ item->part()->setColorIndex(curColorIndex);
+
+ redraw();
+ break;
+ }
+ default:
+ printf("unknown action %d\n", n);
+ break;
+ }
+ delete pl;
+ }
+
+//---------------------------------------------------------
+// viewMousePressEvent
+//---------------------------------------------------------
+
+void PartCanvas::mousePress(QMouseEvent* event)
+ {
+ if (event->modifiers() & Qt::ShiftModifier) {
+ return;
+ }
+ QPoint pt = event->pos();
+ CItem* item = items.find(pt);
+ if (item == 0)
+ return;
+ switch (_tool) {
+ default:
+ emit trackChanged(item->part()->track());
+ break;
+ case CutTool:
+ splitItem(item, pt);
+ break;
+ case GlueTool:
+ glueItem(item);
+ break;
+ case MuteTool:
+ {
+ NPart* np = (NPart*) item;
+ Part* p = np->part();
+ p->setMute(!p->mute());
+ redraw();
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// viewMouseReleaseEvent
+//---------------------------------------------------------
+
+void PartCanvas::mouseRelease(const QPoint&)
+ {
+ }
+
+//---------------------------------------------------------
+// viewMouseMoveEvent
+//---------------------------------------------------------
+
+void PartCanvas::mouseMove(const QPoint& pos)
+ {
+ int x = pos.x();
+ if (x < 0)
+ x = 0;
+ emit timeChanged(AL::sigmap.raster(x, *_raster));
+ }
+
+//---------------------------------------------------------
+// y2Track
+//---------------------------------------------------------
+
+Track* PartCanvas::y2Track(int y) const
+ {
+ TrackList* l = song->tracks();
+ int ty = 0;
+ for (iTrack it = l->begin(); it != l->end(); ++it) {
+ int h = (*it)->height();
+ if (y >= ty && y < ty + h)
+ return *it;
+ ty += h;
+ }
+ return 0;
+ }
+
+//---------------------------------------------------------
+// keyPress
+//---------------------------------------------------------
+
+void PartCanvas::keyPress(QKeyEvent* event)
+ {
+ int key = event->key();
+ if (editMode)
+ {
+ if ( key == Qt::Key_Return || key == Qt::Key_Enter )
+ {
+ returnPressed();
+ return;
+ }
+ else if ( key == Qt::Key_Escape )
+ {
+ lineEditor->hide();
+ editMode = false;
+ return;
+ }
+ }
+
+ if (event->modifiers() & Qt::ShiftModifier)
+ key += Qt::SHIFT;
+ if (event->modifiers() & Qt::AltModifier)
+ key += Qt::ALT;
+ if (event->modifiers() & Qt::ControlModifier)
+ key += Qt::CTRL;
+
+ if (key == shortcuts[SHRT_DELETE].key) {
+ if (getCurrentDrag()) {
+ //printf("dragging!!\n");
+ return;
+ }
+
+ song->startUndo();
+ song->msgRemoveParts();
+ song->endUndo(SC_PART_REMOVED);
+ return;
+ }
+ else if (key == shortcuts[SHRT_POS_DEC].key) {
+ int spos = pos[0];
+ if(spos > 0)
+ {
+ spos -= 1; // Nudge by -1, then snap down with raster1.
+ spos = AL::sigmap.raster1(spos, *_raster);
+ }
+ if(spos < 0)
+ spos = 0;
+ Pos p(spos,true);
+ song->setPos(0, p, true, true, true);
+ return;
+ }
+ else if (key == shortcuts[SHRT_POS_INC].key) {
+ int spos = AL::sigmap.raster2(pos[0] + 1, *_raster); // Nudge by +1, then snap up with raster2.
+ Pos p(spos,true);
+ song->setPos(0, p, true, true, true);
+ return;
+ }
+ else if (key == shortcuts[SHRT_POS_DEC_NOSNAP].key) {
+ int spos = pos[0] - AL::sigmap.rasterStep(pos[0], *_raster);
+ if(spos < 0)
+ spos = 0;
+ Pos p(spos,true);
+ song->setPos(0, p, true, true, true);
+ return;
+ }
+ else if (key == shortcuts[SHRT_POS_INC_NOSNAP].key) {
+ Pos p(pos[0] + AL::sigmap.rasterStep(pos[0], *_raster), true);
+ song->setPos(0, p, true, true, true);
+ return;
+ }
+ else if (key == shortcuts[SHRT_TOOL_POINTER].key) {
+ emit setUsedTool(PointerTool);
+ return;
+ }
+ else if (key == shortcuts[SHRT_TOOL_PENCIL].key) {
+ emit setUsedTool(PencilTool);
+ return;
+ }
+ else if (key == shortcuts[SHRT_TOOL_RUBBER].key) {
+ emit setUsedTool(RubberTool);
+ return;
+ }
+ else if (key == shortcuts[SHRT_TOOL_SCISSORS].key) {
+ emit setUsedTool(CutTool);
+ return;
+ }
+ else if (key == shortcuts[SHRT_TOOL_GLUE].key) {
+ emit setUsedTool(GlueTool);
+ return;
+ }
+ else if (key == shortcuts[SHRT_TOOL_MUTE].key) {
+ emit setUsedTool(MuteTool);
+ return;
+ }
+ else if (key == shortcuts[SHRT_SEL_TRACK_ABOVE].key) {
+ emit selectTrackAbove();
+ return;
+ }
+ else if (key == shortcuts[SHRT_SEL_TRACK_BELOW].key) {
+ emit selectTrackBelow();
+ return;
+ }
+
+ //
+ // Shortcuts that require selected parts from here
+ //
+ if (!curItem) {
+ if (items.size()==0) {
+ event->ignore(); // give global accelerators a chance
+ return;
+ }
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ NPart* part = (NPart*)(i->second);
+ if (part->isSelected()) {
+ curItem=part;
+ break;
+ }
+ }
+ if (!curItem)
+ curItem = (NPart*)items.begin()->second; // just grab the first part
+ }
+
+ CItem* newItem = 0;
+ bool singleSelection = isSingleSelection();
+ bool add = false;
+ //Locators to selection
+ if (key == shortcuts[SHRT_LOCATORS_TO_SELECTION].key) {
+ CItem *leftmost = 0, *rightmost = 0;
+ for (iCItem i = items.begin(); i != items.end(); i++) {
+ if (i->second->isSelected()) {
+ // Check leftmost:
+ if (!leftmost)
+ leftmost = i->second;
+ else
+ if (leftmost->x() > i->second->x())
+ leftmost = i->second;
+
+ // Check rightmost:
+ if (!rightmost)
+ rightmost = i->second;
+ else
+ if (rightmost->x() < i->second->x())
+ rightmost = i->second;
+ }
+ }
+
+ int left_tick = leftmost->part()->tick();
+ int right_tick = rightmost->part()->tick() + rightmost->part()->lenTick();
+ Pos p1(left_tick, true);
+ Pos p2(right_tick, true);
+ song->setPos(1, p1);
+ song->setPos(2, p2);
+ return;
+ }
+
+ // Select part to the right
+ else if (key == shortcuts[SHRT_SEL_RIGHT].key || key == shortcuts[SHRT_SEL_RIGHT_ADD].key) {
+ if (key == shortcuts[SHRT_SEL_RIGHT_ADD].key)
+ add = true;
+
+ Part* part = curItem->part();
+ Track* track = part->track();
+ unsigned int tick = part->tick();
+ bool afterthis = false;
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ NPart* npart = (NPart*)(i->second);
+ Part* ipart = npart->part();
+ if (ipart->track() != track)
+ continue;
+ if (ipart->tick() < tick)
+ continue;
+ if (ipart == part)
+ {
+ afterthis = true;
+ continue;
+ }
+ if(afterthis)
+ {
+ newItem = i->second;
+ break;
+ }
+ }
+ }
+ // Select part to the left
+ else if (key == shortcuts[SHRT_SEL_LEFT].key || key == shortcuts[SHRT_SEL_LEFT_ADD].key) {
+ if (key == shortcuts[SHRT_SEL_LEFT_ADD].key)
+ add = true;
+
+ Part* part = curItem->part();
+ Track* track = part->track();
+ unsigned int tick = part->tick();
+
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ NPart* npart = (NPart*)(i->second);
+ Part* ipart = npart->part();
+
+ if (ipart->track() != track)
+ continue;
+ if (ipart->tick() > tick)
+ continue;
+ if (ipart == part)
+ break;
+ newItem = i->second;
+ }
+ }
+
+ // Select nearest part on track above
+ else if (key == shortcuts[SHRT_SEL_ABOVE].key || key == shortcuts[SHRT_SEL_ABOVE_ADD].key) {
+ if (key == shortcuts[SHRT_SEL_ABOVE_ADD].key)
+ add = true;
+ //To get an idea of which track is above us:
+ int stepsize = rmapxDev(1);
+ Track* track = curItem->part()->track();//top->part()->track();
+ track = y2Track(track->y() - 1);
+
+ //If we're at topmost, leave
+ if (!track) {
+ printf("no track above!\n");
+ return;
+ }
+ int middle = curItem->x() + curItem->part()->lenTick()/2;
+ CItem *aboveL = 0, *aboveR = 0;
+ //Upper limit: song end, lower limit: song start
+ int ulimit = song->len();
+ int llimit = 0;
+
+ while (newItem == 0) {
+ int y = track->y() + 2;
+ int xoffset = 0;
+ int xleft = middle - xoffset;
+ int xright = middle + xoffset;
+ while ((xleft > llimit || xright < ulimit) && (aboveL == 0) && (aboveR == 0)) {
+ xoffset += stepsize;
+ xleft = middle - xoffset;
+ xright = middle + xoffset;
+ if (xleft >= 0)
+ aboveL = items.find(QPoint(xleft,y));
+ if (xright <= ulimit)
+ aboveR = items.find(QPoint(xright,y));
+ }
+
+ if ((aboveL || aboveR) != 0) { //We've hit something
+ CItem* above = 0;
+ above = (aboveL !=0) ? aboveL : aboveR;
+ newItem = above;
+ }
+ else { //We didn't hit anything. Move to track above, if there is one
+ track = y2Track(track->y() - 1);
+ if (track == 0)
+ return;
+ }
+ }
+ emit trackChanged(track);
+ }
+ // Select nearest part on track below
+ else if (key == shortcuts[SHRT_SEL_BELOW].key || key == shortcuts[SHRT_SEL_BELOW_ADD].key) {
+ if (key == shortcuts[SHRT_SEL_BELOW_ADD].key)
+ add = true;
+
+ //To get an idea of which track is below us:
+ int stepsize = rmapxDev(1);
+ Track* track = curItem->part()->track();//bottom->part()->track();
+ track = y2Track(track->y() + track->height() + 1 );
+ int middle = curItem->x() + curItem->part()->lenTick()/2;
+ //If we're at bottommost, leave
+ if (!track)
+ return;
+
+ CItem *belowL = 0, *belowR = 0;
+ //Upper limit: song end , lower limit: song start
+ int ulimit = song->len();
+ int llimit = 0;
+ while (newItem == 0) {
+ int y = track->y() + 1;
+ int xoffset = 0;
+ int xleft = middle - xoffset;
+ int xright = middle + xoffset;
+ while ((xleft > llimit || xright < ulimit) && (belowL == 0) && (belowR == 0)) {
+ xoffset += stepsize;
+ xleft = middle - xoffset;
+ xright = middle + xoffset;
+ if (xleft >= 0)
+ belowL = items.find(QPoint(xleft,y));
+ if (xright <= ulimit)
+ belowR = items.find(QPoint(xright,y));
+ }
+
+ if ((belowL || belowR) != 0) { //We've hit something
+ CItem* below = 0;
+ below = (belowL !=0) ? belowL : belowR;
+ newItem = below;
+ }
+ else {
+ //Get next track below, or abort if this is the lowest
+ track = y2Track(track->y() + track->height() + 1 );
+ if (track == 0)
+ return;
+ }
+ }
+ emit trackChanged(track);
+ }
+ else if (key == shortcuts[SHRT_EDIT_PART].key && curItem) { //This should be the other way around - singleSelection first.
+ if (!singleSelection) {
+ event->ignore();
+ return;
+ }
+ PartList* pl = new PartList;
+ NPart* npart = (NPart*)(curItem);
+ Track* track = npart->part()->track();
+ pl->add(npart->part());
+ int type = 0;
+
+ // Check if track is wave or drum,
+ // else track is midi
+
+ switch (track->type()) {
+ case Track::DRUM:
+ type = 3;
+ break;
+
+ case Track::WAVE:
+ type = 4;
+ break;
+
+ case Track::MIDI:
+ case Track::AUDIO_OUTPUT:
+ case Track::AUDIO_INPUT:
+ case Track::AUDIO_GROUP:
+ case Track::AUDIO_AUX:
+ case Track::AUDIO_SOFTSYNTH: //TODO
+ break;
+ }
+ emit startEditor(pl, type);
+ }
+ else {
+ event->ignore(); // give global accelerators a chance
+ return;
+ }
+
+
+ // Check if anything happened to the selected parts
+ if (newItem) {
+ //If this is a single selection, toggle previous item
+ if (singleSelection && !add)
+ selectItem(curItem, false);
+ else if(!add)
+ deselectAll();
+
+ curItem = newItem;
+ selectItem(newItem, true);
+
+ //Check if we've hit the upper or lower boundaries of the window. If so, set a new position
+ if (newItem->x() < mapxDev(0)) {
+ int curpos = pos[0];
+ setPos(0,newItem->x(),true);
+ setPos(0,curpos,false); //Dummy to put the current position back once we've scrolled
+ }
+ else if (newItem->x() > mapxDev(width())) {
+ int curpos = pos[0];
+ setPos(0,newItem->x(),true);
+ setPos(0,curpos,false); //Dummy to put the current position back once we've scrolled
+ }
+ redraw();
+ }
+ }
+
+//---------------------------------------------------------
+// drawPart
+// draws a part
+//---------------------------------------------------------
+
+void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
+ {
+ int from = rect.x();
+ int to = from + rect.width();
+
+ //printf("from %d to %d\n", from,to);
+ Part* part = ((NPart*)item)->part();
+ int pTick = part->tick();
+ from -= pTick;
+ to -= pTick;
+ if(from < 0)
+ from = 0;
+ if((unsigned int)to > part->lenTick())
+ to = part->lenTick();
+
+ // Item bounding box x is in tick coordinates, same as rectangle.
+ if(item->bbox().intersect(rect).isNull())
+ {
+ //printf("PartCanvas::drawItem rectangle is null\n");
+ return;
+ }
+
+ QRect r = item->bbox();
+
+ //printf("PartCanvas::drawItem %s evRefs:%d pTick:%d pLen:%d\nbb.x:%d bb.y:%d bb.w:%d bb.h:%d\n"
+ // "rect.x:%d rect.y:%d rect.w:%d rect.h:%d\nr.x:%d r.y:%d r.w:%d r.h:%d\n",
+ // part->name().toLatin1().constData(), part->events()->arefCount(), pTick, part->lenTick(),
+ // bb.x(), bb.y(), bb.width(), bb.height(),
+ // rect.x(), rect.y(), rect.width(), rect.height(),
+ // r.x(), r.y(), r.width(), r.height());
+
+ int i = part->colorIndex();
+ p.setPen(Qt::black);
+ if (part->mute()) {
+ QColor c(Qt::white);
+ c.setAlpha(config.globalAlphaBlend);
+ p.setBrush(c);
+
+ // NOTE: For one-pixel border use first line For two-pixel border use second.
+ p.drawRect(QRect(r.x(), r.y()-1, r.width(), r.height()));
+ //p.drawRect(r);
+
+ return;
+ }
+ if (item->isMoving()) {
+ QColor c(Qt::gray);
+ c.setAlpha(config.globalAlphaBlend);
+ p.setBrush(c);
+
+ // NOTE: For one-pixel border use first line. For two-pixel border use second.
+ p.drawRect(QRect(r.x(), r.y()-1, r.width(), r.height()));
+ //p.drawRect(r);
+
+ }
+ //else if (part->mute())
+ // return;
+ else if (part->selected()) {
+ bool clone = part->events()->arefCount() > 1;
+
+ // NOTE: For one-pixel border use first line and don't bother with setCosmetic.
+ // For a two-pixel border use second line and MUST use setCosmetic! Tim.
+ //p.setPen(QPen(config.partColors[i], 0, clone ? Qt::DashLine : Qt::SolidLine));
+ QPen pen(config.partColors[i], 2, clone ? Qt::DashLine : Qt::SolidLine);
+ pen.setCosmetic(true);
+
+ p.setPen(pen);
+ // Hm, put some kind of lower limit? If so do that globally to the adjustment.
+ QColor c(Qt::black);
+ c.setAlpha(config.globalAlphaBlend);
+ p.setBrush(c);
+ p.drawRect(r);
+ }
+ else {
+ bool clone = part->events()->arefCount() > 1;
+
+ // NOTE: Pixel width: See above note.
+ //p.setPen(QPen(Qt::black, 0, clone ? Qt::DashLine : Qt::SolidLine));
+ QPen pen(Qt::black, 2, clone ? Qt::DashLine : Qt::SolidLine);
+ pen.setCosmetic(true);
+
+ p.setPen(pen);
+ QColor c(config.partColors[i]);
+ c.setAlpha(config.globalAlphaBlend);
+ p.setBrush(c);
+
+ p.drawRect(r);
+ }
+
+ MidiPart* mp = 0;
+ WavePart* wp = 0;
+ Track::TrackType type = part->track()->type();
+ if (type == Track::WAVE) {
+ wp =(WavePart*)part;
+ }
+ else {
+ mp = (MidiPart*)part;
+ }
+
+ if (config.canvasShowPartType & 2) { // show events
+ if (mp)
+ {
+ // Do not allow this, causes segfault.
+ if(from <= to)
+ {
+ p.setPen(Qt::darkGray);
+ EventList* events = mp->events();
+ iEvent ito(events->lower_bound(to));
+
+ for (iEvent i = events->lower_bound(from); i != ito; ++i) {
+ EventType type = i->second.type();
+ if (
+ ((config.canvasShowPartEvent & 1) && (type == Note))
+ || ((config.canvasShowPartEvent & 2) && (type == PAfter))
+ || ((config.canvasShowPartEvent & 4) && (type == Controller))
+ || ((config.canvasShowPartEvent &16) && (type == CAfter))
+ || ((config.canvasShowPartEvent &64) && (type == Sysex || type == Meta))
+ ) {
+ int t = i->first + pTick;
+ int th = part->track()->height();
+ if(t >= r.left() && t <= r.right())
+ p.drawLine(t, r.y()+2, t, r.y()+th-4);
+ }
+ }
+ }
+ }
+ else if (wp)
+ drawWavePart(p, rect, wp, r);
+ }
+
+ else { // show Cakewalk Style
+ if (mp) {
+ p.setPen(Qt::darkGray);
+ EventList* events = mp->events();
+ iEvent ito(events->lower_bound(to));
+ //printf("PartCanvas::drawItem pTick:%d from:%d to:%d part len:%d\n", pTick, from, to, part->lenTick());
+
+ for (iEvent i = events->begin(); i != ito; ++i) {
+ int t = i->first + pTick;
+ int te = t + i->second.lenTick();
+
+ if (t > (to + pTick))
+ {
+ printf("PartCanvas::drawItem t:%d > to:%d + pTick:%d i->first:%d\n", t, to, pTick, i->first);
+
+ break;
+ }
+
+ if (te < (from + pTick))
+ continue;
+
+ if (te > (to + pTick))
+ te = to + pTick;
+
+ EventType type = i->second.type();
+ if (type == Note) {
+ int pitch = i->second.pitch();
+ int th = int(part->track()->height() * 0.75); // only draw on three quarters
+ int hoffset = (part->track()->height() - th ) / 2; // offset from bottom
+ int y = hoffset + (r.y() + th - (pitch * (th) / 127));
+ p.drawLine(t, y, te, y);
+ }
+ }
+ }
+ else if (wp)
+ drawWavePart(p, rect, wp, r);
+ }
+ if (config.canvasShowPartType & 1) { // show names
+ // draw name
+ // FN: Set text color depending on part color (black / white)
+ int part_r, part_g, part_b, brightness;
+ config.partColors[i].getRgb(&part_r, &part_g, &part_b);
+ brightness = part_r*29 + part_g*59 + part_b*12;
+ if (brightness < 12000 || part->selected())
+ p.setPen(Qt::white); /* too dark: use white for text color */
+ else
+ p.setPen(Qt::black); /* otherwise use black */
+ QRect rr = map(r);
+ rr.setX(rr.x() + 3);
+ p.save();
+ p.setFont(config.fonts[1]);
+ p.setWorldMatrixEnabled(false);
+ p.drawText(rr, Qt::AlignVCenter|Qt::AlignLeft, part->name());
+ p.restore();
+ }
+ }
+
+//---------------------------------------------------------
+// drawMoving
+// draws moving items
+//---------------------------------------------------------
+
+void PartCanvas::drawMoving(QPainter& p, const CItem* item, const QRect&)
+ {
+ //if(!item->isMoving())
+ // return;
+ p.setPen( Qt::black);
+
+ //p.setBrush( Qt::NoBrush);
+ //QColor c(Qt::gray);
+ Part* part = ((NPart*)item)->part();
+ QColor c(config.partColors[part->colorIndex()]);
+
+ ///c.setAlpha(config.globalAlphaBlend);
+ c.setAlpha(128); // Fix this regardless of global setting. Should be OK.
+
+ p.setBrush(c);
+
+ // NOTE: For one-pixel border use second line. For two-pixel border use first.
+ //p.drawRect(item->mp().x(), item->mp().y()+1, item->width(), item->height());
+ p.drawRect(item->mp().x(), item->mp().y(), item->width(), item->height());
+ }
+
+//---------------------------------------------------------
+// drawWavePart
+// bb - bounding box of paint area
+// pr - part rectangle
+//---------------------------------------------------------
+
+void PartCanvas::drawWavePart(QPainter& p,
+ const QRect& bb, WavePart* wp, const QRect& _pr)
+ {
+ //printf("PartCanvas::drawWavePart bb.x:%d bb.y:%d bb.w:%d bb.h:%d pr.x:%d pr.y:%d pr.w:%d pr.h:%d\n",
+ // bb.x(), bb.y(), bb.width(), bb.height(), _pr.x(), _pr.y(), _pr.width(), _pr.height());
+
+ QRect rr = p.worldMatrix().mapRect(bb);
+ QRect pr = p.worldMatrix().mapRect(_pr);
+
+ p.save();
+ p.resetTransform();
+
+ int x2 = 1;
+ int x1 = rr.x() > pr.x() ? rr.x() : pr.x();
+ x2 += rr.right() < pr.right() ? rr.right() : pr.right();
+
+ if (x1 < 0)
+ x1 = 0;
+ if (x2 > width())
+ x2 = width();
+ int hh = pr.height();
+ int h = hh/2;
+ int y = pr.y() + h;
+
+ EventList* el = wp->events();
+ for (iEvent e = el->begin(); e != el->end(); ++e) {
+ int cc = hh % 2 ? 0 : 1;
+ Event event = e->second;
+ SndFileR f = event.sndFile();
+ if (f.isNull())
+ continue;
+ unsigned channels = f.channels();
+ if (channels == 0) {
+ printf("drawWavePart: channels==0! %s\n", f.name().toLatin1().constData());
+ continue;
+ }
+
+ int xScale;
+ int pos;
+ int tickstep = rmapxDev(1);
+ int postick = tempomap.frame2tick(wp->frame() + event.frame());
+ int eventx = mapx(postick);
+ int drawoffset;
+ if((x1 - eventx) < 0)
+ drawoffset = 0;
+ else
+ drawoffset = rmapxDev(x1 - eventx);
+ postick += drawoffset;
+ pos = event.spos() + tempomap.tick2frame(postick) - wp->frame() - event.frame();
+
+ int i;
+ if(x1 < eventx)
+ i = eventx;
+ else
+ i = x1;
+ int ex = mapx(tempomap.frame2tick(wp->frame() + event.frame() + event.lenFrame()));
+ if(ex > x2)
+ ex = x2;
+ if (h < 20) {
+ //
+ // combine multi channels into one waveform
+ //
+ //printf("PartCanvas::drawWavePart i:%d ex:%d\n", i, ex); // REMOVE Tim.
+
+ for (; i < ex; i++) {
+ SampleV sa[channels];
+ xScale = tempomap.deltaTick2frame(postick, postick + tickstep);
+ f.read(sa, xScale, pos);
+ postick += tickstep;
+ pos += xScale;
+ int peak = 0;
+ int rms = 0;
+ for (unsigned k = 0; k < channels; ++k) {
+ if (sa[k].peak > peak)
+ peak = sa[k].peak;
+ rms += sa[k].rms;
+ }
+ rms /= channels;
+ peak = (peak * (hh-2)) >> 9;
+ rms = (rms * (hh-2)) >> 9;
+ p.setPen(QColor(Qt::darkGray));
+ p.drawLine(i, y - peak - cc, i, y + peak);
+ p.setPen(QColor(Qt::black));
+ p.drawLine(i, y - rms - cc, i, y + rms);
+ }
+ }
+ else {
+ //
+ // multi channel display
+ //
+ int hm = hh / (channels * 2);
+ int cc = hh % (channels * 2) ? 0 : 1;
+ for (; i < ex; i++) {
+ y = pr.y() + hm;
+ SampleV sa[channels];
+ xScale = tempomap.deltaTick2frame(postick, postick + tickstep);
+ f.read(sa, xScale, pos);
+ postick += tickstep;
+ pos += xScale;
+ for (unsigned k = 0; k < channels; ++k) {
+ int peak = (sa[k].peak * (hm - 1)) >> 8;
+ int rms = (sa[k].rms * (hm - 1)) >> 8;
+ p.setPen(QColor(Qt::darkGray));
+ p.drawLine(i, y - peak - cc, i, y + peak);
+ p.setPen(QColor(Qt::black));
+ p.drawLine(i, y - rms - cc, i, y + rms);
+
+ y += 2 * hm;
+ }
+ }
+ }
+ }
+ p.restore();
+ }
+//---------------------------------------------------------
+// cmd
+//---------------------------------------------------------
+
+void PartCanvas::cmd(int cmd)
+ {
+ PartList pl;
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ if (!i->second->isSelected())
+ continue;
+ NPart* npart = (NPart*)(i->second);
+ pl.add(npart->part());
+ }
+ switch (cmd) {
+ case CMD_CUT_PART:
+ copy(&pl);
+ song->startUndo();
+
+ bool loop;
+ do
+ {
+ loop = false;
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ if (!i->second->isSelected())
+ continue;
+ NPart* p = (NPart*)(i->second);
+ Part* part = p->part();
+ audio->msgRemovePart(part);
+
+ loop = true;
+ break;
+ }
+ } while (loop);
+ song->endUndo(SC_PART_REMOVED);
+ break;
+ case CMD_COPY_PART:
+ copy(&pl);
+ break;
+ case CMD_PASTE_PART:
+ paste(false, false);
+ break;
+ case CMD_PASTE_CLONE_PART:
+ paste(true, false);
+ break;
+ case CMD_PASTE_PART_TO_TRACK:
+ paste();
+ break;
+ case CMD_PASTE_CLONE_PART_TO_TRACK:
+ paste(true);
+ break;
+ case CMD_INSERT_PART:
+ paste(false, false, true);
+ break;
+ case CMD_INSERT_EMPTYMEAS:
+ song->startUndo();
+ int startPos=song->vcpos();
+ int oneMeas=AL::sigmap.ticksMeasure(startPos);
+ movePartsTotheRight(startPos,oneMeas);
+ song->endUndo(SC_PART_INSERTED);
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// copy
+// cut copy paste
+//---------------------------------------------------------
+
+void PartCanvas::copy(PartList* pl)
+ {
+ //printf("void PartCanvas::copy(PartList* pl)\n");
+ if (pl->empty())
+ return;
+ // Changed by T356. Support mixed .mpt files.
+ //bool isWave = pl->begin()->second->track()->type() == Track::WAVE;
+ bool wave = false;
+ bool midi = false;
+ for(ciPart p = pl->begin(); p != pl->end(); ++p)
+ {
+ if(p->second->track()->isMidiTrack())
+ midi = true;
+ else
+ if(p->second->track()->type() == Track::WAVE)
+ wave = true;
+ if(midi && wave)
+ break;
+ }
+ if(!(midi || wave))
+ return;
+
+ //---------------------------------------------------
+ // write parts as XML into tmp file
+ //---------------------------------------------------
+
+ FILE* tmp = tmpfile();
+ if (tmp == 0) {
+ fprintf(stderr, "PartCanvas::copy() fopen failed: %s\n",
+ strerror(errno));
+ return;
+ }
+ Xml xml(tmp);
+
+ // Clear the copy clone list.
+ cloneList.clear();
+ //copyCloneList.clear();
+
+ int level = 0;
+ int tick = 0;
+ for (ciPart p = pl->begin(); p != pl->end(); ++p) {
+ // Indicate this is a copy operation. Also force full wave paths.
+ //p->second->write(level, xml);
+ p->second->write(level, xml, true, true);
+
+ int endTick = p->second->endTick();
+ if (endTick > tick)
+ tick = endTick;
+ }
+ Pos p(tick, true);
+ song->setPos(0, p);
+
+ //---------------------------------------------------
+ // read tmp file into QTextDrag Object
+ //---------------------------------------------------
+
+ fflush(tmp);
+ struct stat f_stat;
+ if (fstat(fileno(tmp), &f_stat) == -1) {
+ fprintf(stderr, "PartCanvas::copy() fstat failed:<%s>\n",
+ strerror(errno));
+ fclose(tmp);
+ return;
+ }
+ int n = f_stat.st_size;
+ char* fbuf = (char*)mmap(0, n+1, PROT_READ|PROT_WRITE,
+ MAP_PRIVATE, fileno(tmp), 0);
+ fbuf[n] = 0;
+
+ QByteArray data(fbuf);
+ QMimeData* md = new QMimeData();
+
+
+ if(midi && wave)
+ md->setData("text/x-muse-mixedpartlist", data); // By T356. Support mixed .mpt files.
+ else
+ if(midi)
+ md->setData("text/x-muse-midipartlist", data);
+ else
+ if(wave)
+ md->setData("text/x-muse-wavepartlist", data);
+
+ QApplication::clipboard()->setMimeData(md, QClipboard::Clipboard);
+
+ munmap(fbuf, n);
+ fclose(tmp);
+ }
+
+//---------------------------------------------------------
+// pasteAt
+//---------------------------------------------------------
+
+int PartCanvas::pasteAt(const QString& pt, Track* track, unsigned int pos, bool clone, bool toTrack)
+ {
+ //printf("int PartCanvas::pasteAt(const QString& pt, Track* track, int pos)\n");
+ QByteArray ba = pt.toLatin1();
+ const char* ptxt = ba.constData();
+ Xml xml(ptxt);
+ bool firstPart=true;
+ int posOffset=0;
+ //int finalPos=0;
+ unsigned int finalPos = pos;
+ int notDone = 0;
+ int done = 0;
+ bool end = false;
+
+ //song->startUndo();
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ end = true;
+ break;
+ case Xml::TagStart:
+ if (tag == "part") {
+ /*
+ Part* p = 0;
+ if(clone)
+ {
+ if(!(p = readClone(xml, track, toTrack)))
+ break;
+ }
+ else
+ {
+ if (track->type() == Track::MIDI || track->type() == Track::DRUM)
+ p = new MidiPart((MidiTrack*)track);
+ else if (track->type() == Track::WAVE)
+ p = new WavePart((WaveTrack*)track);
+ else
+ break;
+ p->read(xml, 0, toTrack);
+ }
+ */
+
+ // Read the part.
+ Part* p = 0;
+ p = readXmlPart(xml, track, clone, toTrack);
+ // If it could not be created...
+ if(!p)
+ {
+ // Increment the number of parts not done and break.
+ ++notDone;
+ break;
+ }
+
+ // Increment the number of parts done.
+ ++done;
+
+ if (firstPart) {
+ firstPart=false;
+ posOffset=pos-p->tick();
+ }
+ p->setTick(p->tick()+posOffset);
+ if (p->tick()+p->lenTick()>finalPos) {
+ finalPos=p->tick()+p->lenTick();
+ }
+ //pos += p->lenTick();
+ audio->msgAddPart(p,false);
+ }
+ else
+ xml.unknown("PartCanvas::pasteAt");
+ break;
+ case Xml::TagEnd:
+ break;
+ default:
+ end = true;
+ break;
+ }
+ if(end)
+ break;
+ }
+
+ //song->endUndo(SC_PART_INSERTED);
+ //return pos;
+
+ if(notDone)
+ {
+ int tot = notDone + done;
+ QMessageBox::critical(this, QString("MusE"),
+ QString().setNum(notDone) + (tot > 1 ? (tr(" out of ") + QString().setNum(tot)) : QString("")) +
+ (tot > 1 ? tr(" parts") : tr(" part")) +
+ tr(" could not be pasted.\nLikely the selected track is the wrong type."));
+ }
+
+ return finalPos;
+ }
+
+/*
+//---------------------------------------------------------
+// PartCanvas::readPart
+//---------------------------------------------------------
+
+Part* PartCanvas::readPart(Xml& xml, Track* track, bool doClone, bool toTrack)
+ {
+ int id = -1;
+ Part* npart = 0;
+ uuid_t uuid;
+ uuid_clear(uuid);
+ bool uuidvalid = false;
+ bool clone = true;
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return npart;
+ case Xml::TagStart:
+ // If the part has not been created yet...
+ if(!npart)
+ {
+ // Attribute section did not create a clone from any matching part. Create a non-clone part now.
+ if(!track)
+ {
+ xml.skip("part");
+ return 0;
+ }
+ if (track->type() == Track::MIDI || track->type() == Track::DRUM)
+ npart = new MidiPart((MidiTrack*)track);
+ else if (track->type() == Track::WAVE)
+ npart = new WavePart((WaveTrack*)track);
+ else
+ {
+ xml.skip("part");
+ return 0;
+ }
+
+ // Signify a new non-clone part was created.
+ // Even if the original part was itself a clone, clear this because the
+ // attribute section did not create a clone from any matching part.
+ clone = false;
+
+ // If an id or uuid was found, add the part to the clone list
+ // so that subsequent parts can look it up and clone from it...
+ if(id != -1)
+ {
+ ClonePart ncp(npart, id);
+ cloneList.push_back(ncp);
+ }
+ else
+ if(uuidvalid)
+ {
+ ClonePart ncp(npart);
+ // New ClonePart creates its own uuid, but we need to replace it.
+ uuid_copy(ncp.uuid, uuid);
+ cloneList.push_back(ncp);
+ }
+ }
+
+ if (tag == "name")
+ npart->setName(xml.parse1());
+ else if (tag == "poslen") {
+ ((PosLen*)npart)->read(xml, "poslen");
+ }
+ else if (tag == "pos") {
+ Pos pos;
+ pos.read(xml, "pos"); // obsolete
+ npart->setTick(pos.tick());
+ }
+ else if (tag == "len") {
+ Pos len;
+ len.read(xml, "len"); // obsolete
+ npart->setLenTick(len.tick());
+ }
+ else if (tag == "selected")
+ npart->setSelected(xml.parseInt());
+ else if (tag == "color")
+ npart->setColorIndex(xml.parseInt());
+ else if (tag == "mute")
+ npart->setMute(xml.parseInt());
+ else if (tag == "event")
+ {
+ // If a new non-clone part was created, accept the events...
+ if(!clone)
+ {
+ EventType type = Wave;
+ if(track->isMidiTrack())
+ type = Note;
+ Event e(type);
+ e.read(xml);
+ // stored tickpos for event has absolute value. However internally
+ // tickpos is relative to start of part, we substract tick().
+ // TODO: better handling for wave event
+ e.move( -npart->tick() );
+ int tick = e.tick();
+
+ // Do not discard events belonging to clone parts,
+ // at least not yet. A later clone might have a longer,
+ // fully accommodating part length!
+ //if ((tick < 0) || (tick >= (int) lenTick())) {
+ //if ((tick < 0) || ( id == -1 && !clone && (tick >= (int)lenTick()) ))
+ // No way to tell at the moment whether there will be clones referencing this...
+ // No choice but to accept all events past 0.
+ if(tick < 0)
+ {
+ //printf("readClone: warning: event not in part: %d - %d -%d, discarded\n",
+ printf("readClone: warning: event at tick:%d not in part:%s, discarded\n",
+ tick, npart->name().toLatin1().constData());
+ }
+ else
+ {
+ npart->events()->add(e);
+ }
+ }
+ else
+ // ...Otherwise a clone was created, so we don't need the events.
+ xml.skip(tag);
+ }
+ else
+ xml.unknown("PartCanvas::readClone");
+ break;
+ case Xml::Attribut:
+ if (tag == "cloneId")
+ {
+ id = xml.s2().toInt();
+ if(id != -1)
+ {
+ for(iClone i = cloneList.begin(); i != cloneList.end(); ++i)
+ {
+ // Is a matching part found in the clone list?
+ if(i->id == id)
+ {
+ // If it's a regular paste (not paste clone), and the original part is
+ // not a clone, defer so that a new copy is created in TagStart above.
+ if(!doClone && i->cp->cevents()->arefCount() <= 1)
+ break;
+
+ // This makes a clone, chains the part, and increases ref counts.
+ npart = track->newPart((Part*)i->cp, true);
+ break;
+ }
+ }
+ }
+ }
+ else if (tag == "uuid")
+ {
+ uuid_parse(xml.s2().toLatin1().constData(), uuid);
+ if(!uuid_is_null(uuid))
+ {
+ uuidvalid = true;
+ for(iClone i = cloneList.begin(); i != cloneList.end(); ++i)
+ {
+ // Is a matching part found in the clone list?
+ if(uuid_compare(uuid, i->uuid) == 0)
+ {
+ Track* cpt = i->cp->track();
+ // If we want to paste to the given track...
+ if(toTrack)
+ {
+ // If the given track type is not the same as the part's
+ // original track type, we can't continue. Just return.
+ if(!track || cpt->type() != track->type())
+ {
+ xml.skip("part");
+ return 0;
+ }
+ }
+ else
+ // ...else we want to paste to the part's original track.
+ {
+ // Make sure the track exists (has not been deleted).
+ if((cpt->isMidiTrack() && song->midis()->find(cpt) != song->midis()->end()) ||
+ (cpt->type() == Track::WAVE && song->waves()->find(cpt) != song->waves()->end()))
+ track = cpt;
+ else
+ // Track was not found. Try pasting to the given track, as above...
+ {
+ if(!track || cpt->type() != track->type())
+ {
+ // No luck. Just return.
+ xml.skip("part");
+ return 0;
+ }
+ }
+ }
+
+ // If it's a regular paste (not paste clone), and the original part is
+ // not a clone, defer so that a new copy is created in TagStart above.
+ if(!doClone && i->cp->cevents()->arefCount() <= 1)
+ break;
+
+ // This makes a clone, chains the part, and increases ref counts.
+ npart = track->newPart((Part*)i->cp, true);
+ break;
+ }
+ }
+ }
+ }
+ //else if(tag == "isclone") // Ignore
+ // clone = xml.s2().toInt();
+ break;
+ case Xml::TagEnd:
+ if (tag == "part")
+ return npart;
+ default:
+ break;
+ }
+ }
+ return npart;
+}
+*/
+
+/*
+//---------------------------------------------------------
+// PartCanvas::readClone
+//---------------------------------------------------------
+
+Part* PartCanvas::readClone(Xml& xml, Track* track, bool toTrack)
+ {
+ int id = -1;
+ Part* npart = 0;
+ uuid_t uuid;
+ uuid_clear(uuid);
+ bool uuidvalid = false;
+ bool clone = true;
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return npart;
+ case Xml::TagStart:
+ // If the part has not been created yet...
+ if(!npart)
+ {
+ // Attribute section did not create a clone from any matching part. Create a non-clone part now.
+ if (track->type() == Track::MIDI || track->type() == Track::DRUM)
+ npart = new MidiPart((MidiTrack*)track);
+ else if (track->type() == Track::WAVE)
+ npart = new WavePart((WaveTrack*)track);
+ else
+ return 0;
+
+ // Signify a new non-clone part was created.
+ // Even if the original part was itself a clone, clear this because the
+ // attribute section did not create a clone from any matching part.
+ clone = false;
+
+ // If an id or uuid was found, add the part to the clone list
+ // so that subsequent parts can look it up and clone from it...
+ if(id != -1)
+ {
+ ClonePart ncp(npart, id);
+ cloneList.push_back(ncp);
+ }
+ else
+ if(uuidvalid)
+ {
+ ClonePart ncp(npart);
+ // New ClonePart creates its own uuid, but we need to replace it.
+ uuid_copy(ncp.uuid, uuid);
+ cloneList.push_back(ncp);
+ }
+ }
+
+ if (tag == "name")
+ npart->setName(xml.parse1());
+ else if (tag == "poslen") {
+ ((PosLen*)npart)->read(xml, "poslen");
+ }
+ else if (tag == "pos") {
+ Pos pos;
+ pos.read(xml, "pos"); // obsolete
+ npart->setTick(pos.tick());
+ }
+ else if (tag == "len") {
+ Pos len;
+ len.read(xml, "len"); // obsolete
+ npart->setLenTick(len.tick());
+ }
+ else if (tag == "selected")
+ npart->setSelected(xml.parseInt());
+ else if (tag == "color")
+ npart->setColorIndex(xml.parseInt());
+ else if (tag == "mute")
+ npart->setMute(xml.parseInt());
+ else if (tag == "event")
+ {
+ // If a new non-clone part was created, accept the events...
+ if(!clone)
+ {
+ EventType type = Wave;
+ if(track->isMidiTrack())
+ type = Note;
+ Event e(type);
+ e.read(xml);
+ // stored tickpos for event has absolute value. However internally
+ // tickpos is relative to start of part, we substract tick().
+ // TODO: better handling for wave event
+ e.move( -npart->tick() );
+ int tick = e.tick();
+
+ // Do not discard events belonging to clone parts,
+ // at least not yet. A later clone might have a longer,
+ // fully accommodating part length!
+ //if ((tick < 0) || (tick >= (int) lenTick())) {
+ //if ((tick < 0) || ( id == -1 && !clone && (tick >= (int)lenTick()) ))
+ // No way to tell at the moment whether there will be clones referencing this...
+ // No choice but to accept all events past 0.
+ if(tick < 0)
+ {
+ //printf("readClone: warning: event not in part: %d - %d -%d, discarded\n",
+ printf("readClone: warning: event at tick:%d not in part:%s, discarded\n",
+ tick, npart->name().toLatin1().constData());
+ }
+ else
+ {
+ npart->events()->add(e);
+ }
+ }
+ else
+ // ...Otherwise a clone was created, so we don't need the events.
+ xml.skip(tag);
+ }
+ else
+ xml.unknown("PartCanvas::readClone");
+ break;
+ case Xml::Attribut:
+ if (tag == "cloneId")
+ {
+ id = xml.s2().toInt();
+ if(id != -1)
+ {
+ for(iClone i = cloneList.begin(); i != cloneList.end(); ++i)
+ {
+ // Is a matching part found in the clone list?
+ if(i->id == id)
+ {
+ // This makes a clone, chains the part, and increases ref counts.
+ npart = track->newPart((Part*)i->cp, true);
+ break;
+ }
+ }
+ }
+ }
+ else if (tag == "uuid")
+ {
+ uuid_parse(xml.s2().toLatin1().constData(), uuid);
+ if(!uuid_is_null(uuid))
+ {
+ uuidvalid = true;
+ for(iClone i = cloneList.begin(); i != cloneList.end(); ++i)
+ {
+ // Is a matching part found in the clone list?
+ if(uuid_compare(uuid, i->uuid) == 0)
+ {
+ // If we want to paste to the part's original track...
+ if(!toTrack)
+ {
+ // Make sure the track exists (has not been deleted).
+ if((i->cp->track()->isMidiTrack() && song->midis()->find(i->cp->track()) != song->midis()->end()) ||
+ (i->cp->track()->type() == Track::WAVE && song->waves()->find(i->cp->track()) != song->waves()->end()))
+ track = i->cp->track();
+ }
+ // This makes a clone, chains the part, and increases ref counts.
+ npart = track->newPart((Part*)i->cp, true);
+ break;
+ }
+ }
+ }
+ }
+ //else if(tag == "isclone") // Ignore
+ // clone = xml.s2().toInt();
+ break;
+ case Xml::TagEnd:
+ if (tag == "part")
+ return npart;
+ default:
+ break;
+ }
+ }
+ return npart;
+}
+*/
+
+//---------------------------------------------------------
+// paste
+// paste part to current selected track at cpos
+//---------------------------------------------------------
+
+//void PartCanvas::paste()
+void PartCanvas::paste(bool clone, bool toTrack, bool doInsert)
+{
+ Track* track = 0;
+
+ if (doInsert) // logic depends on keeping track of newly selected tracks
+ deselectAll();
+
+
+ // If we want to paste to a selected track...
+ if(toTrack)
+ {
+ TrackList* tl = song->tracks();
+ for (iTrack i = tl->begin(); i != tl->end(); ++i) {
+ if ((*i)->selected()) {
+ if (track) {
+ QMessageBox::critical(this, QString("MusE"),
+ tr("Cannot paste: multiple tracks selected"));
+ return;
+ }
+ else
+ track = *i;
+ }
+ }
+ if (track == 0) {
+ QMessageBox::critical(this, QString("MusE"),
+ tr("Cannot paste: no track selected"));
+ return;
+ }
+ }
+
+ QClipboard* cb = QApplication::clipboard();
+ const QMimeData* md = cb->mimeData(QClipboard::Clipboard);
+
+ QString pfx("text/");
+ QString mdpl("x-muse-midipartlist");
+ QString wvpl("x-muse-wavepartlist");
+ QString mxpl("x-muse-mixedpartlist");
+ QString txt;
+
+ if(md->hasFormat(pfx + mdpl))
+ {
+ // If we want to paste to a selected track...
+ if(toTrack && !track->isMidiTrack())
+ {
+ QMessageBox::critical(this, QString("MusE"),
+ tr("Can only paste to midi/drum track"));
+ return;
+ }
+ txt = cb->text(mdpl, QClipboard::Clipboard);
+ }
+ else
+ if(md->hasFormat(pfx + wvpl))
+ {
+ // If we want to paste to a selected track...
+ if(toTrack && track->type() != Track::WAVE)
+ {
+ QMessageBox::critical(this, QString("MusE"),
+ tr("Can only paste to wave track"));
+ return;
+ }
+ txt = cb->text(wvpl, QClipboard::Clipboard);
+ }
+ else
+ if(md->hasFormat(pfx + mxpl))
+ {
+ // If we want to paste to a selected track...
+ if(toTrack && !track->isMidiTrack() && track->type() != Track::WAVE)
+ {
+ QMessageBox::critical(this, QString("MusE"),
+ tr("Can only paste to midi or wave track"));
+ return;
+ }
+ txt = cb->text(mxpl, QClipboard::Clipboard);
+ }
+ else
+ {
+ QMessageBox::critical(this, QString("MusE"),
+ tr("Cannot paste: wrong data type"));
+ return;
+ }
+
+ int endPos=0;
+ unsigned int startPos=song->vcpos();
+ if (!txt.isEmpty())
+ {
+ song->startUndo();
+ endPos=pasteAt(txt, track, startPos, clone, toTrack);
+ Pos p(endPos, true);
+ song->setPos(0, p);
+ if (!doInsert)
+ song->endUndo(SC_PART_INSERTED);
+ }
+
+ if (doInsert) {
+ int offset = endPos-startPos;
+ movePartsTotheRight(startPos, offset);
+ song->endUndo(SC_PART_INSERTED);
+ }
+ }
+
+//---------------------------------------------------------
+// movePartsToTheRight
+//---------------------------------------------------------
+void PartCanvas::movePartsTotheRight(unsigned int startTicks, int length)
+{
+ // all parts that start after the pasted parts will be moved the entire length of the pasted parts
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ if (!i->second->isSelected()) {
+ Part* part = i->second->part();
+ if (part->tick() >= startTicks) {
+ //void Audio::msgChangePart(Part* oldPart, Part* newPart, bool doUndoFlag, bool doCtrls, bool doClones)
+ Part *newPart = part->clone();
+ newPart->setTick(newPart->tick()+length);
+ if (part->track()->type() == Track::WAVE) {
+ audio->msgChangePart((WavePart*)part,(WavePart*)newPart,false,false,false);
+ } else {
+ audio->msgChangePart(part,newPart,false,false,false);
+ }
+
+ }
+ }
+ }
+ // perhaps ask if markers should be moved?
+ MarkerList *markerlist = song->marker();
+ for(iMarker i = markerlist->begin(); i != markerlist->end(); ++i)
+ {
+ Marker* m = &i->second;
+ if (m->tick() >= startTicks) {
+ Marker *oldMarker = new Marker();
+ *oldMarker = *m;
+ m->setTick(m->tick()+length);
+ song->undoOp(UndoOp::ModifyMarker,oldMarker, m);
+ }
+ }
+}
+//---------------------------------------------------------
+// startDrag
+//---------------------------------------------------------
+
+void PartCanvas::startDrag(CItem* item, DragType t)
+ {
+ //printf("PartCanvas::startDrag(CItem* item, DragType t)\n");
+ NPart* p = (NPart*)(item);
+ Part* part = p->part();
+
+ //---------------------------------------------------
+ // write part as XML into tmp file
+ //---------------------------------------------------
+
+ FILE* tmp = tmpfile();
+ if (tmp == 0) {
+ fprintf(stderr, "PartCanvas::startDrag() fopen failed: %s\n",
+ strerror(errno));
+ return;
+ }
+ Xml xml(tmp);
+ int level = 0;
+ part->write(level, xml);
+
+ //---------------------------------------------------
+ // read tmp file into QTextDrag Object
+ //---------------------------------------------------
+
+ fflush(tmp);
+ struct stat f_stat;
+ if (fstat(fileno(tmp), &f_stat) == -1) {
+ fprintf(stderr, "PartCanvas::startDrag fstat failed:<%s>\n",
+ strerror(errno));
+ fclose(tmp);
+ return;
+ }
+ int n = f_stat.st_size + 1;
+ char* fbuf = (char*)mmap(0, n, PROT_READ|PROT_WRITE,
+ MAP_PRIVATE, fileno(tmp), 0);
+ fbuf[n] = 0;
+
+ QByteArray data(fbuf);
+ QMimeData* md = new QMimeData();
+
+ md->setData("text/x-muse-partlist", data);
+
+ // "Note that setMimeData() assigns ownership of the QMimeData object to the QDrag object.
+ // The QDrag must be constructed on the heap with a parent QWidget to ensure that Qt can
+ // clean up after the drag and drop operation has been completed. "
+ QDrag* drag = new QDrag(this);
+ drag->setMimeData(md);
+
+ if (t == MOVE_COPY || t == MOVE_CLONE)
+ drag->exec(Qt::CopyAction);
+ else
+ drag->exec(Qt::MoveAction);
+
+ munmap(fbuf, n);
+ fclose(tmp);
+ }
+
+//---------------------------------------------------------
+// dragEnterEvent
+//---------------------------------------------------------
+
+void PartCanvas::dragEnterEvent(QDragEnterEvent* event)
+ {
+ ///event->accept(Q3TextDrag::canDecode(event));
+ event->acceptProposedAction(); // TODO CHECK Tim.
+ }
+
+//---------------------------------------------------------
+// dragMoveEvent
+//---------------------------------------------------------
+
+void PartCanvas::dragMoveEvent(QDragMoveEvent*)
+ {
+// printf("drag move %x\n", this);
+ //event->acceptProposedAction();
+ }
+
+//---------------------------------------------------------
+// dragLeaveEvent
+//---------------------------------------------------------
+
+void PartCanvas::dragLeaveEvent(QDragLeaveEvent*)
+ {
+// printf("drag leave\n");
+ //event->acceptProposedAction();
+ }
+
+//---------------------------------------------------------
+// dropEvent
+//---------------------------------------------------------
+
+void PartCanvas::viewDropEvent(QDropEvent* event)
+ {
+ //printf("void PartCanvas::viewDropEvent(QDropEvent* event)\n");
+ if (event->source() == this) {
+ printf("local DROP\n");
+ //event->ignore(); // TODO CHECK Tim.
+ return;
+ }
+ int type = 0; // 0 = unknown, 1 = partlist, 2 = uri-list
+ QString text;
+
+ if(event->mimeData()->hasFormat("text/partlist"))
+ type = 1;
+ else
+ //if(event->mimeData()->hasFormat("text/uri-list"))
+ if(event->mimeData()->hasUrls())
+ type = 2;
+ else
+ {
+ if(debugMsg && event->mimeData()->formats().size() != 0)
+ printf("Drop with unknown format. First format:<%s>\n", event->mimeData()->formats()[0].toLatin1().constData());
+ //event->ignore(); // TODO CHECK Tim.
+ return;
+ }
+
+ // Make a backup of the current clone list, to retain any 'copy' items,
+ // so that pasting works properly after.
+ CloneList copyCloneList = cloneList;
+ // Clear the clone list to prevent any dangerous associations with
+ // current non-original parts.
+ cloneList.clear();
+
+ if (type == 1)
+ {
+ text = QString(event->mimeData()->data("text/partlist"));
+
+ int x = AL::sigmap.raster(event->pos().x(), *_raster);
+ if (x < 0)
+ x = 0;
+ unsigned trackNo = y2pitch(event->pos().y());
+ Track* track = 0;
+ if (trackNo < tracks->size())
+ track = tracks->index(trackNo);
+ if (track) {
+ song->startUndo();
+ pasteAt(text, track, x);
+ song->endUndo(SC_PART_INSERTED);
+ }
+ }
+ else if (type == 2)
+ {
+ // Multiple urls not supported here. Grab the first one.
+ text = event->mimeData()->urls()[0].path();
+
+ if (text.endsWith(".wav",Qt::CaseInsensitive) ||
+ text.endsWith(".ogg",Qt::CaseInsensitive) ||
+ text.endsWith(".mpt", Qt::CaseInsensitive) )
+ {
+ int x = AL::sigmap.raster(event->pos().x(), *_raster);
+ if (x < 0)
+ x = 0;
+ unsigned trackNo = y2pitch(event->pos().y());
+ Track* track = 0;
+ if (trackNo < tracks->size())
+ track = tracks->index(trackNo);
+ if (track)
+ {
+ if (track->type() == Track::WAVE &&
+ (text.endsWith(".wav", Qt::CaseInsensitive) ||
+ (text.endsWith(".ogg", Qt::CaseInsensitive))))
+ {
+ unsigned tick = x;
+ muse->importWaveToTrack(text, tick, track);
+ }
+ // Changed by T356. Support mixed .mpt files.
+ else if ((track->isMidiTrack() || track->type() == Track::WAVE) && text.endsWith(".mpt", Qt::CaseInsensitive))
+ {
+ unsigned tick = x;
+ muse->importPartToTrack(text, tick, track);
+ }
+ }
+ }
+ else if(text.endsWith(".med",Qt::CaseInsensitive))
+ {
+ emit dropSongFile(text);
+ }
+ else if(text.endsWith(".mid",Qt::CaseInsensitive))
+ {
+ emit dropMidiFile(text);
+ }
+ else
+ {
+ printf("dropped... something... no hable...\n");
+ }
+ }
+
+ // Restore backup of the clone list, to retain any 'copy' items,
+ // so that pasting works properly after.
+ cloneList.clear();
+ cloneList = copyCloneList;
+ }
+
+//---------------------------------------------------------
+// drawCanvas
+//---------------------------------------------------------
+
+void PartCanvas::drawCanvas(QPainter& p, const QRect& rect)
+{
+ int x = rect.x();
+ int y = rect.y();
+ int w = rect.width();
+ int h = rect.height();
+
+ //////////
+ // GRID //
+ //////////
+ QColor baseColor(config.partCanvasBg.light(104));
+ p.setPen(baseColor);
+
+ //--------------------------------
+ // vertical lines
+ //-------------------------------
+ //printf("raster=%d\n", *_raster);
+ if (config.canvasShowGrid) {
+ int bar, beat;
+ unsigned tick;
+
+ AL::sigmap.tickValues(x, &bar, &beat, &tick);
+ for (;;) {
+ int xt = AL::sigmap.bar2tick(bar++, 0, 0);
+ if (xt >= x + w)
+ break;
+ if (!((bar-1) % 4))
+ p.setPen(baseColor.dark(115));
+ else
+ p.setPen(baseColor);
+ p.drawLine(xt, y, xt, y+h);
+
+ // append
+ int noDivisors=0;
+ if (*_raster == config.division *2) // 1/2
+ noDivisors=2;
+ else if (*_raster== config.division) // 1/4
+ noDivisors=4;
+ else if (*_raster==config.division/2) // 1/8
+ noDivisors=8;
+ else if (*_raster==config.division/4) // 1/16
+ noDivisors=16;
+ else if (*_raster==config.division/8) // 1/16
+ noDivisors=32;
+ else if (*_raster==config.division/16) // 1/16
+ noDivisors=64;
+
+ int r = *_raster;
+ int rr = rmapx(r);
+ if (*_raster > 1) {
+ while (rr < 4) {
+ r *= 2;
+ rr = rmapx(r);
+ noDivisors=noDivisors/2;
+ }
+ p.setPen(baseColor);
+ for (int t=1;t< noDivisors;t++)
+ p.drawLine(xt+r*t, y, xt+r*t, y+h);
+ }
+ }
+ }
+ //--------------------------------
+ // horizontal lines
+ //--------------------------------
+
+ TrackList* tl = song->tracks();
+ int yy = 0;
+ int th;
+ for (iTrack it = tl->begin(); it != tl->end(); ++it) {
+ if (yy > y + h)
+ break;
+ Track* track = *it;
+ th = track->height();
+ ///if (/*config.canvasShowGrid ||*/ !track->isMidiTrack()) {
+ if (config.canvasShowGrid && (track->isMidiTrack() || track->type() == Track::WAVE)) // Tim.
+ {
+ //printf("PartCanvas::drawCanvas track name:%s, y:%d h:%d\n", track->name().toLatin1().constData(), yy, th);
+ p.setPen(baseColor.dark(130));
+ ///p.drawLine(x, yy, x + w, yy);
+ p.drawLine(x, yy + th, x + w, yy + th); // Tim.
+ p.setPen(baseColor);
+ }
+ if (!track->isMidiTrack() && (track->type() != Track::WAVE)) {
+ QRect r = rect & QRect(x, yy, w, track->height());
+ drawAudioTrack(p, r, (AudioTrack*)track);
+ p.setPen(baseColor);
+ }
+ if (!track->isMidiTrack()) { // draw automation
+ QRect r = rect & QRect(x, yy, w, track->height());
+ drawAutomation(p, r, (AudioTrack*)track);
+ p.setPen(baseColor);
+
+ }
+ yy += track->height();
+ }
+}
+
+//---------------------------------------------------------
+// drawAudioTrack
+//---------------------------------------------------------
+
+void PartCanvas::drawAudioTrack(QPainter& p, const QRect& r, AudioTrack* /* t */)
+{
+ // NOTE: For one-pixel border use first line and don't bother with setCosmetic.
+ // For a two-pixel border use second line and MUST use setCosmetic! Tim.
+ QPen pen(Qt::black, 0, Qt::SolidLine);
+ //p.setPen(QPen(Qt::black, 2, Qt::SolidLine));
+ //pen.setCosmetic(true);
+ p.setPen(pen);
+ //p.setBrush(Qt::gray);
+ QColor c(Qt::gray);
+ c.setAlpha(config.globalAlphaBlend);
+ p.setBrush(c);
+
+ // Factor in pen stroking size:
+ //QRect rr(r);
+ //rr.setHeight(rr.height() -1);
+
+ p.drawRect(r);
+}
+
+//---------------------------------------------------------
+// drawAutomation
+//---------------------------------------------------------
+
+void PartCanvas::drawAutomation(QPainter& p, const QRect& r, AudioTrack *t)
+{
+// printf("drawAudioTrack %d x %d y %d w %d h %d\n",t, r.x(), r.y(), r.width(), r.height());
+ //int v2=r.x()+r.width();
+ //printf("v2=%d mapx=%d rmapx=%d mapxdev=%d rmapxdev=%d\n",v2, mapx(v2),rmapx(v2),mapxDev(v2),rmapxDev(v2));
+ //return;
+
+// p.setPen(QPen(Qt::black, 2, Qt::SolidLine));
+ int height=r.bottom()-r.top()-4; // limit height
+
+ CtrlListList* cll = t->controller();
+// QColor cols[10];
+// cols[0]=Qt::white;
+// cols[1]=Qt::red;
+// cols[2]=Qt::yellow;
+// cols[3]=Qt::black;
+// cols[4]=Qt::blue;
+ //int colIndex=0;
+ bool firstRun=true;
+ for(CtrlListList::iterator icll =cll->begin();icll!=cll->end();++icll)
+ {
+ //iCtrlList *icl = icll->second;
+ CtrlList *cl = icll->second;
+ if (cl->dontShow())
+ continue;
+ double prevVal;
+ iCtrl ic=cl->begin();
+ if (!cl->isVisible())
+ continue; // skip this iteration if this controller isn't in the visible list
+ p.setPen(QPen(cl->color(),1,Qt::SolidLine));
+
+ // First check that there ARE automation, ic == cl->end means no automation
+ if (ic != cl->end()) {
+ CtrlVal cvFirst = ic->second;
+ ic++;
+ int prevPos=cvFirst.frame;
+ prevVal = cvFirst.val;
+
+ // prepare prevVal
+ if (cl->id() == AC_VOLUME ) { // use db scale for volume
+ prevVal = (20.0*log10(cvFirst.val)+60) / 70.0; // represent volume between 0 and 1
+ if (prevVal < 0) prevVal = 0.0;
+ }
+ else {
+ // we need to set curVal between 0 and 1
+ double min, max;
+ cl->range(&min,&max);
+ prevVal = (prevVal- min)/(max-min);
+ }
+
+ for (; ic !=cl->end(); ++ic)
+ {
+ CtrlVal cv = ic->second;
+ double nextVal = cv.val; // was curVal
+ if (cl->id() == AC_VOLUME ) { // use db scale for volume
+ nextVal = (20.0*log10(cv.val)+60) / 70.0; // represent volume between 0 and 1
+ if (nextVal < 0) nextVal = 0.0;
+ }
+ else {
+ // we need to set curVal between 0 and 1
+ double min, max;
+ cl->range(&min,&max);
+ nextVal = (nextVal- min)/(max-min);
+ }
+ int leftX=tempomap.frame2tick(prevPos);
+ if (firstRun && leftX>r.x()) {
+ leftX=r.x();
+ }
+
+ p.drawLine( leftX,
+ (r.bottom()-2)-prevVal*height,
+ tempomap.frame2tick(cv.frame),
+ (r.bottom()-2)-nextVal*height);
+ firstRun=false;
+ //printf("draw line: %d %f %d %f\n",tempomap.frame2tick(lastPos),r.bottom()-lastVal*height,tempomap.frame2tick(cv.frame),r.bottom()-curVal*height);
+ prevPos=cv.frame;
+ prevVal=nextVal;
+ }
+ //printf("outer draw %f\n", cvFirst.val );
+ p.drawLine(tempomap.frame2tick(prevPos),
+ (r.bottom()-2)-prevVal*height,
+ r.x()+r.width(),
+ (r.bottom()-2)-prevVal*height);
+ //printf("draw last line: %d %f %d %f\n",tempomap.frame2tick(prevPos),(r.bottom()-2)-prevVal*height,tempomap.frame2tick(prevPos)+r.width(),(r.bottom()-2)-prevVal*height);
+ }
+ }
+}
+
+
+void PartCanvas::controllerChanged(Track* /* t */)
+{
+ redraw();
+}
diff --git a/attic/muse2-oom/muse2/muse/arranger/pcanvas.h b/attic/muse2-oom/muse2/muse/arranger/pcanvas.h
new file mode 100644
index 00000000..103b3d02
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/arranger/pcanvas.h
@@ -0,0 +1,139 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: pcanvas.h,v 1.11.2.4 2009/05/24 21:43:44 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __PCANVAS_H__
+#define __PCANVAS_H__
+
+#include "song.h"
+#include "canvas.h"
+#include "trackautomationview.h"
+
+class QDragMoveEvent;
+class QDropEvent;
+class QDragLeaveEvent;
+class QMouseEvent;
+class QKeyEvent;
+class QEvent;
+class QDragEnterEvent;
+
+#define beats 4
+
+//---------------------------------------------------------
+// NPart
+// ''visual'' Part
+// wraps Parts with additional information needed
+// for displaying
+//---------------------------------------------------------
+
+class NPart : public CItem {
+ public:
+ NPart(Part* e);
+ const QString name() const { return part()->name(); }
+ void setName(const QString& s) { part()->setName(s); }
+ Track* track() const { return part()->track(); }
+ };
+
+class QLineEdit;
+class MidiEditor;
+class QMenu;
+class Xml;
+
+//---------------------------------------------------------
+// PartCanvas
+//---------------------------------------------------------
+
+class PartCanvas : public Canvas {
+ int* _raster;
+ TrackList* tracks;
+
+ Part* resizePart;
+ QLineEdit* lineEditor;
+ NPart* editPart;
+ int curColorIndex;
+ bool editMode;
+
+ std::vector<TrackAutomationView*> automationViews;
+ Q_OBJECT
+ virtual void keyPress(QKeyEvent*);
+ virtual void mousePress(QMouseEvent*);
+ virtual void mouseMove(const QPoint&);
+ virtual void mouseRelease(const QPoint&);
+ virtual void viewMouseDoubleClickEvent(QMouseEvent*);
+ virtual void leaveEvent(QEvent*e);
+ virtual void drawItem(QPainter&, const CItem*, const QRect&);
+ virtual void drawMoving(QPainter&, const CItem*, const QRect&);
+ virtual void updateSelection();
+ virtual QPoint raster(const QPoint&) const;
+ virtual int y2pitch(int y) const;
+ virtual int pitch2y(int p) const;
+
+ virtual void moveCanvasItems(CItemList&, int, int, DragType, int*);
+ // Changed by T356.
+ //virtual bool moveItem(CItem*, const QPoint&, DragType, int*);
+ virtual bool moveItem(CItem*, const QPoint&, DragType);
+ virtual CItem* newItem(const QPoint&, int);
+ virtual void resizeItem(CItem*,bool);
+ virtual void newItem(CItem*,bool);
+ virtual bool deleteItem(CItem*);
+ virtual void startUndo(DragType);
+
+ virtual void endUndo(DragType, int);
+ virtual void startDrag(CItem*, DragType);
+ virtual void dragEnterEvent(QDragEnterEvent*);
+ virtual void dragMoveEvent(QDragMoveEvent*);
+ virtual void dragLeaveEvent(QDragLeaveEvent*);
+ virtual void viewDropEvent(QDropEvent*);
+
+ virtual QMenu* genItemPopup(CItem*);
+ virtual void itemPopup(CItem*, int, const QPoint&);
+
+ void glueItem(CItem* item);
+ void splitItem(CItem* item, const QPoint&);
+
+ void copy(PartList*);
+ void paste(bool clone = false, bool toTrack = true, bool doInsert=false);
+ int pasteAt(const QString&, Track*, unsigned int, bool clone = false, bool toTrack = true);
+ void movePartsTotheRight(unsigned int startTick, int length);
+ //Part* readClone(Xml&, Track*, bool toTrack = true);
+ void drawWavePart(QPainter&, const QRect&, WavePart*, const QRect&);
+ Track* y2Track(int) const;
+ void drawAudioTrack(QPainter& p, const QRect& r, AudioTrack* track);
+ void drawAutomation(QPainter& p, const QRect& r, AudioTrack* track);
+
+
+ protected:
+ virtual void drawCanvas(QPainter&, const QRect&);
+
+ signals:
+ void timeChanged(unsigned);
+ void tracklistChanged();
+ void dclickPart(Track*);
+ void selectionChanged();
+ void dropSongFile(const QString&);
+ void dropMidiFile(const QString&);
+ void setUsedTool(int);
+ void trackChanged(Track*);
+ void selectTrackAbove();
+ void selectTrackBelow();
+
+ void startEditor(PartList*, int);
+
+ private slots:
+ void returnPressed();
+
+ public:
+ enum { CMD_CUT_PART, CMD_COPY_PART, CMD_PASTE_PART, CMD_PASTE_CLONE_PART, CMD_PASTE_PART_TO_TRACK, CMD_PASTE_CLONE_PART_TO_TRACK,
+ CMD_INSERT_PART, CMD_INSERT_EMPTYMEAS };
+
+ PartCanvas(int* raster, QWidget* parent, int, int);
+ void partsChanged();
+ void cmd(int);
+ void controllerChanged(Track *t);
+ public slots:
+ void redirKeypress(QKeyEvent* e) { keyPress(e); }
+ };
+#endif
diff --git a/attic/muse2-oom/muse2/muse/arranger/tlist.cpp b/attic/muse2-oom/muse2/muse/arranger/tlist.cpp
new file mode 100644
index 00000000..02f742f7
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/arranger/tlist.cpp
@@ -0,0 +1,1595 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: tlist.cpp,v 1.31.2.31 2009/12/15 03:39:58 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+//#include "config.h"
+
+#include <cmath>
+
+#include <QKeyEvent>
+#include <QLineEdit>
+#include <QMenu>
+#include <QMessageBox>
+#include <QMouseEvent>
+#include <QPainter>
+#include <QPaintEvent>
+#include <QPixmap>
+#include <QResizeEvent>
+#include <QScrollBar>
+#include <QWheelEvent>
+
+#include "popupmenu.h"
+#include "globals.h"
+#include "icons.h"
+#include "scrollscale.h"
+#include "tlist.h"
+#include "xml.h"
+#include "mididev.h"
+#include "midiport.h"
+#include "midiseq.h"
+#include "comment.h"
+#include "track.h"
+#include "song.h"
+#include "header.h"
+#include "node.h"
+#include "audio.h"
+#include "instruments/minstrument.h"
+#include "app.h"
+#include "gconfig.h"
+#include "event.h"
+#include "midiedit/drummap.h"
+#include "synth.h"
+#include "config.h"
+
+#ifdef DSSI_SUPPORT
+#include "dssihost.h"
+#endif
+
+extern QMenu* populateAddSynth(QWidget* parent);
+
+static const int MIN_TRACKHEIGHT = 20;
+static const int WHEEL_DELTA = 120;
+
+//---------------------------------------------------------
+// TList
+//---------------------------------------------------------
+
+TList::TList(Header* hdr, QWidget* parent, const char* name)
+ : QWidget(parent) // Qt::WNoAutoErase | Qt::WResizeNoErase are no longer needed according to Qt4 doc
+ {
+ setBackgroundRole(QPalette::NoRole);
+ setAttribute(Qt::WA_NoSystemBackground);
+ setAttribute(Qt::WA_StaticContents);
+ // This is absolutely required for speed! Otherwise painfully slow because we get
+ // full rect paint events even on small scrolls! See help on QPainter::scroll().
+ setAttribute(Qt::WA_OpaquePaintEvent);
+
+ setObjectName(name);
+ ypos = 0;
+ editMode = false;
+ setFocusPolicy(Qt::StrongFocus);
+ setMouseTracking(true);
+ header = hdr;
+
+ _scroll = 0;
+ editTrack = 0;
+ editor = 0;
+ mode = NORMAL;
+
+ //setBackgroundMode(Qt::NoBackground); // ORCAN - FIXME
+ //setAttribute(Qt::WA_OpaquePaintEvent);
+ resizeFlag = false;
+
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+ connect(muse, SIGNAL(configChanged()), SLOT(redraw()));
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void TList::songChanged(int flags)
+ {
+ if (flags & (SC_MUTE | SC_SOLO | SC_RECFLAG | SC_TRACK_INSERTED
+ | SC_TRACK_REMOVED | SC_TRACK_MODIFIED | SC_ROUTE | SC_CHANNELS | SC_MIDI_TRACK_PROP))
+ redraw();
+ if (flags & (SC_TRACK_INSERTED | SC_TRACK_REMOVED | SC_TRACK_MODIFIED))
+ adjustScrollbar();
+ }
+
+//---------------------------------------------------------
+// drawCenteredPixmap
+// small helper function for "draw()" below
+//---------------------------------------------------------
+
+static void drawCenteredPixmap(QPainter& p, const QPixmap* pm, const QRect& r)
+ {
+ p.drawPixmap(r.x() + (r.width() - pm->width())/2, r.y() + (r.height() - pm->height())/2, *pm);
+ }
+
+//---------------------------------------------------------
+// paintEvent
+//---------------------------------------------------------
+
+void TList::paintEvent(QPaintEvent* ev)
+ {
+ paint(ev->rect());
+ }
+
+//---------------------------------------------------------
+// redraw
+//---------------------------------------------------------
+
+void TList::redraw()
+ {
+ update();
+ }
+
+//---------------------------------------------------------
+// redraw
+//---------------------------------------------------------
+
+void TList::redraw(const QRect& r)
+ {
+ update(r);
+ }
+
+//---------------------------------------------------------
+// paint
+//---------------------------------------------------------
+
+void TList::paint(const QRect& r)
+ {
+ if (!isVisible())
+ return;
+ QRect rect(r);
+ QPainter p(this);
+
+ if (bgPixmap.isNull())
+ p.fillRect(rect, config.trackBg);
+ else
+ p.drawTiledPixmap(rect, bgPixmap, QPoint(rect.x(), ypos + rect.y()));
+ p.setClipRegion(rect);
+
+ //printf("TList::paint hasClipping:%d\n", p.hasClipping()); // Tested true.
+
+ int y = rect.y();
+ int w = rect.width();
+ int h = rect.height();
+ int x1 = rect.x();
+ int x2 = rect.x() + w;
+
+ //---------------------------------------------------
+ // Tracks
+ //---------------------------------------------------
+
+ TrackList* l = song->tracks();
+ int idx = 0;
+ int yy = -ypos;
+ for (iTrack i = l->begin(); i != l->end(); ++idx, yy += (*i)->height(), ++i) {
+ Track* track = *i;
+ Track::TrackType type = track->type();
+ int trackHeight = track->height();
+ if (yy >= (y + h))
+ break;
+ if ((yy + trackHeight) < y)
+ continue;
+ //
+ // clear one row
+ //
+ QColor bg;
+ if (track->selected()) {
+ bg = config.selectTrackBg;
+ //p.setPen(palette().active().text());
+ p.setPen(config.selectTrackFg);
+ }
+ else {
+ switch(type) {
+ case Track::MIDI:
+ bg = config.midiTrackBg;
+ break;
+ case Track::DRUM:
+ bg = config.drumTrackBg;
+ break;
+ case Track::WAVE:
+ bg = config.waveTrackBg;
+ break;
+ case Track::AUDIO_OUTPUT:
+ bg = config.outputTrackBg;
+ break;
+ case Track::AUDIO_INPUT:
+ bg = config.inputTrackBg;
+ break;
+ case Track::AUDIO_GROUP:
+ bg = config.groupTrackBg;
+ break;
+ case Track::AUDIO_AUX:
+ bg = config.auxTrackBg;
+ break;
+ case Track::AUDIO_SOFTSYNTH:
+ bg = config.synthTrackBg;
+ break;
+ }
+ p.setPen(palette().color(QPalette::Active, QPalette::Text));
+ }
+ p.fillRect(x1, yy, w, trackHeight, bg);
+
+ int x = 0;
+ for (int index = 0; index < header->count(); ++index) {
+ int section = header->logicalIndex(index);
+ int w = header->sectionSize(section);
+ //QRect r = p.xForm(QRect(x+2, yy, w-4, trackHeight));
+ QRect r = p.combinedTransform().mapRect(QRect(x+2, yy, w-4, trackHeight));
+
+ switch (section) {
+ case COL_RECORD:
+ if (track->canRecord()) {
+ drawCenteredPixmap(p,
+ track->recordFlag() ? record_on_Icon : record_off_Icon, r);
+ }
+ break;
+ case COL_CLASS:
+ {
+ const QPixmap* pm = 0;
+ switch(type) {
+ case Track::MIDI:
+ pm = addtrack_addmiditrackIcon;
+ break;
+ case Track::DRUM:
+ pm = addtrack_drumtrackIcon;
+ break;
+ case Track::WAVE:
+ pm = addtrack_wavetrackIcon;
+ break;
+ case Track::AUDIO_OUTPUT:
+ pm = addtrack_audiooutputIcon;
+ break;
+ case Track::AUDIO_INPUT:
+ pm = addtrack_audioinputIcon;
+ break;
+ case Track::AUDIO_GROUP:
+ pm = addtrack_audiogroupIcon;
+ break;
+ case Track::AUDIO_AUX:
+ pm = addtrack_auxsendIcon;
+ break;
+ case Track::AUDIO_SOFTSYNTH:
+ //pm = waveIcon;
+ pm = synthIcon;
+ break;
+ }
+ drawCenteredPixmap(p, pm, r);
+ }
+ break;
+ case COL_MUTE:
+ if (track->off())
+ drawCenteredPixmap(p, offIcon, r);
+ else if (track->mute())
+ drawCenteredPixmap(p, editmuteSIcon, r);
+ break;
+ case COL_SOLO:
+ if(track->solo() && track->internalSolo())
+ drawCenteredPixmap(p, blacksqcheckIcon, r);
+ else
+ if(track->internalSolo())
+ drawCenteredPixmap(p, blacksquareIcon, r);
+ else
+ if (track->solo())
+ drawCenteredPixmap(p, bluedotIcon, r);
+ break;
+ case COL_TIMELOCK:
+ if (track->isMidiTrack()
+ && track->locked()) {
+ drawCenteredPixmap(p, lockIcon, r);
+ }
+ break;
+ case COL_NAME:
+ p.drawText(r, Qt::AlignVCenter|Qt::AlignLeft, track->name());
+ break;
+ case COL_OCHANNEL:
+ {
+ QString s;
+ int n;
+ if (track->isMidiTrack()) {
+ n = ((MidiTrack*)track)->outChannel() + 1;
+ }
+ else {
+ // show number of ports
+ n = ((WaveTrack*)track)->channels();
+ }
+ s.setNum(n);
+ p.drawText(r, Qt::AlignVCenter|Qt::AlignHCenter, s);
+ }
+ break;
+ case COL_OPORT:
+ {
+ QString s;
+ if (track->isMidiTrack()) {
+ int outport = ((MidiTrack*)track)->outPort();
+ s.sprintf("%d:%s", outport+1, midiPorts[outport].portname().toLatin1().constData());
+ }
+ // Added by Tim. p3.3.9
+
+ else
+ if(track->type() == Track::AUDIO_SOFTSYNTH)
+ {
+ MidiDevice* md = dynamic_cast<MidiDevice*>(track);
+ if(md)
+ {
+ int outport = md->midiPort();
+ if((outport >= 0) && (outport < MIDI_PORTS))
+ s.sprintf("%d:%s", outport+1, midiPorts[outport].portname().toLatin1().constData());
+ else
+ s = tr("<none>");
+ }
+ }
+
+ p.drawText(r, Qt::AlignVCenter|Qt::AlignLeft, s);
+ }
+ break;
+ case COL_AUTOMATION:
+ {
+ QString s="-";
+
+ if (!track->isMidiTrack()) {
+ int count = ((AudioTrack*)track)->controller()->size();
+ s.sprintf("%d viewed", count);
+ }
+
+
+ p.drawText(r, Qt::AlignVCenter|Qt::AlignLeft, s);
+ }
+ break;
+ default:
+ break;
+ }
+ x += header->sectionSize(section);
+ }
+ p.setPen(Qt::gray);
+ p.drawLine(x1, yy, x2, yy);
+ }
+ p.drawLine(x1, yy, x2, yy);
+
+ if (mode == DRAG) {
+ int yy = curY - dragYoff;
+ p.setPen(Qt::green);
+ p.drawLine(x1, yy, x2, yy);
+ p.drawLine(x1, yy + dragHeight, x2, yy+dragHeight);
+ }
+
+ //---------------------------------------------------
+ // draw vertical lines
+ //---------------------------------------------------
+
+ int n = header->count();
+ int xpos = 0;
+ p.setPen(Qt::gray);
+ for (int index = 0; index < n; index++) {
+ int section = header->logicalIndex(index);
+ xpos += header->sectionSize(section);
+ p.drawLine(xpos, 0, xpos, height());
+ }
+ }
+
+//---------------------------------------------------------
+// returnPressed
+//---------------------------------------------------------
+
+void TList::returnPressed()
+ {
+ editor->hide();
+ if (editor->text() != editTrack->name()) {
+ TrackList* tl = song->tracks();
+ for (iTrack i = tl->begin(); i != tl->end(); ++i) {
+ if ((*i)->name() == editor->text()) {
+ QMessageBox::critical(this,
+ tr("MusE: bad trackname"),
+ tr("please choose a unique track name"),
+ QMessageBox::Ok,
+ Qt::NoButton,
+ Qt::NoButton);
+ editTrack = 0;
+ setFocus();
+ return;
+ }
+ }
+ //Track* track = editTrack->clone();
+ Track* track = editTrack->clone(false);
+ editTrack->setName(editor->text());
+ audio->msgChangeTrack(track, editTrack);
+ }
+ editTrack = 0;
+ editMode = false;
+ setFocus();
+ }
+
+//---------------------------------------------------------
+// adjustScrollbar
+//---------------------------------------------------------
+
+void TList::adjustScrollbar()
+ {
+ int h = 0;
+ TrackList* l = song->tracks();
+ for (iTrack it = l->begin(); it != l->end(); ++it)
+ h += (*it)->height();
+ _scroll->setMaximum(h +30);
+ redraw();
+ }
+
+//---------------------------------------------------------
+// y2Track
+//---------------------------------------------------------
+
+Track* TList::y2Track(int y) const
+ {
+ TrackList* l = song->tracks();
+ int ty = 0;
+ for (iTrack it = l->begin(); it != l->end(); ++it) {
+ int h = (*it)->height();
+ if (y >= ty && y < ty + h)
+ return *it;
+ ty += h;
+ }
+ return 0;
+ }
+
+//---------------------------------------------------------
+// viewMouseDoubleClickEvent
+//---------------------------------------------------------
+
+void TList::mouseDoubleClickEvent(QMouseEvent* ev)
+ {
+ int x = ev->x();
+ int section = header->logicalIndexAt(x);
+ if (section == -1)
+ return;
+
+ Track* t = y2Track(ev->y() + ypos);
+
+ if (t) {
+ int colx = header->sectionPosition(section);
+ int colw = header->sectionSize(section);
+ int coly = t->y() - ypos;
+ int colh = t->height();
+
+ if (section == COL_NAME) {
+ editTrack = t;
+ if (editor == 0) {
+ editor = new QLineEdit(this);
+ /*connect(editor, SIGNAL(returnPressed()),
+ SLOT(returnPressed()));*/
+ editor->setFrame(true);
+ }
+ editor->setText(editTrack->name());
+ editor->end(false);
+ editor->setGeometry(colx, coly, colw, colh);
+ editMode = true;
+ editor->show();
+ }
+ else
+ mousePressEvent(ev);
+ }
+ }
+
+//---------------------------------------------------------
+// portsPopupMenu
+//---------------------------------------------------------
+
+void TList::portsPopupMenu(Track* t, int x, int y)
+ {
+ switch(t->type()) {
+ case Track::MIDI:
+ case Track::DRUM:
+ case Track::AUDIO_SOFTSYNTH:
+ {
+ MidiTrack* track = (MidiTrack*)t;
+
+ //QPopupMenu* p = midiPortsPopup(0);
+ MidiDevice* md = 0;
+ int port = -1;
+ if(t->type() == Track::AUDIO_SOFTSYNTH)
+ {
+ //MidiDevice* md = dynamic_cast<MidiDevice*>((SynthI*)t);
+ md = dynamic_cast<MidiDevice*>(t);
+ if(md)
+ port = md->midiPort();
+ }
+ else
+ port = track->outPort();
+
+ QMenu* p = midiPortsPopup(0, port);
+ QAction* act = p->exec(mapToGlobal(QPoint(x, y)), 0);
+ if (act) {
+ int n = act->data().toInt();
+ // Changed by T356.
+ //track->setOutPort(n);
+ //audio->msgSetTrackOutPort(track, n);
+
+ //song->update();
+ if (t->type() == Track::DRUM) {
+ bool change = QMessageBox::question(this, tr("Update drummap?"),
+ tr("Do you want to use same port for all instruments in the drummap?"),
+ tr("&Yes"), tr("&No"), QString::null, 0, 1);
+ audio->msgIdle(true);
+ if (!change)
+ {
+ // Delete all port controller events.
+ //audio->msgChangeAllPortDrumCtrlEvents(false);
+ song->changeAllPortDrumCtrlEvents(false);
+ track->setOutPort(n);
+
+ for (int i=0; i<DRUM_MAPSIZE; i++) //Remap all drum instruments to this port
+ drumMap[i].port = track->outPort();
+ // Add all port controller events.
+ //audio->msgChangeAllPortDrumCtrlEvents(true);
+ song->changeAllPortDrumCtrlEvents(true);
+ }
+ else
+ {
+ //audio->msgSetTrackOutPort(track, n);
+ track->setOutPortAndUpdate(n);
+ }
+ audio->msgIdle(false);
+ song->update();
+ }
+ else
+ if (t->type() == Track::AUDIO_SOFTSYNTH)
+ {
+ if(md != 0)
+ {
+ // Idling is already handled in msgSetMidiDevice.
+ //audio->msgIdle(true);
+
+ // Compiler complains if simple cast from Track to SynthI...
+ midiSeq->msgSetMidiDevice(&midiPorts[n], (midiPorts[n].device() == md) ? 0 : md);
+ muse->changeConfig(true); // save configuration file
+
+ //audio->msgIdle(false);
+ song->update();
+ }
+ }
+ else
+ {
+ audio->msgIdle(true);
+ //audio->msgSetTrackOutPort(track, n);
+ track->setOutPortAndUpdate(n);
+ audio->msgIdle(false);
+ song->update();
+ }
+ }
+ delete p;
+ }
+ break;
+
+ case Track::WAVE:
+ case Track::AUDIO_OUTPUT:
+ case Track::AUDIO_INPUT:
+ case Track::AUDIO_GROUP:
+ case Track::AUDIO_AUX: //TODO
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// oportPropertyPopupMenu
+//---------------------------------------------------------
+
+void TList::oportPropertyPopupMenu(Track* t, int x, int y)
+ {
+ // Added by Tim. p3.3.9
+ if(t->type() == Track::AUDIO_SOFTSYNTH)
+ {
+ SynthI* synth = (SynthI*)t;
+
+ QMenu* p = new QMenu;
+ QAction* act = p->addAction(tr("Show Gui"));
+ act->setCheckable(true);
+ //printf("synth hasgui %d, gui visible %d\n",synth->hasGui(), synth->guiVisible());
+ act->setEnabled(synth->hasGui());
+ act->setChecked(synth->guiVisible());
+
+ // If it has a gui but we don't have OSC, disable the action.
+ #ifndef OSC_SUPPORT
+ #ifdef DSSI_SUPPORT
+ if(dynamic_cast<DssiSynthIF*>(synth->sif()))
+ {
+ act->setChecked(false);
+ act->setEnabled(false);
+ }
+ #endif
+ #endif
+
+ QAction* ract = p->exec(mapToGlobal(QPoint(x, y)), 0);
+ if (ract == act) {
+ bool show = !synth->guiVisible();
+ audio->msgShowInstrumentGui(synth, show);
+ }
+ delete p;
+ return;
+ }
+
+
+ if (t->type() != Track::MIDI && t->type() != Track::DRUM)
+ return;
+ int oPort = ((MidiTrack*)t)->outPort();
+ MidiPort* port = &midiPorts[oPort];
+
+ QMenu* p = new QMenu;
+ QAction* act = p->addAction(tr("Show Gui"));
+ act->setCheckable(true);
+ //printf("synth hasgui %d, gui visible %d\n",port->hasGui(), port->guiVisible());
+ act->setEnabled(port->hasGui());
+ act->setChecked(port->guiVisible());
+
+ // If it has a gui but we don't have OSC, disable the action.
+ #ifndef OSC_SUPPORT
+ #ifdef DSSI_SUPPORT
+ MidiDevice* dev = port->device();
+ if(dev && dev->isSynti() && (dynamic_cast<DssiSynthIF*>(((SynthI*)dev)->sif())))
+ {
+ act->setChecked(false);
+ act->setEnabled(false);
+ }
+ #endif
+ #endif
+
+ QAction* ract = p->exec(mapToGlobal(QPoint(x, y)), 0);
+ if (ract == act) {
+ bool show = !port->guiVisible();
+ audio->msgShowInstrumentGui(port->instrument(), show);
+ }
+ delete p;
+
+ }
+
+//---------------------------------------------------------
+// tracklistChanged
+//---------------------------------------------------------
+
+void TList::tracklistChanged()
+ {
+ redraw();
+ }
+
+//---------------------------------------------------------
+// keyPressEvent
+//---------------------------------------------------------
+
+void TList::keyPressEvent(QKeyEvent* e)
+ {
+ if (editMode)
+ {
+ // First time we get a keypress event when lineedit is open is on the return key:
+ // -- Not true for Qt4. Modifier keys also send key events - Orcan
+ if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter)
+ {
+ returnPressed();
+ return;
+ }
+ else if ( e->key() == Qt::Key_Escape )
+ {
+ editor->hide();
+ editTrack = 0;
+ editMode = false;
+ setFocus();
+ return;
+ }
+ }
+ emit keyPressExt(e); //redirect keypress events to main app
+
+ // p4.0.10 Removed by Tim. keyPressExt are sent to part canvas, where they are
+ // ignored *only* if necessary.
+ //e->ignore();
+
+ /*
+ int key = e->key();
+ switch (key) {
+ case Key_Up:
+ moveSelection(-1);
+ break;
+ case Key_Down:
+ moveSelection(1);
+ break;
+ default:
+
+ break;
+ }
+ */
+ }
+
+//---------------------------------------------------------
+// moveSelection
+//---------------------------------------------------------
+
+void TList::moveSelection(int n)
+ {
+ TrackList* tracks = song->tracks();
+
+ // check for single selection
+ int nselect = 0;
+ for (iTrack t = tracks->begin(); t != tracks->end(); ++t)
+ if ((*t)->selected())
+ ++nselect;
+ if (nselect != 1)
+ return;
+ Track* selTrack = 0;
+ for (iTrack t = tracks->begin(); t != tracks->end(); ++t) {
+ iTrack s = t;
+ if ((*t)->selected()) {
+ selTrack = *t;
+ if (n > 0) {
+ while (n--) {
+ ++t;
+ if (t == tracks->end()) {
+ --t;
+ break;
+ }
+ }
+ }
+ else {
+ while (n++ != 0) {
+ if (t == tracks->begin())
+ break;
+ --t;
+ }
+ }
+ (*s)->setSelected(false);
+ (*t)->setSelected(true);
+
+ // rec enable track if expected
+ TrackList recd = getRecEnabledTracks();
+ if (recd.size() == 1 && config.moveArmedCheckBox) { // one rec enabled track, move rec enabled with selection
+ song->setRecordFlag((Track*)recd.front(),false);
+ song->setRecordFlag((*t),true);
+ }
+
+ if (editTrack && editTrack != *t)
+ returnPressed();
+ redraw();
+ break;
+ }
+ }
+ ///emit selectionChanged();
+ emit selectionChanged(selTrack);
+ }
+
+TrackList TList::getRecEnabledTracks()
+{
+ //printf("getRecEnabledTracks\n");
+ TrackList recEnabled;
+ TrackList* tracks = song->tracks();
+ for (iTrack t = tracks->begin(); t != tracks->end(); ++t) {
+ if ((*t)->recordFlag()) {
+ //printf("rec enabled track\n");
+ recEnabled.push_back(*t);
+ }
+ }
+ return recEnabled;
+}
+
+//---------------------------------------------------------
+// mousePressEvent
+//---------------------------------------------------------
+
+void TList::changeAutomation(QAction* act)
+{
+ printf("changeAutomation!\n");
+ if (editTrack->type() == Track::MIDI) {
+ printf("this is wrong, we can't edit automation for midi tracks from arranger yet!\n");
+ return;
+ }
+
+ CtrlListList* cll = ((AudioTrack*)editTrack)->controller();
+ int index=0;
+ for(CtrlListList::iterator icll =cll->begin();icll!=cll->end();++icll) {
+ if (act->data() == index++) { // got it, change state
+ CtrlList *cl = icll->second;
+ cl->setVisible(!cl->isVisible());
+ }
+ }
+ song->update(SC_TRACK_MODIFIED);
+}
+
+void TList::mousePressEvent(QMouseEvent* ev)
+ {
+ int x = ev->x();
+ int y = ev->y();
+ int button = ev->button();
+ bool shift = ((QInputEvent*)ev)->modifiers() & Qt::ShiftModifier;
+
+ Track* t = y2Track(y + ypos);
+
+ TrackColumn col = TrackColumn(header->logicalIndexAt(x));
+ if (t == 0) {
+ if (button == Qt::RightButton) {
+ QMenu* p = new QMenu;
+ //p->clear();
+ QAction* midi = p->addAction(*addtrack_addmiditrackIcon,
+ tr("Add Midi Track"));
+ midi->setData(Track::MIDI);
+ QAction* drum = p->addAction(*addtrack_drumtrackIcon,
+ tr("Add Drum Track"));
+ drum->setData(Track::DRUM);
+ QAction* wave = p->addAction(*addtrack_wavetrackIcon,
+ tr("Add Wave Track"));
+ wave->setData(Track::WAVE);
+ QAction* aoutput = p->addAction(*addtrack_audiooutputIcon,
+ tr("Add Output"));
+ aoutput->setData(Track::AUDIO_OUTPUT);
+ QAction* agroup = p->addAction(*addtrack_audiogroupIcon,
+ tr("Add Group"));
+ agroup->setData(Track::AUDIO_GROUP);
+ QAction* ainput = p->addAction(*addtrack_audioinputIcon,
+ tr("Add Input"));
+ ainput->setData(Track::AUDIO_INPUT);
+ QAction* aaux = p->addAction(*addtrack_auxsendIcon,
+ tr("Add Aux Send"));
+ aaux->setData(Track::AUDIO_AUX);
+
+ // Create a sub-menu and fill it with found synth types. Make p the owner.
+ QMenu* synp = populateAddSynth(p);
+ synp->setIcon(*synthIcon);
+ synp->setTitle(QT_TRANSLATE_NOOP("@default", "Add Synth"));
+
+ // Add the 'Add Synth' sub-menu to the menu.
+ p->addMenu(synp);
+
+ // Show the menu
+ QAction* act = p->exec(ev->globalPos(), 0);
+
+ // Valid click?
+ if(act)
+ {
+ int n = act->data().toInt();
+ // Valid item?
+ if((n >= 0) && ((Track::TrackType)n != Track::AUDIO_SOFTSYNTH))
+ {
+ // Synth sub-menu id?
+ if(n >= MENU_ADD_SYNTH_ID_BASE)
+ {
+ n -= MENU_ADD_SYNTH_ID_BASE;
+ //if(n < synthis.size())
+ // t = song->createSynthI(synthis[n]->baseName());
+ //if((n - MENU_ADD_SYNTH_ID_BASE) < (int)synthis.size())
+ if(n < (int)synthis.size())
+ {
+ //t = song->createSynthI(synp->text(n));
+ //t = song->createSynthI(synthis[n]->name());
+ t = song->createSynthI(synthis[n]->baseName(), synthis[n]->name());
+
+ if(t)
+ {
+ // Add instance last in midi device list.
+ for (int i = 0; i < MIDI_PORTS; ++i)
+ {
+ MidiPort* port = &midiPorts[i];
+ MidiDevice* dev = port->device();
+ if (dev==0)
+ {
+ midiSeq->msgSetMidiDevice(port, (SynthI*)t);
+ muse->changeConfig(true); // save configuration file
+ song->update();
+ break;
+ }
+ }
+ }
+ }
+ }
+ // Normal track.
+ else
+ t = song->addTrack((Track::TrackType)n);
+
+ if(t)
+ {
+ song->deselectTracks();
+ t->setSelected(true);
+
+ ///emit selectionChanged();
+ emit selectionChanged(t);
+ adjustScrollbar();
+ }
+ }
+ }
+
+ // Just delete p, and all its children will go too, right?
+ //delete synp;
+ delete p;
+ }
+ return;
+ }
+
+ TrackList* tracks = song->tracks();
+ dragYoff = y - (t->y() - ypos);
+ startY = y;
+
+ if (resizeFlag) {
+ mode = RESIZE;
+ int y = ev->y();
+ int ty = -ypos;
+ sTrack = 0;
+ for (iTrack it = tracks->begin(); it != tracks->end(); ++it, ++sTrack) {
+ int h = (*it)->height();
+ ty += h;
+ if (y >= (ty-2)) {
+
+ if ( (*it) == tracks->back() && y > ty ) {
+ //printf("tracks->back() && y > ty\n");
+ }
+ else if ( y > (ty+2) ) {
+ //printf(" y > (ty+2) \n");
+ }
+ else {
+ //printf("ogga ogga\n");
+
+ break;
+ }
+
+
+ //&& y < (ty))
+ // break;
+ }
+ }
+
+ return;
+ }
+ mode = START_DRAG;
+
+ switch (col) {
+ case COL_AUTOMATION:
+ {
+ if (t->type() != Track::MIDI) {
+ editTrack = t;
+ PopupMenu* p = new PopupMenu();
+ p->disconnect();
+ p->clear();
+ p->setTitle(tr("Viewable automation"));
+ CtrlListList* cll = ((AudioTrack*)t)->controller();
+ QAction* act = 0;
+ int index=0;
+ for(CtrlListList::iterator icll =cll->begin();icll!=cll->end();++icll) {
+ CtrlList *cl = icll->second;
+ if (cl->dontShow())
+ continue;
+ act = p->addAction(cl->name());
+ act->setCheckable(true);
+ act->setChecked(cl->isVisible());
+ act->setData(index++);
+ }
+ connect(p, SIGNAL(triggered(QAction*)), SLOT(changeAutomation(QAction*)));
+ //connect(p, SIGNAL(aboutToHide()), muse, SLOT(routingPopupMenuAboutToHide()));
+ //p->popup(QCursor::pos());
+ p->exec(QCursor::pos());
+
+ delete p;
+ }
+ break;
+ }
+
+ case COL_RECORD:
+ {
+ bool val = !(t->recordFlag());
+ if (button == Qt::LeftButton) {
+ if (!t->isMidiTrack()) {
+ if (t->type() == Track::AUDIO_OUTPUT) {
+ if (val && t->recordFlag() == false) {
+ muse->bounceToFile((AudioOutput*)t);
+ }
+ audio->msgSetRecord((AudioOutput*)t, val);
+ if (!((AudioOutput*)t)->recFile())
+ val = false;
+ else
+ return;
+ }
+ song->setRecordFlag(t, val);
+ }
+ else
+ song->setRecordFlag(t, val);
+ } else if (button == Qt::RightButton) {
+ // enable or disable ALL tracks of this type
+ if (!t->isMidiTrack()) {
+ if (t->type() == Track::AUDIO_OUTPUT) {
+ return;
+ }
+ WaveTrackList* wtl = song->waves();
+ foreach (WaveTrack *wt, *wtl) {
+ song->setRecordFlag(wt, val);
+ }
+ }
+ else {
+ MidiTrackList* mtl = song->midis();
+ foreach (MidiTrack *mt, *mtl) {
+ song->setRecordFlag(mt, val);
+ }
+ }
+ }
+ }
+ break;
+ case COL_NONE:
+ break;
+ case COL_CLASS:
+ if (t->isMidiTrack())
+ classesPopupMenu(t, x, t->y() - ypos);
+ break;
+ case COL_OPORT:
+ // Changed by Tim. p3.3.9
+ // Reverted.
+ if (button == Qt::LeftButton)
+ portsPopupMenu(t, x, t->y() - ypos);
+ else if (button == Qt::RightButton)
+ oportPropertyPopupMenu(t, x, t->y() - ypos);
+ //if(((button == QMouseEvent::LeftButton) && (t->type() == Track::AUDIO_SOFTSYNTH)) || (button == QMouseEvent::RightButton))
+ // oportPropertyPopupMenu(t, x, t->y() - ypos);
+ //else
+ //if(button == QMouseEvent::LeftButton)
+ // portsPopupMenu(t, x, t->y() - ypos);
+
+ break;
+ case COL_MUTE:
+ // p3.3.29
+ if ((button == Qt::RightButton) || (((QInputEvent*)ev)->modifiers() & Qt::ControlModifier))
+ t->setOff(!t->off());
+ else
+ {
+ if (t->off())
+ t->setOff(false);
+ else
+ t->setMute(!t->mute());
+ }
+ song->update(SC_MUTE);
+ break;
+ case COL_SOLO:
+ audio->msgSetSolo(t, !t->solo());
+ song->update(SC_SOLO);
+ break;
+
+ case COL_NAME:
+ if (button == Qt::LeftButton) {
+ if (!shift) {
+ song->deselectTracks();
+ t->setSelected(true);
+
+ // rec enable track if expected
+ TrackList recd = getRecEnabledTracks();
+ if (recd.size() == 1 && config.moveArmedCheckBox) { // one rec enabled track, move rec enabled with selection
+ song->setRecordFlag((Track*)recd.front(),false);
+ song->setRecordFlag(t,true);
+ }
+ }
+ else
+ t->setSelected(!t->selected());
+ if (editTrack && editTrack != t)
+ returnPressed();
+ ///emit selectionChanged();
+ emit selectionChanged(t->selected() ? t : 0);
+ }
+ else if (button == Qt::RightButton) {
+ mode = NORMAL;
+ QMenu* p = new QMenu;
+ //p->clear();
+ p->addAction(QIcon(*automation_clear_dataIcon), tr("Delete Track"))->setData(0);
+ p->addAction(QIcon(*track_commentIcon), tr("Track Comment"))->setData(1);
+ QAction* act = p->exec(ev->globalPos(), 0);
+ if (act) {
+ int n = act->data().toInt();
+ switch (n) {
+ case 0: // delete track
+ song->removeTrack0(t);
+ audio->msgUpdateSoloStates();
+ break;
+
+ case 1: // show track comment
+ {
+ TrackComment* tc = new TrackComment(t, 0);
+ tc->show();
+ //QToolTip::add( this, "FOOOOOOOOOOOOO" );
+ }
+ break;
+
+ default:
+ printf("action %d\n", n);
+ break;
+ }
+
+ }
+ delete p;
+ }
+ break;
+
+ case COL_TIMELOCK:
+ t->setLocked(!t->locked());
+ break;
+
+ case COL_OCHANNEL:
+ {
+ int delta = 0;
+ if (button == Qt::RightButton)
+ delta = 1;
+ else if (button == Qt::MidButton)
+ delta = -1;
+ if (t->isMidiTrack())
+ {
+ MidiTrack* mt = dynamic_cast<MidiTrack*>(t);
+ if (mt == 0)
+ break;
+
+ int channel = mt->outChannel();
+ channel += delta;
+ if(channel >= MIDI_CHANNELS)
+ channel = MIDI_CHANNELS - 1;
+ if(channel < 0)
+ channel = 0;
+ //if (channel != ((MidiTrack*)t)->outChannel())
+ if (channel != mt->outChannel())
+ {
+ // Changed by T356.
+ //mt->setOutChannel(channel);
+ audio->msgIdle(true);
+ //audio->msgSetTrackOutChannel(mt, channel);
+ mt->setOutChanAndUpdate(channel);
+ audio->msgIdle(false);
+
+ /* --- I really don't like this, you can mess up the whole map "as easy as dell"
+ if (mt->type() == MidiTrack::DRUM) {//Change channel on all drum instruments
+ for (int i=0; i<DRUM_MAPSIZE; i++)
+ drumMap[i].channel = channel;
+ }*/
+
+ // may result in adding/removing mixer strip:
+ //song->update(-1);
+ //song->update(SC_CHANNELS);
+ song->update(SC_MIDI_TRACK_PROP);
+ }
+ }
+ else
+ {
+ if(t->type() != Track::AUDIO_SOFTSYNTH)
+ {
+ AudioTrack* at = dynamic_cast<AudioTrack*>(t);
+ if (at == 0)
+ break;
+
+ int n = t->channels() + delta;
+ if (n > MAX_CHANNELS)
+ n = MAX_CHANNELS;
+ else if (n < 1)
+ n = 1;
+ if (n != t->channels()) {
+ audio->msgSetChannels(at, n);
+ song->update(SC_CHANNELS);
+ }
+ }
+ }
+ }
+ break;
+ }
+ redraw();
+ }
+
+//---------------------------------------------------------
+// selectTrack
+//---------------------------------------------------------
+void TList::selectTrack(Track* tr)
+ {
+ song->deselectTracks();
+ tr->setSelected(true);
+
+
+ // rec enable track if expected
+ TrackList recd = getRecEnabledTracks();
+ if (recd.size() == 1 && config.moveArmedCheckBox) { // one rec enabled track, move rec enabled with selection
+ song->setRecordFlag((Track*)recd.front(),false);
+ song->setRecordFlag(tr,true);
+ }
+
+ // By T356. Force a redraw for wave tracks, since it does not seem to happen.
+ //if(!tr->isMidiTrack())
+ redraw();
+ ///emit selectionChanged();
+ emit selectionChanged(tr);
+ }
+
+//---------------------------------------------------------
+// selectTrackAbove
+//---------------------------------------------------------
+void TList::selectTrackAbove()
+{
+ moveSelection(-1);
+}
+//---------------------------------------------------------
+// selectTrackBelow
+//---------------------------------------------------------
+void TList::selectTrackBelow()
+{
+ moveSelection(1);
+}
+
+//---------------------------------------------------------
+// mouseMoveEvent
+//---------------------------------------------------------
+
+void TList::mouseMoveEvent(QMouseEvent* ev)
+ {
+ if ((((QInputEvent*)ev)->modifiers() | ev->buttons()) == 0) {
+ int y = ev->y();
+ int ty = -ypos;
+ TrackList* tracks = song->tracks();
+ iTrack it;
+ for (it = tracks->begin(); it != tracks->end(); ++it) {
+ int h = (*it)->height();
+ ty += h;
+ if (y >= (ty-2)) {
+ if ( (*it) == tracks->back() && y >= ty ) {
+ // outside last track don't change to splitVCursor
+ }
+ else if ( y > (ty+2) ) {
+ //printf(" y > (ty+2) \n");
+ }
+ else {
+ if (!resizeFlag) {
+ resizeFlag = true;
+ setCursor(QCursor(Qt::SplitVCursor));
+ }
+ break;
+ }
+ }
+ }
+ if (it == tracks->end() && resizeFlag) {
+ setCursor(QCursor(Qt::ArrowCursor));
+ resizeFlag = false;
+ }
+ return;
+ }
+ curY = ev->y();
+ int delta = curY - startY;
+ switch (mode) {
+ case START_DRAG:
+ if (delta < 0)
+ delta = -delta;
+ if (delta <= 2)
+ break;
+ {
+ Track* t = y2Track(startY + ypos);
+ if (t == 0)
+ mode = NORMAL;
+ else {
+ mode = DRAG;
+ dragHeight = t->height();
+ sTrack = song->tracks()->index(t);
+ setCursor(QCursor(Qt::SizeVerCursor));
+ redraw();
+ }
+ }
+ break;
+ case NORMAL:
+ break;
+ case DRAG:
+ redraw();
+ break;
+ case RESIZE:
+ {
+ if(sTrack >= 0 && (unsigned) sTrack < song->tracks()->size())
+ {
+ Track* t = song->tracks()->index(sTrack);
+ if(t)
+ {
+ int h = t->height() + delta;
+ startY = curY;
+ if (h < MIN_TRACKHEIGHT)
+ h = MIN_TRACKHEIGHT;
+ t->setHeight(h);
+ song->update(SC_TRACK_MODIFIED);
+ }
+ }
+ }
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// mouseReleaseEvent
+//---------------------------------------------------------
+
+void TList::mouseReleaseEvent(QMouseEvent* ev)
+ {
+ if (mode == DRAG) {
+ Track* t = y2Track(ev->y() + ypos);
+ if (t) {
+ int dTrack = song->tracks()->index(t);
+ audio->msgMoveTrack(sTrack, dTrack);
+ }
+ }
+ if (mode != NORMAL) {
+ mode = NORMAL;
+ setCursor(QCursor(Qt::ArrowCursor));
+ redraw();
+ }
+ if (editTrack && editor && editor->isVisible())
+ editor->setFocus();
+ adjustScrollbar();
+ }
+
+//---------------------------------------------------------
+// wheelEvent
+//---------------------------------------------------------
+
+void TList::wheelEvent(QWheelEvent* ev)
+ {
+ int x = ev->x();
+ int y = ev->y();
+ Track* t = y2Track(y + ypos);
+ if (t == 0) {
+ emit redirectWheelEvent(ev);
+ return;
+ }
+ TrackColumn col = TrackColumn(header->logicalIndexAt(x));
+ int delta = ev->delta() / WHEEL_DELTA;
+ ev->accept();
+
+ switch (col) {
+ case COL_RECORD:
+ case COL_NONE:
+ case COL_CLASS:
+ case COL_NAME:
+ case COL_AUTOMATION:
+ break;
+ case COL_MUTE:
+ // p3.3.29
+ if (((QInputEvent*)ev)->modifiers() & Qt::ControlModifier)
+ t->setOff(!t->off());
+ else
+ {
+ if (t->off())
+ t->setOff(false);
+ else
+ t->setMute(!t->mute());
+ }
+ song->update(SC_MUTE);
+ break;
+
+ case COL_SOLO:
+ audio->msgSetSolo(t, !t->solo());
+ song->update(SC_SOLO);
+ break;
+
+ case COL_TIMELOCK:
+ t->setLocked(!t->locked());
+ break;
+
+ case COL_OPORT:
+ if (t->isMidiTrack()) {
+ MidiTrack* mt = (MidiTrack*)t;
+ int port = mt->outPort() + delta;
+
+ if (port >= MIDI_PORTS)
+ port = MIDI_PORTS-1;
+ else if (port < 0)
+ port = 0;
+ if (port != ((MidiTrack*)t)->outPort()) {
+ // Changed by T356.
+ //mt->setOutPort(port);
+ audio->msgIdle(true);
+ //audio->msgSetTrackOutPort(mt, port);
+ mt->setOutPortAndUpdate(port);
+ audio->msgIdle(false);
+
+ song->update(SC_ROUTE);
+ }
+ }
+ break;
+
+ case COL_OCHANNEL:
+ if (t->isMidiTrack()) {
+ MidiTrack* mt = (MidiTrack*)t;
+ int channel = mt->outChannel() + delta;
+
+ if (channel >= MIDI_CHANNELS)
+ channel = MIDI_CHANNELS-1;
+ else if (channel < 0)
+ channel = 0;
+ if (channel != ((MidiTrack*)t)->outChannel()) {
+ // Changed by T356.
+ //mt->setOutChannel(channel);
+ audio->msgIdle(true);
+ //audio->msgSetTrackOutChannel(mt, channel);
+ mt->setOutChanAndUpdate(channel);
+ audio->msgIdle(false);
+
+ // may result in adding/removing mixer strip:
+ //song->update(-1);
+ song->update(SC_MIDI_TRACK_PROP);
+ }
+ }
+ else {
+ int n = t->channels() + delta;
+ if (n > MAX_CHANNELS)
+ n = MAX_CHANNELS;
+ else if (n < 1)
+ n = 1;
+ if (n != t->channels()) {
+ audio->msgSetChannels((AudioTrack*)t, n);
+ song->update(SC_CHANNELS);
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// writeStatus
+//---------------------------------------------------------
+
+void TList::writeStatus(int level, Xml& xml, const char* name) const
+ {
+ xml.tag(level++, name);
+ header->writeStatus(level, xml);
+ xml.etag(level, name);
+ }
+
+//---------------------------------------------------------
+// readStatus
+//---------------------------------------------------------
+
+void TList::readStatus(Xml& xml, const char* name)
+ {
+ for (;;) {
+ Xml::Token token(xml.parse());
+ const QString& tag(xml.s1());
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == header->objectName())
+ header->readStatus(xml);
+ else
+ xml.unknown("Tlist");
+ break;
+ case Xml::TagEnd:
+ if (tag == name)
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// setYPos
+//---------------------------------------------------------
+
+void TList::setYPos(int y)
+ {
+ int delta = ypos - y; // - -> shift up
+ ypos = y;
+
+ scroll(0, delta);
+ }
+
+//---------------------------------------------------------
+// resizeEvent
+//---------------------------------------------------------
+
+void TList::resizeEvent(QResizeEvent* /*ev*/)
+ {
+
+ }
+
+//---------------------------------------------------------
+// classesPopupMenu
+//---------------------------------------------------------
+
+void TList::classesPopupMenu(Track* t, int x, int y)
+ {
+ QMenu p;
+ p.clear();
+ p.addAction(QIcon(*addtrack_addmiditrackIcon), tr("Midi"))->setData(Track::MIDI);
+ p.addAction(QIcon(*addtrack_drumtrackIcon), tr("Drum"))->setData(Track::DRUM);
+ QAction* act = p.exec(mapToGlobal(QPoint(x, y)), 0);
+
+ if (!act)
+ return;
+
+ int n = act->data().toInt();
+ if (Track::TrackType(n) == Track::MIDI && t->type() == Track::DRUM) {
+ //
+ // Drum -> Midi
+ //
+ audio->msgIdle(true);
+ PartList* pl = t->parts();
+ MidiTrack* m = (MidiTrack*) t;
+ for (iPart ip = pl->begin(); ip != pl->end(); ++ip) {
+ EventList* el = ip->second->events();
+ for (iEvent ie = el->begin(); ie != el->end(); ++ie) {
+ Event ev = ie->second;
+ if(ev.type() == Note)
+ {
+ int pitch = ev.pitch();
+ // Changed by T356.
+ // Tested: Notes were being mixed up switching back and forth between midi and drum.
+ //pitch = drumMap[pitch].anote;
+ pitch = drumMap[pitch].enote;
+
+ ev.setPitch(pitch);
+ }
+ else
+ if(ev.type() == Controller)
+ {
+ int ctl = ev.dataA();
+ // Is it a drum controller event, according to the track port's instrument?
+ MidiController *mc = midiPorts[m->outPort()].drumController(ctl);
+ if(mc)
+ // Change the controller event's index into the drum map to an instrument note.
+ ev.setA((ctl & ~0xff) | drumMap[ctl & 0x7f].enote);
+ }
+
+ }
+ }
+ t->setType(Track::MIDI);
+ audio->msgIdle(false);
+ }
+ else if (Track::TrackType(n) == Track::DRUM && t->type() == Track::MIDI) {
+ //
+ // Midi -> Drum
+ //
+ bool change = QMessageBox::question(this, tr("Update drummap?"),
+ tr("Do you want to use same port and channel for all instruments in the drummap?"),
+ tr("&Yes"), tr("&No"), QString::null, 0, 1);
+
+ audio->msgIdle(true);
+ // Delete all port controller events.
+ //audio->msgChangeAllPortDrumCtrlEvents(false);
+ song->changeAllPortDrumCtrlEvents(false);
+
+ if (!change) {
+ MidiTrack* m = (MidiTrack*) t;
+ for (int i=0; i<DRUM_MAPSIZE; i++) {
+ drumMap[i].channel = m->outChannel();
+ drumMap[i].port = m->outPort();
+ }
+ }
+
+ //audio->msgIdle(true);
+ PartList* pl = t->parts();
+ MidiTrack* m = (MidiTrack*) t;
+ for (iPart ip = pl->begin(); ip != pl->end(); ++ip) {
+ EventList* el = ip->second->events();
+ for (iEvent ie = el->begin(); ie != el->end(); ++ie) {
+ Event ev = ie->second;
+ if (ev.type() == Note)
+ {
+ int pitch = ev.pitch();
+ pitch = drumInmap[pitch];
+ ev.setPitch(pitch);
+ }
+ else
+ {
+ if(ev.type() == Controller)
+ {
+ int ctl = ev.dataA();
+ // Is it a drum controller event, according to the track port's instrument?
+ MidiController *mc = midiPorts[m->outPort()].drumController(ctl);
+ if(mc)
+ // Change the controller event's instrument note to an index into the drum map.
+ ev.setA((ctl & ~0xff) | drumInmap[ctl & 0x7f]);
+ }
+
+ }
+
+ }
+ }
+ t->setType(Track::DRUM);
+
+ // Add all port controller events.
+ //audio->msgChangeAllPortDrumCtrlEvents(true);
+ song->changeAllPortDrumCtrlEvents(true);
+
+ audio->msgIdle(false);
+ }
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/arranger/tlist.h b/attic/muse2-oom/muse2/muse/arranger/tlist.h
new file mode 100644
index 00000000..188685bc
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/arranger/tlist.h
@@ -0,0 +1,115 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: tlist.h,v 1.8.2.5 2008/01/19 13:33:46 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __TLIST_H__
+#define __TLIST_H__
+
+#include "track.h"
+
+#include <QWidget>
+
+class QKeyEvent;
+class QLineEdit;
+class QMouseEvent;
+class QPaintEvent;
+class QResizeEvent;
+class QScrollBar;
+class QWheelEvent;
+
+class ScrollScale;
+class Track;
+class Xml;
+class Header;
+
+enum TrackColumn {
+ COL_RECORD = 0,
+ COL_MUTE,
+ COL_SOLO,
+ COL_CLASS,
+ COL_NAME,
+ COL_OPORT,
+ COL_OCHANNEL,
+ COL_TIMELOCK,
+ COL_AUTOMATION,
+ COL_NONE = -1
+ };
+
+//---------------------------------------------------------
+// TList
+//---------------------------------------------------------
+
+class TList : public QWidget {
+ Q_OBJECT
+
+ int ypos;
+ bool editMode;
+
+ QPixmap bgPixmap; // background Pixmap
+ bool resizeFlag; // true if resize cursor is shown
+
+ Header* header;
+ QScrollBar* _scroll;
+ QLineEdit* editor;
+ Track* editTrack;
+
+ int startY;
+ int curY;
+ int sTrack;
+ int dragHeight;
+ int dragYoff;
+
+ enum { NORMAL, START_DRAG, DRAG, RESIZE} mode;
+
+ virtual void paintEvent(QPaintEvent*);
+ virtual void mousePressEvent(QMouseEvent* event);
+ virtual void mouseDoubleClickEvent(QMouseEvent*);
+ virtual void mouseMoveEvent(QMouseEvent*);
+ virtual void mouseReleaseEvent(QMouseEvent*);
+ virtual void keyPressEvent(QKeyEvent* e);
+ virtual void wheelEvent(QWheelEvent* e);
+
+ void portsPopupMenu(Track*, int, int);
+ void oportPropertyPopupMenu(Track*, int x, int y);
+ void moveSelection(int n);
+ void adjustScrollbar();
+ void paint(const QRect& r);
+ virtual void resizeEvent(QResizeEvent*);
+ void redraw(const QRect& r);
+ Track* y2Track(int) const;
+ void classesPopupMenu(Track*, int x, int y);
+ TrackList getRecEnabledTracks();
+ void setHeaderToolTips();
+
+ private slots:
+ void returnPressed();
+ void songChanged(int flags);
+ void changeAutomation(QAction*);
+
+ signals:
+ ///void selectionChanged();
+ void selectionChanged(Track*);
+ void keyPressExt(QKeyEvent*);
+ void redirectWheelEvent(QWheelEvent*);
+
+ public slots:
+ void tracklistChanged();
+ void setYPos(int);
+ void redraw();
+ void selectTrack(Track*);
+ void selectTrackAbove();
+ void selectTrackBelow();
+
+ public:
+ TList(Header*, QWidget* parent, const char* name);
+ void setScroll(QScrollBar* s) { _scroll = s; }
+ Track* track() const { return editTrack; }
+ void writeStatus(int level, Xml&, const char* name) const;
+ void readStatus(Xml&, const char* name);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/arranger/trackautomationview.cpp b/attic/muse2-oom/muse2/muse/arranger/trackautomationview.cpp
new file mode 100644
index 00000000..8f7cfb12
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/arranger/trackautomationview.cpp
@@ -0,0 +1,52 @@
+#include "trackautomationview.h"
+#include "math.h"
+
+#include <QPainter>
+#include <QPaintEvent>
+
+#include "track.h"
+
+TrackAutomationView::TrackAutomationView(QWidget *parent, Track *t) : QWidget(parent)
+{
+ printf("created trackautomationview\n");
+ _t = t;
+ //show();
+}
+
+void TrackAutomationView::paintEvent(QPaintEvent* e)
+{
+ QPainter p(this);
+ const QRect &r = e->rect();
+
+ // temporary solution, audio track drawing moved here.
+ // best would be to get transparency to work correctly
+ p.setPen(QPen(Qt::black, 2, Qt::SolidLine));
+ p.setBrush(Qt::gray);
+ p.drawRect(r);
+
+ int height=r.bottom()-r.top();
+ if( _t->type()>1) { // audio type
+ double volume = ((AudioTrack*)_t)->volume();
+ double dbvolume = (20.0*log10(volume)+60) /70.0; // represent volume between 0 and 1
+ if (dbvolume < 0) dbvolume =0.0;
+ printf("height=%d volume=%f dbvolume=%f\n", height, volume, dbvolume);
+ p.setPen(QPen(Qt::yellow,1,Qt::SolidLine));
+ p.drawLine(r.left(),r.bottom()-dbvolume*height,r.right(),r.bottom()-dbvolume*height);
+
+ }
+
+
+
+ printf("paintEvent\n");
+}
+
+void TrackAutomationView::collectAutomationData()
+{
+ // here we should collect all automation data that is currently selected for viewing and
+ // prepare an event list that is easy to draw in paintEvent
+ // the main reason being that the event list in it's entirety likely contains too much data to
+ // be processed in the paintEvent. Better to preprocess.
+
+// CtrlListList cll =((AudioTrack*)_t)->controller();
+// cll.count()
+}
diff --git a/attic/muse2-oom/muse2/muse/arranger/trackautomationview.h b/attic/muse2-oom/muse2/muse/arranger/trackautomationview.h
new file mode 100644
index 00000000..2ef05125
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/arranger/trackautomationview.h
@@ -0,0 +1,20 @@
+#ifndef TRACKAUTOMATIONVIEW_H
+#define TRACKAUTOMATIONVIEW_H
+
+class QPaintEvent;
+class QWidget;
+
+#include "track.h"
+
+class TrackAutomationView : public QWidget
+{
+ Track *_t;
+ void paintEvent(QPaintEvent *e);
+ std::map<int,int> automationList;
+public:
+ TrackAutomationView(QWidget *parent, Track *t);
+ Track *track() { return _t; }
+ void collectAutomationData();
+};
+
+#endif // TRACKAUTOMATIONVIEW_H
diff --git a/attic/muse2-oom/muse2/muse/audio.cpp b/attic/muse2-oom/muse2/muse/audio.cpp
new file mode 100644
index 00000000..934a5387
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/audio.cpp
@@ -0,0 +1,1439 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: audio.cpp,v 1.59.2.30 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 2001-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <cmath>
+#include <errno.h>
+
+#include <QSocketNotifier>
+
+#include "app.h"
+#include "song.h"
+#include "node.h"
+#include "audiodev.h"
+//#include "driver/audiodev.h" // p4.0.2
+#include "mididev.h"
+#include "alsamidi.h"
+//#include "driver/alsamidi.h" // p4.0.2
+#include "synth.h"
+#include "audioprefetch.h"
+#include "plugin.h"
+#include "audio.h"
+#include "wave.h"
+#include "midictrl.h"
+#include "midiseq.h"
+#include "sync.h"
+#include "midi.h"
+#include "event.h"
+#include "gconfig.h"
+#include "pos.h"
+#include "ticksynth.h"
+
+extern double curTime();
+Audio* audio;
+AudioDevice* audioDevice; // current audio device in use
+
+// p3.3.25
+extern unsigned int volatile midiExtSyncTicks;
+
+
+//static const unsigned char mmcDeferredPlayMsg[] = { 0x7f, 0x7f, 0x06, 0x03 };
+//static const unsigned char mmcStopMsg[] = { 0x7f, 0x7f, 0x06, 0x01 };
+
+const char* seqMsgList[] = {
+ "SEQM_ADD_TRACK", "SEQM_REMOVE_TRACK", "SEQM_CHANGE_TRACK", "SEQM_MOVE_TRACK",
+ "SEQM_ADD_PART", "SEQM_REMOVE_PART", "SEQM_CHANGE_PART",
+ "SEQM_ADD_EVENT", "SEQM_REMOVE_EVENT", "SEQM_CHANGE_EVENT",
+ "SEQM_ADD_TEMPO", "SEQM_SET_TEMPO", "SEQM_REMOVE_TEMPO", "SEQM_ADD_SIG", "SEQM_REMOVE_SIG",
+ "SEQM_SET_GLOBAL_TEMPO",
+ "SEQM_UNDO", "SEQM_REDO",
+ "SEQM_RESET_DEVICES", "SEQM_INIT_DEVICES", "SEQM_PANIC",
+ "SEQM_MIDI_LOCAL_OFF",
+ "SEQM_SET_MIDI_DEVICE",
+ "SEQM_PLAY_MIDI_EVENT",
+ "SEQM_SET_HW_CTRL_STATE",
+ "SEQM_SET_HW_CTRL_STATES",
+ "SEQM_SET_TRACK_OUT_PORT",
+ "SEQM_SET_TRACK_OUT_CHAN",
+ "SEQM_REMAP_PORT_DRUM_CTL_EVS",
+ "SEQM_CHANGE_ALL_PORT_DRUM_CTL_EVS",
+ "SEQM_SCAN_ALSA_MIDI_PORTS",
+ "SEQM_SET_AUX",
+ "SEQM_UPDATE_SOLO_STATES",
+ "MIDI_SHOW_INSTR_GUI",
+ "AUDIO_RECORD",
+ "AUDIO_ROUTEADD", "AUDIO_ROUTEREMOVE", "AUDIO_REMOVEROUTES",
+ "AUDIO_VOL", "AUDIO_PAN",
+ "AUDIO_ADDPLUGIN",
+ "AUDIO_SET_SEG_SIZE",
+ "AUDIO_SET_PREFADER", "AUDIO_SET_CHANNELS",
+ "AUDIO_SET_PLUGIN_CTRL_VAL",
+ "AUDIO_SWAP_CONTROLLER_IDX",
+ "AUDIO_CLEAR_CONTROLLER_EVENTS",
+ "AUDIO_SEEK_PREV_AC_EVENT",
+ "AUDIO_SEEK_NEXT_AC_EVENT",
+ "AUDIO_ERASE_AC_EVENT",
+ "AUDIO_ERASE_RANGE_AC_EVENTS",
+ "AUDIO_ADD_AC_EVENT",
+ "AUDIO_SET_SOLO", "AUDIO_SET_SEND_METRONOME",
+ "MS_PROCESS", "MS_STOP", "MS_SET_RTC", "MS_UPDATE_POLL_FD",
+ "SEQM_IDLE", "SEQM_SEEK"
+ };
+
+const char* audioStates[] = {
+ "STOP", "START_PLAY", "PLAY", "LOOP1", "LOOP2", "SYNC", "PRECOUNT"
+ };
+
+
+//---------------------------------------------------------
+// Audio
+//---------------------------------------------------------
+
+Audio::Audio()
+ {
+ _running = false;
+ recording = false;
+ idle = false;
+ _freewheel = false;
+ _bounce = false;
+ //loopPassed = false;
+ _loopFrame = 0;
+ _loopCount = 0;
+
+ _pos.setType(Pos::FRAMES);
+ _pos.setFrame(0);
+ curTickPos = 0;
+
+ midiClick = 0;
+ clickno = 0;
+ clicksMeasure = 0;
+ ticksBeat = 0;
+
+ syncTime = 0.0;
+ syncFrame = 0;
+ frameOffset = 0;
+
+ state = STOP;
+ msg = 0;
+
+ // Changed by Tim. p3.3.8
+ //startRecordPos.setType(Pos::TICKS);
+ //endRecordPos.setType(Pos::TICKS);
+ startRecordPos.setType(Pos::FRAMES);
+ endRecordPos.setType(Pos::FRAMES);
+
+ _audioMonitor = 0;
+ _audioMaster = 0;
+
+ //---------------------------------------------------
+ // establish pipes/sockets
+ //---------------------------------------------------
+
+ int filedes[2]; // 0 - reading 1 - writing
+ if (pipe(filedes) == -1) {
+ perror("creating pipe0");
+ exit(-1);
+ }
+ fromThreadFdw = filedes[1];
+ fromThreadFdr = filedes[0];
+ int rv = fcntl(fromThreadFdw, F_SETFL, O_NONBLOCK);
+ if (rv == -1)
+ perror("set pipe O_NONBLOCK");
+
+ if (pipe(filedes) == -1) {
+ perror("creating pipe1");
+ exit(-1);
+ }
+ sigFd = filedes[1];
+ QSocketNotifier* ss = new QSocketNotifier(filedes[0], QSocketNotifier::Read);
+ song->connect(ss, SIGNAL(activated(int)), song, SLOT(seqSignal(int)));
+ }
+
+//---------------------------------------------------------
+// start
+// start audio processing
+//---------------------------------------------------------
+
+extern bool initJackAudio();
+
+bool Audio::start()
+ {
+ //process(segmentSize); // warm up caches
+ state = STOP;
+ _loopCount = 0;
+ muse->setHeartBeat();
+ if (audioDevice) {
+ // Added by Tim. p3.3.6
+ //_running = true;
+
+ //audioDevice->start();
+ }
+ else {
+ if(false == initJackAudio()) {
+ // Added by Tim. p3.3.6
+ //_running = true;
+
+ InputList* itl = song->inputs();
+ for (iAudioInput i = itl->begin(); i != itl->end(); ++i) {
+ //printf("reconnecting input %s\n", (*i)->name().ascii());
+ for (int x=0; x < (*i)->channels();x++)
+ (*i)->setJackPort(x,0);
+ (*i)->setName((*i)->name()); // restore jack connection
+ }
+
+ OutputList* otl = song->outputs();
+ for (iAudioOutput i = otl->begin(); i != otl->end(); ++i) {
+ //printf("reconnecting output %s\n", (*i)->name().ascii());
+ for (int x=0; x < (*i)->channels();x++)
+ (*i)->setJackPort(x,0);
+ //printf("name=%s\n",(*i)->name().toLatin1());
+ (*i)->setName((*i)->name()); // restore jack connection
+ }
+ //audioDevice->start();
+ }
+ else {
+ printf("Failed to init audio!\n");
+ return false;
+ }
+ }
+
+ audioDevice->start(realTimePriority);
+
+ _running = true;
+
+ // shall we really stop JACK transport and locate to
+ // saved position?
+
+ audioDevice->stopTransport();
+ //audioDevice->seekTransport(song->cPos().frame());
+ audioDevice->seekTransport(song->cPos());
+ return true;
+ }
+
+//---------------------------------------------------------
+// stop
+// stop audio processing
+//---------------------------------------------------------
+
+void Audio::stop(bool)
+ {
+ if (audioDevice)
+ audioDevice->stop();
+ _running = false;
+ }
+
+//---------------------------------------------------------
+// sync
+// return true if sync is completed
+//---------------------------------------------------------
+
+bool Audio::sync(int jackState, unsigned frame)
+ {
+
+// Changed by Tim. p3.3.24
+/*
+ bool done = true;
+ if (state == LOOP1)
+ state = LOOP2;
+ else {
+ if (_pos.frame() != frame) {
+ Pos p(frame, false);
+ seek(p);
+ }
+ state = State(jackState);
+ if (!_freewheel)
+ //done = audioPrefetch->seekDone;
+ done = audioPrefetch->seekDone();
+ }
+
+ return done;
+*/
+ bool done = true;
+ if (state == LOOP1)
+ state = LOOP2;
+ else {
+ State s = State(jackState);
+ //
+ // STOP -> START_PLAY start rolling
+ // STOP -> STOP seek in stop state
+ // PLAY -> START_PLAY seek in play state
+
+ if (state != START_PLAY) {
+ //Pos p(frame, AL::FRAMES);
+ // seek(p);
+ Pos p(frame, false);
+ seek(p);
+ if (!_freewheel)
+ done = audioPrefetch->seekDone();
+ if (s == START_PLAY)
+ state = START_PLAY;
+ }
+ else {
+ //if (frame != _seqTime.pos.frame()) {
+ if (frame != _pos.frame()) {
+ // seek during seek
+ //seek(Pos(frame, AL::FRAMES));
+ seek(Pos(frame, false));
+ }
+ done = audioPrefetch->seekDone();
+ }
+ }
+ return done;
+
+ }
+
+//---------------------------------------------------------
+// setFreewheel
+//---------------------------------------------------------
+
+void Audio::setFreewheel(bool val)
+ {
+// printf("JACK: freewheel callback %d\n", val);
+ _freewheel = val;
+ }
+
+//---------------------------------------------------------
+// shutdown
+//---------------------------------------------------------
+
+void Audio::shutdown()
+ {
+ _running = false;
+ printf("Audio::shutdown()\n");
+ write(sigFd, "S", 1);
+ }
+
+//---------------------------------------------------------
+// process
+// process one audio buffer at position "_pos "
+// of size "frames"
+//---------------------------------------------------------
+
+void Audio::process(unsigned frames)
+ {
+ // Disabled by Tim. p3.3.22
+// extern int watchAudio;
+// ++watchAudio; // make a simple watchdog happy
+
+ if (!checkAudioDevice()) return;
+ if (msg) {
+ processMsg(msg);
+ int sn = msg->serialNo;
+ msg = 0; // dont process again
+ int rv = write(fromThreadFdw, &sn, sizeof(int));
+ if (rv != sizeof(int)) {
+ fprintf(stderr, "audio: write(%d) pipe failed: %s\n",
+ fromThreadFdw, strerror(errno));
+ }
+ }
+
+ OutputList* ol = song->outputs();
+ if (idle) {
+ // deliver no audio
+ for (iAudioOutput i = ol->begin(); i != ol->end(); ++i)
+ (*i)->silence(frames);
+ return;
+ }
+
+ int jackState = audioDevice->getState();
+
+ //if(debugMsg)
+ // printf("Audio::process Current state:%s jackState:%s\n", audioStates[state], audioStates[jackState]);
+
+ if (state == START_PLAY && jackState == PLAY) {
+ _loopCount = 0;
+ startRolling();
+ if (_bounce)
+ write(sigFd, "f", 1);
+ }
+ else if (state == LOOP2 && jackState == PLAY) {
+ ++_loopCount; // Number of times we have looped so far
+ Pos newPos(_loopFrame, false);
+ seek(newPos);
+ startRolling();
+ }
+ else if (isPlaying() && jackState == STOP) {
+ // p3.3.43 Make sure to stop bounce and freewheel mode, for example if user presses stop
+ // in QJackCtl before right-hand marker is reached (which is handled below).
+ //printf("Audio::process isPlaying() && jackState == STOP\n");
+ //if (_bounce)
+ //{
+ //printf(" stopping bounce...\n");
+ // _bounce = false;
+ // write(sigFd, "F", 1);
+ //}
+
+ stopRolling();
+ }
+ else if (state == START_PLAY && jackState == STOP) {
+ state = STOP;
+ if (_bounce) {
+ audioDevice->startTransport();
+ }
+ else
+ write(sigFd, "3", 1); // abort rolling
+ }
+ else if (state == STOP && jackState == PLAY) {
+ _loopCount = 0;
+ startRolling();
+ }
+ else if (state == LOOP1 && jackState == PLAY)
+ ; // treat as play
+ else if (state == LOOP2 && jackState == START_PLAY) {
+ ; // sync cycle
+ }
+ else if (state != jackState)
+ printf("JACK: state transition %s -> %s ?\n",
+ audioStates[state], audioStates[jackState]);
+
+// printf("p %s %s %d\n", audioStates[jackState], audioStates[state], _pos.frame());
+
+ //
+ // clear aux send buffers
+ //
+ AuxList* al = song->auxs();
+ for (unsigned i = 0; i < al->size(); ++i) {
+ AudioAux* a = (AudioAux*)((*al)[i]);
+ float** dst = a->sendBuffer();
+ for (int ch = 0; ch < a->channels(); ++ch)
+ memset(dst[ch], 0, sizeof(float) * segmentSize);
+ }
+
+ for (iAudioOutput i = ol->begin(); i != ol->end(); ++i)
+ (*i)->processInit(frames);
+ int samplePos = _pos.frame();
+ int offset = 0; // buffer offset in audio buffers
+
+ if (isPlaying()) {
+ if (!freewheel())
+ audioPrefetch->msgTick();
+
+ if (_bounce && _pos >= song->rPos()) {
+ _bounce = false;
+ write(sigFd, "F", 1);
+ return;
+ }
+
+ //
+ // check for end of song
+ //
+ if ((curTickPos >= song->len())
+ && !(song->record()
+ || _bounce
+ || song->loop())) {
+ //if(debugMsg)
+ // printf("Audio::process curTickPos >= song->len\n");
+
+ audioDevice->stopTransport();
+ return;
+ }
+
+ //
+ // check for loop end
+ //
+ if (state == PLAY && song->loop() && !_bounce && !extSyncFlag.value()) {
+ const Pos& loop = song->rPos();
+ unsigned n = loop.frame() - samplePos - (3 * frames);
+ if (n < frames) {
+ // loop end in current cycle
+ unsigned lpos = song->lPos().frame();
+ // adjust loop start so we get exact loop len
+ if (n > lpos)
+ n = 0;
+ state = LOOP1;
+ _loopFrame = lpos - n;
+
+ // clear sustain
+ for (int i = 0; i < MIDI_PORTS; ++i) {
+ MidiPort* mp = &midiPorts[i];
+ for (int ch = 0; ch < MIDI_CHANNELS; ++ch) {
+ if (mp->hwCtrlState(ch, CTRL_SUSTAIN) == 127) {
+ if (mp->device()!=NULL) {
+ //printf("send clear sustain!!!!!!!! port %d ch %d\n", i,ch);
+ MidiPlayEvent ev(0, i, ch, ME_CONTROLLER, CTRL_SUSTAIN, 0);
+ // may cause problems, called from audio thread
+ mp->device()->putEvent(ev);
+ }
+ }
+ }
+ }
+
+ //audioDevice->seekTransport(_loopFrame);
+ Pos lp(_loopFrame, false);
+ audioDevice->seekTransport(lp);
+
+
+// printf(" process: seek to %d, end %d\n", _loopFrame, loop.frame());
+ }
+ }
+
+
+ // p3.3.25
+ if(extSyncFlag.value())
+ {
+ nextTickPos = curTickPos + midiExtSyncTicks;
+ // Probably not good - interfere with midi thread.
+ midiExtSyncTicks = 0;
+ }
+ else
+ {
+
+ Pos ppp(_pos);
+ ppp += frames;
+ nextTickPos = ppp.tick();
+ }
+ }
+ //
+ // resync with audio interface
+ //
+ syncFrame = audioDevice->framePos();
+ syncTime = curTime();
+ frameOffset = syncFrame - samplePos;
+
+ //printf("Audio::process calling process1:\n");
+
+ process1(samplePos, offset, frames);
+ for (iAudioOutput i = ol->begin(); i != ol->end(); ++i)
+ (*i)->processWrite();
+ if (isPlaying()) {
+ _pos += frames;
+ curTickPos = nextTickPos;
+ }
+ }
+
+//---------------------------------------------------------
+// process1
+//---------------------------------------------------------
+
+void Audio::process1(unsigned samplePos, unsigned offset, unsigned frames)
+ {
+ if (midiSeqRunning) {
+ processMidi();
+ }
+ //midiSeq->msgProcess();
+
+ //
+ // process not connected tracks
+ // to animate meter display
+ //
+ TrackList* tl = song->tracks();
+ AudioTrack* track;
+ int channels;
+ for(ciTrack it = tl->begin(); it != tl->end(); ++it)
+ {
+ if((*it)->isMidiTrack())
+ continue;
+ track = (AudioTrack*)(*it);
+
+ // Added by T356.
+ // For audio track types, synths etc. which need some kind of non-audio
+ // (but possibly audio-affecting) processing always, even if their output path
+ // is ultimately unconnected.
+ // Example: A fluidsynth instance whose output path ultimately led to nowhere
+ // would not allow us to load a font. Since process() was driven by audio output,
+ // in this case there was nothing driving the process() function which responds to
+ // such gui commands. So I separated the events processing from process(), into this.
+ // It should be used for things like midi events, gui events etc. - things which need to
+ // be done BEFORE all the AudioOutput::process() are called below. That does NOT include
+ // audio processing, because THAT is done at the very end of this routine.
+ // This will also reset the track's processed flag.
+ track->preProcessAlways();
+
+ // Removed by T356
+ /*
+ if (track->noOutRoute() && !track->noInRoute() &&
+ track->type() != Track::AUDIO_AUX && track->type() != Track::AUDIO_OUTPUT) {
+ channels = track->channels();
+ float* buffer[channels];
+ float data[frames * channels];
+ for (int i = 0; i < channels; ++i)
+ buffer[i] = data + i * frames;
+ track->copyData(samplePos, channels, frames, buffer);
+ }
+ */
+
+ }
+ // Pre-process the metronome.
+ ((AudioTrack*)metronome)->preProcessAlways();
+
+ OutputList* ol = song->outputs();
+ for (ciAudioOutput i = ol->begin(); i != ol->end(); ++i)
+ (*i)->process(samplePos, offset, frames);
+
+ // Removed by T356
+ /*
+ AuxList* auxl = song->auxs();
+ for (ciAudioAux ia = auxl->begin(); ia != auxl->end(); ++ia) {
+ track = (AudioTrack*)(*ia);
+ if (track->noOutRoute()) {
+ channels = track->channels();
+ float* buffer[channels];
+ float data[frames * channels];
+ for (int i = 0; i < channels; ++i)
+ buffer[i] = data + i * frames;
+ track->copyData(samplePos, channels, frames, buffer);
+ }
+ }
+ */
+
+ // Added by T356.
+ // Were ANY tracks unprocessed as a result of processing all the AudioOutputs, above?
+ // Not just unconnected ones, as previously done, but ones whose output path ultimately leads nowhere.
+ // Those tracks were missed, until this fix.
+ // Do them now. This will animate meters, and 'quietly' process some audio which needs to be done -
+ // for example synths really need to be processed, 'quietly' or not, otherwise the next time
+ // processing is 'turned on', if there was a backlog of events while it was off, then they all happen at once.
+ for(ciTrack it = tl->begin(); it != tl->end(); ++it)
+ {
+ if((*it)->isMidiTrack())
+ continue;
+ track = (AudioTrack*)(*it);
+ // Ignore unprocessed tracks which have an output route, because they will be processed by
+ // whatever track(s) they are routed to.
+ if(!track->processed() && track->noOutRoute() && (track->type() != Track::AUDIO_OUTPUT))
+ {
+ channels = track->channels();
+ // Just a dummy buffer.
+ float* buffer[channels];
+ float data[frames * channels];
+ for (int i = 0; i < channels; ++i)
+ buffer[i] = data + i * frames;
+ //printf("Audio::process1 calling track->copyData for track:%s\n", track->name().toLatin1());
+
+ // p3.3.38
+ //track->copyData(samplePos, channels, frames, buffer);
+ track->copyData(samplePos, channels, -1, -1, frames, buffer);
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// processMsg
+//---------------------------------------------------------
+
+void Audio::processMsg(AudioMsg* msg)
+ {
+ switch(msg->id) {
+ case AUDIO_RECORD:
+ msg->snode->setRecordFlag2(msg->ival);
+ break;
+ case AUDIO_ROUTEADD:
+ addRoute(msg->sroute, msg->droute);
+ break;
+ case AUDIO_ROUTEREMOVE:
+ removeRoute(msg->sroute, msg->droute);
+ break;
+ case AUDIO_REMOVEROUTES: // p3.3.55
+ removeAllRoutes(msg->sroute, msg->droute);
+ break;
+ case AUDIO_VOL:
+ msg->snode->setVolume(msg->dval);
+ break;
+ case AUDIO_PAN:
+ msg->snode->setPan(msg->dval);
+ break;
+ case SEQM_SET_AUX:
+ msg->snode->setAuxSend(msg->ival, msg->dval);
+ break;
+ case AUDIO_SET_PREFADER:
+ msg->snode->setPrefader(msg->ival);
+ break;
+ case AUDIO_SET_CHANNELS:
+ msg->snode->setChannels(msg->ival);
+ break;
+ case AUDIO_ADDPLUGIN:
+ msg->snode->addPlugin(msg->plugin, msg->ival);
+ break;
+ case AUDIO_SET_PLUGIN_CTRL_VAL:
+ //msg->plugin->track()->setPluginCtrlVal(msg->ival, msg->dval);
+ // p3.3.43
+ msg->snode->setPluginCtrlVal(msg->ival, msg->dval);
+ break;
+ case AUDIO_SWAP_CONTROLLER_IDX:
+ msg->snode->swapControllerIDX(msg->a, msg->b);
+ break;
+ case AUDIO_CLEAR_CONTROLLER_EVENTS:
+ msg->snode->clearControllerEvents(msg->ival);
+ break;
+ case AUDIO_SEEK_PREV_AC_EVENT:
+ msg->snode->seekPrevACEvent(msg->ival);
+ break;
+ case AUDIO_SEEK_NEXT_AC_EVENT:
+ msg->snode->seekNextACEvent(msg->ival);
+ break;
+ case AUDIO_ERASE_AC_EVENT:
+ msg->snode->eraseACEvent(msg->ival, msg->a);
+ break;
+ case AUDIO_ERASE_RANGE_AC_EVENTS:
+ msg->snode->eraseRangeACEvents(msg->ival, msg->a, msg->b);
+ break;
+ case AUDIO_ADD_AC_EVENT:
+ msg->snode->addACEvent(msg->ival, msg->a, msg->dval);
+ break;
+ case AUDIO_SET_SOLO:
+ msg->track->setSolo((bool)msg->ival);
+ break;
+
+ case AUDIO_SET_SEND_METRONOME:
+ msg->snode->setSendMetronome((bool)msg->ival);
+ break;
+
+ case AUDIO_SET_SEG_SIZE:
+ segmentSize = msg->ival;
+ sampleRate = msg->iival;
+#if 0 //TODO
+ audioOutput.segmentSizeChanged();
+ for (int i = 0; i < mixerGroups; ++i)
+ audioGroups[i].segmentSizeChanged();
+ for (iSynthI ii = synthiInstances.begin(); ii != synthiInstances.end();++ii)
+ (*ii)->segmentSizeChanged();
+#endif
+ break;
+
+ case SEQM_RESET_DEVICES:
+ for (int i = 0; i < MIDI_PORTS; ++i)
+ midiPorts[i].instrument()->reset(i, song->mtype());
+ break;
+ case SEQM_INIT_DEVICES:
+ initDevices();
+ break;
+ case SEQM_MIDI_LOCAL_OFF:
+ sendLocalOff();
+ break;
+ case SEQM_PANIC:
+ panic();
+ break;
+ case SEQM_PLAY_MIDI_EVENT:
+ {
+ MidiPlayEvent* ev = (MidiPlayEvent*)(msg->p1);
+ midiPorts[ev->port()].sendEvent(*ev);
+ // Record??
+ }
+ break;
+ case SEQM_SET_HW_CTRL_STATE:
+ {
+ MidiPort* port = (MidiPort*)(msg->p1);
+ port->setHwCtrlState(msg->a, msg->b, msg->c);
+ }
+ break;
+ case SEQM_SET_HW_CTRL_STATES:
+ {
+ MidiPort* port = (MidiPort*)(msg->p1);
+ port->setHwCtrlStates(msg->a, msg->b, msg->c, msg->ival);
+ }
+ break;
+ case SEQM_SCAN_ALSA_MIDI_PORTS:
+ alsaScanMidiPorts();
+ break;
+ case MIDI_SHOW_INSTR_GUI:
+ midiSeq->msgUpdatePollFd();
+ break;
+ case SEQM_ADD_TEMPO:
+ case SEQM_REMOVE_TEMPO:
+ case SEQM_SET_GLOBAL_TEMPO:
+ case SEQM_SET_TEMPO:
+ song->processMsg(msg);
+ if (isPlaying()) {
+ if (!checkAudioDevice()) return;
+ _pos.setTick(curTickPos);
+ int samplePos = _pos.frame();
+ syncFrame = audioDevice->framePos();
+ syncTime = curTime();
+ frameOffset = syncFrame - samplePos;
+ }
+ break;
+ case SEQM_ADD_TRACK:
+ case SEQM_REMOVE_TRACK:
+ case SEQM_CHANGE_TRACK:
+ case SEQM_ADD_PART:
+ case SEQM_REMOVE_PART:
+ case SEQM_CHANGE_PART:
+ case SEQM_SET_TRACK_OUT_CHAN:
+ case SEQM_SET_TRACK_OUT_PORT:
+ case SEQM_REMAP_PORT_DRUM_CTL_EVS:
+ case SEQM_CHANGE_ALL_PORT_DRUM_CTL_EVS:
+ midiSeq->sendMsg(msg);
+ break;
+
+ case SEQM_IDLE:
+ idle = msg->a;
+ midiSeq->sendMsg(msg);
+ break;
+
+ default:
+ song->processMsg(msg);
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// seek
+// - called before start play
+// - initiated from gui
+//---------------------------------------------------------
+
+void Audio::seek(const Pos& p)
+ {
+ if (_pos == p) {
+ if(debugMsg)
+ printf("Audio::seek already there\n");
+ return;
+ }
+
+ // p3.3.23
+ //printf("Audio::seek frame:%d\n", p.frame());
+ _pos = p;
+ if (!checkAudioDevice()) return;
+ syncFrame = audioDevice->framePos();
+ frameOffset = syncFrame - _pos.frame();
+ curTickPos = _pos.tick();
+
+ midiSeq->msgSeek(); // handle stuck notes and set
+ // controller for new position
+
+ // p3.3.31
+ // Don't send if external sync is on. The master, and our sync routing system will take care of that.
+ if(!extSyncFlag.value())
+ {
+
+ for(int port = 0; port < MIDI_PORTS; ++port)
+ {
+ MidiPort* mp = &midiPorts[port];
+ MidiDevice* dev = mp->device();
+ //if(!dev || !mp->syncInfo().MCOut())
+ if(!dev || !mp->syncInfo().MRTOut())
+ continue;
+
+ // Added by T356: Shall we check for device write open flag to see if it's ok to send?...
+ // This means obey what the user has chosen for read/write in the midi port config dialog,
+ // which already takes into account whether the device is writable or not.
+ //if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
+ //if(!(dev->openFlags() & 1))
+ // continue;
+
+ //int port = dev->midiPort();
+
+ // By checking for no port here (-1), (and out of bounds), it means
+ // the device must be assigned to a port for these MMC commands to be sent.
+ // Without this check, interesting sync things can be done by the user without ever
+ // assigning any devices to ports !
+ //if(port < 0 || port > MIDI_PORTS)
+ //if(port < -1 || port > MIDI_PORTS)
+ // continue;
+
+ int beat = (curTickPos * 4) / config.division;
+
+ bool isPlaying=false;
+ if(state == PLAY)
+ isPlaying = true;
+
+ mp->sendStop();
+ mp->sendSongpos(beat);
+ if(isPlaying)
+ mp->sendContinue();
+ }
+ }
+
+ /*
+ if(genMCSync)
+ {
+ for(iMidiDevice imd = midiDevices.begin(); imd != midiDevices.end(); ++imd)
+ {
+ MidiDevice* dev = (*imd);
+ if(!dev->syncInfo().MCOut())
+ continue;
+
+ // Added by T356: Shall we check for device write open flag to see if it's ok to send?...
+ // This means obey what the user has chosen for read/write in the midi port config dialog,
+ // which already takes into account whether the device is writable or not.
+ //if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
+ //if(!(dev->openFlags() & 1))
+ // continue;
+
+ int port = dev->midiPort();
+
+ // By checking for no port here (-1), (and out of bounds), it means
+ // the device must be assigned to a port for these MMC commands to be sent.
+ // Without this check, interesting sync things can be done by the user without ever
+ // assigning any devices to ports !
+ //if(port < 0 || port > MIDI_PORTS)
+ if(port < -1 || port > MIDI_PORTS)
+ continue;
+
+ int beat = (curTickPos * 4) / config.division;
+
+ bool isPlaying=false;
+ if(state == PLAY)
+ isPlaying = true;
+
+ if(port == -1)
+ // Send straight to the device... Copied from MidiPort.
+ {
+ MidiPlayEvent event(0, 0, 0, ME_STOP, 0, 0);
+ dev->putEvent(event);
+
+ event.setType(ME_SONGPOS);
+ event.setA(beat);
+ dev->putEvent(event);
+
+ if(isPlaying)
+ {
+ event.setType(ME_CONTINUE);
+ event.setA(0);
+ dev->putEvent(event);
+ }
+ }
+ else
+ // Go through the port...
+ {
+ MidiPort* mp = &midiPorts[port];
+
+ mp->sendStop();
+ mp->sendSongpos(beat);
+ if(isPlaying)
+ mp->sendContinue();
+ }
+ }
+ }
+ */
+
+ //loopPassed = true; // for record loop mode
+ if (state != LOOP2 && !freewheel())
+ {
+ // Changed by T356 08/17/08. We need to force prefetch to update,
+ // to ensure the most recent data. Things can happen to a part
+ // before play is pressed - such as part muting, part moving etc.
+ // Without a force, the wrong data was being played.
+ //audioPrefetch->msgSeek(_pos.frame());
+ audioPrefetch->msgSeek(_pos.frame(), true);
+ }
+
+ write(sigFd, "G", 1); // signal seek to gui
+ }
+
+//---------------------------------------------------------
+// writeTick
+// called from audio prefetch thread context
+// write another buffer to soundfile
+//---------------------------------------------------------
+
+void Audio::writeTick()
+ {
+ AudioOutput* ao = song->bounceOutput;
+ if(ao && song->outputs()->find(ao) != song->outputs()->end())
+ {
+ if(ao->recordFlag())
+ ao->record();
+ }
+ WaveTrackList* tl = song->waves();
+ for (iWaveTrack t = tl->begin(); t != tl->end(); ++t) {
+ WaveTrack* track = *t;
+ if (track->recordFlag())
+ track->record();
+ }
+ }
+
+//---------------------------------------------------------
+// startRolling
+//---------------------------------------------------------
+
+void Audio::startRolling()
+ {
+ // Changed by Tim. p3.3.8
+ //startRecordPos = _pos;
+ if(_loopCount == 0)
+ startRecordPos = _pos;
+
+ if (song->record()) {
+ recording = true;
+ TrackList* tracks = song->tracks();
+ for (iTrack i = tracks->begin(); i != tracks->end(); ++i) {
+ if ((*i)->isMidiTrack())
+ continue;
+ if ((*i)->type() == Track::WAVE)
+ ((WaveTrack*)(*i))->resetMeter();
+ }
+ }
+ state = PLAY;
+ write(sigFd, "1", 1); // Play
+
+ // p3.3.31
+ // Don't send if external sync is on. The master, and our sync routing system will take care of that.
+ if(!extSyncFlag.value())
+ {
+
+ // Changed by Tim. p3.3.6
+ //if (genMMC)
+ // midiPorts[txSyncPort].sendSysex(mmcDeferredPlayMsg, sizeof(mmcDeferredPlayMsg));
+ //if (genMCSync) {
+ // if (curTickPos)
+ // midiPorts[txSyncPort].sendContinue();
+ // else
+ // midiPorts[txSyncPort].sendStart();
+ // }
+ for(int port = 0; port < MIDI_PORTS; ++port)
+ {
+ MidiPort* mp = &midiPorts[port];
+ MidiDevice* dev = mp->device();
+ if(!dev)
+ continue;
+
+ // Shall we check open flags?
+ //if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
+ //if(!(dev->openFlags() & 1))
+ // continue;
+
+ MidiSyncInfo& si = mp->syncInfo();
+
+ //if(genMMC && si.MMCOut())
+ if(si.MMCOut())
+ //mp->sendSysex(mmcDeferredPlayMsg, sizeof(mmcDeferredPlayMsg));
+ mp->sendMMCDeferredPlay();
+
+ //if(genMCSync && si.MCOut())
+ //if(si.MCOut())
+ if(si.MRTOut())
+ {
+ if(curTickPos)
+ mp->sendContinue();
+ else
+ mp->sendStart();
+ }
+ }
+ }
+
+ /*
+ for(iMidiDevice imd = midiDevices.begin(); imd != midiDevices.end(); ++imd)
+ {
+ MidiDevice* dev = (*imd);
+
+ // Shall we check open flags?
+ //if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
+ //if(!(dev->openFlags() & 1))
+ // continue;
+
+ int port = dev->midiPort();
+
+ // Without this -1 check, interesting sync things can be done by the user without ever
+ // assigning any devices to ports !
+ //if(port < 0 || port > MIDI_PORTS)
+ if(port < -1 || port > MIDI_PORTS)
+ continue;
+
+ MidiSyncInfo& si = dev->syncInfo();
+
+ if(port == -1)
+ // Send straight to the device... Copied from MidiPort.
+ {
+ if(genMMC && si.MMCOut())
+ {
+ MidiPlayEvent event(0, 0, ME_SYSEX, mmcDeferredPlayMsg, sizeof(mmcDeferredPlayMsg));
+ dev->putEvent(event);
+ }
+
+ if(genMCSync && si.MCOut())
+ {
+ if(curTickPos)
+ {
+ MidiPlayEvent event(0, 0, 0, ME_CONTINUE, 0, 0);
+ dev->putEvent(event);
+ }
+ else
+ {
+ MidiPlayEvent event(0, 0, 0, ME_START, 0, 0);
+ dev->putEvent(event);
+ }
+ }
+ }
+ else
+ // Go through the port...
+ {
+ MidiPort* mp = &midiPorts[port];
+
+ if(genMMC && si.MMCOut())
+ mp->sendSysex(mmcDeferredPlayMsg, sizeof(mmcDeferredPlayMsg));
+
+ if(genMCSync && si.MCOut())
+ {
+ if(curTickPos)
+ mp->sendContinue();
+ else
+ mp->sendStart();
+ }
+ }
+ }
+ */
+
+ if (precountEnableFlag
+ && song->click()
+ && !extSyncFlag.value()
+ && song->record()) {
+#if 0
+ state = PRECOUNT;
+ int z, n;
+ if (precountFromMastertrackFlag)
+ AL::sigmap.timesig(playTickPos, z, n);
+ else {
+ z = precountSigZ;
+ n = precountSigN;
+ }
+ clickno = z * preMeasures;
+ clicksMeasure = z;
+ ticksBeat = (division * 4)/n;
+#endif
+ }
+ else {
+ //
+ // compute next midi metronome click position
+ //
+ int bar, beat;
+ unsigned tick;
+ AL::sigmap.tickValues(curTickPos, &bar, &beat, &tick);
+ if (tick)
+ beat += 1;
+ midiClick = AL::sigmap.bar2tick(bar, beat, 0);
+ }
+
+ // reenable sustain
+ for (int i = 0; i < MIDI_PORTS; ++i) {
+ MidiPort* mp = &midiPorts[i];
+ for (int ch = 0; ch < MIDI_CHANNELS; ++ch) {
+ if (mp->hwCtrlState(ch, CTRL_SUSTAIN) == 127) {
+ if(mp->device() != NULL) {
+ //printf("send enable sustain!!!!!!!! port %d ch %d\n", i,ch);
+ MidiPlayEvent ev(0, i, ch, ME_CONTROLLER, CTRL_SUSTAIN, 127);
+
+ // may cause problems, called from audio thread
+ mp->device()->playEvents()->add(ev);
+ }
+ }
+ }
+ }
+
+ //tempomap.clearExtTempoList();
+ }
+
+//---------------------------------------------------------
+// stopRolling
+//---------------------------------------------------------
+
+void Audio::stopRolling()
+ {
+ // Added by Tim. p3.3.20
+ //if(debugMsg)
+ // printf("Audio::stopRolling state %s\n", audioStates[state]);
+
+ state = STOP;
+ midiSeq->msgStop();
+
+#if 1 //TODO
+ //---------------------------------------------------
+ // reset sustain
+ //---------------------------------------------------
+
+
+ // clear sustain
+ for (int i = 0; i < MIDI_PORTS; ++i) {
+ MidiPort* mp = &midiPorts[i];
+ for (int ch = 0; ch < MIDI_CHANNELS; ++ch) {
+ if (mp->hwCtrlState(ch, CTRL_SUSTAIN) == 127) {
+ if(mp->device()!=NULL) {
+ //printf("send clear sustain!!!!!!!! port %d ch %d\n", i,ch);
+ MidiPlayEvent ev(0, i, ch, ME_CONTROLLER, CTRL_SUSTAIN, 0);
+ // may cause problems, called from audio thread
+ mp->device()->putEvent(ev);
+ }
+ }
+ }
+ }
+
+#endif
+
+ // p3.3.31
+ // Don't send if external sync is on. The master, and our sync routing system will take care of that.
+ if(!extSyncFlag.value())
+ {
+
+ // Changed by Tim. p3.3.6
+ //MidiPort* syncPort = &midiPorts[txSyncPort];
+ //if (genMMC) {
+ // unsigned char mmcPos[] = {
+ // 0x7f, 0x7f, 0x06, 0x44, 0x06, 0x01,
+ // 0, 0, 0, 0, 0
+ // };
+ // int frame = tempomap.tick2frame(curTickPos);
+ // MTC mtc(double(frame) / double(sampleRate));
+ // mmcPos[6] = mtc.h() | (mtcType << 5);
+ // mmcPos[7] = mtc.m();
+ // mmcPos[8] = mtc.s();
+ // mmcPos[9] = mtc.f();
+ // mmcPos[10] = mtc.sf();
+ // syncPort->sendSysex(mmcStopMsg, sizeof(mmcStopMsg));
+ // syncPort->sendSysex(mmcPos, sizeof(mmcPos));
+ // }
+ //if (genMCSync) { // Midi Clock
+ // send STOP and
+ // "set song position pointer"
+ // syncPort->sendStop();
+ // syncPort->sendSongpos(curTickPos * 4 / config.division);
+ // }
+ for(int port = 0; port < MIDI_PORTS; ++port)
+ {
+ MidiPort* mp = &midiPorts[port];
+ MidiDevice* dev = mp->device();
+ if(!dev)
+ continue;
+
+ // Shall we check open flags?
+ //if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
+ //if(!(dev->openFlags() & 1))
+ // continue;
+
+ MidiSyncInfo& si = mp->syncInfo();
+
+ //if(genMMC && si.MMCOut())
+ if(si.MMCOut())
+ {
+ //unsigned char mmcPos[] = {
+ // 0x7f, 0x7f, 0x06, 0x44, 0x06, 0x01,
+ // 0, 0, 0, 0, 0
+ // };
+
+ // p3.3.31
+ /*
+ int frame = tempomap.tick2frame(curTickPos);
+ MTC mtc(double(frame) / double(sampleRate));
+ */
+
+ //mmcPos[6] = mtc.h() | (mtcType << 5);
+ //mmcPos[7] = mtc.m();
+ //mmcPos[8] = mtc.s();
+ //mmcPos[9] = mtc.f();
+ //mmcPos[10] = mtc.sf();
+
+ //mp->sendSysex(mmcStopMsg, sizeof(mmcStopMsg));
+ mp->sendMMCStop();
+ //mp->sendSysex(mmcPos, sizeof(mmcPos));
+
+ // p3.3.31
+ // Added check of option send continue not start.
+ // Hmm, is this required? Seems to make other devices unhappy.
+ /*
+ if(!si.sendContNotStart())
+ mp->sendMMCLocate(mtc.h() | (mtcType << 5),
+ mtc.m(), mtc.s(), mtc.f(), mtc.sf());
+ */
+
+ }
+
+ //if(genMCSync && si.MCOut()) // Midi Clock
+ //if(si.MCOut()) // Midi Clock
+ if(si.MRTOut()) //
+ {
+ // send STOP and
+ // "set song position pointer"
+ mp->sendStop();
+
+ // p3.3.31
+ // Added check of option send continue not start.
+ // Hmm, is this required? Seems to make other devices unhappy.
+ /*
+ if(!si.sendContNotStart())
+ mp->sendSongpos(curTickPos * 4 / config.division);
+ */
+
+ }
+ }
+ }
+
+ /*
+ for(iMidiDevice imd = midiDevices.begin(); imd != midiDevices.end(); ++imd)
+ {
+ MidiDevice* dev = (*imd);
+
+ // Shall we check open flags?
+ //if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
+ //if(!(dev->openFlags() & 1))
+ // continue;
+
+ int port = dev->midiPort();
+
+ // Without this -1 check, interesting sync things can be done by the user without ever
+ // assigning any devices to ports !
+ //if(port < 0 || port > MIDI_PORTS)
+ if(port < -1 || port > MIDI_PORTS)
+ continue;
+
+ MidiSyncInfo& si = dev->syncInfo();
+
+ MidiPort* mp = 0;
+ if(port != -1)
+ mp = &midiPorts[port];
+
+ if(genMMC && si.MMCOut())
+ {
+ unsigned char mmcPos[] = {
+ 0x7f, 0x7f, 0x06, 0x44, 0x06, 0x01,
+ 0, 0, 0, 0, 0
+ };
+ int frame = tempomap.tick2frame(curTickPos);
+ MTC mtc(double(frame) / double(sampleRate));
+ mmcPos[6] = mtc.h() | (mtcType << 5);
+ mmcPos[7] = mtc.m();
+ mmcPos[8] = mtc.s();
+ mmcPos[9] = mtc.f();
+ mmcPos[10] = mtc.sf();
+
+ if(mp)
+ // Go through the port...
+ {
+ mp->sendSysex(mmcStopMsg, sizeof(mmcStopMsg));
+ mp->sendSysex(mmcPos, sizeof(mmcPos));
+ }
+ else
+ // Send straight to the device... Copied from MidiPort.
+ {
+ MidiPlayEvent event(0, 0, ME_SYSEX, mmcStopMsg, sizeof(mmcStopMsg));
+ dev->putEvent(event);
+
+ event.setData(mmcPos, sizeof(mmcPos));
+ dev->putEvent(event);
+ }
+ }
+
+ if(genMCSync && si.MCOut()) // Midi Clock
+ {
+ // send STOP and
+ // "set song position pointer"
+ if(mp)
+ // Go through the port...
+ {
+ mp->sendStop();
+ mp->sendSongpos(curTickPos * 4 / config.division);
+ }
+ else
+ // Send straight to the device... Copied from MidiPort.
+ {
+ MidiPlayEvent event(0, 0, 0, ME_STOP, 0, 0);
+ dev->putEvent(event);
+ event.setType(ME_SONGPOS);
+ event.setA(curTickPos * 4 / config.division);
+ dev->putEvent(event);
+ }
+ }
+ }
+ */
+
+ WaveTrackList* tracks = song->waves();
+ for (iWaveTrack i = tracks->begin(); i != tracks->end(); ++i) {
+ WaveTrack* track = *i;
+ track->resetMeter();
+ }
+ recording = false;
+ endRecordPos = _pos;
+ write(sigFd, "0", 1); // STOP
+ }
+
+//---------------------------------------------------------
+// recordStop
+// execution environment: gui thread
+//---------------------------------------------------------
+
+void Audio::recordStop()
+ {
+ audio->msgIdle(true); // gain access to all data structures
+
+ song->startUndo();
+ WaveTrackList* wl = song->waves();
+
+ for (iWaveTrack it = wl->begin(); it != wl->end(); ++it) {
+ WaveTrack* track = *it;
+ if (track->recordFlag() || song->bounceTrack == track) {
+ song->cmdAddRecordedWave(track, startRecordPos, endRecordPos);
+ // The track's _recFile pointer may have been kept and turned
+ // into a SndFileR and added to a new part.
+ // Or _recFile may have been discarded (no new recorded part created).
+ // Regardless, we are done with the pointer itself. Set to zero so
+ // song->setRecordFlag knows about it...
+
+ track->setRecFile(0); // flush out the old file
+ song->setRecordFlag(track, false); //
+ //track->setRecordFlag1(true); // and re-arm the track here
+ //song->setRecordFlag(track, true); // here
+ }
+ }
+ MidiTrackList* ml = song->midis();
+ for (iMidiTrack it = ml->begin(); it != ml->end(); ++it) {
+ MidiTrack* mt = *it;
+ MPEventList* mpel = mt->mpevents();
+ EventList* el = mt->events();
+
+ //---------------------------------------------------
+ // resolve NoteOff events, Controller etc.
+ //---------------------------------------------------
+
+ //buildMidiEventList(el, mpel, mt, config.division, true);
+ // Do SysexMeta. Do loops.
+ buildMidiEventList(el, mpel, mt, config.division, true, true);
+ song->cmdAddRecordedEvents(mt, el, startRecordPos.tick());
+ el->clear();
+ mpel->clear();
+ }
+
+ //
+ // bounce to file operates on the only
+ // selected output port
+ //
+
+ AudioOutput* ao = song->bounceOutput;
+ if(ao && song->outputs()->find(ao) != song->outputs()->end())
+ {
+ if(ao->recordFlag())
+ {
+ song->bounceOutput = 0;
+ SndFile* sf = ao->recFile();
+ if (sf)
+ delete sf; // close
+ ao->setRecFile(0);
+ ao->setRecordFlag1(false);
+ msgSetRecord(ao, false);
+ }
+ }
+ audio->msgIdle(false);
+ song->endUndo(0);
+ song->setRecord(false);
+ }
+
+//---------------------------------------------------------
+// curFrame
+// extrapolates current play frame on syncTime/syncFrame
+//---------------------------------------------------------
+
+unsigned int Audio::curFrame() const
+ {
+ return lrint((curTime() - syncTime) * sampleRate) + syncFrame;
+ }
+
+//---------------------------------------------------------
+// timestamp
+//---------------------------------------------------------
+
+int Audio::timestamp() const
+ {
+ int t = curFrame() - frameOffset;
+ return t;
+ }
+
+//---------------------------------------------------------
+// sendMsgToGui
+//---------------------------------------------------------
+
+void Audio::sendMsgToGui(char c)
+ {
+ write(sigFd, &c, 1);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/audio.h b/attic/muse2-oom/muse2/muse/audio.h
new file mode 100644
index 00000000..ba188f8a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/audio.h
@@ -0,0 +1,301 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: audio.h,v 1.25.2.13 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __AUDIO_H__
+#define __AUDIO_H__
+
+#include "thread.h"
+#include "pos.h"
+#include "mpevent.h"
+#include "route.h"
+#include "event.h"
+
+class SndFile;
+class PluginI;
+class SynthI;
+class MidiDevice;
+class AudioDevice;
+class Track;
+class AudioTrack;
+class Part;
+class Event;
+class MidiPlayEvent;
+class Event;
+class MidiPort;
+class EventList;
+class MidiInstrument;
+class MidiTrack;
+
+//---------------------------------------------------------
+// AudioMsgId
+// this are the messages send from the GUI thread to
+// the midi thread
+//---------------------------------------------------------
+
+enum {
+ SEQM_ADD_TRACK, SEQM_REMOVE_TRACK, SEQM_CHANGE_TRACK, SEQM_MOVE_TRACK,
+ SEQM_ADD_PART, SEQM_REMOVE_PART, SEQM_CHANGE_PART,
+ SEQM_ADD_EVENT, SEQM_REMOVE_EVENT, SEQM_CHANGE_EVENT,
+ SEQM_ADD_TEMPO, SEQM_SET_TEMPO, SEQM_REMOVE_TEMPO, SEQM_ADD_SIG, SEQM_REMOVE_SIG,
+ SEQM_SET_GLOBAL_TEMPO,
+ SEQM_UNDO, SEQM_REDO,
+ SEQM_RESET_DEVICES, SEQM_INIT_DEVICES, SEQM_PANIC,
+ SEQM_MIDI_LOCAL_OFF,
+ SEQM_SET_MIDI_DEVICE,
+ SEQM_PLAY_MIDI_EVENT,
+ SEQM_SET_HW_CTRL_STATE,
+ SEQM_SET_HW_CTRL_STATES,
+ SEQM_SET_TRACK_OUT_PORT,
+ SEQM_SET_TRACK_OUT_CHAN,
+ SEQM_REMAP_PORT_DRUM_CTL_EVS,
+ SEQM_CHANGE_ALL_PORT_DRUM_CTL_EVS,
+ SEQM_SCAN_ALSA_MIDI_PORTS,
+ SEQM_SET_AUX,
+ SEQM_UPDATE_SOLO_STATES,
+ MIDI_SHOW_INSTR_GUI,
+ AUDIO_RECORD,
+ AUDIO_ROUTEADD, AUDIO_ROUTEREMOVE, AUDIO_REMOVEROUTES,
+ AUDIO_VOL, AUDIO_PAN,
+ AUDIO_ADDPLUGIN,
+ AUDIO_SET_SEG_SIZE,
+ AUDIO_SET_PREFADER, AUDIO_SET_CHANNELS,
+ AUDIO_SET_PLUGIN_CTRL_VAL,
+ AUDIO_SWAP_CONTROLLER_IDX,
+ AUDIO_CLEAR_CONTROLLER_EVENTS,
+ AUDIO_SEEK_PREV_AC_EVENT,
+ AUDIO_SEEK_NEXT_AC_EVENT,
+ AUDIO_ERASE_AC_EVENT,
+ AUDIO_ERASE_RANGE_AC_EVENTS,
+ AUDIO_ADD_AC_EVENT,
+ AUDIO_SET_SOLO, AUDIO_SET_SEND_METRONOME,
+ MS_PROCESS, MS_STOP, MS_SET_RTC, MS_UPDATE_POLL_FD,
+ SEQM_IDLE, SEQM_SEEK,
+ };
+
+extern const char* seqMsgList[]; // for debug
+
+//---------------------------------------------------------
+// Msg
+//---------------------------------------------------------
+
+struct AudioMsg : public ThreadMsg { // this should be an union
+ int serialNo;
+ SndFile* downmix;
+ AudioTrack* snode;
+ AudioTrack* dnode;
+ Route sroute, droute;
+ AudioDevice* device;
+ int ival;
+ int iival;
+ double dval;
+ PluginI* plugin;
+ SynthI* synth;
+ Part* spart;
+ Part* dpart;
+ Track* track;
+
+ const void *p1, *p2, *p3;
+ Event ev1, ev2;
+ char port, channel, ctrl;
+ int a, b, c;
+ Pos pos;
+ };
+
+class AudioOutput;
+
+//---------------------------------------------------------
+// Audio
+//---------------------------------------------------------
+
+class Audio {
+ public:
+ enum State {STOP, START_PLAY, PLAY, LOOP1, LOOP2, SYNC, PRECOUNT};
+
+ private:
+ bool _running; // audio is active
+ bool recording; // recording is active
+ bool idle; // do nothing in idle mode
+ bool _freewheel;
+ bool _bounce;
+ //bool loopPassed;
+ unsigned _loopFrame; // Startframe of loop if in LOOP mode. Not quite the same as left marker !
+ int _loopCount; // Number of times we have looped so far
+
+ Pos _pos; // current play position
+
+ unsigned curTickPos; // pos at start of frame during play/record
+ unsigned nextTickPos; // pos at start of next frame during play/record
+
+ //metronome values
+ unsigned midiClick;
+ int clickno; // precount values
+ int clicksMeasure;
+ int ticksBeat;
+
+ double syncTime; // wall clock at last sync point
+ unsigned syncFrame; // corresponding frame no. to syncTime
+ int frameOffset; // offset to free running hw frame counter
+
+ State state;
+
+ AudioMsg* msg;
+ int fromThreadFdw, fromThreadFdr; // message pipe
+
+ int sigFd; // pipe fd for messages to gui
+
+ // record values:
+ Pos startRecordPos;
+ Pos endRecordPos;
+
+ //
+ AudioOutput* _audioMaster;
+ AudioOutput* _audioMonitor;
+
+ void sendLocalOff();
+ bool filterEvent(const MidiPlayEvent* event, int type, bool thru);
+
+ void startRolling();
+ void stopRolling();
+
+ void panic();
+ void processMsg(AudioMsg* msg);
+ void process1(unsigned samplePos, unsigned offset, unsigned samples);
+
+ void collectEvents(MidiTrack*, unsigned int startTick, unsigned int endTick);
+
+ public:
+ Audio();
+ virtual ~Audio() {}
+
+ void process(unsigned frames);
+ bool sync(int state, unsigned frame);
+ void shutdown();
+ void writeTick();
+
+ // transport:
+ bool start();
+ void stop(bool);
+ void seek(const Pos& pos);
+
+ bool isPlaying() const { return state == PLAY || state == LOOP1 || state == LOOP2; }
+ bool isRecording() const { return state == PLAY && recording; }
+ void setRunning(bool val) { _running = val; }
+ bool isRunning() const { return _running; }
+
+ //-----------------------------------------
+ // message interface
+ //-----------------------------------------
+
+ void msgSeek(const Pos&);
+ void msgPlay(bool val);
+
+ void msgRemoveTrack(Track*, bool u = true);
+ void msgRemoveTracks();
+ void msgChangeTrack(Track* oldTrack, Track* newTrack, bool u = true);
+ void msgMoveTrack(int idx1, int dx2, bool u = true);
+ void msgAddPart(Part*, bool u = true);
+ void msgRemovePart(Part*, bool u = true);
+ //void msgChangePart(Part* oldPart, Part* newPart, bool u = true);
+ void msgChangePart(Part* oldPart, Part* newPart, bool u = true, bool doCtrls = true, bool doClones = false);
+ //void msgAddEvent(Event&, Part*, bool u = true);
+ void msgAddEvent(Event&, Part*, bool u = true, bool doCtrls = true, bool doClones = false);
+ //void msgDeleteEvent(Event&, Part*, bool u = true);
+ void msgDeleteEvent(Event&, Part*, bool u = true, bool doCtrls = true, bool doClones = false);
+ //void msgChangeEvent(Event&, Event&, Part*, bool u = true);
+ void msgChangeEvent(Event&, Event&, Part*, bool u = true, bool doCtrls = true, bool doClones = false);
+ void msgScanAlsaMidiPorts();
+ void msgAddTempo(int tick, int tempo, bool doUndoFlag = true);
+ void msgSetTempo(int tick, int tempo, bool doUndoFlag = true);
+ void msgUpdateSoloStates();
+ void msgSetAux(AudioTrack*, int, double);
+ void msgSetGlobalTempo(int val);
+ void msgDeleteTempo(int tick, int tempo, bool doUndoFlag = true);
+ void msgAddSig(int tick, int z, int n, bool doUndoFlag = true);
+ void msgRemoveSig(int tick, int z, int n, bool doUndoFlag = true);
+ void msgShowInstrumentGui(MidiInstrument*, bool);
+ void msgPanic();
+ void sendMsg(AudioMsg*);
+ bool sendMessage(AudioMsg* m, bool doUndo);
+ void msgRemoveRoute(Route, Route);
+ void msgRemoveRoute1(Route, Route);
+ void msgRemoveRoutes(Route, Route); // p3.3.55
+ void msgRemoveRoutes1(Route, Route); // p3.3.55
+ void msgAddRoute(Route, Route);
+ void msgAddRoute1(Route, Route);
+ void msgAddPlugin(AudioTrack*, int idx, PluginI* plugin);
+ void msgSetMute(AudioTrack*, bool val);
+ void msgSetVolume(AudioTrack*, double val);
+ void msgSetPan(AudioTrack*, double val);
+ void msgAddSynthI(SynthI* synth);
+ void msgRemoveSynthI(SynthI* synth);
+ void msgSetSegSize(int, int);
+ void msgSetPrefader(AudioTrack*, int);
+ void msgSetChannels(AudioTrack*, int);
+ void msgSetOff(AudioTrack*, bool);
+ void msgSetRecord(AudioTrack*, bool);
+ void msgUndo();
+ void msgRedo();
+ void msgLocalOff();
+ void msgInitMidiDevices();
+ void msgResetMidiDevices();
+ void msgIdle(bool);
+ void msgBounce();
+ //void msgSetPluginCtrlVal(PluginI* /*plugin*/, int /*param*/, double /*val*/);
+ void msgSetPluginCtrlVal(AudioTrack*, int /*param*/, double /*val*/);
+ void msgSwapControllerIDX(AudioTrack*, int, int);
+ void msgClearControllerEvents(AudioTrack*, int);
+ void msgSeekPrevACEvent(AudioTrack*, int);
+ void msgSeekNextACEvent(AudioTrack*, int);
+ void msgEraseACEvent(AudioTrack*, int, int);
+ void msgEraseRangeACEvents(AudioTrack*, int, int, int);
+ void msgAddACEvent(AudioTrack*, int, int, double);
+ void msgSetSolo(Track*, bool);
+ void msgSetHwCtrlState(MidiPort*, int, int, int);
+ void msgSetHwCtrlStates(MidiPort*, int, int, int, int);
+ void msgSetTrackOutChannel(MidiTrack*, int);
+ void msgSetTrackOutPort(MidiTrack*, int);
+ void msgRemapPortDrumCtlEvents(int, int, int, int);
+ void msgChangeAllPortDrumCtrlEvents(bool, bool);
+ void msgSetSendMetronome(AudioTrack*, bool);
+
+ void msgPlayMidiEvent(const MidiPlayEvent* event);
+ void rescanAlsaPorts();
+
+ void midiPortsChanged();
+
+ const Pos& pos() const { return _pos; }
+ const Pos& getStartRecordPos() const { return startRecordPos; }
+ const Pos& getEndRecordPos() const { return endRecordPos; }
+ int loopCount() { return _loopCount; } // Number of times we have looped so far
+ unsigned loopFrame() { return _loopFrame; }
+
+ int tickPos() const { return curTickPos; }
+ int timestamp() const;
+ void processMidi();
+ unsigned curFrame() const;
+ void recordStop();
+ bool freewheel() const { return _freewheel; }
+ void setFreewheel(bool val);
+ int getFrameOffset() const { return frameOffset; }
+ void initDevices();
+
+ AudioOutput* audioMaster() const { return _audioMaster; }
+ AudioOutput* audioMonitor() const { return _audioMonitor; }
+ void setMaster(AudioOutput* track) { _audioMaster = track; }
+ void setMonitor(AudioOutput* track) { _audioMonitor = track; }
+ void sendMsgToGui(char c);
+ bool bounce() const { return _bounce; }
+ };
+
+extern int processAudio(unsigned long, void*);
+extern void processAudio1(void*, void*);
+
+extern Audio* audio;
+extern AudioDevice* audioDevice; // current audio device in use
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/audioconvert.cpp b/attic/muse2-oom/muse2/muse/audioconvert.cpp
new file mode 100644
index 00000000..552b5e95
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/audioconvert.cpp
@@ -0,0 +1,886 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: audioconvert.cpp,v 1.1.1.1 2009/12/28 16:07:33 terminator356 Exp $
+//
+// (C) Copyright 1999-2009 Werner Schweer (ws@seh.de)
+//
+// Audio converter module created by Tim terminator356
+//=========================================================
+
+#include <math.h>
+
+#include "wave.h"
+#include "globals.h"
+#include "audioconvert.h"
+#include "eventbase.h"
+
+//#define AUDIOCONVERT_DEBUG
+//#define AUDIOCONVERT_DEBUG_PRC
+
+//---------------------------------------------------------
+// AudioConvertMap
+//---------------------------------------------------------
+
+void AudioConvertMap::remapEvents(const EventList* /*el*/)
+{
+
+}
+
+iAudioConvertMap AudioConvertMap::addEvent(EventBase* eb)
+{
+ iAudioConvertMap iacm = getConverter(eb);
+ if(iacm == end())
+ {
+ AudioConverter* cv = 0;
+ if(!eb->sndFile().isNull())
+ cv = new SRCAudioConverter(eb->sndFile().channels(), SRC_SINC_MEDIUM_QUALITY);
+
+ // Use insert with hint for speed.
+ return insert(iacm, std::pair<EventBase*, AudioConverter*> (eb, cv));
+ }
+ else
+ // Adopt a policy of returning an already existing item to enforce no-duplicates.
+ return iacm;
+}
+
+void AudioConvertMap::removeEvent(EventBase* eb)
+{
+ iAudioConvertMap iacm = find(eb);
+ if(iacm != end())
+ {
+ AudioConverter* cv = iacm->second;
+ if(cv)
+ delete cv;
+ erase(iacm);
+ }
+}
+
+iAudioConvertMap AudioConvertMap::getConverter(EventBase* eb)
+{
+ return find(eb);
+}
+
+//---------------------------------------------------------
+// AudioConverter
+//---------------------------------------------------------
+
+AudioConverter::AudioConverter()
+{
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("AudioConverter::AudioConverter this:%p\n", this);
+ #endif
+
+ _refCount = 1;
+ _sfCurFrame = 0;
+}
+
+AudioConverter::~AudioConverter()
+{
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("AudioConverter::~AudioConverter this:%p\n", this);
+ #endif
+}
+
+AudioConverter* AudioConverter::reference()
+{
+ _refCount += 1;
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("AudioConverter::reference this:%p current refcount:%d\n", this, _refCount);
+ #endif
+ return this;
+}
+
+AudioConverter* AudioConverter::release(AudioConverter* cv)
+{
+ if(!cv)
+ return 0;
+ //if(cv->incRefCount(-1) <= 0)
+ cv->_refCount -= 1;
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("AudioConverter::release converter:%p current refcount:%d\n", cv, cv->_refCount);
+ #endif
+ if(cv->_refCount <= 0)
+ {
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("AudioConverter::release deleting converter:%p\n", cv);
+ #endif
+ delete cv;
+ cv = 0;
+ }
+ return cv;
+}
+
+//off_t AudioConverter::readAudio(SndFileR& f, off_t sfCurFrame, unsigned offset, float** buffer, int channel, int n, bool doSeek, bool overwrite)
+off_t AudioConverter::readAudio(SndFileR& f, unsigned offset, float** buffer, int channel, int n, bool doSeek, bool overwrite)
+{
+ if(f.isNull())
+ return _sfCurFrame;
+
+ // Added by Tim. p3.3.17
+ //#ifdef AUDIOCONVERT_DEBUG_PRC
+ //printf("AudioConverter::process %s audConv:%p sfCurFrame:%ld offset:%u channel:%d fchan:%d n:%d\n",
+ // f.name().toLatin1(), this, sfCurFrame, offset, channel, f.channels(), n);
+ //#endif
+
+ off_t frame = offset; // _spos is added before the call.
+ unsigned fsrate = f.samplerate();
+ bool resample = isValid() && ((unsigned)sampleRate != fsrate);
+
+ // No resampling needed?
+ if(!resample)
+ {
+ // Sample rates are the same. Just a regular seek + read, no conversion.
+ _sfCurFrame = f.seek(frame, 0);
+ return _sfCurFrame + f.read(channel, buffer, n, overwrite);
+ }
+
+ // Is a 'transport' seek requested? (Not to be requested with every read! Should only be for 'first read' seeks, or positional 'transport' seeks.)
+ // Due to the support of sound file references in MusE, seek must ALWAYS be done before read, as before,
+ // except now we alter the seek position if sample rate conversion is being used and remember the seek positions.
+ if(doSeek)
+ {
+ // Sample rates are different. Seek to a calculated 'sample rate ratio factored' position.
+
+ double srcratio = (double)fsrate / (double)sampleRate;
+ //long inSize = long((double)frames * _src_ratio) + 1 // From MusE-2 file converter.
+ off_t newfr = (off_t)floor(((double)frame * srcratio)); // From simplesynth.
+
+ _sfCurFrame = f.seek(newfr, 0);
+
+ // Added by Tim. p3.3.17
+ //#ifdef AUDIOCONVERT_DEBUG_PRC
+ //printf("AudioConverter::process Seek frame:%ld converted to frame:%ld sfCurFrame:%ld\n", frame, newfr, sfCurFrame);
+ //#endif
+
+ // Reset the converter. Its current state is meaningless now.
+ reset();
+ }
+ else
+ {
+ // No seek requested.
+ // Added by Tim. p3.3.17
+ //#ifdef AUDIOCONVERT_DEBUG_PRC
+ //printf("AudioConverter::process No 'transport' seek, rates different. Seeking to sfCurFrame:%ld\n", sfCurFrame);
+ //#endif
+
+ // Sample rates are different. We can't just tell seek to go to an absolute calculated position,
+ // since the last position can vary - it might not be what the calculated position is.
+ // We must use the last position left by SRC conversion, ie. let the file position progress on its own.
+ _sfCurFrame = f.seek(_sfCurFrame, 0);
+ }
+
+ /*
+ int fchan = f.channels();
+ long outFrames = n;
+ long outSize = outFrames * fchan;
+ float outbuffer[outSize];
+ */
+
+ //sfCurFrame = process(f, sfCurFrame, offset, &outbuffer[0], channel, n);
+// sfCurFrame = process(f, sfCurFrame, outbuffer, channel, n);
+ //sfCurFrame = process(f, sfCurFrame, buffer, channel, n, overwrite);
+ _sfCurFrame = process(f, buffer, channel, n, overwrite);
+
+ /*
+ float* poutbuf = &outbuffer[0];
+ if(fchan == channel)
+ {
+ if(overwrite)
+ //for (size_t i = 0; i < rn; ++i)
+ for (int i = 0; i < n; ++i)
+ {
+ for(int ch = 0; ch < channel; ++ch)
+ *(buffer[ch] + i) = *poutbuf++;
+ }
+ else
+ //for(size_t i = 0; i < rn; ++i)
+ for(int i = 0; i < n; ++i)
+ {
+ for(int ch = 0; ch < channel; ++ch)
+ *(buffer[ch] + i) += *poutbuf++;
+ }
+ }
+ else if((fchan == 2) && (channel == 1))
+ {
+ // stereo to mono
+ if(overwrite)
+ //for(size_t i = 0; i < rn; ++i)
+ for(int i = 0; i < n; ++i)
+ *(buffer[0] + i) = poutbuf[i + i] + poutbuf[i + i + 1];
+ else
+ //for(size_t i = 0; i < rn; ++i)
+ for(int i = 0; i < n; ++i)
+ *(buffer[0] + i) += poutbuf[i + i] + poutbuf[i + i + 1];
+ }
+ else if((fchan == 1) && (channel == 2))
+ {
+ // mono to stereo
+ if(overwrite)
+ //for(size_t i = 0; i < rn; ++i)
+ for(int i = 0; i < n; ++i)
+ {
+ float data = *poutbuf++;
+ *(buffer[0]+i) = data;
+ *(buffer[1]+i) = data;
+ }
+ else
+ //for(size_t i = 0; i < rn; ++i)
+ for(int i = 0; i < n; ++i)
+ {
+ float data = *poutbuf++;
+ *(buffer[0]+i) += data;
+ *(buffer[1]+i) += data;
+ }
+ }
+ else
+ {
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("AudioConverter::readAudio Channel mismatch: source chans:%d -> dst chans:%d\n", fchan, channel);
+ #endif
+ }
+ */
+
+ return _sfCurFrame;
+}
+
+//---------------------------------------------------------
+// SRCAudioConverter
+//---------------------------------------------------------
+
+SRCAudioConverter::SRCAudioConverter(int channels, int type) : AudioConverter()
+{
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("SRCAudioConverter::SRCAudioConverter this:%p channels:%d type:%d\n", this, channels, type);
+ #endif
+
+ _type = type;
+ _src_state = 0;
+ _channels = channels;
+
+ int srcerr;
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("SRCAudioConverter::SRCaudioConverter Creating samplerate converter type:%d with %d channels\n", _type, _channels);
+ #endif
+ _src_state = src_new(_type, _channels, &srcerr);
+ if(!_src_state)
+ printf("SRCAudioConverter::SRCaudioConverter Creation of samplerate converter type:%d with %d channels failed:%s\n", _type, _channels, src_strerror(srcerr));
+}
+
+SRCAudioConverter::~SRCAudioConverter()
+{
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("SRCAudioConverter::~SRCAudioConverter this:%p\n", this);
+ #endif
+ if(_src_state)
+ src_delete(_src_state);
+}
+
+void SRCAudioConverter::setChannels(int ch)
+{
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("SRCAudioConverter::setChannels this:%p channels:%d\n", this, ch);
+ #endif
+ if(_src_state)
+ src_delete(_src_state);
+ _src_state = 0;
+
+ _channels = ch;
+ int srcerr;
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("SRCAudioConverter::setChannels Creating samplerate converter type:%d with %d channels\n", _type, ch);
+ #endif
+ _src_state = src_new(_type, ch, &srcerr);
+ if(!_src_state)
+ printf("SRCAudioConverter::setChannels of samplerate converter type:%d with %d channels failed:%s\n", _type, ch, src_strerror(srcerr));
+ return;
+}
+
+void SRCAudioConverter::reset()
+{
+ if(!_src_state)
+ return;
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("SRCAudioConverter::reset this:%p\n", this);
+ #endif
+ int srcerr = src_reset(_src_state);
+ if(srcerr != 0)
+ printf("SRCAudioConverter::reset Converter reset failed: %s\n", src_strerror(srcerr));
+ return;
+}
+
+//off_t SRCAudioConverter::process(SndFileR& f, off_t sfCurFrame, float** buffer, int channel, int n, bool overwrite)
+off_t SRCAudioConverter::process(SndFileR& f, float** buffer, int channel, int n, bool overwrite)
+{
+ //return src_process(_src_state, sd);
+
+ if(f.isNull())
+ //return;
+ return _sfCurFrame;
+
+ // Added by Tim. p3.3.17
+ //#ifdef AUDIOCONVERT_DEBUG_PRC
+ //printf("AudioConverter::process %s audConv:%p sfCurFrame:%ld offset:%u channel:%d fchan:%d n:%d\n",
+ // f.name().toLatin1(), this, sfCurFrame, offset, channel, f.channels(), n);
+ //#endif
+
+// off_t frame = offset; // _spos is added before the call.
+ unsigned fsrate = f.samplerate();
+ //bool resample = src_state && ((unsigned)sampleRate != fsrate);
+// bool resample = isValid() && ((unsigned)sampleRate != fsrate);
+
+ if((sampleRate == 0) || (fsrate == 0))
+ {
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("SRCAudioConverter::process Error: sampleRate or file samplerate is zero!\n");
+ #endif
+ return _sfCurFrame;
+ }
+
+ SRC_DATA srcdata;
+ int fchan = f.channels();
+ // Ratio is defined as output sample rate over input samplerate.
+ double srcratio = (double)sampleRate / (double)fsrate;
+ // Extra input compensation.
+ long inComp = 1;
+
+ long outFrames = n;
+ //long outSize = outFrames * channel;
+ long outSize = outFrames * fchan;
+
+ //long inSize = long(outSize * srcratio) + 1 // From MusE-2 file converter.
+ //long inSize = (long)floor(((double)outSize / srcratio)); // From simplesynth.
+ //long inFrames = (long)floor(((double)outFrames / srcratio)); // From simplesynth.
+ long inFrames = (long)ceil(((double)outFrames / srcratio)) + inComp; // From simplesynth.
+ //long inFrames = (long)floor(double(outFrames * sfinfo.samplerate) / double(sampleRate)); // From simplesynth.
+
+ long inSize = inFrames * fchan;
+ //long inSize = inFrames * channel;
+
+ // Start with buffers at expected sizes. We won't need anything larger than this, but add 4 for good luck.
+ float inbuffer[inSize + 4];
+ float outbuffer[outSize];
+
+ //size_t sfTotalRead = 0;
+ size_t rn = 0;
+ long totalOutFrames = 0;
+
+ srcdata.data_in = inbuffer;
+ srcdata.data_out = outbuffer;
+// srcdata.data_out = buffer;
+
+ // Set some kind of limit on the number of attempts to completely fill the output buffer,
+ // in case something is really screwed up - we don't want to get stuck in a loop here.
+ int attempts = 10;
+ for(int attempt = 0; attempt < attempts; ++attempt)
+ {
+ rn = f.readDirect(inbuffer, inFrames);
+ //sfTotalRead += rn;
+
+ // convert
+ //srcdata.data_in = inbuffer;
+ //srcdata.data_out = outbuffer;
+ //srcdata.data_out = poutbuf;
+ //srcdata.input_frames = inSize;
+ srcdata.input_frames = rn;
+ srcdata.output_frames = outFrames;
+ srcdata.end_of_input = ((long)rn != inFrames);
+ srcdata.src_ratio = srcratio;
+
+ //#ifdef AUDIOCONVERT_DEBUG_PRC
+ //printf("AudioConverter::process attempt:%d inFrames:%ld outFrames:%ld rn:%d data in:%p out:%p",
+ // attempt, inFrames, outFrames, rn, srcdata.data_in, srcdata.data_out);
+ //#endif
+
+ int srcerr = src_process(_src_state, &srcdata);
+ if(srcerr != 0)
+ {
+ printf("\nSRCAudioConverter::process SampleRate converter process failed: %s\n", src_strerror(srcerr));
+ return _sfCurFrame += rn;
+ }
+
+ totalOutFrames += srcdata.output_frames_gen;
+
+ //#ifdef AUDIOCONVERT_DEBUG_PRC
+ //printf(" frames used in:%ld out:%ld totalOutFrames:%ld data in:%p out:%p\n", srcdata.input_frames_used, srcdata.output_frames_gen, totalOutFrames, srcdata.data_in, srcdata.data_out);
+ //#endif
+
+ #ifdef AUDIOCONVERT_DEBUG
+ if(srcdata.output_frames_gen != outFrames)
+ printf("SRCAudioConverter::process %s output_frames_gen:%ld != outFrames:%ld inFrames:%ld srcdata.input_frames_used:%ld rn:%d\n",
+ f.name().toLatin1(), srcdata.output_frames_gen, outFrames, inFrames, srcdata.input_frames_used, rn);
+ #endif
+
+ // If the number of frames read by the soundfile equals the input frames, go back.
+ // Otherwise we have reached the end of the file, so going back is useless since
+ // there shouldn't be any further calls.
+ if((long)rn == inFrames)
+ {
+ // Go back by the amount of unused frames.
+ sf_count_t seekn = inFrames - srcdata.input_frames_used;
+ if(seekn != 0)
+ {
+ #ifdef AUDIOCONVERT_DEBUG_PRC
+ printf("SRCAudioConverter::process Seek-back by:%d\n", seekn);
+ #endif
+ _sfCurFrame = f.seek(-seekn, SEEK_CUR);
+ }
+ else
+ _sfCurFrame += rn;
+
+ if(totalOutFrames == n)
+ {
+ // We got our desired number of output frames. Stop attempting.
+ break;
+ }
+ else
+ {
+ // No point in continuing if on last attempt.
+ if(attempt == (attempts - 1))
+ break;
+
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("SRCAudioConverter::process %s attempt:%d totalOutFrames:%ld != n:%d try again\n", f.name().toLatin1(), attempt, totalOutFrames, n);
+ #endif
+
+ // SRC didn't give us the number of frames we requested.
+ // This can occasionally be radically different from the requested frames, or zero,
+ // even when ample excess input frames are supplied.
+ // Move the src output pointer to a new position.
+ srcdata.data_out += srcdata.output_frames_gen * channel;
+ // Set new number of maximum out frames.
+ outFrames -= srcdata.output_frames_gen;
+ // Calculate the new number of file input frames required.
+ inFrames = (long)ceil(((double)outFrames / srcratio)) + inComp;
+ // Keep trying.
+ continue;
+ }
+ }
+ else
+ {
+ _sfCurFrame += rn;
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("SRCAudioConverter::process %s rn:%zd != inFrames:%ld output_frames_gen:%ld outFrames:%ld srcdata.input_frames_used:%ld\n",
+ f.name().toLatin1(), rn, inFrames, srcdata.output_frames_gen, outFrames, srcdata.input_frames_used);
+ #endif
+
+ // We've reached the end of the file. Convert the number of frames read.
+ //rn = (double)rn * srcratio + 1;
+ //rn = (long)floor((double)rn * srcratio);
+ //if(rn > (size_t)outFrames)
+ // rn = outFrames;
+ // Stop attempting.
+ break;
+ }
+ }
+
+ // If we still didn't get the desired number of output frames.
+ if(totalOutFrames != n)
+ {
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("SRCAudioConverter::process %s totalOutFrames:%ld != n:%d\n", f.name().toLatin1(), totalOutFrames, n);
+ #endif
+
+ // Let's zero the rest of it.
+ long b = totalOutFrames * channel;
+ long e = n * channel;
+ for(long i = b; i < e; ++i)
+ outbuffer[i] = 0.0f;
+ //buffer[i] = 0.0f;
+ }
+
+ //float* poutbuf = &outbuffer[0];
+ float* poutbuf = outbuffer;
+ if(fchan == channel)
+ {
+ if(overwrite)
+ //for (size_t i = 0; i < rn; ++i)
+ for (int i = 0; i < n; ++i)
+ {
+ for(int ch = 0; ch < channel; ++ch)
+ *(buffer[ch] + i) = *poutbuf++;
+ }
+ else
+ //for(size_t i = 0; i < rn; ++i)
+ for(int i = 0; i < n; ++i)
+ {
+ for(int ch = 0; ch < channel; ++ch)
+ *(buffer[ch] + i) += *poutbuf++;
+ }
+ }
+ else if((fchan == 2) && (channel == 1))
+ {
+ // stereo to mono
+ if(overwrite)
+ //for(size_t i = 0; i < rn; ++i)
+ for(int i = 0; i < n; ++i)
+ *(buffer[0] + i) = poutbuf[i + i] + poutbuf[i + i + 1];
+ else
+ //for(size_t i = 0; i < rn; ++i)
+ for(int i = 0; i < n; ++i)
+ *(buffer[0] + i) += poutbuf[i + i] + poutbuf[i + i + 1];
+ }
+ else if((fchan == 1) && (channel == 2))
+ {
+ // mono to stereo
+ if(overwrite)
+ //for(size_t i = 0; i < rn; ++i)
+ for(int i = 0; i < n; ++i)
+ {
+ float data = *poutbuf++;
+ *(buffer[0]+i) = data;
+ *(buffer[1]+i) = data;
+ }
+ else
+ //for(size_t i = 0; i < rn; ++i)
+ for(int i = 0; i < n; ++i)
+ {
+ float data = *poutbuf++;
+ *(buffer[0]+i) += data;
+ *(buffer[1]+i) += data;
+ }
+ }
+ else
+ {
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("SRCAudioConverter::process Channel mismatch: source chans:%d -> dst chans:%d\n", fchan, channel);
+ #endif
+ }
+
+ return _sfCurFrame;
+}
+
+#ifdef RUBBERBAND_SUPPORT
+
+//---------------------------------------------------------
+// RubberBandAudioConverter
+//---------------------------------------------------------
+
+RubberBandAudioConverter::RubberBandAudioConverter(int channels, int options) : AudioConverter()
+{
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("RubberBandAudioConverter::RubberBandAudioConverter this:%p channels:%d options:%x\n", this, channels, options);
+ #endif
+
+ _options = options;
+ _rbs = 0;
+ _channels = channels;
+
+ _rbs = new RubberBandStretcher(sampleRate, _channels, _options); // , initialTimeRatio = 1.0, initialPitchScale = 1.0
+}
+
+RubberBandAudioConverter::~RubberBandAudioConverter()
+{
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("RubberBandAudioConverter::~RubberBandAudioConverter this:%p\n", this);
+ #endif
+ if(_rbs)
+ delete _rbs;
+}
+
+void RubberBandAudioConverter::setChannels(int ch)
+{
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("RubberBandAudioConverter::setChannels this:%p channels:%d\n", this, ch);
+ #endif
+ if(_rbs)
+ delete _rbs;
+ _rbs = 0;
+
+ _channels = ch;
+ _rbs = new RubberBandStretcher(sampleRate, _channels, _options); // , initialTimeRatio = 1.0, initialPitchScale = 1.0
+}
+
+void RubberBandAudioConverter::reset()
+{
+ if(!_rbs)
+ return;
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("RubberBandAudioConverter::reset this:%p\n", this);
+ #endif
+ _rbs->reset();
+ return;
+}
+
+/////////////////////////////////
+// TODO: Not finished yet..
+////////////////////////////////
+//off_t RubberBandAudioConverter::process(SndFileR& f, off_t sfCurFrame, float** buffer, int channel, int n, bool overwrite)
+off_t RubberBandAudioConverter::process(SndFileR& f, float** buffer, int channel, int n, bool overwrite)
+{
+ //return src_process(_src_state, sd);
+
+ if(f.isNull())
+ //return;
+ return _sfCurFrame;
+
+ // Added by Tim. p3.3.17
+ //#ifdef AUDIOCONVERT_DEBUG_PRC
+ //printf("AudioConverter::process %s audConv:%p sfCurFrame:%ld offset:%u channel:%d fchan:%d n:%d\n",
+ // f.name().toLatin1(), this, sfCurFrame, offset, channel, f.channels(), n);
+ //#endif
+
+// off_t frame = offset; // _spos is added before the call.
+ unsigned fsrate = f.samplerate();
+ //bool resample = src_state && ((unsigned)sampleRate != fsrate);
+// bool resample = isValid() && ((unsigned)sampleRate != fsrate);
+
+ if((sampleRate == 0) || (fsrate == 0))
+ {
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("RubberBandAudioConverter::process Error: sampleRate or file samplerate is zero!\n");
+ #endif
+ return _sfCurFrame;
+ }
+
+// SRC_DATA srcdata;
+ int fchan = f.channels();
+ // Ratio is defined as output sample rate over input samplerate.
+ double srcratio = (double)sampleRate / (double)fsrate;
+ // Extra input compensation.
+ long inComp = 1;
+
+ long outFrames = n;
+ //long outSize = outFrames * channel;
+ long outSize = outFrames * fchan;
+
+ //long inSize = long(outSize * srcratio) + 1 // From MusE-2 file converter.
+ //long inSize = (long)floor(((double)outSize / srcratio)); // From simplesynth.
+ //long inFrames = (long)floor(((double)outFrames / srcratio)); // From simplesynth.
+ long inFrames = (long)ceil(((double)outFrames / srcratio)) + inComp; // From simplesynth.
+ //long inFrames = (long)floor(double(outFrames * sfinfo.samplerate) / double(sampleRate)); // From simplesynth.
+
+ long inSize = inFrames * fchan;
+ //long inSize = inFrames * channel;
+
+ // Start with buffers at expected sizes. We won't need anything larger than this, but add 4 for good luck.
+ float inbuffer[inSize]; // +4
+// float outbuffer[outSize];
+
+ //float* rbinbuffer[fchan];
+ //float rbindata[inSize];
+ //for (int i = 0; i < fchan; ++i)
+ // rbinbuffer[i] = rbindata + i * inFrames;
+
+ float* rboutbuffer[fchan];
+ float rboutdata[outSize];
+ for (int i = 0; i < fchan; ++i)
+ rboutbuffer[i] = rboutdata + i * outFrames;
+
+ //size_t sfTotalRead = 0;
+ size_t rn = 0;
+ long totalOutFrames = 0;
+
+// srcdata.data_in = inbuffer;
+ //srcdata.data_out = outbuffer;
+// srcdata.data_out = buffer;
+ float** data_out = rboutbuffer;
+
+ // For just sample rate conversion, apply same ratio to both time and pitch.
+ _rbs->setTimeRatio(srcratio);
+ _rbs->setPitchScale(srcratio);
+
+ // Set some kind of limit on the number of attempts to completely fill the output buffer,
+ // in case something is really screwed up - we don't want to get stuck in a loop here.
+ int attempts = 10;
+ for(int attempt = 0; attempt < attempts; ++attempt)
+ {
+ size_t sreq = _rbs->getSamplesRequired();
+
+ size_t rbinSize = sreq * fchan;
+ float* rbinbuffer[fchan];
+ float rbindata[rbinSize];
+ for(int i = 0; i < fchan; ++i)
+ rbinbuffer[i] = rbindata + i * sreq;
+
+// rn = f.readDirect(inbuffer, inFrames);
+ rn = f.readDirect(inbuffer, sreq);
+ //sfTotalRead += rn;
+
+ // Must de-interleave soundfile data to feed to rubberband.
+ for(size_t i = 0; i < rn; ++i)
+ {
+ for(int ch = 0; ch < fchan; ++ch)
+ *(rbinbuffer[ch] + i) = *inbuffer++;
+ }
+
+ _rbs->process(rbinbuffer, rn, (long)rn != inFrames);
+
+ // "This function returns -1 if all data has been fully processed and all output read, and the stretch process is now finished."
+ int savail = _rbs->available();
+
+
+ // convert
+ //srcdata.data_in = inbuffer;
+ //srcdata.data_out = outbuffer;
+ //srcdata.data_out = poutbuf;
+ //srcdata.input_frames = inSize;
+ srcdata.input_frames = rn;
+ srcdata.output_frames = outFrames;
+ srcdata.end_of_input = ((long)rn != inFrames);
+ srcdata.src_ratio = srcratio;
+
+ //#ifdef AUDIOCONVERT_DEBUG_PRC
+ //printf("AudioConverter::process attempt:%d inFrames:%ld outFrames:%ld rn:%d data in:%p out:%p",
+ // attempt, inFrames, outFrames, rn, srcdata.data_in, srcdata.data_out);
+ //#endif
+
+ int srcerr = src_process(_src_state, &srcdata);
+ if(srcerr != 0)
+ {
+ printf("\RubberBandAudioConverter::process SampleRate converter process failed: %s\n", src_strerror(srcerr));
+ return _sfCurFrame += rn;
+ }
+
+ totalOutFrames += srcdata.output_frames_gen;
+
+ //#ifdef AUDIOCONVERT_DEBUG_PRC
+ //printf(" frames used in:%ld out:%ld totalOutFrames:%ld data in:%p out:%p\n", srcdata.input_frames_used, srcdata.output_frames_gen, totalOutFrames, srcdata.data_in, srcdata.data_out);
+ //#endif
+
+ #ifdef AUDIOCONVERT_DEBUG
+ if(srcdata.output_frames_gen != outFrames)
+ printf("RubberBandAudioConverter::process %s output_frames_gen:%ld != outFrames:%ld inFrames:%ld srcdata.input_frames_used:%ld rn:%d\n",
+ f.name().toLatin1(), srcdata.output_frames_gen, outFrames, inFrames, srcdata.input_frames_used, rn);
+ #endif
+
+ // If the number of frames read by the soundfile equals the input frames, go back.
+ // Otherwise we have reached the end of the file, so going back is useless since
+ // there shouldn't be any further calls.
+ if((long)rn == inFrames)
+ {
+ // Go back by the amount of unused frames.
+ sf_count_t seekn = inFrames - srcdata.input_frames_used;
+ if(seekn != 0)
+ {
+ #ifdef AUDIOCONVERT_DEBUG_PRC
+ printf("RubberBandAudioConverter::process Seek-back by:%d\n", seekn);
+ #endif
+ _sfCurFrame = f.seek(-seekn, SEEK_CUR);
+ }
+ else
+ _sfCurFrame += rn;
+
+ if(totalOutFrames == n)
+ {
+ // We got our desired number of output frames. Stop attempting.
+ break;
+ }
+ else
+ {
+ // No point in continuing if on last attempt.
+ if(attempt == (attempts - 1))
+ break;
+
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("RubberBandAudioConverter::process %s attempt:%d totalOutFrames:%ld != n:%d try again\n", f.name().toLatin1(), attempt, totalOutFrames, n);
+ #endif
+
+ // We didn't get the number of frames we requested.
+ // This can occasionally be radically different from the requested frames, or zero,
+ // even when ample excess input frames are supplied.
+ // Move the src output pointer to a new position.
+ srcdata.data_out += srcdata.output_frames_gen * channel;
+ // Set new number of maximum out frames.
+ outFrames -= srcdata.output_frames_gen;
+ // Calculate the new number of file input frames required.
+ inFrames = (long)ceil(((double)outFrames / srcratio)) + inComp;
+ // Keep trying.
+ continue;
+ }
+ }
+ else
+ {
+ _sfCurFrame += rn;
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("RubberBandAudioConverter::process %s rn:%zd != inFrames:%ld output_frames_gen:%ld outFrames:%ld srcdata.input_frames_used:%ld\n",
+ f.name().toLatin1(), rn, inFrames, srcdata.output_frames_gen, outFrames, srcdata.input_frames_used);
+ #endif
+
+ // We've reached the end of the file. Convert the number of frames read.
+ //rn = (double)rn * srcratio + 1;
+ //rn = (long)floor((double)rn * srcratio);
+ //if(rn > (size_t)outFrames)
+ // rn = outFrames;
+ // Stop attempting.
+ break;
+ }
+ }
+
+ // If we still didn't get the desired number of output frames.
+ if(totalOutFrames != n)
+ {
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("RubberBandAudioConverter::process %s totalOutFrames:%ld != n:%d\n", f.name().toLatin1(), totalOutFrames, n);
+ #endif
+
+ // Let's zero the rest of it.
+ long b = totalOutFrames * channel;
+ long e = n * channel;
+ for(long i = b; i < e; ++i)
+ //outbuffer[i] = 0.0f;
+ buffer[i] = 0.0f;
+ }
+
+ //float* poutbuf = &outbuffer[0];
+ float* poutbuf = outbuffer;
+ if(fchan == channel)
+ {
+ if(overwrite)
+ //for (size_t i = 0; i < rn; ++i)
+ for (int i = 0; i < n; ++i)
+ {
+ for(int ch = 0; ch < channel; ++ch)
+ *(buffer[ch] + i) = *poutbuf++;
+ }
+ else
+ //for(size_t i = 0; i < rn; ++i)
+ for(int i = 0; i < n; ++i)
+ {
+ for(int ch = 0; ch < channel; ++ch)
+ *(buffer[ch] + i) += *poutbuf++;
+ }
+ }
+ else if((fchan == 2) && (channel == 1))
+ {
+ // stereo to mono
+ if(overwrite)
+ //for(size_t i = 0; i < rn; ++i)
+ for(int i = 0; i < n; ++i)
+ *(buffer[0] + i) = poutbuf[i + i] + poutbuf[i + i + 1];
+ else
+ //for(size_t i = 0; i < rn; ++i)
+ for(int i = 0; i < n; ++i)
+ *(buffer[0] + i) += poutbuf[i + i] + poutbuf[i + i + 1];
+ }
+ else if((fchan == 1) && (channel == 2))
+ {
+ // mono to stereo
+ if(overwrite)
+ //for(size_t i = 0; i < rn; ++i)
+ for(int i = 0; i < n; ++i)
+ {
+ float data = *poutbuf++;
+ *(buffer[0]+i) = data;
+ *(buffer[1]+i) = data;
+ }
+ else
+ //for(size_t i = 0; i < rn; ++i)
+ for(int i = 0; i < n; ++i)
+ {
+ float data = *poutbuf++;
+ *(buffer[0]+i) += data;
+ *(buffer[1]+i) += data;
+ }
+ }
+ else
+ {
+ #ifdef AUDIOCONVERT_DEBUG
+ printf("RubberBandAudioConverter::process Channel mismatch: source chans:%d -> dst chans:%d\n", fchan, channel);
+ #endif
+ }
+
+ return _sfCurFrame;
+}
+
+#endif // RUBBERBAND_SUPPORT
diff --git a/attic/muse2-oom/muse2/muse/audioconvert.h b/attic/muse2-oom/muse2/muse/audioconvert.h
new file mode 100644
index 00000000..039af912
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/audioconvert.h
@@ -0,0 +1,129 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: audioconvert.h,v 1.1.1.1 2009/12/28 16:07:33 terminator356 Exp $
+//
+// (C) Copyright 1999-2009 Werner Schweer (ws@seh.de)
+//
+// Audio converter module created by Tim terminator356
+//=========================================================
+
+#ifndef __AUDIOCONVERT_H__
+#define __AUDIOCONVERT_H__
+
+#include <map>
+
+#ifdef RUBBERBAND_SUPPORT
+#include <RubberBandStretcher.h>
+#endif
+
+#include <samplerate.h>
+#include <sys/types.h>
+
+//#include "eventbase.h"
+class EventBase;
+class EventList;
+
+class SndFileR;
+
+//---------------------------------------------------------
+// AudioConverter
+//---------------------------------------------------------
+
+class AudioConverter
+{
+ protected:
+ int _refCount;
+ off_t _sfCurFrame;
+
+ public:
+ AudioConverter();
+ ~AudioConverter();
+
+ AudioConverter* reference();
+ static AudioConverter* release(AudioConverter* cv);
+
+ //off_t readAudio(SndFileR& /*sf*/, off_t /*sfCurFrame*/, unsigned /*offset*/, float** /*buffer*/,
+ // int /*channels*/, int /*frames*/, bool /*doSeek*/, bool /*overwrite*/);
+ off_t readAudio(SndFileR& /*sf*/, unsigned /*offset*/, float** /*buffer*/,
+ int /*channels*/, int /*frames*/, bool /*doSeek*/, bool /*overwrite*/);
+
+ virtual bool isValid() = 0;
+ virtual void reset() = 0;
+ virtual void setChannels(int ch) = 0;
+ //virtual off_t process(SndFileR& /*sf*/, off_t /*sfCurFrame*/, float** /*buffer*/,
+ // int /*channels*/, int /*frames*/, bool /*overwrite*/) = 0; // Interleaved buffer if stereo.
+ virtual off_t process(SndFileR& /*sf*/, float** /*buffer*/,
+ int /*channels*/, int /*frames*/, bool /*overwrite*/) = 0; // Interleaved buffer if stereo.
+};
+
+//---------------------------------------------------------
+// SRCAudioConverter
+//---------------------------------------------------------
+
+class SRCAudioConverter : public AudioConverter
+{
+ int _type;
+ int _channels;
+ SRC_STATE* _src_state;
+
+ public:
+ SRCAudioConverter(int channels, int type);
+ ~SRCAudioConverter();
+
+ virtual bool isValid() { return _src_state != 0; }
+ virtual void reset();
+ virtual void setChannels(int ch);
+ //virtual off_t process(SndFileR& /*sf*/, off_t /*sfCurFrame*/, float** /*buffer*/,
+ // int /*channels*/, int /*frames*/, bool /*overwrite*/); // Interleaved buffer if stereo.
+ virtual off_t process(SndFileR& /*sf*/, float** /*buffer*/,
+ int /*channels*/, int /*frames*/, bool /*overwrite*/); // Interleaved buffer if stereo.
+};
+
+#ifdef RUBBERBAND_SUPPORT
+
+//---------------------------------------------------------
+// RubberBandAudioConverter
+//---------------------------------------------------------
+
+class RubberBandAudioConverter : public AudioConverter
+{
+ int _options;
+ int _channels;
+ RubberBandStretcher* _rbs;
+
+ public:
+ RubberBandAudioConverter(int channels, int options);
+ ~RubberBandAudioConverter();
+
+ virtual bool isValid() { return _rbs != 0; }
+ virtual void reset();
+ virtual void setChannels(int ch);
+ //virtual off_t process(SndFileR& /*sf*/, off_t /*sfCurFrame*/, float** /*buffer*/,
+ // int /*channels*/, int /*frames*/, bool /*overwrite*/); // Interleaved buffer if stereo.
+ virtual off_t process(SndFileR& /*sf*/, float** /*buffer*/,
+ int /*channels*/, int /*frames*/, bool /*overwrite*/); // Interleaved buffer if stereo.
+};
+
+#endif // RUBBERBAND_SUPPORT
+
+//---------------------------------------------------------
+// AudioConvertMap
+//---------------------------------------------------------
+
+typedef std::map<EventBase*, AudioConverter*, std::less<EventBase*> >::iterator iAudioConvertMap;
+typedef std::map<EventBase*, AudioConverter*, std::less<EventBase*> >::const_iterator ciAudioConvertMap;
+
+//typedef std::map<EventBase*, AudioConverter*, std::less<EventBase*> > AudioConvertMap;
+class AudioConvertMap : public std::map<EventBase*, AudioConverter*, std::less<EventBase*> >
+{
+ public:
+ void remapEvents(const EventList*);
+ iAudioConvertMap addEvent(EventBase*);
+ void removeEvent(EventBase*);
+ //AudioConverter* getConverter(const EventBase*);
+ iAudioConvertMap getConverter(EventBase*);
+};
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/audioprefetch.cpp b/attic/muse2-oom/muse2/muse/audioprefetch.cpp
new file mode 100644
index 00000000..b2ddab8c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/audioprefetch.cpp
@@ -0,0 +1,262 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: audioprefetch.cpp,v 1.14.2.7 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <poll.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <values.h>
+
+#include "audioprefetch.h"
+#include "globals.h"
+#include "track.h"
+#include "song.h"
+#include "audio.h"
+#include "sync.h"
+
+// Added by Tim. p3.3.20
+//#define AUDIOPREFETCH_DEBUG
+
+enum { PREFETCH_TICK, PREFETCH_SEEK
+ };
+
+//---------------------------------------------------------
+// PrefetchMsg
+//---------------------------------------------------------
+
+struct PrefetchMsg : public ThreadMsg {
+ int pos;
+ };
+
+AudioPrefetch* audioPrefetch;
+
+//---------------------------------------------------------
+// AudioPrefetch
+//---------------------------------------------------------
+
+//AudioPrefetch::AudioPrefetch(int prio, const char* name)
+// : Thread(prio,name)
+AudioPrefetch::AudioPrefetch(const char* name)
+ : Thread(name)
+ {
+ seekPos = ~0;
+ writePos = ~0;
+ //seekDone = true;
+ seekCount = 0;
+ }
+
+//---------------------------------------------------------
+// readMsg
+//---------------------------------------------------------
+
+static void readMsgP(void* p, void*)
+ {
+ AudioPrefetch* at = (AudioPrefetch*)p;
+ at->readMsg1(sizeof(PrefetchMsg));
+ }
+
+//---------------------------------------------------------
+// start
+//---------------------------------------------------------
+
+//void AudioPrefetch::start()
+void AudioPrefetch::start(int priority)
+ {
+ clearPollFd();
+ addPollFd(toThreadFdr, POLLIN, ::readMsgP, this, 0);
+ //Thread::start();
+ Thread::start(priority);
+ }
+
+//---------------------------------------------------------
+// ~AudioPrefetch
+//---------------------------------------------------------
+
+AudioPrefetch::~AudioPrefetch()
+ {
+ }
+
+//---------------------------------------------------------
+// processMsg
+//---------------------------------------------------------
+
+void AudioPrefetch::processMsg1(const void* m)
+ {
+ const PrefetchMsg* msg = (PrefetchMsg*)m;
+ switch(msg->id) {
+ case PREFETCH_TICK:
+ if (audio->isRecording()) {
+ //puts("writeTick");
+ audio->writeTick();
+ }
+ // Indicate do not seek file before each read.
+ // Changed by Tim. p3.3.17
+ //prefetch();
+ prefetch(false);
+
+ seekPos = ~0; // invalidate cached last seek position
+ break;
+ case PREFETCH_SEEK:
+ #ifdef AUDIOPREFETCH_DEBUG
+ printf("AudioPrefetch::processMsg1 PREFETCH_SEEK msg->pos:%d\n", msg->pos);
+ #endif
+
+ // process seek in background
+ seek(msg->pos);
+ break;
+ default:
+ printf("AudioPrefetch::processMsg1: unknown message\n");
+ }
+ }
+
+//---------------------------------------------------------
+// msgTick
+//---------------------------------------------------------
+
+void AudioPrefetch::msgTick()
+ {
+ PrefetchMsg msg;
+ msg.id = PREFETCH_TICK;
+ while (sendMsg1(&msg, sizeof(msg))) {
+ printf("AudioPrefetch::msgTick(): send failed!\n");
+ }
+ }
+
+//---------------------------------------------------------
+// msgSeek
+// called from audio RT context
+//---------------------------------------------------------
+
+void AudioPrefetch::msgSeek(unsigned samplePos, bool force)
+ {
+ if (samplePos == seekPos && !force) {
+ //seekDone = true;
+ return;
+ }
+
+ ++seekCount;
+ //seekDone = false;
+
+ #ifdef AUDIOPREFETCH_DEBUG
+ printf("AudioPrefetch::msgSeek samplePos:%u force:%d seekCount:%d\n", samplePos, force, seekCount);
+ #endif
+
+ PrefetchMsg msg;
+ msg.id = PREFETCH_SEEK;
+ msg.pos = samplePos;
+ while (sendMsg1(&msg, sizeof(msg))) {
+ printf("AudioPrefetch::msgSeek::sleep(1)\n");
+ sleep(1);
+ }
+ }
+
+//---------------------------------------------------------
+// prefetch
+//---------------------------------------------------------
+
+//void AudioPrefetch::prefetch()
+void AudioPrefetch::prefetch(bool doSeek)
+ {
+ if (writePos == ~0U) {
+ printf("AudioPrefetch::prefetch: invalid write position\n");
+ return;
+ }
+ if (song->loop() && !audio->bounce() && !extSyncFlag.value()) {
+ const Pos& loop = song->rPos();
+ unsigned n = loop.frame() - writePos;
+ if (n < segmentSize) {
+ unsigned lpos = song->lPos().frame();
+ // adjust loop start so we get exact loop len
+ if (n > lpos)
+ n = 0;
+// printf("prefetch seek %d\n", writePos);
+ writePos = lpos - n;
+ }
+ }
+ WaveTrackList* tl = song->waves();
+ for (iWaveTrack it = tl->begin(); it != tl->end(); ++it) {
+ WaveTrack* track = *it;
+ // p3.3.29
+ // Save time. Don't bother if track is off. Track On/Off not designed for rapid repeated response (but mute is).
+ if(track->off())
+ continue;
+
+ int ch = track->channels();
+ float* bp[ch];
+// printf("prefetch %d\n", writePos);
+ if (track->prefetchFifo()->getWriteBuffer(ch, segmentSize, bp, writePos)) {
+ // printf("AudioPrefetch::prefetch No write buffer!\n"); // p3.3.46 Was getting this...
+ continue;
+ }
+ //track->fetchData(writePos, segmentSize, bp);
+ track->fetchData(writePos, segmentSize, bp, doSeek);
+
+ // p3.3.41
+ //fprintf(stderr, "AudioPrefetch::prefetch data: segmentSize:%ld %e %e %e %e\n", segmentSize, bp[0][0], bp[0][1], bp[0][2], bp[0][3]);
+
+ }
+ writePos += segmentSize;
+ }
+
+//---------------------------------------------------------
+// seek
+//---------------------------------------------------------
+
+void AudioPrefetch::seek(unsigned seekTo)
+ {
+// printf("seek %d\n", seekTo);
+ #ifdef AUDIOPREFETCH_DEBUG
+ printf("AudioPrefetch::seek to:%u seekCount:%d\n", seekTo, seekCount);
+ #endif
+
+ // Speedup: More than one seek message pending?
+ // Eat up seek messages until we get to the very LATEST one,
+ // because all the rest which came before it are irrelevant now,
+ // and processing them all was taking extreme time, especially with
+ // resampling enabled.
+ // In particular, when the user 'slides' the play cursor back and forth
+ // there are MANY seek messages in the pipe, and with resampling enabled
+ // it was taking minutes to finish seeking. If the user hit play during that time,
+ // things were messed up (FIFO underruns, choppy intermittent sound etc).
+ // Added by Tim. p3.3.20
+ if(seekCount > 1)
+ {
+ --seekCount;
+ return;
+ }
+
+ writePos = seekTo;
+ WaveTrackList* tl = song->waves();
+ for (iWaveTrack it = tl->begin(); it != tl->end(); ++it) {
+ WaveTrack* track = *it;
+ track->clearPrefetchFifo();
+ }
+
+ bool isFirstPrefetch = true;
+ for (unsigned int i = 0; i < (fifoLength)-1; ++i)//prevent compiler warning: comparison of signed/unsigned
+ {
+ // Indicate do a seek command before read, but only on the first pass.
+ // Changed by Tim. p3.3.17
+ //prefetch();
+ prefetch(isFirstPrefetch);
+
+ isFirstPrefetch = false;
+
+ // To help speed things up even more, check the count again. Return if more seek messages are pending.
+ // Added by Tim. p3.3.20
+ if(seekCount > 1)
+ {
+ --seekCount;
+ return;
+ }
+ }
+
+ seekPos = seekTo;
+ //seekDone = true;
+ --seekCount;
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/audioprefetch.h b/attic/muse2-oom/muse2/muse/audioprefetch.h
new file mode 100644
index 00000000..dda4d895
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/audioprefetch.h
@@ -0,0 +1,46 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: audioprefetch.h,v 1.3.2.2 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __AUDIOPREFETCH_H__
+#define __AUDIOPREFETCH_H__
+
+#include "thread.h"
+
+//---------------------------------------------------------
+// AudioPrefetch
+//---------------------------------------------------------
+
+class AudioPrefetch : public Thread {
+ unsigned writePos;
+ unsigned seekPos; // remember last seek to optimize seeks
+
+ virtual void processMsg1(const void*);
+ //void prefetch();
+ void prefetch(bool doSeek);
+ void seek(unsigned pos);
+
+ volatile int seekCount;
+
+ public:
+ //AudioPrefetch(int prio, const char* name);
+ AudioPrefetch(const char* name);
+
+ ~AudioPrefetch();
+ //virtual void start();
+ virtual void start(int);
+
+ void msgTick();
+ void msgSeek(unsigned samplePos, bool force=false);
+
+ //volatile bool seekDone;
+ bool seekDone() const { return seekCount == 0; }
+ };
+
+extern AudioPrefetch* audioPrefetch;
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/audiotrack.cpp b/attic/muse2-oom/muse2/muse/audiotrack.cpp
new file mode 100644
index 00000000..415b1b8d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/audiotrack.cpp
@@ -0,0 +1,1652 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: audiotrack.cpp,v 1.14.2.21 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <values.h>
+#include <stdlib.h>
+#include <map>
+
+#include <QMessageBox>
+
+#include "track.h"
+#include "event.h"
+#include "song.h"
+#include "audio.h"
+#include "wave.h"
+#include "xml.h"
+#include "plugin.h"
+#include "audiodev.h"
+
+// By T356. For caching jack in/out routing names BEFORE file save.
+// Jack often shuts down during file save, causing the routes to be lost in the file.
+// cacheJackRouteNames() is ONLY called from MusE::save() in app.cpp
+// Update: Not required any more because the real problem was Jack RT priority, which has been fixed.
+/*
+typedef std::multimap <const int, QString> jackRouteNameMap;
+std::map <const AudioTrack*, jackRouteNameMap > jackRouteNameCache;
+typedef std::multimap <const int, QString>::const_iterator ciJackRouteNameMap;
+typedef std::map <const AudioTrack*, jackRouteNameMap>::const_iterator ciJackRouteNameCache;
+void cacheJackRouteNames()
+{
+ jackRouteNameCache.clear();
+ const InputList* il = song->inputs();
+ for(ciAudioInput iai = il->begin(); iai != il->end(); ++iai)
+ {
+ const RouteList* rl = (*iai)->inRoutes();
+ if(!rl->empty())
+ {
+ jackRouteNameMap rm = jackRouteNameMap();
+ for(ciRoute r = rl->begin(); r != rl->end(); ++r)
+ rm.insert(std::pair<const int, QString>(r->channel, r->name()));
+ jackRouteNameCache.insert(std::pair<const AudioTrack*, jackRouteNameMap>(*iai, rm));
+ }
+ }
+ const OutputList* ol = song->outputs();
+ for(ciAudioOutput iao = ol->begin(); iao != ol->end(); ++iao)
+ {
+ const RouteList* rl = (*iao)->outRoutes();
+ if(!rl->empty())
+ {
+ jackRouteNameMap rm = jackRouteNameMap();
+ for(ciRoute r = rl->begin(); r != rl->end(); ++r)
+ rm.insert(std::pair<const int, QString>(r->channel, r->name()));
+ jackRouteNameCache.insert(std::pair<const AudioTrack*, jackRouteNameMap>(*iao, rm));
+ }
+ }
+}
+*/
+
+//---------------------------------------------------------
+// AudioTrack
+//---------------------------------------------------------
+
+AudioTrack::AudioTrack(TrackType t)
+//AudioTrack::AudioTrack(TrackType t, int num_out_bufs)
+ : Track(t)
+ {
+ //_totalOutChannels = num_out_bufs; // Is either parameter-default MAX_CHANNELS, or custom value passed (used by syntis).
+ _processed = false;
+ _haveData = false;
+ _sendMetronome = false;
+ _prefader = false;
+ _efxPipe = new Pipeline();
+ _recFile = 0;
+ _channels = 0;
+ _automationType = AUTO_OFF;
+ //setChannels(1);
+ setChannels(2);
+ addController(new CtrlList(AC_VOLUME,"Volume",0.0,1.0));
+ addController(new CtrlList(AC_PAN, "Pan", -1.0, 1.0));
+ addController(new CtrlList(AC_MUTE,"Mute",0.0,1.0, true /*dont show in arranger */));
+
+ // Changed by Tim. p3.3.15
+ //outBuffers = new float*[MAX_CHANNELS];
+ //for (int i = 0; i < MAX_CHANNELS; ++i)
+ // outBuffers[i] = new float[segmentSize];
+ //for (int i = 0; i < MAX_CHANNELS; ++i)
+ // posix_memalign((void**)(outBuffers + i), 16, sizeof(float) * segmentSize);
+
+ // Let's allocate it all in one block, and just point the remaining buffer pointers into the block
+ // which allows faster one-shot buffer copying.
+ // Nope. Nice but interferes with possibility we don't know if other buffers are contiguous (jack buffers, local stack buffers etc.).
+ //posix_memalign((void**)(outBuffers), 16, sizeof(float) * segmentSize * MAX_CHANNELS);
+ //for (int i = 0; i < MAX_CHANNELS; ++i)
+ // *(outBuffers + i) = sizeof(float) * segmentSize * i;
+
+ // p3.3.38
+ // Easy way, less desirable... Start out with enough for MAX_CHANNELS. Then multi-channel syntis can re-allocate,
+ // via a call to (a modified!) setChannels().
+ // Hard way, more desirable... Creating a synti instance passes the total channels to this constructor, overriding MAX_CHANNELS.
+ _totalOutChannels = MAX_CHANNELS;
+ outBuffers = new float*[_totalOutChannels];
+ for (int i = 0; i < _totalOutChannels; ++i)
+ posix_memalign((void**)&outBuffers[i], 16, sizeof(float) * segmentSize);
+
+ // This is only set by multi-channel syntis...
+ _totalInChannels = 0;
+
+ bufferPos = MAXINT;
+
+ setVolume(1.0);
+ }
+
+//AudioTrack::AudioTrack(const AudioTrack& t)
+// : Track(t)
+AudioTrack::AudioTrack(const AudioTrack& t, bool cloneParts)
+ : Track(t, cloneParts)
+ {
+ _totalOutChannels = t._totalOutChannels; // Is either MAX_CHANNELS, or custom value (used by syntis).
+ _processed = false;
+ _haveData = false;
+ _sendMetronome = t._sendMetronome;
+ _controller = t._controller;
+ _prefader = t._prefader;
+ _auxSend = t._auxSend;
+ _efxPipe = new Pipeline(*(t._efxPipe));
+ _automationType = t._automationType;
+ _inRoutes = t._inRoutes;
+ _outRoutes = t._outRoutes;
+ // Changed by Tim. p3.3.15
+ //outBuffers = new float*[MAX_CHANNELS];
+ //for (int i = 0; i < MAX_CHANNELS; ++i)
+ // outBuffers[i] = new float[segmentSize];
+ //for (int i = 0; i < MAX_CHANNELS; ++i)
+ // posix_memalign((void**)(outBuffers + i), 16, sizeof(float) * segmentSize);
+
+ // p3.3.38
+ int chans = _totalOutChannels;
+ // Number of allocated buffers is always MAX_CHANNELS or more, even if _totalOutChannels is less.
+ if(chans < MAX_CHANNELS)
+ chans = MAX_CHANNELS;
+ outBuffers = new float*[chans];
+ for (int i = 0; i < chans; ++i)
+ posix_memalign((void**)&outBuffers[i], 16, sizeof(float) * segmentSize);
+
+ bufferPos = MAXINT;
+ _recFile = t._recFile;
+ }
+
+AudioTrack::~AudioTrack()
+{
+ delete _efxPipe;
+ //for (int i = 0; i < MAX_CHANNELS; ++i)
+ // delete[] outBuffers[i];
+ //delete[] outBuffers;
+
+ // p3.3.15
+ //for(int i = 0; i < MAX_CHANNELS; ++i)
+ //{
+ // if(outBuffers[i])
+ // free(outBuffers[i]);
+ //}
+
+ // p3.3.38
+ int chans = _totalOutChannels;
+ // Number of allocated buffers is always MAX_CHANNELS or more, even if _totalOutChannels is less.
+ if(chans < MAX_CHANNELS)
+ chans = MAX_CHANNELS;
+ for(int i = 0; i < chans; ++i)
+ {
+ if(outBuffers[i])
+ free(outBuffers[i]);
+ }
+ delete[] outBuffers;
+
+}
+
+//---------------------------------------------------------
+// deleteAllEfxGuis
+//---------------------------------------------------------
+
+void AudioTrack::deleteAllEfxGuis()
+{
+ if(_efxPipe)
+ _efxPipe->deleteAllGuis();
+}
+
+//---------------------------------------------------------
+// clearEfxList
+//---------------------------------------------------------
+
+void AudioTrack::clearEfxList()
+{
+ if(_efxPipe)
+ for(int i = 0; i < PipelineDepth; i++)
+ (*_efxPipe)[i] = 0;
+}
+
+//---------------------------------------------------------
+// newPart
+//---------------------------------------------------------
+
+Part* AudioTrack::newPart(Part*, bool /*clone*/)
+ {
+ return 0;
+ }
+
+//---------------------------------------------------------
+// addPlugin
+//---------------------------------------------------------
+
+void AudioTrack::addPlugin(PluginI* plugin, int idx)
+{
+ if (plugin == 0)
+ {
+ PluginI* oldPlugin = (*_efxPipe)[idx];
+ if (oldPlugin)
+ {
+ oldPlugin->setID(-1);
+ oldPlugin->setTrack(0);
+
+ int controller = oldPlugin->parameters();
+ for (int i = 0; i < controller; ++i)
+ {
+ int id = genACnum(idx, i);
+ removeController(id);
+ }
+ }
+ }
+ efxPipe()->insert(plugin, idx);
+ if (plugin)
+ {
+ plugin->setID(idx);
+ plugin->setTrack(this);
+
+ int controller = plugin->parameters();
+ for (int i = 0; i < controller; ++i)
+ {
+ int id = genACnum(idx, i);
+ const char* name = plugin->paramName(i);
+ float min, max;
+ plugin->range(i, &min, &max);
+ CtrlValueType t = plugin->valueType();
+ CtrlList* cl = new CtrlList(id);
+ cl->setRange(min, max);
+ cl->setName(QString(name));
+ cl->setValueType(t);
+ LADSPA_PortRangeHint range = plugin->range(i);
+ if(LADSPA_IS_HINT_TOGGLED(range.HintDescriptor))
+ cl->setMode(CtrlList::DISCRETE);
+ else
+ cl->setMode(CtrlList::INTERPOLATE);
+ cl->setCurVal(plugin->param(i));
+ addController(cl);
+ }
+ }
+}
+
+//---------------------------------------------------------
+// addAuxSend
+//---------------------------------------------------------
+
+void AudioTrack::addAuxSend(int n)
+ {
+ int nn = _auxSend.size();
+ for (int i = nn; i < n; ++i) {
+ _auxSend.push_back(0.0);
+ _auxSend[i] = 0.0; //??
+ }
+ }
+
+//---------------------------------------------------------
+// addController
+//---------------------------------------------------------
+
+void AudioTrack::addController(CtrlList* list)
+ {
+ _controller.add(list);
+ }
+
+//---------------------------------------------------------
+// removeController
+//---------------------------------------------------------
+
+void AudioTrack::removeController(int id)
+ {
+ iCtrlList i = _controller.find(id);
+ if (i == _controller.end()) {
+ printf("AudioTrack::removeController id %d not found\n", id);
+ return;
+ }
+ _controller.erase(i);
+ }
+
+//---------------------------------------------------------
+// swapControllerIDX
+//---------------------------------------------------------
+
+void AudioTrack::swapControllerIDX(int idx1, int idx2)
+{
+ // FIXME This code is ugly.
+ // At best we would like to modify the keys (IDXs) in-place and
+ // do some kind of deferred re-sort, but it can't be done...
+
+ if(idx1 == idx2)
+ return;
+
+ if(idx1 < 0 || idx2 < 0 || idx1 >= PipelineDepth || idx2 >= PipelineDepth)
+ return;
+
+ CtrlList *cl;
+ CtrlList *newcl;
+ int id1 = (idx1 + 1) * AC_PLUGIN_CTL_BASE;
+ int id2 = (idx2 + 1) * AC_PLUGIN_CTL_BASE;
+ int i, j;
+
+ CtrlListList tmpcll;
+ CtrlVal cv(0, 0.0);
+
+ for(ciCtrlList icl = _controller.begin(); icl != _controller.end(); ++icl)
+ {
+ cl = icl->second;
+ i = cl->id() & AC_PLUGIN_CTL_ID_MASK;
+ j = cl->id() & ~((unsigned long)AC_PLUGIN_CTL_ID_MASK);
+ if(j == id1 || j == id2)
+ {
+ newcl = new CtrlList(i | (j == id1 ? id2 : id1));
+ newcl->setMode(cl->mode());
+ newcl->setValueType(cl->valueType());
+ newcl->setName(cl->name());
+ double min, max;
+ cl->range(&min, &max);
+ newcl->setRange(min, max);
+ newcl->setCurVal(cl->curVal());
+ newcl->setDefault(cl->getDefault());
+ for(iCtrl ic = cl->begin(); ic != cl->end(); ++ic)
+ {
+ cv = ic->second;
+ newcl->insert(std::pair<const int, CtrlVal>(cv.frame, cv));
+ }
+ tmpcll.insert(std::pair<const int, CtrlList*>(newcl->id(), newcl));
+ }
+ else
+ {
+ newcl = new CtrlList();
+ *newcl = *cl;
+ tmpcll.insert(std::pair<const int, CtrlList*>(newcl->id(), newcl));
+ }
+ }
+
+ for(iCtrlList ci = _controller.begin(); ci != _controller.end(); ++ci)
+ delete (*ci).second;
+
+ _controller.clear();
+
+ for(ciCtrlList icl = tmpcll.begin(); icl != tmpcll.end(); ++icl)
+ {
+ newcl = icl->second;
+ _controller.insert(std::pair<const int, CtrlList*>(newcl->id(), newcl));
+ }
+
+
+ /*
+ unsigned int idmask = ~AC_PLUGIN_CTL_ID_MASK;
+
+ CtrlList* cl;
+ CtrlList* ctl1 = 0;
+ CtrlList* ctl2 = 0;
+ CtrlList* newcl1 = 0;
+ CtrlList* newcl2 = 0;
+ CtrlVal cv(0, 0.0);
+ int id1 = (idx1 + 1) * AC_PLUGIN_CTL_BASE;
+ int id2 = (idx2 + 1) * AC_PLUGIN_CTL_BASE;
+ int i, j;
+ double min, max;
+
+ for(ciCtrlList icl = _controller.begin(); icl != _controller.end(); ++icl)
+ {
+ cl = icl->second;
+ i = cl->id() & AC_PLUGIN_CTL_ID_MASK;
+ j = cl->id() & idmask;
+
+ if(j == id1)
+ {
+ ctl1 = cl;
+ newcl1 = new CtrlList( i | id2 );
+ newcl1->setMode(cl->mode());
+ newcl1->setValueType(cl->valueType());
+ newcl1->setName(cl->name());
+ cl->range(&min, &max);
+ newcl1->setRange(min, max);
+ newcl1->setCurVal(cl->curVal());
+ newcl1->setDefault(cl->getDefault());
+ for(iCtrl ic = cl->begin(); ic != cl->end(); ++ic)
+ {
+ cv = ic->second;
+ newcl1->insert(std::pair<const int, CtrlVal>(cv.frame, cv));
+ }
+ }
+ //else
+ if(j == id2)
+ {
+ ctl2 = cl;
+ newcl2 = new CtrlList( i | id1 );
+ newcl2->setMode(cl->mode());
+ newcl2->setValueType(cl->valueType());
+ newcl2->setName(cl->name());
+ cl->range(&min, &max);
+ newcl2->setRange(min, max);
+ newcl2->setCurVal(cl->curVal());
+ newcl2->setDefault(cl->getDefault());
+ for(iCtrl ic = cl->begin(); ic != cl->end(); ++ic)
+ {
+ cv = ic->second;
+ newcl2->insert(std::pair<const int, CtrlVal>(cv.frame, cv));
+ }
+ }
+ }
+ if(ctl1)
+ _controller.erase(ctl1->id());
+ if(ctl2)
+ _controller.erase(ctl2->id());
+ if(newcl1)
+ //_controller.add(newcl1);
+ _controller.insert(std::pair<const int, CtrlList*>(newcl1->id(), newcl1));
+ if(newcl2)
+ _controller.insert(std::pair<const int, CtrlList*>(newcl2->id(), newcl2));
+ //_controller.add(newcl2);
+ */
+}
+
+//---------------------------------------------------------
+// setAutomationType
+//---------------------------------------------------------
+
+void AudioTrack::setAutomationType(AutomationType t)
+{
+ // Clear pressed and touched and rec event list.
+ clearRecAutomation(true);
+
+ // Now set the type.
+ _automationType = t;
+}
+
+//---------------------------------------------------------
+// processAutomationEvents
+//---------------------------------------------------------
+
+void AudioTrack::processAutomationEvents()
+{
+ if (_automationType != AUTO_TOUCH && _automationType != AUTO_WRITE)
+ return;
+
+ for (iCtrlList icl = _controller.begin(); icl != _controller.end(); ++icl)
+ {
+ CtrlList* cl = icl->second;
+ int id = cl->id();
+
+ // Remove old events from record region.
+ if (_automationType == AUTO_WRITE)
+ {
+ int start = audio->getStartRecordPos().frame();
+ int end = audio->getEndRecordPos().frame();
+ iCtrl s = cl->lower_bound(start);
+ iCtrl e = cl->lower_bound(end);
+
+ // Erase old events only if there were recorded events.
+ for(iCtrlRec icr = _recEvents.begin(); icr != _recEvents.end(); ++icr)
+ {
+ if(icr->id == id) // && icr->type == ARVT_VAL && icr->frame >= s->frame && icr->frame <= e->frame)
+ {
+ cl->erase(s, e);
+ break;
+ }
+ }
+ }
+ else
+ { // type AUTO_TOUCH
+ for (iCtrlRec icr = _recEvents.begin(); icr != _recEvents.end(); ++icr)
+ {
+ // Don't bother looking for start, it's OK, just take the first one.
+ // Needed for mousewheel and paging etc.
+ //if (icr->id == id && icr->type == ARVT_START)
+ if (icr->id == id)
+ {
+ int start = icr->frame;
+
+ if(icr == _recEvents.end())
+ {
+ int end = audio->getEndRecordPos().frame();
+ iCtrl s = cl->lower_bound(start);
+ iCtrl e = cl->lower_bound(end);
+ cl->erase(s, e);
+ break;
+ }
+
+ iCtrlRec icrlast = icr;
+ ++icr;
+ for(; ; ++icr)
+ {
+ if(icr == _recEvents.end())
+ {
+ int end = icrlast->frame;
+ iCtrl s = cl->lower_bound(start);
+ iCtrl e = cl->lower_bound(end);
+ cl->erase(s, e);
+ break;
+ }
+
+ if(icr->id == id && icr->type == ARVT_STOP)
+ {
+ int end = icr->frame;
+ // Erase everything up to, not including, this stop event's frame.
+ // Because an event was already stored directly when slider released.
+ if(end > start)
+ --end;
+
+ iCtrl s = cl->lower_bound(start);
+ iCtrl e = cl->lower_bound(end);
+
+ cl->erase(s, e);
+
+ break;
+ }
+
+ if(icr->id == id)
+ icrlast = icr;
+ }
+ if (icr == _recEvents.end())
+ break;
+ }
+ }
+ }
+
+ // Extract all recorded events for controller "id"
+ // from CtrlRecList and put into cl.
+ for (iCtrlRec icr = _recEvents.begin(); icr != _recEvents.end(); ++icr)
+ {
+ if (icr->id == id && (icr->type == ARVT_VAL || icr->type == ARVT_START))
+ cl->add(icr->frame, icr->val);
+ }
+ }
+
+ // Done with the recorded automation event list. Clear it.
+ _recEvents.clear();
+
+ // Try muse without this, so that the user can remain in automation write mode
+ // after a stop.
+ /*
+ if (automationType() == AUTO_WRITE)
+ {
+ setAutomationType(AUTO_READ);
+ song->update(SC_AUTOMATION);
+ }
+ */
+
+}
+
+//---------------------------------------------------------
+// setControllerMode
+//---------------------------------------------------------
+
+void AudioTrack::setControllerMode(int ctlID, CtrlList::Mode m)
+ {
+ ciCtrlList cl = _controller.find(ctlID);
+ if(cl == _controller.end())
+ return;
+
+ cl->second->setMode(m);
+ }
+
+//---------------------------------------------------------
+// clearControllerEvents
+//---------------------------------------------------------
+
+void AudioTrack::clearControllerEvents(int id)
+{
+ ciCtrlList icl = _controller.find(id);
+ if(icl == _controller.end())
+ return;
+
+ CtrlList* cl = icl->second;
+ cl->clear();
+ return;
+}
+
+//---------------------------------------------------------
+// seekPrevACEvent
+//---------------------------------------------------------
+
+void AudioTrack::seekPrevACEvent(int id)
+{
+ ciCtrlList icl = _controller.find(id);
+ if(icl == _controller.end())
+ return;
+
+ CtrlList* cl = icl->second;
+ if(cl->empty())
+ return;
+
+ iCtrl s = cl->lower_bound(song->cPos().frame());
+ if(s != cl->begin())
+ --s;
+ song->setPos(Song::CPOS, Pos(s->second.frame, false), true, false, true);
+ return;
+}
+
+//---------------------------------------------------------
+// seekNextACEvent
+//---------------------------------------------------------
+
+void AudioTrack::seekNextACEvent(int id)
+{
+ ciCtrlList icl = _controller.find(id);
+ if(icl == _controller.end())
+ return;
+
+ CtrlList* cl = icl->second;
+ if(cl->empty())
+ return;
+
+ iCtrl s = cl->upper_bound(song->cPos().frame());
+ if(s == cl->end())
+ {
+ --s;
+ }
+
+ song->setPos(Song::CPOS, Pos(s->second.frame, false), true, false, true);
+ return;
+}
+
+//---------------------------------------------------------
+// eraseACEvent
+//---------------------------------------------------------
+
+void AudioTrack::eraseACEvent(int id, int frame)
+{
+ ciCtrlList icl = _controller.find(id);
+ if(icl == _controller.end())
+ return;
+
+ CtrlList* cl = icl->second;
+ if(cl->empty())
+ return;
+
+ iCtrl s = cl->find(frame);
+ if(s != cl->end())
+ cl->erase(s);
+ return;
+}
+
+//---------------------------------------------------------
+// eraseRangeACEvents
+//---------------------------------------------------------
+
+void AudioTrack::eraseRangeACEvents(int id, int frame1, int frame2)
+{
+ ciCtrlList icl = _controller.find(id);
+ if(icl == _controller.end())
+ return;
+
+ CtrlList* cl = icl->second;
+ if(cl->empty())
+ return;
+
+ iCtrl s = cl->lower_bound(frame1);
+ iCtrl e = cl->lower_bound(frame2);
+ cl->erase(s, e);
+ return;
+}
+
+//---------------------------------------------------------
+// addACEvent
+//---------------------------------------------------------
+
+void AudioTrack::addACEvent(int id, int frame, double val)
+{
+ ciCtrlList icl = _controller.find(id);
+ if(icl == _controller.end())
+ return;
+
+ CtrlList* cl = icl->second;
+
+ // Add will replace if found.
+ cl->add(frame, val);
+ return;
+}
+
+//---------------------------------------------------------
+// volume
+//---------------------------------------------------------
+
+double AudioTrack::volume() const
+ {
+ ciCtrlList cl = _controller.find(AC_VOLUME);
+ if (cl == _controller.end())
+ return 0.0;
+
+ if (automation &&
+ automationType() != AUTO_OFF && _volumeEnCtrl && _volumeEn2Ctrl )
+ return cl->second->value(song->cPos().frame());
+ else
+ return cl->second->curVal();
+ }
+
+//---------------------------------------------------------
+// setVolume
+//---------------------------------------------------------
+
+void AudioTrack::setVolume(double val)
+ {
+ iCtrlList cl = _controller.find(AC_VOLUME);
+ if (cl == _controller.end()) {
+ printf("no volume controller %s %zd\n",
+ name().toLatin1().constData(), _controller.size());
+ return;
+ }
+ cl->second->setCurVal(val);
+ }
+
+//---------------------------------------------------------
+// pan
+//---------------------------------------------------------
+
+double AudioTrack::pan() const
+ {
+ ciCtrlList cl = _controller.find(AC_PAN);
+ if (cl == _controller.end())
+ return 0.0;
+
+ if (automation &&
+ automationType() != AUTO_OFF && _panEnCtrl && _panEn2Ctrl )
+ return cl->second->value(song->cPos().frame());
+ else
+ return cl->second->curVal();
+ }
+
+//---------------------------------------------------------
+// setPan
+//---------------------------------------------------------
+
+void AudioTrack::setPan(double val)
+ {
+ iCtrlList cl = _controller.find(AC_PAN);
+ if (cl == _controller.end()) {
+ printf("no pan controller\n");
+ return;
+ }
+ cl->second->setCurVal(val);
+ }
+
+//---------------------------------------------------------
+// pluginCtrlVal
+//---------------------------------------------------------
+
+double AudioTrack::pluginCtrlVal(int ctlID) const
+ {
+ ciCtrlList cl = _controller.find(ctlID);
+ if (cl == _controller.end())
+ return 0.0;
+
+ if (automation && (automationType() != AUTO_OFF))
+ return cl->second->value(song->cPos().frame());
+ else
+ return cl->second->curVal();
+ }
+
+//---------------------------------------------------------
+// setPluginCtrlVal
+//---------------------------------------------------------
+
+void AudioTrack::setPluginCtrlVal(int param, double val)
+{
+ iCtrlList cl = _controller.find(param);
+ if (cl == _controller.end())
+ return;
+
+ cl->second->setCurVal(val);
+}
+
+void AudioTrack::recordAutomation(int n, double v)
+ {
+ if(!automation)
+ return;
+ if(audio->isPlaying())
+ _recEvents.push_back(CtrlRecVal(song->cPos().frame(), n, v));
+ else
+ {
+ if(automationType() == AUTO_WRITE)
+ _recEvents.push_back(CtrlRecVal(song->cPos().frame(), n, v));
+ else
+ if(automationType() == AUTO_TOUCH)
+ // In touch mode and not playing. Send directly to controller list.
+ {
+ iCtrlList cl = _controller.find(n);
+ if (cl == _controller.end())
+ return;
+ // Add will replace if found.
+ cl->second->add(song->cPos().frame(), v);
+ }
+ }
+ }
+
+void AudioTrack::startAutoRecord(int n, double v)
+ {
+ if(!automation)
+ return;
+ if(audio->isPlaying())
+ {
+ if(automationType() == AUTO_TOUCH)
+ _recEvents.push_back(CtrlRecVal(song->cPos().frame(), n, v, ARVT_START));
+ else
+ if(automationType() == AUTO_WRITE)
+ _recEvents.push_back(CtrlRecVal(song->cPos().frame(), n, v));
+ }
+ else
+ {
+ if(automationType() == AUTO_TOUCH)
+ // In touch mode and not playing. Send directly to controller list.
+ {
+ iCtrlList cl = _controller.find(n);
+ if (cl == _controller.end())
+ return;
+ // Add will replace if found.
+ cl->second->add(song->cPos().frame(), v);
+ }
+ else
+ if(automationType() == AUTO_WRITE)
+ _recEvents.push_back(CtrlRecVal(song->cPos().frame(), n, v));
+ }
+ }
+
+void AudioTrack::stopAutoRecord(int n, double v)
+ {
+ if(!automation)
+ return;
+ if(audio->isPlaying())
+ {
+ if(automationType() == AUTO_TOUCH)
+ {
+ audio->msgAddACEvent(this, n, song->cPos().frame(), v);
+ _recEvents.push_back(CtrlRecVal(song->cPos().frame(), n, v, ARVT_STOP));
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// AudioTrack::writeProperties
+//---------------------------------------------------------
+
+void AudioTrack::writeProperties(int level, Xml& xml) const
+ {
+ Track::writeProperties(level, xml);
+ xml.intTag(level, "prefader", prefader());
+ xml.intTag(level, "sendMetronome", sendMetronome());
+ xml.intTag(level, "automation", int(automationType()));
+ if (hasAuxSend()) {
+ int naux = song->auxs()->size();
+ for (int idx = 0; idx < naux; ++idx) {
+ QString s("<auxSend idx=\"%1\">%2</auxSend>\n");
+ xml.nput(level, s.arg(idx).arg(_auxSend[idx]).toAscii().constData());
+ }
+ }
+ for (ciPluginI ip = _efxPipe->begin(); ip != _efxPipe->end(); ++ip) {
+ if (*ip)
+ (*ip)->writeConfiguration(level, xml);
+ }
+ for (ciCtrlList icl = _controller.begin(); icl != _controller.end(); ++icl) {
+ const CtrlList* cl = icl->second;
+ QString s("controller id=\"%1\" cur=\"%2\"");
+ xml.tag(level++, s.arg(cl->id()).arg(cl->curVal()).toAscii().constData());
+ int i = 0;
+ for (ciCtrl ic = cl->begin(); ic != cl->end(); ++ic) {
+ QString s("%1 %2, ");
+ xml.nput(level, s.arg(ic->second.frame).arg(ic->second.val).toAscii().constData());
+ ++i;
+ if (i >= 4) {
+ xml.put(level, "");
+ i = 0;
+ }
+ }
+ if (i)
+ xml.put(level, "");
+ xml.etag(level--, "controller");
+ }
+ }
+
+//---------------------------------------------------------
+// readAuxSend
+//---------------------------------------------------------
+
+void AudioTrack::readAuxSend(Xml& xml)
+ {
+ unsigned idx = 0;
+ double val;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::Attribut:
+ if (tag == "idx")
+ idx = xml.s2().toInt();
+ break;
+ case Xml::Text:
+ val = tag.toDouble();
+ break;
+ case Xml::TagEnd:
+ if (xml.s1() == "auxSend") {
+ if (_auxSend.size() < idx+1)
+ _auxSend.push_back(val);
+ else
+ _auxSend[idx] = val;
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// AudioTrack::readProperties
+//---------------------------------------------------------
+
+bool AudioTrack::readProperties(Xml& xml, const QString& tag)
+ {
+ if (tag == "plugin")
+ {
+ int rackpos;
+ for(rackpos = 0; rackpos < PipelineDepth; ++rackpos)
+ {
+ if(!(*_efxPipe)[rackpos])
+ break;
+ }
+ if(rackpos < PipelineDepth)
+ {
+ PluginI* pi = new PluginI();
+ pi->setTrack(this);
+ pi->setID(rackpos);
+ if(pi->readConfiguration(xml, false))
+ delete pi;
+ else
+ (*_efxPipe)[rackpos] = pi;
+ }
+ else
+ printf("can't load plugin - plugin rack is already full\n");
+ }
+ else if (tag == "auxSend")
+ readAuxSend(xml);
+ else if (tag == "prefader")
+ _prefader = xml.parseInt();
+ else if (tag == "sendMetronome")
+ _sendMetronome = xml.parseInt();
+ else if (tag == "automation")
+ setAutomationType(AutomationType(xml.parseInt()));
+ // Removed by T356
+ // "recfile" tag not saved anymore
+ //else if (tag == "recfile")
+ // readRecfile(xml);
+ else if (tag == "controller") {
+ CtrlList* l = new CtrlList();
+ l->read(xml);
+
+ // Since (until now) muse wrote a 'zero' for plugin controller current value
+ // in the XML file, we can't use that value, now that plugin automation is added.
+ // We must take the value from the plugin control value.
+ // Otherwise we break all existing .med files with plugins, because the gui
+ // controls would all be set to zero.
+ // But we will allow for the (unintended, useless) possibility of a controller
+ // with no matching plugin control.
+ PluginI* p = 0;
+ bool ctlfound = false;
+ int m = l->id() & AC_PLUGIN_CTL_ID_MASK;
+ int n = (l->id() >> AC_PLUGIN_CTL_BASE_POW) - 1;
+ if(n >= 0 && n < PipelineDepth)
+ {
+ p = (*_efxPipe)[n];
+ if(p && m < p->parameters())
+ ctlfound = true;
+ }
+
+ iCtrlList icl = _controller.find(l->id());
+ if (icl == _controller.end())
+ _controller.add(l);
+ else {
+ CtrlList* d = icl->second;
+ for (iCtrl i = l->begin(); i != l->end(); ++i)
+ d->insert(std::pair<const int, CtrlVal> (i->first, i->second));
+
+ if(!ctlfound)
+ d->setCurVal(l->curVal());
+
+ d->setDefault(l->getDefault());
+ delete l;
+ l = d;
+ }
+
+ if(ctlfound)
+ {
+ l->setCurVal(p->param(m));
+ LADSPA_PortRangeHint range = p->range(m);
+ if(LADSPA_IS_HINT_TOGGLED(range.HintDescriptor))
+ l->setMode(CtrlList::DISCRETE);
+ else
+ l->setMode(CtrlList::INTERPOLATE);
+ }
+ }
+ else
+ return Track::readProperties(xml, tag);
+ return false;
+ }
+
+//---------------------------------------------------------
+// showPendingPluginNativeGuis
+// This is needed because OSC needs all tracks with plugins to be already
+// added to their track lists so it can find them and show their native guis.
+//---------------------------------------------------------
+
+void AudioTrack::showPendingPluginNativeGuis()
+{
+ for(int idx = 0; idx < PipelineDepth; ++idx)
+ {
+ PluginI* p = (*_efxPipe)[idx];
+ if(!p)
+ continue;
+
+ if(p->isShowNativeGuiPending())
+ p->showNativeGui(true);
+ }
+}
+
+//---------------------------------------------------------
+// mapRackPluginsToControllers
+//---------------------------------------------------------
+
+void AudioTrack::mapRackPluginsToControllers()
+{
+ // Iterate all possible plugin controller indexes...
+ for(int idx = PipelineDepth - 1; idx >= 0; idx--)
+ {
+ iCtrlList icl = _controller.lower_bound((idx + 1) * AC_PLUGIN_CTL_BASE);
+ if(icl == _controller.end() || ((icl->second->id() >> AC_PLUGIN_CTL_BASE_POW) - 1) != idx)
+ continue;
+
+ // We found some controllers with that index. Now iterate the plugin rack...
+ for(int i = idx; i >= 0; i--)
+ {
+ PluginI* p = (*_efxPipe)[i];
+ if(!p)
+ continue;
+
+ // We found a plugin at a rack position. If the rack position is not the same as the controller index...
+ if(i != idx)
+ {
+ (*_efxPipe)[i] = 0;
+ (*_efxPipe)[idx] = p;
+ }
+ p->setID(idx);
+
+ // It is now safe to update the controllers.
+ p->updateControllers();
+
+ break;
+ }
+ }
+
+ // No matter of the outcome of the above - rack position is not too critical -
+ // making sure that each control has a controller is important. Otherwise they
+ // are stuck at zero can't be adjusted.
+ // Muse med files created before the automation patches (before 0.9pre1) may have broken
+ // controller sections, so this will allow more tolerance of them.
+ for(int idx = 0; idx < PipelineDepth; idx++)
+ {
+ PluginI* p = (*_efxPipe)[idx];
+ if(!p)
+ continue;
+
+ if(p->id() != idx)
+ p->setID(idx);
+
+ int j = p->parameters();
+
+ for(int i = 0; i < j; i++)
+ {
+ int id = genACnum(idx, i);
+ CtrlList* l = 0;
+
+ ciCtrlList icl = _controller.find(id);
+ if(icl == _controller.end())
+ {
+ l = new CtrlList(id);
+ addController(l);
+ }
+ else
+ l = icl->second;
+
+ // Force all of these now, even though they may have already been set. With a pre-
+ // 0.9pre1 med file with broken controller sections they may not be set correct.
+ float min, max;
+ p->range(i, &min, &max);
+ CtrlValueType t = p->valueType();
+ l->setRange(min, max);
+ l->setName(QString(p->paramName(i)));
+ l->setValueType(t);
+ LADSPA_PortRangeHint rh = p->range(i);
+ if(LADSPA_IS_HINT_TOGGLED(rh.HintDescriptor))
+ l->setMode(CtrlList::DISCRETE);
+ else
+ l->setMode(CtrlList::INTERPOLATE);
+ l->setCurVal(p->param(i));
+ //l->setDefault(p->defaultValue(i));
+ }
+ }
+
+ // The loop is a safe way to delete while iterating 'non-linear' lists.
+ bool loop;
+ do
+ {
+ loop = false;
+ for(ciCtrlList icl = _controller.begin(); icl != _controller.end(); ++icl)
+ {
+ CtrlList* l = icl->second;
+ int id = l->id();
+ // Ignore volume, pan, mute etc.
+ if(id < AC_PLUGIN_CTL_BASE)
+ continue;
+ int param = id & AC_PLUGIN_CTL_ID_MASK;
+ int idx = (id >> AC_PLUGIN_CTL_BASE_POW) - 1;
+ PluginI* p = (*_efxPipe)[idx];
+ // If there's no plugin at that rack position, or the param is out of range of
+ // the number of controls in the plugin, then it's a stray controller. Delete it.
+ // Future: Leave room for possible bypass controller at AC_PLUGIN_CTL_ID_MASK -1.
+ //if(!p || (param >= p->parameters() && (param != AC_PLUGIN_CTL_ID_MASK -1)))
+ if(!p || (param >= p->parameters()))
+ {
+ _controller.erase(id);
+
+ loop = true;
+ break;
+ }
+ }
+ }
+ while (loop);
+
+
+ // Although this tested OK, and is the 'official' way to erase while iterating,
+ // I don't trust it. I'm weary of this method. The technique didn't work
+ // in Audio::msgRemoveTracks(), see comments there.
+ /*
+
+ // Now delete any stray controllers which don't belong to anything.
+ for(iCtrlList icl = _controller.begin(); icl != _controller.end(); )
+ {
+ CtrlList* l = icl->second;
+ int id = l->id();
+ // Ignore volume, pan, mute etc.
+ if(id < AC_PLUGIN_CTL_BASE)
+ {
+ ++icl;
+ continue;
+ }
+ int param = id & AC_PLUGIN_CTL_ID_MASK;
+ int idx = (id >> AC_PLUGIN_CTL_BASE_POW) - 1;
+ PluginI* p = (*_efxPipe)[idx];
+ // If there's no plugin at that rack position, or the param is out of range of
+ // the number of controls in the plugin, then it's a stray controller. Delete it.
+ // Future: Leave room for possible bypass controller at AC_PLUGIN_CTL_ID_MASK -1.
+ //if(!p || (param >= p->parameters() && (param != AC_PLUGIN_CTL_ID_MASK -1)))
+ if(!p || (param >= p->parameters()))
+ _controller.erase(icl++);
+ else
+ ++icl;
+ }
+ */
+}
+
+/*
+//---------------------------------------------------------
+// writeRouting
+//---------------------------------------------------------
+
+void AudioTrack::writeRouting(int level, Xml& xml) const
+{
+ QString n;
+ if (type() == Track::AUDIO_INPUT) {
+ ciJackRouteNameCache circ = jackRouteNameCache.find(this);
+ if(circ != jackRouteNameCache.end())
+ {
+ jackRouteNameMap rm = circ->second;
+ for(ciJackRouteNameMap cirm = rm.begin(); cirm != rm.end(); ++cirm)
+ {
+ n = cirm->second;
+ if(!n.isEmpty())
+ {
+ Route dst(name(), true, cirm->first);
+ xml.tag(level++, "Route");
+ xml.strTag(level, "srcNode", n);
+ xml.strTag(level, "dstNode", dst.name());
+ xml.etag(level--, "Route");
+ }
+ }
+ }
+ }
+ if(type() == Track::AUDIO_OUTPUT)
+ {
+ ciJackRouteNameCache circ = jackRouteNameCache.find(this);
+ if(circ != jackRouteNameCache.end())
+ {
+ jackRouteNameMap rm = circ->second;
+ for(ciJackRouteNameMap cirm = rm.begin(); cirm != rm.end(); ++cirm)
+ {
+ n = cirm->second;
+ if(!n.isEmpty())
+ {
+ Route src(name(), false, cirm->first);
+ xml.tag(level++, "Route");
+ xml.strTag(level, "srcNode", src.name());
+ xml.strTag(level, "dstNode", n);
+ xml.etag(level--, "Route");
+ }
+ }
+ }
+ }
+ else
+ {
+ const RouteList* rl = &_outRoutes;
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r) {
+ if(!r->name().isEmpty())
+ {
+ xml.tag(level++, "Route");
+ xml.strTag(level, "srcNode", name());
+ xml.strTag(level, "dstNode", r->name());
+ xml.etag(level--, "Route");
+ }
+ }
+ }
+}
+*/
+
+//---------------------------------------------------------
+// AudioInput
+//---------------------------------------------------------
+
+AudioInput::AudioInput()
+ : AudioTrack(AUDIO_INPUT)
+ {
+ // set Default for Input Ports:
+ _mute = true;
+ //setVolume(1.0);
+ for (int i = 0; i < MAX_CHANNELS; ++i)
+ jackPorts[i] = 0;
+ //_channels = 0;
+ //setChannels(2);
+ }
+
+//AudioInput::AudioInput(const AudioInput& t)
+// : AudioTrack(t)
+AudioInput::AudioInput(const AudioInput& t, bool cloneParts)
+ : AudioTrack(t, cloneParts)
+ {
+ for (int i = 0; i < MAX_CHANNELS; ++i)
+ jackPorts[i] = t.jackPorts[i];
+ }
+
+//---------------------------------------------------------
+// ~AudioInput
+//---------------------------------------------------------
+
+AudioInput::~AudioInput()
+ {
+ if (!checkAudioDevice()) return;
+ for (int i = 0; i < _channels; ++i)
+ if(jackPorts[i])
+ audioDevice->unregisterPort(jackPorts[i]);
+ }
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+void AudioInput::write(int level, Xml& xml) const
+ {
+ xml.tag(level++, "AudioInput");
+ AudioTrack::writeProperties(level, xml);
+ xml.etag(level, "AudioInput");
+ }
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+void AudioInput::read(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (AudioTrack::readProperties(xml, tag))
+ xml.unknown("AudioInput");
+ break;
+ case Xml::Attribut:
+ break;
+ case Xml::TagEnd:
+ if (tag == "AudioInput") {
+ setName(name()); // allocate jack ports
+ mapRackPluginsToControllers();
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// AudioOutput
+//---------------------------------------------------------
+
+AudioOutput::AudioOutput()
+ : AudioTrack(AUDIO_OUTPUT)
+ {
+ for (int i = 0; i < MAX_CHANNELS; ++i)
+ jackPorts[i] = 0;
+ //_channels = 0;
+ //setChannels(2);
+ }
+
+//AudioOutput::AudioOutput(const AudioOutput& t)
+// : AudioTrack(t)
+AudioOutput::AudioOutput(const AudioOutput& t, bool cloneParts)
+ : AudioTrack(t, cloneParts)
+ {
+ for (int i = 0; i < MAX_CHANNELS; ++i)
+ jackPorts[i] = t.jackPorts[i];
+ _nframes = t._nframes;
+ }
+
+//---------------------------------------------------------
+// ~AudioOutput
+//---------------------------------------------------------
+
+AudioOutput::~AudioOutput()
+ {
+ if (!checkAudioDevice()) return;
+ for (int i = 0; i < _channels; ++i)
+ if(jackPorts[i])
+ audioDevice->unregisterPort(jackPorts[i]);
+ }
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+void AudioOutput::write(int level, Xml& xml) const
+ {
+ xml.tag(level++, "AudioOutput");
+ AudioTrack::writeProperties(level, xml);
+ xml.etag(level, "AudioOutput");
+ }
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+void AudioOutput::read(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (AudioTrack::readProperties(xml, tag))
+ xml.unknown("AudioOutput");
+ break;
+ case Xml::Attribut:
+ break;
+ case Xml::TagEnd:
+ if (tag == "AudioOutput") {
+ setName(name()); // allocate jack ports
+ mapRackPluginsToControllers();
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+void AudioGroup::write(int level, Xml& xml) const
+ {
+ xml.tag(level++, "AudioGroup");
+ AudioTrack::writeProperties(level, xml);
+ xml.etag(level, "AudioGroup");
+ }
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+void AudioGroup::read(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (AudioTrack::readProperties(xml, tag))
+ xml.unknown("AudioGroup");
+ break;
+ case Xml::Attribut:
+ break;
+ case Xml::TagEnd:
+ if (tag == "AudioGroup")
+ {
+ mapRackPluginsToControllers();
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+void AudioAux::write(int level, Xml& xml) const
+ {
+ xml.tag(level++, "AudioAux");
+ AudioTrack::writeProperties(level, xml);
+ xml.etag(level, "AudioAux");
+ }
+
+//---------------------------------------------------------
+// AudioAux
+//---------------------------------------------------------
+
+AudioAux::AudioAux()
+ : AudioTrack(AUDIO_AUX)
+{
+ //_channels = 0;
+ //setChannels(2);
+ // Changed by Tim. p3.3.15
+ //for (int i = 0; i < MAX_CHANNELS; ++i)
+ // buffer[i] = (i < channels()) ? new float[segmentSize] : 0;
+ for(int i = 0; i < MAX_CHANNELS; ++i)
+ {
+ if(i < channels())
+ posix_memalign((void**)(buffer + i), 16, sizeof(float) * segmentSize);
+ else
+ buffer[i] = 0;
+ }
+}
+
+//---------------------------------------------------------
+// AudioAux
+//---------------------------------------------------------
+
+AudioAux::~AudioAux()
+ {
+ // Changed by Tim. p3.3.15
+ //for (int i = 0; i < channels(); ++i)
+ // delete[] buffer[i];
+ for (int i = 0; i < MAX_CHANNELS; ++i) {
+ if (buffer[i])
+ free(buffer[i]);
+ }
+ }
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+void AudioAux::read(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (AudioTrack::readProperties(xml, tag))
+ xml.unknown("AudioAux");
+ break;
+ case Xml::Attribut:
+ break;
+ case Xml::TagEnd:
+ if (tag == "AudioAux")
+ {
+ mapRackPluginsToControllers();
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// getData
+//---------------------------------------------------------
+
+bool AudioAux::getData(unsigned /*pos*/, int ch, unsigned /*samples*/, float** data)
+ {
+ for (int i = 0; i < ch; ++i)
+ data[i] = buffer[i % channels()];
+ return true;
+ }
+
+//---------------------------------------------------------
+// setChannels
+//---------------------------------------------------------
+
+void AudioAux::setChannels(int n)
+{
+ if(n > channels())
+ {
+ // Changed by Tim. p3.3.15
+ //for (int i = channels(); i < n; ++i)
+ // buffer[i] = new float[segmentSize];
+ for(int i = channels(); i < n; ++i)
+ posix_memalign((void**)(buffer + i), 16, sizeof(float) * segmentSize);
+ }
+ else if(n < channels())
+ {
+ // Changed by Tim. p3.3.15
+ //for (int i = n; i < channels(); ++i)
+ // delete[] buffer[i];
+ for(int i = n; i < channels(); ++i)
+ {
+ if(buffer[i])
+ free(buffer[i]);
+ }
+ }
+ AudioTrack::setChannels(n);
+}
+
+//---------------------------------------------------------
+// setRecordFlag1
+// gui part (executed in gui thread)
+//---------------------------------------------------------
+
+bool AudioTrack::setRecordFlag1(bool f)
+ {
+ if (f == _recordFlag)
+ return true;
+ if (f) {
+ if (_recFile == 0) {
+ //
+ // create soundfile for recording
+ //
+ char buffer[128];
+ QFile fil;
+ for (;;++recFileNumber) {
+ sprintf(buffer, "%s/rec%d.wav",
+ museProject.toLatin1().constData(),
+ recFileNumber);
+ fil.setFileName(QString(buffer));
+ if (!fil.exists())
+ break;
+ }
+ _recFile = new SndFile(QString(buffer));
+ _recFile->setFormat(
+ SF_FORMAT_WAV | SF_FORMAT_FLOAT,
+ _channels, sampleRate);
+ }
+// if(_recFile->openWrite())
+// {
+// QMessageBox::critical(NULL, "MusE write error.", "Error creating target wave file\n"
+// "Check your configuration.");
+// return false;
+//
+// }
+ if (debugMsg)
+ printf("AudioNode::setRecordFlag1: create internal file %s\n",
+ _recFile->path().toLatin1().constData());
+ }
+ else {
+ if (_recFile) {
+ // this file has not been processed and can be
+ // deleted
+ // We should only arrive here if going from a 'record-armed' state
+ // to a non record-armed state. Because otherwise after actually
+ // recording, the _recFile pointer is made into an event,
+ // then _recFile is made zero before this function is called.
+ QString s = _recFile->path();
+ // Added by Tim. p3.3.8
+ delete _recFile;
+ setRecFile(0);
+
+ remove(s.toLatin1().constData());
+ if(debugMsg)
+ printf("AudioNode::setRecordFlag1: remove file %s\n", s.toLatin1().constData());
+ //_recFile = 0;
+ }
+ }
+ return true;
+ }
+bool AudioTrack::prepareRecording()
+{
+ if(_recFile->openWrite())
+ {
+ QMessageBox::critical(NULL, "MusE write error.", "Error creating target wave file\n"
+ "Check your configuration.");
+ return false;
+
+ }
+ return true;
+}
+double AudioTrack::auxSend(int idx) const
+ {
+ if (unsigned(idx) >= _auxSend.size()) {
+ printf("%s auxSend: bad index: %d >= %zd\n",
+ name().toLatin1().constData(), idx, _auxSend.size());
+ return 0.0;
+ }
+ return _auxSend[idx];
+ }
+
+void AudioTrack::setAuxSend(int idx, double v)
+ {
+ if (unsigned(idx) >= _auxSend.size()) {
+ printf("%s setAuxSend: bad index: %d >= %zd\n",
+ name().toLatin1().constData(), idx, _auxSend.size());
+ return;
+ }
+ _auxSend[idx] = v;
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/cliplist/CMakeLists.txt b/attic/muse2-oom/muse2/muse/cliplist/CMakeLists.txt
new file mode 100644
index 00000000..7633b8bb
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/cliplist/CMakeLists.txt
@@ -0,0 +1,76 @@
+#=============================================================================
+# MusE
+# Linux Music Editor
+# $Id:$
+#
+# Copyright (C) 2002-2006 by Werner Schweer and others
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#=============================================================================
+
+##
+## Expand Qt macros in source files
+##
+QT4_WRAP_CPP (cliplist_mocs
+ cliplist.h
+ )
+
+##
+## List of source files to compile
+##
+file (GLOB cliplist_source_files
+ cliplist.cpp
+ )
+
+##
+## Define target
+##
+add_library ( cliplist SHARED
+ ${cliplist_source_files}
+ ${cliplist_mocs}
+ )
+
+##
+## Append to the list of translations
+##
+set (FILES_TO_TRANSLATE
+ ${FILES_TO_TRANSLATE}
+ ${cliplist_source_files}
+ CACHE INTERNAL ""
+ )
+
+##
+## Compilation flags and target name
+##
+set_target_properties( cliplist
+ PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h -fPIC"
+ OUTPUT_NAME muse_cliplist
+ )
+
+##
+## Linkage
+##
+target_link_libraries ( cliplist
+ ${QT_LIBRARIES}
+ awl
+ widgets
+ )
+
+##
+## Install location
+##
+install(TARGETS cliplist
+ DESTINATION ${MusE_MODULES_DIR}
+ )
+
+
diff --git a/attic/muse2-oom/muse2/muse/cliplist/cliplist.cpp b/attic/muse2-oom/muse2/muse/cliplist/cliplist.cpp
new file mode 100644
index 00000000..967c608d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/cliplist/cliplist.cpp
@@ -0,0 +1,260 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: cliplist.cpp,v 1.6.2.3 2008/08/18 00:15:24 terminator356 Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QCloseEvent>
+
+#include "cliplist.h"
+#include "song.h"
+#include "globals.h"
+#include "wave.h"
+#include "xml.h"
+#include "ui_cliplisteditorbase.h"
+
+
+extern int mtcType;
+enum { COL_NAME=0, COL_REFS, COL_POS, COL_LEN };
+
+//---------------------------------------------------------
+// ClipItem
+//---------------------------------------------------------
+
+class ClipItem : public QTreeWidgetItem {
+ SndFileR _wf;
+
+ virtual QString text(int) const;
+
+ public:
+ ClipItem(QTreeWidget*, const SndFileR&);
+ SndFileR* wf() { return &_wf; }
+ };
+
+ClipItem::ClipItem(QTreeWidget* parent, const SndFileR& w)
+ : QTreeWidgetItem(parent), _wf(w)
+ {
+ }
+
+//---------------------------------------------------------
+// samples2smpte
+//---------------------------------------------------------
+
+#if 0
+static QString samples2smpte(int samples)
+ {
+ double time = double(samples) / double(sampleRate);
+ int min = int(time) / 60;
+ int sec = int(time) % 60;
+ double rest = time - (min * 60 + sec);
+ switch(mtcType) {
+ case 0: // 24 frames sec
+ rest *= 24;
+ break;
+ case 1: // 25
+ rest *= 25;
+ break;
+ case 2: // 30 drop frame
+ rest *= 30;
+ break;
+ case 3: // 30 non drop frame
+ rest *= 30;
+ break;
+ }
+ int frame = int(rest);
+ int subframe = int((rest-frame)*100);
+ QString s;
+ s.sprintf("%03d:%02d:%02d:%02d", min, sec, frame, subframe);
+ return s;
+ }
+#endif
+
+//---------------------------------------------------------
+// text
+//---------------------------------------------------------
+
+QString ClipItem::text(int col) const
+ {
+ QString s("");
+ switch(col) {
+ case COL_NAME:
+ s = _wf.name();
+ break;
+ case COL_POS:
+ case COL_LEN:
+ break;
+ case COL_REFS:
+ s.setNum(_wf.getRefCount());
+ break;
+ }
+ return s;
+ }
+
+//---------------------------------------------------------
+// ClipListEdit
+//---------------------------------------------------------
+
+ClipListEdit::ClipListEdit(QWidget* parent)
+ : TopWin(parent, "cliplist", Qt::Window)
+ {
+ //setAttribute(Qt::WA_DeleteOnClose);
+ setWindowTitle(tr("MusE: Clip List Editor"));
+
+ editor = new ClipListEditorBaseWidget;
+ setCentralWidget(editor);
+
+ //editor->view->setColumnAlignment(COL_REFS, Qt::AlignRight);
+
+ QFontMetrics fm(editor->view->font());
+ int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth,0, this); // ddskrjo 0
+ int w = 2 + fm.width('9') * 9 + fm.width(':') * 3 + fw * 4;
+ //editor->view->setColumnAlignment(COL_POS, Qt::AlignRight);
+ editor->view->setColumnWidth(COL_POS, w);
+ //editor->view->setColumnAlignment(COL_LEN, Qt::AlignRight);
+ editor->view->setColumnWidth(COL_LEN, w);
+
+ connect(editor->view, SIGNAL(itemSelectionChanged()), SLOT(clipSelectionChanged()));
+ connect(editor->view, SIGNAL(itemClicked(QTreeWidgetItem*, int)), SLOT(clicked(QTreeWidgetItem*, int)));
+
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+ connect(editor->start, SIGNAL(valueChanged(const Pos&)), SLOT(startChanged(const Pos&)));
+ connect(editor->len, SIGNAL(valueChanged(const Pos&)), SLOT(lenChanged(const Pos&)));
+
+ updateList();
+ }
+
+ClipListEdit::~ClipListEdit()
+{
+
+}
+
+//---------------------------------------------------------
+// updateList
+//---------------------------------------------------------
+
+void ClipListEdit::updateList()
+ {
+ editor->view->clear();
+ for (iSndFile f = SndFile::sndFiles.begin(); f != SndFile::sndFiles.end(); ++f) {
+ new ClipItem(editor->view, *f);
+ }
+ clipSelectionChanged();
+ }
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void ClipListEdit::closeEvent(QCloseEvent* e)
+ {
+ emit deleted((unsigned long)this);
+ e->accept();
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void ClipListEdit::songChanged(int type)
+ {
+ // Is it simply a midi controller value adjustment? Forget it.
+ if(type == SC_MIDI_CONTROLLER)
+ return;
+
+ updateList();
+ }
+
+//---------------------------------------------------------
+// readStatus
+//---------------------------------------------------------
+
+void ClipListEdit::readStatus(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ if (token == Xml::Error || token == Xml::End)
+ break;
+ switch (token) {
+ case Xml::TagStart:
+ if (tag == "topwin")
+ TopWin::readStatus(xml);
+ else
+ xml.unknown("CliplistEdit");
+ break;
+ case Xml::TagEnd:
+ if (tag == "cliplist")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// writeStatus
+//---------------------------------------------------------
+
+void ClipListEdit::writeStatus(int level, Xml& xml) const
+ {
+ xml.tag(level++, "cliplist");
+ TopWin::writeStatus(level, xml);
+ xml.etag(level, "cliplist");
+ }
+
+//---------------------------------------------------------
+// startChanged
+//---------------------------------------------------------
+
+void ClipListEdit::startChanged(const Pos& /*pos*/)//prevent compiler warning: unsused parameter
+ {
+// editor->view->triggerUpdate();
+ }
+
+//---------------------------------------------------------
+// lenChanged
+//---------------------------------------------------------
+
+void ClipListEdit::lenChanged(const Pos& /*pos*/) //prevent compiler warning: unsused parameter
+ {
+// curClip.setLenFrame(pos.frame());
+// editor->view->triggerUpdate();
+ }
+
+//---------------------------------------------------------
+// clipSelectionChanged
+//---------------------------------------------------------
+
+void ClipListEdit::clipSelectionChanged()
+ {
+// ClipItem* item = (ClipItem*)(editor->view->selectedItem());
+
+// if (item == 0) {
+ editor->start->setEnabled(false);
+ editor->len->setEnabled(false);
+ return;
+#if 0
+ }
+ editor->start->setEnabled(true);
+ editor->len->setEnabled(true);
+ Pos pos, len;
+ pos.setType(Pos::FRAMES);
+ len.setType(Pos::FRAMES);
+ pos.setFrame(curClip.spos());
+ len.setFrame(curClip.lenFrame());
+ editor->start->setValue(pos);
+ editor->len->setValue(len);
+#endif
+ }
+
+//---------------------------------------------------------
+// clicked
+//---------------------------------------------------------
+
+void ClipListEdit::clicked(QTreeWidgetItem*, int)
+ {
+// printf("clicked\n");
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/cliplist/cliplist.h b/attic/muse2-oom/muse2/muse/cliplist/cliplist.h
new file mode 100644
index 00000000..d440aec3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/cliplist/cliplist.h
@@ -0,0 +1,67 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: cliplist.h,v 1.3.2.1 2005/12/11 21:29:23 spamatica Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __CLIPLIST_H__
+#define __CLIPLIST_H__
+
+#include "../cobject.h"
+#include "event.h"
+
+#include "ui_cliplisteditorbase.h"
+
+class QCloseEvent;
+class QDialog;
+class QWidget;
+class QTreeWidgetItem;
+
+class Xml;
+class Pos;
+
+//---------------------------------------------------------
+// ClipListEditorBaseWidget
+// Wrapper around Ui::ClipListEditorBase
+//---------------------------------------------------------
+
+class ClipListEditorBaseWidget : public QWidget, public Ui::ClipListEditorBase
+{
+ Q_OBJECT
+
+ public:
+ ClipListEditorBaseWidget(QWidget *parent = 0) : QWidget(parent) { setupUi(this); }
+};
+
+//---------------------------------------------------------
+// ClipListEdit
+//---------------------------------------------------------
+
+class ClipListEdit : public TopWin {
+ Q_OBJECT
+ ClipListEditorBaseWidget* editor;
+
+ virtual void closeEvent(QCloseEvent*);
+ void updateList();
+
+ private slots:
+ void songChanged(int);
+ void startChanged(const Pos&);
+ void lenChanged(const Pos&);
+ void clipSelectionChanged();
+ void clicked(QTreeWidgetItem*, int);
+
+ signals:
+ void deleted(unsigned long);
+
+ public:
+ ClipListEdit(QWidget* parent);
+ ~ClipListEdit();
+ virtual void readStatus(Xml&);
+ virtual void writeStatus(int, Xml&) const;
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/cobject.cpp b/attic/muse2-oom/muse2/muse/cobject.cpp
new file mode 100644
index 00000000..dc257425
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/cobject.cpp
@@ -0,0 +1,68 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: cobject.cpp,v 1.4 2004/02/02 12:10:09 wschweer Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "cobject.h"
+#include "xml.h"
+#include "gui.h"
+
+//---------------------------------------------------------
+// readStatus
+//---------------------------------------------------------
+
+void TopWin::readStatus(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ if (token == Xml::Error || token == Xml::End)
+ break;
+ QString tag = xml.s1();
+ switch (token) {
+ case Xml::TagStart:
+ if (tag == "geometry") {
+ QRect r(readGeometry(xml, tag));
+ resize(r.size());
+ move(r.topLeft());
+ }
+ else
+ xml.unknown("TopWin");
+ break;
+ case Xml::TagEnd:
+ if (tag == "topwin")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// writeStatus
+//---------------------------------------------------------
+
+void TopWin::writeStatus(int level, Xml& xml) const
+ {
+ xml.tag(level++, "topwin");
+ xml.tag(level++, "geometry x=\"%d\" y=\"%d\" w=\"%d\" h=\"%d\"",
+ geometry().x(),
+ geometry().y(),
+ geometry().width(),
+ geometry().height());
+ xml.tag(level--, "/geometry");
+ xml.tag(level, "/topwin");
+ }
+
+TopWin::TopWin(QWidget* parent, const char* name,
+ Qt::WindowFlags f) : QMainWindow(parent, f)
+ {
+ setObjectName(QString(name));
+ //setAttribute(Qt::WA_DeleteOnClose);
+ // Allow multiple rows. Tim.
+ //setDockNestingEnabled(true);
+ setIconSize(ICON_SIZE);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/cobject.h b/attic/muse2-oom/muse2/muse/cobject.h
new file mode 100644
index 00000000..8e21eaf0
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/cobject.h
@@ -0,0 +1,66 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: cobject.h,v 1.3.2.1 2005/12/11 21:29:24 spamatica Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __COBJECT_H__
+#define __COBJECT_H__
+
+#include "config.h"
+
+#include <QMainWindow>
+#include <list>
+
+class Xml;
+
+//---------------------------------------------------------
+// TopWin
+//---------------------------------------------------------
+
+class TopWin : public QMainWindow
+ {
+ Q_OBJECT
+
+ public:
+ virtual void readStatus(Xml&);
+ virtual void writeStatus(int, Xml&) const;
+ TopWin(QWidget* parent=0, const char* name=0,
+ Qt::WindowFlags f = Qt::Window);
+ };
+
+//---------------------------------------------------------
+// Toplevel
+//---------------------------------------------------------
+
+class Toplevel {
+ public:
+ enum ToplevelType { PIANO_ROLL, LISTE, DRUM, MASTER, WAVE,
+ LMASTER, CLIPLIST, MARKER
+#ifdef PATCHBAY
+ , M_PATCHBAY
+#endif /* PATCHBAY */
+ };
+ Toplevel(ToplevelType t, unsigned long obj, TopWin* cobj) {
+ _type = t;
+ _object = obj;
+ _cobject = cobj;
+ }
+ ToplevelType type() const { return _type; }
+ unsigned long object() const { return _object; }
+ TopWin* cobject() const { return _cobject; }
+
+ private:
+ ToplevelType _type;
+ unsigned long _object;
+ TopWin* _cobject;
+ };
+
+typedef std::list <Toplevel> ToplevelList;
+typedef ToplevelList::iterator iToplevel;
+typedef ToplevelList::const_iterator ciToplevel;
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/conf.cpp b/attic/muse2-oom/muse2/muse/conf.cpp
new file mode 100644
index 00000000..328224f3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/conf.cpp
@@ -0,0 +1,1634 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: conf.cpp,v 1.33.2.18 2009/12/01 03:52:40 terminator356 Exp $
+//
+// (C) Copyright 1999-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <sndfile.h>
+#include <errno.h>
+#include <stdio.h>
+
+#include "app.h"
+#include "transport.h"
+#include "icons.h"
+#include "globals.h"
+#include "drumedit.h"
+#include "pianoroll.h"
+#include "master/masteredit.h"
+///#include "transport.h"
+#include "bigtime.h"
+#include "arranger.h"
+#include "conf.h"
+#include "gconfig.h"
+#include "pitchedit.h"
+#include "midiport.h"
+#include "mididev.h"
+#include "driver/audiodev.h"
+#include "driver/jackmidi.h"
+#include "xml.h"
+#include "waveedit.h"
+#include "midi.h"
+#include "midisyncimpl.h"
+#include "midifilterimpl.h"
+#include "midictrl.h"
+#include "ctrlcombo.h"
+#include "genset.h"
+#include "midiitransform.h"
+#include "synth.h"
+#include "audio.h"
+#include "sync.h"
+#include "wave.h"
+#include "midiseq.h"
+#include "amixer.h"
+
+extern void writeMidiTransforms(int level, Xml& xml);
+extern void readMidiTransform(Xml&);
+
+extern void writeMidiInputTransforms(int level, Xml& xml);
+extern void readMidiInputTransform(Xml&);
+
+//---------------------------------------------------------
+// readGeometry
+//---------------------------------------------------------
+
+QRect readGeometry(Xml& xml, const QString& name)
+ {
+ QRect r(0, 0, 50, 50);
+ int val;
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ if (token == Xml::Error || token == Xml::End)
+ break;
+ QString tag = xml.s1();
+ switch (token) {
+ case Xml::TagStart:
+ xml.parse1();
+ break;
+ case Xml::Attribut:
+ val = xml.s2().toInt();
+ if (tag == "x")
+ r.setX(val);
+ else if (tag == "y")
+ r.setY(val);
+ else if (tag == "w")
+ r.setWidth(val);
+ else if (tag == "h")
+ r.setHeight(val);
+ break;
+ case Xml::TagEnd:
+ if (tag == name)
+ return r;
+ default:
+ break;
+ }
+ }
+ return r;
+ }
+
+
+//---------------------------------------------------------
+// readColor
+//---------------------------------------------------------
+
+QColor readColor(Xml& xml)
+ {
+ int val, r=0, g=0, b=0;
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ if (token != Xml::Attribut)
+ break;
+ QString tag = xml.s1();
+ switch (token) {
+ case Xml::Attribut:
+ val = xml.s2().toInt();
+ if (tag == "r")
+ r = val;
+ else if (tag == "g")
+ g = val;
+ else if (tag == "b")
+ b = val;
+ break;
+ default:
+ break;
+ }
+ }
+
+ return QColor(r, g, b);
+ }
+
+//---------------------------------------------------------
+// readController
+//---------------------------------------------------------
+
+static void readController(Xml& xml, int midiPort, int channel)
+ {
+ int id = 0;
+ int val = CTRL_VAL_UNKNOWN;
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ QString tag = xml.s1();
+ switch (token) {
+ case Xml::TagStart:
+ if (tag == "val")
+ val = xml.parseInt();
+ else
+ xml.unknown("controller");
+ break;
+ case Xml::Attribut:
+ if (tag == "id")
+ id = xml.s2().toInt();
+ break;
+ case Xml::TagEnd:
+ if (tag == "controller") {
+ MidiPort* port = &midiPorts[midiPort];
+ //port->addManagedController(channel, id);
+ val = port->limitValToInstrCtlRange(id, val);
+ // The value here will actually be sent to the device LATER, in MidiPort::setMidiDevice()
+ port->setHwCtrlState(channel, id, val);
+ return;
+ }
+ default:
+ return;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// readPortChannel
+//---------------------------------------------------------
+
+static void readPortChannel(Xml& xml, int midiPort)
+ {
+ int idx = 0; //torbenh
+ for (;;) {
+ Xml::Token token = xml.parse();
+ if (token == Xml::Error || token == Xml::End)
+ break;
+ QString tag = xml.s1();
+ switch (token) {
+ case Xml::TagStart:
+ if (tag == "controller") {
+ readController(xml, midiPort, idx);
+ }
+ else
+ xml.unknown("MidiDevice");
+ break;
+ case Xml::Attribut:
+ if (tag == "idx")
+ idx = xml.s2().toInt();
+ break;
+ case Xml::TagEnd:
+ if (tag == "channel")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// readConfigMidiPort
+//---------------------------------------------------------
+
+static void readConfigMidiPort(Xml& xml)
+ {
+ int idx = 0;
+ QString device;
+
+ //QString instrument;
+ // Changed by Tim.
+ //QString instrument("generic midi");
+ // Let's be bold. New users have been confused by generic midi not enabling any patches and controllers.
+ // I had said this may cause HW problems by sending out GM sysEx when really the HW might not be GM.
+ // But this really needs to be done, one way or another.
+ // FIXME: TODO: Make this user-configurable!
+ QString instrument("GM");
+
+ int openFlags = 1;
+ bool thruFlag = false;
+ int dic = 0;
+ int doc = 0;
+ MidiSyncInfo tmpSi;
+ int type = MidiDevice::ALSA_MIDI;
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ if (token == Xml::Error || token == Xml::End)
+ break;
+ QString tag = xml.s1();
+ switch (token) {
+ case Xml::TagStart:
+ if (tag == "name")
+ device = xml.parse1();
+ else if (tag == "type")
+ type = xml.parseInt();
+ else if (tag == "record") { // old
+ bool f = xml.parseInt();
+ if (f)
+ openFlags |= 2;
+ }
+ else if (tag == "openFlags")
+ openFlags = xml.parseInt();
+ else if (tag == "defaultInChans")
+ dic = xml.parseInt();
+ else if (tag == "defaultOutChans")
+ doc = xml.parseInt();
+ else if (tag == "midiSyncInfo")
+ tmpSi.read(xml);
+ else if (tag == "instrument") {
+ instrument = xml.parse1();
+ // Moved by Tim.
+ //midiPorts[idx].setInstrument(
+ // registerMidiInstrument(instrument)
+ // );
+ }
+ else if (tag == "midithru")
+ thruFlag = xml.parseInt(); // obsolete
+ else if (tag == "channel") {
+ readPortChannel(xml, idx);
+ }
+ else
+ xml.unknown("MidiDevice");
+ break;
+ case Xml::Attribut:
+ if (tag == "idx") {
+ idx = xml.s2().toInt();
+ }
+ break;
+ case Xml::TagEnd:
+ if (tag == "midiport") {
+ //if (idx > MIDI_PORTS) {
+ if (idx < 0 || idx >= MIDI_PORTS) {
+ fprintf(stderr, "bad midi port %d (>%d)\n",
+ idx, MIDI_PORTS);
+ idx = 0;
+ }
+
+ MidiDevice* dev = midiDevices.find(device);
+
+ //if(debugMsg && !dev)
+ // fprintf(stderr, "readConfigMidiPort: device not found %s\n", device.toLatin1().constData());
+
+ if(!dev && type == MidiDevice::JACK_MIDI)
+ {
+ if(debugMsg)
+ fprintf(stderr, "readConfigMidiPort: creating jack midi device %s\n", device.toLatin1().constData());
+ //dev = MidiJackDevice::createJackMidiDevice(device, openFlags);
+ dev = MidiJackDevice::createJackMidiDevice(device); // p3.3.55
+ }
+
+ if(debugMsg && !dev)
+ fprintf(stderr, "readConfigMidiPort: device not found %s\n", device.toLatin1().constData());
+
+ MidiPort* mp = &midiPorts[idx];
+
+ mp->setInstrument(registerMidiInstrument(instrument)); // By Tim.
+ mp->setDefaultInChannels(dic);
+ mp->setDefaultOutChannels(doc);
+
+ mp->syncInfo().copyParams(tmpSi);
+ // p3.3.50 Indicate the port was found in the song file, even if no device is assigned to it.
+ mp->setFoundInSongFile(true);
+
+ if (dev) {
+ dev->setOpenFlags(openFlags);
+ midiSeq->msgSetMidiDevice(mp, dev);
+ }
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+/*
+//---------------------------------------------------------
+// readConfigMidiSyncInfo
+//---------------------------------------------------------
+
+static void readConfigMidiSyncInfo(Xml& xml)
+{
+ QString device;
+ int idOut = 127;
+ int idIn = 127;
+ bool sendMC = false;
+ bool sendMMC = false;
+ bool sendMTC = false;
+ bool recMC = false;
+ bool recMMC = false;
+ bool recMTC = false;
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ if (token == Xml::Error || token == Xml::End)
+ break;
+ QString tag = xml.s1();
+ switch (token) {
+ case Xml::TagStart:
+ if (tag == "device")
+ device = xml.parse1();
+ else if (tag == "idOut")
+ idOut = (xml.parseInt());
+ else if (tag == "idIn")
+ idIn = xml.parseInt();
+ else if (tag == "sendMC")
+ sendMC = xml.parseInt();
+ else if (tag == "sendMMC")
+ sendMMC = xml.parseInt();
+ else if (tag == "sendMTC")
+ sendMTC = xml.parseInt();
+ else if (tag == "recMC")
+ recMC = xml.parseInt();
+ else if (tag == "recMMC")
+ recMMC = xml.parseInt();
+ else if (tag == "recMTC")
+ recMTC = xml.parseInt();
+ else
+ xml.unknown("midiSyncInfo");
+ break;
+ case Xml::Attribut:
+ break;
+ case Xml::TagEnd:
+ if(tag == "midiSyncInfo")
+ {
+ MidiDevice* dev = midiDevices.find(device);
+ if(dev)
+ {
+ MidiSyncInfo& si = dev->syncInfo();
+ si.setIdIn(idIn);
+ si.setIdOut(idOut);
+
+ si.setMCIn(recMC);
+ si.setMMCIn(recMMC);
+ si.setMTCIn(recMTC);
+
+ si.setMCOut(sendMC);
+ si.setMMCOut(sendMMC);
+ si.setMTCOut(sendMTC);
+ }
+ else
+ fprintf(stderr, "Read configuration: Sync device: %s not found\n", device.toLatin1().constData());
+
+ return;
+ }
+ default:
+ break;
+ }
+ }
+}
+*/
+
+//---------------------------------------------------------
+// loadConfigMetronom
+//---------------------------------------------------------
+
+static void loadConfigMetronom(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ if (token == Xml::Error || token == Xml::End)
+ break;
+ QString tag = xml.s1();
+ switch (token) {
+ case Xml::TagStart:
+ if (tag == "premeasures")
+ preMeasures = xml.parseInt();
+ else if (tag == "measurepitch")
+ measureClickNote = xml.parseInt();
+ else if (tag == "measurevelo")
+ measureClickVelo = xml.parseInt();
+ else if (tag == "beatpitch")
+ beatClickNote = xml.parseInt();
+ else if (tag == "beatvelo")
+ beatClickVelo = xml.parseInt();
+ else if (tag == "channel")
+ clickChan = xml.parseInt();
+ else if (tag == "port")
+ clickPort = xml.parseInt();
+ else if (tag == "precountEnable")
+ precountEnableFlag = xml.parseInt();
+ else if (tag == "fromMastertrack")
+ precountFromMastertrackFlag = xml.parseInt();
+ else if (tag == "signatureZ")
+ precountSigZ = xml.parseInt();
+ else if (tag == "signatureN")
+ precountSigN = xml.parseInt();
+ else if (tag == "prerecord")
+ precountPrerecord = xml.parseInt();
+ else if (tag == "preroll")
+ precountPreroll = xml.parseInt();
+ else if (tag == "midiClickEnable")
+ midiClickFlag = xml.parseInt();
+ else if (tag == "audioClickEnable")
+ audioClickFlag = xml.parseInt();
+ else if (tag == "audioClickVolume")
+ audioClickVolume = xml.parseFloat();
+ else
+ xml.unknown("Metronome");
+ break;
+ case Xml::TagEnd:
+ if (tag == "metronom")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// readSeqConfiguration
+//---------------------------------------------------------
+
+static void readSeqConfiguration(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ if (token == Xml::Error || token == Xml::End)
+ break;
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::TagStart:
+ if (tag == "metronom")
+ loadConfigMetronom(xml);
+ else if (tag == "midiport")
+ readConfigMidiPort(xml);
+ else if (tag == "rcStop")
+ rcStopNote = xml.parseInt();
+ else if (tag == "rcEnable")
+ rcEnable = xml.parseInt();
+ else if (tag == "rcRecord")
+ rcRecordNote = xml.parseInt();
+ else if (tag == "rcGotoLeft")
+ rcGotoLeftMarkNote = xml.parseInt();
+ else if (tag == "rcPlay")
+ rcPlayNote = xml.parseInt();
+ else
+ xml.unknown("Seq");
+ break;
+ case Xml::TagEnd:
+ if (tag == "sequencer") {
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// readConfiguration
+//---------------------------------------------------------
+
+void readConfiguration(Xml& xml, bool readOnlySequencer)
+ {
+ int mixers = 0;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ if (token == Xml::Error || token == Xml::End)
+ break;
+ QString tag = xml.s1();
+ switch (token) {
+ case Xml::TagStart:
+ /* the reading of configuration is split in two; read
+ "sequencer" and read ALL. The reason is that it is
+ possible to load a song without configuration. In
+ this case the <configuration> chapter in the song
+ file should be skipped. However the sub part
+ <sequencer> contains elements that are necessary
+ to preserve composition consistency. Mainly
+ midiport configuration and VOLUME.
+ */
+ if (tag == "sequencer") {
+ readSeqConfiguration(xml);
+ break;
+ }
+ else if (readOnlySequencer) {
+ xml.skip(tag);
+ break;
+ }
+
+ if (tag == "theme")
+ config.style = xml.parse1();
+ else if (tag == "styleSheetFile")
+ config.styleSheetFile = xml.parse1();
+ else if (tag == "useOldStyleStopShortCut")
+ config.useOldStyleStopShortCut = xml.parseInt();
+ else if (tag == "moveArmedCheckBox")
+ config.moveArmedCheckBox = xml.parseInt();
+ else if (tag == "externalWavEditor")
+ config.externalWavEditor = xml.parse1();
+ else if (tag == "font0")
+ config.fonts[0].fromString(xml.parse1());
+ else if (tag == "font1")
+ config.fonts[1].fromString(xml.parse1());
+ else if (tag == "font2")
+ config.fonts[2].fromString(xml.parse1());
+ else if (tag == "font3")
+ config.fonts[3].fromString(xml.parse1());
+ else if (tag == "font4")
+ config.fonts[4].fromString(xml.parse1());
+ else if (tag == "font5")
+ config.fonts[5].fromString(xml.parse1());
+ else if (tag == "font6")
+ config.fonts[6].fromString(xml.parse1());
+ else if (tag == "globalAlphaBlend")
+ config.globalAlphaBlend = xml.parseInt();
+ else if (tag == "palette0")
+ config.palette[0] = readColor(xml);
+ else if (tag == "palette1")
+ config.palette[1] = readColor(xml);
+ else if (tag == "palette2")
+ config.palette[2] = readColor(xml);
+ else if (tag == "palette3")
+ config.palette[3] = readColor(xml);
+ else if (tag == "palette4")
+ config.palette[4] = readColor(xml);
+ else if (tag == "palette5")
+ config.palette[5] = readColor(xml);
+ else if (tag == "palette6")
+ config.palette[6] = readColor(xml);
+ else if (tag == "palette7")
+ config.palette[7] = readColor(xml);
+ else if (tag == "palette8")
+ config.palette[8] = readColor(xml);
+ else if (tag == "palette9")
+ config.palette[9] = readColor(xml);
+ else if (tag == "palette10")
+ config.palette[10] = readColor(xml);
+ else if (tag == "palette11")
+ config.palette[11] = readColor(xml);
+ else if (tag == "palette12")
+ config.palette[12] = readColor(xml);
+ else if (tag == "palette13")
+ config.palette[13] = readColor(xml);
+ else if (tag == "palette14")
+ config.palette[14] = readColor(xml);
+ else if (tag == "palette15")
+ config.palette[15] = readColor(xml);
+ else if (tag == "palette16")
+ config.palette[16] = readColor(xml);
+ else if (tag == "partColor0")
+ config.partColors[0] = readColor(xml);
+ else if (tag == "partColor1")
+ config.partColors[1] = readColor(xml);
+ else if (tag == "partColor2")
+ config.partColors[2] = readColor(xml);
+ else if (tag == "partColor3")
+ config.partColors[3] = readColor(xml);
+ else if (tag == "partColor4")
+ config.partColors[4] = readColor(xml);
+ else if (tag == "partColor5")
+ config.partColors[5] = readColor(xml);
+ else if (tag == "partColor6")
+ config.partColors[6] = readColor(xml);
+ else if (tag == "partColor7")
+ config.partColors[7] = readColor(xml);
+ else if (tag == "partColor8")
+ config.partColors[8] = readColor(xml);
+ else if (tag == "partColor9")
+ config.partColors[9] = readColor(xml);
+ else if (tag == "partColor10")
+ config.partColors[10] = readColor(xml);
+ else if (tag == "partColor11")
+ config.partColors[11] = readColor(xml);
+ else if (tag == "partColor12")
+ config.partColors[12] = readColor(xml);
+ else if (tag == "partColor13")
+ config.partColors[13] = readColor(xml);
+ else if (tag == "partColor14")
+ config.partColors[14] = readColor(xml);
+ else if (tag == "partColor15")
+ config.partColors[15] = readColor(xml);
+ else if (tag == "partColor16")
+ config.partColors[16] = readColor(xml);
+ else if (tag == "partColor17")
+ config.partColors[17] = readColor(xml);
+
+ else if (tag == "partColorName0")
+ config.partColorNames[0] = xml.parse1();
+ else if (tag == "partColorName1")
+ config.partColorNames[1] = xml.parse1();
+ else if (tag == "partColorName2")
+ config.partColorNames[2] = xml.parse1();
+ else if (tag == "partColorName3")
+ config.partColorNames[3] = xml.parse1();
+ else if (tag == "partColorName4")
+ config.partColorNames[4] = xml.parse1();
+ else if (tag == "partColorName5")
+ config.partColorNames[5] = xml.parse1();
+ else if (tag == "partColorName6")
+ config.partColorNames[6] = xml.parse1();
+ else if (tag == "partColorName7")
+ config.partColorNames[7] = xml.parse1();
+ else if (tag == "partColorName8")
+ config.partColorNames[8] = xml.parse1();
+ else if (tag == "partColorName9")
+ config.partColorNames[9] = xml.parse1();
+ else if (tag == "partColorName10")
+ config.partColorNames[10] = xml.parse1();
+ else if (tag == "partColorName11")
+ config.partColorNames[11] = xml.parse1();
+ else if (tag == "partColorName12")
+ config.partColorNames[12] = xml.parse1();
+ else if (tag == "partColorName13")
+ config.partColorNames[13] = xml.parse1();
+ else if (tag == "partColorName14")
+ config.partColorNames[14] = xml.parse1();
+ else if (tag == "partColorName15")
+ config.partColorNames[15] = xml.parse1();
+ else if (tag == "partColorName16")
+ config.partColorNames[16] = xml.parse1();
+ else if (tag == "partColorName17")
+ config.partColorNames[17] = xml.parse1();
+
+ else if (tag == "partCanvasBg")
+ config.partCanvasBg = readColor(xml);
+ else if (tag == "trackBg")
+ config.trackBg = readColor(xml);
+ else if (tag == "selectTrackBg")
+ config.selectTrackBg = readColor(xml);
+ else if (tag == "selectTrackFg")
+ config.selectTrackFg = readColor(xml);
+
+ else if (tag == "mixerBg")
+ config.mixerBg = readColor(xml);
+ else if (tag == "midiTrackLabelBg")
+ config.midiTrackLabelBg = readColor(xml);
+ else if (tag == "drumTrackLabelBg")
+ config.drumTrackLabelBg = readColor(xml);
+ else if (tag == "waveTrackLabelBg")
+ config.waveTrackLabelBg = readColor(xml);
+ else if (tag == "outputTrackLabelBg")
+ config.outputTrackLabelBg = readColor(xml);
+ else if (tag == "inputTrackLabelBg")
+ config.inputTrackLabelBg = readColor(xml);
+ else if (tag == "groupTrackLabelBg")
+ config.groupTrackLabelBg = readColor(xml);
+ else if (tag == "auxTrackLabelBg")
+ config.auxTrackLabelBg = readColor(xml);
+ else if (tag == "synthTrackLabelBg")
+ config.synthTrackLabelBg = readColor(xml);
+
+ else if (tag == "midiTrackBg")
+ config.midiTrackBg = readColor(xml);
+ else if (tag == "ctrlGraphFg")
+ config.ctrlGraphFg = readColor(xml);
+ else if (tag == "drumTrackBg")
+ config.drumTrackBg = readColor(xml);
+ else if (tag == "waveTrackBg")
+ config.waveTrackBg = readColor(xml);
+ else if (tag == "outputTrackBg")
+ config.outputTrackBg = readColor(xml);
+ else if (tag == "inputTrackBg")
+ config.inputTrackBg = readColor(xml);
+ else if (tag == "groupTrackBg")
+ config.groupTrackBg = readColor(xml);
+ else if (tag == "auxTrackBg")
+ config.auxTrackBg = readColor(xml);
+ else if (tag == "synthTrackBg")
+ config.synthTrackBg = readColor(xml);
+
+ else if (tag == "extendedMidi")
+ config.extendedMidi = xml.parseInt();
+ else if (tag == "midiExportDivision")
+ config.midiDivision = xml.parseInt();
+ else if (tag == "copyright")
+ config.copyright = xml.parse1();
+ else if (tag == "smfFormat")
+ config.smfFormat = xml.parseInt();
+ else if (tag == "exp2ByteTimeSigs")
+ config.exp2ByteTimeSigs = xml.parseInt();
+ else if (tag == "expOptimNoteOffs")
+ config.expOptimNoteOffs = xml.parseInt();
+ else if (tag == "importMidiSplitParts")
+ config.importMidiSplitParts = xml.parseInt();
+ else if (tag == "midiInputDevice")
+ midiInputPorts = xml.parseInt();
+ else if (tag == "midiInputChannel")
+ midiInputChannel = xml.parseInt();
+ else if (tag == "midiRecordType")
+ midiRecordType = xml.parseInt();
+ else if (tag == "midiThruType")
+ midiThruType = xml.parseInt();
+ else if (tag == "midiFilterCtrl1")
+ midiFilterCtrl1 = xml.parseInt();
+ else if (tag == "midiFilterCtrl2")
+ midiFilterCtrl2 = xml.parseInt();
+ else if (tag == "midiFilterCtrl3")
+ midiFilterCtrl3 = xml.parseInt();
+ else if (tag == "midiFilterCtrl4")
+ midiFilterCtrl4 = xml.parseInt();
+ else if (tag == "bigtimeVisible")
+ config.bigTimeVisible = xml.parseInt();
+ else if (tag == "transportVisible")
+ config.transportVisible = xml.parseInt();
+ else if (tag == "markerVisible")
+ config.markerVisible = xml.parseInt();
+
+ else if (tag == "mixerVisible")
+ // config.mixerVisible = xml.parseInt(); // Obsolete
+ xml.skip(tag);
+ else if (tag == "mixer1Visible")
+ config.mixer1Visible = xml.parseInt();
+ else if (tag == "mixer2Visible")
+ config.mixer2Visible = xml.parseInt();
+
+ else if (tag == "showSplashScreen")
+ config.showSplashScreen = xml.parseInt();
+ else if (tag == "canvasShowPartType")
+ config.canvasShowPartType = xml.parseInt();
+ else if (tag == "canvasShowPartEvent")
+ config.canvasShowPartEvent = xml.parseInt();
+ else if (tag == "canvasShowGrid")
+ config.canvasShowGrid = xml.parseInt();
+ else if (tag == "canvasBgPixmap")
+ config.canvasBgPixmap = xml.parse1();
+ else if (tag == "canvasCustomBgList")
+ config.canvasCustomBgList = xml.parse1().split(";", QString::SkipEmptyParts);
+ else if (tag == "geometryMain")
+ config.geometryMain = readGeometry(xml, tag);
+ else if (tag == "geometryTransport")
+ config.geometryTransport = readGeometry(xml, tag);
+ else if (tag == "geometryBigTime")
+ config.geometryBigTime = readGeometry(xml, tag);
+ else if (tag == "geometryPianoroll")
+ config.geometryPianoroll = readGeometry(xml, tag);
+ else if (tag == "geometryDrumedit")
+ config.geometryDrumedit = readGeometry(xml, tag);
+
+ else if (tag == "geometryMixer")
+ // config.geometryMixer = readGeometry(xml, tag); // Obsolete
+ xml.skip(tag);
+ //else if (tag == "mixer1")
+ // config.mixer1.read(xml);
+ //else if (tag == "mixer2")
+ // config.mixer2.read(xml);
+ else if (tag == "Mixer")
+ {
+ if(mixers == 0)
+ config.mixer1.read(xml);
+ else
+ config.mixer2.read(xml);
+ ++mixers;
+ }
+
+ else if (tag == "bigtimeForegroundcolor")
+ config.bigTimeForegroundColor = readColor(xml);
+ else if (tag == "bigtimeBackgroundcolor")
+ config.bigTimeBackgroundColor = readColor(xml);
+ else if (tag == "transportHandleColor")
+ config.transportHandleColor = readColor(xml);
+ else if (tag == "waveEditBackgroundColor")
+ config.waveEditBackgroundColor = readColor(xml);
+ else if (tag == "txDeviceId")
+ //txDeviceId = xml.parseInt();
+ xml.parseInt();
+ else if (tag == "rxDeviceId")
+ //rxDeviceId = xml.parseInt();
+ xml.parseInt();
+ else if (tag == "txSyncPort")
+ //txSyncPort= xml.parseInt();
+ xml.parseInt();
+ else if (tag == "rxSyncPort")
+ //rxSyncPort= xml.parseInt();
+ xml.parseInt();
+ else if (tag == "mtctype")
+ mtcType= xml.parseInt();
+ else if (tag == "sendClockDelay")
+ syncSendFirstClockDelay = xml.parseUInt();
+ else if (tag == "extSync")
+ extSyncFlag.setValue(xml.parseInt());
+ else if (tag == "useJackTransport")
+ {
+ useJackTransport.setValue(xml.parseInt());
+ }
+ else if (tag == "jackTransportMaster")
+ {
+ jackTransportMaster = xml.parseInt();
+ if(audioDevice)
+ audioDevice->setMaster(jackTransportMaster);
+ }
+ else if (tag == "syncgentype") {
+ // for compatibility
+ //int syncGenType= xml.parseInt();
+ //genMTCSync = syncGenType == 1;
+ //genMCSync = syncGenType == 2;
+ xml.parseInt();
+ }
+ else if (tag == "genMTCSync")
+ //genMTCSync = xml.parseInt();
+ xml.parseInt();
+ else if (tag == "genMCSync")
+ //genMCSync = xml.parseInt();
+ xml.parseInt();
+ else if (tag == "genMMC")
+ //genMMC = xml.parseInt();
+ xml.parseInt();
+ else if (tag == "acceptMTC")
+ //acceptMTC = xml.parseInt();
+ xml.parseInt();
+ else if (tag == "acceptMMC")
+ //acceptMMC = xml.parseInt();
+ xml.parseInt();
+ else if (tag == "acceptMC")
+ //acceptMC = xml.parseInt();
+ xml.parseInt();
+ else if (tag == "mtcoffset") {
+ QString qs(xml.parse1());
+ QByteArray ba = qs.toLatin1();
+ const char* str = ba.constData();
+ int h, m, s, f, sf;
+ sscanf(str, "%d:%d:%d:%d:%d", &h, &m, &s, &f, &sf);
+ mtcOffset = MTC(h, m, s, f, sf);
+ }
+ //else if (tag == "midiSyncInfo")
+ // readConfigMidiSyncInfo(xml);
+ else if (tag == "arranger") {
+ if (muse && muse->arranger)
+ muse->arranger->readStatus(xml);
+ else
+ xml.skip(tag);
+ }
+ else if (tag == "drumedit")
+ DrumEdit::readConfiguration(xml);
+ else if (tag == "pianoroll")
+ PianoRoll::readConfiguration(xml);
+ else if (tag == "masteredit")
+ MasterEdit::readConfiguration(xml);
+ else if (tag == "waveedit")
+ WaveEdit::readConfiguration(xml);
+ else if (tag == "shortcuts")
+ readShortCuts(xml);
+ else if (tag == "division")
+ config.division = xml.parseInt();
+ else if (tag == "guiDivision")
+ config.guiDivision = xml.parseInt();
+ else if (tag == "samplerate")
+ xml.parseInt();
+ else if (tag == "segmentsize")
+ xml.parseInt();
+ else if (tag == "segmentcount")
+ xml.parseInt();
+ else if (tag == "rtcTicks")
+ config.rtcTicks = xml.parseInt();
+ else if (tag == "minMeter")
+ config.minMeter = xml.parseInt();
+ else if (tag == "minSlider")
+ config.minSlider = xml.parseDouble();
+ else if (tag == "freewheelMode")
+ config.freewheelMode = xml.parseInt();
+ else if (tag == "denormalProtection")
+ config.useDenormalBias = xml.parseInt();
+ else if (tag == "didYouKnow")
+ config.showDidYouKnow = xml.parseInt();
+ else if (tag == "outputLimiter")
+ config.useOutputLimiter = xml.parseInt();
+ else if (tag == "vstInPlace")
+ config.vstInPlace = xml.parseInt();
+ else if (tag == "dummyAudioSampleRate")
+ config.dummyAudioSampleRate = xml.parseInt();
+ else if (tag == "dummyAudioBufSize")
+ config.dummyAudioBufSize = xml.parseInt();
+ else if (tag == "guiRefresh")
+ config.guiRefresh = xml.parseInt();
+ else if (tag == "userInstrumentsDir")
+ config.userInstrumentsDir = xml.parse1();
+ else if (tag == "midiTransform")
+ readMidiTransform(xml);
+ else if (tag == "midiInputTransform")
+ readMidiInputTransform(xml);
+ else if (tag == "startMode")
+ config.startMode = xml.parseInt();
+ else if (tag == "startSong")
+ config.startSong = xml.parse1();
+ else if (tag == "projectBaseFolder")
+ config.projectBaseFolder = xml.parse1();
+ else if (tag == "projectStoreInFolder")
+ config.projectStoreInFolder = xml.parseInt();
+ else
+ xml.unknown("configuration");
+ break;
+ case Xml::Text:
+ printf("text <%s>\n", xml.s1().toLatin1().constData());
+ break;
+ case Xml::Attribut:
+ if (readOnlySequencer)
+ break;
+ if (tag == "version") {
+ int major = xml.s2().section('.', 0, 0).toInt();
+ int minor = xml.s2().section('.', 1, 1).toInt();
+ xml.setVersion(major, minor);
+ }
+ break;
+ case Xml::TagEnd:
+ if (tag == "configuration") {
+ return;
+ }
+ break;
+ case Xml::Proc:
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// readConfiguration
+//---------------------------------------------------------
+
+bool readConfiguration()
+ {
+ FILE* f = fopen(configName.toLatin1().constData(), "r");
+ if (f == 0) {
+ if (debugMsg || debugMode)
+ fprintf(stderr, "NO Config File <%s> found\n", configName.toLatin1().constData());
+
+ if (config.userInstrumentsDir.isEmpty())
+ config.userInstrumentsDir = configPath + "/instruments";
+ return true;
+ }
+ Xml xml(f);
+ bool skipmode = true;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ fclose(f);
+ return true;
+ case Xml::TagStart:
+ if (skipmode && tag == "muse")
+ skipmode = false;
+ else if (skipmode)
+ break;
+ else if (tag == "configuration")
+ readConfiguration(xml,false);
+ else
+ xml.unknown("muse config");
+ break;
+ case Xml::Attribut:
+ if (tag == "version") {
+ int major = xml.s2().section('.', 0, 0).toInt();
+ int minor = xml.s2().section('.', 1, 1).toInt();
+ xml.setVersion(major, minor);
+ }
+ break;
+ case Xml::TagEnd:
+ if (!skipmode && tag == "muse") {
+ fclose(f);
+ return false;
+ }
+ default:
+ break;
+ }
+ }
+ fclose(f);
+ return true;
+ }
+
+//---------------------------------------------------------
+// writeSeqConfiguration
+//---------------------------------------------------------
+
+static void writeSeqConfiguration(int level, Xml& xml, bool writePortInfo)
+ {
+ xml.tag(level++, "sequencer");
+
+ xml.tag(level++, "metronom");
+ xml.intTag(level, "premeasures", preMeasures);
+ xml.intTag(level, "measurepitch", measureClickNote);
+ xml.intTag(level, "measurevelo", measureClickVelo);
+ xml.intTag(level, "beatpitch", beatClickNote);
+ xml.intTag(level, "beatvelo", beatClickVelo);
+ xml.intTag(level, "channel", clickChan);
+ xml.intTag(level, "port", clickPort);
+
+ xml.intTag(level, "precountEnable", precountEnableFlag);
+ xml.intTag(level, "fromMastertrack", precountFromMastertrackFlag);
+ xml.intTag(level, "signatureZ", precountSigZ);
+ xml.intTag(level, "signatureN", precountSigN);
+ xml.intTag(level, "prerecord", precountPrerecord);
+ xml.intTag(level, "preroll", precountPreroll);
+ xml.intTag(level, "midiClickEnable", midiClickFlag);
+ xml.intTag(level, "audioClickEnable", audioClickFlag);
+ xml.floatTag(level, "audioClickVolume", audioClickVolume);
+ xml.tag(level--, "/metronom");
+
+ xml.intTag(level, "rcEnable", rcEnable);
+ xml.intTag(level, "rcStop", rcStopNote);
+ xml.intTag(level, "rcRecord", rcRecordNote);
+ xml.intTag(level, "rcGotoLeft", rcGotoLeftMarkNote);
+ xml.intTag(level, "rcPlay", rcPlayNote);
+
+ if (writePortInfo) {
+ //
+ // write information about all midi ports, their assigned
+ // instruments and all managed midi controllers
+ //
+ for (int i = 0; i < MIDI_PORTS; ++i) {
+ bool used = false;
+ MidiPort* mport = &midiPorts[i];
+ // Route check by Tim. Port can now be used for routing even if no device.
+ // Also, check for other non-defaults and save port, to preserve settings even if no device.
+ if(!mport->noInRoute() || !mport->noOutRoute() ||
+ mport->defaultInChannels() || mport->defaultOutChannels() ||
+ (!mport->instrument()->iname().isEmpty() && mport->instrument()->iname() != "GM") ||
+ !mport->syncInfo().isDefault())
+ used = true;
+ else
+ {
+ MidiTrackList* tl = song->midis();
+ for (iMidiTrack it = tl->begin(); it != tl->end(); ++it)
+ {
+ MidiTrack* t = *it;
+ if (t->outPort() == i)
+ {
+ used = true;
+ break;
+ }
+ }
+ }
+
+ MidiDevice* dev = mport->device();
+ if (!used && !dev)
+ continue;
+ xml.tag(level++, "midiport idx=\"%d\"", i);
+
+ if(mport->defaultInChannels())
+ xml.intTag(level, "defaultInChans", mport->defaultInChannels());
+ if(mport->defaultOutChannels())
+ xml.intTag(level, "defaultOutChans", mport->defaultOutChannels());
+
+ if(!mport->instrument()->iname().isEmpty() && // Tim.
+ (mport->instrument()->iname() != "GM")) // FIXME: TODO: Make this user configurable.
+ xml.strTag(level, "instrument", mport->instrument()->iname());
+
+ if (dev) {
+ xml.strTag(level, "name", dev->name());
+
+ // p3.3.38
+ //if(dynamic_cast<MidiJackDevice*>(dev))
+ if(dev->deviceType() != MidiDevice::ALSA_MIDI)
+ //xml.intTag(level, "type", MidiDevice::JACK_MIDI);
+ xml.intTag(level, "type", dev->deviceType());
+
+ // Changed by T356. "record" is old and by mistake written as rwFlags here.
+ // openFlags was read before, but never written here.
+ //xml.intTag(level, "record", dev->rwFlags() & 0x2 ? 1 : 0);
+ xml.intTag(level, "openFlags", dev->openFlags());
+ }
+ mport->syncInfo().write(level, xml);
+ // write out registered controller for all channels
+ MidiCtrlValListList* vll = mport->controller();
+ for (int k = 0; k < MIDI_CHANNELS; ++k) {
+ int min = k << 24;
+ int max = min + 0x100000;
+ xml.tag(level++, "channel idx=\"%d\"", k);
+ iMidiCtrlValList s = vll->lower_bound(min);
+ iMidiCtrlValList e = vll->lower_bound(max);
+ if (s != e) {
+ for (iMidiCtrlValList i = s; i != e; ++i) {
+ xml.tag(level++, "controller id=\"%d\"", i->second->num());
+ if (i->second->hwVal() != CTRL_VAL_UNKNOWN)
+ xml.intTag(level, "val", i->second->hwVal());
+ xml.etag(level--, "controller");
+ }
+ }
+ xml.etag(level--, "channel");
+ }
+ xml.etag(level--, "midiport");
+ }
+ }
+ xml.tag(level, "/sequencer");
+ }
+
+//---------------------------------------------------------
+// writeGlobalConfiguration
+//---------------------------------------------------------
+
+void MusE::writeGlobalConfiguration() const
+ {
+ FILE* f = fopen(configName.toLatin1().constData(), "w");
+ if (f == 0) {
+ printf("save configuration to <%s> failed: %s\n",
+ configName.toLatin1().constData(), strerror(errno));
+ return;
+ }
+ Xml xml(f);
+ xml.header();
+ xml.tag(0, "muse version=\"2.0\"");
+ writeGlobalConfiguration(1, xml);
+ xml.tag(1, "/muse");
+ fclose(f);
+ }
+
+void MusE::writeGlobalConfiguration(int level, Xml& xml) const
+ {
+ xml.tag(level++, "configuration");
+
+ xml.intTag(level, "division", config.division);
+ xml.intTag(level, "rtcTicks", config.rtcTicks);
+ xml.intTag(level, "minMeter", config.minMeter);
+ xml.doubleTag(level, "minSlider", config.minSlider);
+ xml.intTag(level, "freewheelMode", config.freewheelMode);
+ xml.intTag(level, "denormalProtection", config.useDenormalBias);
+ xml.intTag(level, "didYouKnow", config.showDidYouKnow);
+ xml.intTag(level, "outputLimiter", config.useOutputLimiter);
+ xml.intTag(level, "vstInPlace", config.vstInPlace);
+ xml.intTag(level, "dummyAudioBufSize", config.dummyAudioBufSize);
+ xml.intTag(level, "dummyAudioSampleRate", config.dummyAudioSampleRate);
+
+ xml.intTag(level, "guiRefresh", config.guiRefresh);
+ xml.strTag(level, "userInstrumentsDir", config.userInstrumentsDir);
+ // Removed by Orcan. 20101220
+ //xml.strTag(level, "helpBrowser", config.helpBrowser);
+ xml.intTag(level, "extendedMidi", config.extendedMidi);
+ xml.intTag(level, "midiExportDivision", config.midiDivision);
+ xml.intTag(level, "guiDivision", config.guiDivision);
+ xml.strTag(level, "copyright", config.copyright);
+ xml.intTag(level, "smfFormat", config.smfFormat);
+ xml.intTag(level, "exp2ByteTimeSigs", config.exp2ByteTimeSigs);
+ xml.intTag(level, "expOptimNoteOffs", config.expOptimNoteOffs);
+ xml.intTag(level, "importMidiSplitParts", config.importMidiSplitParts);
+ xml.intTag(level, "startMode", config.startMode);
+ xml.strTag(level, "startSong", config.startSong);
+ xml.strTag(level, "projectBaseFolder", config.projectBaseFolder);
+ xml.intTag(level, "projectStoreInFolder", config.projectStoreInFolder);
+ xml.intTag(level, "midiInputDevice", midiInputPorts);
+ xml.intTag(level, "midiInputChannel", midiInputChannel);
+ xml.intTag(level, "midiRecordType", midiRecordType);
+ xml.intTag(level, "midiThruType", midiThruType);
+ xml.intTag(level, "midiFilterCtrl1", midiFilterCtrl1);
+ xml.intTag(level, "midiFilterCtrl2", midiFilterCtrl2);
+ xml.intTag(level, "midiFilterCtrl3", midiFilterCtrl3);
+ xml.intTag(level, "midiFilterCtrl4", midiFilterCtrl4);
+ // Removed by Tim. p3.3.6
+
+ //xml.intTag(level, "txDeviceId", txDeviceId);
+ //xml.intTag(level, "rxDeviceId", rxDeviceId);
+ xml.strTag(level, "theme", config.style);
+ xml.strTag(level, "styleSheetFile", config.styleSheetFile);
+ xml.strTag(level, "externalWavEditor", config.externalWavEditor);
+ xml.intTag(level, "useOldStyleStopShortCut", config.useOldStyleStopShortCut);
+ xml.intTag(level, "moveArmedCheckBox", config.moveArmedCheckBox);
+
+ //for (int i = 0; i < 6; ++i) {
+ for (int i = 0; i < NUM_FONTS; ++i) {
+ char buffer[32];
+ sprintf(buffer, "font%d", i);
+ xml.strTag(level, buffer, config.fonts[i].toString());
+ }
+
+ xml.intTag(level, "globalAlphaBlend", config.globalAlphaBlend);
+
+ for (int i = 0; i < 16; ++i) {
+ char buffer[32];
+ sprintf(buffer, "palette%d", i);
+ xml.colorTag(level, buffer, config.palette[i]);
+ }
+
+ for (int i = 0; i < NUM_PARTCOLORS; ++i) {
+ char buffer[32];
+ sprintf(buffer, "partColor%d", i);
+ xml.colorTag(level, buffer, config.partColors[i]);
+ }
+
+ for (int i = 0; i < NUM_PARTCOLORS; ++i) {
+ char buffer[32];
+ sprintf(buffer, "partColorName%d", i);
+ xml.strTag(level, buffer, config.partColorNames[i]);
+ }
+
+ xml.colorTag(level, "partCanvasBg", config.partCanvasBg);
+ xml.colorTag(level, "trackBg", config.trackBg);
+ xml.colorTag(level, "selectTrackBg", config.selectTrackBg);
+ xml.colorTag(level, "selectTrackFg", config.selectTrackFg);
+
+ xml.colorTag(level, "mixerBg", config.mixerBg);
+ xml.colorTag(level, "midiTrackLabelBg", config.midiTrackLabelBg);
+ xml.colorTag(level, "drumTrackLabelBg", config.drumTrackLabelBg);
+ xml.colorTag(level, "waveTrackLabelBg", config.waveTrackLabelBg);
+ xml.colorTag(level, "outputTrackLabelBg", config.outputTrackLabelBg);
+ xml.colorTag(level, "inputTrackLabelBg", config.inputTrackLabelBg);
+ xml.colorTag(level, "groupTrackLabelBg", config.groupTrackLabelBg);
+ xml.colorTag(level, "auxTrackLabelBg", config.auxTrackLabelBg);
+ xml.colorTag(level, "synthTrackLabelBg", config.synthTrackLabelBg);
+
+ xml.colorTag(level, "midiTrackBg", config.midiTrackBg);
+ xml.colorTag(level, "ctrlGraphFg", config.ctrlGraphFg);
+ xml.colorTag(level, "drumTrackBg", config.drumTrackBg);
+ xml.colorTag(level, "waveTrackBg", config.waveTrackBg);
+ xml.colorTag(level, "outputTrackBg", config.outputTrackBg);
+ xml.colorTag(level, "inputTrackBg", config.inputTrackBg);
+ xml.colorTag(level, "groupTrackBg", config.groupTrackBg);
+ xml.colorTag(level, "auxTrackBg", config.auxTrackBg);
+ xml.colorTag(level, "synthTrackBg", config.synthTrackBg);
+
+ // Changed by Tim. p3.3.6
+
+ //xml.intTag(level, "txSyncPort", txSyncPort);
+ /*
+ // To keep old muse versions happy...
+ bool mcsync = mmc = mtc = false;
+ for(int sp = 0; sp < MIDI_PORTS; ++sp)
+ {
+ MidiSyncTxPort* txPort = &midiSyncTxPorts[sp];
+ if(txPort->doMCSync() || txPort->doMMC() || txPort->doMTC())
+ {
+ if(txPort->doMCSync())
+ mcsync = true;
+ if(txPort->doMMC())
+ mmc = true;
+ if(txPort->doMTC())
+ mtc = true;
+ xml.intTag(level, "txSyncPort", sp);
+ break;
+ }
+ }
+ */
+
+ // Added by Tim. p3.3.6
+
+ //xml.tag(level++, "midiSyncInfo");
+ //for(iMidiDevice id = midiDevices.begin(); id != midiDevices.end(); ++id)
+ //{
+ // MidiDevice* md = *id;
+ // (*id)->syncInfo().write(level, xml, md);
+ //}
+ //xml.etag(level, "midiSyncInfo");
+
+ //xml.intTag(level, "rxSyncPort", rxSyncPort);
+ xml.intTag(level, "mtctype", mtcType);
+ xml.nput(level, "<mtcoffset>%02d:%02d:%02d:%02d:%02d</mtcoffset>\n",
+ mtcOffset.h(), mtcOffset.m(), mtcOffset.s(),
+ mtcOffset.f(), mtcOffset.sf());
+ //xml.uintTag(level, "sendClockDelay", syncSendFirstClockDelay);
+ //xml.intTag(level, "useJackTransport", useJackTransport);
+ //xml.intTag(level, "jackTransportMaster", jackTransportMaster);
+ extSyncFlag.save(level, xml);
+
+// xml.intTag(level, "genMTCSync", genMTCSync);
+// xml.intTag(level, "genMCSync", genMCSync);
+// xml.intTag(level, "genMMC", genMMC);
+// xml.intTag(level, "acceptMTC", acceptMTC);
+// xml.intTag(level, "acceptMMC", acceptMMC);
+// xml.intTag(level, "acceptMC", acceptMC);
+
+ xml.qrectTag(level, "geometryMain", config.geometryMain);
+ xml.qrectTag(level, "geometryTransport", config.geometryTransport);
+ xml.qrectTag(level, "geometryBigTime", config.geometryBigTime);
+ xml.qrectTag(level, "geometryPianoroll", config.geometryPianoroll);
+ xml.qrectTag(level, "geometryDrumedit", config.geometryDrumedit);
+ //xml.qrectTag(level, "geometryMixer", config.geometryMixer); // Obsolete
+
+ xml.intTag(level, "bigtimeVisible", config.bigTimeVisible);
+ xml.intTag(level, "transportVisible", config.transportVisible);
+
+ //xml.intTag(level, "mixerVisible", config.mixerVisible); // Obsolete
+ xml.intTag(level, "mixer1Visible", config.mixer1Visible);
+ xml.intTag(level, "mixer2Visible", config.mixer2Visible);
+ //config.mixer1.write(level, xml, "mixer1");
+ //config.mixer2.write(level, xml, "mixer2");
+ config.mixer1.write(level, xml);
+ config.mixer2.write(level, xml);
+
+ xml.intTag(level, "showSplashScreen", config.showSplashScreen);
+ xml.intTag(level, "canvasShowPartType", config.canvasShowPartType);
+ xml.intTag(level, "canvasShowPartEvent", config.canvasShowPartEvent);
+ xml.intTag(level, "canvasShowGrid", config.canvasShowGrid);
+ xml.strTag(level, "canvasBgPixmap", config.canvasBgPixmap);
+ xml.strTag(level, "canvasCustomBgList", config.canvasCustomBgList.join(";"));
+
+ xml.colorTag(level, "transportHandleColor", config.transportHandleColor);
+ xml.colorTag(level, "bigtimeForegroundcolor", config.bigTimeForegroundColor);
+ xml.colorTag(level, "bigtimeBackgroundcolor", config.bigTimeBackgroundColor);
+ xml.colorTag(level, "waveEditBackgroundColor", config.waveEditBackgroundColor);
+
+ writeSeqConfiguration(level, xml, false);
+
+ DrumEdit::writeConfiguration(level, xml);
+ PianoRoll::writeConfiguration(level, xml);
+ MasterEdit::writeConfiguration(level, xml);
+ WaveEdit::writeConfiguration(level, xml);
+
+ writeShortCuts(level, xml);
+ xml.etag(level, "configuration");
+ }
+
+//---------------------------------------------------------
+// writeConfiguration
+// write song specific configuration
+//---------------------------------------------------------
+
+void MusE::writeConfiguration(int level, Xml& xml) const
+ {
+ xml.tag(level++, "configuration");
+
+ xml.intTag(level, "midiInputDevice", midiInputPorts);
+ xml.intTag(level, "midiInputChannel", midiInputChannel);
+ xml.intTag(level, "midiRecordType", midiRecordType);
+ xml.intTag(level, "midiThruType", midiThruType);
+ xml.intTag(level, "midiFilterCtrl1", midiFilterCtrl1);
+ xml.intTag(level, "midiFilterCtrl2", midiFilterCtrl2);
+ xml.intTag(level, "midiFilterCtrl3", midiFilterCtrl3);
+ xml.intTag(level, "midiFilterCtrl4", midiFilterCtrl4);
+ // Removed by Tim. p3.3.6
+
+ //xml.intTag(level, "txDeviceId", txDeviceId);
+ //xml.intTag(level, "rxDeviceId", rxDeviceId);
+
+ // Changed by Tim. p3.3.6
+
+ //xml.intTag(level, "txSyncPort", txSyncPort);
+ /*
+ // To keep old muse versions happy...
+ bool mcsync = mmc = mtc = false;
+ for(int sp = 0; sp < MIDI_PORTS; ++sp)
+ {
+ MidiSyncTxPort* txPort = &midiSyncTxPorts[sp];
+ if(txPort->doMCSync() || txPort->doMMC() || txPort->doMTC())
+ {
+ if(txPort->doMCSync())
+ mcsync = true;
+ if(txPort->doMMC())
+ mmc = true;
+ if(txPort->doMTC())
+ mtc = true;
+ xml.intTag(level, "txSyncPort", sp);
+ break;
+ }
+ }
+ */
+
+ // Added by Tim. p3.3.6
+
+ //xml.tag(level++, "midiSyncInfo");
+ //for(iMidiDevice id = midiDevices.begin(); id != midiDevices.end(); ++id)
+ //{
+ // MidiDevice* md = *id;
+ // md->syncInfo().write(level, xml, md);
+ //}
+ //xml.etag(level, "midiSyncInfo");
+
+ //xml.intTag(level, "rxSyncPort", rxSyncPort);
+ xml.intTag(level, "mtctype", mtcType);
+ xml.nput(level, "<mtcoffset>%02d:%02d:%02d:%02d:%02d</mtcoffset>\n",
+ mtcOffset.h(), mtcOffset.m(), mtcOffset.s(),
+ mtcOffset.f(), mtcOffset.sf());
+ xml.uintTag(level, "sendClockDelay", syncSendFirstClockDelay);
+ xml.intTag(level, "useJackTransport", useJackTransport.value());
+ xml.intTag(level, "jackTransportMaster", jackTransportMaster);
+ extSyncFlag.save(level, xml);
+
+// xml.intTag(level, "genMTCSync", genMTCSync);
+// xml.intTag(level, "genMCSync", genMCSync);
+// xml.intTag(level, "genMMC", genMMC);
+// xml.intTag(level, "acceptMTC", acceptMTC);
+// xml.intTag(level, "acceptMMC", acceptMMC);
+// xml.intTag(level, "acceptMC", acceptMC);
+
+ xml.intTag(level, "bigtimeVisible", viewBigtimeAction->isChecked());
+ xml.intTag(level, "transportVisible", viewTransportAction->isChecked());
+ xml.intTag(level, "markerVisible", viewMarkerAction->isChecked());
+ //xml.intTag(level, "mixerVisible", menuView->isItemChecked(aid1)); // Obsolete
+
+ xml.geometryTag(level, "geometryMain", this);
+ if (transport)
+ xml.geometryTag(level, "geometryTransport", transport);
+ if (bigtime)
+ xml.geometryTag(level, "geometryBigTime", bigtime);
+
+ //if (audioMixer)
+ // xml.geometryTag(level, "geometryMixer", audioMixer); // Obsolete
+ xml.intTag(level, "mixer1Visible", viewMixerAAction->isChecked());
+ xml.intTag(level, "mixer2Visible", viewMixerBAction->isChecked());
+ if (mixer1)
+ //mixer1->write(level, xml, "mixer1");
+ mixer1->write(level, xml);
+ if (mixer2)
+ //mixer2->write(level, xml, "mixer2");
+ mixer2->write(level, xml);
+
+ arranger->writeStatus(level, xml);
+ writeSeqConfiguration(level, xml, true);
+
+ DrumEdit::writeConfiguration(level, xml);
+ PianoRoll::writeConfiguration(level, xml);
+ MasterEdit::writeConfiguration(level, xml);
+ WaveEdit::writeConfiguration(level, xml);
+
+ writeMidiTransforms(level, xml);
+ writeMidiInputTransforms(level, xml);
+ xml.etag(level, "configuration");
+ }
+
+//---------------------------------------------------------
+// configMidiSync
+//---------------------------------------------------------
+
+void MusE::configMidiSync()
+ {
+ if (!midiSyncConfig)
+ //midiSyncConfig = new MidiSyncConfig(this);
+ midiSyncConfig = new MidiSyncConfig;
+
+ if (midiSyncConfig->isVisible()) {
+ midiSyncConfig->raise();
+ midiSyncConfig->activateWindow();
+ }
+ else
+ midiSyncConfig->show();
+ }
+
+//---------------------------------------------------------
+// configMidiFile
+//---------------------------------------------------------
+
+void MusE::configMidiFile()
+ {
+ if (!midiFileConfig)
+ midiFileConfig = new MidiFileConfig();
+ midiFileConfig->updateValues();
+
+ if (midiFileConfig->isVisible()) {
+ midiFileConfig->raise();
+ midiFileConfig->activateWindow();
+ }
+ else
+ midiFileConfig->show();
+ }
+
+//---------------------------------------------------------
+// MidiFileConfig
+// config properties of exported midi files
+//---------------------------------------------------------
+
+MidiFileConfig::MidiFileConfig(QWidget* parent)
+ : QDialog(parent), ConfigMidiFileBase()
+ {
+ setupUi(this);
+ connect(buttonOk, SIGNAL(clicked()), SLOT(okClicked()));
+ connect(buttonCancel, SIGNAL(clicked()), SLOT(cancelClicked()));
+ }
+
+//---------------------------------------------------------
+// updateValues
+//---------------------------------------------------------
+
+void MidiFileConfig::updateValues()
+ {
+ int divisionIdx = 2;
+ switch(config.midiDivision) {
+ case 96: divisionIdx = 0; break;
+ case 192: divisionIdx = 1; break;
+ case 384: divisionIdx = 2; break;
+ }
+ divisionCombo->setCurrentIndex(divisionIdx);
+ formatCombo->setCurrentIndex(config.smfFormat);
+ extendedFormat->setChecked(config.extendedMidi);
+ copyrightEdit->setText(config.copyright);
+ optNoteOffs->setChecked(config.expOptimNoteOffs);
+ twoByteTimeSigs->setChecked(config.exp2ByteTimeSigs);
+ splitPartsCheckBox->setChecked(config.importMidiSplitParts);
+ }
+
+//---------------------------------------------------------
+// okClicked
+//---------------------------------------------------------
+
+void MidiFileConfig::okClicked()
+ {
+ int divisionIdx = divisionCombo->currentIndex();
+
+ int divisions[3] = { 96, 192, 384 };
+ if (divisionIdx >= 0 && divisionIdx < 3)
+ config.midiDivision = divisions[divisionIdx];
+ config.extendedMidi = extendedFormat->isChecked();
+ config.smfFormat = formatCombo->currentIndex();
+ config.copyright = copyrightEdit->text();
+ config.expOptimNoteOffs = optNoteOffs->isChecked();
+ config.exp2ByteTimeSigs = twoByteTimeSigs->isChecked();
+ config.importMidiSplitParts = splitPartsCheckBox->isChecked();
+
+ muse->changeConfig(true); // write config file
+ close();
+ }
+
+//---------------------------------------------------------
+// cancelClicked
+//---------------------------------------------------------
+
+void MidiFileConfig::cancelClicked()
+ {
+ close();
+ }
+
+//---------------------------------------------------------
+// configGlobalSettings
+//---------------------------------------------------------
+
+void MusE::configGlobalSettings()
+ {
+ if (!globalSettingsConfig)
+ globalSettingsConfig = new GlobalSettingsConfig();
+
+ if (globalSettingsConfig->isVisible()) {
+ globalSettingsConfig->raise();
+ globalSettingsConfig->activateWindow();
+ }
+ else
+ globalSettingsConfig->show();
+ }
+
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+//void MixerConfig::write(Xml& xml, const char* name)
+void MixerConfig::write(int level, Xml& xml)
+//void MixerConfig::write(int level, Xml& xml, const char* name)
+ {
+ //xml.stag(QString(name));
+ //xml.tag(level++, name.toLatin1().constData());
+ xml.tag(level++, "Mixer");
+ //xml.tag(level++, name);
+
+ xml.strTag(level, "name", name);
+
+ //xml.tag("geometry", geometry);
+ xml.qrectTag(level, "geometry", geometry);
+
+ xml.intTag(level, "showMidiTracks", showMidiTracks);
+ xml.intTag(level, "showDrumTracks", showDrumTracks);
+ xml.intTag(level, "showInputTracks", showInputTracks);
+ xml.intTag(level, "showOutputTracks", showOutputTracks);
+ xml.intTag(level, "showWaveTracks", showWaveTracks);
+ xml.intTag(level, "showGroupTracks", showGroupTracks);
+ xml.intTag(level, "showAuxTracks", showAuxTracks);
+ xml.intTag(level, "showSyntiTracks", showSyntiTracks);
+
+ //xml.etag(name);
+ //xml.etag(level, name.toLatin1().constData());
+ xml.etag(level, "Mixer");
+ //xml.etag(level, name);
+ }
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+//void MixerConfig::read(QDomNode node)
+void MixerConfig::read(Xml& xml)
+//void MixerConfig::read(Xml& xml, const QString& name)
+ {
+ for (;;) {
+ Xml::Token token(xml.parse());
+ const QString& tag(xml.s1());
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "name")
+ name = xml.parse1();
+ else if (tag == "geometry")
+ geometry = readGeometry(xml, tag);
+ else if (tag == "showMidiTracks")
+ showMidiTracks = xml.parseInt();
+ else if (tag == "showDrumTracks")
+ showDrumTracks = xml.parseInt();
+ else if (tag == "showInputTracks")
+ showInputTracks = xml.parseInt();
+ else if (tag == "showOutputTracks")
+ showOutputTracks = xml.parseInt();
+ else if (tag == "showWaveTracks")
+ showWaveTracks = xml.parseInt();
+ else if (tag == "showGroupTracks")
+ showGroupTracks = xml.parseInt();
+ else if (tag == "showAuxTracks")
+ showAuxTracks = xml.parseInt();
+ else if (tag == "showSyntiTracks")
+ showSyntiTracks = xml.parseInt();
+ else
+ //xml.unknown(name.toLatin1().constData());
+ xml.unknown("Mixer");
+ break;
+ case Xml::TagEnd:
+ //if (tag == name)
+ if (tag == "Mixer")
+ return;
+ default:
+ break;
+ }
+ }
+
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/conf.h b/attic/muse2-oom/muse2/muse/conf.h
new file mode 100644
index 00000000..656be4a7
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/conf.h
@@ -0,0 +1,38 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: conf.h,v 1.4.2.1 2006/09/28 19:22:25 spamatica Exp $
+//
+// (C) Copyright 1999-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __CONF_H__
+#define __CONF_H__
+
+#include "ui_configmidifilebase.h"
+
+class QDialog;
+class QLineEdit;
+
+//---------------------------------------------------------
+// MidiFileConfig
+// config properties of exported midi files
+//---------------------------------------------------------
+
+class MidiFileConfig : public QDialog, public Ui::ConfigMidiFileBase {
+ Q_OBJECT
+
+ private slots:
+ void okClicked();
+ void cancelClicked();
+
+ public:
+ MidiFileConfig(QWidget* parent=0);
+ void updateValues();
+ };
+
+class Xml;
+extern bool readConfiguration();
+extern void readConfiguration(Xml&, bool readOnlySequencer);
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/confmport.cpp b/attic/muse2-oom/muse2/muse/confmport.cpp
new file mode 100644
index 00000000..77e6889c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/confmport.cpp
@@ -0,0 +1,1026 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: confmport.cpp,v 1.9.2.10 2009/12/15 03:39:58 terminator356 Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <list>
+#include <termios.h>
+#include <iostream>
+#include <stdio.h>
+
+#include <QMenu>
+#include <QMessageBox>
+#include <QPixmap>
+#include <QTableWidget>
+#include <QTableWidgetItem>
+
+#include "confmport.h"
+#include "app.h"
+#include "icons.h"
+#include "globals.h"
+#include "arranger.h"
+#include "midiport.h"
+#include "mididev.h"
+#include "xml.h"
+#include "midisyncimpl.h"
+#include "midifilterimpl.h"
+#include "ctrlcombo.h"
+#include "minstrument.h"
+#include "synth.h"
+#include "audio.h"
+#include "midiseq.h"
+#include "driver/alsamidi.h"
+#include "driver/jackmidi.h"
+#include "audiodev.h"
+#include "menutitleitem.h"
+#include "utils.h"
+
+extern std::vector<Synth*> synthis;
+
+enum { DEVCOL_NO = 0, DEVCOL_GUI, DEVCOL_REC, DEVCOL_PLAY, DEVCOL_INSTR, DEVCOL_NAME,
+ //DEVCOL_STATE };
+ //DEVCOL_ROUTES, DEVCOL_STATE };
+ //DEVCOL_INROUTES, DEVCOL_OUTROUTES, DEVCOL_STATE }; // p3.3.55
+ DEVCOL_INROUTES, DEVCOL_OUTROUTES, DEVCOL_DEF_IN_CHANS, DEVCOL_DEF_OUT_CHANS, DEVCOL_STATE };
+
+//---------------------------------------------------------
+// mdevViewItemRenamed
+//---------------------------------------------------------
+
+void MPConfig::mdevViewItemRenamed(QTableWidgetItem* item)
+{
+ int col = item->column();
+ QString s = item->text();
+ //printf("MPConfig::mdevViewItemRenamed col:%d txt:%s\n", col, s.toLatin1().constData());
+ if(item == 0)
+ return;
+ switch(col)
+ {
+ case DEVCOL_DEF_IN_CHANS:
+ {
+ QString id = item->tableWidget()->item(item->row(), DEVCOL_NO)->text();
+ int no = atoi(id.toLatin1().constData()) - 1;
+ if(no < 0 || no >= MIDI_PORTS)
+ return;
+ midiPorts[no].setDefaultInChannels(((1 << MIDI_CHANNELS) - 1) & string2bitmap(s));
+ song->update();
+ }
+ break;
+ case DEVCOL_DEF_OUT_CHANS:
+ {
+ QString id = item->tableWidget()->item(item->row(), DEVCOL_NO)->text();
+ int no = atoi(id.toLatin1().constData()) - 1;
+ if(no < 0 || no >= MIDI_PORTS)
+ return;
+ midiPorts[no].setDefaultOutChannels(((1 << MIDI_CHANNELS) - 1) & string2bitmap(s));
+ song->update();
+ }
+ break;
+ case DEVCOL_NAME:
+ {
+ QString id = item->tableWidget()->item(item->row(), DEVCOL_NO)->text();
+ int no = atoi(id.toLatin1().constData()) - 1;
+ if(no < 0 || no >= MIDI_PORTS)
+ return;
+
+ MidiPort* port = &midiPorts[no];
+ MidiDevice* dev = port->device();
+ // Only Jack midi devices.
+ if(!dev || dev->deviceType() != MidiDevice::JACK_MIDI)
+ return;
+ if(dev->name() == s)
+ return;
+
+ if(midiDevices.find(s))
+ {
+ QMessageBox::critical(this,
+ tr("MusE: bad device name"),
+ tr("please choose a unique device name"),
+ QMessageBox::Ok,
+ Qt::NoButton,
+ Qt::NoButton);
+ songChanged(-1);
+ return;
+ }
+ dev->setName(s);
+ song->update();
+ }
+ break;
+ default:
+ //printf("MPConfig::mdevViewItemRenamed unknown column clicked col:%d txt:%s\n", col, s.toLatin1().constData());
+ break;
+ }
+}
+
+//---------------------------------------------------------
+// rbClicked
+//---------------------------------------------------------
+
+void MPConfig::rbClicked(QTableWidgetItem* item)
+ {
+ if (item == 0)
+ return;
+ QString id = item->tableWidget()->item(item->row(), DEVCOL_NO)->text();
+ int no = atoi(id.toLatin1().constData()) - 1;
+ if (no < 0 || no >= MIDI_PORTS)
+ return;
+
+ int n;
+ MidiPort* port = &midiPorts[no];
+ MidiDevice* dev = port->device();
+ int rwFlags = dev ? dev->rwFlags() : 0;
+ int openFlags = dev ? dev->openFlags() : 0;
+ QTableWidget* listView = item->tableWidget();
+ //printf("MPConfig::rbClicked cpt x:%d y:%d\n", cpt.x(), cpt.y());
+ //printf("MPConfig::rbClicked new cpt x:%d y:%d\n", cpt.x(), cpt.y());
+ //printf("MPConfig::rbClicked new mapped cpt x:%d y:%d\n", cpt.x(), cpt.y());
+ QPoint ppt = listView->visualItemRect(item).bottomLeft();
+ QPoint mousepos = QCursor::pos();
+ //printf("MPConfig::rbClicked ppt x:%d y:%d\n", ppt.x(), ppt.y());
+ int col = item->column();
+ ppt += QPoint(0, listView->horizontalHeader()->height());
+ //printf("MPConfig::rbClicked new ppt x:%d y:%d\n", ppt.x(), ppt.y());
+ ppt = listView->mapToGlobal(ppt);
+ //printf("MPConfig::rbClicked new mapped ppt x:%d y:%d\n", ppt.x(), ppt.y());
+
+ switch (col) {
+ case DEVCOL_GUI:
+ if (dev == 0)
+ //break;
+ return;
+ if (port->hasGui())
+ {
+ port->instrument()->showGui(!port->guiVisible());
+ item->setIcon(port->guiVisible() ? QIcon(*dotIcon) : QIcon(*dothIcon));
+ }
+ //break;
+ return;
+
+ case DEVCOL_REC:
+ if (dev == 0 || !(rwFlags & 2))
+ //break;
+ return;
+ openFlags ^= 0x2;
+ dev->setOpenFlags(openFlags);
+ midiSeq->msgSetMidiDevice(port, dev); // reopen device
+ item->setIcon(openFlags & 2 ? QIcon(*dotIcon) : QIcon(*dothIcon));
+
+ // p3.3.55
+ if(dev->deviceType() == MidiDevice::JACK_MIDI)
+ {
+ if(dev->openFlags() & 2)
+ {
+ //item->setPixmap(DEVCOL_INROUTES, *buttondownIcon);
+ item->tableWidget()->item(item->row(), DEVCOL_INROUTES)->setText(tr("in"));
+ }
+ else
+ {
+ //item->setPixmap(DEVCOL_INROUTES, *buttondownIcon);
+ item->tableWidget()->item(item->row(), DEVCOL_INROUTES)->setText("");
+ }
+ }
+
+ //break;
+ return;
+
+ case DEVCOL_PLAY:
+ if (dev == 0 || !(rwFlags & 1))
+ //break;
+ return;
+ openFlags ^= 0x1;
+ dev->setOpenFlags(openFlags);
+ midiSeq->msgSetMidiDevice(port, dev); // reopen device
+ item->setIcon(openFlags & 1 ? QIcon(*dotIcon) : QIcon(*dothIcon));
+
+ // p3.3.55
+ if(dev->deviceType() == MidiDevice::JACK_MIDI)
+ {
+ if(dev->openFlags() & 1)
+ {
+ //item->setPixmap(DEVCOL_OUTROUTES, *buttondownIcon);
+ item->tableWidget()->item(item->row(), DEVCOL_OUTROUTES)->setText(tr("out"));
+ }
+ else
+ {
+ //item->setPixmap(DEVCOL_OUTROUTES, *buttondownIcon);
+ item->tableWidget()->item(item->row(), DEVCOL_OUTROUTES)->setText("");
+ }
+ }
+
+ //break;
+ return;
+
+ //case DEVCOL_ROUTES:
+ case DEVCOL_INROUTES: // p3.3.55
+ case DEVCOL_OUTROUTES:
+ {
+ if(!checkAudioDevice())
+ return;
+
+ if(audioDevice->deviceType() != AudioDevice::JACK_AUDIO) // p3.3.52 Only if Jack is running.
+ return;
+
+ if(!dev)
+ return;
+
+ // Only Jack midi devices.
+ //MidiJackDevice* mjd = dynamic_cast<MidiJackDevice*>(dev);
+ //if(!mjd)
+ if(dev->deviceType() != MidiDevice::JACK_MIDI)
+ return;
+
+ //if(!(dev->rwFlags() & 3))
+ //if(!(dev->rwFlags() & ((col == DEVCOL_OUTROUTES) ? 1 : 2))) // p3.3.55
+ if(!(dev->openFlags() & ((col == DEVCOL_OUTROUTES) ? 1 : 2)))
+ return;
+
+ //RouteList* rl = (dev->rwFlags() & 1) ? dev->outRoutes() : dev->inRoutes();
+ RouteList* rl = (col == DEVCOL_OUTROUTES) ? dev->outRoutes() : dev->inRoutes(); // p3.3.55
+ QMenu* pup = 0;
+ int gid = 0;
+ std::list<QString> sl;
+ pup = new QMenu(this);
+
+ _redisplay:
+ pup->clear();
+ gid = 0;
+
+ // Jack input ports if device is writable, and jack output ports if device is readable.
+ //sl = (dev->rwFlags() & 1) ? audioDevice->inputPorts(true, _showAliases) : audioDevice->outputPorts(true, _showAliases);
+ // p3.3.55
+ sl = (col == DEVCOL_OUTROUTES) ? audioDevice->inputPorts(true, _showAliases) : audioDevice->outputPorts(true, _showAliases);
+
+ //for (int i = 0; i < channel; ++i)
+ //{
+ //char buffer[128];
+ //snprintf(buffer, 128, "%s %d", tr("Channel").toLatin1().constData(), i+1);
+ //MenuTitleItem* titel = new MenuTitleItem(QString(buffer));
+ //pup->insertItem(titel);
+
+ QAction* act;
+
+ act = pup->addAction(tr("Show first aliases"));
+ act->setData(gid);
+ act->setCheckable(true);
+ act->setChecked(_showAliases == 0);
+ ++gid;
+
+ act = pup->addAction(tr("Show second aliases"));
+ act->setData(gid);
+ act->setCheckable(true);
+ act->setChecked(_showAliases == 1);
+ ++gid;
+
+ pup->addSeparator();
+ for(std::list<QString>::iterator ip = sl.begin(); ip != sl.end(); ++ip)
+ {
+ act = pup->addAction(*ip);
+ act->setData(gid);
+ act->setCheckable(true);
+
+ //Route dst(*ip, true, i);
+ //Route rt(*ip, (dev->rwFlags() & 1), -1, Route::JACK_ROUTE);
+ Route rt(*ip, (col == DEVCOL_OUTROUTES), -1, Route::JACK_ROUTE); // p3.3.55
+ for(iRoute ir = rl->begin(); ir != rl->end(); ++ir)
+ {
+ if (*ir == rt)
+ {
+ act->setChecked(true);
+ break;
+ }
+ }
+ ++gid;
+ }
+ //if (i+1 != channel)
+ // pup->insertSeparator();
+ //}
+
+ act = pup->exec(ppt);
+ if(act)
+ {
+ n = act->data().toInt();
+ if(n == 0) // Show first aliases
+ {
+ //delete pup;
+ if(_showAliases == 0)
+ _showAliases = -1;
+ else
+ _showAliases = 0;
+ goto _redisplay; // Go back
+ }
+ else
+ if(n == 1) // Show second aliases
+ {
+ //delete pup;
+ if(_showAliases == 1)
+ _showAliases = -1;
+ else
+ _showAliases = 1;
+ goto _redisplay; // Go back
+ }
+
+ QString s(act->text());
+
+ //if(dev->rwFlags() & 1) // Writable
+ if(col == DEVCOL_OUTROUTES) // Writable p3.3.55
+ {
+ Route srcRoute(dev, -1);
+ Route dstRoute(s, true, -1, Route::JACK_ROUTE);
+
+ iRoute iir = rl->begin();
+ for(; iir != rl->end(); ++iir)
+ {
+ if(*iir == dstRoute)
+ break;
+ }
+ if(iir != rl->end())
+ // disconnect
+ audio->msgRemoveRoute(srcRoute, dstRoute);
+ else
+ // connect
+ audio->msgAddRoute(srcRoute, dstRoute);
+ }
+ else
+ //if(dev->rwFlags() & 2) // Readable
+ //if(col == DEVCOL_INROUTES) // Readable p3.3.55
+ {
+ Route srcRoute(s, false, -1, Route::JACK_ROUTE);
+ Route dstRoute(dev, -1);
+
+ iRoute iir = rl->begin();
+ for(; iir != rl->end(); ++iir)
+ {
+ if(*iir == srcRoute)
+ break;
+ }
+ if(iir != rl->end())
+ // disconnect
+ audio->msgRemoveRoute(srcRoute, dstRoute);
+ else
+ // connect
+ audio->msgAddRoute(srcRoute, dstRoute);
+ }
+
+ audio->msgUpdateSoloStates();
+ song->update(SC_ROUTE);
+
+ // p3.3.46
+ //delete pup;
+ // FIXME:
+ // Routes can't be re-read until the message sent from msgAddRoute1()
+ // has had time to be sent and actually affected the routes.
+ ///goto _redisplay; // Go back
+ }
+ delete pup;
+ //iR->setDown(false); // pup->exec() catches mouse release event
+ }
+ //break;
+ return;
+
+ case DEVCOL_DEF_IN_CHANS:
+ case DEVCOL_DEF_OUT_CHANS:
+ {
+ }
+ //break;
+ return;
+
+ case DEVCOL_NAME:
+ {
+ //printf("MPConfig::rbClicked DEVCOL_NAME\n");
+
+ // Did we click in the text area?
+ if((mousepos.x() - ppt.x()) > buttondownIcon->width())
+ {
+ //printf("MPConfig::rbClicked starting item rename... enabled?:%d\n", item->renameEnabled(DEVCOL_NAME));
+ // Start the renaming of the cell...
+ QModelIndex current = item->tableWidget()->currentIndex();
+ if (item->flags() & Qt::ItemIsEditable)
+ item->tableWidget()->edit(current.sibling(current.row(), DEVCOL_NAME));
+
+ return;
+ }
+ else
+ // We clicked the 'down' button.
+ {
+ QMenu* pup = new QMenu(this);
+
+ QAction* act;
+
+ // Could do it this way...
+ //act = pup->addAction(tr("Create") + QT_TRANSLATE_NOOP("@default", " Jack") + tr(" input"));
+ //act = pup->addAction(tr("Create") + QT_TRANSLATE_NOOP("@default", " Jack") + tr(" output"));
+ //act = pup->addAction(tr("Create") + QT_TRANSLATE_NOOP("@default", " Jack") + tr(" combo"));
+ // ... or keep it simple and let the user click on the green lights instead.
+ act = pup->addAction(tr("Create") + QT_TRANSLATE_NOOP("@default", " Jack") + tr(" device"));
+ act->setData(0);
+
+ typedef std::map<std::string, int > asmap;
+ typedef std::map<std::string, int >::iterator imap;
+
+ asmap mapALSA;
+ asmap mapJACK;
+ asmap mapSYNTH;
+
+ int aix = 0x10000000;
+ int jix = 0x20000000;
+ int six = 0x30000000;
+ for(iMidiDevice i = midiDevices.begin(); i != midiDevices.end(); ++i)
+ {
+ //devALSA = dynamic_cast<MidiAlsaDevice*>(*i);
+ //if(devALSA)
+ if((*i)->deviceType() == MidiDevice::ALSA_MIDI)
+ {
+ //mapALSA.insert( std::pair<std::string, int> (std::string(devALSA->name().lower().toLatin1().constData()), ii) );
+ mapALSA.insert( std::pair<std::string, int> (std::string((*i)->name().toLatin1().constData()), aix) );
+ ++aix;
+ }
+ else
+ if((*i)->deviceType() == MidiDevice::JACK_MIDI)
+ {
+ //devJACK = dynamic_cast<MidiJackDevice*>(*i);
+ //if(devJACK)
+ //mapJACK.insert( std::pair<std::string, int> (std::string(devJACK->name().lower().toLatin1().constData()), ii) );
+ mapJACK.insert( std::pair<std::string, int> (std::string((*i)->name().toLatin1().constData()), jix) );
+ ++jix;
+ }
+ else
+ if((*i)->deviceType() == MidiDevice::SYNTH_MIDI)
+ {
+ mapSYNTH.insert( std::pair<std::string, int> (std::string((*i)->name().toLatin1().constData()), six) );
+ ++six;
+ }
+ else
+ printf("MPConfig::rbClicked unknown midi device: %s\n", (*i)->name().toLatin1().constData());
+ }
+
+ //int sz = midiDevices.size();
+ //if(!mapALSA.empty())
+ {
+ pup->addSeparator();
+ pup->addAction(new MenuTitleItem(QT_TRANSLATE_NOOP("@default", "ALSA:"), pup));
+
+ for(imap i = mapALSA.begin(); i != mapALSA.end(); ++i)
+ {
+ int idx = i->second;
+ //if(idx > sz) // Sanity check
+ // continue;
+ QString s(i->first.c_str());
+ MidiDevice* md = midiDevices.find(s, MidiDevice::ALSA_MIDI);
+ if(md)
+ {
+ //if(!dynamic_cast<MidiAlsaDevice*>(md))
+ if(md->deviceType() != MidiDevice::ALSA_MIDI)
+ continue;
+
+ act = pup->addAction(QT_TRANSLATE_NOOP("@default", md->name()));
+ act->setData(idx);
+ act->setCheckable(true);
+ act->setChecked(md == dev);
+ }
+ }
+ }
+
+ if(!mapSYNTH.empty())
+ {
+ pup->addSeparator();
+ pup->addAction(new MenuTitleItem(QT_TRANSLATE_NOOP("@default", "SYNTH:"), pup));
+
+ for(imap i = mapSYNTH.begin(); i != mapSYNTH.end(); ++i)
+ {
+ int idx = i->second;
+ //if(idx > sz)
+ // continue;
+ QString s(i->first.c_str());
+ MidiDevice* md = midiDevices.find(s, MidiDevice::SYNTH_MIDI);
+ if(md)
+ {
+ //if(!dynamic_cast<MidiJackDevice*>(md))
+ if(md->deviceType() != MidiDevice::SYNTH_MIDI)
+ continue;
+
+ act = pup->addAction(QT_TRANSLATE_NOOP("@default", md->name()));
+ act->setData(idx);
+ act->setCheckable(true);
+ act->setChecked(md == dev);
+ }
+ }
+ }
+
+ //if(!mapJACK.empty())
+ {
+ pup->addSeparator();
+ pup->addAction(new MenuTitleItem(QT_TRANSLATE_NOOP("@default", "JACK:"), pup));
+
+ for(imap i = mapJACK.begin(); i != mapJACK.end(); ++i)
+ {
+ int idx = i->second;
+ //if(idx > sz)
+ // continue;
+ QString s(i->first.c_str());
+ MidiDevice* md = midiDevices.find(s, MidiDevice::JACK_MIDI);
+ if(md)
+ {
+ //if(!dynamic_cast<MidiJackDevice*>(md))
+ if(md->deviceType() != MidiDevice::JACK_MIDI)
+ continue;
+
+ act = pup->addAction(QT_TRANSLATE_NOOP("@default", md->name()));
+ act->setData(idx);
+ act->setCheckable(true);
+ act->setChecked(md == dev);
+ }
+ }
+ }
+
+ act = pup->exec(ppt);
+ if(!act)
+ {
+ delete pup;
+ //break;
+ return;
+ }
+
+ n = act->data().toInt();
+ //printf("MPConfig::rbClicked n:%d\n", n);
+
+ MidiDevice* sdev = 0;
+ if(n < 0x10000000)
+ {
+ delete pup;
+ if(n <= 2) // p3.3.55
+ {
+ sdev = MidiJackDevice::createJackMidiDevice();
+
+ if(sdev)
+ {
+ int of = 3;
+ switch(n)
+ {
+ case 0: of = 3; break;
+ case 1: of = 2; break;
+ case 2: of = 1; break;
+ }
+ sdev->setOpenFlags(of);
+ }
+ }
+ }
+ else
+ {
+ int typ;
+ if(n < 0x20000000)
+ typ = MidiDevice::ALSA_MIDI;
+ else
+ if(n < 0x30000000)
+ typ = MidiDevice::JACK_MIDI;
+ else
+ //if(n < 0x40000000)
+ typ = MidiDevice::SYNTH_MIDI;
+
+ sdev = midiDevices.find(act->text(), typ);
+ delete pup;
+ // Is it the current device? Reset it to <none>.
+ if(sdev == dev)
+ sdev = 0;
+ }
+
+ midiSeq->msgSetMidiDevice(port, sdev);
+ muse->changeConfig(true); // save configuration file
+ song->update();
+ }
+ }
+ //break;
+ return;
+
+ case DEVCOL_INSTR:
+ {
+ if (dev && dev->isSynti())
+ //break;
+ return;
+ if (instrPopup == 0)
+ instrPopup = new QMenu(this);
+ instrPopup->clear();
+ for (iMidiInstrument i = midiInstruments.begin(); i
+ != midiInstruments.end(); ++i)
+ {
+ // By T356.
+ // Do not list synths. Although it is possible to assign a synth
+ // as an instrument to a non-synth device, we should not allow this.
+ // (One reason is that the 'show gui' column is then enabled, which
+ // makes no sense for a non-synth device).
+ SynthI* si = dynamic_cast<SynthI*>(*i);
+ if(!si)
+ instrPopup->addAction((*i)->iname());
+ }
+
+ QAction* act = instrPopup->exec(ppt, 0);
+ if(!act)
+ //break;
+ return;
+ QString s = act->text();
+ item->tableWidget()->item(item->row(), DEVCOL_INSTR)->setText(s);
+ for (iMidiInstrument i = midiInstruments.begin(); i
+ != midiInstruments.end(); ++i) {
+ if ((*i)->iname() == s) {
+ port->setInstrument(*i);
+ break;
+ }
+ }
+ song->update();
+ }
+ //break;
+ return;
+ }
+ //songChanged(-1);
+ }
+
+//---------------------------------------------------------
+// MPConfig::setToolTip
+//---------------------------------------------------------
+
+void MPConfig::setToolTip(QTableWidgetItem *item, int col)
+ {
+ switch (col) {
+ case DEVCOL_NO: item->setToolTip(tr("Port Number")); break;
+ case DEVCOL_GUI: item->setToolTip(tr("Enable gui")); break;
+ case DEVCOL_REC: item->setToolTip(tr("Enable reading")); break;
+ case DEVCOL_PLAY: item->setToolTip(tr("Enable writing")); break;
+ case DEVCOL_INSTR: item->setToolTip(tr("Port instrument")); break;
+ case DEVCOL_NAME: item->setToolTip(tr("Midi device name. Click to edit (Jack)")); break;
+ //case DEVCOL_ROUTES: item->setToolTip(tr("Jack midi ports")); break;
+ case DEVCOL_INROUTES: item->setToolTip(tr("Connections from Jack Midi outputs")); break;
+ case DEVCOL_OUTROUTES: item->setToolTip(tr("Connections to Jack Midi inputs")); break;
+ case DEVCOL_DEF_IN_CHANS: item->setToolTip(tr("Connect these to new midi tracks")); break;
+ case DEVCOL_DEF_OUT_CHANS: item->setToolTip(tr("Connect new midi tracks to this (first listed only)")); break;
+ case DEVCOL_STATE: item->setToolTip(tr("Device state")); break;
+ default: return;
+ }
+ }
+
+//---------------------------------------------------------
+// MPConfig::setWhatsThis
+//---------------------------------------------------------
+
+void MPConfig::setWhatsThis(QTableWidgetItem *item, int col)
+ {
+ switch (col) {
+ case DEVCOL_NO:
+ item->setWhatsThis(tr("Port Number")); break;
+ case DEVCOL_GUI:
+ item->setWhatsThis(tr("Enable gui for device")); break;
+ case DEVCOL_REC:
+ item->setWhatsThis(tr("Enable reading from device")); break;
+ case DEVCOL_PLAY:
+ item->setWhatsThis(tr("Enable writing to device")); break;
+ case DEVCOL_NAME:
+ item->setWhatsThis(tr("Name of the midi device associated with"
+ " this port number. Click to edit Jack midi name.")); break;
+ case DEVCOL_INSTR:
+ item->setWhatsThis(tr("Instrument connected to port")); break;
+ //case DEVCOL_ROUTES:
+ // item->setWhatsThis(tr("Jack midi ports")); break;
+ case DEVCOL_INROUTES:
+ item->setWhatsThis(tr("Connections from Jack Midi output ports")); break;
+ case DEVCOL_OUTROUTES:
+ item->setWhatsThis(tr("Connections to Jack Midi input ports")); break;
+ case DEVCOL_DEF_IN_CHANS:
+ item->setWhatsThis(tr("Connect these channels, on this port, to new midi tracks.\n"
+ "Example:\n"
+ " 1 2 3 channel 1 2 and 3\n"
+ " 1-3 same\n"
+ " 1-3 5 channel 1 2 3 and 5\n"
+ " all all channels\n"
+ " none no channels")); break;
+ case DEVCOL_DEF_OUT_CHANS:
+ item->setWhatsThis(tr("Connect new midi tracks to these channels, on this port.\n"
+ "See default in channels.\n"
+ "NOTE: Currently only one output port and channel supported (first found)")); break;
+ case DEVCOL_STATE:
+ item->setWhatsThis(tr("State: result of opening the device")); break;
+ default:
+ break;
+ }
+ }
+
+
+//---------------------------------------------------------
+// MPConfig::addItem()
+//---------------------------------------------------------
+
+void MPConfig::addItem(int row, int col, QTableWidgetItem *item, QTableWidget *table)
+ {
+ setWhatsThis(item, col);
+ table->setItem(row, col, item);
+ }
+
+
+//---------------------------------------------------------
+// MPConfig
+// Midi Port Config
+//---------------------------------------------------------
+
+MPConfig::MPConfig(QWidget* parent)
+ : QDialog(parent)
+ {
+ setupUi(this);
+ mdevView->setRowCount(MIDI_PORTS);
+ mdevView->verticalHeader()->hide();
+ mdevView->setSelectionMode(QAbstractItemView::SingleSelection);
+ mdevView->setShowGrid(false);
+
+ //popup = 0;
+ instrPopup = 0;
+ _showAliases = -1; // 0: Show first aliases, if available. Nah, stick with -1: none at first.
+
+ QStringList columnnames;
+ columnnames << tr("Port")
+ << tr("GUI")
+ << tr("I")
+ << tr("O")
+ << tr("Instrument")
+ << tr("Device Name")
+ << tr("In routes")
+ << tr("Out routes")
+ << tr("Def in ch")
+ << tr("Def out ch")
+ << tr("State");
+
+ mdevView->setColumnCount(columnnames.size());
+ mdevView->setHorizontalHeaderLabels(columnnames);
+ for (int i = 0; i < columnnames.size(); ++i) {
+ setWhatsThis(mdevView->horizontalHeaderItem(i), i);
+ setToolTip(mdevView->horizontalHeaderItem(i), i);
+ }
+ mdevView->setFocusPolicy(Qt::NoFocus);
+
+ connect(mdevView, SIGNAL(itemPressed(QTableWidgetItem*)),
+ this, SLOT(rbClicked(QTableWidgetItem*)));
+ connect(mdevView, SIGNAL(itemChanged(QTableWidgetItem*)),
+ this, SLOT(mdevViewItemRenamed(QTableWidgetItem*)));
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+
+ connect(synthList, SIGNAL(itemSelectionChanged()), SLOT(selectionChanged()));
+ connect(instanceList, SIGNAL(itemSelectionChanged()), SLOT(selectionChanged()));
+
+ connect(addInstance, SIGNAL(clicked()), SLOT(addInstanceClicked()));
+ connect(synthList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), SLOT(addInstanceClicked()));
+ connect(removeInstance, SIGNAL(clicked()), SLOT(removeInstanceClicked()));
+ connect(instanceList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), SLOT(removeInstanceClicked()));
+ songChanged(0);
+ }
+
+
+MPConfig::~MPConfig()
+{
+}
+
+//---------------------------------------------------------
+// selectionChanged
+//---------------------------------------------------------
+
+void MPConfig::selectionChanged()
+ {
+ addInstance->setEnabled(synthList->currentItem());
+ removeInstance->setEnabled(instanceList->currentItem());
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void MPConfig::songChanged(int flags)
+ {
+ // Is it simply a midi controller value adjustment? Forget it.
+ if(flags == SC_MIDI_CONTROLLER)
+ return;
+
+ // Get currently selected index...
+ int no = -1;
+ QTableWidgetItem* sitem = mdevView->currentItem();
+ if(sitem)
+ {
+ QString id = sitem->tableWidget()->item(sitem->row(), DEVCOL_NO)->text();
+ no = atoi(id.toLatin1().constData()) - 1;
+ if(no < 0 || no >= MIDI_PORTS)
+ no = -1;
+ }
+
+ sitem = 0;
+ mdevView->clearContents();
+ for (int i = MIDI_PORTS-1; i >= 0; --i)
+ {
+ mdevView->blockSignals(true); // otherwise itemChanged() is triggered and bad things happen.
+ MidiPort* port = &midiPorts[i];
+ MidiDevice* dev = port->device();
+ QString s;
+ s.setNum(i+1);
+ QTableWidgetItem* itemno = new QTableWidgetItem(s);
+ addItem(i, DEVCOL_NO, itemno, mdevView);
+ itemno->setTextAlignment(Qt::AlignHCenter);
+ itemno->setFlags(Qt::ItemIsEnabled);
+ QTableWidgetItem* itemstate = new QTableWidgetItem(port->state());
+ addItem(i, DEVCOL_STATE, itemstate, mdevView);
+ itemstate->setFlags(Qt::ItemIsEnabled);
+ QTableWidgetItem* iteminstr = new QTableWidgetItem(port->instrument() ?
+ port->instrument()->iname() :
+ tr("<unknown>"));
+ addItem(i, DEVCOL_INSTR, iteminstr, mdevView);
+ iteminstr->setFlags(Qt::ItemIsEnabled);
+ QTableWidgetItem* itemname = new QTableWidgetItem;
+ addItem(i, DEVCOL_NAME, itemname, mdevView);
+ itemname->setFlags(Qt::ItemIsEnabled);
+ QTableWidgetItem* itemgui = new QTableWidgetItem;
+ addItem(i, DEVCOL_GUI, itemgui, mdevView);
+ itemgui->setTextAlignment(Qt::AlignHCenter);
+ itemgui->setFlags(Qt::ItemIsEnabled);
+ QTableWidgetItem* itemrec = new QTableWidgetItem;
+ addItem(i, DEVCOL_REC, itemrec, mdevView);
+ itemrec->setTextAlignment(Qt::AlignHCenter);
+ itemrec->setFlags(Qt::ItemIsEnabled);
+ QTableWidgetItem* itemplay = new QTableWidgetItem;
+ addItem(i, DEVCOL_PLAY, itemplay, mdevView);
+ itemplay->setTextAlignment(Qt::AlignHCenter);
+ itemplay->setFlags(Qt::ItemIsEnabled);
+ QTableWidgetItem* itemout = new QTableWidgetItem;
+ addItem(i, DEVCOL_OUTROUTES, itemout, mdevView);
+ itemout->setFlags(Qt::ItemIsEnabled);
+ QTableWidgetItem* itemin = new QTableWidgetItem;
+ addItem(i, DEVCOL_INROUTES, itemin, mdevView);
+ itemin->setFlags(Qt::ItemIsEnabled);
+ QTableWidgetItem* itemdefin = new QTableWidgetItem(bitmap2String(port->defaultInChannels()));
+ addItem(i, DEVCOL_DEF_IN_CHANS, itemdefin, mdevView);
+ itemdefin->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled);
+ QTableWidgetItem* itemdefout = new QTableWidgetItem(bitmap2String(port->defaultOutChannels()));
+ addItem(i, DEVCOL_DEF_OUT_CHANS, itemdefout, mdevView);
+ itemdefout->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled);
+ mdevView->blockSignals(false);
+
+
+ if (dev) {
+ itemname->setText(dev->name());
+
+ // Is it a Jack midi device? Allow renaming.
+ //if(dynamic_cast<MidiJackDevice*>(dev))
+ if (dev->deviceType() == MidiDevice::JACK_MIDI)
+ itemname->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled);
+
+ if (dev->rwFlags() & 0x2)
+ itemrec->setIcon(dev->openFlags() & 2 ? QIcon(*dotIcon) : QIcon(*dothIcon));
+ else
+ itemrec->setIcon(QIcon(QPixmap()));
+ if (dev->rwFlags() & 0x1)
+ itemplay->setIcon( dev->openFlags() & 1 ? QIcon(*dotIcon) : QIcon(*dothIcon));
+ else
+ itemplay->setIcon(QIcon(QPixmap()));
+ }
+ else {
+ itemname->setText(tr("<none>"));
+ itemgui->setIcon(QIcon(*dothIcon));
+ itemrec->setIcon(QIcon(QPixmap()));
+ itemplay->setIcon(QIcon(QPixmap()));
+ }
+ if (port->hasGui()) {
+ itemgui->setIcon(port->guiVisible() ? QIcon(*dotIcon) : QIcon(*dothIcon));
+ }
+ else {
+ itemgui->setIcon(QIcon(QPixmap()));
+ }
+ if (!(dev && dev->isSynti()))
+ iteminstr->setIcon(QIcon(*buttondownIcon));
+ itemname->setIcon(QIcon(*buttondownIcon));
+
+
+ //if(dev && dynamic_cast<MidiJackDevice*>(dev))
+ if(dev && dev->deviceType() == MidiDevice::JACK_MIDI)
+ {
+ //item->setPixmap(DEVCOL_ROUTES, *buttondownIcon);
+ //item->setText(DEVCOL_ROUTES, tr("routes"));
+
+ // p3.3.55
+ if(dev->rwFlags() & 1)
+ //if(dev->openFlags() & 1)
+ {
+ itemout->setIcon(QIcon(*buttondownIcon));
+ if(dev->openFlags() & 1)
+ itemout->setText(tr("out"));
+ }
+ if(dev->rwFlags() & 2)
+ //if(dev->openFlags() & 2)
+ {
+ itemin->setIcon(QIcon(*buttondownIcon));
+ if(dev->openFlags() & 2)
+ itemin->setText(tr("in"));
+ }
+ }
+
+ if(i == no) sitem = itemno;
+ }
+ if(sitem)
+ mdevView->setCurrentItem(sitem);
+
+ QString s;
+ synthList->clear();
+ for (std::vector<Synth*>::iterator i = synthis.begin();
+ i != synthis.end(); ++i) {
+ //s = (*i)->baseName();
+ //s = (*i)->name();
+
+ QTreeWidgetItem* item = new QTreeWidgetItem(synthList);
+ //item->setText(0, s);
+ item->setText(0, QString((*i)->baseName()));
+ s.setNum((*i)->instances());
+ item->setText(1, s);
+ item->setTextAlignment(1, Qt::AlignHCenter);
+ //item->setText(2, QString((*i)->baseName()));
+ item->setText(2, QString((*i)->name()));
+
+ item->setText(3, QString((*i)->version()));
+ item->setText(4, QString((*i)->description()));
+ }
+ instanceList->clear();
+ SynthIList* sl = song->syntis();
+ for (iSynthI si = sl->begin(); si != sl->end(); ++si) {
+ QTreeWidgetItem* iitem = new QTreeWidgetItem(instanceList);
+ iitem->setText(0, (*si)->name());
+ if ((*si)->midiPort() == -1)
+ s = tr("<none>");
+ else
+ s.setNum((*si)->midiPort() + 1);
+ iitem->setText(1, s);
+ iitem->setTextAlignment(1, Qt::AlignHCenter);
+ }
+ synthList->resizeColumnToContents(1);
+ mdevView->resizeColumnsToContents();
+ mdevView->horizontalHeader()->setResizeMode(DEVCOL_NO ,QHeaderView::Fixed);
+ mdevView->horizontalHeader()->setResizeMode(DEVCOL_REC ,QHeaderView::Fixed);
+ mdevView->horizontalHeader()->setResizeMode(DEVCOL_PLAY ,QHeaderView::Fixed);
+ mdevView->horizontalHeader()->setResizeMode(DEVCOL_GUI ,QHeaderView::Fixed);
+ mdevView->horizontalHeader()->setStretchLastSection( true );
+ selectionChanged();
+ }
+
+//---------------------------------------------------------
+// addInstanceClicked
+//---------------------------------------------------------
+
+void MPConfig::addInstanceClicked()
+ {
+ QTreeWidgetItem* item = synthList->currentItem();
+ if (item == 0)
+ return;
+ //SynthI *si = song->createSynthI(item->text(2));
+ SynthI *si = song->createSynthI(item->text(0), item->text(2));
+ if(!si)
+ return;
+
+ // add instance last in midi device list
+ for (int i = 0; i < MIDI_PORTS; ++i) {
+ MidiPort* port = &midiPorts[i];
+ MidiDevice* dev = port->device();
+ if (dev==0) {
+ midiSeq->msgSetMidiDevice(port, si);
+ muse->changeConfig(true); // save configuration file
+ song->update();
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// removeInstanceClicked
+//---------------------------------------------------------
+
+void MPConfig::removeInstanceClicked()
+ {
+ QTreeWidgetItem* item = instanceList->currentItem();
+ if (item == 0)
+ return;
+ SynthIList* sl = song->syntis();
+ iSynthI ii;
+ for (ii = sl->begin(); ii != sl->end(); ++ii) {
+ if ((*ii)->iname() == item->text(0))
+ break;
+ }
+ if (ii == sl->end()) {
+ printf("synthesizerConfig::removeInstanceClicked(): synthi not found\n");
+ return;
+ }
+ audio->msgRemoveTrack(*ii);
+ }
+
+//---------------------------------------------------------
+// configMidiPorts
+//---------------------------------------------------------
+
+void MusE::configMidiPorts()
+ {
+ if (!midiPortConfig) {
+ midiPortConfig = new MPConfig(this);
+ }
+ midiPortConfig->show();
+ midiPortConfig->raise();
+ midiPortConfig->activateWindow();
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/confmport.h b/attic/muse2-oom/muse2/muse/confmport.h
new file mode 100644
index 00000000..d8bd663b
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/confmport.h
@@ -0,0 +1,51 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: confmport.h,v 1.3 2004/01/25 11:20:31 wschweer Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __CONFMPORT_H__
+#define __CONFMPORT_H__
+
+#include <QWidget>
+#include <QToolTip>
+
+#include "ui_synthconfigbase.h"
+
+class QTreeWidget;
+class QTableWidget;
+class QPoint;
+class QMenu;
+class Xml;
+
+//---------------------------------------------------------
+// MPConfig
+// Midi Port Config
+//---------------------------------------------------------
+
+class MPConfig : public QDialog, Ui::SynthConfigBase {
+ QMenu* instrPopup;
+ //QMenu* popup;
+ int _showAliases; // -1: None. 0: First aliases. 1: Second aliases etc.
+ void setWhatsThis(QTableWidgetItem *item, int col);
+ void setToolTip(QTableWidgetItem *item, int col);
+ void addItem(int row, int col, QTableWidgetItem *item, QTableWidget *table);
+
+ Q_OBJECT
+
+ private slots:
+ void rbClicked(QTableWidgetItem*);
+ void mdevViewItemRenamed(QTableWidgetItem*);
+ void songChanged(int);
+ void selectionChanged();
+ void addInstanceClicked();
+ void removeInstanceClicked();
+
+ public:
+ MPConfig(QWidget* parent=0);
+ ~MPConfig();
+ };
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/ctrl.cpp b/attic/muse2-oom/muse2/muse/ctrl.cpp
new file mode 100644
index 00000000..42802829
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/ctrl.cpp
@@ -0,0 +1,322 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: ctrl.cpp,v 1.1.2.4 2009/06/10 00:34:59 terminator356 Exp $
+//
+// controller handling for mixer automation
+//
+// (C) Copyright 2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+
+#include <QLocale>
+#include <QColor>
+//#include <stdlib.h>
+
+#include "globals.h"
+#include "ctrl.h"
+#include "xml.h"
+// #include "audio.h"
+
+void CtrlList::initColor(int i)
+{
+ if (i == 0)
+ _displayColor = Qt::red;
+ else if (i == 1)
+ _displayColor = Qt::yellow;
+ else
+ _displayColor = Qt::black;
+
+ if (i < 2)
+ _visible = true;
+ else
+ _visible = false;
+
+}
+
+
+
+//---------------------------------------------------------
+// CtrlList
+//---------------------------------------------------------
+
+CtrlList::CtrlList(int id)
+ {
+ _id = id;
+ _default = 0.0;
+ _curVal = 0.0;
+ _mode = INTERPOLATE;
+ initColor(id);
+ }
+//---------------------------------------------------------
+// CtrlList
+//---------------------------------------------------------
+CtrlList::CtrlList(int id, QString name, double min, double max, bool dontShow)
+{
+ _id = id;
+ _default = 0.0;
+ _curVal = 0.0;
+ _mode = INTERPOLATE;
+ _name = name;
+ _min = min;
+ _max = max;
+ _dontShow = dontShow;
+ initColor(id);
+}
+//---------------------------------------------------------
+// CtrlList
+//---------------------------------------------------------
+
+CtrlList::CtrlList()
+ {
+ _id = 0;
+ _default = 0.0;
+ _curVal = 0.0;
+ _mode = INTERPOLATE;
+ initColor(0);
+ }
+
+//---------------------------------------------------------
+// value
+//---------------------------------------------------------
+
+double CtrlList::value(int frame)
+ {
+ if (!automation || empty()) {
+ return _curVal;
+ }
+ ciCtrl i = upper_bound(frame);
+ if (i == end()) {
+ ciCtrl i = end();
+ --i;
+ const CtrlVal& val = i->second;
+ _curVal = val.val;
+ }
+ else
+ if(_mode == DISCRETE)
+ {
+ if(i == begin())
+ _curVal = _default;
+ else
+ {
+ --i;
+ const CtrlVal& val = i->second;
+ _curVal = val.val;
+ }
+ }
+ else {
+ int frame2 = i->second.frame;
+ double val2 = i->second.val;
+ int frame1;
+ double val1;
+ if (i == begin()) {
+ frame1 = 0;
+ val1 = _default;
+ }
+ else {
+ --i;
+ frame1 = i->second.frame;
+ val1 = i->second.val;
+ }
+ frame -= frame1;
+ val2 -= val1;
+ frame2 -= frame1;
+ val1 += (frame * val2)/frame2;
+ _curVal = val1;
+ }
+// printf("autoVal %d %f\n", frame, _curVal);
+ return _curVal;
+ }
+
+
+//---------------------------------------------------------
+// setCurVal
+//---------------------------------------------------------
+void CtrlList::setCurVal(double val)
+{
+ _curVal = val;
+ if (size() < 2) {
+ add(0,val);
+ }
+}
+
+//---------------------------------------------------------
+// add
+//---------------------------------------------------------
+
+void CtrlList::add(int frame, double val)
+ {
+// printf("add %d %f\n", frame, val);
+ iCtrl e = find(frame);
+ if (e != end())
+ e->second.val = val;
+ else
+ insert(std::pair<const int, CtrlVal> (frame, CtrlVal(frame, val)));
+ }
+
+//---------------------------------------------------------
+// del
+//---------------------------------------------------------
+
+void CtrlList::del(int /* frame*/)
+ {
+ /*
+ iCtrl e = find(frame);
+ if (e == end()) {
+ printf("CtrlList::del(%d): not found\n", frame);
+ return;
+ }
+ erase(e);
+ */
+ }
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+void CtrlList::read(Xml& xml)
+ {
+ QLocale loc = QLocale::c();
+ bool ok;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::Attribut:
+ if (tag == "id")
+ {
+ //_id = xml.s2().toInt();
+ _id = loc.toInt(xml.s2(), &ok);
+ if(!ok)
+ printf("CtrlList::read failed reading _id string: %s\n", xml.s2().toLatin1().constData());
+ }
+ else if (tag == "cur")
+ {
+ //_curVal = xml.s2().toDouble();
+ _curVal = loc.toDouble(xml.s2(), &ok);
+ if(!ok)
+ printf("CtrlList::read failed reading _curVal string: %s\n", xml.s2().toLatin1().constData());
+ }
+ else
+ printf("unknown tag %s\n", tag.toLatin1().constData());
+ break;
+ case Xml::Text:
+ {
+ // Changed by Tim. Users in some locales reported corrupt reading,
+ // because of the way floating point is represented (2,3456 not 2.3456).
+ /*
+ QByteArray ba = tag.toLatin1();
+ const char* s = ba;.constData();
+ int frame;
+ double val;
+
+ for (;;) {
+ char* endp;
+ while (*s == ' ' || *s == '\n')
+ ++s;
+ if (*s == 0)
+ break;
+ frame = strtol(s, &endp, 10);
+ s = endp;
+ while (*s == ' ' || *s == '\n')
+ ++s;
+ val = strtod(s, &endp);
+ add(frame, val);
+ s = endp;
+ ++s;
+ }
+ */
+
+ // Added by Tim. p3.3.6
+ //printf("CtrlList::read tag:%s\n", tag.toLatin1().constData());
+
+ int len = tag.length();
+ int frame;
+ double val;
+
+ int i = 0;
+ for(;;)
+ {
+ while(i < len && (tag[i] == ',' || tag[i] == ' ' || tag[i] == '\n'))
+ ++i;
+ if(i == len)
+ break;
+
+ QString fs;
+ while(i < len && tag[i] != ' ')
+ {
+ fs.append(tag[i]);
+ ++i;
+ }
+ if(i == len)
+ break;
+
+ // Works OK, but only because if current locale fails it falls back on 'C' locale.
+ // So, let's skip the fallback and force use of 'C' locale.
+ //frame = fs.toInt(&ok);
+ frame = loc.toInt(fs, &ok);
+ if(!ok)
+ {
+ printf("CtrlList::read failed reading frame string: %s\n", fs.toLatin1().constData());
+ break;
+ }
+
+ while(i < len && (tag[i] == ' ' || tag[i] == '\n'))
+ ++i;
+ if(i == len)
+ break;
+
+ QString vs;
+ while(i < len && tag[i] != ' ' && tag[i] != ',')
+ {
+ vs.append(tag[i]);
+ ++i;
+ }
+
+ // Works OK, but only because if current locale fails it falls back on 'C' locale.
+ // So, let's skip the fallback and force use of 'C' locale.
+ //val = vs.toDouble(&ok);
+ val = loc.toDouble(vs, &ok);
+ if(!ok)
+ {
+ printf("CtrlList::read failed reading value string: %s\n", vs.toLatin1().constData());
+ break;
+ }
+
+ // Added by Tim. p3.3.6
+ //printf("CtrlList::read i:%d len:%d fs:%s frame %d: vs:%s val %f \n", i, len, fs.toLatin1().constData(), frame, vs.toLatin1().constData(), val);
+
+ add(frame, val);
+
+ if(i == len)
+ break;
+ }
+ }
+ break;
+ case Xml::TagEnd:
+ if (xml.s1() == "controller")
+ {
+ // Added by Tim. p3.3.6
+ //printf("CtrlList::read _id:%d _curVal:%f\n", _id, _curVal);
+
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// add
+//---------------------------------------------------------
+
+void CtrlListList::add(CtrlList* vl)
+ {
+// printf("CtrlListList(%p)::add(id=%d) size %d\n", this, vl->id(), size());
+ insert(std::pair<const int, CtrlList*>(vl->id(), vl));
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/ctrl.h b/attic/muse2-oom/muse2/muse/ctrl.h
new file mode 100644
index 00000000..c845bb1e
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/ctrl.h
@@ -0,0 +1,155 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: ctrl.h,v 1.4.2.2 2006/10/29 07:54:51 terminator356 Exp $
+//
+// controller for mixer automation
+//
+// (C) Copyright 2003-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __CTRL_H__
+#define __CTRL_H__
+
+#include <map>
+#include <list>
+#include <qcolor.h>
+
+const int AC_VOLUME = 0;
+const int AC_PAN = 1;
+const int AC_MUTE = 2;
+
+#define AC_PLUGIN_CTL_BASE 0x1000
+#define AC_PLUGIN_CTL_BASE_POW 12
+#define AC_PLUGIN_CTL_ID_MASK 0xFFF
+
+inline int genACnum(int plugin, int ctrl) { return (plugin + 1) * AC_PLUGIN_CTL_BASE + ctrl; }
+
+class Xml;
+
+enum CtrlValueType { VAL_LOG, VAL_LINEAR, VAL_INT, VAL_BOOL };
+enum CtrlRecValueType { ARVT_VAL, ARVT_START, ARVT_STOP };
+
+//---------------------------------------------------------
+// CtrlVal
+// controller "event"
+//---------------------------------------------------------
+
+struct CtrlVal {
+ int frame;
+ double val;
+ CtrlVal(int f, double v) {
+ frame = f;
+ val = v;
+ }
+ };
+
+//---------------------------------------------------------
+// CtrlRecVal
+// recorded controller event, mixer automation
+//---------------------------------------------------------
+
+struct CtrlRecVal : public CtrlVal {
+ int id;
+ CtrlRecValueType type; // 0 - ctrlVal, 1 - start, 2 - end
+ CtrlRecVal(int f, int n, double v) : CtrlVal(f, v), id(n), type(ARVT_VAL) {}
+ CtrlRecVal(int f, int n, double v, CtrlRecValueType t) : CtrlVal(f, v), id(n), type(t) {}
+ };
+
+//---------------------------------------------------------
+// CtrlRecList
+//---------------------------------------------------------
+
+class CtrlRecList : public std::list<CtrlRecVal> {
+ public:
+ };
+
+typedef CtrlRecList::iterator iCtrlRec;
+
+//---------------------------------------------------------
+// CtrlList
+// arrange controller events of a specific type in a
+// list for easy retrieval
+//---------------------------------------------------------
+
+typedef std::map<int, CtrlVal, std::less<int> >::iterator iCtrl;
+typedef std::map<int, CtrlVal, std::less<int> >::const_iterator ciCtrl;
+
+class CtrlList : public std::map<int, CtrlVal, std::less<int> > {
+ public:
+ enum Mode { INTERPOLATE, DISCRETE};
+
+ private:
+ Mode _mode;
+ int _id;
+ double _default;
+ double _curVal;
+ void del(CtrlVal);
+ QString _name;
+ double _min, _max;
+ CtrlValueType _valueType;
+ QColor _displayColor;
+ bool _visible;
+ bool _dontShow; // when this is true the control exists but is not compatible with viewing in the arranger
+ void initColor(int i);
+
+ public:
+ CtrlList();
+ CtrlList(int id);
+ CtrlList(int id, QString name, double min, double max, bool dontShow=false);
+
+ Mode mode() const { return _mode; }
+ void setMode(Mode m) { _mode = m; }
+ double getDefault() const { return _default; }
+ void setDefault(double val) { _default = val; }
+ double curVal() const { return _curVal; }
+ void setCurVal(double val); // { _curVal = val; }
+ int id() const { return _id; }
+ QString name() const { return _name; }
+ void setName(const QString& s) { _name = s; }
+ void setRange(double min, double max) {
+ _min = min;
+ _max = max;
+ }
+ void range(double* min, double* max) const {
+ *min = _min;
+ *max = _max;
+ }
+ CtrlValueType valueType() const { return _valueType; }
+ void setValueType(CtrlValueType t) { _valueType = t; }
+
+ double value(int frame);
+ void add(int tick, double value);
+ void del(int tick);
+ void read(Xml& xml);
+
+ void setColor( QColor c ) { _displayColor = c;}
+ QColor color() { return _displayColor; }
+ void setVisible(bool v) { _visible = v; }
+ bool isVisible() { return _visible; }
+ bool dontShow() { return _dontShow; }
+ };
+
+//---------------------------------------------------------
+// CtrlListList
+// List of controller value lists.
+// This list represents the controller state of a
+// mixer strip
+//---------------------------------------------------------
+
+typedef std::map<int, CtrlList*, std::less<int> >::iterator iCtrlList;
+typedef std::map<int, CtrlList*, std::less<int> >::const_iterator ciCtrlList;
+
+class CtrlListList : public std::map<int, CtrlList*, std::less<int> > {
+ public:
+ void add(CtrlList* vl);
+ iCtrlList find(int id) {
+ return std::map<int, CtrlList*, std::less<int> >::find(id);
+ }
+ ciCtrlList find(int id) const {
+ return std::map<int, CtrlList*, std::less<int> >::find(id);
+ }
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/ctrl/CMakeLists.txt b/attic/muse2-oom/muse2/muse/ctrl/CMakeLists.txt
new file mode 100644
index 00000000..731632f7
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/ctrl/CMakeLists.txt
@@ -0,0 +1,85 @@
+#=============================================================================
+# MusE
+# Linux Music Editor
+# $Id:$
+#
+# Copyright (C) 2002-2006 by Werner Schweer and others
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#=============================================================================
+
+##
+## Expand Qt macros in source files
+##
+QT4_WRAP_CPP (ctrl_mocs
+ # configmidictrl.h
+ # ctrldialog.h
+ # definemidictrl.h
+ ctrlcanvas.h
+ ctrledit.h
+ ctrlpanel.h
+ )
+
+##
+## List of source files to compile
+##
+file (GLOB ctrl_source_files
+ ctrlcanvas.cpp
+ ctrledit.cpp
+ ctrlpanel.cpp
+ )
+
+##
+## Define target
+##
+add_library ( ctrl SHARED
+ # configmidictrl.cpp
+ # definemidictrl.cpp
+ # ctrldialog.cpp
+ # ctrleditor.cpp
+ ${ctrl_source_files}
+ ${ctrl_mocs}
+ )
+
+##
+## Append to the list of translations
+##
+set (FILES_TO_TRANSLATE
+ ${FILES_TO_TRANSLATE}
+ ${ctrl_source_files}
+ CACHE INTERNAL ""
+ )
+
+##
+## Compilation flags and target name
+##
+set_target_properties( ctrl
+ PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h -fPIC"
+ OUTPUT_NAME muse_ctrl
+ )
+
+##
+## Linkage
+##
+target_link_libraries ( ctrl
+ ${QT_LIBRARIES}
+ widgets
+ )
+
+##
+## Install location
+##
+install(TARGETS ctrl
+ DESTINATION ${MusE_MODULES_DIR}
+ )
+
diff --git a/attic/muse2-oom/muse2/muse/ctrl/ctrlcanvas.cpp b/attic/muse2-oom/muse2/muse/ctrl/ctrlcanvas.cpp
new file mode 100644
index 00000000..9317ade7
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/ctrl/ctrlcanvas.cpp
@@ -0,0 +1,1629 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: ctrlcanvas.cpp,v 1.15.2.10 2009/11/14 03:37:48 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <values.h>
+
+#include <QPainter>
+#include <QCursor>
+#include <QMouseEvent>
+
+#include "globals.h"
+#include "ctrledit.h"
+#include "midieditor.h"
+#include "icons.h"
+#include "midiport.h"
+#include "song.h"
+#include "midictrl.h"
+#include "audio.h"
+#include "gconfig.h"
+#include "ctrlpanel.h"
+#include "midiedit/drummap.h"
+
+extern void drawTickRaster(QPainter& p, int x, int y,
+ int w, int h, int quant);
+
+static MidiCtrlValList veloList(CTRL_VELOCITY); // dummy
+
+//---------------------------------------------------------
+// computeVal
+//---------------------------------------------------------
+
+static int computeVal(MidiController* mc, int y, int height)
+ {
+ int min; int max;
+ if(mc->num() == CTRL_PROGRAM)
+ {
+ min = 1;
+ max = 128;
+ }
+ else
+ {
+ min = mc->minVal();
+ max = mc->maxVal();
+ }
+ int val = max - (y * (max-min) / height);
+ if (val < min)
+ val = min;
+ if (val > max)
+ val = max;
+ if(mc->num() != CTRL_PROGRAM)
+ val += mc->bias();
+ return val;
+ }
+
+//---------------------------------------------------------
+// CEvent
+//---------------------------------------------------------
+
+CEvent::CEvent(Event e, MidiPart* pt, int v)
+ {
+ _event = e;
+ _part = pt;
+ _val = v;
+ ex = !e.empty() ? e.tick() : 0;
+ }
+
+//---------------------------------------------------------
+// contains
+//---------------------------------------------------------
+
+bool CEvent::contains(int x1, int x2) const
+ {
+ int tick1 = !_event.empty() ? _event.tick() + _part->tick() : 0;
+ if(ex == -1)
+ return (tick1 < x2);
+
+ int tick2 = ex + _part->tick();
+ return ((tick1 >= x1 && tick1 < x2)
+ //|| (tick2 >= x1 && tick2 < x2)
+ || (tick2 > x1 && tick2 < x2)
+ || (tick1 < x1 && tick2 >= x2));
+ }
+
+//---------------------------------------------------------
+// clearDelete
+//---------------------------------------------------------
+
+void CEventList::clearDelete()
+{
+ for(ciCEvent i = begin(); i != end(); ++i)
+ {
+ CEvent* ce = *i;
+ if(ce)
+ delete ce;
+ }
+ clear();
+}
+
+//---------------------------------------------------------
+// CtrlCanvas
+//---------------------------------------------------------
+
+CtrlCanvas::CtrlCanvas(MidiEditor* e, QWidget* parent, int xmag,
+ const char* name, CtrlPanel* pnl) : View(parent, xmag, 1, name)
+ {
+ setBg(QColor(195,198,196));
+
+ editor = e;
+ drag = DRAG_OFF;
+ tool = PointerTool;
+ pos[0] = 0;
+ pos[1] = 0;
+ pos[2] = 0;
+ noEvents=false;
+
+ ctrl = &veloList;
+ _controller = &veloCtrl;
+ _panel = pnl;
+ _cnum = CTRL_VELOCITY;
+ _dnum = CTRL_VELOCITY;
+ _didx = CTRL_VELOCITY;
+ connect(song, SIGNAL(posChanged(int, unsigned, bool)), this, SLOT(setPos(int, unsigned, bool)));
+
+ setMouseTracking(true);
+ if (editor->parts()->empty()) {
+ curPart = 0;
+ curTrack = 0;
+ }
+ else {
+ setCurTrackAndPart();
+ }
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+
+ curDrumInstrument = editor->curDrumInstrument();
+ //printf("CtrlCanvas::CtrlCanvas curDrumInstrument:%d\n", curDrumInstrument);
+
+ connect(editor, SIGNAL(curDrumInstrumentChanged(int)), SLOT(setCurDrumInstrument(int)));
+ updateItems();
+ }
+
+//---------------------------------------------------------
+// setPos
+// set one of three markers
+// idx - 0-cpos 1-lpos 2-rpos
+// flag - emit followEvent()
+//---------------------------------------------------------
+
+void CtrlCanvas::setPos(int idx, unsigned val, bool adjustScrollbar)
+ {
+ if (pos[idx] == val)
+ return;
+
+ int opos = mapx(pos[idx]);
+ int npos = mapx(val);
+
+ if (adjustScrollbar && idx == 0) {
+ switch (song->follow()) {
+ case Song::NO:
+ break;
+ case Song::JUMP:
+ if (npos >= width()) {
+ int ppos = val - rmapxDev(width()/4);
+ if (ppos < 0)
+ ppos = 0;
+ emit followEvent(ppos);
+ opos = mapx(pos[idx]);
+ npos = mapx(val);
+ }
+ else if (npos < 0) {
+ int ppos = val - rmapxDev(width()*3/4);
+ if (ppos < 0)
+ ppos = 0;
+ emit followEvent(ppos);
+ opos = mapx(pos[idx]);
+ npos = mapx(val);
+ }
+ break;
+ case Song::CONTINUOUS:
+ if (npos > (width()*5)/8) {
+ int ppos = pos[idx] - rmapxDev(width()*5/8);
+ if (ppos < 0)
+ ppos = 0;
+ emit followEvent(ppos);
+ opos = mapx(pos[idx]);
+ npos = mapx(val);
+ }
+ else if (npos < (width()*3)/8) {
+ int ppos = pos[idx] - rmapxDev(width()*3/8);
+ if (ppos < 0)
+ ppos = 0;
+ emit followEvent(ppos);
+ opos = mapx(pos[idx]);
+ npos = mapx(val);
+ }
+ break;
+ }
+ }
+
+ int x;
+ int w = 1;
+ if (opos > npos) {
+ w += opos - npos;
+ x = npos;
+ }
+ else {
+ w += npos - opos;
+ x = opos;
+ }
+ pos[idx] = val;
+ redraw(QRect(x, 0, w, height()));
+ }
+
+//---------------------------------------------------------
+// setMidiController
+//---------------------------------------------------------
+
+void CtrlCanvas::setMidiController(int num)
+ {
+ _cnum = num;
+ partControllers(curPart, _cnum, &_dnum, &_didx, &_controller, &ctrl);
+ if(_panel)
+ {
+ if(_cnum == CTRL_VELOCITY)
+ _panel->setHWController(curTrack, &veloCtrl);
+ else
+ _panel->setHWController(curTrack, _controller);
+ }
+ }
+
+//---------------------------------------------------------
+// leaveEvent
+//---------------------------------------------------------
+
+void CtrlCanvas::leaveEvent(QEvent*)
+ {
+ emit xposChanged(MAXINT);
+ emit yposChanged(-1);
+ }
+
+//---------------------------------------------------------
+// raster
+//---------------------------------------------------------
+
+QPoint CtrlCanvas::raster(const QPoint& p) const
+ {
+ return p;
+ }
+
+//---------------------------------------------------------
+// deselectAll
+//---------------------------------------------------------
+
+void CtrlCanvas::deselectAll()
+ {
+// for (iCEvent i = selection.begin(); i != selection.end(); ++i)
+// (*i)->setState(CEvent::Normal);
+// selection.clear();
+// update();
+ }
+
+//---------------------------------------------------------
+// selectItem
+//---------------------------------------------------------
+
+void CtrlCanvas::selectItem(CEvent*)
+ {
+// e->setState(CEvent::Selected);
+// selection.push_back(e);
+// update();
+ }
+
+//---------------------------------------------------------
+// deselectItem
+//---------------------------------------------------------
+
+void CtrlCanvas::deselectItem(CEvent*)
+ {
+/* e->setState(CEvent::Normal);
+ for (iCEvent i = selection.begin(); i != selection.end(); ++i) {
+ if (*i == e) {
+ selection.erase(i);
+ break;
+ }
+ }
+ update();
+ */
+ }
+
+//---------------------------------------------------------
+// setController
+//---------------------------------------------------------
+
+void CtrlCanvas::setController(int num)
+{
+ setMidiController(num);
+ updateItems();
+}
+
+
+//---------------------------------------------------------
+// setCurTrackAndPart
+//---------------------------------------------------------
+
+bool CtrlCanvas::setCurTrackAndPart()
+{
+ bool changed = false;
+ MidiPart* part = 0;
+ MidiTrack* track = 0;
+
+ if(!editor->parts()->empty())
+ {
+ Part* pt = editor->curCanvasPart();
+ if(pt && pt->track())
+ {
+ if(pt->track()->isMidiTrack())
+ {
+ part = (MidiPart*)pt;
+ track = part->track();
+ }
+ }
+ }
+
+ if(part != curPart)
+ {
+ curPart = part;
+ changed = true;
+ }
+
+ if(track != curTrack)
+ {
+ curTrack = track;
+ changed = true;
+ }
+
+ return changed;
+}
+
+//---------------------------------------------------------
+// songChanged
+// all marked parts are added to the internal event list
+//---------------------------------------------------------
+
+void CtrlCanvas::songChanged(int type)
+{
+ // Is it simply a midi controller value adjustment? Forget it.
+ if(type == SC_MIDI_CONTROLLER)
+ return;
+
+ bool changed = false;
+ if(type & (SC_CONFIG | SC_PART_MODIFIED | SC_SELECTION))
+ changed = setCurTrackAndPart();
+
+ // Although changing the instrument/device in the
+ // config window generates a type of -1, we can eliminate
+ // some other useless calls using SC_CONFIG, which was not used
+ // anywhere else in muse before now, except song header.
+ if((type & (SC_CONFIG | SC_DRUMMAP)) || ((type & (SC_PART_MODIFIED | SC_SELECTION)) && changed))
+ {
+ setMidiController(_cnum);
+ //return;
+ }
+
+ updateItems();
+
+}
+
+//---------------------------------------------------------
+// partControllers
+//---------------------------------------------------------
+
+void CtrlCanvas::partControllers(const MidiPart* part, int num, int* dnum, int* didx, MidiController** mc, MidiCtrlValList** mcvl)
+{
+ if(num == CTRL_VELOCITY) // special case
+ {
+ if(mcvl)
+ *mcvl = &veloList;
+ if(mc)
+ *mc = &veloCtrl;
+ if(dnum)
+ *dnum = num;
+ if(didx)
+ *didx = num;
+ }
+ else
+ {
+ MidiTrack* mt = part->track();
+ MidiPort* mp;
+ int di;
+ int n;
+
+ if((mt->type() != Track::DRUM) && curDrumInstrument != -1)
+ printf("keyfilter != -1 in non drum track?\n");
+
+ if((mt->type() == Track::DRUM) && (curDrumInstrument != -1) && ((num & 0xff) == 0xff))
+ {
+ di = (num & ~0xff) | curDrumInstrument;
+ n = (num & ~0xff) | drumMap[curDrumInstrument].anote; // construct real controller number
+ //num = (num & ~0xff) | curDrumInstrument); // construct real controller number
+ mp = &midiPorts[drumMap[curDrumInstrument].port];
+ }
+ else
+ {
+ di = num;
+ n = num;
+ mp = &midiPorts[mt->outPort()];
+ }
+
+ if(dnum)
+ *dnum = n;
+
+ if(didx)
+ *didx = di;
+
+ if(mc)
+ *mc = mp->midiController(n);
+
+ if(mcvl)
+ {
+ MidiCtrlValList* tmcvl = 0;
+ MidiCtrlValListList* cvll = mp->controller();
+ for(iMidiCtrlValList i = cvll->begin(); i != cvll->end(); ++i)
+ {
+ if(i->second->num() == n)
+ {
+ tmcvl = i->second;
+ break;
+ }
+ }
+ *mcvl = tmcvl;
+
+ // Removed by T356.
+ // MidiCtrlValList not found is now an acceptable state (for multiple part editing).
+ //if (i == cvll->end()) {
+ // printf("CtrlCanvas::setController(0x%x): not found\n", num);
+ // for (i = cvll->begin(); i != cvll->end(); ++i)
+ // printf(" 0x%x\n", i->second->num());
+ // return;
+ // }
+ }
+ }
+}
+
+//---------------------------------------------------------
+// updateItems
+//---------------------------------------------------------
+
+void CtrlCanvas::updateItems()
+ {
+ items.clearDelete();
+
+ /*
+ if(ctrl)
+ {
+ for(ciMidiCtrlVal imcv = ctrl->begin(); imcv != ctrl->end(); ++imcv)
+ {
+ MidiPart* part = (MidiPart*)imcv->part;
+ int val = imcv->val;
+
+ bool edpart = false;
+ if(editor->parts()->index(part) != -1)
+ edpart = true;
+
+ MidiController* mc;
+ MidiCtrlValList* mcvl;
+ partControllers(part, _cnum, 0, 0, &mc, &mcvl);
+
+ Event e(Controller);
+
+ if(_cnum == CTRL_VELOCITY && e.type() == Note)
+ {
+ items.add(new CEvent(e, part, e.velo()));
+
+ }
+
+ }
+ }
+ */
+
+ /*
+ MidiTrackList* mtl = song->midis();
+ for(ciMidiTrack imt = mtl->begin(); imt != mtl->end(); ++imt)
+ {
+ //MidiTrack* mt = *imt;
+ PartList* pl = (*imt)->parts();
+ for(ciPart p = pl->begin(); p != pl->end(); ++p)
+ {
+ MidiPart* part = (MidiPart*)(p->second);
+
+ bool edpart = false;
+ if(editor->parts()->index(part) != -1)
+ edpart = true;
+
+ EventList* el = part->events();
+ MidiController* mc;
+ MidiCtrlValList* mcvl;
+ partControllers(part, _cnum, 0, 0, &mc, &mcvl);
+
+ for(iEvent i = el->begin(); i != el->end(); ++i)
+ {
+ Event e = i->second;
+ if(_cnum == CTRL_VELOCITY && e.type() == Note)
+ {
+ if(curDrumInstrument == -1)
+ {
+ items.add(new CEvent(e, part, e.velo()));
+ }
+ else if (e.dataA() == curDrumInstrument) //same note
+ items.add(new CEvent(e, part, e.velo()));
+ }
+ else if (e.type() == Controller && e.dataA() == _didx)
+ {
+ if(mcvl && last.empty())
+ {
+ Event le(Controller);
+ //le.setType(Controller);
+ le.setA(_didx);
+ //le.setB(e.dataB());
+ le.setB(CTRL_VAL_UNKNOWN);
+ //lastce = new CEvent(Event(), part, mcvl->value(part->tick(), part));
+ //lastce = new CEvent(le, part, mcvl->value(part->tick(), part));
+ lastce = new CEvent(le, part, mcvl->value(part->tick()));
+ items.add(lastce);
+ }
+ if (lastce)
+ lastce->setEX(e.tick());
+ lastce = new CEvent(e, part, e.dataB());
+ items.add(lastce);
+ last = e;
+ }
+ }
+ }
+ }
+ */
+
+
+
+
+
+ if(!editor->parts()->empty())
+ {
+ //Event last;
+ //CEvent* lastce = 0;
+
+ for (iPart p = editor->parts()->begin(); p != editor->parts()->end(); ++p)
+ {
+ Event last;
+ CEvent* lastce = 0;
+
+ MidiPart* part = (MidiPart*)(p->second);
+ EventList* el = part->events();
+ MidiController* mc;
+ MidiCtrlValList* mcvl;
+ partControllers(part, _cnum, 0, 0, &mc, &mcvl);
+ unsigned len = part->lenTick();
+
+ for (iEvent i = el->begin(); i != el->end(); ++i)
+ {
+ Event e = i->second;
+ // Added by T356. Do not add events which are past the end of the part.
+ if(e.tick() >= len)
+ break;
+
+ if(_cnum == CTRL_VELOCITY && e.type() == Note)
+ {
+ //printf("CtrlCanvas::updateItems CTRL_VELOCITY curDrumInstrument:%d\n", curDrumInstrument);
+ if(curDrumInstrument == -1)
+ {
+ // This is interesting - it would allow ALL drum note velocities to be shown.
+ // But currently the drum list ALWAYS has a selected item so this is not supposed to happen.
+ items.add(new CEvent(e, part, e.velo()));
+ }
+ else if (e.dataA() == curDrumInstrument) //same note
+ items.add(new CEvent(e, part, e.velo()));
+ }
+ else if (e.type() == Controller && e.dataA() == _didx)
+ {
+ if(mcvl && last.empty())
+ {
+ lastce = new CEvent(Event(), part, mcvl->value(part->tick()));
+ items.add(lastce);
+ }
+ if (lastce)
+ lastce->setEX(e.tick());
+ lastce = new CEvent(e, part, e.dataB());
+ lastce->setEX(-1);
+ items.add(lastce);
+ last = e;
+ }
+ }
+ }
+ }
+
+
+ redraw();
+ }
+
+//---------------------------------------------------------
+// viewMousePressEvent
+//---------------------------------------------------------
+
+void CtrlCanvas::viewMousePressEvent(QMouseEvent* event)
+ {
+ start = event->pos();
+ Tool activeTool = tool;
+ bool shift = event->modifiers() & Qt::ShiftModifier;
+
+ int xpos = start.x();
+ int ypos = start.y();
+
+ MidiController::ControllerType type = midiControllerType(_controller->num());
+
+ switch (activeTool) {
+ case PointerTool:
+ drag = DRAG_LASSO_START;
+ break;
+
+ case PencilTool:
+ if (shift) {
+ if (type != MidiController::Velo) {
+ drag = DRAG_NEW;
+ song->startUndo();
+ newVal(xpos, xpos, ypos);
+ }
+ }
+ else {
+ drag = DRAG_RESIZE;
+ song->startUndo();
+ changeVal(xpos, xpos, ypos);
+ }
+ break;
+
+ case RubberTool:
+ if (type != MidiController::Velo) {
+ drag = DRAG_DELETE;
+ song->startUndo();
+ deleteVal(xpos, xpos, ypos);
+ }
+ break;
+
+ case DrawTool:
+ if (drawLineMode) {
+ line2x = xpos;
+ line2y = ypos;
+ if (shift)
+ newValRamp(line1x, line1y, line2x, line2y);
+ else
+ changeValRamp(line1x, line1y, line2x, line2y);
+ drawLineMode = false;
+ }
+ else {
+ line2x = line1x = xpos;
+ line2y = line1y = ypos;
+ drawLineMode = true;
+ }
+ redraw();
+ break;
+
+ default:
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// newValRamp
+//---------------------------------------------------------
+
+void CtrlCanvas::newValRamp(int x1, int y1, int x2, int y2)
+ {
+ int xx1 = editor->rasterVal1(x1);
+ int xx2 = editor->rasterVal2(x2);
+ int type = _controller->num();
+
+ int raster = editor->raster();
+ if (raster == 1) // set reasonable raster
+ raster = config.division/4;
+
+ song->startUndo();
+
+ // delete existing events
+
+ int lastpv = CTRL_VAL_UNKNOWN;
+ for (ciCEvent i = items.begin(); i != items.end(); ++i) {
+ CEvent* ev = *i;
+ if(ev->part() != curPart)
+ continue;
+ Event event = ev->event();
+ if (event.empty())
+ continue;
+ int x = event.tick() + curPart->tick();
+ // Added by Tim. p3.3.6
+ //printf("CtrlCanvas::newValRamp x:%d xx1:%d xx2:%d len:%d\n", x, xx1, xx2, curPart->lenTick());
+
+ if (x < xx1)
+ {
+ // if(event.dataB() != CTRL_VAL_UNKNOWN)
+ // lastpv = event.dataB();
+ continue;
+ }
+ //if (x <= xx1)
+ //{
+ // if(type == CTRL_PROGRAM && event.dataB() != CTRL_VAL_UNKNOWN && ((event.dataB() & 0xffffff) != 0xffffff))
+ // lastpv = event.dataB();
+ // if (x < xx1)
+ // continue;
+ //}
+ if (x >= xx2)
+ break;
+
+ // Indicate no undo, and do port controller values and clone parts.
+ //audio->msgDeleteEvent(event, ev->part(), false);
+ audio->msgDeleteEvent(event, curPart, false, true, true);
+ }
+
+ //if(type == CTRL_PROGRAM && lastpv == CTRL_VAL_UNKNOWN)
+ if(ctrl)
+ lastpv = ctrl->hwVal();
+
+ // insert new events
+ for (int x = xx1; x < xx2; x += raster) {
+ int y = (x2==x1) ? y1 : (((y2-y1)*(x-x1))/(x2-x1))+y1;
+ int nval = computeVal(_controller, y, height());
+ int tick = x - curPart->tick();
+ // Do not add events which are past the end of the part.
+ if((unsigned)tick >= curPart->lenTick())
+ break;
+ Event event(Controller);
+ event.setTick(tick);
+ event.setA(_didx);
+ if(type == CTRL_PROGRAM)
+ {
+ if(lastpv == CTRL_VAL_UNKNOWN)
+ {
+ if(song->mtype() == MT_GM)
+ event.setB(0xffff00 | (nval - 1));
+ else
+ event.setB(nval - 1);
+ }
+ else
+ event.setB((lastpv & 0xffff00) | (nval - 1));
+ }
+ else
+ event.setB(nval);
+
+ // Indicate no undo, and do port controller values and clone parts.
+ //audio->msgAddEvent(event, curPart, false);
+ audio->msgAddEvent(event, curPart, false, true, true);
+ }
+
+ song->update(0);
+ redraw();
+ song->endUndo(SC_EVENT_MODIFIED | SC_EVENT_INSERTED | SC_EVENT_REMOVED);
+ }
+
+//---------------------------------------------------------
+// changeValRamp
+//---------------------------------------------------------
+
+void CtrlCanvas::changeValRamp(int x1, int y1, int x2, int y2)
+ {
+ int h = height();
+ bool changed = false;
+ int type = _controller->num();
+ //int xx1 = editor->rasterVal1(x1);
+
+ song->startUndo();
+ for (ciCEvent i = items.begin(); i != items.end(); ++i) {
+ if ((*i)->contains(x1, x2)) {
+ //if ((*i)->contains(xx1, x2)) {
+ CEvent* ev = *i;
+ if(ev->part() != curPart)
+ continue;
+ Event event = ev->event();
+ if (event.empty())
+ continue;
+
+ //MidiPart* part = ev->part();
+ //int x = event.tick() + ev->part()->tick();
+ int x = event.tick() + curPart->tick();
+ int y = (x2==x1) ? y1 : (((y2-y1)*(x-x1))/(x2-x1))+y1;
+ int nval = computeVal(_controller, y, h);
+ if(type == CTRL_PROGRAM)
+ {
+ if(event.dataB() == CTRL_VAL_UNKNOWN)
+ {
+ --nval;
+ if(song->mtype() == MT_GM)
+ nval |= 0xffff00;
+ }
+ else
+ nval = (event.dataB() & 0xffff00) | (nval - 1);
+ }
+
+ ev->setVal(nval);
+
+ //MidiController::ControllerType type = midiControllerType(_controller->num());
+ //if (type == MidiController::Velo) {
+ if (type == CTRL_VELOCITY) {
+ if ((event.velo() != nval)) {
+ Event newEvent = event.clone();
+ newEvent.setVelo(nval);
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(event, newEvent, part, false);
+ audio->msgChangeEvent(event, newEvent, curPart, false, false, false);
+ ev->setEvent(newEvent);
+ changed = true;
+ }
+ }
+ else {
+ if (!event.empty()) {
+ if ((event.dataB() != nval)) {
+ Event newEvent = event.clone();
+ newEvent.setB(nval);
+ // Indicate no undo, and do port controller values and clone parts.
+ //audio->msgChangeEvent(event, newEvent, part, false);
+ audio->msgChangeEvent(event, newEvent, curPart, false, true, true);
+ ev->setEvent(newEvent);
+ changed = true;
+ }
+ }
+ else {
+ //if(!ctrl)
+ //{
+ // ctrl =
+ //}
+
+ // Removed by T356. Never gets here? A good thing, don't wan't auto-create values.
+ //int oval = ctrl->value(0);
+ //if (oval != nval) {
+ // Changed by T356.
+ //ctrl->add(0, nval);
+ // ctrl->add(0, nval, part);
+ // changed = true;
+ // }
+
+ }
+ }
+ }
+ }
+ if (changed)
+ redraw();
+ song->endUndo(SC_EVENT_MODIFIED);
+ }
+
+//---------------------------------------------------------
+// viewMouseMoveEvent
+//---------------------------------------------------------
+
+void CtrlCanvas::viewMouseMoveEvent(QMouseEvent* event)
+ {
+ QPoint pos = event->pos();
+ QPoint dist = pos - start;
+ bool moving = dist.y() >= 3 || dist.y() <= 3 || dist.x() >= 3 || dist.x() <= 3;
+ switch (drag) {
+ case DRAG_LASSO_START:
+ if (!moving)
+ break;
+ drag = DRAG_LASSO;
+ // weiter mit DRAG_LASSO:
+ case DRAG_LASSO:
+ lasso.setRect(start.x(), start.y(), dist.x(), dist.y());
+ redraw();
+ break;
+ case DRAG_RESIZE:
+ changeVal(start.x(), pos.x(), pos.y());
+ start = pos;
+ break;
+
+ case DRAG_NEW:
+ newVal(start.x(), pos.x(), pos.y());
+ start = pos;
+ break;
+
+ case DRAG_DELETE:
+ deleteVal(start.x(), pos.x(), pos.y());
+ start = pos;
+ break;
+
+ default:
+ break;
+ }
+ if (tool == DrawTool && drawLineMode) {
+ line2x = pos.x();
+ line2y = pos.y();
+ redraw();
+ }
+ emit xposChanged(pos.x());
+
+
+ int val = computeVal(_controller, pos.y(), height());
+ emit yposChanged(val);
+ }
+
+//---------------------------------------------------------
+// viewMouseReleaseEvent
+//---------------------------------------------------------
+
+void CtrlCanvas::viewMouseReleaseEvent(QMouseEvent* event)
+ {
+ bool shift = event->modifiers() & Qt::ShiftModifier;
+
+ switch (drag) {
+ case DRAG_RESIZE:
+ case DRAG_NEW:
+ case DRAG_DELETE:
+ song->endUndo(SC_EVENT_MODIFIED | SC_EVENT_INSERTED);
+ break;
+
+ case DRAG_LASSO_START:
+ lasso.setRect(-1, -1, -1, -1);
+
+ case DRAG_LASSO:
+ if (!shift)
+ deselectAll();
+ lasso = lasso.normalized();
+ for (iCEvent i = items.begin(); i != items.end(); ++i) {
+#if 0
+ if ((*i)->intersects(lasso)) {
+ if (shift && (*i)->isSelected())
+ deselectItem(*i);
+ else
+ selectItem(*i);
+ }
+#endif
+ }
+ drag = DRAG_OFF;
+ redraw();
+ break;
+
+ default:
+ break;
+ }
+ drag = DRAG_OFF;
+ }
+
+//---------------------------------------------------------
+// changeVal
+//---------------------------------------------------------
+
+void CtrlCanvas::changeVal(int x1, int x2, int y)
+ {
+ bool changed = false;
+ int newval = computeVal(_controller, y, height());
+ int type = _controller->num();
+ //int xx1 = editor->rasterVal1(x1);
+
+ for (ciCEvent i = items.begin(); i != items.end(); ++i) {
+ if (!(*i)->contains(x1, x2))
+ //if (!(*i)->contains(xx1, x2))
+ continue;
+ CEvent* ev = *i;
+ if(ev->part() != curPart)
+ continue;
+ Event event = ev->event();
+ //if(event.tick() >= curPart->lenTick())
+ // break;
+
+ //MidiPart* part = ev->part();
+ //int nval = newval;
+ //if(type == CTRL_PROGRAM)
+ //{
+ // if(event.dataB() == CTRL_VAL_UNKNOWN)
+ // {
+ // --nval;
+ // if(song->mtype() == MT_GM)
+ // nval |= 0xffff00;
+ // }
+ // else
+ // nval = (event.dataB() & 0xffff00) | (nval - 1);
+ //}
+ //ev->setVal(nval);
+
+ //MidiController::ControllerType type = midiControllerType(_controller->num());
+ //if (type == MidiController::Velo) {
+ if (type == CTRL_VELOCITY) {
+ if ((event.velo() != newval)) {
+ ev->setVal(newval);
+ Event newEvent = event.clone();
+ newEvent.setVelo(newval);
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(event, newEvent, part, false);
+ audio->msgChangeEvent(event, newEvent, curPart, false, false, false);
+ ev->setEvent(newEvent);
+ changed = true;
+ }
+ }
+ else {
+ if (!event.empty()) {
+ int nval = newval;
+ if(type == CTRL_PROGRAM)
+ {
+ if(event.dataB() == CTRL_VAL_UNKNOWN)
+ {
+ --nval;
+ if(song->mtype() == MT_GM)
+ nval |= 0xffff00;
+ }
+ else
+ nval = (event.dataB() & 0xffff00) | (nval - 1);
+ }
+ ev->setVal(nval);
+
+ if ((event.dataB() != nval)) {
+ Event newEvent = event.clone();
+ newEvent.setB(nval);
+ // Indicate no undo, and do port controller values and clone parts.
+ //audio->msgChangeEvent(event, newEvent, part, false);
+ audio->msgChangeEvent(event, newEvent, curPart, false, true, true);
+ ev->setEvent(newEvent);
+ changed = true;
+ }
+ }
+ else {
+ //if(!ctrl)
+ //{
+ // ctrl =
+ //}
+
+ // Removed by T356. Never gets here? A good thing, don't wan't auto-create values.
+ //int oval = ctrl->value(0);
+ //if (oval != nval) {
+ // Changed by T356.
+ //ctrl->add(0, nval);
+ // ctrl->add(0, nval, part);
+ // changed = true;
+ // }
+ }
+ }
+ }
+ if (changed)
+ redraw();
+ }
+
+//---------------------------------------------------------
+// newVal
+//---------------------------------------------------------
+
+void CtrlCanvas::newVal(int x1, int x2, int y)
+ {
+ int xx1 = editor->rasterVal1(x1);
+ int xx2 = editor->rasterVal2(x2);
+ int newval = computeVal(_controller, y, height());
+ int type = _controller->num();
+
+ bool found = false;
+ bool song_changed = false;
+
+ int lastpv = CTRL_VAL_UNKNOWN;
+ if(ctrl)
+ lastpv = ctrl->hwVal();
+
+ for (ciCEvent i = items.begin(); i != items.end(); ++i) {
+ CEvent* ev = *i;
+ if(ev->part() != curPart)
+ continue;
+ //int partTick = ev->part()->tick();
+ int partTick = curPart->tick();
+ Event event = ev->event();
+ if (event.empty())
+ continue;
+ int ax = event.tick() + partTick;
+ // Added by Tim. p3.3.6
+ //printf("CtrlCanvas::newVal ax:%d xx1:%d xx2:%d len:%d\n", ax, xx1, xx2, curPart->lenTick());
+
+ if (ax < xx1)
+ continue;
+ //if(ax <= xx1)
+ //{
+ // if(type == CTRL_PROGRAM && event.dataB() != CTRL_VAL_UNKNOWN && ((event.dataB() & 0xffffff) != 0xffffff))
+ // lastpv = event.dataB();
+ // if(ax < xx1)
+ // continue;
+ //}
+ if (ax >= xx2)
+ break;
+
+ // Added by T356. Do not add events which are past the end of the part.
+ //if(event.tick() >= curPart->lenTick())
+ // break;
+
+ int nval = newval;
+ if(type == CTRL_PROGRAM)
+ {
+ if(event.dataB() == CTRL_VAL_UNKNOWN)
+ {
+ //if(lastpv == CTRL_VAL_UNKNOWN)
+ // lastpv = ctrl->hwVal();
+
+ if(lastpv == CTRL_VAL_UNKNOWN)
+ {
+ --nval;
+ if(song->mtype() == MT_GM)
+ nval |= 0xffff00;
+ }
+ else
+ nval = (lastpv & 0xffff00) | (nval - 1);
+ }
+ else
+ nval = (event.dataB() & 0xffff00) | (nval - 1);
+ }
+
+ if (ax == xx1) {
+ // change event
+ found = true;
+ ev->setVal(nval);
+ if ((event.dataB() != nval)) {
+ Event newEvent = event.clone();
+ newEvent.setB(nval);
+ // Added by Tim. p3.3.6
+ //printf("CtrlCanvas::newVal change xx1:%d xx2:%d len:%d\n", xx1, xx2, curPart->lenTick());
+
+ // Indicate no undo, and do port controller values and clone parts.
+ //audio->msgChangeEvent(event, newEvent, ev->part(), false);
+ audio->msgChangeEvent(event, newEvent, curPart, false, true, true);
+
+ ev->setEvent(newEvent);
+ song_changed = true;
+ }
+ }
+ else if (ax < xx2) {
+ // delete event
+ // Added by Tim. p3.3.6
+ //printf("CtrlCanvas::newVal delete xx1:%d xx2:%d len:%d\n", xx1, xx2, curPart->lenTick());
+
+ // Indicate no undo, and do port controller values and clone parts.
+ //audio->msgDeleteEvent(event, ev->part(), false);
+ audio->msgDeleteEvent(event, curPart, false, true, true);
+
+ song_changed = true;
+ }
+ }
+ if (!found) {
+ // new event
+ int tick = xx1 - curPart->tick();
+ // Do not add events which are past the end of the part.
+ if((unsigned)tick < curPart->lenTick())
+ {
+ Event event(Controller);
+ event.setTick(tick);
+ event.setA(_didx);
+ if(type == CTRL_PROGRAM)
+ {
+ if(lastpv == CTRL_VAL_UNKNOWN)
+ {
+ if(song->mtype() == MT_GM)
+ event.setB(0xffff00 | (newval - 1));
+ else
+ event.setB(newval - 1);
+ }
+ else
+ event.setB((lastpv & 0xffff00) | (newval - 1));
+ }
+ else
+ event.setB(newval);
+
+ // Indicate no undo, and do port controller values and clone parts.
+ //audio->msgAddEvent(event, curPart, false);
+ audio->msgAddEvent(event, curPart, false, true, true);
+
+ song_changed = true;
+ }
+ }
+ if (song_changed) {
+ songChanged(0);
+ return;
+ }
+ redraw();
+ }
+
+//---------------------------------------------------------
+// deleteVal
+//---------------------------------------------------------
+
+void CtrlCanvas::deleteVal(int x1, int x2, int)
+ {
+ int xx1 = editor->rasterVal1(x1);
+ int xx2 = editor->rasterVal2(x2);
+
+ int partTick = curPart->tick();
+ xx1 -= partTick;
+ xx2 -= partTick;
+
+ bool song_changed = false;
+ for (ciCEvent i = items.begin(); i != items.end(); ++i) {
+ CEvent* ev = *i;
+ if(ev->part() != curPart)
+ continue;
+ Event event = ev->event();
+ if (event.empty())
+ continue;
+ int x = event.tick();
+ if (x < xx1)
+ continue;
+ if (x >= xx2)
+ break;
+ if (!event.empty()) {
+ // Indicate no undo, and do port controller values and clone parts.
+ //audio->msgDeleteEvent(event, ev->part(), false);
+ audio->msgDeleteEvent(event, curPart, false, true, true);
+ song_changed = true;
+ }
+ }
+ if (song_changed) {
+ songChanged(0);
+ return;
+ }
+ }
+
+//---------------------------------------------------------
+// setTool
+//---------------------------------------------------------
+
+void CtrlCanvas::setTool(int t)
+ {
+ if (tool == Tool(t))
+ return;
+ tool = Tool(t);
+ switch(tool) {
+ case PencilTool:
+ setCursor(QCursor(*pencilIcon, 4, 15));
+ break;
+ case DrawTool:
+ drawLineMode = false;
+ break;
+ default:
+ setCursor(QCursor(Qt::ArrowCursor));
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// pdrawItems
+//---------------------------------------------------------
+
+void CtrlCanvas::pdrawItems(QPainter& p, const QRect& rect, const MidiPart* part, bool velo, bool fg)
+{
+ int x = rect.x() - 1; // compensate for 3 pixel line width
+ int w = rect.width() + 2;
+ int wh = height();
+
+ if(velo)
+ {
+ for(iCEvent i = items.begin(); i != items.end(); ++i)
+ {
+ CEvent* e = *i;
+ // Draw selected part velocity events on top of unselected part events.
+ //if((fg && e->part() != part) || (!fg && e->part() == part))
+ if(e->part() != part)
+ continue;
+ int tick = mapx(e->event().tick() + e->part()->tick());
+ if (tick <= x)
+ continue;
+ if (tick > x+w)
+ break;
+ int y1 = wh - (e->val() * wh / 128);
+ //p.setPen(QPen(Qt::black, 1));
+ //p.drawLine(tick+3, wh, tick+3, y1);
+ // fg means 'draw selected parts'.
+ if(fg)
+ {
+ int velo2 = e->val();
+ QColor color = QColor(147,186,195,127);
+ if(velo2 <= 11)
+ color.setRgb(147,186,195,127);
+ else if(velo2 <= 22)
+ color.setRgb(119,169,181,127);
+ else if(velo2 <= 33)
+ color.setRgb(85,157,175,127);
+ else if(velo2 <= 44)
+ color.setRgb(58,152,176,127);
+ else if(velo2 <= 55)
+ color.setRgb(33,137,163,127);
+ else if(velo2 <= 66)
+ color.setRgb(30,136,162,127);
+ else if(velo2 <= 77)
+ color.setRgb(13,124,151,127);
+ else if(velo2 <= 88)
+ color.setRgb(0,110,138,127);
+ else if(velo2 <= 99)
+ color.setRgb(0,99,124,127);
+ else if(velo2 <= 110)
+ color.setRgb(0,77,96,127);
+ else if(velo2 <= 121)
+ color.setRgb(0,69,86,127);
+ else
+ color.setRgb(0,58,72,127);
+
+ p.setPen(QPen(color, 6));
+
+ //p.setPen(QPen(config.ctrlGraphFg, 3));
+
+ }
+ else
+ p.setPen(QPen(QColor(172,172,172), 6));
+
+ p.drawLine(tick+4, wh, tick+4, y1);
+
+ //p.setPen(QPen(Qt::black, 1));
+ //p.drawLine(tick-3, wh, tick-3, y1);
+ }
+ }
+ else
+ {
+
+ MidiTrack* mt = part->track();
+ MidiPort* mp;
+
+ if((mt->type() == Track::DRUM) && (curDrumInstrument != -1) && ((_cnum & 0xff) == 0xff))
+ mp = &midiPorts[drumMap[curDrumInstrument].port];
+ else
+ mp = &midiPorts[mt->outPort()];
+
+ MidiController* mc = mp->midiController(_cnum);
+
+ int min;
+ int max;
+ int bias;
+ if(_cnum == CTRL_PROGRAM)
+ {
+ min = 1;
+ max = 128;
+ bias = 0;
+ }
+ else
+ {
+ min = mc->minVal();
+ max = mc->maxVal();
+ bias = mc->bias();
+ }
+ int x1 = rect.x();
+ int lval = CTRL_VAL_UNKNOWN;
+ noEvents=false;
+ QColor color = QColor();
+ QColor green = QColor(119,169,181,127);
+ QColor yellow = QColor(41,130,140);
+ QColor red = QColor(0,37,46,127);
+ QLinearGradient vuGrad(QPointF(0, 0), QPointF(0, height()));
+ vuGrad.setColorAt(1, green);
+ //vuGrad.setColorAt(0.45, yellow);
+ //vuGrad.setColorAt(0.3, yellow);
+ vuGrad.setColorAt(0, red);
+ QPen myPen = QPen();
+ //myPen.setCapStyle(Qt::RoundCap);
+ //myPen.setStyle(Qt::DashLine);
+ myPen.setBrush(QBrush(vuGrad));
+ for (iCEvent i = items.begin(); i != items.end(); ++i)
+ {
+ CEvent* e = *i;
+ // Draw unselected part controller events (lines) on top of selected part events (bars).
+ //if((fg && (e->part() == part)) || (!fg && (e->part() != part)))
+ if(e->part() != part)
+ {
+ continue;
+ }
+ Event ev = e->event();
+ int tick = mapx(!ev.empty() ? ev.tick() + e->part()->tick() : 0);
+ int val = e->val();
+ int pval = val;
+ if(_cnum == CTRL_PROGRAM)
+ {
+ if((val & 0xff) == 0xff)
+ // What to do here? prog = 0xff should not be allowed, but may still be encountered.
+ pval = 1;
+ else
+ pval = (val & 0x7f) + 1;
+ }
+ if (tick <= x)
+ {
+ if (val == CTRL_VAL_UNKNOWN)
+ lval = CTRL_VAL_UNKNOWN;
+ else
+ {
+ if(_cnum == CTRL_PROGRAM)
+ lval = wh - ((pval - min - bias) * wh / (max - min));
+ else
+ lval = wh - ((val - min - bias) * wh / (max - min));
+ }
+ continue;
+ }
+ if (tick > x+w)
+ break;
+ int velo2 = e->val();
+ /*if(velo2 <= 11)
+ color.setRgb(75,145,47);
+ else if(velo2 <= 22)
+ color.setRgb(64,139,83);
+ else if(velo2 <= 33)
+ color.setRgb(61,138,92);
+ else if(velo2 <= 44)
+ color.setRgb(57,135,107);
+ else if(velo2 <= 55)
+ color.setRgb(54,133,120);
+ else if(velo2 <= 66)
+ color.setRgb(50,131,133);
+ else if(velo2 <= 77)
+ color.setRgb(47,130,143);
+ else if(velo2 <= 88)
+ color.setRgb(57,121,144);
+ else if(velo2 <= 99)
+ color.setRgb(70,110,143);
+ else if(velo2 <= 110)
+ color.setRgb(82,100,142);
+ else if(velo2 <= 121)
+ color.setRgb(94,90,142);
+ else
+ color.setRgb(110,76,141);
+ */
+
+ if (lval == CTRL_VAL_UNKNOWN)
+ {
+ // fg means 'draw unselected parts'.
+ if(!fg)
+ p.fillRect(x1, 0, tick - x1, wh, QColor(192,192,192,127));
+ }
+ else
+ {
+ if(fg)
+ {
+ p.setPen(Qt::gray);
+ p.drawLine(x1, lval, tick, lval);
+ }
+ else
+ {
+ p.setPen(myPen);
+ p.fillRect(x1, lval, tick - x1, wh - lval, QBrush(vuGrad));//, config.ctrlGraphFg);
+ }
+ }
+
+
+ x1 = tick;
+ if (val == CTRL_VAL_UNKNOWN)
+ lval = CTRL_VAL_UNKNOWN;
+ else
+ {
+ if(_cnum == CTRL_PROGRAM)
+ lval = wh - ((pval - min - bias) * wh / (max - min));
+ else
+ lval = wh - ((val - min - bias) * wh / (max - min));
+ }
+ }
+ if (lval == CTRL_VAL_UNKNOWN)
+ {
+ if(!fg)
+ {
+ p.fillRect(x1, 0, (x+w) - x1, wh, QColor(192,192,192,127));
+ noEvents=true;
+ }
+ }
+ else
+ {
+ if(fg)
+ {
+ p.setPen(QColor(192,192,192,127));
+ p.drawLine(x1, lval, x + w, lval);
+ }
+ else
+ {
+ p.setPen(myPen);
+ p.fillRect(x1, lval, (x+w) - x1, wh - lval, QBrush(vuGrad));//, config.ctrlGraphFg);
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------
+// pdraw
+//---------------------------------------------------------
+
+void CtrlCanvas::pdraw(QPainter& p, const QRect& rect)
+ {
+
+ int x = rect.x() - 1; // compensate for 3 pixel line width
+ int y = rect.y();
+ int w = rect.width() + 2;
+ int h = rect.height();
+
+ //---------------------------------------------------
+ // draw the grid
+ //---------------------------------------------------
+
+ p.save();
+ View::pdraw(p, rect);
+ p.restore();
+
+ //---------------------------------------------------
+ // draw Canvas Items
+ //---------------------------------------------------
+
+ bool velo = (midiControllerType(_controller->num()) == MidiController::Velo);
+ if(!velo)
+ {
+ pdrawItems(p, rect, curPart, false, false);
+ }
+ for(iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip)
+ {
+ MidiPart* part = (MidiPart*)(ip->second);
+ //if((velo && part == curPart) || (!velo && part != curPart))
+ if(part == curPart)
+ continue;
+ pdrawItems(p, rect, part, velo, !velo);
+ }
+ if(velo)
+ {
+ pdrawItems(p, rect, curPart, true, true);
+ }
+
+ //---------------------------------------------------
+ // draw marker
+ //---------------------------------------------------
+
+ int xp = mapx(pos[0]);
+ if (xp >= x && xp < x+w)
+ {
+ //p.setPen(Qt::red);
+ p.setPen(QColor(0,186,255));
+ //p.setPen(QColor(139,225,69));
+ p.drawLine(xp, y, xp, y+h);
+ }
+ xp = mapx(pos[1]);
+ if (xp >= x && xp < x+w)
+ {
+ p.setPen(QColor(139,225,69));
+ //p.setPen(Qt::blue);
+ p.drawLine(xp, y, xp, y+h);
+ }
+ xp = mapx(pos[2]);
+ if (xp >= x && xp < x+w)
+ {
+ p.setPen(QColor(139,225,69));
+ //p.setPen(Qt::blue);
+ p.drawLine(xp, y, xp, y+h);
+ }
+
+ //---------------------------------------------------
+ // draw lasso
+ //---------------------------------------------------
+
+ if (drag == DRAG_LASSO) {
+ setPainter(p);
+ p.setPen(QColor(181,109,16,127));
+ //p.setPen(Qt::blue);
+ p.setBrush(Qt::NoBrush);
+ p.drawRect(lasso);
+ }
+ }
+
+//---------------------------------------------------------
+// drawOverlay
+//---------------------------------------------------------
+
+void CtrlCanvas::drawOverlay(QPainter& p)
+ {
+ QString s(_controller->name());
+ p.setFont(config.fonts[3]);
+ p.setPen(Qt::black);
+ QFontMetrics fm(config.fonts[3]);
+ int y = fm.lineSpacing() + 2;
+ p.drawText(2, y, s);
+ if (noEvents) {
+ p.setFont(config.fonts[3]);
+ p.setPen(Qt::black);
+ p.drawText(width()/2-100,height()/2-10, "Use shift + pencil or line tool to draw new events");
+ //p.drawText(2 , y * 2, "Use shift + pencil or line tool to draw new events");
+ }
+ }
+
+//---------------------------------------------------------
+// overlayRect
+// returns geometry of overlay rectangle
+//---------------------------------------------------------
+
+QRect CtrlCanvas::overlayRect() const
+ {
+ QFontMetrics fm(config.fonts[3]);
+ QRect r(fm.boundingRect(_controller ? _controller->name() : QString("")));
+ r.translate(2, 2); // top/left margin
+ return r;
+ }
+
+//---------------------------------------------------------
+// draw
+//---------------------------------------------------------
+
+void CtrlCanvas::draw(QPainter& p, const QRect& rect)
+{
+ drawTickRaster(p, rect.x(), rect.y(),
+ //rect.width(), rect.height(), editor->quant());
+ rect.width(), rect.height(), editor->raster());
+
+ //---------------------------------------------------
+ // draw line tool
+ //---------------------------------------------------
+
+ if (drawLineMode && (tool == DrawTool))
+ {
+ p.setRenderHint(QPainter::Antialiasing, true);
+ //p.setPen(Qt::black);
+ p.setPen(QColor(247,206,107));
+ p.drawLine(line1x, line1y, line2x, line2y);
+ }
+}
+
+//---------------------------------------------------------
+// setCurDrumInstrument
+//---------------------------------------------------------
+
+void CtrlCanvas::setCurDrumInstrument(int di)
+ {
+ curDrumInstrument = di;
+ //printf("CtrlCanvas::setCurDrumInstrument curDrumInstrument:%d\n", curDrumInstrument);
+
+ //
+ // check if current controller is only valid for
+ // a specific drum instrument
+ //
+ // Removed by T356.
+ //if(curTrack && (curTrack->type() == Track::DRUM) && ((_controller->num() & 0xff) == 0xff)) {
+ //if(curTrack && (curTrack->type() == Track::DRUM) && ((_cnum & 0xff) == 0xff)) {
+ // reset to default
+ // TODO: check, if new drum instrument has a similar controller
+ // configured
+ // _cnum = CTRL_VELOCITY;
+ // }
+ // Removed by T356
+ //songChanged(-1);
+ }
diff --git a/attic/muse2-oom/muse2/muse/ctrl/ctrlcanvas.h b/attic/muse2-oom/muse2/muse/ctrl/ctrlcanvas.h
new file mode 100644
index 00000000..e76bf71c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/ctrl/ctrlcanvas.h
@@ -0,0 +1,165 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: ctrlcanvas.h,v 1.7.2.4 2009/06/01 20:15:53 spamatica Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __CTRLCANVAS_H__
+#define __CTRLCANVAS_H__
+
+#include <list>
+
+
+#include "view.h"
+#include "tools.h"
+#include "midictrl.h"
+#include "event.h"
+
+class QMouseEvent;
+class QEvent;
+class QWidget;
+
+class Event;
+class MidiPart;
+class PartList;
+class MidiTrack;
+class MidiEditor;
+class CtrlPanel;
+
+//---------------------------------------------------------
+// CEvent
+// ''visual'' Controller Event
+//---------------------------------------------------------
+
+class CEvent {
+ Event _event;
+ int _val;
+ MidiPart* _part;
+ int ex;
+
+ public:
+ CEvent(Event e, MidiPart* part, int v);
+ Event event() const { return _event; }
+ void setEvent(Event& ev) { _event = ev; }
+ int val() const { return _val; }
+ void setVal(int v) { _val = v; }
+ void setEX(int v) { ex = v; }
+ MidiPart* part() const { return _part; }
+ bool contains(int x1, int x2) const;
+ int x() { return ex; }
+ };
+
+typedef std::list<CEvent*>::iterator iCEvent;
+typedef std::list<CEvent*>::const_iterator ciCEvent;
+
+//---------------------------------------------------------
+// CEventList
+// Controller Item List
+//---------------------------------------------------------
+
+class CEventList: public std::list<CEvent*> {
+ public:
+ void add(CEvent* item) { push_back(item); }
+
+ void clearDelete();
+ };
+
+//---------------------------------------------------------
+// CtrlCanvas
+//---------------------------------------------------------
+
+class CtrlCanvas : public View {
+ MidiEditor* editor;
+ MidiTrack* curTrack;
+ MidiPart* curPart;
+ MidiCtrlValList* ctrl;
+ MidiController* _controller;
+ CtrlPanel* _panel;
+ int _cnum;
+ // Current real drum controller number (anote).
+ int _dnum;
+ // Current real drum controller index.
+ int _didx;
+ int line1x;
+ int line1y;
+ int line2x;
+ int line2y;
+ bool drawLineMode;
+ bool noEvents;
+
+ void viewMousePressEvent(QMouseEvent* event);
+ void viewMouseMoveEvent(QMouseEvent*);
+ void viewMouseReleaseEvent(QMouseEvent*);
+
+ virtual void draw(QPainter&, const QRect&);
+ virtual void pdraw(QPainter&, const QRect&);
+ virtual void drawOverlay(QPainter& p);
+ virtual QRect overlayRect() const;
+
+ void changeValRamp(int x1, int x2, int y1, int y2);
+ void newValRamp(int x1, int y1, int x2, int y2);
+ void changeVal(int x1, int x2, int y);
+ void newVal(int x1, int x2, int y);
+ void deleteVal(int x1, int x2, int y);
+
+ bool setCurTrackAndPart();
+ void pdrawItems(QPainter&, const QRect&, const MidiPart*, bool, bool);
+ void partControllers(const MidiPart*, int, int*, int*, MidiController**, MidiCtrlValList**);
+
+ Q_OBJECT
+
+ protected:
+ enum DragMode { DRAG_OFF, DRAG_NEW, DRAG_MOVE_START, DRAG_MOVE,
+ DRAG_DELETE, DRAG_COPY_START, DRAG_COPY,
+ DRAG_RESIZE, DRAG_LASSO_START, DRAG_LASSO
+ };
+
+ CEventList items;
+ CEventList selection;
+ CEventList moving;
+ CEvent* curItem;
+
+ DragMode drag;
+ QRect lasso;
+ QPoint start;
+ Tool tool;
+ unsigned pos[3];
+ int curDrumInstrument; //Used by the drum-editor to view velocity of only one key (one drum)
+
+ void leaveEvent(QEvent*e);
+ QPoint raster(const QPoint&) const;
+
+ // selection
+ bool isSingleSelection() { return selection.size() == 1; }
+ void deselectAll();
+ void selectItem(CEvent* e);
+ void deselectItem(CEvent* e);
+
+ void setMidiController(int);
+ void updateItems();
+
+ private slots:
+ void songChanged(int type);
+ void setCurDrumInstrument(int);
+
+ public slots:
+ void setTool(int t);
+ void setPos(int, unsigned, bool adjustScrollbar);
+ void setController(int ctrl);
+
+ signals:
+ void followEvent(int);
+ void xposChanged(unsigned);
+ void yposChanged(int);
+
+ public:
+ CtrlCanvas(MidiEditor*, QWidget* parent, int,
+ const char* name = 0, CtrlPanel* pnl = 0);
+ void setPanel(CtrlPanel* pnl) { _panel = pnl; }
+ MidiCtrlValList* ctrlValList() { return ctrl; }
+ MidiController* controller() { return _controller; }
+ MidiTrack* track() const { return curTrack; }
+ };
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/ctrl/ctrledit.cpp b/attic/muse2-oom/muse2/muse/ctrl/ctrledit.cpp
new file mode 100644
index 00000000..fe04844d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/ctrl/ctrledit.cpp
@@ -0,0 +1,134 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: ctrledit.cpp,v 1.4.2.2 2009/02/02 21:38:00 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include "ctrledit.h"
+#include "ctrlcanvas.h"
+#include "midieditor.h"
+#include "xml.h"
+#include "vscale.h"
+#include "ctrlpanel.h"
+#include "globals.h"
+#include "midiport.h"
+#include "instruments/minstrument.h"
+#include "gconfig.h"
+
+#include <QHBoxLayout>
+
+//---------------------------------------------------------
+// setTool
+//---------------------------------------------------------
+
+void CtrlEdit::setTool(int t)
+ {
+ canvas->setTool(t);
+ }
+
+//---------------------------------------------------------
+// CtrlEdit
+//---------------------------------------------------------
+
+CtrlEdit::CtrlEdit(QWidget* parent, MidiEditor* e, int xmag,
+ bool expand, const char* name) : QWidget(parent)
+ {
+ setObjectName(name);
+ setAttribute(Qt::WA_DeleteOnClose);
+ QHBoxLayout* hbox = new QHBoxLayout;
+ panel = new CtrlPanel(0, e, "panel");
+ canvas = new CtrlCanvas(e, 0, xmag, "ctrlcanvas", panel);
+ QWidget* vscale = new VScale;
+
+ hbox->setContentsMargins(0, 0, 0, 0);
+ hbox->setSpacing (0);
+
+ canvas->setOrigin(-(config.division/4), 0);
+
+ canvas->setMinimumHeight(50);
+
+ panel->setFixedWidth(CTRL_PANEL_FIXED_WIDTH);
+ hbox->addWidget(panel, expand ? 100 : 0, Qt::AlignRight);
+ hbox->addWidget(canvas, 100);
+ hbox->addWidget(vscale, 0);
+ setLayout(hbox);
+
+ connect(panel, SIGNAL(destroyPanel()), SLOT(destroy()));
+ connect(panel, SIGNAL(controllerChanged(int)), canvas, SLOT(setController(int)));
+ connect(canvas, SIGNAL(xposChanged(unsigned)), SIGNAL(timeChanged(unsigned)));
+ connect(canvas, SIGNAL(yposChanged(int)), SIGNAL(yposChanged(int)));
+ }
+
+//---------------------------------------------------------
+// writeStatus
+//---------------------------------------------------------
+
+void CtrlEdit::writeStatus(int level, Xml& xml)
+ {
+ if (canvas->controller()) {
+ xml.tag(level++, "ctrledit");
+ xml.strTag(level, "ctrl", canvas->controller()->name());
+ xml.tag(level, "/ctrledit");
+ }
+ }
+
+//---------------------------------------------------------
+// readStatus
+//---------------------------------------------------------
+
+void CtrlEdit::readStatus(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "ctrl") {
+ QString name = xml.parse1();
+ int portno = canvas->track()->outPort();
+ MidiPort* port = &midiPorts[portno];
+ MidiInstrument* instr = port->instrument();
+ MidiControllerList* mcl = instr->controller();
+
+ for (iMidiController ci = mcl->begin(); ci != mcl->end(); ++ci) {
+ if (ci->second->name() == name) {
+ canvas->setController(ci->second->num());
+ break;
+ }
+ }
+ }
+ else
+ xml.unknown("CtrlEdit");
+ break;
+ case Xml::TagEnd:
+ if (tag == "ctrledit")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// destroy
+//---------------------------------------------------------
+
+void CtrlEdit::destroy()
+ {
+ emit destroyedCtrl(this);
+ close(); // close and destroy widget
+ }
+
+//---------------------------------------------------------
+// setCanvasWidth
+//---------------------------------------------------------
+
+void CtrlEdit::setCanvasWidth(int w)
+{
+ canvas->setFixedWidth(w);
+}
diff --git a/attic/muse2-oom/muse2/muse/ctrl/ctrledit.h b/attic/muse2-oom/muse2/muse/ctrl/ctrledit.h
new file mode 100644
index 00000000..61bf9b46
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/ctrl/ctrledit.h
@@ -0,0 +1,54 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: ctrledit.h,v 1.4.2.1 2008/05/21 00:28:53 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __CTRL_EDIT_H__
+#define __CTRL_EDIT_H__
+
+#include <QWidget>
+
+#include "ctrlcanvas.h"
+#include "song.h"
+
+class MidiEditor;
+class CtrlView;
+class CtrlPanel;
+class Xml;
+
+#define CTRL_PANEL_FIXED_WIDTH 40
+//---------------------------------------------------------
+// CtrlEdit
+//---------------------------------------------------------
+
+class CtrlEdit : public QWidget {
+ CtrlCanvas* canvas;
+ CtrlPanel* panel;
+
+ Q_OBJECT
+
+ private slots:
+ void destroy();
+
+ public slots:
+ void setTool(int tool);
+ void setXPos(int val) { canvas->setXPos(val); }
+ void setXMag(int val) { canvas->setXMag(val); }
+ void setCanvasWidth(int w);
+ signals:
+ void timeChanged(unsigned);
+ void destroyedCtrl(CtrlEdit*);
+ void enterCanvas();
+ void yposChanged(int);
+
+ public:
+ CtrlEdit(QWidget*, MidiEditor* e, int xmag,
+ bool expand = false, const char* name = 0);
+ void readStatus(Xml&);
+ void writeStatus(int, Xml&);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/ctrl/ctrlpanel.cpp b/attic/muse2-oom/muse2/muse/ctrl/ctrlpanel.cpp
new file mode 100644
index 00000000..9e990861
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/ctrl/ctrlpanel.cpp
@@ -0,0 +1,709 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: ctrlpanel.cpp,v 1.10.2.9 2009/06/14 05:24:45 terminator356 Exp $
+// (C) Copyright 1999-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <list>
+
+#include "ctrlpanel.h"
+#include "ctrlcanvas.h"
+
+#include <QMenu>
+#include <QPushButton>
+#include <QSizePolicy>
+#include <QHBoxLayout>
+#include <QTimer>
+#include <QVBoxLayout>
+
+#include <math.h>
+
+#include "globals.h"
+#include "midictrl.h"
+#include "instruments/minstrument.h"
+#include "midiport.h"
+#include "xml.h"
+#include "icons.h"
+#include "event.h"
+#include "midieditor.h"
+#include "track.h"
+#include "part.h"
+#include "midiedit/drummap.h"
+#include "gconfig.h"
+#include "song.h"
+#include "knob.h"
+#include "doublelabel.h"
+#include "midi.h"
+#include "audio.h"
+
+//---------------------------------------------------------
+// CtrlPanel
+//---------------------------------------------------------
+
+CtrlPanel::CtrlPanel(QWidget* parent, MidiEditor* e, const char* name)
+ : QWidget(parent)
+ {
+ setObjectName(name);
+ inHeartBeat = true;
+ editor = e;
+ setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
+ QVBoxLayout* vbox = new QVBoxLayout;
+ QHBoxLayout* bbox = new QHBoxLayout;
+ bbox->setSpacing (0);
+ vbox->addLayout(bbox);
+ vbox->addStretch();
+ QHBoxLayout* kbox = new QHBoxLayout;
+ QHBoxLayout* dbox = new QHBoxLayout;
+ vbox->addLayout(kbox);
+ vbox->addLayout(dbox);
+ vbox->addStretch();
+ vbox->setContentsMargins(0, 0, 0, 0);
+ bbox->setContentsMargins(0, 0, 0, 0);
+ kbox->setContentsMargins(0, 0, 0, 0);
+ dbox->setContentsMargins(0, 0, 0, 0);
+
+ selCtrl = new QPushButton(tr("S"));
+ selCtrl->setFont(config.fonts[3]);
+ selCtrl->setFixedHeight(20);
+ selCtrl->setSizePolicy(
+ QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
+ selCtrl->setToolTip(tr("select controller"));
+
+ ///pop = new QMenu;
+
+ // destroy button
+ QPushButton* destroy = new QPushButton(tr("X"));
+ destroy->setFont(config.fonts[3]);
+ destroy->setFixedHeight(20);
+ destroy->setSizePolicy(
+ QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
+ destroy->setToolTip(tr("remove panel"));
+ // Cursor Position
+ connect(selCtrl, SIGNAL(clicked()), SLOT(ctrlPopup()));
+ connect(destroy, SIGNAL(clicked()), SIGNAL(destroyPanel()));
+
+ _track = 0;
+ _ctrl = 0;
+ _val = CTRL_VAL_UNKNOWN;
+ _dnum = -1;
+
+ _knob = new Knob;
+ _knob->setFixedWidth(25);
+ _knob->setFixedHeight(25);
+ _knob->setToolTip(tr("manual adjust"));
+ _knob->setRange(0.0, 127.0, 1.0);
+ _knob->setValue(0.0);
+ _knob->setEnabled(false);
+ _knob->hide();
+ _knob->setAltFaceColor(Qt::red);
+
+ _dl = new DoubleLabel(-1.0, 0.0, +127.0);
+ _dl->setPrecision(0);
+ _dl->setToolTip(tr("double click on/off"));
+ _dl->setSpecialText(tr("off"));
+ _dl->setFont(config.fonts[1]);
+ _dl->setBackgroundRole(QPalette::Mid);
+ _dl->setFrame(true);
+ _dl->setFixedWidth(36);
+ _dl->setFixedHeight(15);
+ _dl->setEnabled(false);
+ _dl->hide();
+
+ connect(_knob, SIGNAL(sliderMoved(double,int)), SLOT(ctrlChanged(double)));
+ connect(_knob, SIGNAL(sliderRightClicked(const QPoint&, int)), SLOT(ctrlRightClicked(const QPoint&, int)));
+ //connect(_knob, SIGNAL(sliderReleased(int)), SLOT(ctrlReleased(int)));
+ connect(_dl, SIGNAL(valueChanged(double,int)), SLOT(ctrlChanged(double)));
+ connect(_dl, SIGNAL(doubleClicked(int)), SLOT(labelDoubleClicked()));
+
+ bbox->addStretch();
+ bbox->addWidget(selCtrl);
+ bbox->addWidget(destroy);
+ bbox->addStretch();
+ kbox->addStretch();
+ kbox->addWidget(_knob);
+ kbox->addStretch();
+ dbox->addStretch();
+ dbox->addWidget(_dl);
+ dbox->addStretch();
+ connect(heartBeatTimer, SIGNAL(timeout()), SLOT(heartBeat()));
+ inHeartBeat = false;
+ setLayout(vbox);
+ }
+//---------------------------------------------------------
+// heartBeat
+//---------------------------------------------------------
+
+void CtrlPanel::heartBeat()
+{
+ inHeartBeat = true;
+
+ if(_track && _ctrl && _dnum != -1)
+ {
+ //if(_dnum != CTRL_VELOCITY && _dnum != CTRL_PROGRAM)
+ if(_dnum != CTRL_VELOCITY)
+ {
+ int outport;
+ int chan;
+ int cdi = editor->curDrumInstrument();
+ if(_track->type() == Track::DRUM && ((_ctrl->num() & 0xff) == 0xff) && cdi != -1)
+ {
+ outport = drumMap[cdi].port;
+ chan = drumMap[cdi].channel;
+ }
+ else
+ {
+ outport = _track->outPort();
+ chan = _track->outChannel();
+ }
+ MidiPort* mp = &midiPorts[outport];
+
+ int v = mp->hwCtrlState(chan, _dnum);
+ if(v == CTRL_VAL_UNKNOWN)
+ {
+ // DoubleLabel ignores the value if already set...
+ _dl->setValue(_dl->off() - 1.0);
+ _val = CTRL_VAL_UNKNOWN;
+ v = mp->lastValidHWCtrlState(chan, _dnum);
+ if(v != CTRL_VAL_UNKNOWN && ((_dnum != CTRL_PROGRAM) || ((v & 0xff) != 0xff) ))
+ {
+ if(_dnum == CTRL_PROGRAM)
+ v = (v & 0x7f) + 1;
+ else
+ // Auto bias...
+ v -= _ctrl->bias();
+ if(double(v) != _knob->value())
+ {
+ // Added by Tim. p3.3.6
+ //printf("CtrlPanel::heartBeat setting knob\n");
+
+ _knob->setValue(double(v));
+ }
+ }
+ }
+ else
+ if(v != _val)
+ {
+ _val = v;
+ if(v == CTRL_VAL_UNKNOWN || ((_dnum == CTRL_PROGRAM) && ((v & 0xff) == 0xff) ))
+ {
+ // DoubleLabel ignores the value if already set...
+ //_dl->setValue(double(_ctrl->minVal() - 1));
+ _dl->setValue(_dl->off() - 1.0);
+ }
+ else
+ {
+ if(_dnum == CTRL_PROGRAM)
+ v = (v & 0x7f) + 1;
+ else
+ // Auto bias...
+ v -= _ctrl->bias();
+
+ // Added by Tim. p3.3.6
+ //printf("CtrlPanel::heartBeat setting knob and label\n");
+
+ _knob->setValue(double(v));
+ _dl->setValue(double(v));
+ }
+ }
+ }
+ }
+
+ inHeartBeat = false;
+}
+
+//---------------------------------------------------------
+// labelDoubleClicked
+//---------------------------------------------------------
+
+void CtrlPanel::labelDoubleClicked()
+{
+ if(!_track || !_ctrl || _dnum == -1)
+ return;
+
+ int outport;
+ int chan;
+ int cdi = editor->curDrumInstrument();
+ if(_track->type() == Track::DRUM && ((_ctrl->num() & 0xff) == 0xff) && cdi != -1)
+ {
+ outport = drumMap[cdi].port;
+ chan = drumMap[cdi].channel;
+ }
+ else
+ {
+ outport = _track->outPort();
+ chan = _track->outChannel();
+ }
+ MidiPort* mp = &midiPorts[outport];
+ int lastv = mp->lastValidHWCtrlState(chan, _dnum);
+
+ int curv = mp->hwCtrlState(chan, _dnum);
+
+ if(_dnum == CTRL_PROGRAM)
+ {
+ if(curv == CTRL_VAL_UNKNOWN || ((curv & 0xffffff) == 0xffffff))
+ {
+ // If no value has ever been set yet, use the current knob value
+ // (or the controller's initial value?) to 'turn on' the controller.
+ if(lastv == CTRL_VAL_UNKNOWN || ((lastv & 0xffffff) == 0xffffff))
+ {
+ //int kiv = _ctrl->initVal());
+ int kiv = lrint(_knob->value());
+ --kiv;
+ kiv &= 0x7f;
+ kiv |= 0xffff00;
+ //MidiPlayEvent ev(song->cpos(), outport, chan, ME_CONTROLLER, _dnum, kiv);
+ MidiPlayEvent ev(0, outport, chan, ME_CONTROLLER, _dnum, kiv);
+ audio->msgPlayMidiEvent(&ev);
+ }
+ else
+ {
+ //MidiPlayEvent ev(song->cpos(), outport, chan, ME_CONTROLLER, _dnum, lastv);
+ MidiPlayEvent ev(0, outport, chan, ME_CONTROLLER, _dnum, lastv);
+ audio->msgPlayMidiEvent(&ev);
+ }
+ }
+ else
+ {
+ //if((curv & 0xffff00) == 0xffff00)
+ //{
+ ////if(mp->hwCtrlState(chan, _dnum) != CTRL_VAL_UNKNOWN)
+ audio->msgSetHwCtrlState(mp, chan, _dnum, CTRL_VAL_UNKNOWN);
+ //}
+ //else
+ //{
+ // MidiPlayEvent ev(song->cpos(), outport, chan, ME_CONTROLLER, _dnum, (curv & 0xffff00) | 0xff);
+ // audio->msgPlayMidiEvent(&ev);
+ //}
+ }
+ }
+ else
+ {
+ if(curv == CTRL_VAL_UNKNOWN)
+ {
+ // If no value has ever been set yet, use the current knob value
+ // (or the controller's initial value?) to 'turn on' the controller.
+ if(lastv == CTRL_VAL_UNKNOWN)
+ {
+ //int kiv = _ctrl->initVal());
+ int kiv = lrint(_knob->value());
+ if(kiv < _ctrl->minVal())
+ kiv = _ctrl->minVal();
+ if(kiv > _ctrl->maxVal())
+ kiv = _ctrl->maxVal();
+ kiv += _ctrl->bias();
+ //MidiPlayEvent ev(song->cpos(), outport, chan, ME_CONTROLLER, _dnum, kiv);
+ MidiPlayEvent ev(0, outport, chan, ME_CONTROLLER, _dnum, kiv);
+ audio->msgPlayMidiEvent(&ev);
+ }
+ else
+ {
+ //MidiPlayEvent ev(song->cpos(), outport, chan, ME_CONTROLLER, _dnum, lastv);
+ MidiPlayEvent ev(0, outport, chan, ME_CONTROLLER, _dnum, lastv);
+ audio->msgPlayMidiEvent(&ev);
+ }
+ }
+ else
+ {
+ //if(mp->hwCtrlState(chan, _dnum) != CTRL_VAL_UNKNOWN)
+ audio->msgSetHwCtrlState(mp, chan, _dnum, CTRL_VAL_UNKNOWN);
+ }
+ }
+ song->update(SC_MIDI_CONTROLLER);
+}
+
+//---------------------------------------------------------
+// ctrlChanged
+//---------------------------------------------------------
+
+void CtrlPanel::ctrlChanged(double val)
+ {
+ if (inHeartBeat)
+ return;
+ if(!_track || !_ctrl || _dnum == -1)
+ return;
+
+ int ival = lrint(val);
+
+ int outport;
+ int chan;
+ int cdi = editor->curDrumInstrument();
+ if(_track->type() == Track::DRUM && ((_ctrl->num() & 0xff) == 0xff) && cdi != -1)
+ {
+ outport = drumMap[cdi].port;
+ chan = drumMap[cdi].channel;
+ }
+ else
+ {
+ outport = _track->outPort();
+ chan = _track->outChannel();
+ }
+ MidiPort* mp = &midiPorts[outport];
+ int curval = mp->hwCtrlState(chan, _dnum);
+
+ if(_dnum == CTRL_PROGRAM)
+ {
+ --ival;
+ ival &= 0x7f;
+
+ if(curval == CTRL_VAL_UNKNOWN)
+ ival |= 0xffff00;
+ else
+ ival |= (curval & 0xffff00);
+ //MidiPlayEvent ev(song->cpos(), outport, chan, ME_CONTROLLER, _dnum, ival);
+ MidiPlayEvent ev(0, outport, chan, ME_CONTROLLER, _dnum, ival);
+ audio->msgPlayMidiEvent(&ev);
+ }
+ else
+ // Shouldn't happen, but...
+ if((ival < _ctrl->minVal()) || (ival > _ctrl->maxVal()))
+ {
+ //if(mp->hwCtrlState(chan, _dnum) != CTRL_VAL_UNKNOWN)
+ if(curval != CTRL_VAL_UNKNOWN)
+ audio->msgSetHwCtrlState(mp, chan, _dnum, CTRL_VAL_UNKNOWN);
+ }
+ else
+ {
+ // Auto bias...
+ ival += _ctrl->bias();
+
+ //MidiPlayEvent ev(song->cpos(), outport, chan, ME_CONTROLLER, _dnum, ival);
+ MidiPlayEvent ev(0, outport, chan, ME_CONTROLLER, _dnum, ival);
+ audio->msgPlayMidiEvent(&ev);
+ }
+ song->update(SC_MIDI_CONTROLLER);
+ }
+
+//---------------------------------------------------------
+// setHWController
+//---------------------------------------------------------
+
+void CtrlPanel::setHWController(MidiTrack* t, MidiController* ctrl)
+{
+ inHeartBeat = true;
+
+ _track = t; _ctrl = ctrl;
+
+ if(!_track || !_ctrl)
+ {
+ _knob->setEnabled(false);
+ _dl->setEnabled(false);
+ _knob->hide();
+ _dl->hide();
+ inHeartBeat = false;
+ return;
+ }
+
+ MidiPort* mp;
+ int ch;
+ int cdi = editor->curDrumInstrument();
+ _dnum = _ctrl->num();
+ if(_track->type() == Track::DRUM && ((_dnum & 0xff) == 0xff) && cdi != -1)
+ {
+ _dnum = (_dnum & ~0xff) | drumMap[cdi].anote;
+ mp = &midiPorts[drumMap[cdi].port];
+ ch = drumMap[cdi].channel;
+ }
+ else
+ {
+ mp = &midiPorts[_track->outPort()];
+ ch = _track->outChannel();
+ }
+
+ //if(_dnum == CTRL_VELOCITY || _dnum == CTRL_PROGRAM)
+ if(_dnum == CTRL_VELOCITY)
+ {
+ _knob->setEnabled(false);
+ _dl->setEnabled(false);
+ _knob->hide();
+ _dl->hide();
+ }
+ else
+ {
+ _knob->setEnabled(true);
+ _dl->setEnabled(true);
+ double dlv;
+ int mn; int mx; int v;
+ if(_dnum == CTRL_PROGRAM)
+ {
+ mn = 1;
+ mx = 128;
+ v = mp->hwCtrlState(ch, _dnum);
+ _val = v;
+ _knob->setRange(double(mn), double(mx), 1.0);
+ _dl->setRange(double(mn), double(mx));
+ //_dl->setOff(double(mn - 1));
+ if(v == CTRL_VAL_UNKNOWN || ((v & 0xffffff) == 0xffffff))
+ {
+ int lastv = mp->lastValidHWCtrlState(ch, _dnum);
+ if(lastv == CTRL_VAL_UNKNOWN || ((lastv & 0xffffff) == 0xffffff))
+ {
+ int initv = _ctrl->initVal();
+ if(initv == CTRL_VAL_UNKNOWN || ((initv & 0xffffff) == 0xffffff))
+ v = 1;
+ else
+ v = (initv + 1) & 0xff;
+ }
+ else
+ v = (lastv + 1) & 0xff;
+
+ if(v > 128)
+ v = 128;
+ //dlv = mn - 1;
+ dlv = _dl->off() - 1.0;
+ }
+ else
+ {
+ v = (v + 1) & 0xff;
+ if(v > 128)
+ v = 128;
+ dlv = double(v);
+ }
+ }
+ else
+ {
+ mn = _ctrl->minVal();
+ mx = _ctrl->maxVal();
+ v = mp->hwCtrlState(ch, _dnum);
+ _val = v;
+ _knob->setRange(double(mn), double(mx), 1.0);
+ _dl->setRange(double(mn), double(mx));
+ //_dl->setOff(double(mn - 1));
+ if(v == CTRL_VAL_UNKNOWN)
+ {
+ int lastv = mp->lastValidHWCtrlState(ch, _dnum);
+ if(lastv == CTRL_VAL_UNKNOWN)
+ {
+ if(_ctrl->initVal() == CTRL_VAL_UNKNOWN)
+ v = 0;
+ else
+ v = _ctrl->initVal();
+ }
+ else
+ v = lastv - _ctrl->bias();
+ //dlv = mn - 1;
+ dlv = _dl->off() - 1.0;
+ }
+ else
+ {
+ // Auto bias...
+ v -= _ctrl->bias();
+ dlv = double(v);
+ }
+ }
+ _knob->setValue(double(v));
+ _dl->setValue(dlv);
+
+ _knob->show();
+ _dl->show();
+ // Incomplete drawing sometimes. Update fixes it.
+ _knob->update();
+ _dl->update();
+ }
+
+ inHeartBeat = false;
+}
+
+//---------------------------------------------------------
+// setHeight
+//---------------------------------------------------------
+
+void CtrlPanel::setHeight(int h)
+ {
+ setFixedHeight(h);
+ }
+
+struct CI {
+ QString s;
+ bool used;
+ CI(const QString& ss, bool u) : s(ss), used(u) {}
+ };
+
+//---------------------------------------------------------
+// ctrlPopup
+//---------------------------------------------------------
+
+void CtrlPanel::ctrlPopup()
+ {
+ //---------------------------------------------------
+ // build list of midi controllers for current
+ // MidiPort/channel
+ //---------------------------------------------------
+
+ PartList* parts = editor->parts();
+ Part* part = editor->curCanvasPart();
+ MidiTrack* track = (MidiTrack*)(part->track());
+ int channel = track->outChannel();
+ MidiPort* port = &midiPorts[track->outPort()];
+ int curDrumInstrument = editor->curDrumInstrument();
+ bool isDrum = track->type() == Track::DRUM;
+
+ QMenu* pop = new QMenu;
+ //pop->clear();
+ pop->addAction(tr("Velocity"))->setData(1);
+
+ MidiCtrlValListList* cll = port->controller();
+ int min = channel << 24;
+ int max = min + 0x1000000;
+
+ std::list<CI> sList;
+ typedef std::list<CI>::iterator isList;
+
+ for (iMidiCtrlValList i = cll->lower_bound(min); i != cll->lower_bound(max); ++i) {
+ MidiCtrlValList* cl = i->second;
+ MidiController* c = port->midiController(cl->num());
+ // dont show drum specific controller if not a drum track
+ if ((c->num() & 0xff) == 0xff) {
+ if (!isDrum)
+ continue;
+ // only show controller for curDrumInstrument:
+ if ((cl->num() & 0xff) != drumMap[curDrumInstrument].anote) {
+ continue;
+ }
+ }
+ isList i = sList.begin();
+ for (; i != sList.end(); ++i) {
+ if (i->s == c->name())
+ break;
+ }
+ if (i == sList.end()) {
+ bool used = false;
+ for (iPart ip = parts->begin(); ip != parts->end(); ++ip) {
+ EventList* el = ip->second->events();
+ for (iEvent ie = el->begin(); ie != el->end(); ++ie) {
+ Event e = ie->second;
+ if ((e.type() == Controller) && (e.dataA() == cl->num())) {
+ used = true;
+ break;
+ }
+ }
+ if (used)
+ break;
+ }
+ sList.push_back(CI(c->name(), used));
+ }
+ }
+ for (isList i = sList.begin(); i != sList.end(); ++i) {
+ if (i->used)
+ pop->addAction(QIcon(*greendotIcon), i->s);
+ else
+ pop->addAction(i->s);
+ }
+
+ pop->addAction(QIcon(*configureIcon), tr("add new ..."))->setData(2);
+ QAction *act = pop->exec(selCtrl->mapToGlobal(QPoint(0,0)));
+ selCtrl->setDown(false);
+
+ if (!act)
+ {
+ delete pop;
+ return;
+ }
+
+ int rv = act->data().toInt();
+ QString s = act->text();
+ delete pop;
+
+ if (rv == 1) { // special case velocity
+ emit controllerChanged(CTRL_VELOCITY);
+ }
+ else if (rv == 2) {
+ //
+ // add new controller
+ //
+ QMenu* pop1 = new QMenu(this);
+ //pop1->setCheckable(false); // Qt4 doc says not needed.
+ //
+ // populate popup with all controllers available for
+ // current instrument
+ //
+ MidiInstrument* instr = port->instrument();
+ MidiControllerList* mcl = instr->controller();
+ for (iMidiController ci = mcl->begin(); ci != mcl->end(); ++ci)
+ {
+ int num = ci->second->num();
+ if (isDrum && ((num & 0xff) == 0xff))
+ num = (num & ~0xff) + drumMap[curDrumInstrument].anote;
+
+ if(cll->find(channel, num) == cll->end())
+ pop1->addAction(ci->second->name());
+ }
+ QAction *act2 = pop1->exec(selCtrl->mapToGlobal(QPoint(0,0)));
+ if (act2) {
+ QString s = act2->text();
+ MidiController* c;
+ for (iMidiController ci = mcl->begin(); ci != mcl->end(); ++ci) {
+ c = ci->second;
+ if (c->name() == s) {
+ int num = c->num();
+ if (isDrum && ((num & 0xff) == 0xff))
+ num = (num & ~0xff) + drumMap[curDrumInstrument].anote;
+
+ if(cll->find(channel, num) == cll->end())
+ {
+ MidiCtrlValList* vl = new MidiCtrlValList(num);
+
+ cll->add(channel, vl);
+ emit controllerChanged(c->num());
+ //song->update(SC_MIDI_CONTROLLER_ADD);
+ }
+ else
+ emit controllerChanged(c->num());
+ break;
+ }
+ }
+ }
+ delete pop1;
+ }
+ else {
+ ///QString s = act->text();
+ iMidiCtrlValList i = cll->begin();
+ for (; i != cll->end(); ++i) {
+ MidiCtrlValList* cl = i->second;
+ MidiController* c = port->midiController(cl->num());
+ if (c->name() == s) {
+ emit controllerChanged(c->num());
+ break;
+ }
+ }
+ if (i == cll->end()) {
+ printf("CtrlPanel: controller %s not found!", s.toLatin1().constData());
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// ctrlRightClicked
+//---------------------------------------------------------
+
+void CtrlPanel::ctrlRightClicked(const QPoint& p, int /*id*/)
+{
+ //if(!_knob->selectedFaceColor())
+ // _knob->selectFaceColor(true);
+ //if(_dnum == -1)
+ // return;
+ if(!editor->curCanvasPart())
+ return;
+
+ int cdi = editor->curDrumInstrument();
+ int ctlnum = _ctrl->num();
+ if(_track->type() == Track::DRUM && ((ctlnum & 0xff) == 0xff) && cdi != -1)
+ //ctlnum = (ctlnum & ~0xff) | drumMap[cdi].enote;
+ ctlnum = (ctlnum & ~0xff) | cdi;
+
+ MidiPart* part = dynamic_cast<MidiPart*>(editor->curCanvasPart());
+ song->execMidiAutomationCtlPopup(0, part, p, ctlnum);
+}
+
+/*
+//---------------------------------------------------------
+// ctrlReleased
+//---------------------------------------------------------
+
+void CtrlPanel::ctrlReleased(int id)
+{
+ //if(_knob->selectedFaceColor())
+ // _knob->selectFaceColor(false);
+}
+*/
diff --git a/attic/muse2-oom/muse2/muse/ctrl/ctrlpanel.h b/attic/muse2-oom/muse2/muse/ctrl/ctrlpanel.h
new file mode 100644
index 00000000..a0e5f915
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/ctrl/ctrlpanel.h
@@ -0,0 +1,64 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: ctrlpanel.h,v 1.2.2.5 2009/06/10 00:34:59 terminator356 Exp $
+// (C) Copyright 1999-2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __CTRL_PANEL_H__
+#define __CTRL_PANEL_H__
+
+#include <QWidget>
+
+class MidiController;
+
+class QMenu;
+class QPushButton;
+
+class MidiEditor;
+class Knob;
+class DoubleLabel;
+class MidiPort;
+class MidiTrack;
+
+//---------------------------------------------------------
+// CtrlPanel
+//---------------------------------------------------------
+
+class CtrlPanel: public QWidget {
+ ///QMenu* pop;
+ QPushButton* selCtrl;
+ MidiEditor* editor;
+
+ MidiTrack* _track;
+ MidiController* _ctrl;
+ int _dnum;
+ bool inHeartBeat;
+ Knob* _knob;
+ DoubleLabel* _dl;
+ int _val;
+
+ Q_OBJECT
+
+ signals:
+ void destroyPanel();
+ void controllerChanged(int);
+
+ private slots:
+ void ctrlChanged(double val);
+ void labelDoubleClicked();
+ void ctrlRightClicked(const QPoint& p, int id);
+ //void ctrlReleased(int id);
+
+ protected slots:
+ virtual void heartBeat();
+
+ public slots:
+ void setHeight(int);
+ void ctrlPopup();
+
+ public:
+ CtrlPanel(QWidget*, MidiEditor*, const char* name = 0);
+ void setHWController(MidiTrack* t, MidiController* ctrl);
+ };
+#endif
diff --git a/attic/muse2-oom/muse2/muse/debug.h b/attic/muse2-oom/muse2/muse/debug.h
new file mode 100644
index 00000000..7339a613
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/debug.h
@@ -0,0 +1,31 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: debug.h,v 1.1.1.1 2003/10/27 18:51:20 wschweer Exp $
+//=========================================================
+
+#ifndef __MUSE_DEBUG_H__
+#define __MUSE_DEBUG_H__
+
+#include <stdio.h>
+#include "globals.h"
+
+#ifdef DEBUG_1
+#define M_REPORT(string) printf("%s:%d:%s: " string "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+#define M_REPORTARG(format, args...) printf("%s:%d:%s: " format "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, ##args);
+#define M_DEBUG(string) if (debugMsg) fprintf(stderr, "%s:%d:%s: " string "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+#define M_DEBUGARG(format, args...) if (debugMsg) fprintf(stderr, "%s:%d:%s: " format "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, ##args);
+#define M_ERROR(string) fprintf(stderr, "%s:%d:%s: " string "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__);
+#define M_ERRORARG(format, args...) fprintf(stderr, "%s:%d:%s: " format "\n", __FILE__, __LINE__, __PRETTY_FUNCTION__, ##args);
+#else
+#define M_REPORT(string)
+#define M_REPORTARG(format, args...)
+#define M_DEBUG(string)
+#define M_DEBUGARG(format, args...)
+#define M_ERROR(string)
+#define M_ERRORARG(format, args...)
+#endif
+
+#define DEBUG_ARGS __FILE__ << ":" << __LINE__ << ":" << __PRETTY_FUNCTION__ << ": "
+
+#endif /* __MUSE_DEBUG_H__ */
diff --git a/attic/muse2-oom/muse2/muse/default_click.h b/attic/muse2-oom/muse2/muse/default_click.h
new file mode 100644
index 00000000..7f074350
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/default_click.h
@@ -0,0 +1,1213 @@
+/*
+ Copyright (C) 20002 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+ $Id: default_click.h,v 1.1.2.1 2004/11/15 23:25:51 spamatica Exp $
+*/
+
+static const float defaultClick[] = {
+ -0.0019836426, 0.0097045898, 0.019165039, 0.028594971, 0.036102295,
+ 0.040679932, 0.040649414, 0.036560059, 0.029693604, 0.016967773,
+ 0.0057067871, -0.008026123, -0.021453857, -0.026153564,
+ -0.031921387, -0.036834717, -0.04397583, -0.046844482,
+ -0.045349121, -0.041748047, -0.032623291, -0.026611328,
+ -0.026702881, -0.025482178, -0.013092041, 0.0055847168,
+ 0.023040771, 0.027435303, 0.043426514, 0.07925415, 0.1086731,
+ 0.09463501, 0.039154053, -0.027832031, -0.081542969, -0.099090576,
+ -0.089385986, -0.051055908, -0.0023803711, 0.031951904,
+ 0.044128418, 0.029998779, 0.0086669922, 0.0022888184, 0.0082092285,
+ 0.0085144043, -0.0057983398, -0.027496338, -0.036834717,
+ -0.021759033, -0.020721436, -0.024078369, -0.025360107,
+ -0.090698242, -0.16491699, -0.16052246, -0.090454102, 0.0031433105,
+ 0.013031006, 0.034790039, 0.30599976, 0.58151245, 0.5078125,
+ 0.32858276, 0.21975708, -0.050018311, -0.34790039, -0.46588135,
+ -0.26513672, 0.12893677, 0.19259644, 0.11685181, 0.095825195,
+ -0.039154053, -0.041473389, 0.0069274902, -0.14685059, -0.32232666,
+ -0.21795654, 0.051086426, 0.18112183, 0.30905151, 0.47305298,
+ 0.60980225, 0.59518433, 0.46920776, 0.51705933, 0.47116089,
+ 0.31832886, 0.20901489, 0.059539795, -0.10055542, -0.23834229,
+ -0.26708984, -0.27468872, -0.29516602, -0.22879028, -0.12854004,
+ -0.064300537, -0.0068664551, 0.060211182, 0.10339355, 0.12594604,
+ 0.12954712, 0.063568115, -0.041046143, -0.1184082, -0.19332886,
+ -0.27337646, -0.34906006, -0.40966797, -0.46533203, -0.45361328,
+ -0.39672852, -0.32958984, -0.15246582, 0.086853027, 0.23678589,
+ 0.24838257, 0.13034058, -0.15222168, -0.5199585, -0.80224609,
+ -0.9397583, -0.89654541, -0.71923828, -0.47998047, -0.14666748,
+ 0.26187134, 0.54995728, 0.69186401, 0.84616089, 0.79928589,
+ 0.53170776, 0.39968872, 0.32455444, 0.2137146, 0.19454956,
+ 0.24069214, 0.22750854, 0.14596558, 0.047058105, -0.04876709,
+ -0.13095093, -0.19775391, -0.16293335, -0.059265137, 0.027526855,
+ 0.13961792, 0.26803589, 0.35470581, 0.37600708, 0.34085083,
+ 0.2572937, 0.13265991, -0.008026123, -0.12841797, -0.22216797,
+ -0.30899048, -0.37841797, -0.4251709, -0.45947266, -0.48376465,
+ -0.50341797, -0.52294922, -0.54516602, -0.58447266, -0.62121582,
+ -0.63989258, -0.64990234, -0.63037109, -0.568573, -0.46630859,
+ -0.36468506, -0.27618408, -0.18487549, -0.11065674, -0.070404053,
+ -0.066101074, -0.049835205, -0.026611328, -0.013061523,
+ 0.011444092, 0.034576416, 0.046112061, 0.052215576, 0.045501709,
+ 0.030059814, 0.011657715, 0.026489258, 0.056121826, 0.10122681,
+ 0.20016479, 0.33053589, 0.45944214, 0.54830933, 0.57751465, 0.5625,
+ 0.55612183, 0.55319214, 0.5697937, 0.64987183, 0.73553467,
+ 0.78170776, 0.84420776, 0.89987183, 0.90475464, 0.85861206,
+ 0.75338745, 0.57077026, 0.3354187, 0.067779541, -0.1741333,
+ -0.36557007, -0.47802734, -0.51281738, -0.47766113, -0.36865234,
+ -0.22381592, -0.065765381, 0.066680908, 0.12365723, 0.098114014,
+ 0.020965576, -0.10775757, -0.27294922, -0.41845703, -0.50146484,
+ -0.52563477, -0.48291016, -0.38186646, -0.27264404, -0.16925049,
+ -0.07043457, 0.003326416, 0.025085449, -0.028320312, -0.11358643,
+ -0.18164062, -0.21984863, -0.21286011, -0.16635132, -0.12728882,
+ -0.088104248, 0.016693115, 0.18893433, 0.40280151, 0.59127808,
+ 0.67233276, 0.64682007, 0.54733276, 0.4213562, 0.30703735,
+ 0.19845581, 0.12661743, 0.095611572, 0.10531616, 0.17950439,
+ 0.29904175, 0.41726685, 0.47506714, 0.48678589, 0.48873901,
+ 0.46694946, 0.42233276, 0.38088989, 0.34689331, 0.30709839,
+ 0.26022339, 0.18258667, 0.064544678, -0.09085083, -0.25634766,
+ -0.41540527, -0.54693604, -0.62731934, -0.6809082, -0.70849609,
+ -0.71044922, -0.68469238, -0.64886475, -0.62115479, -0.6104126,
+ -0.62451172, -0.65185547, -0.67504883, -0.68969727, -0.70257568,
+ -0.71337891, -0.68994141, -0.61865234, -0.49755859, -0.32177734,
+ -0.10437012, 0.11209106, 0.30691528, 0.46789551, 0.51602173,
+ 0.44674683, 0.32055664, 0.1769104, 0.06072998, 0.0075378418,
+ -0.013641357, -0.0038146973, 0.082244873, 0.22116089, 0.35787964,
+ 0.47689819, 0.60266113, 0.71801758, 0.81747437, 0.91799927,
+ 0.97079468, 0.97677612, 0.93850708, 0.83322144, 0.65866089,
+ 0.42324829, 0.14834595, -0.10574341, -0.31484985, -0.46813965,
+ -0.54833984, -0.55517578, -0.51220703, -0.43115234, -0.34613037,
+ -0.29052734, -0.2699585, -0.29443359, -0.33349609, -0.38720703,
+ -0.45751953, -0.51318359, -0.54800415, -0.55706787, -0.5402832,
+ -0.48666382, -0.41162109, -0.32958984, -0.24560547, -0.19873047,
+ -0.18457031, -0.19171143, -0.21240234, -0.23876953, -0.25823975,
+ -0.26184082, -0.24902344, -0.21612549, -0.16552734, -0.11083984,
+ -0.058349609, -0.0034179688, 0.053283691, 0.12722778, 0.23052979,
+ 0.35769653, 0.51147461, 0.68243408, 0.85015869, 0.96902466,
+ 0.99908447, 0.99899292, 0.99453735, 0.87936401, 0.72964478,
+ 0.59124756, 0.45162964, 0.29949951, 0.18435669, 0.087219238,
+ 0.0085754395, -0.031677246, -0.057434082, -0.06338501,
+ -0.050262451, -0.021179199, 0.010986328, 0.035095215, 0.041900635,
+ 0.026275635, -0.008972168, -0.067260742, -0.14938354, -0.24298096,
+ -0.33901978, -0.44342041, -0.53179932, -0.59924316, -0.64294434,
+ -0.66220093, -0.65362549, -0.61437988, -0.56277466, -0.48764038,
+ -0.41287231, -0.3420105, -0.25909424, -0.17782593, -0.10604858,
+ -0.033355713, 0.037872314, 0.097198486, 0.15203857, 0.19644165,
+ 0.23324585, 0.2668457, 0.29403687, 0.31442261, 0.33148193,
+ 0.33639526, 0.32794189, 0.31109619, 0.30651855, 0.30456543,
+ 0.31005859, 0.32266235, 0.34017944, 0.36062622, 0.37988281,
+ 0.39459229, 0.40344238, 0.41464233, 0.41500854, 0.41091919,
+ 0.40512085, 0.39819336, 0.3843689, 0.36633301, 0.33621216,
+ 0.28076172, 0.19436646, 0.083892822, -0.056732178, -0.21832275,
+ -0.38809204, -0.55502319, -0.70330811, -0.82672119, -0.909729,
+ -0.93505859, -0.9085083, -0.84347534, -0.74786377, -0.63342285,
+ -0.52468872, -0.42883301, -0.35321045, -0.29504395, -0.26339722,
+ -0.23782349, -0.21252441, -0.19006348, -0.16159058, -0.12472534,
+ -0.075958252, -0.012115479, 0.056091309, 0.11953735, 0.17373657,
+ 0.22116089, 0.25097656, 0.25982666, 0.2539978, 0.24578857,
+ 0.24325562, 0.25292969, 0.28744507, 0.34677124, 0.42510986,
+ 0.51596069, 0.60205078, 0.67550659, 0.71774292, 0.728302,
+ 0.70874023, 0.6612854, 0.59188843, 0.49536133, 0.37322998,
+ 0.23904419, 0.10256958, -0.030303955, -0.15093994, -0.24526978,
+ -0.31253052, -0.3414917, -0.33178711, -0.29302979, -0.23806763,
+ -0.17816162, -0.13470459, -0.12387085, -0.15142822, -0.20706177,
+ -0.28427124, -0.37112427, -0.44927979, -0.50619507, -0.53219604,
+ -0.53118896, -0.49990845, -0.45379639, -0.39599609, -0.31643677,
+ -0.22329712, -0.15414429, -0.1050415, -0.075592041, -0.0753479,
+ -0.088775635, -0.099090576, -0.086639404, -0.035797119,
+ 0.052154541, 0.1661377, 0.28082275, 0.39169312, 0.50491333,
+ 0.59762573, 0.67288208, 0.71621704, 0.73251343, 0.71405029,
+ 0.66171265, 0.60040283, 0.53762817, 0.46520996, 0.3727417,
+ 0.26971436, 0.17245483, 0.092346191, 0.034851074, 0.0072937012,
+ 0.007232666, 0.017547607, 0.01852417, 0.020172119, 0.023345947,
+ 0.014434814, -0.013946533, -0.054168701, -0.094726562, -0.14425659,
+ -0.20623779, -0.27316284, -0.34069824, -0.40481567, -0.4647522,
+ -0.51278687, -0.55215454, -0.57962036, -0.58953857, -0.59140015,
+ -0.57885742, -0.55456543, -0.51055908, -0.45095825, -0.37948608,
+ -0.29974365, -0.22027588, -0.13543701, -0.047271729, 0.033721924,
+ 0.1005249, 0.14877319, 0.18429565, 0.20465088, 0.21621704,
+ 0.2272644, 0.23416138, 0.24511719, 0.26138306, 0.2805481,
+ 0.3006897, 0.32943726, 0.36660767, 0.40802002, 0.44424438,
+ 0.47698975, 0.50256348, 0.52005005, 0.5267334, 0.52258301,
+ 0.50723267, 0.47485352, 0.42205811, 0.34805298, 0.26202393,
+ 0.16522217, 0.067749023, -0.024169922, -0.1060791, -0.18280029,
+ -0.25424194, -0.31921387, -0.37774658, -0.43612671, -0.50094604,
+ -0.56121826, -0.61495972, -0.66091919, -0.69436646, -0.70004272,
+ -0.67868042, -0.63104248, -0.56182861, -0.48074341, -0.39840698,
+ -0.31900024, -0.24609375, -0.18695068, -0.1461792, -0.11993408,
+ -0.11032104, -0.10159302, -0.091918945, -0.076904297, -0.069580078,
+ -0.058898926, -0.038146973, -0.012542725, 0.014831543, 0.043304443,
+ 0.082824707, 0.13180542, 0.1895752, 0.25256348, 0.32229614,
+ 0.38531494, 0.43493652, 0.4697876, 0.48736572, 0.48733521,
+ 0.46533203, 0.42901611, 0.38223267, 0.33636475, 0.2819519,
+ 0.22467041, 0.16455078, 0.10604858, 0.047485352, -0.010040283,
+ -0.057098389, -0.093933105, -0.12252808, -0.14291382, -0.15545654,
+ -0.16064453, -0.16348267, -0.16918945, -0.17095947, -0.17773438,
+ -0.19436646, -0.21868896, -0.25158691, -0.2890625, -0.33297729,
+ -0.37677002, -0.41171265, -0.43563843, -0.44619751, -0.44320679,
+ -0.42520142, -0.39151001, -0.34609985, -0.29324341, -0.23846436,
+ -0.18026733, -0.12319946, -0.068023682, -0.017944336, 0.033691406,
+ 0.08416748, 0.13388062, 0.18310547, 0.23513794, 0.28579712,
+ 0.3314209, 0.37133789, 0.40841675, 0.44143677, 0.46252441,
+ 0.47073364, 0.46435547, 0.44342041, 0.40725708, 0.35971069,
+ 0.30911255, 0.26272583, 0.22372437, 0.19876099, 0.18948364,
+ 0.18948364, 0.19799805, 0.21658325, 0.23733521, 0.25439453,
+ 0.26513672, 0.26702881, 0.25582886, 0.2338562, 0.19677734,
+ 0.15100098, 0.097106934, 0.036804199, -0.02456665, -0.087005615,
+ -0.14819336, -0.20632935, -0.26040649, -0.30117798, -0.33422852,
+ -0.35610962, -0.36178589, -0.3522644, -0.3237915, -0.28857422,
+ -0.24789429, -0.20108032, -0.14822388, -0.097442627, -0.055877686,
+ -0.019500732, 0.0064086914, 0.024627686, 0.033721924, 0.042114258,
+ 0.052032471, 0.069763184, 0.094207764, 0.12030029, 0.14993286,
+ 0.18215942, 0.22003174, 0.26171875, 0.30029297, 0.33355713,
+ 0.35992432, 0.3833313, 0.40148926, 0.41094971, 0.40899658,
+ 0.39849854, 0.37387085, 0.34091187, 0.30215454, 0.26016235,
+ 0.2170105, 0.17681885, 0.13604736, 0.093658447, 0.049316406,
+ 0.0074462891, -0.037322998, -0.086120605, -0.13262939, -0.18286133,
+ -0.22872925, -0.26879883, -0.3026123, -0.33206177, -0.35943604,
+ -0.37924194, -0.39431763, -0.40466309, -0.40936279, -0.40270996,
+ -0.38815308, -0.36676025, -0.3421936, -0.31149292, -0.27597046,
+ -0.24679565, -0.22177124, -0.20294189, -0.19259644, -0.18527222,
+ -0.18157959, -0.17645264, -0.16998291, -0.1524353, -0.12554932,
+ -0.086669922, -0.03894043, 0.016204834, 0.075744629, 0.13665771,
+ 0.18896484, 0.23040771, 0.26107788, 0.28408813, 0.29443359,
+ 0.29440308, 0.28460693, 0.27456665, 0.26107788, 0.24020386,
+ 0.21322632, 0.18551636, 0.15698242, 0.12554932, 0.095855713,
+ 0.069152832, 0.045501709, 0.020141602, -0.0030517578, -0.026702881,
+ -0.0496521, -0.071960449, -0.098327637, -0.12268066, -0.14907837,
+ -0.17523193, -0.20068359, -0.22494507, -0.2482605, -0.27352905,
+ -0.29666138, -0.31420898, -0.32751465, -0.33670044, -0.33874512,
+ -0.32943726, -0.31417847, -0.29504395, -0.26898193, -0.23904419,
+ -0.20245361, -0.16390991, -0.1210022, -0.078308105, -0.039337158,
+ -0.0037231445, 0.029174805, 0.05847168, 0.084106445, 0.1078186,
+ 0.13174438, 0.15719604, 0.17941284, 0.20126343, 0.22348022,
+ 0.2432251, 0.2578125, 0.2640686, 0.26593018, 0.25933838,
+ 0.24685669, 0.2288208, 0.21047974, 0.19494629, 0.18075562,
+ 0.17199707, 0.17199707, 0.17175293, 0.1729126, 0.17126465,
+ 0.16873169, 0.16256714, 0.15036011, 0.1355896, 0.11254883,
+ 0.083465576, 0.050079346, 0.01159668, -0.030029297, -0.074707031,
+ -0.11532593, -0.15432739, -0.18942261, -0.21673584, -0.23681641,
+ -0.24554443, -0.24703979, -0.24472046, -0.23815918, -0.22784424,
+ -0.21243286, -0.19384766, -0.17596436, -0.15844727, -0.14089966,
+ -0.12030029, -0.099395752, -0.076538086, -0.058746338,
+ -0.034484863, -0.0097351074, 0.015625, 0.037445068, 0.063079834,
+ 0.087738037, 0.11401367, 0.13973999, 0.16848755, 0.19680786,
+ 0.2244873, 0.25567627, 0.28305054, 0.30465698, 0.31854248,
+ 0.32287598, 0.31808472, 0.30102539, 0.27633667, 0.24591064,
+ 0.20962524, 0.17144775, 0.13021851, 0.09487915, 0.057861328,
+ 0.023651123, -0.014129639, -0.051239014, -0.086639404, -0.12316895,
+ -0.15304565, -0.18545532, -0.21154785, -0.23434448, -0.25100708,
+ -0.26113892, -0.26712036, -0.26678467, -0.26687622, -0.262146,
+ -0.25656128, -0.24734497, -0.23501587, -0.22433472, -0.20773315,
+ -0.19207764, -0.17459106, -0.15997314, -0.14196777, -0.12670898,
+ -0.1166687, -0.10726929, -0.099243164, -0.090179443, -0.078521729,
+ -0.062225342, -0.038360596, -0.0068054199, 0.031402588,
+ 0.072143555, 0.11181641, 0.15362549, 0.19085693, 0.22195435,
+ 0.24661255, 0.26379395, 0.27166748, 0.27072144, 0.26507568,
+ 0.25247192, 0.2348938, 0.21447754, 0.18756104, 0.15771484,
+ 0.13241577, 0.10873413, 0.087036133, 0.065460205, 0.046875,
+ 0.029754639, 0.013153076, -0.0065917969, -0.024993896,
+ -0.046051025, -0.067810059, -0.092285156, -0.11779785, -0.14529419,
+ -0.17376709, -0.19503784, -0.21487427, -0.23205566, -0.24533081,
+ -0.25128174, -0.2522583, -0.24685669, -0.23486328, -0.21954346,
+ -0.19946289, -0.1786499, -0.15280151, -0.12744141, -0.098022461,
+ -0.069091797, -0.038146973, -0.0079040527, 0.024719238,
+ 0.054351807, 0.082275391, 0.11019897, 0.13510132, 0.15545654,
+ 0.17276001, 0.1854248, 0.19042969, 0.19281006, 0.1930542,
+ 0.19232178, 0.18795776, 0.17938232, 0.17156982, 0.16223145,
+ 0.15603638, 0.15182495, 0.15118408, 0.14651489, 0.14263916,
+ 0.13916016, 0.1343689, 0.12649536, 0.11480713, 0.10400391,
+ 0.091766357, 0.079589844, 0.063781738, 0.04776001, 0.029510498,
+ 0.013061523, -0.0087890625, -0.034454346, -0.06362915,
+ -0.097381592, -0.12896729, -0.15893555, -0.18429565, -0.20910645,
+ -0.22930908, -0.2411499, -0.25009155, -0.2505188, -0.24719238,
+ -0.23956299, -0.22445679, -0.20892334, -0.18774414, -0.16699219,
+ -0.14205933, -0.12145996, -0.10317993, -0.085449219, -0.066101074,
+ -0.050048828, -0.03326416, -0.014404297, 0.0099182129, 0.041809082,
+ 0.077087402, 0.11599731, 0.14718628, 0.18060303, 0.20654297,
+ 0.23117065, 0.25247192, 0.27026367, 0.28042603, 0.27871704,
+ 0.27175903, 0.25527954, 0.2315979, 0.20584106, 0.17654419,
+ 0.1446228, 0.1086731, 0.073699951, 0.040588379, 0.011627197,
+ -0.016143799, -0.044189453, -0.071838379, -0.098449707,
+ -0.12316895, -0.14602661, -0.16595459, -0.17871094, -0.18606567,
+ -0.19488525, -0.20278931, -0.209198, -0.21121216, -0.21276855,
+ -0.21395874, -0.21328735, -0.21072388, -0.20718384, -0.20404053,
+ -0.19812012, -0.19073486, -0.17901611, -0.16781616, -0.15267944,
+ -0.13824463, -0.12042236, -0.098999023, -0.077453613, -0.053497314,
+ -0.029022217, -0.001373291, 0.022583008, 0.050720215, 0.077026367,
+ 0.10748291, 0.13626099, 0.16424561, 0.18908691, 0.21191406,
+ 0.2300415, 0.2428894, 0.25292969, 0.25643921, 0.25924683,
+ 0.25518799, 0.24127197, 0.22161865, 0.19989014, 0.17800903,
+ 0.14935303, 0.12268066, 0.094787598, 0.068878174, 0.041046143,
+ 0.018585205, 0.0020141602, -0.0094604492, -0.01651001, -0.02243042,
+ -0.031860352, -0.049102783, -0.072113037, -0.098083496,
+ -0.12472534, -0.14935303, -0.17062378, -0.18566895, -0.19500732,
+ -0.19784546, -0.19299316, -0.18365479, -0.17153931, -0.1555481,
+ -0.13491821, -0.11233521, -0.090209961, -0.063781738, -0.038879395,
+ -0.017089844, 0.0027770996, 0.021697998, 0.041046143, 0.059844971,
+ 0.078674316, 0.093536377, 0.10656738, 0.11816406, 0.12698364,
+ 0.13323975, 0.13742065, 0.14559937, 0.1522522, 0.15563965,
+ 0.15548706, 0.1583252, 0.15756226, 0.15576172, 0.15216064,
+ 0.1479187, 0.14260864, 0.13577271, 0.1272583, 0.11904907,
+ 0.10968018, 0.10412598, 0.096618652, 0.087615967, 0.07522583,
+ 0.059265137, 0.039978027, 0.017852783, -0.0061950684, -0.029510498,
+ -0.05065918, -0.075500488, -0.099395752, -0.12225342, -0.1418457,
+ -0.16101074, -0.17797852, -0.1932373, -0.20556641, -0.20901489,
+ -0.21026611, -0.20684814, -0.20016479, -0.18768311, -0.17312622,
+ -0.15994263, -0.14834595, -0.13482666, -0.11865234, -0.10229492,
+ -0.083404541, -0.063079834, -0.039276123, -0.014129639,
+ 0.011199951, 0.035583496, 0.059417725, 0.079925537, 0.098571777,
+ 0.11416626, 0.1270752, 0.14013672, 0.15286255, 0.16619873,
+ 0.17810059, 0.18783569, 0.19454956, 0.19598389, 0.19143677,
+ 0.18264771, 0.16867065, 0.15258789, 0.13143921, 0.10482788,
+ 0.075073242, 0.045928955, 0.018371582, -0.0075683594, -0.032928467,
+ -0.054992676, -0.072662354, -0.089813232, -0.10479736, -0.12127686,
+ -0.13748169, -0.15161133, -0.16473389, -0.17370605, -0.18240356,
+ -0.18569946, -0.18682861, -0.18756104, -0.18310547, -0.18099976,
+ -0.17584229, -0.17102051, -0.16162109, -0.15145874, -0.1421814,
+ -0.12973022, -0.11398315, -0.096557617, -0.078460693, -0.061035156,
+ -0.042541504, -0.023590088, -0.0029296875, 0.020996094,
+ 0.044403076, 0.068237305, 0.092926025, 0.11682129, 0.13772583,
+ 0.15460205, 0.17050171, 0.18438721, 0.19360352, 0.19952393,
+ 0.20303345, 0.2048645, 0.20132446, 0.1930542, 0.18280029,
+ 0.16989136, 0.1546936, 0.13711548, 0.12115479, 0.10336304,
+ 0.087890625, 0.068023682, 0.049804688, 0.028320312, 0.0081787109,
+ -0.012664795, -0.030334473, -0.046783447, -0.061584473,
+ -0.073883057, -0.084655762, -0.093719482, -0.10314941, -0.11251831,
+ -0.12094116, -0.1300354, -0.13421631, -0.13647461, -0.13491821,
+ -0.13186646, -0.12530518, -0.11520386, -0.10275269, -0.088775635,
+ -0.074310303, -0.061462402, -0.046875, -0.032409668, -0.014892578,
+ 0.00057983398, 0.016967773, 0.031738281, 0.0440979, 0.054656982,
+ 0.063659668, 0.073791504, 0.081176758, 0.088562012, 0.095916748,
+ 0.10043335, 0.10443115, 0.10519409, 0.1076355, 0.1071167,
+ 0.10748291, 0.10601807, 0.1026001, 0.10031128, 0.095123291,
+ 0.08972168, 0.082763672, 0.075164795, 0.06729126, 0.057922363,
+ 0.049865723, 0.042144775, 0.035125732, 0.026367188, 0.016571045,
+ 0.0040893555, -0.0084228516, -0.025054932, -0.042053223,
+ -0.060974121, -0.077178955, -0.093902588, -0.10845947, -0.1229248,
+ -0.13531494, -0.14489746, -0.15274048, -0.15701294, -0.15966797,
+ -0.15670776, -0.15130615, -0.140625, -0.12561035, -0.10900879,
+ -0.091644287, -0.077362061, -0.063690186, -0.051879883,
+ -0.04083252, -0.028869629, -0.017059326, -0.0053710938,
+ 0.0051574707, 0.020172119, 0.034484863, 0.051361084, 0.067810059,
+ 0.085540771, 0.10223389, 0.11761475, 0.13146973, 0.14044189,
+ 0.1468811, 0.14923096, 0.14846802, 0.14407349, 0.13641357,
+ 0.12796021, 0.11773682, 0.1076355, 0.09463501, 0.081207275,
+ 0.065124512, 0.050323486, 0.035552979, 0.020965576, 0.0063476562,
+ -0.0094299316, -0.024810791, -0.040008545, -0.054534912,
+ -0.0703125, -0.084228516, -0.096862793, -0.10809326, -0.1171875,
+ -0.12515259, -0.13067627, -0.13568115, -0.13632202, -0.13449097,
+ -0.131073, -0.12503052, -0.11868286, -0.11099243, -0.10317993,
+ -0.095306396, -0.087158203, -0.077667236, -0.068115234,
+ -0.059082031, -0.047241211, -0.033966064, -0.019805908,
+ -0.0041503906, 0.012573242, 0.030029297, 0.047637939, 0.063751221,
+ 0.079162598, 0.092987061, 0.1055603, 0.11737061, 0.12628174,
+ 0.13504028, 0.14266968, 0.14840698, 0.1519165, 0.15158081,
+ 0.14685059, 0.14041138, 0.13082886, 0.11962891, 0.10525513,
+ 0.089599609, 0.072784424, 0.057556152, 0.044464111, 0.032470703,
+ 0.02053833, 0.0086364746, -0.0019226074, -0.013336182,
+ -0.026184082, -0.039398193, -0.052368164, -0.064605713,
+ -0.076293945, -0.086303711, -0.09475708, -0.10128784, -0.10568237,
+ -0.10748291, -0.10894775, -0.10787964, -0.10577393, -0.10229492,
+ -0.097198486, -0.090087891, -0.081695557, -0.07244873,
+ -0.062927246, -0.051940918, -0.041748047, -0.028839111,
+ -0.015960693, -0.0022277832, 0.011779785, 0.024932861, 0.038482666,
+ 0.048614502, 0.059326172, 0.066925049, 0.072021484, 0.077026367,
+ 0.079681396, 0.082733154, 0.082855225, 0.081481934, 0.08001709,
+ 0.079833984, 0.079345703, 0.079162598, 0.078582764, 0.078521729,
+ 0.078582764, 0.077575684, 0.073059082, 0.065612793, 0.055480957,
+ 0.044189453, 0.031768799, 0.019744873, 0.008972168, -0.00094604492,
+ -0.0081176758, -0.013885498, -0.018463135, -0.025634766,
+ -0.032623291, -0.041442871, -0.05279541, -0.0652771, -0.078399658,
+ -0.088256836, -0.098297119, -0.10681152, -0.112854, -0.11355591,
+ -0.11132812, -0.10617065, -0.098449707, -0.087738037, -0.077606201,
+ -0.068054199, -0.059051514, -0.051330566, -0.041503906,
+ -0.031066895, -0.019470215, -0.0077514648, 0.0030517578,
+ 0.014892578, 0.026062012, 0.038879395, 0.050079346, 0.060028076,
+ 0.069793701, 0.076568604, 0.082611084, 0.088989258, 0.094360352,
+ 0.098754883, 0.10293579, 0.10635376, 0.10720825, 0.10586548,
+ 0.10314941, 0.0987854, 0.093475342, 0.087432861, 0.079406738,
+ 0.070159912, 0.059204102, 0.048095703, 0.036529541, 0.023071289,
+ 0.010406494, -0.0024719238, -0.01361084, -0.026184082,
+ -0.036682129, -0.047180176, -0.056213379, -0.065765381,
+ -0.07510376, -0.082702637, -0.091064453, -0.09677124, -0.10232544,
+ -0.10546875, -0.1072998, -0.10693359, -0.10385132, -0.10055542,
+ -0.093078613, -0.085235596, -0.075439453, -0.065643311,
+ -0.054138184, -0.042449951, -0.029785156, -0.017822266,
+ -0.0068359375, 0.0038452148, 0.01373291, 0.023773193, 0.033081055,
+ 0.042053223, 0.049560547, 0.057952881, 0.066223145, 0.075775146,
+ 0.083190918, 0.08984375, 0.096191406, 0.10202026, 0.10595703,
+ 0.10742188, 0.10778809, 0.10528564, 0.1020813, 0.096069336,
+ 0.08883667, 0.07925415, 0.069458008, 0.057952881, 0.047454834,
+ 0.036804199, 0.026397705, 0.015777588, 0.004119873, -0.0077819824,
+ -0.019927979, -0.030822754, -0.040405273, -0.048980713,
+ -0.056610107, -0.062805176, -0.069366455, -0.074035645,
+ -0.077026367, -0.079406738, -0.079986572, -0.080322266,
+ -0.078338623, -0.07598877, -0.072479248, -0.067230225,
+ -0.061218262, -0.055847168, -0.050048828, -0.043823242,
+ -0.037536621, -0.030792236, -0.02230835, -0.012634277,
+ -0.0030822754, 0.0069580078, 0.016204834, 0.023040771, 0.03024292,
+ 0.036865234, 0.043518066, 0.051025391, 0.056396484, 0.061645508,
+ 0.063720703, 0.065185547, 0.065032959, 0.0652771, 0.06439209,
+ 0.06451416, 0.063598633, 0.062011719, 0.058654785, 0.055297852,
+ 0.053131104, 0.051208496, 0.048950195, 0.046905518, 0.042175293,
+ 0.035675049, 0.028411865, 0.019622803, 0.0091247559, -0.0016174316,
+ -0.012207031, -0.022521973, -0.031616211, -0.040618896,
+ -0.047302246, -0.052734375, -0.057098389, -0.060455322,
+ -0.064849854, -0.068664551, -0.07321167, -0.074829102, -0.07623291,
+ -0.075378418, -0.072814941, -0.069152832, -0.064819336,
+ -0.059417725, -0.052368164, -0.044769287, -0.036712646,
+ -0.027679443, -0.018005371, -0.0093383789, 0.0010375977,
+ 0.011474609, 0.022399902, 0.03125, 0.03793335, 0.042449951,
+ 0.045379639, 0.048065186, 0.050567627, 0.054260254, 0.058166504,
+ 0.062316895, 0.066436768, 0.068786621, 0.072113037, 0.074707031,
+ 0.077453613, 0.076507568, 0.074523926, 0.071838379, 0.06729126,
+ 0.061126709, 0.053771973, 0.045410156, 0.037078857, 0.027862549,
+ 0.019134521, 0.0096435547, 0.00079345703, -0.0076293945,
+ -0.016296387, -0.024810791, -0.034454346, -0.043334961,
+ -0.052703857, -0.06048584, -0.066101074, -0.070739746, -0.07220459,
+ -0.073394775, -0.072967529, -0.072509766, -0.072296143,
+ -0.070404053, -0.06842041, -0.064819336, -0.062072754,
+ -0.058624268, -0.05380249, -0.048400879, -0.039764404,
+ -0.031280518, -0.021881104, -0.012786865, -0.0053100586,
+ 0.0022888184, 0.0081176758, 0.014038086, 0.020568848, 0.026885986,
+ 0.032867432, 0.037628174, 0.042999268, 0.046722412, 0.052276611,
+ 0.056884766, 0.061584473, 0.065124512, 0.066955566, 0.068054199,
+ 0.067565918, 0.066589355, 0.06362915, 0.058410645, 0.052764893,
+ 0.045349121, 0.036987305, 0.029144287, 0.021606445, 0.015197754,
+ 0.0087280273, 0.0020446777, -0.004699707, -0.012115479,
+ -0.018920898, -0.02633667, -0.032897949, -0.037841797,
+ -0.042205811, -0.046783447, -0.050567627, -0.055114746,
+ -0.05847168, -0.061004639, -0.061401367, -0.059173584,
+ -0.056915283, -0.053955078, -0.049255371, -0.043121338,
+ -0.037384033, -0.032501221, -0.027709961, -0.023468018,
+ -0.018951416, -0.01385498, -0.0096740723, -0.005279541,
+ -0.0010986328, 0.0033874512, 0.0088806152, 0.01348877, 0.01953125,
+ 0.025024414, 0.031097412, 0.036895752, 0.0418396, 0.045837402,
+ 0.048492432, 0.050231934, 0.051208496, 0.052490234, 0.052856445,
+ 0.053344727, 0.052581787, 0.051452637, 0.049224854, 0.046356201,
+ 0.042938232, 0.038543701, 0.034362793, 0.029602051, 0.025726318,
+ 0.021606445, 0.017272949, 0.013641357, 0.009185791, 0.0037841797,
+ -0.0022888184, -0.0105896, -0.019439697, -0.027709961,
+ -0.034454346, -0.039642334, -0.044464111, -0.046569824,
+ -0.048400879, -0.047546387, -0.046142578, -0.043395996,
+ -0.040405273, -0.037994385, -0.035217285, -0.03414917,
+ -0.031890869, -0.029205322, -0.026306152, -0.021820068,
+ -0.018035889, -0.01361084, -0.0084228516, -0.001373291,
+ 0.0057067871, 0.011962891, 0.018157959, 0.022766113, 0.02722168,
+ 0.030090332, 0.032928467, 0.03503418, 0.036895752, 0.039001465,
+ 0.04107666, 0.042816162, 0.04397583, 0.045074463, 0.045562744,
+ 0.045654297, 0.045532227, 0.045135498, 0.043518066, 0.040618896,
+ 0.036437988, 0.032012939, 0.027099609, 0.021911621, 0.016296387,
+ 0.010955811, 0.006072998, 0.00048828125, -0.0053100586,
+ -0.011535645, -0.017303467, -0.023529053, -0.028717041,
+ -0.03427124, -0.038604736, -0.042572021, -0.045074463,
+ -0.046661377, -0.047851562, -0.04776001, -0.047668457,
+ -0.046691895, -0.045379639, -0.04385376, -0.042297363,
+ -0.040435791, -0.037322998, -0.033691406, -0.029205322,
+ -0.024749756, -0.019775391, -0.014556885, -0.0090942383,
+ -0.0034790039, 0.0011901855, 0.0063171387, 0.0095214844,
+ 0.013519287, 0.016174316, 0.019622803, 0.022094727, 0.024627686,
+ 0.027435303, 0.029876709, 0.032958984, 0.035858154, 0.038208008,
+ 0.039398193, 0.040374756, 0.040222168, 0.039978027, 0.039154053,
+ 0.037811279, 0.034820557, 0.030822754, 0.025695801, 0.020721436,
+ 0.015991211, 0.010864258, 0.006439209, 0.0018005371, -0.002166748,
+ -0.0062561035, -0.0096740723, -0.013244629, -0.01663208,
+ -0.019927979, -0.023742676, -0.026611328, -0.029907227,
+ -0.032684326, -0.035064697, -0.037261963, -0.037811279,
+ -0.037902832, -0.036437988, -0.033233643, -0.029876709,
+ -0.026031494, -0.021759033, -0.017456055, -0.014251709,
+ -0.011566162, -0.0094909668, -0.0071105957, -0.0048217773,
+ -0.0027770996, 0.00036621094, 0.0036010742, 0.0076904297,
+ 0.01159668, 0.015350342, 0.019226074, 0.021697998, 0.024749756,
+ 0.026947021, 0.029266357, 0.030853271, 0.032104492, 0.032470703,
+ 0.032165527, 0.03225708, 0.031860352, 0.03213501, 0.032104492,
+ 0.03213501, 0.031860352, 0.031005859, 0.029205322, 0.026550293,
+ 0.023406982, 0.01940918, 0.015258789, 0.010437012, 0.005859375,
+ 0.0013122559, -0.003112793, -0.0067443848, -0.010040283,
+ -0.01361084, -0.016662598, -0.020324707, -0.023193359,
+ -0.026062012, -0.028503418, -0.029663086, -0.030487061,
+ -0.030059814, -0.029418945, -0.027374268, -0.025024414,
+ -0.022857666, -0.0206604, -0.018585205, -0.016113281, -0.013397217,
+ -0.010192871, -0.0072021484, -0.0043029785, -0.002166748, 0,
+ 0.0024414062, 0.005065918, 0.0079345703, 0.01071167, 0.012878418,
+ 0.015380859, 0.017669678, 0.019958496, 0.021575928, 0.023284912,
+ 0.024078369, 0.024719238, 0.025024414, 0.02557373, 0.02633667,
+ 0.026275635, 0.02520752, 0.024017334, 0.022369385, 0.021057129,
+ 0.019622803, 0.017578125, 0.015258789, 0.012054443, 0.0086975098,
+ 0.0051269531, 0.0020141602, -0.00082397461, -0.00390625,
+ -0.0068054199, -0.010406494, -0.014129639, -0.017425537,
+ -0.020385742, -0.02230835, -0.025054932, -0.026916504,
+ -0.028961182, -0.029724121, -0.029937744, -0.029907227,
+ -0.02911377, -0.027770996, -0.025238037, -0.023010254,
+ -0.019714355, -0.016540527, -0.013641357, -0.011077881,
+ -0.008605957, -0.0062866211, -0.0043945312, -0.0021972656,
+ -0.00067138672, 0.0012512207, 0.0020751953, 0.0036315918,
+ 0.0053405762, 0.0081481934, 0.011352539, 0.014709473, 0.017944336,
+ 0.020202637, 0.022003174, 0.023742676, 0.02520752, 0.026031494,
+ 0.026062012, 0.025421143, 0.024261475, 0.022766113, 0.020904541,
+ 0.019287109, 0.017852783, 0.017333984, 0.017181396, 0.016357422,
+ 0.014770508, 0.012298584, 0.0095825195, 0.0057373047, 0.0017089844,
+ -0.0032043457, -0.0075073242, -0.011260986, -0.014068604,
+ -0.016021729, -0.017608643, -0.0184021, -0.019104004, -0.019775391,
+ -0.020507812, -0.020721436, -0.020355225, -0.019348145,
+ -0.017974854, -0.016235352, -0.014648438, -0.013183594,
+ -0.011657715, -0.010498047, -0.0097961426, -0.0091552734,
+ -0.0082702637, -0.0070800781, -0.0055236816, -0.003112793,
+ -0.00054931641, 0.0024719238, 0.0049743652, 0.0075073242,
+ 0.0095825195, 0.011352539, 0.012512207, 0.013580322, 0.014251709,
+ 0.015045166, 0.016113281, 0.017089844, 0.018096924, 0.018890381,
+ 0.019897461, 0.020629883, 0.020965576, 0.020782471, 0.019744873,
+ 0.018371582, 0.016113281, 0.014068604, 0.011260986, 0.0094604492,
+ 0.0072631836, 0.0054016113, 0.0033874512, 0.0014343262,
+ -0.0007019043, -0.0032958984, -0.0055847168, -0.0082397461,
+ -0.010650635, -0.013275146, -0.015167236, -0.016662598,
+ -0.017852783, -0.018218994, -0.018157959, -0.017486572,
+ -0.017181396, -0.01675415, -0.01651001, -0.015808105, -0.015014648,
+ -0.01385498, -0.012390137, -0.01083374, -0.0090332031,
+ -0.0072937012, -0.0054626465, -0.0038757324, -0.0022888184,
+ -0.00051879883, 0.0011901855, 0.0027770996, 0.0043334961,
+ 0.0057067871, 0.0071716309, 0.0084533691, 0.010101318, 0.011047363,
+ 0.011993408, 0.012969971, 0.013092041, 0.013427734, 0.013641357,
+ 0.013946533, 0.014221191, 0.014099121, 0.01385498, 0.012756348,
+ 0.012054443, 0.011322021, 0.010162354, 0.0087280273, 0.0073547363,
+ 0.0061950684, 0.0046386719, 0.0029602051, 0.0014953613,
+ -0.00033569336, -0.0021362305, -0.0043640137, -0.0064086914,
+ -0.0086975098, -0.010498047, -0.012023926, -0.013092041,
+ -0.013366699, -0.01348877, -0.013793945, -0.013763428,
+ -0.013977051, -0.013824463, -0.013519287, -0.013305664,
+ -0.012878418, -0.012390137, -0.011352539, -0.010131836,
+ -0.0085144043, -0.0065307617, -0.0048217773, -0.0028076172,
+ -0.00094604492, 0.00082397461, 0.0019836426, 0.0028991699,
+ 0.0037841797, 0.0042114258, 0.0050048828, 0.0057067871,
+ 0.0067443848, 0.0078735352, 0.0088195801, 0.0099182129,
+ 0.010986328, 0.011657715, 0.012145996, 0.012573242, 0.012969971,
+ 0.013000488, 0.0128479, 0.012481689, 0.011993408, 0.011352539,
+ 0.010498047, 0.0093688965, 0.0081176758, 0.0067749023,
+ 0.0054931641, 0.0044250488, 0.0032958984, 0.001953125,
+ 0.00054931641, -0.00085449219, -0.0026855469, -0.0042114258,
+ -0.0060119629, -0.0071716309, -0.0086364746, -0.0095825195,
+ -0.010284424, -0.010528564, -0.010498047, -0.010284424,
+ -0.0096740723, -0.0094299316, -0.0088195801, -0.0082092285,
+ -0.0076599121, -0.007232666, -0.0068359375, -0.0063171387,
+ -0.0056152344, -0.0047607422, -0.0038146973, -0.0027770996,
+ -0.0015563965, -0.00061035156, 0.00057983398, 0.0016174316,
+ 0.002532959, 0.0032348633, 0.0037536621, 0.0041503906,
+ 0.0043945312, 0.0048217773, 0.0053405762, 0.0060119629,
+ 0.0067443848, 0.0075073242, 0.0080566406, 0.0084228516,
+ 0.008392334, 0.0083618164, 0.0080566406, 0.0076293945,
+ 0.0071411133, 0.0067749023, 0.0062255859, 0.0054626465,
+ 0.0046081543, 0.0036315918, 0.0026550293, 0.0014648438,
+ 0.0002746582, -0.00076293945, -0.0018615723, -0.0027160645,
+ -0.0035400391, -0.0041809082, -0.0048522949, -0.0054626465,
+ -0.0061035156, -0.0067138672, -0.0072021484, -0.0072937012,
+ -0.0072937012, -0.0069885254, -0.0065002441, -0.0059204102,
+ -0.0051269531, -0.0045471191, -0.0039672852, -0.0036010742,
+ -0.0031738281, -0.0027770996, -0.0023803711, -0.0018310547,
+ -0.0012817383, -0.00064086914, -3.0517578e-05, 0.00064086914,
+ 0.0011901855, 0.0017700195, 0.0021972656, 0.002532959,
+ 0.0028381348, 0.003112793, 0.0034484863, 0.0038146973,
+ 0.0040893555, 0.0043334961, 0.0044250488, 0.0044555664,
+ 0.0045776367, 0.0046691895, 0.0047302246, 0.0046691895,
+ 0.0045471191, 0.0042724609, 0.00390625, 0.0035095215, 0.0029296875,
+ 0.0024414062, 0.001953125, 0.0014343262, 0.00085449219,
+ 0.00021362305, -0.00018310547, -0.00073242188, -0.0012207031,
+ -0.001739502, -0.002166748, 0
+ };
+
+static const unsigned defaultClickLength = sizeof(defaultClick) / sizeof(*defaultClick);
+
+static const float defaultClickEmphasis[] = {
+ 0.002166748, 0.0023193359, 0.001739502, 0.002166748, 0.0021362305,
+ 0.0018615723, 0.0020446777, 0.002166748, 0.0019836426, 0.0022277832,
+ 0.0018310547, 0.0023803711, 0.0022277832, 0.001953125, 0.0022888184,
+ 0.0018005371, 0.0025024414, 0.0018310547, 0.0019836426, 0.001953125,
+ 0.0020446777, 0.0017700195, 0.0021057129, 0.0020751953,
+ 0.0019836426, 0.0014343262, 0.0024414062, 0.0015869141,
+ 0.0022888184, 0.0016784668, 0.0025024414, 0.0017089844,
+ 0.0024719238, 0.0020141602, 0.0026855469, 0.0013427734,
+ 0.0028381348, 0.0015563965, 0.0020446777, 0.0018615723, 0.002532959,
+ 0.0015258789, 0.0021972656, 0.0016784668, 0.002166748, 0.0016479492,
+ 0.0021362305, 0.0018920898, 0.0021362305, 0.0017700195,
+ 0.0020141602, 0.0022277832, 0.001739502, 0.0022583008, 0.001953125,
+ 0.0021362305, 0.0018920898, 0.0020446777, 0.001953125, 0.0026550293,
+ 0.0014953613, 0.0023803711, 0.001953125, 0.0021972656, 0.0015869141,
+ 0.0017700195, 0.0020141602, 0.0022277832, 0.0015258789,
+ 0.0015869141, -0.0045471191, -0.011230469, -0.009185791,
+ -0.0038757324, -0.020690918, -0.030731201, -0.0088806152,
+ 0.0032958984, -0.0068664551, -0.0024719238, 0.024688721,
+ 0.035400391, 0.014892578, 0.0047607422, 0.011779785, 0.0035095215,
+ -0.012573242, -0.0059814453, 0.0065612793, 0.0039672852,
+ 0.0014343262, 0.010406494, 0.027374268, 0.021942139, 0.0065612793,
+ 0.010681152, 0.024688721, 0.024291992, 0.012451172, 0.023590088,
+ 0.033203125, 0.024139404, 0.010375977, 0.016662598, 0.026885986,
+ 0.039215088, 0.038330078, 0.039703369, 0.048309326, 0.046447754,
+ 0.029937744, 0.031311035, 0.066497803, 0.052856445, -0.0074768066,
+ -0.016998291, 0.016784668, 0.039428711, 0.021759033, 0.0040893555,
+ -0.0016174316, 0.012451172, 0.052215576, 0.047485352, 0.017150879,
+ 0.015075684, 0.013397217, 0.024475098, 0.035247803, 0.039978027,
+ 0.06137085, 0.080108643, 0.078521729, 0.054779053, 0.0625,
+ 0.1076355, 0.10934448, 0.079803467, 0.056945801, 0.056182861,
+ 0.047851562, 0.028503418, 0.022979736, 0.010803223, -0.015686035,
+ -0.050811768, -0.072509766, -0.057891846, -0.032073975,
+ -0.051300049, -0.078887939, -0.069366455, -0.038146973,
+ -0.0099182129, 0.010528564, 0.048492432, 0.082305908, 0.084838867,
+ 0.059753418, 0.0043029785, -0.087158203, -0.18395996, -0.2911377,
+ -0.37133789, -0.33422852, -0.28649902, -0.31976318, -0.33630371,
+ -0.22824097, 0.020385742, 0.24456787, 0.31582642, 0.37380981,
+ 0.40820312, 0.40539551, 0.41415405, 0.34210205, 0.20877075,
+ 0.010498047, -0.17623901, -0.22705078, -0.15548706, -0.039855957,
+ 0.0067443848, -0.0022277832, -0.050048828, -0.10186768, -0.11407471,
+ -0.1050415, -0.067352295, 0.0018615723, 0.079742432, 0.11517334,
+ 0.12005615, 0.14709473, 0.19543457, 0.2015686, 0.150177,
+ 0.052703857, -0.029602051, -0.084838867, -0.14590454, -0.18951416,
+ -0.18814087, -0.15014648, -0.11505127, -0.094360352, -0.076721191,
+ -0.037872314, 0.011749268, 0.034851074, 0.060791016, 0.11419678,
+ 0.14096069, 0.13140869, 0.1277771, 0.12313843, 0.10934448,
+ 0.055541992, -0.026397705, -0.07144165, -0.050262451, -0.0097961426,
+ -0.02822876, -0.15008545, -0.28927612, -0.32809448, -0.2772522,
+ -0.15994263, 0.016448975, 0.13085938, 0.12866211, 0.1072998,
+ 0.094177246, 0.036346436, -0.026245117, -0.040496826, -0.01348877,
+ 0.0085144043, 0.0070800781, -0.0086669922, -0.0038452148,
+ 0.040252686, 0.077026367, 0.071960449, 0.032470703, 0.002166748,
+ 0.0065612793, 0.0053100586, -0.025115967, -0.058532715,
+ -0.060699463, -0.015563965, 0.048278809, 0.086273193, 0.078582764,
+ 0.031524658, -0.026580811, -0.077911377, -0.11288452, -0.13244629,
+ -0.15325928, -0.14471436, -0.095672607, -0.048858643, -0.012115479,
+ 0.023132324, 0.051544189, 0.046691895, 0.01373291, -0.0097961426,
+ -0.016143799, -0.022460938, -0.025726318, 0.0075378418, 0.091522217,
+ 0.19741821, 0.23269653, 0.16726685, 0.12173462, 0.12973022,
+ 0.064300537, -0.12158203, -0.29794312, -0.33813477, -0.27990723,
+ -0.19500732, -0.063903809, 0.10449219, 0.23712158, 0.34381104,
+ 0.41766357, 0.37658691, 0.22747803, 0.056365967, -0.088317871,
+ -0.19509888, -0.21295166, -0.15499878, -0.1114502, -0.093597412,
+ -0.071289062, -0.034606934, 0.009552002, 0.068084717, 0.12075806,
+ 0.13098145, 0.11383057, 0.08291626, 0.037322998, -0.017211914,
+ -0.05456543, -0.074829102, -0.087768555, -0.076202393, -0.022735596,
+ 0.032653809, 0.045623779, 0.045806885, 0.040496826, 0.016845703,
+ -0.023712158, -0.057769775, -0.07232666, -0.055145264,
+ -0.00091552734, 0.063201904, 0.11480713, 0.13497925, 0.11572266,
+ 0.030731201, -0.11346436, -0.23406982, -0.27478027, -0.23690796,
+ -0.13735962, -0.016479492, 0.076904297, 0.09487915, 0.070220947,
+ 0.058074951, 0.05355835, 0.017181396, -0.096893311, -0.21951294,
+ -0.26168823, -0.20983887, -0.093109131, 0.051879883, 0.15631104,
+ 0.18319702, 0.15551758, 0.078826904, -0.012084961, -0.083007812,
+ -0.10766602, -0.085479736, -0.059906006, -0.040039062, -0.031646729,
+ -0.046142578, -0.065551758, -0.03414917, 0.025482178, 0.046325684,
+ 0.054473877, 0.073303223, 0.073791504, 0.068786621, 0.082366943,
+ 0.080596924, 0.052215576, 0.015594482, -0.0053405762, 0.0040588379,
+ 0.032501221, 0.065551758, 0.093322754, 0.1199646, 0.13677979,
+ 0.14523315, 0.1401062, 0.12902832, 0.11553955, 0.09664917,
+ 0.091278076, 0.13305664, 0.24594116, 0.38180542, 0.45907593,
+ 0.45343018, 0.4213562, 0.36801147, 0.31027222, 0.30541992,
+ 0.33691406, 0.35479736, 0.3321228, 0.27334595, 0.25701904,
+ 0.23641968, 0.18139648, 0.16793823, 0.17538452, 0.17803955,
+ 0.19009399, 0.25280762, 0.38833618, 0.54940796, 0.70336914,
+ 0.74789429, 0.64334106, 0.49359131, 0.30703735, 0.071624756,
+ -0.075897217, -0.096191406, -0.076568604, 0.023406982, 0.15078735,
+ 0.21612549, 0.30493164, 0.39697266, 0.41009521, 0.32348633,
+ 0.24707031, 0.20645142, 0.11102295, 0.0075073242, -0.046325684,
+ -0.038085938, 0.014251709, 0.096618652, 0.1842041, 0.21417236,
+ 0.15905762, 0.0016174316, -0.25387573, -0.57302856, -0.85641479,
+ -0.99038696, -0.99038696, -0.99038696, -0.99038696, -0.99038696,
+ -0.90664673, -0.64364624, -0.42892456, -0.32131958, -0.23550415,
+ -0.25338745, -0.32595825, -0.44995117, -0.57858276, -0.68716431,
+ -0.80804443, -0.90670776, -0.9654541, -0.97409058, -0.95211792,
+ -0.90264893, -0.85357666, -0.80429077, -0.7482605, -0.69125366,
+ -0.60876465, -0.46228027, -0.23776245, -0.049041748, 0.019989014,
+ 0.048950195, 0.033172607, -0.02142334, -0.084259033, -0.15020752,
+ -0.16220093, -0.14608765, -0.14526367, -0.16497803, -0.1781311,
+ -0.19717407, -0.24871826, -0.26089478, -0.21688843, -0.19818115,
+ -0.23718262, -0.2824707, -0.32797241, -0.36758423, -0.3258667,
+ -0.18960571, -0.082885742, -0.056365967, -0.054534912, -0.10766602,
+ -0.26501465, -0.44006348, -0.58209229, -0.71032715, -0.77719116,
+ -0.76467896, -0.68914795, -0.51403809, -0.27841187, -0.092163086,
+ 0.056030273, 0.16799927, 0.19827271, 0.18478394, 0.17562866,
+ 0.15100098, 0.066619873, -0.040313721, -0.15875244, -0.27044678,
+ -0.35754395, -0.39682007, -0.34078979, -0.22293091, -0.13269043,
+ -0.048034668, 0.0730896, 0.19732666, 0.30789185, 0.39804077,
+ 0.44244385, 0.41928101, 0.35534668, 0.29177856, 0.22891235,
+ 0.18084717, 0.15231323, 0.13360596, 0.13049316, 0.13156128,
+ 0.1293335, 0.11477661, 0.12258911, 0.1824646, 0.26675415,
+ 0.35171509, 0.43341064, 0.49163818, 0.51086426, 0.50985718,
+ 0.49337769, 0.45962524, 0.43182373, 0.42025757, 0.4161377,
+ 0.40631104, 0.40435791, 0.42172241, 0.44003296, 0.45986938,
+ 0.47451782, 0.47540283, 0.48825073, 0.51907349, 0.5612793,
+ 0.62319946, 0.7109375, 0.79650879, 0.86904907, 0.92111206,
+ 0.96124268, 0.96994019, 0.92593384, 0.83483887, 0.70803833,
+ 0.57583618, 0.45834351, 0.3828125, 0.35479736, 0.35110474,
+ 0.38894653, 0.45022583, 0.49264526, 0.48919678, 0.45336914,
+ 0.40823364, 0.35009766, 0.28097534, 0.22503662, 0.18313599,
+ 0.14697266, 0.11010742, 0.07019043, 0.023956299, -0.024658203,
+ -0.087219238, -0.14846802, -0.19796753, -0.23556519, -0.25576782,
+ -0.25366211, -0.2333374, -0.19955444, -0.13546753, -0.052581787,
+ 0.018371582, 0.079620361, 0.14343262, 0.20013428, 0.2388916,
+ 0.25930786, 0.26889038, 0.26208496, 0.24691772, 0.22842407,
+ 0.19110107, 0.14624023, 0.093017578, 0.034301758, -0.044189453,
+ -0.1378479, -0.22967529, -0.29983521, -0.32650757, -0.31271362,
+ -0.26196289, -0.19345093, -0.11380005, -0.032806396, 0.038330078,
+ 0.087677002, 0.10690308, 0.092254639, 0.035766602, -0.057952881,
+ -0.17190552, -0.28945923, -0.40023804, -0.49761963, -0.5635376,
+ -0.59222412, -0.60348511, -0.61352539, -0.60958862, -0.57702637,
+ -0.53674316, -0.49453735, -0.45465088, -0.42507935, -0.40863037,
+ -0.4095459, -0.42730713, -0.45852661, -0.49362183, -0.53048706,
+ -0.55499268, -0.5526123, -0.52798462, -0.49053955, -0.44320679,
+ -0.38500977, -0.30548096, -0.2182312, -0.14306641, -0.073547363,
+ -0.0094299316, 0.045196533, 0.083312988, 0.11129761, 0.14489746,
+ 0.19921875, 0.24578857, 0.25418091, 0.23397827, 0.20111084,
+ 0.14822388, 0.078582764, 0.020812988, -0.012390137, -0.02520752,
+ -0.010559082, 0.026947021, 0.081542969, 0.13687134, 0.18441772,
+ 0.21426392, 0.22711182, 0.21377563, 0.17559814, 0.12246704,
+ 0.060882568, -0.0017089844, -0.067504883, -0.12475586, -0.16159058,
+ -0.16809082, -0.15145874, -0.12081909, -0.077362061, -0.03012085,
+ 0.011444092, 0.044189453, 0.075256348, 0.1050415, 0.13238525,
+ 0.15667725, 0.17337036, 0.17050171, 0.14389038, 0.10055542,
+ 0.057220459, 0.016204834, -0.012664795, -0.025024414, -0.014221191,
+ 0.012939453, 0.063781738, 0.12664795, 0.19824219, 0.26501465,
+ 0.32858276, 0.3782959, 0.40698242, 0.42160034, 0.42788696,
+ 0.43948364, 0.46075439, 0.48413086, 0.49819946, 0.50167847,
+ 0.49963379, 0.48529053, 0.45324707, 0.40890503, 0.36273193,
+ 0.31619263, 0.27200317, 0.23919678, 0.21868896, 0.2046814,
+ 0.18276978, 0.15286255, 0.11727905, 0.071807861, 0.015777588,
+ -0.054199219, -0.12478638, -0.19580078, -0.25622559, -0.30892944,
+ -0.34820557, -0.37606812, -0.39535522, -0.40704346, -0.42147827,
+ -0.43313599, -0.4447937, -0.44998169, -0.44503784, -0.431427,
+ -0.40750122, -0.37838745, -0.34109497, -0.29644775, -0.24822998,
+ -0.1991272, -0.15881348, -0.12728882, -0.10827637, -0.09979248,
+ -0.094055176, -0.091125488, -0.089508057, -0.087646484, -0.0809021,
+ -0.072387695, -0.055328369, -0.035583496, -0.0079956055,
+ 0.018188477, 0.04309082, 0.060577393, 0.073272705, 0.080413818,
+ 0.084503174, 0.083343506, 0.07522583, 0.071136475, 0.076141357,
+ 0.088348389, 0.10449219, 0.12374878, 0.14376831, 0.1534729,
+ 0.14807129, 0.1255188, 0.092559814, 0.047485352, -0.0028076172,
+ -0.062286377, -0.12301636, -0.17855835, -0.22631836, -0.26260376,
+ -0.28588867, -0.29559326, -0.29629517, -0.287323, -0.27877808,
+ -0.26751709, -0.25668335, -0.24749756, -0.24139404, -0.24041748,
+ -0.23944092, -0.23544312, -0.22592163, -0.20898438, -0.184021,
+ -0.15014648, -0.11633301, -0.082702637, -0.0496521, -0.017944336,
+ 0.017486572, 0.052581787, 0.092041016, 0.13427734, 0.18481445,
+ 0.24057007, 0.29467773, 0.33944702, 0.37042236, 0.38433838,
+ 0.38241577, 0.36376953, 0.33966064, 0.31497192, 0.29443359,
+ 0.27792358, 0.2600708, 0.24700928, 0.23727417, 0.23452759,
+ 0.23358154, 0.23257446, 0.23406982, 0.23239136, 0.23312378,
+ 0.22958374, 0.22579956, 0.21710205, 0.20043945, 0.17419434,
+ 0.13870239, 0.096466064, 0.051971436, 0.010437012, -0.024963379,
+ -0.052490234, -0.066467285, -0.068969727, -0.058563232,
+ -0.044616699, -0.030029297, -0.017486572, -0.0077209473,
+ -0.0032043457, -0.0048217773, -0.012481689, -0.027801514,
+ -0.042724609, -0.060211182, -0.072937012, -0.081756592,
+ -0.082977295, -0.07800293, -0.064605713, -0.043792725, -0.013031006,
+ 0.028625488, 0.077667236, 0.13046265, 0.18130493, 0.22851562,
+ 0.26617432, 0.29119873, 0.3039856, 0.30383301, 0.2925415,
+ 0.27261353, 0.24078369, 0.20632935, 0.16989136, 0.13552856,
+ 0.1038208, 0.074462891, 0.045898438, 0.013061523, -0.021087646,
+ -0.06072998, -0.099700928, -0.14016724, -0.17874146, -0.21130371,
+ -0.23596191, -0.25204468, -0.26132202, -0.26803589, -0.27981567,
+ -0.29934692, -0.32730103, -0.36425781, -0.40698242, -0.45092773,
+ -0.48971558, -0.51776123, -0.53198242, -0.5333252, -0.52218628,
+ -0.50076294, -0.47000122, -0.43017578, -0.38583374, -0.33612061,
+ -0.28347778, -0.23306274, -0.18682861, -0.14859009, -0.11853027,
+ -0.099853516, -0.09072876, -0.088562012, -0.091369629, -0.098022461,
+ -0.10787964, -0.11395264, -0.11013794, -0.093841553, -0.069274902,
+ -0.035369873, 0.0026245117, 0.046783447, 0.090698242, 0.1315918,
+ 0.16296387, 0.18664551, 0.2038269, 0.2154541, 0.22036743,
+ 0.21444702, 0.20489502, 0.18753052, 0.16650391, 0.13882446,
+ 0.10861206, 0.078735352, 0.049346924, 0.024078369, 0.0013427734,
+ -0.017974854, -0.032165527, -0.043243408, -0.050262451, -0.05670166,
+ -0.061157227, -0.068695068, -0.078918457, -0.085601807,
+ -0.090698242, -0.093658447, -0.095581055, -0.092529297, -0.08404541,
+ -0.068939209, -0.053649902, -0.037017822, -0.016448975,
+ 0.0096740723, 0.041687012, 0.074798584, 0.10549927, 0.13494873,
+ 0.16445923, 0.1937561, 0.2208252, 0.24539185, 0.26721191,
+ 0.28359985, 0.29733276, 0.30651855, 0.31622314, 0.32266235,
+ 0.31842041, 0.31008911, 0.29681396, 0.2819519, 0.26678467,
+ 0.25457764, 0.24642944, 0.24273682, 0.23709106, 0.22891235,
+ 0.2197876, 0.21051025, 0.20257568, 0.19024658, 0.17764282,
+ 0.1607666, 0.14309692, 0.12210083, 0.096893311, 0.073150635,
+ 0.049530029, 0.028045654, 0.0048522949, -0.017669678, -0.036224365,
+ -0.050506592, -0.059112549, -0.066345215, -0.068939209,
+ -0.070495605, -0.073059082, -0.073028564, -0.076812744,
+ -0.080963135, -0.092010498, -0.10275269, -0.11016846, -0.11907959,
+ -0.12677002, -0.13555908, -0.13842773, -0.13674927, -0.13088989,
+ -0.11846924, -0.099334717, -0.072784424, -0.042541504,
+ -0.0082702637, 0.031524658, 0.072387695, 0.10968018, 0.13861084,
+ 0.15847778, 0.16812134, 0.16650391, 0.15774536, 0.14169312,
+ 0.12005615, 0.092895508, 0.061737061, 0.02923584, -0.0022277832,
+ -0.032836914, -0.05670166, -0.075439453, -0.093322754, -0.1121521,
+ -0.13204956, -0.15255737, -0.17541504, -0.19900513, -0.21817017,
+ -0.23519897, -0.25091553, -0.27148438, -0.29296875, -0.31069946,
+ -0.3243103, -0.33599854, -0.34689331, -0.35461426, -0.3598938,
+ -0.36212158, -0.36105347, -0.35699463, -0.34725952, -0.33319092,
+ -0.31484985, -0.29327393, -0.26959229, -0.24423218, -0.21859741,
+ -0.18777466, -0.15194702, -0.11468506, -0.079498291, -0.0496521,
+ -0.023529053, 0.001159668, 0.025848389, 0.044494629, 0.054168701,
+ 0.058135986, 0.059844971, 0.066894531, 0.075195312, 0.087585449,
+ 0.10009766, 0.11755371, 0.13864136, 0.16278076, 0.18545532,
+ 0.20370483, 0.22076416, 0.23773193, 0.25531006, 0.26928711,
+ 0.27508545, 0.27371216, 0.26660156, 0.25100708, 0.2260437,
+ 0.1942749, 0.16079712, 0.12878418, 0.10110474, 0.07244873,
+ 0.046051025, 0.024993896, 0.010284424, -0.0010070801, -0.0082397461,
+ -0.011383057, -0.0072937012, -0.0034179688, 0.0040893555,
+ 0.013519287, 0.022583008, 0.031219482, 0.032714844, 0.034851074,
+ 0.033508301, 0.033935547, 0.030975342, 0.031982422, 0.039794922,
+ 0.05569458, 0.077392578, 0.10113525, 0.1277771, 0.15429688,
+ 0.18026733, 0.20275879, 0.21591187, 0.22341919, 0.224823,
+ 0.22775269, 0.22766113, 0.22491455, 0.2170105, 0.20431519,
+ 0.19171143, 0.17459106, 0.15859985, 0.14315796, 0.12554932,
+ 0.10998535, 0.09463501, 0.083435059, 0.070465088, 0.057983398,
+ 0.048278809, 0.041351318, 0.036224365, 0.030639648, 0.021850586,
+ 0.012176514, -0.0034484863, -0.022735596, -0.045166016,
+ -0.068908691, -0.094421387, -0.11810303, -0.13882446, -0.15774536,
+ -0.17269897, -0.18533325, -0.19125366, -0.19116211, -0.18655396,
+ -0.18423462, -0.18267822, -0.17877197, -0.17248535, -0.16625977,
+ -0.16271973, -0.16104126, -0.16125488, -0.16192627, -0.16333008,
+ -0.16461182, -0.16616821, -0.16235352, -0.15325928, -0.13644409,
+ -0.11523438, -0.090240479, -0.058013916, -0.024383545, 0.0089111328,
+ 0.039093018, 0.067749023, 0.096221924, 0.11837769, 0.13458252,
+ 0.13946533, 0.13269043, 0.12045288, 0.099212646, 0.073608398,
+ 0.042266846, 0.011627197, -0.019042969, -0.04876709, -0.07409668,
+ -0.096038818, -0.11062622, -0.1239624, -0.1340332, -0.14199829,
+ -0.14428711, -0.14074707, -0.13641357, -0.13253784, -0.13400269,
+ -0.13830566, -0.1505127, -0.16162109, -0.17391968, -0.1847229,
+ -0.19418335, -0.2019043, -0.20770264, -0.21234131, -0.21121216,
+ -0.20510864, -0.19058228, -0.16986084, -0.14498901, -0.11407471,
+ -0.082061768, -0.048492432, -0.015533447, 0.018341064, 0.052185059,
+ 0.078826904, 0.10336304, 0.12106323, 0.1315918, 0.13513184,
+ 0.13653564, 0.13986206, 0.14501953, 0.14926147, 0.15634155,
+ 0.16189575, 0.16915894, 0.17584229, 0.18264771, 0.19329834,
+ 0.20681763, 0.22433472, 0.24029541, 0.25708008, 0.27435303,
+ 0.28552246, 0.28768921, 0.2796936, 0.26013184, 0.23287964,
+ 0.20193481, 0.17483521, 0.14996338, 0.12689209, 0.10336304,
+ 0.081939697, 0.063842773, 0.047302246, 0.031677246, 0.01953125,
+ 0.010559082, 0.0013427734, -0.0082397461, -0.016357422,
+ -0.019348145, -0.023223877, -0.023406982, -0.023895264,
+ -0.022155762, -0.020477295, -0.017089844, -0.013031006,
+ -0.0098571777, -0.0046691895, 6.1035156e-05, 0.0072937012,
+ 0.0128479, 0.025878906, 0.040618896, 0.055908203, 0.066558838,
+ 0.072021484, 0.076965332, 0.080383301, 0.081237793, 0.077575684,
+ 0.072113037, 0.067443848, 0.064880371, 0.063720703, 0.058959961,
+ 0.054534912, 0.047576904, 0.039276123, 0.025390625, 0.010986328,
+ -0.0061645508, -0.018859863, -0.028900146, -0.036376953,
+ -0.041473389, -0.047241211, -0.054260254, -0.063049316, -0.0730896,
+ -0.081085205, -0.090118408, -0.10089111, -0.11264038, -0.12442017,
+ -0.1350708, -0.14535522, -0.15383911, -0.16052246, -0.16329956,
+ -0.1668396, -0.17166138, -0.17819214, -0.18157959, -0.18133545,
+ -0.17935181, -0.1758728, -0.17181396, -0.16687012, -0.16067505,
+ -0.15344238, -0.14562988, -0.13626099, -0.12780762, -0.11743164,
+ -0.10961914, -0.098510742, -0.085601807, -0.071716309, -0.05758667,
+ -0.041412354, -0.024078369, -0.0043640137, 0.015960693, 0.037567139,
+ 0.060455322, 0.082855225, 0.10211182, 0.11419678, 0.12088013,
+ 0.12197876, 0.12145996, 0.11743164, 0.11026001, 0.096984863,
+ 0.077789307, 0.054504395, 0.031890869, 0.010986328, -0.0061340332,
+ -0.020507812, -0.032836914, -0.042541504, -0.050476074,
+ -0.056762695, -0.06137085, -0.065032959, -0.064727783, -0.064147949,
+ -0.060119629, -0.05770874, -0.056549072, -0.057098389, -0.059692383,
+ -0.063140869, -0.067321777, -0.072021484, -0.075439453,
+ -0.078033447, -0.077575684, -0.073059082, -0.063995361,
+ -0.049560547, -0.030212402, -0.008605957, 0.015930176, 0.039794922,
+ 0.065917969, 0.090820312, 0.11099243, 0.12619019, 0.13739014,
+ 0.1472168, 0.15374756, 0.15893555, 0.16152954, 0.16671753,
+ 0.17425537, 0.17889404, 0.18060303, 0.17886353, 0.17861938,
+ 0.17984009, 0.18179321, 0.18499756, 0.18548584, 0.18609619,
+ 0.18521118, 0.18234253, 0.17956543, 0.17547607, 0.1690979,
+ 0.16101074, 0.15505981, 0.14837646, 0.13739014, 0.12255859,
+ 0.10522461, 0.082397461, 0.05770874, 0.030609131, 0.0046691895,
+ -0.018676758, -0.037872314, -0.054779053, -0.069458008,
+ -0.078826904, -0.084136963, -0.085479736, -0.083404541,
+ -0.076324463, -0.066314697, -0.056060791, -0.049926758,
+ -0.043182373, -0.040252686, -0.037811279, -0.038543701,
+ -0.039276123, -0.040771484, -0.041687012, -0.042053223,
+ -0.043548584, -0.040161133, -0.034637451, -0.024841309,
+ -0.015197754, -0.0059509277, 0.001159668, 0.0042114258,
+ 0.0062866211, 0.0049438477, 0.0047302246, 0.0028686523,
+ -0.00082397461, -0.0034790039, -0.0077514648, -0.01260376,
+ -0.019500732, -0.02645874, -0.032409668, -0.041351318, -0.049163818,
+ -0.058532715, -0.068603516, -0.078948975, -0.088897705,
+ -0.094543457, -0.097167969, -0.095581055, -0.094726562,
+ -0.095001221, -0.095336914, -0.094726562, -0.096160889, -0.09866333,
+ -0.10427856, -0.1104126, -0.11727905, -0.12301636, -0.13006592,
+ -0.13479614, -0.13574219, -0.13119507, -0.12451172, -0.11630249,
+ -0.10476685, -0.094543457, -0.08416748, -0.074066162, -0.061767578,
+ -0.050415039, -0.040557861, -0.031402588, -0.023834229, -0.01361084,
+ -0.0036010742, 0.0055236816, 0.013122559, 0.02142334, 0.029418945,
+ 0.041717529, 0.056518555, 0.075714111, 0.095062256, 0.11523438,
+ 0.13363647, 0.146698, 0.15646362, 0.16061401, 0.16043091,
+ 0.15634155, 0.14889526, 0.13769531, 0.12127686, 0.10272217,
+ 0.085418701, 0.070739746, 0.055541992, 0.040405273, 0.024200439,
+ 0.010803223, -0.00048828125, -0.0087890625, -0.012481689,
+ -0.014404297, -0.014068604, -0.011230469, -0.0081787109,
+ -0.0049438477, -0.0041809082, -0.0060119629, -0.012237549,
+ -0.020355225, -0.027832031, -0.034759521, -0.042053223, -0.04675293,
+ -0.045349121, -0.042297363, -0.03604126, -0.027862549, -0.015777588,
+ -0.0011291504, 0.013397217, 0.030212402, 0.04598999, 0.061401367,
+ 0.074615479, 0.086242676, 0.094238281, 0.09979248, 0.10458374,
+ 0.10662842, 0.10894775, 0.11077881, 0.11056519, 0.11022949,
+ 0.10903931, 0.1072998, 0.10266113, 0.098999023, 0.095977783,
+ 0.095916748, 0.095611572, 0.094909668, 0.093963623, 0.092895508,
+ 0.092559814, 0.090423584, 0.084014893, 0.073852539, 0.059020996,
+ 0.044830322, 0.02822876, 0.012023926, -0.0049743652, -0.020050049,
+ -0.036193848, -0.052398682, -0.066253662, -0.078796387,
+ -0.089019775, -0.098083496, -0.10592651, -0.11224365, -0.11618042,
+ -0.11715698, -0.11807251, -0.11676025, -0.11459351, -0.11108398,
+ -0.10748291, -0.10400391, -0.10064697, -0.096923828, -0.092163086,
+ -0.086639404, -0.08114624, -0.075531006, -0.071838379, -0.06854248,
+ -0.064971924, -0.061035156, -0.054382324, -0.047393799,
+ -0.043518066, -0.04095459, -0.041351318, -0.041259766, -0.041931152,
+ -0.04095459, -0.037841797, -0.034210205, -0.029541016, -0.026550293,
+ -0.02444458, -0.024139404, -0.026397705, -0.03036499, -0.035675049,
+ -0.041046143, -0.04675293, -0.054168701, -0.061218262, -0.065704346,
+ -0.066650391, -0.066650391, -0.063537598, -0.06048584, -0.055664062,
+ -0.053375244, -0.052642822, -0.052764893, -0.054718018,
+ -0.053955078, -0.05355835, -0.052764893, -0.053405762, -0.056213379,
+ -0.06036377, -0.062744141, -0.063110352, -0.06072998, -0.054504395,
+ -0.044647217, -0.034057617, -0.022949219, -0.011810303, 0.002532959,
+ 0.015594482, 0.024383545, 0.032165527, 0.03894043, 0.047302246,
+ 0.055236816, 0.064605713, 0.072387695, 0.081115723, 0.088348389,
+ 0.094940186, 0.10223389, 0.11135864, 0.12249756, 0.13082886,
+ 0.13803101, 0.14520264, 0.14993286, 0.15118408, 0.14987183,
+ 0.14846802, 0.14581299, 0.13851929, 0.12878418, 0.11639404,
+ 0.10375977, 0.09173584, 0.078796387, 0.063842773, 0.048980713,
+ 0.034576416, 0.022338867, 0.011932373, 0.0039672852, 0.0011291504,
+ -0.00094604492, -0.0015563965, -0.0034484863, -0.0050354004,
+ -0.0083312988, -0.012390137, -0.01651001, -0.019683838,
+ -0.022003174, -0.024414062, -0.027557373, -0.03137207, -0.03314209,
+ -0.030700684, -0.028045654, -0.025482178, -0.022247314,
+ -0.018737793, -0.013275146, -0.0074157715, 0.0010070801,
+ 0.0093078613, 0.01763916, 0.027404785, 0.035583496, 0.043151855,
+ 0.047485352, 0.051239014, 0.053649902, 0.054626465, 0.054382324,
+ 0.053039551, 0.050323486, 0.046691895, 0.044158936, 0.041534424,
+ 0.039794922, 0.035797119, 0.031494141, 0.026580811, 0.021575928,
+ 0.017944336, 0.014038086, 0.0093688965, 0.0051574707,
+ -0.00067138672, -0.0070495605, -0.014984131, -0.021728516,
+ -0.030151367, -0.037719727, -0.049804688, -0.062255859,
+ -0.073791504, -0.08416748, -0.089599609, -0.096496582, -0.10055542,
+ -0.10531616, -0.10870361, -0.11083984, -0.11102295, -0.10925293,
+ -0.10610962, -0.10125732, -0.094848633, -0.086700439, -0.07925415,
+ -0.074005127, -0.070770264, -0.068511963, -0.065643311,
+ -0.060577393, -0.054595947, -0.049407959, -0.043914795,
+ -0.039794922, -0.033813477, -0.027923584, -0.022674561,
+ -0.017791748, -0.01260376, -0.008972168, -0.0076293945,
+ -0.0053100586, -0.0030517578, -0.0024719238, -0.0032043457,
+ -0.0035705566, -0.002746582, -0.0013427734, -0.0011901855,
+ -0.0012817383, -0.0016479492, -0.0030212402, -0.0040588379,
+ -0.0071411133, -0.0085449219, -0.010375977, -0.01171875,
+ -0.011230469, -0.012512207, -0.013305664, -0.014190674,
+ -0.014099121, -0.015625, -0.01763916, -0.020202637, -0.020172119,
+ -0.017730713, -0.014068604, -0.0097351074, -0.0065917969,
+ -0.0020751953, 0.0018310547, 0.0045471191, 0.0046691895,
+ 0.003326416, 0.0018615723, -0.00021362305, 0.0010986328,
+ 0.0056152344, 0.011962891, 0.019866943, 0.029846191, 0.040130615,
+ 0.050811768, 0.058746338, 0.068267822, 0.076721191, 0.083862305,
+ 0.091491699, 0.096008301, 0.10150146, 0.1036377, 0.10562134,
+ 0.10449219, 0.1026001, 0.10076904, 0.099822998, 0.098297119,
+ 0.095245361, 0.094207764, 0.091949463, 0.092773438, 0.093048096,
+ 0.093658447, 0.090881348, 0.084747314, 0.078186035, 0.068328857,
+ 0.058197021, 0.044403076, 0.031768799, 0.019866943, 0.010345459,
+ 0.0029602051, -0.0044555664, -0.011932373, -0.018920898,
+ -0.024993896, -0.029205322, -0.031768799, -0.034790039,
+ -0.036773682, -0.037841797, -0.04019165, -0.042785645, -0.045928955,
+ -0.045776367, -0.044006348, -0.040649414, -0.037902832,
+ -0.036834717, -0.035308838, -0.033569336, -0.030090332,
+ -0.025543213, -0.020263672, -0.014678955, -0.0094604492,
+ -0.0042114258, -0.00067138672, 0.0016784668, 0.0021362305,
+ 0.0038452148, 0.007598877, 0.0099487305, 0.013793945, 0.015838623,
+ 0.01852417, 0.019958496, 0.021087646, 0.021270752, 0.021911621,
+ 0.021789551, 0.020965576, 0.01776123, 0.013275146, 0.0070495605,
+ 0.00076293945, -0.004119873, -0.007232666, -0.009552002,
+ -0.012695312, -0.016052246, -0.019226074, -0.02331543, -0.028625488,
+ -0.032348633, -0.035736084, -0.038909912, -0.044372559,
+ -0.050354004, -0.056610107, -0.061309814, -0.065704346,
+ -0.065948486, -0.067230225, -0.06652832, -0.0652771, -0.061981201,
+ -0.057128906, -0.052185059, -0.046112061, -0.041595459,
+ -0.035461426, -0.031097412, -0.025970459, -0.022979736,
+ -0.019836426, -0.015899658, -0.01260376, -0.0087585449,
+ -0.0061950684, -0.0028991699, -0.0014953613, 0.0018615723,
+ 0.0055847168, 0.008605957, 0.011871338, 0.015594482, 0.020629883,
+ 0.025970459, 0.030212402, 0.034973145, 0.037322998, 0.037597656,
+ 0.036254883, 0.034698486, 0.032440186, 0.029937744, 0.026062012,
+ 0.021972656, 0.018432617, 0.013397217, 0.010528564, 0.0077514648,
+ 0.0076904297, 0.0078430176, 0.0095825195, 0.012512207, 0.01550293,
+ 0.017486572, 0.017150879, 0.015563965, 0.013031006, 0.010070801,
+ 0.0068969727, 0.0039367676, 0.0021057129, 0.0018920898,
+ 0.0032653809, 0.0064697266, 0.0092163086, 0.010437012, 0.0097961426,
+ 0.0078125, 0.0053405762, 0.0048828125, 0.0055236816, 0.0086669922,
+ 0.013061523, 0.019897461, 0.027252197, 0.035675049, 0.043518066,
+ 0.050018311, 0.056427002, 0.06072998, 0.062011719, 0.061859131,
+ 0.060546875, 0.060577393, 0.059173584, 0.056945801, 0.054138184,
+ 0.053283691, 0.053131104, 0.052764893, 0.050811768, 0.04864502,
+ 0.046295166, 0.044921875, 0.043182373, 0.040161133, 0.036529541,
+ 0.032287598, 0.028411865, 0.022247314, 0.015960693, 0.0095825195,
+ 0.0032958984, -0.0028991699, -0.01159668, -0.018249512, -0.02532959,
+ -0.03137207, -0.035919189, -0.040710449, -0.044006348, -0.049163818,
+ -0.052246094, -0.055969238, -0.056396484, -0.055511475,
+ -0.052825928, -0.049194336, -0.046844482, -0.04598999, -0.045227051,
+ -0.044586182, -0.042388916, -0.039611816, -0.037719727,
+ -0.035766602, -0.032806396, -0.030700684, -0.027313232, -0.02444458,
+ -0.020019531, -0.015533447, -0.012145996, -0.0091552734,
+ -0.0064697266, -0.0040893555, -0.00048828125, 0.001953125,
+ 0.0048522949, 0.0061950684, 0.007019043, 0.0083007812, 0.0091247559,
+ 0.0094909668, 0.0098876953, 0.010894775, 0.011566162, 0.0105896,
+ 0.0083007812, 0.0047607422, 0.0010986328, -0.0036621094,
+ -0.0073242188, -0.010223389, -0.011505127, -0.011993408,
+ -0.012786865, -0.015350342, -0.017669678, -0.019500732,
+ -0.022613525, -0.025115967, -0.027862549, -0.027832031,
+ -0.028320312, -0.029602051, -0.030761719, -0.033111572,
+ -0.033630371, -0.032592773, -0.030914307, -0.027008057, -0.02355957,
+ -0.020507812, -0.017211914, -0.014709473, -0.0097351074,
+ -0.0033874512, 0.0032958984, 0.010284424, 0.014007568, 0.017272949,
+ 0.017791748, 0.018371582, 0.018096924, 0.017272949, 0.016326904,
+ 0.016021729, 0.017028809, 0.020507812, 0.025238037, 0.031280518,
+ 0.036834717, 0.040283203, 0.04284668, 0.045410156, 0.048339844,
+ 0.050109863, 0.04800415, 0.044311523, 0.040557861, 0.036010742,
+ 0.031982422, 0.026977539, 0.022766113, 0.018829346, 0.015411377,
+ 0.012359619, 0.010925293, 0.0095214844, 0.010498047, 0.012054443,
+ 0.014221191, 0.016326904, 0.017150879, 0.016784668, 0.01473999,
+ 0.012481689, 0.0090026855, 0.0057678223, 0.002746582,
+ -0.00024414062, -6.1035156e-05, -0.00042724609, -0.00039672852,
+ -0.0024414062, -0.0037841797, -0.0043334961, -0.0034790039,
+ -0.0015563965, 0.0011901855, 0.0047302246, 0.0079345703,
+ 0.011108398, 0.013885498, 0.017150879, 0.020874023, 0.024139404,
+ 0.028411865, 0.031860352, 0.036010742, 0.038330078, 0.038574219,
+ 0.03805542, 0.035980225, 0.033905029, 0.03112793, 0.027496338,
+ 0.024414062, 0.020690918, 0.017791748, 0.013549805, 0.0098876953,
+ 0.0071105957, 0.0046081543, 0.0029296875, 0.0013122559,
+ 0.0002746582, -0.0014343262, -0.0029907227, -0.0065307617,
+ -0.009979248, -0.014831543, -0.02041626, -0.027008057, -0.036132812,
+ -0.043670654, -0.049591064, -0.053894043, -0.057312012,
+ -0.059570312, -0.059051514, -0.057617188, -0.05581665, -0.054962158,
+ -0.053283691, -0.051300049, -0.049591064, -0.049407959,
+ -0.049560547, -0.0496521, -0.04788208, -0.044830322, -0.040771484,
+ -0.03616333, -0.031066895, -0.024902344, -0.019226074, -0.014312744,
+ -0.010925293, -0.0085754395, -0.0065612793, -0.0048217773,
+ -0.0020141602, -0.00039672852, 0.0014648438, 0.003326416,
+ 0.0067749023, 0.009979248, 0.014068604, 0.016052246, 0.017486572,
+ 0.017700195, 0.018127441, 0.018066406, 0.017608643, 0.016845703,
+ 0.015838623, 0.014404297, 0.013214111, 0.011901855, 0.010650635,
+ 0.0085754395, 0.0069885254, 0.0051269531, 0.0030212402,
+ 0.00015258789, -0.0031738281, -0.0065307617, -0.0090637207,
+ -0.010498047, -0.011505127, -0.012023926, -0.01260376, -0.012115479,
+ -0.010406494, -0.0086975098, -0.0063781738, -0.005859375,
+ -0.0042114258, -0.0034179688, -0.0012207031, 0.00057983398,
+ 0.0030822754, 0.0048828125, 0.0070800781, 0.010040283, 0.013793945,
+ 0.01763916, 0.020935059, 0.024047852, 0.026245117, 0.02822876,
+ 0.028381348, 0.028015137, 0.027618408, 0.027496338, 0.0284729,
+ 0.029174805, 0.029815674, 0.030670166, 0.033081055, 0.035797119,
+ 0.037445068, 0.039154053, 0.039825439, 0.040283203, 0.03918457,
+ 0.036987305, 0.033874512, 0.02935791, 0.025177002, 0.020507812,
+ 0.016479492, 0.013031006, 0.010070801, 0.0077209473, 0.0056152344,
+ 0.003326416, 0.00048828125, -0.0017089844, -0.0030517578,
+ -0.0029602051, -0.003112793, -0.0025024414, -0.0024414062,
+ -0.0021362305, -0.0023498535, -0.0029907227, -0.0043029785,
+ -0.0059814453, -0.0078735352, -0.01083374, -0.013397217,
+ -0.016448975, -0.018890381, -0.020568848, -0.020080566, -0.01852417,
+ -0.016845703, -0.014007568, -0.0105896, -0.0066833496,
+ -0.0030517578, 0.0014953613, 0.0065002441, 0.0098571777,
+ 0.013122559, 0.014404297, 0.015472412, 0.016571045, 0.018035889,
+ 0.018585205, 0.018371582, 0.016540527, 0.014099121, 0.011413574,
+ 0.009185791, 0.0065917969, 0.0032653809, 0.00054931641,
+ -0.0018005371, -0.0024719238, -0.0046081543, -0.0062255859,
+ -0.0078430176, -0.009979248, -0.011627197, -0.015289307,
+ -0.017456055, -0.019897461, -0.022918701, -0.025543213,
+ -0.028747559, -0.031524658, -0.036865234, -0.041534424,
+ -0.045410156, -0.046875, -0.048126221, -0.049499512, -0.049163818,
+ -0.048828125, -0.047790527, -0.04574585, -0.043579102, -0.040924072,
+ -0.040222168, -0.038360596, -0.036895752, -0.034210205,
+ -0.031616211, -0.028289795, -0.024200439, -0.020294189,
+ -0.015838623, -0.011993408, -0.007598877, -0.0036010742,
+ 0.00054931641, 0.004486084, 0.0074157715, 0.0098571777, 0.012054443,
+ 0.01473999, 0.017700195, 0.019744873, 0.022399902, 0.02432251,
+ 0.025817871, 0.027130127, 0.027709961, 0.0284729, 0.027893066,
+ 0.027496338, 0.026580811, 0.025634766, 0.023681641, 0.021972656,
+ 0.019775391, 0.017730713, 0.016052246, 0.014556885, 0.014434814,
+ 0.013763428, 0.012268066, 0.0105896, 0.0091247559, 0.0077819824,
+ 0.0054626465, 0.0030822754, 0.00067138672, -0.0012207031,
+ -0.0028686523, -0.0048217773, -0.0047912598, -0.004486084,
+ -0.002746582, -0.00067138672, 0.0012512207, 0.0037231445,
+ 0.0054321289, 0.0074157715, 0.010192871, 0.013214111, 0.016448975,
+ 0.018005371, 0.019134521, 0.018463135, 0.017944336, 0.016723633,
+ 0.016448975, 0.01651001, 0.01651001, 0.017669678, 0.019622803,
+ 0.022064209, 0.024017334, 0.025909424, 0.026977539, 0.027008057,
+ 0.026733398, 0.025634766, 0.024261475, 0.022247314, 0.020202637,
+ 0.017730713, 0.01663208, 0.015319824, 0.014404297, 0.013092041,
+ 0.0098266602, 0.0065307617, 0.0032653809, 0.00061035156,
+ -0.0028076172, -0.0061340332, -0.0094909668, -0.012115479,
+ -0.013244629, -0.014251709, -0.015075684, -0.015808105,
+ -0.015991211, -0.016418457, -0.016601562, -0.01663208, -0.01675415,
+ -0.017333984, -0.018615723, -0.019775391, -0.02053833, -0.020721436,
+ -0.021820068, -0.022918701, -0.023651123, -0.023895264,
+ -0.023590088, -0.02331543, -0.022338867, -0.020141602, -0.017669678,
+ -0.014068604, -0.010528564, -0.0055236816, 0, 0.0051574707,
+ 0.008972168, 0.011291504, 0.012207031, 0.012420654, 0.01159668,
+ 0.0105896, 0.009185791, 0.0078735352, 0.0067749023, 0.0052490234,
+ 0.0040588379, 0.0025024414, 0.0013427734, 0.0014038086,
+ 0.0009765625, 0.00076293945, -0.00079345703, -0.0029907227,
+ -0.0054626465, -0.0073547363, -0.0095825195, -0.011383057,
+ -0.012237549, -0.013000488, -0.014373779, -0.016448975,
+ -0.018341064, -0.020446777, -0.02331543, -0.025909424, -0.02835083,
+ -0.028869629, -0.028839111, -0.028686523, -0.028106689,
+ -0.027740479, -0.027435303, -0.027313232, -0.026672363,
+ -0.025604248, -0.02355957, -0.020263672, -0.016204834, -0.011383057,
+ -0.0068359375, -0.0024719238, 0.00021362305, 0.0022583008,
+ 0.0036621094, 0.0053710938, 0.0079040527, 0.010162354, 0.013214111,
+ 0.016052246, 0.019042969, 0.022064209, 0.024871826, 0.027618408,
+ 0.029205322, 0.030761719, 0.031921387, 0.032012939, 0.032562256,
+ 0.032714844, 0.032958984, 0.032318115, 0.031860352, 0.030822754,
+ 0.03024292, 0.029510498, 0.028167725, 0.027099609, 0.024810791,
+ 0.022674561, 0.019958496, 0.018218994, 0.016143799, 0.014373779,
+ 0.012145996, 0.010101318, 0.0079345703, 0.0063476562, 0.0045471191,
+ 0.003112793, 0.00085449219, -0.00088500977, -0.002532959,
+ -0.0035095215, -0.0039672852, -0.0041503906, -0.0031433105,
+ -0.0017700195, -3.0517578e-05, 0.0010681152, 0.0033874512,
+ 0.0053405762, 0.0074768066, 0.0082397461, 0.0075683594, 0.007019043,
+ 0.005279541, 0.004486084, 0.0035400391, 0.0035400391, 0.0047607422,
+ 0.0061645508, 0.0079345703, 0.0090332031, 0.010314941, 0.010681152,
+ 0.010467529, 0.010467529, 0.009979248, 0.009765625, 0.0090637207,
+ 0.0083007812, 0.0075683594, 0.0065917969, 0.0066223145,
+ 0.0054626465, 0.0040893555, 0.0021362305, -3.0517578e-05,
+ -0.0024719238, -0.0052490234, -0.008026123, -0.010375977,
+ -0.012573242, -0.01461792, -0.01651001, -0.017822266, -0.018981934,
+ -0.019622803, -0.019592285, -0.020172119, -0.020751953,
+ -0.021728516, -0.022186279, -0.02230835, -0.02230835, -0.022155762,
+ -0.022583008, -0.022338867, -0.023193359, -0.023284912,
+ -0.023406982, -0.022766113, -0.022216797, -0.022094727,
+ -0.021484375, -0.021026611, -0.019836426, -0.018005371,
+ -0.015533447, -0.012512207, -0.0092773438, -0.0061340332,
+ -0.0029907227, 0.00076293945, 0.00390625, 0.0065002441,
+ 0.0084228516, 0.010070801, 0.011566162, 0.012054443, 0.012573242,
+ 0.011779785, 0.011077881, 0.010131836, 0.0088500977, 0.0075073242,
+ 0.0054321289, 0.0044555664, 0.003692627, 0.0032348633, 0.0028991699,
+ 0.0022583008, 0.0026245117, 0.0021972656, 0.001953125,
+ 0.00079345703, -0.001159668, -0.0028381348, -0.0046386719,
+ -0.0059814453, -0.0075378418, -0.0087890625, -0.010192871,
+ -0.01083374, -0.011993408, -0.012695312, -0.012756348, -0.012908936,
+ -0.012695312, -0.013061523, -0.012756348, -0.012145996,
+ -0.011352539, -0.010253906, -0.0094909668, -0.0081787109,
+ -0.0067138672, -0.0047912598, -0.0016784668, 0.00085449219,
+ 0.0041809082, 0.0070495605, 0.0098571777, 0.013061523, 0.016052246,
+ 0.019012451, 0.020965576, 0.022613525, 0.023590088, 0.024169922,
+ 0.02432251, 0.024078369, 0.024261475, 0.023681641, 0.024291992,
+ 0.024475098, 0.025390625, 0.026306152, 0.026641846, 0.027008057,
+ 0.026672363, 0.026641846, 0.026153564, 0.025482178, 0.024108887,
+ 0.022155762, 0.020050049, 0.017578125, 0.01461792, 0.011932373,
+ 0.0090332031, 0.0069580078, 0.0048828125, 0.0032653809, 0.001953125,
+ 0.0007019043, -0.00036621094, -0.0019226074, -0.0037536621,
+ -0.0056152344, -0.0076904297, -0.0087280273, -0.0090942383,
+ -0.0088195801, -0.0081481934, -0.0072937012, -0.006439209,
+ -0.005279541, -0.0043640137, -0.0034179688, -0.003112793,
+ -0.0025024414, -0.0022888184, -0.0019226074, -0.0015869141,
+ -0.0015869141, -0.0015258789, -0.0016784668, -0.0017700195,
+ -0.0016784668, -0.0013427734, -0.0011291504, -0.00061035156, 0,
+ 0.00079345703, 0.0012207031, 0.0015869141, 0.0016479492,
+ 0.0015258789, 0.0012817383, 0.00094604492, 0.00045776367,
+ -0.0002746582, -0.00088500977, -0.0016479492, -0.0024108887,
+ -0.0036621094, -0.0050354004, -0.0063476562, -0.0079956055,
+ -0.0096435547, -0.011535645, -0.013458252, -0.014953613,
+ -0.016296387, -0.017364502, -0.01776123, -0.018280029, -0.018371582,
+ -0.018035889, -0.017456055, -0.016479492, -0.015838623,
+ -0.015167236, -0.015228271, -0.015380859, -0.015625, -0.015716553,
+ -0.015411377, -0.015197754, -0.015106201, -0.01473999, -0.014221191,
+ -0.013092041, -0.012054443, -0.010742188, -0.008605957,
+ -0.006439209, -0.0038757324, -0.0016479492, 0.00079345703,
+ 0.0026550293, 0.0045471191, 0.0065612793, 0.009185791, 0.011566162,
+ 0.013427734, 0.014404297, 0.015075684, 0.015411377, 0.015319824,
+ 0.014801025, 0.013977051, 0.013305664, 0.012634277, 0.011932373,
+ 0.010864258, 0.0099182129, 0.0098571777, 0.0093994141, 0.0091247559,
+ 0.0080566406, 0.0068359375, 0.0056762695, 0.0043640137,
+ 0.0037841797, 0.0027770996, 0.0023803711, 0.0017700195,
+ 0.0010375977, 0, -0.0011901855, -0.0020446777, -0.0028991699,
+ -0.0037841797, -0.0050964355, -0.0057983398, -0.0063476562,
+ -0.0065917969, -0.0063781738, -0.0061950684, -0.0056152344,
+ -0.0050354004, -0.0045471191, -0.0035705566, -0.0025939941,
+ -0.00091552734, 0.00082397461, 0.0028076172, 0.0045471191,
+ 0.0061950684, 0.0078430176, 0.0096435547, 0.010742188, 0.011474609,
+ 0.012176514, 0.01260376, 0.013153076, 0.013458252, 0.014129639,
+ 0.014801025, 0.015228271, 0.015991211, 0.016204834, 0.01663208,
+ 0.016601562, 0.016357422, 0.015808105, 0.014770508, 0.014007568,
+ 0.012939453, 0.012268066, 0.011444092, 0.01071167, 0.010070801,
+ 0.0086975098, 0.0075683594, 0.0058288574, 0.0040588379,
+ 0.0018615723, 6.1035156e-05, -0.0015258789, -0.0029602051,
+ -0.0040283203, -0.0055236816, -0.0065307617, -0.0078735352,
+ -0.0090942383, -0.010131836, -0.010925293, -0.011260986,
+ -0.011322021, -0.011199951, -0.010955811, -0.010925293, -0.0105896,
+ -0.010375977, -0.0097351074, -0.0092163086, -0.0085754395,
+ -0.0077819824, -0.007232666, -0.0067443848, -0.0063171387,
+ -0.0060119629, -0.0053405762, -0.0050048828, -0.0045166016,
+ -0.0040588379, -0.0035400391, -0.0030517578, -0.0029907227,
+ -0.0027160645, -0.0028076172, -0.0025024414, -0.0021972656,
+ -0.001953125, -0.0013122559, -0.00091552734, -0.00033569336,
+ -0.00012207031, -0.00024414062, -0.00054931641, -0.0010375977,
+ -0.0018615723, -0.0028686523, -0.0036010742, -0.0042724609,
+ -0.0046691895, -0.0052490234, -0.0056152344, -0.0061035156,
+ -0.0066833496, -0.0074768066, -0.0083007812, -0.0089111328,
+ -0.0093688965, -0.0096435547, -0.0096740723, -0.0093994141,
+ -0.0086669922, -0.0079040527, -0.0073242188, -0.007019043,
+ -0.0067749023, -0.0067138672, -0.0064697266, -0.0060424805,
+ -0.0054931641, -0.0048828125, -0.0044250488, -0.0039367676,
+ -0.0031738281, -0.0024414062, -0.0014953613, -0.00039672852,
+ 0.0007019043, 0.001739502, 0.0028991699, 0.0042724609, 0.005645752,
+ 0.0072021484, 0.0087585449, 0.010192871, 0.011627197, 0.012542725,
+ 0.013244629, 0.01361084, 0.013671875, 0.013580322, 0.013122559,
+ 0.012512207, 0.012145996, 0.011993408, 0.011932373, 0.011779785,
+ 0.011352539, 0.010742188, 0.0099487305, 0.0090942383, 0.0079956055,
+ 0.0068054199, 0.0057373047, 0.0047912598, 0.004119873, 0.003326416,
+ 0.0027770996, 0.0021057129, 0.0015869141, 0.0010375977,
+ 0.00024414062, -0.00030517578, -0.00085449219, -0.0012512207,
+ -0.0015869141, -0.002166748, -0.0025939941, -0.0032043457,
+ -0.0038757324, -0.0043640137, -0.0044250488, -0.004486084,
+ -0.004119873, -0.0036621094, -0.0028381348, -0.0020751953,
+ -0.0012817383, -0.00064086914, -0.00012207031, 0.00051879883,
+ 0.0012512207, 0.002166748, 0.0032653809, 0.0042419434, 0.0049743652,
+ 0.0056152344, 0.0059509277, 0.0061645508, 0.0062866211,
+ 0.0061035156, 0.0059204102, 0.005645752, 0.005645752, 0.0054016113,
+ 0.0051879883, 0.0050354004, 0.0049133301, 0.0049133301, 0.004699707,
+ 0.0045776367, 0.0043640137, 0.0040283203, 0.0033569336,
+ 0.0025024414, 0.0013122559, 6.1035156e-05, -0.0009765625,
+ -0.0021972656, -0.0028076172, -0.0036010742, -0.0038452148,
+ -0.0042419434, -0.004699707, -0.0052185059, -0.0058898926,
+ -0.0064697266, -0.0073242188, -0.0082397461, -0.0091552734,
+ -0.0096740723, -0.0099182129, -0.0096435547, -0.0091552734,
+ -0.0085449219, -0.0079040527, -0.0074768066, -0.0068969727,
+ -0.0066223145, -0.0062561035, -0.005859375, -0.0055236816,
+ -0.0049438477, -0.0045471191, -0.0039672852, -0.0035095215,
+ -0.0030822754, -0.002746582, -0.0026245117, -0.0025939941,
+ -0.002532959, -0.0024414062, -0.0020141602, -0.0015869141,
+ -0.001159668, -0.00067138672, -0.0002746582, 0.00021362305,
+ 0.00033569336, 0.00045776367, 0.00051879883, 0.00064086914,
+ 0.00079345703, 0.00088500977, 0.00094604492, 0.00082397461,
+ 0.00064086914, 0.00030517578, 0.00015258789, -0.00024414062,
+ -0.00061035156, -0.0011901855, -0.0016174316, -0.0020446777,
+ -0.0022888184, -0.0023803711, -0.0023803711, -0.0023803711,
+ -0.0023498535, -0.0022888184, -0.0020446777, -0.0018005371,
+ -0.0014343262, -0.0011901855, -0.00088500977, -0.00064086914,
+ -0.00045776367, -0.00039672852, -0.00033569336, -0.00015258789, 0,
+ 0.00030517578, 0.00054931641, 0.0010375977, 0.001373291,
+ 0.0016784668, 0.001953125, 0.0023193359, 0.0028381348, 0.0035095215,
+ 0.0043334961, 0.0049133301, 0.0056152344, 0.006072998, 0.0065917969,
+ 0.0068664551, 0.0072021484, 0.0073547363, 0.0074768066,
+ 0.0075378418, 0.0073547363, 0.0070800781, 0.0066223145,
+ 0.0062866211, 0.005859375, 0.0054321289, 0.0050048828, 0.0045776367,
+ 0.0043334961, 0.0039978027, 0.003692627, 0.0032958984, 0.0029602051,
+ 0.0024108887, 0.0019226074, 0.0014343262, 0.00088500977,
+ 0.00054931641, 0.00012207031, -0.00015258789, -0.00045776367,
+ -0.00067138672, -0.0009765625, -0.0012512207, -0.0015869141,
+ -0.001953125, -0.0022888184, -3.0517578e-05, -3.0517578e-05,
+ -3.0517578e-05, -3.0517578e-05, -3.0517578e-05, -3.0517578e-05,
+ -3.0517578e-05, -3.0517578e-05, -3.0517578e-05, -6.1035156e-05,
+ -3.0517578e-05, -6.1035156e-05, -3.0517578e-05, -6.1035156e-05,
+ -6.1035156e-05, -3.0517578e-05, -3.0517578e-05, -3.0517578e-05,
+ -3.0517578e-05, -3.0517578e-05, -3.0517578e-05, -3.0517578e-05,
+ -3.0517578e-05, -3.0517578e-05, -3.0517578e-05, -3.0517578e-05,
+ -3.0517578e-05, -3.0517578e-05, 0,
+ };
+
+static const unsigned defaultClickEmphasisLength = sizeof(defaultClickEmphasis) / sizeof(*defaultClickEmphasis);
+
diff --git a/attic/muse2-oom/muse2/muse/device.h b/attic/muse2-oom/muse2/muse/device.h
new file mode 100644
index 00000000..b77ffb9b
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/device.h
@@ -0,0 +1,46 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: device.h,v 1.1.1.1 2003/10/27 18:51:58 wschweer Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __DEVICE_H__
+#define __DEVICE_H__
+
+class QString;
+
+//---------------------------------------------------------
+// Device
+//---------------------------------------------------------
+
+class Device {
+
+ public:
+ enum DeviceType { MidiDevice, WaveDevice };
+
+ protected:
+ QString _name;
+ DeviceType _type;
+ int _port;
+
+ public:
+ Device() {}
+ virtual ~Device() {}
+ Device(const QString& name, DeviceType t = MidiDevice)
+ : _name(name), _type(t) {}
+
+ virtual QString open(int) = 0;
+ virtual void close() = 0;
+
+ const QString& name() const { return _name; }
+ void setName(const QString& s) { _name = s; }
+ const DeviceType type() const { return _type; }
+ void setDeviceType(DeviceType t) { _type = t; }
+ int port() const { return _port; }
+ void setPort(int p) { _port = p; }
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/driver/CMakeLists.txt b/attic/muse2-oom/muse2/muse/driver/CMakeLists.txt
new file mode 100644
index 00000000..fbac3f0b
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/driver/CMakeLists.txt
@@ -0,0 +1,73 @@
+#=============================================================================
+# MusE
+# Linux Music Editor
+# $Id:$
+#
+# Copyright (C) 2002-2006 by Werner Schweer and others
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#=============================================================================
+
+##
+## List of source files to compile
+##
+file (GLOB driver_source_files
+ alsamidi.cpp
+ alsatimer.cpp
+ dummyaudio.cpp
+ jack.cpp
+ jackmidi.cpp
+ rtctimer.cpp
+ )
+
+##
+## Define target
+##
+add_library ( driver SHARED
+ # ${PROJECT_BINARY_DIR}/all.h.pch
+ ${driver_source_files}
+ )
+
+##
+## Append to the list of translations
+##
+set (FILES_TO_TRANSLATE
+ ${FILES_TO_TRANSLATE}
+ ${driver_source_files}
+ CACHE INTERNAL ""
+ )
+
+##
+## Compilation flags and target name
+##
+set_target_properties( driver
+ PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h -fPIC"
+ OUTPUT_NAME muse_driver
+ )
+
+##
+## Linkage
+##
+target_link_libraries ( driver
+ ${ALSA_LIBRARIES}
+ ${JACK_LIBRARIES}
+ ${QT_LIBRARIES}
+ mplugins
+ )
+
+##
+## Install location
+##
+install(TARGETS driver
+ DESTINATION ${MusE_MODULES_DIR}
+ )
diff --git a/attic/muse2-oom/muse2/muse/driver/alsamidi.cpp b/attic/muse2-oom/muse2/muse/driver/alsamidi.cpp
new file mode 100644
index 00000000..c7ae07b5
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/driver/alsamidi.cpp
@@ -0,0 +1,917 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: alsamidi.cpp,v 1.8.2.7 2009/11/19 04:20:33 terminator356 Exp $
+// (C) Copyright 2000-2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+
+#include "alsamidi.h"
+#include "globals.h"
+#include "midi.h"
+#include "mididev.h"
+#include "../midiport.h"
+#include "../midiseq.h"
+#include "../midictrl.h"
+#include "../audio.h"
+#include "mpevent.h"
+//#include "sync.h"
+#include "utils.h"
+#include "audiodev.h"
+#include "xml.h"
+
+static int alsaSeqFdi = -1;
+static int alsaSeqFdo = -1;
+
+snd_seq_t* alsaSeq;
+static snd_seq_addr_t musePort;
+
+//---------------------------------------------------------
+// MidiAlsaDevice
+//---------------------------------------------------------
+
+MidiAlsaDevice::MidiAlsaDevice(const snd_seq_addr_t& a, const QString& n)
+ : MidiDevice(n)
+ {
+ adr = a;
+ init();
+ }
+
+//---------------------------------------------------------
+// selectWfd
+//---------------------------------------------------------
+
+int MidiAlsaDevice::selectWfd()
+ {
+ return alsaSeqFdo;
+ }
+
+//---------------------------------------------------------
+// open
+//---------------------------------------------------------
+
+QString MidiAlsaDevice::open()
+{
+ _openFlags &= _rwFlags; // restrict to available bits
+ snd_seq_port_subscribe_t* subs;
+ // Allocated on stack, no need to call snd_seq_port_subscribe_free() later.
+ snd_seq_port_subscribe_alloca(&subs);
+
+ QString estr;
+ int wer = 0;
+ int rer = 0;
+
+ // subscribe for writing
+ if (_openFlags & 1)
+ {
+ snd_seq_port_subscribe_set_sender(subs, &musePort);
+ snd_seq_port_subscribe_set_dest(subs, &adr);
+ // Not already subscribed (or error)? Then try subscribing.
+ if(snd_seq_get_port_subscription(alsaSeq, subs) < 0)
+ {
+ //int error = snd_seq_subscribe_port(alsaSeq, subs);
+ wer = snd_seq_subscribe_port(alsaSeq, subs);
+ //if (error < 0)
+ if(wer < 0)
+ //return QString("Play: ")+QString(snd_strerror(error));
+ estr += (QString("Play: ") + QString(snd_strerror(wer)) + QString(" "));
+ }
+ if(!wer)
+ _writeEnable = true;
+ }
+
+ // subscribe for reading
+ if (_openFlags & 2)
+ {
+ snd_seq_port_subscribe_set_dest(subs, &musePort);
+ snd_seq_port_subscribe_set_sender(subs, &adr);
+ // Not already subscribed (or error)? Then try subscribing.
+ if(snd_seq_get_port_subscription(alsaSeq, subs) < 0)
+ {
+ //int error = snd_seq_subscribe_port(alsaSeq, subs);
+ rer = snd_seq_subscribe_port(alsaSeq, subs);
+ //if (error < 0)
+ if(rer < 0)
+ //return QString("Rec: ") + QString(snd_strerror(error));
+ estr += (QString("Rec: ") + QString(snd_strerror(rer)));
+ }
+ if(!rer)
+ _readEnable = true;
+ }
+
+
+ if(wer < 0 || rer < 0)
+ return estr;
+
+ return QString("OK");
+}
+
+//---------------------------------------------------------
+// close
+//---------------------------------------------------------
+
+void MidiAlsaDevice::close()
+{
+ snd_seq_port_subscribe_t* subs;
+ // Allocated on stack, no need to call snd_seq_port_subscribe_free() later.
+ snd_seq_port_subscribe_alloca(&subs);
+
+ // Changed by T356. This function appears to be called only by MidiPort::setMidiDevice(),
+ // which closes then opens the device.
+ // Because the open flags are set BEFORE setMidiDevice() is called, we must ignore the flags.
+ //
+ // NOTE: Tested: The read unsubscribe works ok but not the write.
+ // As viewed in say, qjackctl, the connection is clearly lost,
+ // but strangely the events are still accepted, ie, playback notes
+ // are still heard etc. Tried an alsa midi device AND external fluidsynth inst.
+ //
+ // Also, jack running and with jack midi disabled, we get messages like
+ // MidiAlsaDevice::0x84512c0 putEvent(): midi write error: No such device
+ // dst 16:0
+ // only sometimes (not when playing notes), but with jack midi turned on,
+ // we don't get the messages. With jack stopped we get the messages
+ // no matter if jack midi is turned on or not.
+
+ //if (_openFlags & 1) {
+ //if (!(_openFlags & 1))
+ {
+ snd_seq_port_subscribe_set_sender(subs, &musePort);
+ snd_seq_port_subscribe_set_dest(subs, &adr);
+
+ // Already subscribed? Then unsubscribe.
+ if(!snd_seq_get_port_subscription(alsaSeq, subs))
+ {
+ if(!snd_seq_unsubscribe_port(alsaSeq, subs))
+ _writeEnable = false;
+ else
+ printf("MidiAlsaDevice::close Error unsubscribing alsa midi port for writing\n");
+ }
+ else
+ _writeEnable = false;
+ }
+
+ //if (_openFlags & 2) {
+ //if (!(_openFlags & 2))
+ {
+ snd_seq_port_subscribe_set_dest(subs, &musePort);
+ snd_seq_port_subscribe_set_sender(subs, &adr);
+
+ // Already subscribed? Then unsubscribe.
+ if(!snd_seq_get_port_subscription(alsaSeq, subs))
+ {
+ if(!snd_seq_unsubscribe_port(alsaSeq, subs))
+ _readEnable = false;
+ else
+ printf("MidiAlsaDevice::close Error unsubscribing alsa midi port for reading\n");
+ }
+ else
+ _readEnable = false;
+ }
+}
+
+//---------------------------------------------------------
+// writeRouting
+//---------------------------------------------------------
+
+void MidiAlsaDevice::writeRouting(int level, Xml& xml) const
+{
+ // p3.3.45
+ // If this device is not actually in use by the song, do not write any routes.
+ // This prevents bogus routes from being saved and propagated in the med file.
+ if(midiPort() == -1)
+ return;
+
+ QString s;
+ /*
+ //if(rwFlags() & 2) // Readable
+ {
+ //RouteList* rl = _inRoutes;
+ //for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ for (ciRoute r = _inRoutes.begin(); r != _inRoutes.end(); ++r)
+ {
+ // Since an ALSA midi device supports read + write, this is the only way we can tell if this route is using the device as input.
+ if(r->type == Route::TRACK_ROUTE)
+ continue;
+
+ if(!r->name().isEmpty())
+ {
+ xml.tag(level++, "Route");
+
+ //xml.strTag(level, "srcNode", r->name());
+ xml.tag(level, "source type=\"%d\" name=\"%s\"/", r->type, r->name().toLatin1().constData());
+
+ //xml.strTag(level, "dstNode", name());
+ xml.tag(level, "dest type=\"%d\" name=\"%s\"/", Route::ALSA_MIDI_ROUTE, name().toLatin1().constData());
+
+ xml.etag(level--, "Route");
+ }
+ }
+ }
+ */
+
+ for (ciRoute r = _outRoutes.begin(); r != _outRoutes.end(); ++r)
+ {
+ //if(r->type != Route::TRACK_ROUTE)
+ //{
+ // printf("MidiAlsaDevice::writeRouting Warning out route is not TRACK_ROUTE type\n");
+ // continue;
+ //}
+
+ if(!r->name().isEmpty())
+ {
+ //xml.tag(level++, "Route");
+
+ s = QT_TRANSLATE_NOOP("@default", "Route");
+ if(r->channel != -1)
+ s += QString(QT_TRANSLATE_NOOP("@default", " channel=\"%1\"")).arg(r->channel);
+ xml.tag(level++, s.toLatin1().constData());
+
+ /*
+ //xml.strTag(level, "srcNode", name());
+ if(r->channel != -1)
+ //xml.tag(level, "source type=\"%d\" channel=\"%d\" name=\"%s\"/", Route::ALSA_MIDI_ROUTE, r->channel, name().toLatin1().constData());
+ //xml.tag(level, "source type=\"%d\" channel=\"%d\" name=\"%s\"/", Route::MIDI_DEVICE_ROUTE, r->channel, name().toLatin1().constData());
+ xml.tag(level, "source devtype=\"%d\" channel=\"%d\" name=\"%s\"/", MidiDevice::ALSA_MIDI, r->channel, name().toLatin1().constData());
+ else
+ //xml.tag(level, "source type=\"%d\" name=\"%s\"/", Route::ALSA_MIDI_ROUTE, name().toLatin1().constData());
+ //xml.tag(level, "source type=\"%d\" name=\"%s\"/", Route::MIDI_DEVICE_ROUTE, name().toLatin1().constData());
+ */
+ //xml.tag(level, "source devtype=\"%d\" name=\"%s\"/", MidiDevice::ALSA_MIDI, name().toLatin1().constData());
+ xml.tag(level, "source devtype=\"%d\" name=\"%s\"/", MidiDevice::ALSA_MIDI, Xml::xmlString(name()).toLatin1().constData());
+
+ /*
+ //xml.strTag(level, "dstNode", r->name());
+ if(r->channel != -1)
+ {
+ if(r->type == Route::MIDI_DEVICE_ROUTE)
+ xml.tag(level, "dest devtype=\"%d\" channel=\"%d\" name=\"%s\"/", r->device->deviceType(), r->channel, r->name().toLatin1().constData());
+ else
+ xml.tag(level, "dest type=\"%d\" channel=\"%d\" name=\"%s\"/", r->type, r->channel, r->name().toLatin1().constData());
+ }
+ else
+ {
+ if(r->type == Route::MIDI_DEVICE_ROUTE)
+ xml.tag(level, "dest devtype=\"%d\" name=\"%s\"/", r->device->deviceType(), r->name().toLatin1().constData());
+ else
+ xml.tag(level, "dest type=\"%d\" name=\"%s\"/", r->type, r->name().toLatin1().constData());
+ }
+ */
+
+ s = QT_TRANSLATE_NOOP("@default", "dest");
+ if(r->type == Route::MIDI_DEVICE_ROUTE)
+ s += QString(QT_TRANSLATE_NOOP("@default", " devtype=\"%1\"")).arg(r->device->deviceType());
+ else
+ if(r->type != Route::TRACK_ROUTE)
+ s += QString(QT_TRANSLATE_NOOP("@default", " type=\"%1\"")).arg(r->type);
+ //s += QString(QT_TRANSLATE_NOOP("@default", " name=\"%1\"/")).arg(r->name());
+ s += QString(QT_TRANSLATE_NOOP("@default", " name=\"%1\"/")).arg(Xml::xmlString(r->name()));
+ xml.tag(level, s.toLatin1().constData());
+
+ xml.etag(level--, "Route");
+ }
+ }
+}
+
+//---------------------------------------------------------
+// putEvent
+//---------------------------------------------------------
+
+bool MidiAlsaDevice::putMidiEvent(const MidiPlayEvent& e)
+ {
+ if (midiOutputTrace) {
+ printf("MidiOut: midiAlsa: ");
+ e.dump();
+ }
+ int chn = e.channel();
+ int a = e.dataA();
+ int b = e.dataB();
+
+ snd_seq_event_t event;
+ memset(&event, 0, sizeof(event));
+ event.queue = SND_SEQ_QUEUE_DIRECT;
+ event.source = musePort;
+ event.dest = adr;
+
+ switch(e.type()) {
+ case ME_NOTEON:
+ snd_seq_ev_set_noteon(&event, chn, a, b);
+ break;
+ case ME_NOTEOFF:
+ snd_seq_ev_set_noteoff(&event, chn, a, 0);
+ break;
+ case ME_PROGRAM:
+ snd_seq_ev_set_pgmchange(&event, chn, a);
+ break;
+ case ME_CONTROLLER:
+#if 1
+ snd_seq_ev_set_controller(&event, chn, a, b);
+#else
+ {
+ int a = e.dataA();
+ int b = e.dataB();
+ int chn = e.channel();
+ // p3.3.37
+ //if (a < 0x1000) { // 7 Bit Controller
+ if (a < CTRL_14_OFFSET) { // 7 Bit Controller
+ snd_seq_ev_set_controller(&event, chn, a, b);
+ }
+ //else if (a < 0x20000) { // 14 bit high resolution controller
+ else if (a < CTRL_RPN_OFFSET) { // 14 bit high resolution controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ a = (ctrlH << 7) + ctrlL;
+ snd_seq_ev_set_controller(&event, chn, a, b);
+ event.type = SND_SEQ_EVENT_CONTROL14;
+ }
+ //else if (a < 0x30000) { // RPN 7-Bit Controller
+ else if (a < CTRL_NRPN_OFFSET) { // RPN 7-Bit Controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ a = (ctrlH << 7) + ctrlL;
+ b <<= 7;
+ snd_seq_ev_set_controller(&event, chn, a, b);
+ event.type = SND_SEQ_EVENT_REGPARAM;
+ }
+ //else if (a < 0x40000) { // NRPN 7-Bit Controller
+ else if (a < CTRL_INTERNAL_OFFSET) { // NRPN 7-Bit Controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ a = (ctrlH << 7) + ctrlL;
+ b <<= 7;
+ snd_seq_ev_set_controller(&event, chn, a, b);
+ event.type = SND_SEQ_EVENT_NONREGPARAM;
+ }
+ //else if (a < 0x60000) { // RPN14 Controller
+ else if (a < CTRL_NRPN14_OFFSET) { // RPN14 Controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ a = (ctrlH << 7) + ctrlL;
+ snd_seq_ev_set_controller(&event, chn, a, b);
+ event.type = SND_SEQ_EVENT_REGPARAM;
+ }
+ //else if (a < 0x70000) { // NRPN14 Controller
+ else if (a < CTRL_NONE_OFFSET) { // NRPN14 Controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ a = (ctrlH << 7) + ctrlL;
+ snd_seq_ev_set_controller(&event, chn, a, b);
+ event.type = SND_SEQ_EVENT_NONREGPARAM;
+ }
+ else {
+ printf("putEvent: unknown controller type 0x%x\n", a);
+ }
+ }
+#endif
+ break;
+ case ME_PITCHBEND:
+ snd_seq_ev_set_pitchbend(&event, chn, a);
+ break;
+ case ME_POLYAFTER:
+ // chnEvent2(chn, 0xa0, a, b);
+ break;
+ case ME_AFTERTOUCH:
+ snd_seq_ev_set_chanpress(&event, chn, a);
+ break;
+ case ME_SYSEX:
+ {
+ const unsigned char* p = e.data();
+ int n = e.len();
+ int len = n + sizeof(event) + 2;
+ char buf[len];
+ event.type = SND_SEQ_EVENT_SYSEX;
+ event.flags = SND_SEQ_EVENT_LENGTH_VARIABLE;
+ event.data.ext.len = n + 2;
+ event.data.ext.ptr = (void*)(buf + sizeof(event));
+ memcpy(buf, &event, sizeof(event));
+ char* pp = buf + sizeof(event);
+ *pp++ = 0xf0;
+ memcpy(pp, p, n);
+ pp += n;
+ *pp = 0xf7;
+ return putEvent(&event);
+ }
+ case ME_SONGPOS:
+ event.data.control.value = a;
+ event.type = SND_SEQ_EVENT_SONGPOS;
+ break;
+ case ME_CLOCK:
+ event.type = SND_SEQ_EVENT_CLOCK;
+ break;
+ case ME_START:
+ event.type = SND_SEQ_EVENT_START;
+ break;
+ case ME_CONTINUE:
+ event.type = SND_SEQ_EVENT_CONTINUE;
+ break;
+ case ME_STOP:
+ event.type = SND_SEQ_EVENT_STOP;
+ break;
+ default:
+ printf("MidiAlsaDevice::putEvent(): event type %d not implemented\n",
+ e.type());
+ return true;
+ }
+ return putEvent(&event);
+ }
+
+//---------------------------------------------------------
+// putEvent
+// return false if event is delivered
+//---------------------------------------------------------
+
+bool MidiAlsaDevice::putEvent(snd_seq_event_t* event)
+ {
+ int error;
+
+ do {
+ error = snd_seq_event_output_direct(alsaSeq, event);
+ int len = snd_seq_event_length(event);
+ if (error == len) {
+// printf(".");fflush(stdout);
+ return false;
+ }
+ if (error < 0) {
+ if (error == -12) {
+// printf("?");fflush(stdout);
+ return true;
+ }
+ else {
+ fprintf(stderr, "MidiAlsaDevice::%p putEvent(): midi write error: %s\n",
+ this, snd_strerror(error));
+ fprintf(stderr, " dst %d:%d\n", adr.client, adr.port);
+ //exit(-1);
+ }
+ }
+ else
+ fprintf(stderr, "MidiAlsaDevice::putEvent(): midi write returns %d, expected %d: %s\n",
+ error, len, snd_strerror(error));
+ } while (error == -12);
+ return true;
+ }
+
+//---------------------------------------------------------
+// initMidiAlsa
+// return true on error
+//---------------------------------------------------------
+
+bool initMidiAlsa()
+ {
+ if (debugMsg)
+ printf("initMidiAlsa\n");
+ int error = snd_seq_open(&alsaSeq, "hw", SND_SEQ_OPEN_DUPLEX, SND_SEQ_NONBLOCK);
+ if (error < 0) {
+ fprintf(stderr, "Could not open ALSA sequencer: %s\n",
+ snd_strerror(error));
+ return true;
+ }
+ const int inCap = SND_SEQ_PORT_CAP_SUBS_READ;
+ const int outCap = SND_SEQ_PORT_CAP_SUBS_WRITE;
+
+ snd_seq_client_info_t *cinfo;
+ snd_seq_client_info_alloca(&cinfo);
+ snd_seq_client_info_set_client(cinfo, -1);
+
+ while (snd_seq_query_next_client(alsaSeq, cinfo) >= 0) {
+ snd_seq_port_info_t *pinfo;
+ snd_seq_port_info_alloca(&pinfo);
+ snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo));
+ snd_seq_port_info_set_port(pinfo, -1);
+
+ while (snd_seq_query_next_port(alsaSeq, pinfo) >= 0) {
+ unsigned int capability = snd_seq_port_info_get_capability(pinfo);
+ if ((capability & outCap) == 0) {
+ const char *name = snd_seq_port_info_get_name(pinfo);
+ if (strcmp("Timer", name) == 0 ||
+ strcmp("Announce", name) == 0 ||
+ strcmp("Receiver", name) == 0)
+ continue;
+ }
+ snd_seq_addr_t adr = *snd_seq_port_info_get_addr(pinfo);
+ MidiAlsaDevice* dev = new MidiAlsaDevice(adr, QString(snd_seq_port_info_get_name(pinfo)));
+ int flags = 0;
+ if (capability & outCap)
+ flags |= 1;
+ if (capability & inCap)
+ flags |= 2;
+ dev->setrwFlags(flags);
+ if (debugMsg)
+ printf("ALSA port add: <%s>, %d:%d flags %d 0x%0x\n",
+ snd_seq_port_info_get_name(pinfo),
+ adr.client, adr.port,
+ flags, capability);
+ midiDevices.add(dev);
+
+ /*
+ // Experimental... Need to list 'sensible' devices first and ignore unwanted ones...
+ // Add instance last in midi device list.
+ for(int i = 0; i < MIDI_PORTS; ++i)
+ {
+ MidiPort* mp = &midiPorts[i];
+ if(mp->device() == 0)
+ {
+ // midiSeq might not be initialzed yet!
+ //midiSeq->msgSetMidiDevice(mp, dev);
+ mp->setMidiDevice(dev);
+
+ //muse->changeConfig(true); // save configuration file
+ //update();
+ break;
+ }
+ }
+ */
+
+ }
+ }
+
+ // p3.3.38
+ //snd_seq_set_client_name(alsaSeq, "MusE Sequencer");
+ snd_seq_set_client_name(alsaSeq, audioDevice->clientName());
+
+ int ci = snd_seq_poll_descriptors_count(alsaSeq, POLLIN);
+ int co = snd_seq_poll_descriptors_count(alsaSeq, POLLOUT);
+
+ if (ci > 1 || co > 1) {
+ printf("ALSA midi: cannot handle more than one poll fd\n");
+ abort();
+ }
+
+ struct pollfd pfdi[ci];
+ struct pollfd pfdo[co];
+ snd_seq_poll_descriptors(alsaSeq, pfdi, ci, POLLIN);
+ snd_seq_poll_descriptors(alsaSeq, pfdo, co, POLLOUT);
+ alsaSeqFdo = pfdo[0].fd;
+ alsaSeqFdi = pfdi[0].fd;
+
+ int port = snd_seq_create_simple_port(alsaSeq, "MusE Port 0",
+ inCap | outCap | SND_SEQ_PORT_CAP_READ | SND_SEQ_PORT_CAP_WRITE,
+ SND_SEQ_PORT_TYPE_APPLICATION);
+ if (port < 0) {
+ perror("create port");
+ exit(1);
+ }
+ musePort.port = port;
+ musePort.client = snd_seq_client_id(alsaSeq);
+
+ //-----------------------------------------
+ // subscribe to "Announce"
+ // this enables callbacks for any
+ // alsa port changes
+ //-----------------------------------------
+
+ snd_seq_addr_t aadr;
+ aadr.client = SND_SEQ_CLIENT_SYSTEM;
+ aadr.port = SND_SEQ_PORT_SYSTEM_ANNOUNCE;
+
+ snd_seq_port_subscribe_t* subs;
+ snd_seq_port_subscribe_alloca(&subs);
+ snd_seq_port_subscribe_set_dest(subs, &musePort);
+ snd_seq_port_subscribe_set_sender(subs, &aadr);
+ error = snd_seq_subscribe_port(alsaSeq, subs);
+ if (error < 0) {
+ printf("Alsa: Subscribe System failed: %s", snd_strerror(error));
+ return true;
+ }
+ return false;
+ }
+
+struct AlsaPort {
+ snd_seq_addr_t adr;
+ char* name;
+ int flags;
+ AlsaPort(snd_seq_addr_t a, const char* s, int f) {
+ adr = a;
+ name = strdup(s);
+ flags = f;
+ }
+ };
+
+static std::list<AlsaPort> portList;
+
+//---------------------------------------------------------
+// alsaScanMidiPorts
+//---------------------------------------------------------
+
+void alsaScanMidiPorts()
+ {
+// printf("alsa scan midi ports\n");
+ const int inCap = SND_SEQ_PORT_CAP_SUBS_READ;
+ const int outCap = SND_SEQ_PORT_CAP_SUBS_WRITE;
+
+ portList.clear();
+
+ snd_seq_client_info_t* cinfo;
+ snd_seq_client_info_alloca(&cinfo);
+ snd_seq_client_info_set_client(cinfo, 0);
+
+ while (snd_seq_query_next_client(alsaSeq, cinfo) >= 0) {
+ snd_seq_port_info_t *pinfo;
+ snd_seq_port_info_alloca(&pinfo);
+ snd_seq_port_info_set_client(pinfo, snd_seq_client_info_get_client(cinfo));
+ snd_seq_port_info_set_port(pinfo, -1);
+ while (snd_seq_query_next_port(alsaSeq, pinfo) >= 0) {
+ unsigned int capability = snd_seq_port_info_get_capability(pinfo);
+ if (((capability & outCap) == 0)
+ && ((capability & inCap) == 0))
+ continue;
+ snd_seq_addr_t adr;
+ const char* name;
+ adr = *snd_seq_port_info_get_addr(pinfo);
+ name = snd_seq_port_info_get_name(pinfo);
+ if (adr.client == musePort.client && adr.port == musePort.port)
+ continue;
+ int flags = 0;
+ if (capability & outCap)
+ flags |= 1;
+ if (capability & inCap)
+ flags |= 2;
+// printf("ALSA port add: <%s>, flags %d\n", name, flags);
+ portList.push_back(AlsaPort(adr, name, flags));
+ }
+ }
+ //
+ // check for devices to delete
+ //
+ for (iMidiDevice i = midiDevices.begin(); i != midiDevices.end();) {
+ MidiAlsaDevice* d = dynamic_cast<MidiAlsaDevice*>(*i);
+ if (d == 0) {
+ ++i;
+ continue;
+ }
+ std::list<AlsaPort>::iterator k = portList.begin();
+ for (; k != portList.end(); ++k) {
+ if (k->adr.client == d->adr.client
+ && k->adr.port == d->adr.port) {
+ break;
+ }
+ }
+ if (k == portList.end()) {
+ if (d->midiPort() != -1)
+ midiPorts[d->midiPort()].setMidiDevice(0);
+ iMidiDevice k = i;
+// printf("erase device\n");
+ ++i;
+ midiDevices.erase(k);
+ }
+ else {
+ ++i;
+ }
+ }
+ //
+ // check for devices to add
+ //
+ for (std::list<AlsaPort>::iterator k = portList.begin(); k != portList.end(); ++k) {
+ iMidiDevice i = midiDevices.begin();
+// printf("ALSA port: <%s>\n", k->name);
+ for (;i != midiDevices.end(); ++i) {
+ MidiAlsaDevice* d = dynamic_cast<MidiAlsaDevice*>(*i);
+ if (d == 0)
+ continue;
+ if ((k->adr.client == d->adr.client) && (k->adr.port == d->adr.port)) {
+ break;
+ }
+ }
+ if (i == midiDevices.end()) {
+ // add device
+ MidiAlsaDevice* dev = new MidiAlsaDevice(k->adr,
+ QString(k->name));
+ dev->setrwFlags(k->flags);
+ midiDevices.add(dev);
+// printf("add device\n");
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// alsaSelectRfd
+//---------------------------------------------------------
+
+int alsaSelectRfd()
+ {
+ return alsaSeqFdi;
+ }
+
+//---------------------------------------------------------
+// alsaSelectWfd
+//---------------------------------------------------------
+
+int alsaSelectWfd()
+ {
+ return alsaSeqFdo;
+ }
+
+//---------------------------------------------------------
+// processInput
+//---------------------------------------------------------
+
+void alsaProcessMidiInput()
+{
+ MidiRecordEvent event;
+ snd_seq_event_t* ev;
+
+ for (;;)
+ {
+ int rv = snd_seq_event_input(alsaSeq, &ev);
+// printf("AlsaInput %d\n", rv);
+ if (rv < 0) {
+// printf("AlsaMidi: read error %s\n", snd_strerror(rv));
+ return;
+ }
+ switch(ev->type) {
+ case SND_SEQ_EVENT_PORT_SUBSCRIBED:
+ case SND_SEQ_EVENT_PORT_UNSUBSCRIBED:
+ return;
+ case SND_SEQ_EVENT_CLIENT_START:
+ case SND_SEQ_EVENT_CLIENT_EXIT:
+ // return;
+ // on first start of a software synthesizer we only
+ // get CLIENT_START event and no PORT_START, why?
+
+ case SND_SEQ_EVENT_PORT_START:
+ case SND_SEQ_EVENT_PORT_EXIT:
+ alsaScanMidiPorts();
+ audio->midiPortsChanged(); // signal gui
+ snd_seq_free_event(ev);
+ return;
+ }
+
+ int curPort = -1;
+ MidiAlsaDevice* mdev = 0;
+ //
+ // find real source device
+ //
+ for (iMidiDevice i = midiDevices.begin(); i != midiDevices.end(); ++i) {
+ MidiAlsaDevice* d = dynamic_cast<MidiAlsaDevice*>(*i);
+ if (d && d->adr.client == ev->source.client
+ && d->adr.port == ev->source.port) {
+ curPort = d->midiPort();
+ mdev = d;
+ }
+ }
+
+ if (mdev == 0 || curPort == -1) {
+ if (debugMsg) {
+ fprintf(stderr, "no port %d:%d found for received alsa event\n",
+ ev->source.client, ev->source.port);
+ }
+ snd_seq_free_event(ev);
+ return;
+ }
+
+ /*
+ if(curPort == -1)
+ {
+ if(mdev == 0)
+ {
+ if (debugMsg)
+ {
+ fprintf(stderr, "no port %d:%d found for received alsa event\n",
+ ev->source.client, ev->source.port);
+ }
+ }
+ else
+ {
+ // Allow the sync detect mechanisms to work, even if device is not assigned to a port.
+ if(ev->type == SND_SEQ_EVENT_CLOCK)
+ mdev->syncInfo().trigMCSyncDetect();
+ else
+ if(ev->type == SND_SEQ_EVENT_TICK)
+ mdev->syncInfo().trigTickDetect();
+ }
+ snd_seq_free_event(ev);
+ return;
+ }
+ */
+
+ event.setType(0); // mark as unused
+ event.setPort(curPort);
+ event.setB(0);
+
+ switch(ev->type)
+ {
+ case SND_SEQ_EVENT_NOTEON:
+ case SND_SEQ_EVENT_KEYPRESS:
+ event.setChannel(ev->data.note.channel);
+ event.setType(ME_NOTEON);
+ event.setA(ev->data.note.note);
+ event.setB(ev->data.note.velocity);
+ break;
+
+ case SND_SEQ_EVENT_NOTEOFF:
+ event.setChannel(ev->data.note.channel);
+ event.setType(ME_NOTEOFF);
+ event.setA(ev->data.note.note);
+ event.setB(ev->data.note.velocity);
+ break;
+
+ case SND_SEQ_EVENT_CHANPRESS:
+ event.setChannel(ev->data.control.channel);
+ event.setType(ME_AFTERTOUCH);
+ event.setA(ev->data.control.value);
+ break;
+
+ case SND_SEQ_EVENT_PGMCHANGE:
+ event.setChannel(ev->data.control.channel);
+ event.setType(ME_PROGRAM);
+ event.setA(ev->data.control.value);
+ break;
+
+ case SND_SEQ_EVENT_PITCHBEND:
+ event.setChannel(ev->data.control.channel);
+ event.setType(ME_PITCHBEND);
+ event.setA(ev->data.control.value);
+ break;
+
+ case SND_SEQ_EVENT_CONTROLLER:
+ event.setChannel(ev->data.control.channel);
+ event.setType(ME_CONTROLLER);
+ event.setA(ev->data.control.param);
+ event.setB(ev->data.control.value);
+ break;
+
+ case SND_SEQ_EVENT_CLOCK:
+ midiSeq->realtimeSystemInput(curPort, ME_CLOCK);
+ //mdev->syncInfo().trigMCSyncDetect();
+ break;
+
+ case SND_SEQ_EVENT_START:
+ midiSeq->realtimeSystemInput(curPort, ME_START);
+ break;
+
+ case SND_SEQ_EVENT_CONTINUE:
+ midiSeq->realtimeSystemInput(curPort, ME_CONTINUE);
+ break;
+
+ case SND_SEQ_EVENT_STOP:
+ midiSeq->realtimeSystemInput(curPort, ME_STOP);
+ break;
+
+ case SND_SEQ_EVENT_TICK:
+ midiSeq->realtimeSystemInput(curPort, ME_TICK);
+ //mdev->syncInfo().trigTickDetect();
+ break;
+
+ case SND_SEQ_EVENT_SYSEX:
+
+ // TODO: Deal with large sysex, which are broken up into chunks!
+ // For now, do not accept if the first byte is not SYSEX or the last byte is not EOX,
+ // meaning it's a chunk, possibly with more chunks to follow.
+ if((*((unsigned char*)ev->data.ext.ptr) != ME_SYSEX) ||
+ (*(((unsigned char*)ev->data.ext.ptr) + ev->data.ext.len - 1) != ME_SYSEX_END))
+ {
+ printf("MusE: alsaProcessMidiInput sysex chunks not supported!\n");
+ break;
+ }
+
+ event.setTime(0); // mark as used
+ event.setType(ME_SYSEX);
+ event.setData((unsigned char*)(ev->data.ext.ptr)+1,
+ ev->data.ext.len-2);
+ break;
+ case SND_SEQ_EVENT_PORT_SUBSCRIBED:
+ case SND_SEQ_EVENT_PORT_UNSUBSCRIBED: // write port is released
+ break;
+ case SND_SEQ_EVENT_SONGPOS:
+ midiSeq->setSongPosition(curPort, ev->data.control.value);
+ break;
+ case SND_SEQ_EVENT_SENSING:
+ break;
+ case SND_SEQ_EVENT_QFRAME:
+ midiSeq->mtcInputQuarter(curPort, ev->data.control.value);
+ break;
+ // case SND_SEQ_EVENT_CLIENT_START:
+ // case SND_SEQ_EVENT_CLIENT_EXIT:
+ // case SND_SEQ_EVENT_CLIENT_CHANGE:
+ // case SND_SEQ_EVENT_PORT_CHANGE:
+ // case SND_SEQ_EVENT_SONGSEL:
+ // case SND_SEQ_EVENT_TIMESIGN:
+ // case SND_SEQ_EVENT_KEYSIGN:
+ // case SND_SEQ_EVENT_SETPOS_TICK:
+ // case SND_SEQ_EVENT_SETPOS_TIME:
+ // case SND_SEQ_EVENT_TEMPO:
+ // case SND_SEQ_EVENT_TUNE_REQUEST:
+ // case SND_SEQ_EVENT_RESET:
+
+ // case SND_SEQ_EVENT_NOTE:
+ // case SND_SEQ_EVENT_CONTROL14:
+ // case SND_SEQ_EVENT_NONREGPARAM:
+ // case SND_SEQ_EVENT_REGPARAM:
+ default:
+ printf("ALSA Midi input: type %d not handled\n", ev->type);
+ break;
+ }
+ if(event.type())
+ {
+ mdev->recordEvent(event);
+ // p3.3.26 1/23/10 Moved to MidiDevice now. Anticipating Jack midi support, so don't make it ALSA specific. Tim.
+ //if(ev->type != SND_SEQ_EVENT_SYSEX)
+ // Trigger general activity indicator detector. Sysex has no channel, don't trigger.
+ // midiPorts[curPort].syncInfo().trigActDetect(event.channel());
+ }
+
+ snd_seq_free_event(ev);
+ if (rv == 0)
+ break;
+ }
+}
+
diff --git a/attic/muse2-oom/muse2/muse/driver/alsamidi.h b/attic/muse2-oom/muse2/muse/driver/alsamidi.h
new file mode 100644
index 00000000..455ab1df
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/driver/alsamidi.h
@@ -0,0 +1,58 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: alsamidi.h,v 1.2 2004/01/14 09:06:43 wschweer Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __ALSAMIDI_H__
+#define __ALSAMIDI_H__
+
+#include <config.h>
+#include <alsa/asoundlib.h>
+
+#include "mididev.h"
+
+class Xml;
+
+//---------------------------------------------------------
+// MidiAlsaDevice
+//---------------------------------------------------------
+
+class MidiAlsaDevice : public MidiDevice {
+ public:
+ snd_seq_addr_t adr;
+
+ private:
+ virtual QString open();
+ virtual void close();
+ virtual void processInput() {}
+ virtual int selectRfd() { return -1; }
+ virtual int selectWfd();
+
+ bool putEvent(snd_seq_event_t*);
+ virtual bool putMidiEvent(const MidiPlayEvent&);
+
+ public:
+ //MidiAlsaDevice() {} // p3.3.55 Removed
+ MidiAlsaDevice(const snd_seq_addr_t&, const QString& name);
+ virtual ~MidiAlsaDevice() {}
+
+ //virtual void* clientPort() { return (void*)&adr; }
+ // p3.3.55
+ virtual void* inClientPort() { return (void*)&adr; } // For ALSA midi, in/out client ports are the same.
+ virtual void* outClientPort() { return (void*)&adr; } // That is, ALSA midi client ports can be both r/w.
+
+ virtual void writeRouting(int, Xml&) const;
+ virtual inline int deviceType() { return ALSA_MIDI; }
+ };
+
+extern bool initMidiAlsa();
+extern int alsaSelectRfd();
+extern int alsaSelectWfd();
+extern void alsaProcessMidiInput();
+extern void alsaScanMidiPorts();
+
+#endif
+
+
diff --git a/attic/muse2-oom/muse2/muse/driver/alsatimer.cpp b/attic/muse2-oom/muse2/muse/driver/alsatimer.cpp
new file mode 100644
index 00000000..d851410d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/driver/alsatimer.cpp
@@ -0,0 +1,225 @@
+ //=========================================================
+ // MusE
+ // Linux Music Editor
+ // $Id: alsatimer.cpp,v 1.1.2.9 2009/03/28 01:46:10 terminator356 Exp $
+ //
+ // Plenty of code borrowed from timer.c example in
+ // alsalib 1.0.7
+ //
+ // (C) Copyright 2004 Robert Jonsson (rj@spamatica.se)
+ //=========================================================
+
+ #include "alsatimer.h"
+ #include <climits>
+
+#define TIMER_DEBUG 0
+
+ AlsaTimer::AlsaTimer()
+ {
+ if(TIMER_DEBUG)
+ fprintf(stderr,"AlsaTimer::AlsaTimer(this=%p) called\n",this);
+ handle = NULL;
+ id = NULL;
+ info = NULL;
+ params = NULL;
+ findBest = true;
+ }
+
+ AlsaTimer::~AlsaTimer()
+ {
+ if(TIMER_DEBUG)
+ fprintf(stderr,"AlsaTimer::~AlsaTimer(this=%p) called\n",this);
+ if (handle)
+ snd_timer_close(handle);
+ if (id) snd_timer_id_free(id);
+ if (info) snd_timer_info_free(info);
+ if (params) snd_timer_params_free(params);
+ }
+
+ signed int AlsaTimer::initTimer()
+ {
+ if(TIMER_DEBUG)
+ printf("AlsaTimer::initTimer(this=%p)\n",this);
+
+ int err;
+ int devclass = SND_TIMER_CLASS_GLOBAL;
+ int sclass = SND_TIMER_CLASS_NONE;
+ int card = 0;
+ int device = SND_TIMER_GLOBAL_SYSTEM;
+ int subdevice = 0;
+ int test_ids[] = { SND_TIMER_GLOBAL_SYSTEM
+ , SND_TIMER_GLOBAL_RTC
+#ifdef SND_TIMER_GLOBAL_HPET
+ , SND_TIMER_GLOBAL_HPET
+#endif
+ };
+ int max_ids = sizeof(test_ids) / sizeof(int);
+ long best_res = LONG_MAX;
+ //int best_dev = -1; // SND_TIMER_GLOBAL_SYSTEM;
+ int best_dev = SND_TIMER_GLOBAL_SYSTEM; // p3.3.51
+ int i;
+
+ if (id || info || params) {
+ fprintf(stderr,"AlsaTimer::initTimer(): called on initialised timer!\n");
+ return fds->fd;
+ }
+ snd_timer_id_malloc(&id);
+ snd_timer_info_malloc(&info);
+ snd_timer_params_malloc(&params);
+
+ if (findBest) {
+ for (i = 0; i < max_ids; ++i) {
+ device = test_ids[i];
+ sprintf(timername, "hw:CLASS=%i,SCLASS=%i,CARD=%i,DEV=%i,SUBDEV=%i", devclass, sclass, card, device, subdevice);
+ if ((err = snd_timer_open(&handle, timername, SND_TIMER_OPEN_NONBLOCK)) < 0) {
+ continue;
+ }
+ if ((err = snd_timer_info(handle, info)) < 0) {
+ snd_timer_close(handle);
+ continue;
+ }
+ // select a non slave timer with the lowest resolution value
+ int is_slave = snd_timer_info_is_slave(info);
+ long res = snd_timer_info_get_resolution(info);
+ if ((is_slave == 0) && (best_res > res)) {
+ best_res = res;
+ best_dev = device;
+ }
+ snd_timer_close(handle);
+ }
+ device = best_dev;
+ }
+
+ // p3.3.51 Removed.
+ //if(best_dev==-1)
+ // return -1; // no working timer found
+
+ sprintf(timername, "hw:CLASS=%i,SCLASS=%i,CARD=%i,DEV=%i,SUBDEV=%i", devclass, sclass, card, device, subdevice);
+ if ((err = snd_timer_open(&handle, timername, SND_TIMER_OPEN_NONBLOCK))<0) {
+ fprintf(stderr, "AlsaTimer::initTimer(): timer open %i (%s)\n", err, snd_strerror(err));
+ return -1; // p3.3.51
+ }
+
+ if ((err = snd_timer_info(handle, info)) < 0) {
+ fprintf(stderr, "AlsaTimer::initTimer(): timer info %i (%s)\n", err, snd_strerror(err));
+ return -1;
+ }
+
+ //if(debugMsg)
+ fprintf(stderr, "AlsaTimer::initTimer(): best available ALSA timer: %s\n", snd_timer_info_get_name(info));
+
+ snd_timer_params_set_auto_start(params, 1);
+ snd_timer_params_set_ticks(params, 1);
+
+ if ((err = snd_timer_params(handle, params)) < 0) {
+ fprintf(stderr, "AlsaTimer::initTimer(): timer params %i (%s)\n", err, snd_strerror(err));
+ return -1;
+ }
+
+ count = snd_timer_poll_descriptors_count(handle);
+ fds = (pollfd *)calloc(count, sizeof(pollfd));
+ if (fds == NULL) {
+ fprintf(stderr, "AlsaTimer::initTimer(): malloc error\n");
+ return -1;
+ }
+ if ((err = snd_timer_poll_descriptors(handle, fds, count)) < 0) {
+ fprintf(stderr, "AlsaTimer::initTimer(): snd_timer_poll_descriptors error: %s\n", snd_strerror(err));
+ return -1;
+ }
+ return fds->fd;
+ }
+
+ unsigned int AlsaTimer::setTimerResolution(unsigned int resolution)
+ {
+ if(TIMER_DEBUG)
+ printf("AlsaTimer::setTimerResolution(%d)\n",resolution);
+ /* Resolution of an AlsaTimer is fixed - it cannot be set */
+ return 0;
+ }
+
+ unsigned int AlsaTimer::setTimerFreq(unsigned int freq)
+ {
+ signed int err;
+ unsigned int setTick, actFreq;
+
+ if(TIMER_DEBUG)
+ printf("AlsaTimer::setTimerFreq(this=%p)\n",this);
+
+ setTick = (1000000000 / snd_timer_info_get_resolution(info)) / freq;
+
+ if (setTick == 0) {
+ // return, print error if freq is below 500 (timing will suffer)
+ if (((1000000000.0 / snd_timer_info_get_resolution(info)) / snd_timer_params_get_ticks(params)) < 500) {
+ fprintf(stderr,"AlsaTimer::setTimerTicks(): requested freq %u Hz too high for timer (max is %g)\n",
+ freq, 1000000000.0 / snd_timer_info_get_resolution(info));
+ fprintf(stderr," freq stays at %ld Hz\n",
+ (long int)((1000000000.0 / snd_timer_info_get_resolution(info)) / snd_timer_params_get_ticks(params)));
+ }
+
+ return 0;
+ }
+ actFreq = (1000000000 / snd_timer_info_get_resolution(info)) / setTick;
+ if (actFreq != freq) {
+ fprintf(stderr,"AlsaTimer::setTimerTicks(): warning: requested %u Hz, actual freq is %u Hz\n",
+ freq, actFreq);
+ }
+ if(TIMER_DEBUG)
+ printf("AlsaTimer::setTimerFreq(): Setting ticks (period) to %d ticks\n", setTick);
+ snd_timer_params_set_auto_start(params, 1);
+ snd_timer_params_set_ticks(params, setTick);
+ if ((err = snd_timer_params(handle, params)) < 0) {
+ fprintf(stderr, "AlsaTimer::setTimerFreq(): timer params %i (%s)\n", err, snd_strerror(err));
+ return 0;
+ }
+
+ return actFreq;
+ }
+
+ unsigned int AlsaTimer::getTimerResolution()
+ {
+ return snd_timer_info_get_resolution(info);
+ }
+
+ unsigned int AlsaTimer::getTimerFreq()
+ {
+ return (1000000000 / snd_timer_info_get_resolution(info)) / snd_timer_params_get_ticks(params);
+ }
+
+ bool AlsaTimer::startTimer()
+ {
+ if(TIMER_DEBUG)
+ printf("AlsaTimer::startTimer(this=%p): handle=%p\n",this,handle);
+ int err;
+ if ((err = snd_timer_start(handle)) < 0) {
+ fprintf(stderr, "AlsaTimer::startTimer(): timer start %i (%s)\n", err, snd_strerror(err));
+ return false;
+ }
+ return true;
+ }
+
+ bool AlsaTimer::stopTimer()
+ {
+ int err;
+ if(TIMER_DEBUG)
+ printf("AlsaTimer::stopTimer(this=%p): handle=%p\n",this,handle);
+ if ((err = snd_timer_stop(handle)) < 0) {
+ fprintf(stderr, "AlsaTimer::stopTimer(): timer stop %i (%s)\n", err, snd_strerror(err));
+ return false;
+ }
+ return true;
+ }
+
+ unsigned int AlsaTimer::getTimerTicks(bool printTicks)
+ {
+ //if(TIMER_DEBUG)
+ // printf("AlsaTimer::getTimerTicks\n");
+ snd_timer_read_t tr;
+ tr.ticks = 0;
+ while (snd_timer_read(handle, &tr, sizeof(tr)) == sizeof(tr)) {
+ if (printTicks) {
+ printf("TIMER: resolution = %uns, ticks = %u\n",
+ tr.resolution, tr.ticks);
+ }
+ }
+ return tr.ticks;
+ }
diff --git a/attic/muse2-oom/muse2/muse/driver/alsatimer.h b/attic/muse2-oom/muse2/muse/driver/alsatimer.h
new file mode 100644
index 00000000..211ba5ec
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/driver/alsatimer.h
@@ -0,0 +1,52 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: alsatimer.h,v 1.1.2.4 2009/03/09 02:05:18 terminator356 Exp $
+//
+// Plenty of code borrowed from timer.c example in
+// alsalib 1.0.7
+//
+// (C) Copyright 2004 Robert Jonsson (rj@spamatica.se)
+//=========================================================
+
+#ifndef __ALSATIMER_H__
+#define __ALSATIMER_H__
+
+#include "alsa/asoundlib.h"
+#include "timerdev.h"
+
+
+//---------------------------------------------------------
+// AlsaTimer
+//---------------------------------------------------------
+
+class AlsaTimer : public Timer{
+
+ snd_timer_t *handle;
+ snd_timer_id_t *id;
+ snd_timer_info_t *info;
+ snd_timer_params_t *params;
+ struct pollfd *fds;
+ char timername[64];
+ signed int count;
+ unsigned int ticks;
+ bool findBest;
+
+ public:
+ AlsaTimer();
+ virtual ~AlsaTimer();
+
+ virtual signed int initTimer();
+ virtual unsigned int setTimerResolution(unsigned int resolution);
+ virtual unsigned int getTimerResolution();
+ virtual unsigned int setTimerFreq(unsigned int freq);
+ virtual unsigned int getTimerFreq();
+
+ virtual bool startTimer();
+ virtual bool stopTimer();
+ virtual unsigned int getTimerTicks(bool printTicks=false);
+
+ void setFindBestTimer(bool b) { findBest = b; }
+};
+
+#endif //__ALSATIMER_H__
diff --git a/attic/muse2-oom/muse2/muse/driver/audiodev.h b/attic/muse2-oom/muse2/muse/driver/audiodev.h
new file mode 100644
index 00000000..af53d7de
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/driver/audiodev.h
@@ -0,0 +1,76 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: audiodev.h,v 1.5.2.2 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __AUDIODEV_H__
+#define __AUDIODEV_H__
+
+#include <list>
+
+class QString;
+
+class MidiPlayEvent;
+class Pos;
+
+//---------------------------------------------------------
+// AudioDevice
+//---------------------------------------------------------
+
+class AudioDevice {
+
+ public:
+ enum { DUMMY_AUDIO=0, JACK_AUDIO=1 }; // p3.3.52
+
+ AudioDevice() {}
+ virtual ~AudioDevice() {}
+
+ virtual int deviceType() = 0; // p3.3.52
+
+ //virtual void start() = 0;
+ virtual void start(int priority) = 0;
+
+ virtual void stop () = 0;
+ virtual int framePos() const = 0;
+ virtual unsigned frameTime() const = 0;
+
+ virtual float* getBuffer(void* port, unsigned long nframes) = 0;
+
+ virtual std::list<QString> outputPorts(bool midi = false, int aliases = -1) = 0;
+ virtual std::list<QString> inputPorts(bool midi = false, int aliases = -1) = 0;
+
+ virtual void registerClient() = 0;
+
+ virtual const char* clientName() = 0;
+
+ //virtual void* registerOutPort(const char* name) = 0;
+ //virtual void* registerInPort(const char* name) = 0;
+ virtual void* registerOutPort(const char* /*name*/, bool /*midi*/) = 0;
+ virtual void* registerInPort(const char* /*name*/, bool /*midi*/) = 0;
+
+ virtual void unregisterPort(void*) = 0;
+ virtual void connect(void*, void*) = 0;
+ virtual void disconnect(void*, void*) = 0;
+ virtual int connections(void* /*clientPort*/) = 0;
+ virtual void setPortName(void* p, const char* n) = 0;
+ virtual void* findPort(const char* name) = 0;
+ virtual QString portName(void* port) = 0;
+ virtual int getState() = 0;
+ virtual unsigned getCurFrame() = 0;
+ virtual bool isRealtime() = 0;
+ virtual int realtimePriority() const = 0; // return zero if not realtime
+ virtual void startTransport() = 0;
+ virtual void stopTransport() = 0;
+ virtual void seekTransport(unsigned frame) = 0;
+ virtual void seekTransport(const Pos &p) = 0;
+ virtual void setFreewheel(bool f) = 0;
+ virtual void graphChanged() {}
+ virtual void registrationChanged() {}
+ virtual int setMaster(bool f) = 0;
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/driver/dummyaudio.cpp b/attic/muse2-oom/muse2/muse/driver/dummyaudio.cpp
new file mode 100644
index 00000000..f4a00b4e
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/driver/dummyaudio.cpp
@@ -0,0 +1,453 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: dummyaudio.cpp,v 1.3.2.16 2009/12/20 05:00:35 terminator356 Exp $
+// (C) Copyright 2002-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <errno.h>
+#include <stdarg.h>
+#include <pthread.h>
+#include <sys/poll.h>
+
+#include "config.h"
+#include "audio.h"
+#include "audiodev.h"
+#include "globals.h"
+#include "song.h"
+#include "driver/alsatimer.h"
+#include "pos.h"
+#include "gconfig.h"
+#include "utils.h"
+
+class MidiPlayEvent;
+
+#define DEBUG_DUMMY 0
+//---------------------------------------------------------
+// DummyAudioDevice
+//---------------------------------------------------------
+
+//static const unsigned dummyFrames = 1024;
+
+enum Cmd {
+trSeek,
+trStart,
+trStop
+};
+
+struct Msg {
+ enum Cmd cmd;
+ int arg;
+};
+
+
+class DummyAudioDevice : public AudioDevice {
+ pthread_t dummyThread;
+ // Changed by Tim. p3.3.15
+ //float buffer[1024];
+ float* buffer;
+ int _realTimePriority;
+
+ public:
+ std::list<Msg> cmdQueue;
+ Audio::State state;
+ int _framePos;
+ int playPos;
+ bool realtimeFlag;
+
+ DummyAudioDevice();
+ virtual ~DummyAudioDevice()
+ {
+ // Added by Tim. p3.3.15
+ free(buffer);
+ }
+
+ virtual inline int deviceType() { return DUMMY_AUDIO; } // p3.3.52
+
+ //virtual void start();
+ virtual void start(int);
+
+ virtual void stop ();
+ virtual int framePos() const {
+ if(DEBUG_DUMMY)
+ printf("DummyAudioDevice::framePos %d\n", _framePos);
+ return _framePos;
+ }
+
+ virtual float* getBuffer(void* /*port*/, unsigned long nframes)
+ {
+ // p3.3.30
+ //if (nframes > dummyFrames) {
+ //printf("error: segment size > 1024\n");
+ if (nframes > segmentSize) {
+ printf("DummyAudioDevice::getBuffer nframes > segment size\n");
+
+ exit(-1);
+ }
+ return buffer;
+ }
+
+ virtual std::list<QString> outputPorts(bool midi = false, int aliases = -1);
+ virtual std::list<QString> inputPorts(bool midi = false, int aliases = -1);
+
+ virtual void registerClient() {}
+
+ virtual const char* clientName() { return "MusE"; }
+
+ //virtual void* registerOutPort(const char*) {
+ virtual void* registerOutPort(const char*, bool) {
+ return (void*)1;
+ }
+ //virtual void* registerInPort(const char*) {
+ virtual void* registerInPort(const char*, bool) {
+ return (void*)2;
+ }
+ virtual void unregisterPort(void*) {}
+ virtual void connect(void*, void*) {}
+ virtual void disconnect(void*, void*) {}
+ virtual int connections(void* /*clientPort*/) { return 0; }
+ virtual void setPortName(void*, const char*) {}
+ virtual void* findPort(const char*) { return 0;}
+ virtual QString portName(void*) {
+ return QString("mops");
+ }
+ virtual int getState() {
+// if(DEBUG_DUMMY)
+// printf("DummyAudioDevice::getState %d\n", state);
+
+ return state; }
+ virtual unsigned getCurFrame() {
+ if(DEBUG_DUMMY)
+ printf("DummyAudioDevice::getCurFrame %d\n", _framePos);
+
+ return _framePos; }
+ virtual unsigned frameTime() const {
+ return lrint(curTime() * sampleRate);
+ }
+ virtual bool isRealtime() { return realtimeFlag; }
+ //virtual int realtimePriority() const { return 40; }
+ virtual int realtimePriority() const { return _realTimePriority; }
+ virtual void startTransport() {
+ if(DEBUG_DUMMY)
+ printf("DummyAudioDevice::startTransport playPos=%d\n", playPos);
+ Msg trcmd;
+ trcmd.cmd = trStart;
+ trcmd.arg = playPos;
+ cmdQueue.push_front(trcmd);
+/* state = Audio::START_PLAY;
+ audio->sync(state, playPos);
+ state = Audio::PLAY;*/
+ }
+ virtual void stopTransport() {
+ if(DEBUG_DUMMY)
+ printf("DummyAudioDevice::stopTransport, playPos=%d\n", playPos);
+ state = Audio::STOP;
+ }
+ virtual int setMaster(bool) { return 1; }
+
+ virtual void seekTransport(const Pos &p)
+ {
+ if(DEBUG_DUMMY)
+ printf("DummyAudioDevice::seekTransport frame=%d topos=%d\n",playPos, p.frame());
+ Msg trcmd;
+ trcmd.cmd = trSeek;
+ trcmd.arg = p.frame();
+ cmdQueue.push_front(trcmd);
+ playPos = p.frame();
+ }
+ virtual void seekTransport(unsigned pos) {
+ if(DEBUG_DUMMY)
+ printf("DummyAudioDevice::seekTransport frame=%d topos=%d\n",playPos,pos);
+ Msg trcmd;
+ trcmd.cmd = trSeek;
+ trcmd.arg = pos;
+ cmdQueue.push_front(trcmd);
+ playPos = pos;
+/*
+ Audio::State tempState = state;
+ state = Audio::START_PLAY;
+ audio->sync(state, playPos);
+ state = tempState;*/
+ }
+ virtual void setFreewheel(bool) {}
+ void setRealTime() { realtimeFlag = true; }
+ };
+
+DummyAudioDevice* dummyAudio = 0;
+
+DummyAudioDevice::DummyAudioDevice()
+ {
+ // Added by Tim. p3.3.15
+ // p3.3.30
+ //posix_memalign((void**)&buffer, 16, sizeof(float) * dummyFrames);
+ posix_memalign((void**)&buffer, 16, sizeof(float) * config.dummyAudioBufSize);
+
+ realtimeFlag = false;
+ state = Audio::STOP;
+ _framePos = 0;
+ playPos = 0;
+ cmdQueue.clear();
+ }
+
+//---------------------------------------------------------
+// exitDummyAudio
+//---------------------------------------------------------
+
+void exitDummyAudio()
+{
+ if(dummyAudio)
+ delete dummyAudio;
+ dummyAudio = NULL;
+ audioDevice = NULL;
+}
+
+//---------------------------------------------------------
+// initDummyAudio
+//---------------------------------------------------------
+
+bool initDummyAudio()
+ {
+ dummyAudio = new DummyAudioDevice();
+ audioDevice = dummyAudio;
+ return false;
+ }
+
+//---------------------------------------------------------
+// outputPorts
+//---------------------------------------------------------
+
+std::list<QString> DummyAudioDevice::outputPorts(bool midi, int /*aliases*/)
+ {
+ std::list<QString> clientList;
+ if(!midi)
+ {
+ clientList.push_back(QString("output1"));
+ clientList.push_back(QString("output2"));
+ }
+ return clientList;
+ }
+
+//---------------------------------------------------------
+// inputPorts
+//---------------------------------------------------------
+
+std::list<QString> DummyAudioDevice::inputPorts(bool midi, int /*aliases*/)
+ {
+ std::list<QString> clientList;
+ if(!midi)
+ {
+ clientList.push_back(QString("input1"));
+ clientList.push_back(QString("input2"));
+ }
+ return clientList;
+ }
+
+//---------------------------------------------------------
+// dummyLoop
+//---------------------------------------------------------
+
+static void* dummyLoop(void* ptr)
+ {
+ //unsigned int tickRate = 25;
+
+ // p3.3.30
+ //sampleRate = 25600;
+ sampleRate = config.dummyAudioSampleRate;
+ //segmentSize = dummyFrames;
+ segmentSize = config.dummyAudioBufSize;
+ //unsigned int tickRate = sampleRate / dummyFrames;
+ unsigned int tickRate = sampleRate / segmentSize;
+
+ AlsaTimer timer;
+ fprintf(stderr, "Get alsa timer for dummy driver:\n");
+ timer.setFindBestTimer(false);
+ int fd = timer.initTimer();
+ if (fd==-1) {
+ // QMessageBox::critical( 0, /*tr*/(QString("Failed to start timer for dummy audio driver!")),
+ // /*tr*/(QString("No functional timer was available.\n"
+ // "Alsa timer not available, check if module snd_timer is available and /dev/snd/timer is available")));
+ fprintf(stderr, "Failed to start timer for dummy audio driver! No functional timer was available.\n"
+ "Alsa timer not available, check if module snd_timer is available and /dev/snd/timer is available\n");
+ pthread_exit(0);
+ }
+
+ /* Depending on nature of the timer, the requested tickRate might not
+ * be available. The return value is the nearest available frequency,
+ * so use this to reset our dummpy sampleRate to keep everything
+ * consistent.
+ */
+ tickRate = timer.setTimerFreq( /*250*/ tickRate );
+
+ // p3.3.31
+ // If it didn't work, get the actual rate.
+ if(tickRate == 0)
+ tickRate = timer.getTimerFreq();
+
+ sampleRate = tickRate * segmentSize;
+ timer.startTimer();
+
+ DummyAudioDevice *drvPtr = (DummyAudioDevice *)ptr;
+
+ pollfd myPollFd;
+
+ myPollFd.fd = fd;
+ myPollFd.events = POLLIN;
+
+ /*
+ doSetuid();
+ struct sched_param rt_param;
+ int rv;
+ memset(&rt_param, 0, sizeof(sched_param));
+ int type;
+ rv = pthread_getschedparam(pthread_self(), &type, &rt_param);
+ if (rv != 0)
+ perror("get scheduler parameter");
+ if (type != SCHED_FIFO) {
+ fprintf(stderr, "Driver thread not running SCHED_FIFO, trying to set...\n");
+
+ memset(&rt_param, 0, sizeof(sched_param));
+ //rt_param.sched_priority = 1;
+ rt_param.sched_priority = realtimePriority();
+ rv = pthread_setschedparam(pthread_self(), SCHED_FIFO, &rt_param);
+ if (rv != 0)
+ perror("set realtime scheduler");
+ memset(&rt_param, 0, sizeof(sched_param));
+ rv = pthread_getschedparam(pthread_self(), &type, &rt_param);
+ if (rv != 0)
+ perror("get scheduler parameter");
+ if (type == SCHED_FIFO) {
+ drvPtr->setRealTime();
+ fprintf(stderr, "Thread succesfully set to SCHED_FIFO\n");
+ }
+ else {
+ fprintf(stderr, "Unable to set thread to SCHED_FIFO\n");
+ }
+ }
+ undoSetuid();
+ */
+
+#ifndef __APPLE__
+ doSetuid();
+ //if (realTimePriority) {
+ if (realTimeScheduling) {
+ //
+ // check if we really got realtime priviledges
+ //
+ int policy;
+ if ((policy = sched_getscheduler (0)) < 0) {
+ printf("cannot get current client scheduler for audio dummy thread: %s!\n", strerror(errno));
+ }
+ else
+ {
+ if (policy != SCHED_FIFO)
+ printf("audio dummy thread _NOT_ running SCHED_FIFO\n");
+ else if (debugMsg) {
+ struct sched_param rt_param;
+ memset(&rt_param, 0, sizeof(sched_param));
+ int type;
+ int rv = pthread_getschedparam(pthread_self(), &type, &rt_param);
+ if (rv == -1)
+ perror("get scheduler parameter");
+ printf("audio dummy thread running SCHED_FIFO priority %d\n",
+ rt_param.sched_priority);
+ }
+ }
+ }
+ undoSetuid();
+#endif
+
+ /* unsigned long tick = 0;*/ // prevent compiler warning: unused variable
+ for (;;) {
+ int _pollWait = 10; // ms
+ unsigned long count = 0;
+ while (count < 1 /*250/tickRate*/) // will loop until the next tick occurs
+ {
+ /*int n = */ poll(&myPollFd, 1 /* npfd */, _pollWait);
+ count += timer.getTimerTicks();
+ while (drvPtr->cmdQueue.size())
+ {
+ Msg &msg = drvPtr->cmdQueue.back();
+ drvPtr->cmdQueue.pop_back();
+ switch(msg.cmd) {
+ case trSeek:
+ {
+ //printf("trSeek\n");
+ drvPtr->playPos = msg.arg;
+ Audio::State tempState = drvPtr->state;
+ drvPtr->state = Audio::START_PLAY;
+ audio->sync(drvPtr->state, msg.arg);
+ drvPtr->state = tempState;
+ }
+ break;
+ case trStart:
+ {
+ //printf("trStart\n");
+ drvPtr->state = Audio::START_PLAY;
+ audio->sync(drvPtr->state, msg.arg);
+ drvPtr->state = Audio::PLAY;
+ }
+ break;
+ case trStop:
+ break;
+ default:
+ printf("dummyLoop: Unknown command!\n");
+ }
+ }
+ }
+ audio->process(segmentSize);
+ int increment = segmentSize; // 1 //tickRate / sampleRate * segmentSize;
+ drvPtr->_framePos+=increment;
+ if (drvPtr->state == Audio::PLAY)
+ {
+ drvPtr->playPos+=increment;
+ }
+ }
+ timer.stopTimer();
+ pthread_exit(0);
+ }
+
+//void DummyAudioDevice::start()
+void DummyAudioDevice::start(int priority)
+ {
+ //realTimePriority = priority;
+ _realTimePriority = priority;
+ pthread_attr_t* attributes = 0;
+
+ //if (priority) {
+ if (realTimeScheduling && priority > 0) {
+ attributes = (pthread_attr_t*) malloc(sizeof(pthread_attr_t));
+ pthread_attr_init(attributes);
+
+ if (pthread_attr_setschedpolicy(attributes, SCHED_FIFO)) {
+ printf("cannot set FIFO scheduling class for RT thread\n");
+ }
+ if (pthread_attr_setscope (attributes, PTHREAD_SCOPE_SYSTEM)) {
+ printf("Cannot set scheduling scope for RT thread\n");
+ }
+ struct sched_param rt_param;
+ memset(&rt_param, 0, sizeof(rt_param));
+ rt_param.sched_priority = priority;
+ if (pthread_attr_setschedparam (attributes, &rt_param)) {
+ printf("Cannot set scheduling priority %d for RT thread (%s)\n",
+ priority, strerror(errno));
+ }
+ }
+
+ //pthread_attr_t* attributes = (pthread_attr_t*) malloc(sizeof(pthread_attr_t));
+ //pthread_attr_init(attributes);
+ if (pthread_create(&dummyThread, attributes, ::dummyLoop, this))
+ perror("creating thread failed:");
+ if (priority)
+ pthread_attr_destroy(attributes);
+ }
+
+void DummyAudioDevice::stop ()
+ {
+ pthread_cancel(dummyThread);
+ pthread_join(dummyThread, 0);
+ dummyThread = 0;
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/driver/jack.cpp b/attic/muse2-oom/muse2/muse/driver/jack.cpp
new file mode 100644
index 00000000..f70cf3d3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/driver/jack.cpp
@@ -0,0 +1,2217 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: jack.cpp,v 1.30.2.17 2009/12/20 05:00:35 terminator356 Exp $
+// (C) Copyright 2002 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "config.h"
+#include <string>
+#include <set>
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <stdarg.h>
+//#include <time.h>
+#include <unistd.h>
+#include <jack/midiport.h>
+#include <string.h>
+
+#include "audio.h"
+#include "globals.h"
+#include "song.h"
+#include "jackaudio.h"
+#include "track.h"
+#include "pos.h"
+#include "tempo.h"
+#include "sync.h"
+#include "utils.h"
+
+#include "midi.h"
+#include "mididev.h"
+#include "mpevent.h"
+
+#include "jackmidi.h"
+
+
+#define JACK_DEBUG 0
+
+//#include "errorhandler.h"
+
+#ifndef RTCAP
+extern void doSetuid();
+extern void undoSetuid();
+#endif
+
+#ifdef VST_SUPPORT
+#include <fst.h>
+#endif
+
+//extern int jackmidi_pi[2];
+//extern int jackmidi_po[2];
+
+//jack_port_t *midi_port_in[JACK_MIDI_CHANNELS];
+//jack_port_t *midi_port_out[JACK_MIDI_CHANNELS];
+
+//muse_jack_midi_buffer jack_midi_out_data[JACK_MIDI_CHANNELS];
+//muse_jack_midi_buffer jack_midi_in_data[JACK_MIDI_CHANNELS];
+
+JackAudioDevice* jackAudio;
+
+//---------------------------------------------------------
+// checkJackClient - make sure client is valid
+//---------------------------------------------------------
+inline bool checkJackClient(jack_client_t* _client)
+ {
+ if (_client == NULL) {
+ printf("Panic! no _client!\n");
+ return false;
+ }
+ return true;
+ }
+//---------------------------------------------------------
+// checkAudioDevice - make sure audioDevice exists
+//---------------------------------------------------------
+bool checkAudioDevice()
+ {
+ if (audioDevice == NULL) {
+ printf("Muse:checkAudioDevice: no audioDevice\n");
+ return false;
+ }
+ return true;
+ }
+
+
+//---------------------------------------------------------
+// jack_thread_init
+//---------------------------------------------------------
+
+static void jack_thread_init (void* ) // data
+ {
+ doSetuid();
+ /*
+ if (jackAudio->isRealtime()) {
+ struct sched_param rt_param;
+ int rv;
+ memset(&rt_param, 0, sizeof(sched_param));
+ int type;
+ rv = pthread_getschedparam(pthread_self(), &type, &rt_param);
+ if (rv != 0)
+ perror("get scheduler parameter");
+ if (type != SCHED_FIFO) {
+ fprintf(stderr, "JACK thread not running SCHED_FIFO, try to set...\n");
+
+ memset(&rt_param, 0, sizeof(sched_param));
+ rt_param.sched_priority = 1;
+ rv = pthread_setschedparam(pthread_self(), SCHED_FIFO, &rt_param);
+ if (rv != 0)
+ perror("set realtime scheduler");
+ memset(&rt_param, 0, sizeof(sched_param));
+ rv = pthread_getschedparam(pthread_self(), &type, &rt_param);
+ if (rv != 0)
+ perror("get scheduler parameter");
+ if (type != SCHED_FIFO)
+ fprintf(stderr, "JACK still not running FIFO !?!\n"
+ "======reliable RT operation not possible!!======\n");
+ else
+ fprintf(stderr, "JACK thread succesfully set to SCHED_FIFO\n");
+ }
+ }
+ */
+#ifdef VST_SUPPORT
+ if (loadVST)
+ fst_adopt_thread();
+#endif
+ undoSetuid();
+ }
+
+/*
+//---------------------------------------------------------
+// processAudio + Midi
+// JACK callback
+//---------------------------------------------------------
+void
+print_triplet(unsigned char *data)
+{
+ int a,b,c;
+ a = b = c = 0;
+ memcpy(&a, data, 1);
+ memcpy(&b, data+1, 1);
+ memcpy(&c, data+2, 1);
+ fprintf(stderr, "%x,%x,%x", a, b, c);
+}
+*/
+
+/*
+void handle_jack_midi_in_events(jack_nframes_t frames)
+{
+ char buf = 0;
+ int i,j;
+ jack_midi_event_t midi_event;
+ unsigned char t,n,v;
+
+ for(j = 0; j < JACK_MIDI_CHANNELS; j++){
+ void *midi_buffer_in = jack_port_get_buffer(midi_port_in[j], frames);
+ int event_count = jack_midi_get_event_count(midi_buffer_in);
+
+ for(i = 0; i < event_count; i++){
+ jack_midi_event_get(&midi_event, midi_buffer_in, i);
+ t = midi_event.buffer[0];
+ n = midi_event.buffer[1];
+ v = midi_event.buffer[2];
+ if(((*(midi_event.buffer) & 0xf0)) == 0x90){
+ fprintf(stderr, "jack-midi-in-event: ON_ time=%d %u ", midi_event.time,
+ midi_event.size);
+ print_triplet(midi_event.buffer);
+ fprintf(stderr, "\n");
+ }else if(((*(midi_event.buffer)) & 0xf0) == 0x80){
+ fprintf(stderr, "jack-midi-in-event: OFF time=%d %u ", midi_event.time,
+ midi_event.size);
+ print_triplet(midi_event.buffer);
+ fprintf(stderr, "\n");
+ }else{
+ fprintf(stderr, "jack-midi-in-event: ??? time=%d %u ", midi_event.time,
+ midi_event.size);
+ print_triplet(midi_event.buffer);
+ fprintf(stderr, "\n");
+ }
+ jack_midi_in_data[j].buffer[0] = t;
+ jack_midi_in_data[j].buffer[1] = n;
+ jack_midi_in_data[j].buffer[2] = v;
+ jack_midi_in_data[j].buffer[3] = 1;
+ fprintf(stderr, "handle_jack_midi_in_events() w\n");
+ write(jackmidi_pi[1], &buf, 1);
+ fprintf(stderr, "handle_jack_midi_in_events() wd\n");
+ }
+ }
+}
+
+void handle_jack_midi_out_events(jack_nframes_t frames)
+{
+ unsigned char *data;
+ void *port_buf;
+ int i,j,n,x;
+
+ //for(i = 0; i < JACK_MIDI_CHANNELS; i++){
+ for(i = 0; i < JACK_MIDI_CHANNELS; ++i){
+ // jack-midi-clear any old events
+ while(jack_midi_out_data[i].buffer[jack_midi_out_data[i].take*4+3] == 2){
+ port_buf = jack_port_get_buffer(midi_port_out[i], frames);
+ jack_midi_clear_buffer(port_buf);
+ jack_midi_out_data[i].buffer[jack_midi_out_data[i].take*4+3] = 0;
+ // point the take to the next slot
+ jack_midi_out_data[i].take++;
+ if(jack_midi_out_data[i].take >= JACK_MIDI_BUFFER_SIZE){
+ jack_midi_out_data[i].take = 0;
+ }
+ }
+ // check if any incoming midi-events from muse
+ if(jack_midi_out_data[i].give != jack_midi_out_data[i].take){
+
+ if(jack_midi_out_data[i].give > jack_midi_out_data[i].take){
+ n = jack_midi_out_data[i].give - jack_midi_out_data[i].take;
+ }else{
+ n = jack_midi_out_data[i].give +
+ (JACK_MIDI_BUFFER_SIZE - jack_midi_out_data[i].take);
+ }
+ port_buf = jack_port_get_buffer(midi_port_out[i], frames);
+ jack_midi_clear_buffer(port_buf);
+ // FIX: midi events has different sizes, compare note-on to
+ // program-change. We should first walk over the events
+ // counting the size.
+ //data = jack_midi_event_reserve(port_buf, 0, n*3);
+ //x = jack_midi_out_data[i].take;
+ //for(j = 0; j < n; j++){
+ // data[j*3+0] = jack_midi_out_data[i].buffer[x*4+0];
+ // data[j*3+1] = jack_midi_out_data[i].buffer[x*4+1];
+ // data[j*3+2] = jack_midi_out_data[i].buffer[x*4+2];
+ // after having copied the buffer over to the jack-buffer,
+ // mark the muses midi-out buffer as 'need-cleaning'
+ // jack_midi_out_data[i].buffer[x*4+3] = 2;
+ // x++;
+ // if(x >= JACK_MIDI_BUFFER_SIZE){
+ // x = 0;
+ // }
+ //}
+
+ x = jack_midi_out_data[i].take;
+ for(j = 0; j < n; ++j)
+ {
+ data = jack_midi_event_reserve(port_buf, 0, 3);
+ if(data == 0)
+ {
+ fprintf(stderr, "handle_jack_midi_out_events: buffer overflow, event lost\n");
+ // Can do no more processing. Just return.
+ return;
+ }
+ data[0] = jack_midi_out_data[i].buffer[x*4+0];
+ data[1] = jack_midi_out_data[i].buffer[x*4+1];
+ data[2] = jack_midi_out_data[i].buffer[x*4+2];
+ // after having copied the buffer over to the jack-buffer,
+ // mark the muses midi-out buffer as 'need-cleaning'
+ jack_midi_out_data[i].buffer[x*4+3] = 2;
+ x++;
+ if(x >= JACK_MIDI_BUFFER_SIZE){
+ x = 0;
+ }
+ }
+
+ }
+ }
+}
+*/
+
+//static int processAudio(jack_nframes_t frames, void*)
+int JackAudioDevice::processAudio(jack_nframes_t frames, void*)
+{
+ jackAudio->_frameCounter += frames;
+
+/// handle_jack_midi_in_events(frames);
+/// handle_jack_midi_out_events(frames);
+
+// if (JACK_DEBUG)
+// printf("processAudio - >>>>\n");
+ segmentSize = frames;
+ if (audio->isRunning())
+ audio->process((unsigned long)frames);
+ else {
+ if (debugMsg)
+ puts("jack calling when audio is disconnected!\n");
+ }
+// if (JACK_DEBUG)
+// printf("processAudio - <<<<\n");
+ return 0;
+}
+
+//---------------------------------------------------------
+// processSync
+// return TRUE (non-zero) when ready to roll.
+//---------------------------------------------------------
+
+static int processSync(jack_transport_state_t state, jack_position_t* pos, void*)
+ {
+ if (JACK_DEBUG)
+ printf("processSync()\n");
+
+ if(!useJackTransport.value())
+ return 1;
+
+ int audioState = Audio::STOP;
+ switch (state) {
+ case JackTransportStopped:
+ audioState = Audio::STOP;
+ break;
+ case JackTransportLooping:
+ case JackTransportRolling:
+ audioState = Audio::PLAY;
+ break;
+ case JackTransportStarting:
+ //printf("processSync JackTransportStarting\n");
+
+ audioState = Audio::START_PLAY;
+ break;
+ //case JackTransportNetStarting:
+ // FIXME: Quick and dirty hack to support both Jack-1 and Jack-2
+ // Really need a config check of version...
+ case 4:
+ //printf("processSync JackTransportNetStarting\n");
+
+ audioState = Audio::START_PLAY;
+ break;
+ }
+
+ unsigned frame = pos->frame;
+ //printf("processSync valid:%d frame:%d\n", pos->valid, frame);
+
+ // p3.3.23
+ //printf("Jack processSync() before audio->sync frame:%d\n", frame);
+ //return audio->sync(audioState, frame);
+ int rv = audio->sync(audioState, frame);
+ //printf("Jack processSync() after audio->sync frame:%d\n", frame);
+ return rv;
+ }
+
+//---------------------------------------------------------
+// timebase_callback
+//---------------------------------------------------------
+
+static void timebase_callback(jack_transport_state_t /* state */,
+ jack_nframes_t /* nframes */,
+ jack_position_t* pos,
+ int /* new_pos */,
+ void*)
+ {
+ //printf("Jack timebase_callback pos->frame:%u audio->tickPos:%d song->cpos:%d\n", pos->frame, audio->tickPos(), song->cpos());
+
+ // p3.3.27
+ //Pos p(pos->frame, false);
+ Pos p(extSyncFlag.value() ? audio->tickPos() : pos->frame, extSyncFlag.value() ? true : false);
+ // Can't use song pos - it is only updated every (slow) GUI heartbeat !
+ //Pos p(extSyncFlag.value() ? song->cpos() : pos->frame, extSyncFlag.value() ? true : false);
+
+ pos->valid = JackPositionBBT;
+ p.mbt(&pos->bar, &pos->beat, &pos->tick);
+ pos->bar++;
+ pos->beat++;
+ pos->bar_start_tick = Pos(pos->bar, 0, 0).tick();
+
+ //
+ // dummy:
+ //
+
+ // p3.3.26
+ //pos->beats_per_bar = 4;
+ //pos->beat_type = 4;
+ //pos->ticks_per_beat = 384;
+ //
+ /* // From example client transport.c :
+ float time_beats_per_bar = 4.0;
+ float time_beat_type = 0.25; // Huh? Inverted? From docs: "Time signature 'denominator'"
+ double time_ticks_per_beat = 1920.0; // Huh? Ticks per beat should be 24 etc. not 384 or 1920 etc. Otherwise it would be called 'frames_per_beat'.
+ double time_beats_per_minute = 120.0;
+ */
+ //
+ int z, n;
+ AL::sigmap.timesig(p.tick(), z, n);
+ pos->beats_per_bar = z;
+ pos->beat_type = n;
+ //pos->ticks_per_beat = config.division;
+ pos->ticks_per_beat = 24;
+
+ int tempo = tempomap.tempo(p.tick());
+ pos->beats_per_minute = (60000000.0 / tempo) * tempomap.globalTempo()/100.0;
+ }
+
+//---------------------------------------------------------
+// processShutdown
+//---------------------------------------------------------
+
+static void processShutdown(void*)
+ {
+ if (JACK_DEBUG)
+ printf("processShutdown()\n");
+ //printf("processShutdown\n");
+ jackAudio->nullify_client();
+ audio->shutdown();
+
+ int c=0;
+ while(midiSeqRunning == true) {
+ if(c++ >10) {
+ fprintf(stderr, "sequencer still running, something is very wrong.\n");
+ break;
+ }
+ sleep(1);
+ }
+ delete jackAudio;
+ jackAudio=0;
+ audioDevice=0;
+ }
+
+//---------------------------------------------------------
+// jackError
+//---------------------------------------------------------
+
+static void jackError(const char *s)
+ {
+ //error->logError( "JACK ERROR: %s\n", s);
+ fprintf(stderr,"JACK ERROR: %s\n", s);
+ }
+
+//---------------------------------------------------------
+// noJackError
+//---------------------------------------------------------
+
+static void noJackError(const char* /* s */)
+ {
+ }
+
+//---------------------------------------------------------
+// JackAudioDevice
+//---------------------------------------------------------
+
+JackAudioDevice::JackAudioDevice(jack_client_t* cl, char* name)
+ : AudioDevice()
+ {
+ _frameCounter = 0;
+ //JackAudioDevice::jackStarted=false;
+ strcpy(jackRegisteredName, name);
+ _client = cl;
+ dummyState = Audio::STOP;
+ dummyPos = 0;
+ }
+
+//---------------------------------------------------------
+// ~JackAudioDevice
+//---------------------------------------------------------
+
+JackAudioDevice::~JackAudioDevice()
+ {
+ if (JACK_DEBUG)
+ printf("~JackAudioDevice()\n");
+ if (_client) {
+
+ /*
+ // p3.3.35
+ for(int i = 0; i < JACK_MIDI_CHANNELS; i++)
+ {
+ if(midi_port_in[i])
+ jack_port_unregister(_client, midi_port_in[i]);
+ if(midi_port_out[i])
+ jack_port_unregister(_client, midi_port_out[i]);
+ }
+ */
+
+ if (jack_client_close(_client)) {
+ //error->logError("jack_client_close() failed: %s\n", strerror(errno));
+ fprintf(stderr,"jack_client_close() failed: %s\n", strerror(errno));
+ }
+ }
+ if (JACK_DEBUG)
+ printf("~JackAudioDevice() after jack_client_close()\n");
+ }
+
+//---------------------------------------------------------
+// realtimePriority
+// return zero if not running realtime
+// can only be called if JACK client thread is already
+// running
+//---------------------------------------------------------
+
+int JackAudioDevice::realtimePriority() const
+ {
+ pthread_t t = jack_client_thread_id(_client);
+ int policy;
+ struct sched_param param;
+ memset(&param, 0, sizeof(param));
+ int rv = pthread_getschedparam(t, &policy, &param);
+ if (rv) {
+ perror("MusE: JackAudioDevice::realtimePriority: Error: Get jack schedule parameter");
+ return 0;
+ }
+ if (policy != SCHED_FIFO) {
+ printf("MusE: JackAudioDevice::realtimePriority: JACK is not running realtime\n");
+ return 0;
+ }
+ return param.sched_priority;
+ }
+
+/*
+//---------------------------------------------------------
+// getJackName()
+//---------------------------------------------------------
+
+char* JackAudioDevice::getJackName()
+ {
+ return jackRegisteredName;
+ }
+*/
+
+/*
+//---------------------------------------------------------
+// clientName()
+//---------------------------------------------------------
+
+const char* JackAudioDevice::clientName()
+{
+ //if(_client)
+ // return jack_get_client_name(_client);
+ //else
+ // return "MusE";
+ return jackRegisteredName;
+}
+*/
+
+//---------------------------------------------------------
+// initJackAudio
+// return true if JACK not found
+//---------------------------------------------------------
+
+bool initJackAudio()
+ {
+ /*
+ // p3.3.35
+ for(int i = 0; i < JACK_MIDI_CHANNELS; i++)
+ {
+ midi_port_in[i] = 0;
+ midi_port_out[i] = 0;
+ }
+ */
+
+ if (JACK_DEBUG)
+ printf("initJackAudio()\n");
+ if (debugMsg) {
+ fprintf(stderr,"initJackAudio()\n");
+ jack_set_error_function(jackError);
+ }
+ else
+ jack_set_error_function(noJackError);
+ doSetuid();
+
+ //jack_client_t* client = 0;
+ //int i = 0;
+ //char jackIdString[8];
+ //for (i = 0; i < 5; ++i) {
+ // sprintf(jackIdString, "MusE-%d", i+1);
+ //client = jack_client_new(jackIdString);
+ // client = jack_client_open(jackIdString, JackNoStartServer, 0);
+ // if (client)
+ // break;
+ // }
+ //if (i == 5)
+ // return true;
+ jack_status_t status;
+ jack_client_t* client = jack_client_open("MusE", JackNoStartServer, &status);
+ if (!client) {
+ if (status & JackServerStarted)
+ printf("jack server started...\n");
+ if (status & JackServerFailed)
+ printf("cannot connect to jack server\n");
+ if (status & JackServerError)
+ printf("communication with jack server failed\n");
+ if (status & JackShmFailure)
+ printf("jack cannot access shared memory\n");
+ if (status & JackVersionError)
+ printf("jack server has wrong version\n");
+ printf("cannot create jack client\n");
+ undoSetuid(); // p3.3.51
+ return true;
+ }
+
+ if (debugMsg)
+ fprintf(stderr, "initJackAudio(): client %s opened.\n", jack_get_client_name(client));
+ if (client) {
+ jack_set_error_function(jackError);
+ //jackAudio = new JackAudioDevice(client, jackIdString);
+ jackAudio = new JackAudioDevice(client, jack_get_client_name(client));
+ if (debugMsg)
+ fprintf(stderr, "initJackAudio(): registering client...\n");
+ jackAudio->registerClient();
+ sampleRate = jack_get_sample_rate(client);
+ segmentSize = jack_get_buffer_size(client);
+ jack_set_thread_init_callback(client, (JackThreadInitCallback) jack_thread_init, 0);
+ //jack_set_timebase_callback(client, 0, (JackTimebaseCallback) timebase_callback, 0);
+ }
+ undoSetuid();
+
+ /*
+ // setup midi input/output
+ //memset(jack_midi_out_data, 0, JACK_MIDI_CHANNELS * sizeof(muse_jack_midi_buffer));
+ //memset(jack_midi_in_data, 0, JACK_MIDI_CHANNELS * sizeof(muse_jack_midi_buffer));
+ if(client){
+ for(i = 0; i < JACK_MIDI_CHANNELS; i++)
+ {
+ char buf[80];
+ snprintf(buf, 80, "muse-jack-midi-in-%d", i+1);
+ midi_port_in[i] = jack_port_register(client, buf,
+ JACK_DEFAULT_MIDI_TYPE,
+ JackPortIsInput, 0);
+ if(midi_port_in[i] == NULL){
+ fprintf(stderr, "failed to register jack-midi-in\n");
+ exit(-1);
+ }
+ snprintf(buf, 80, "muse-jack-midi-out-%d", i+1);
+ midi_port_out[i] = jack_port_register(client, buf,
+ JACK_DEFAULT_MIDI_TYPE,
+ JackPortIsOutput, 0);
+ if(midi_port_out == NULL)
+ {
+ fprintf(stderr, "failed to register jack-midi-out\n");
+ exit(-1);
+ }
+ }
+ }
+ else
+ {
+ fprintf(stderr, "WARNING NO muse-jack midi connection\n");
+ }
+ */
+
+ if (client) {
+ audioDevice = jackAudio;
+ jackAudio->scanMidiPorts();
+ return false;
+ }
+ return true;
+ }
+
+static int bufsize_callback(jack_nframes_t n, void*)
+ {
+ printf("JACK: buffersize changed %d\n", n);
+ return 0;
+ }
+
+//---------------------------------------------------------
+// freewheel_callback
+//---------------------------------------------------------
+
+static void freewheel_callback(int starting, void*)
+ {
+ if (debugMsg || JACK_DEBUG)
+ printf("JACK: freewheel_callback: starting%d\n", starting);
+ audio->setFreewheel(starting);
+ }
+
+static int srate_callback(jack_nframes_t n, void*)
+ {
+ if (debugMsg || JACK_DEBUG)
+ printf("JACK: sample rate changed: %d\n", n);
+ return 0;
+ }
+
+//---------------------------------------------------------
+// registration_callback
+//---------------------------------------------------------
+
+static void registration_callback(jack_port_id_t, int, void*)
+{
+ if(debugMsg || JACK_DEBUG)
+ printf("JACK: registration changed\n");
+
+ audio->sendMsgToGui('R');
+}
+
+//---------------------------------------------------------
+// JackAudioDevice::registrationChanged
+// this is called from song in gui context triggered
+// by registration_callback()
+//---------------------------------------------------------
+
+void JackAudioDevice::registrationChanged()
+{
+ if(JACK_DEBUG)
+ printf("JackAudioDevice::registrationChanged()\n");
+
+ // Rescan.
+ scanMidiPorts();
+ // Connect the Jack midi client ports to the device ports.
+ //connectJackMidiPorts();
+}
+
+//---------------------------------------------------------
+// JackAudioDevice::connectJackMidiPorts
+//---------------------------------------------------------
+
+void JackAudioDevice::connectJackMidiPorts()
+{
+ if(JACK_DEBUG)
+ printf("JackAudioDevice::connectJackMidiPorts()\n");
+
+ for (iMidiDevice i = midiDevices.begin(); i != midiDevices.end(); ++i)
+ {
+ //MidiJackDevice* mjd = dynamic_cast<MidiJackDevice*>(*i);
+ //if(!mjd)
+ MidiDevice* md = *i;
+ if(md->deviceType() != MidiDevice::JACK_MIDI)
+ continue;
+
+ //void* port = md->clientPort();
+ if(md->rwFlags() & 1)
+ {
+ void* port = md->outClientPort(); // p3.3.55
+ if(port) //
+ {
+ RouteList* rl = md->outRoutes();
+ for (iRoute r = rl->begin(); r != rl->end(); ++r)
+ connect(port, r->jackPort);
+ }
+ }
+
+ // else // p3.3.55 Removed
+
+ if(md->rwFlags() & 2)
+ {
+ void* port = md->inClientPort(); // p3.3.55
+ if(port) //
+ {
+ RouteList* rl = md->inRoutes();
+ for (iRoute r = rl->begin(); r != rl->end(); ++r)
+ connect(r->jackPort, port);
+ }
+ }
+ }
+
+
+ /*
+ const char* type = JACK_DEFAULT_MIDI_TYPE;
+ const char** ports = jack_get_ports(_client, 0, type, 0);
+ for (const char** p = ports; p && *p; ++p)
+ {
+ jack_port_t* port = jack_port_by_name(_client, *p);
+ if(!port)
+ continue;
+ // Ignore our own client ports.
+ if(jack_port_is_mine(_client, port))
+ {
+ if(debugMsg)
+ printf(" ignoring own port: %s\n", *p);
+ continue;
+ }
+ int nsz = jack_port_name_size();
+ char buffer[nsz];
+ strncpy(buffer, *p, nsz);
+ // Ignore the MusE Jack port.
+ //if(strncmp(buffer, "MusE", 4) == 0)
+ // continue;
+
+ if(debugMsg)
+ printf(" found port: %s ", buffer);
+
+ // If there are aliases for this port, use the first one - much better for identifying.
+ //char a1[nsz];
+ char a2[nsz];
+ char* aliases[2];
+ //aliases[0] = a1;
+ aliases[0] = buffer;
+ aliases[1] = a2;
+ // To disable aliases, just rem this line.
+ jack_port_get_aliases(port, aliases);
+ //int na = jack_port_get_aliases(port, aliases);
+ //char* namep = (na >= 1) ? aliases[0] : buffer;
+ char* namep = aliases[0];
+
+ if(debugMsg)
+ printf("alias: %s\n", aliases[0]);
+
+ //int flags = 0;
+ int pf = jack_port_flags(port);
+ // If Jack port can send data to us...
+ //if(pf & JackPortIsOutput)
+ // Mark as input capable.
+ // flags |= 2;
+ // If Jack port can receive data from us...
+ //if(pf & JackPortIsInput)
+ // Mark as output capable.
+ // flags |= 1;
+
+ //JackPort jp(0, QString(buffer), flags);
+ //portList.append(jp);
+
+ QString name(namep);
+
+ if(JACK_DEBUG)
+ printf("JackAudioDevice::graphChanged %s\n", name.toLatin1());
+
+ for(iMidiDevice imd = midiDevices.begin(); imd != midiDevices.end(); ++imd)
+ {
+ // Is it a Jack midi device?
+ MidiJackDevice* mjd = dynamic_cast<MidiJackDevice*>(*imd);
+ if(!mjd)
+ continue;
+
+ //if(dev->name() != name)
+ // continue;
+
+ // Is this port the one created for the Jack midi device?
+ if(!mjd->clientJackPort() || (mjd->clientJackPort() != port))
+ continue;
+
+ jack_port_t* devport = jack_port_by_name(_client, mjd->name().toLatin1());
+ if(!devport)
+ continue;
+
+ int ofl = mjd->openFlags();
+
+ if(JACK_DEBUG)
+ printf("JackAudioDevice::graphChanged found MidiJackDevice:%s\n", mjd->name().toLatin1());
+
+ // Note docs say it can't be both input and output. src, dest
+ // If Jack port can receive data from us and we actually want to...
+ if((pf & JackPortIsOutput) && (ofl & 1))
+ {
+ if(JACK_DEBUG)
+ printf("JackAudioDevice::graphChanged connecting MusE output\n");
+ audioDevice->connect(port, devport);
+ }
+ else
+ // If Jack port can send data to us and we actually want it...
+ if((pf & JackPortIsInput) && (ofl & 2))
+ {
+ if(JACK_DEBUG)
+ printf("JackAudioDevice::graphChanged connecting MusE input\n");
+ audioDevice->connect(devport, port);
+ }
+
+ break;
+ }
+ }
+
+ if(ports)
+ free(ports);
+
+ */
+}
+//---------------------------------------------------------
+// client_registration_callback
+//---------------------------------------------------------
+
+static void client_registration_callback(const char *name, int isRegister, void*)
+ {
+ if (debugMsg || JACK_DEBUG)
+ printf("JACK: client registration changed:%s register:%d\n", name, isRegister);
+ }
+
+//---------------------------------------------------------
+// port_connect_callback
+//---------------------------------------------------------
+
+static void port_connect_callback(jack_port_id_t a, jack_port_id_t b, int isConnect, void*)
+ {
+ if (debugMsg || JACK_DEBUG)
+ {
+ //jack_port_t* ap = jack_port_by_id(_client, a);
+ //jack_port_t* bp = jack_port_by_id(_client, b);
+ //printf("JACK: port connections changed: A:%d:%s B:%d:%s isConnect:%d\n", a, jack_port_name(ap), b, jack_port_name(bp), isConnect);
+ printf("JACK: port connections changed: A:%d B:%d isConnect:%d\n", a, b, isConnect);
+ }
+ }
+
+//---------------------------------------------------------
+// graph_callback
+// this is called from jack when the connections
+// changed
+//---------------------------------------------------------
+
+static int graph_callback(void*)
+ {
+ if (JACK_DEBUG)
+ printf("graph_callback()\n");
+ // we cannot call JackAudioDevice::graphChanged() from this
+ // context, so we send a message to the gui thread which in turn
+ // calls graphChanged()
+ audio->sendMsgToGui('C');
+ if (debugMsg)
+ printf("JACK: graph changed\n");
+ return 0;
+ }
+
+//---------------------------------------------------------
+// JackAudioDevice::graphChanged
+// this is called from song in gui context triggered
+// by graph_callback()
+//---------------------------------------------------------
+
+void JackAudioDevice::graphChanged()
+{
+ if (JACK_DEBUG)
+ printf("graphChanged()\n");
+ if(!checkJackClient(_client)) return;
+ InputList* il = song->inputs();
+ for (iAudioInput ii = il->begin(); ii != il->end(); ++ii) {
+ AudioInput* it = *ii;
+ int channels = it->channels();
+ for (int channel = 0; channel < channels; ++channel) {
+ jack_port_t* port = (jack_port_t*)(it->jackPort(channel));
+ if (port == 0)
+ continue;
+ const char** ports = jack_port_get_all_connections(_client, port);
+ RouteList* rl = it->inRoutes();
+
+ //---------------------------------------
+ // check for disconnects
+ //---------------------------------------
+
+ bool erased;
+ // limit set to 20 iterations for disconnects, don't know how to make it go
+ // the "right" amount
+ for (int i = 0;i < 20;i++) {
+ erased = false;
+ for (iRoute irl = rl->begin(); irl != rl->end(); ++irl) {
+ if (irl->channel != channel)
+ continue;
+ QString name = irl->name();
+ QByteArray ba = name.toLatin1();
+ const char* portName = ba.constData();
+ //printf("portname=%s\n", portName);
+ bool found = false;
+ const char** pn = ports;
+ while (pn && *pn) {
+ if (strcmp(*pn, portName) == 0) {
+ found = true;
+ break;
+ }
+ ++pn;
+ }
+ if (!found) {
+ audio->msgRemoveRoute1(
+ //Route(portName, false, channel),
+ Route(portName, false, channel, Route::JACK_ROUTE),
+ Route(it, channel)
+ );
+ erased = true;
+ break;
+ }
+ }
+ if (!erased)
+ break;
+ }
+
+ //---------------------------------------
+ // check for connects
+ //---------------------------------------
+
+ if (ports) {
+ const char** pn = ports;
+ while (*pn) {
+ bool found = false;
+ for (iRoute irl = rl->begin(); irl != rl->end(); ++irl) {
+ if (irl->channel != channel)
+ continue;
+ QString name = irl->name();
+ QByteArray ba = name.toLatin1();
+ const char* portName = ba.constData();
+ if (strcmp(*pn, portName) == 0) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ audio->msgAddRoute1(
+ //Route(*pn, false, channel),
+ Route(*pn, false, channel, Route::JACK_ROUTE),
+ Route(it, channel)
+ );
+ }
+ ++pn;
+ }
+
+ // p3.3.37
+ //delete ports;
+ free(ports);
+
+ ports = NULL;
+ }
+ }
+ }
+ OutputList* ol = song->outputs();
+ for (iAudioOutput ii = ol->begin(); ii != ol->end(); ++ii) {
+ AudioOutput* it = *ii;
+ int channels = it->channels();
+ for (int channel = 0; channel < channels; ++channel) {
+ jack_port_t* port = (jack_port_t*)(it->jackPort(channel));
+ if (port == 0)
+ continue;
+ const char** ports = jack_port_get_all_connections(_client, port);
+ RouteList* rl = it->outRoutes();
+
+ //---------------------------------------
+ // check for disconnects
+ //---------------------------------------
+
+ bool erased;
+ // limit set to 20 iterations for disconnects, don't know how to make it go
+ // the "right" amount
+ for (int i = 0; i < 20 ; i++) {
+ erased = false;
+ for (iRoute irl = rl->begin(); irl != rl->end(); ++irl) {
+ if (irl->channel != channel)
+ continue;
+ QString name = irl->name();
+ QByteArray ba = name.toLatin1();
+ const char* portName = ba.constData();
+ bool found = false;
+ const char** pn = ports;
+ while (pn && *pn) {
+ if (strcmp(*pn, portName) == 0) {
+ found = true;
+ break;
+ }
+ ++pn;
+ }
+ if (!found) {
+ audio->msgRemoveRoute1(
+ Route(it, channel),
+ //Route(portName, false, channel)
+ Route(portName, false, channel, Route::JACK_ROUTE)
+ );
+ erased = true;
+ break;
+ }
+ }
+ if (!erased)
+ break;
+ }
+
+ //---------------------------------------
+ // check for connects
+ //---------------------------------------
+
+ if (ports) {
+ const char** pn = ports;
+ while (*pn) {
+ bool found = false;
+ for (iRoute irl = rl->begin(); irl != rl->end(); ++irl) {
+ if (irl->channel != channel)
+ continue;
+ QString name = irl->name();
+ QByteArray ba = name.toLatin1();
+ const char* portName = ba.constData();
+ if (strcmp(*pn, portName) == 0) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ audio->msgAddRoute1(
+ Route(it, channel),
+ //Route(*pn, false, channel)
+ Route(*pn, false, channel, Route::JACK_ROUTE)
+ );
+ }
+ ++pn;
+ }
+
+ // p3.3.37
+ //delete ports;
+ free(ports);
+
+ ports = NULL;
+ }
+ }
+ }
+
+ for (iMidiDevice ii = midiDevices.begin(); ii != midiDevices.end(); ++ii)
+ {
+ MidiDevice* md = *ii;
+ if(md->deviceType() != MidiDevice::JACK_MIDI)
+ continue;
+
+ //MidiJackDevice* mjd = dynamic_cast<MidiJackDevice*>(*ii);
+ //if(!mjd)
+ // continue;
+ //for (int channel = 0; channel < channels; ++channel)
+ //{
+
+ // p3.3.55 Removed
+ //jack_port_t* port = (jack_port_t*)md->clientPort();
+ //if (port == 0)
+ // continue;
+ //const char** ports = jack_port_get_all_connections(_client, port);
+
+ //---------------------------------------
+ // outputs
+ //---------------------------------------
+
+ if(md->rwFlags() & 1) // Writable
+ {
+ // p3.3.55
+ jack_port_t* port = (jack_port_t*)md->outClientPort();
+ if(port != 0)
+ {
+ //printf("graphChanged() valid out client port\n"); // p3.3.55
+
+ const char** ports = jack_port_get_all_connections(_client, port);
+
+ RouteList* rl = md->outRoutes();
+
+ //---------------------------------------
+ // check for disconnects
+ //---------------------------------------
+
+ bool erased;
+ // limit set to 20 iterations for disconnects, don't know how to make it go
+ // the "right" amount
+ for (int i = 0; i < 20 ; i++)
+ {
+ erased = false;
+ for (iRoute irl = rl->begin(); irl != rl->end(); ++irl) {
+ //if (irl->channel != channel)
+ // continue;
+ QString name = irl->name();
+ //name += QString(JACK_MIDI_OUT_PORT_SUFFIX); // p3.3.55
+ QByteArray ba = name.toLatin1();
+ const char* portName = ba.constData();
+ bool found = false;
+ const char** pn = ports;
+ while (pn && *pn) {
+ if (strcmp(*pn, portName) == 0) {
+ found = true;
+ break;
+ }
+ ++pn;
+ }
+ if (!found) {
+ audio->msgRemoveRoute1(
+ //Route(it, channel),
+ //Route(mjd),
+ Route(md, -1),
+ //Route(portName, false, channel)
+ //Route(portName, false, -1)
+ Route(portName, false, -1, Route::JACK_ROUTE)
+ );
+ erased = true;
+ break;
+ }
+ }
+ if (!erased)
+ break;
+ }
+
+ //---------------------------------------
+ // check for connects
+ //---------------------------------------
+
+ if (ports)
+ {
+ const char** pn = ports;
+ while (*pn) {
+ bool found = false;
+ for (iRoute irl = rl->begin(); irl != rl->end(); ++irl) {
+ //if (irl->channel != channel)
+ // continue;
+ QString name = irl->name();
+ QByteArray ba = name.toLatin1();
+ const char* portName = ba.constData();
+ if (strcmp(*pn, portName) == 0) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ audio->msgAddRoute1(
+ //Route(it, channel),
+ //Route(mjd),
+ Route(md, -1),
+ //Route(*pn, false, channel)
+ //Route(*pn, false, -1)
+ Route(*pn, false, -1, Route::JACK_ROUTE)
+ );
+ }
+ ++pn;
+ }
+
+ // p3.3.55
+ // Done with ports. Free them.
+ free(ports);
+ }
+ }
+ }
+
+
+ //------------------------
+ // Inputs
+ //------------------------
+
+ if(md->rwFlags() & 2) // Readable
+ {
+ // p3.3.55
+ jack_port_t* port = (jack_port_t*)md->inClientPort();
+ if(port != 0)
+ {
+ //printf("graphChanged() valid in client port\n"); // p3.3.55
+ const char** ports = jack_port_get_all_connections(_client, port);
+
+ RouteList* rl = md->inRoutes();
+
+ //---------------------------------------
+ // check for disconnects
+ //---------------------------------------
+
+ bool erased;
+ // limit set to 20 iterations for disconnects, don't know how to make it go
+ // the "right" amount
+ for (int i = 0; i < 20 ; i++)
+ {
+ erased = false;
+ for (iRoute irl = rl->begin(); irl != rl->end(); ++irl) {
+ //if (irl->channel != channel)
+ // continue;
+ QString name = irl->name();
+ QByteArray ba = name.toLatin1();
+ const char* portName = ba.constData();
+ bool found = false;
+ const char** pn = ports;
+ while (pn && *pn) {
+ if (strcmp(*pn, portName) == 0) {
+ found = true;
+ break;
+ }
+ ++pn;
+ }
+ if (!found) {
+ audio->msgRemoveRoute1(
+ //Route(portName, false, channel),
+ //Route(portName, false, -1),
+ Route(portName, false, -1, Route::JACK_ROUTE),
+ //Route(it, channel)
+ //Route(mjd)
+ Route(md, -1)
+ );
+ erased = true;
+ break;
+ }
+ }
+ if (!erased)
+ break;
+ }
+
+ //---------------------------------------
+ // check for connects
+ //---------------------------------------
+
+ if (ports)
+ {
+ const char** pn = ports;
+ while (*pn) {
+ bool found = false;
+ for (iRoute irl = rl->begin(); irl != rl->end(); ++irl) {
+ //if (irl->channel != channel)
+ // continue;
+ QString name = irl->name();
+ QByteArray ba = name.toLatin1();
+ const char* portName = ba.constData();
+ if (strcmp(*pn, portName) == 0) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ audio->msgAddRoute1(
+ //Route(*pn, false, channel),
+ //Route(*pn, false, -1),
+ Route(*pn, false, -1, Route::JACK_ROUTE),
+ //Route(it, channel)
+ //Route(mjd)
+ Route(md, -1)
+ );
+ }
+ ++pn;
+ }
+ // p3.3.55
+ // Done with ports. Free them.
+ free(ports);
+ }
+ }
+ }
+
+ // p3.3.55 Removed.
+ //if(ports)
+ // Done with ports. Free them.
+ //delete ports;
+ // free(ports);
+ //ports = NULL;
+ }
+}
+
+//static int xrun_callback(void*)
+// {
+// printf("JACK: xrun\n");
+// return 0;
+// }
+
+//---------------------------------------------------------
+// register
+//---------------------------------------------------------
+
+void JackAudioDevice::registerClient()
+ {
+ if (JACK_DEBUG)
+ printf("registerClient()\n");
+ if(!checkJackClient(_client)) return;
+ jack_set_process_callback(_client, processAudio, 0);
+ jack_set_sync_callback(_client, processSync, 0);
+ // FIXME: FIXME:
+ // Added by Tim. p3.3.20
+ // Did not help. Seek during play: Jack keeps switching to STOP state after about 1-2 seconds timeout if sync is holding it up.
+ // Nothing in MusE seems to be telling it to stop.
+ // NOTE: Update: It was a bug in QJackCtl. Fixed now.
+ //jack_set_sync_timeout(_client, 5000000); // Change default 2 to 5 second sync timeout because prefetch may be very slow esp. with resampling !
+
+ jack_on_shutdown(_client, processShutdown, 0);
+ jack_set_buffer_size_callback(_client, bufsize_callback, 0);
+ jack_set_sample_rate_callback(_client, srate_callback, 0);
+ jack_set_port_registration_callback(_client, registration_callback, 0);
+ // p3.3.37
+ jack_set_client_registration_callback(_client, client_registration_callback, 0);
+ jack_set_port_connect_callback(_client, port_connect_callback, 0);
+
+ jack_set_graph_order_callback(_client, graph_callback, 0);
+// jack_set_xrun_callback(client, xrun_callback, 0);
+ jack_set_freewheel_callback (_client, freewheel_callback, 0);
+ }
+
+//---------------------------------------------------------
+// registerInPort
+//---------------------------------------------------------
+
+//void* JackAudioDevice::registerInPort(const char* name)
+void* JackAudioDevice::registerInPort(const char* name, bool midi)
+ {
+ if (JACK_DEBUG)
+ printf("registerInPort()\n");
+ if(!checkJackClient(_client)) return NULL;
+ const char* type = midi ? JACK_DEFAULT_MIDI_TYPE : JACK_DEFAULT_AUDIO_TYPE;
+ //void* p = jack_port_register(_client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
+ void* p = jack_port_register(_client, name, type, JackPortIsInput, 0);
+// printf("JACK: registerInPort: <%s> %p\n", name, p);
+ return p;
+ }
+
+//---------------------------------------------------------
+// registerOutPort
+//---------------------------------------------------------
+
+//void* JackAudioDevice::registerOutPort(const char* name)
+void* JackAudioDevice::registerOutPort(const char* name, bool midi)
+ {
+ if (JACK_DEBUG)
+ printf("registerOutPort()\n");
+ if(!checkJackClient(_client)) return NULL;
+ const char* type = midi ? JACK_DEFAULT_MIDI_TYPE : JACK_DEFAULT_AUDIO_TYPE;
+ //void* p = jack_port_register(_client, name, JACK_DEFAULT_AUDIO_TYPE, JackPortIsOutput, 0);
+ void* p = jack_port_register(_client, name, type, JackPortIsOutput, 0);
+// printf("JACK: registerOutPort: <%s> %p\n", name, p);
+ return p;
+ }
+
+//---------------------------------------------------------
+// exitJackAudio
+//---------------------------------------------------------
+
+void exitJackAudio()
+ {
+ if (JACK_DEBUG)
+ printf("exitJackAudio()\n");
+ if (jackAudio)
+ delete jackAudio;
+
+ if (JACK_DEBUG)
+ printf("exitJackAudio() after delete jackAudio\n");
+
+ // Added by Tim. p3.3.14
+ audioDevice = NULL;
+
+ }
+
+//---------------------------------------------------------
+// connect
+//---------------------------------------------------------
+
+void JackAudioDevice::connect(void* src, void* dst)
+{
+ if (JACK_DEBUG)
+ printf("JackAudioDevice::connect()\n");
+ if(!checkJackClient(_client)) return;
+ const char* sn = jack_port_name((jack_port_t*) src);
+ const char* dn = jack_port_name((jack_port_t*) dst);
+ if (sn == 0 || dn == 0) {
+ fprintf(stderr, "JackAudio::connect: unknown jack ports\n");
+ return;
+ }
+ int err = jack_connect(_client, sn, dn);
+ //if (jack_connect(_client, sn, dn)) {
+ if (err) {
+ fprintf(stderr, "jack connect <%s>%p - <%s>%p failed with err:%d\n",
+ sn, src, dn, dst, err);
+ }
+ else
+ if (JACK_DEBUG)
+ {
+ fprintf(stderr, "jack connect <%s>%p - <%s>%p succeeded\n",
+ sn, src, dn, dst);
+ }
+}
+
+//---------------------------------------------------------
+// disconnect
+//---------------------------------------------------------
+
+void JackAudioDevice::disconnect(void* src, void* dst)
+{
+ if (JACK_DEBUG)
+ printf("JackAudioDevice::disconnect()\n");
+ if(!checkJackClient(_client)) return;
+ if(!src || !dst) // p3.3.55
+ return;
+ const char* sn = jack_port_name((jack_port_t*) src);
+ const char* dn = jack_port_name((jack_port_t*) dst);
+ if (sn == 0 || dn == 0) {
+ fprintf(stderr, "JackAudio::disconnect: unknown jack ports\n");
+ return;
+ }
+ int err = jack_disconnect(_client, sn, dn);
+ //if (jack_disconnect(_client, sn, dn)) {
+ if (err) {
+ fprintf(stderr, "jack disconnect <%s> - <%s> failed with err:%d\n",
+ sn, dn, err);
+ }
+ else
+ if (JACK_DEBUG)
+ {
+ fprintf(stderr, "jack disconnect <%s> - <%s> succeeded\n",
+ sn, dn);
+ }
+}
+
+//---------------------------------------------------------
+// start
+//---------------------------------------------------------
+
+//void JackAudioDevice::start()
+void JackAudioDevice::start(int /*priority*/)
+ {
+ if (JACK_DEBUG)
+ printf("JackAudioDevice::start()\n");
+ if(!checkJackClient(_client)) return;
+
+ doSetuid();
+
+ if (jack_activate(_client)) {
+ undoSetuid(); // p3.3.51
+ fprintf (stderr, "JACK: cannot activate client\n");
+ exit(-1);
+ }
+ /* connect the ports. Note: you can't do this before
+ the client is activated, because we can't allow
+ connections to be made to clients that aren't
+ running.
+ */
+
+ InputList* il = song->inputs();
+ for (iAudioInput i = il->begin(); i != il->end(); ++i) {
+ AudioInput* ai = *i;
+ int channel = ai->channels();
+ for (int ch = 0; ch < channel; ++ch) {
+ RouteList* rl = ai->inRoutes();
+ void* port = ai->jackPort(ch);
+ for (iRoute ir = rl->begin(); ir != rl->end(); ++ir) {
+ if (ir->channel == ch)
+ connect(ir->jackPort, port);
+ }
+ }
+ }
+ OutputList* ol = song->outputs();
+ for (iAudioOutput i = ol->begin(); i != ol->end(); ++i) {
+ AudioOutput* ai = *i;
+ int channel = ai->channels();
+ for (int ch = 0; ch < channel; ++ch) {
+ RouteList* rl = ai->outRoutes();
+ void* port = ai->jackPort(ch);
+ for (iRoute r = rl->begin(); r != rl->end(); ++r) {
+ if (r->channel == ch) {
+ connect(port, r->jackPort);
+ }
+ }
+ }
+ }
+
+ // p3.3.37
+ // Connect the Jack midi client ports to device ports.
+ connectJackMidiPorts();
+
+ undoSetuid();
+
+ //MUSE_DEBUG("JackAudioDevice::start()\n");
+ fflush(stdin);
+ //JackAudioDevice::jackStarted=true;
+ }
+
+//---------------------------------------------------------
+// stop
+//---------------------------------------------------------
+
+void JackAudioDevice::stop()
+ {
+ if (JACK_DEBUG)
+ printf("JackAudioDevice::stop()\n");
+ if(!checkJackClient(_client)) return;
+ if (jack_deactivate(_client)) {
+ fprintf (stderr, "cannot deactivate client\n");
+ }
+ //JackAudioDevice::jackStarted=false;
+ }
+
+//---------------------------------------------------------
+// transportQuery
+//---------------------------------------------------------
+
+jack_transport_state_t JackAudioDevice::transportQuery(jack_position_t* pos)
+{
+ if (JACK_DEBUG)
+ printf("JackAudioDevice::transportQuery pos:%d\n", (unsigned int)pos->frame);
+
+ // TODO: Compose and return a state if MusE is disengaged from Jack transport.
+
+ return jack_transport_query(_client, pos);
+}
+
+//---------------------------------------------------------
+// getCurFrame
+//---------------------------------------------------------
+
+unsigned int JackAudioDevice::getCurFrame()
+{
+ if (JACK_DEBUG)
+ printf("JackAudioDevice::getCurFrame pos.frame:%d\n", pos.frame);
+
+ if(!useJackTransport.value())
+ return (unsigned int)dummyPos;
+
+ return pos.frame;
+}
+
+//---------------------------------------------------------
+// framePos
+//---------------------------------------------------------
+
+int JackAudioDevice::framePos() const
+ {
+ //if(!useJackTransport.value())
+ //{
+ // if (JACK_DEBUG)
+ // printf("JackAudioDevice::framePos dummyPos:%d\n", dummyPos);
+ // return dummyPos;
+ //}
+
+ if(!checkJackClient(_client)) return 0;
+ jack_nframes_t n = jack_frame_time(_client);
+
+ //if (JACK_DEBUG)
+ // printf("JackAudioDevice::framePos jack frame:%d\n", (int)n);
+
+ return (int)n;
+ }
+
+#if 0
+//---------------------------------------------------------
+// framesSinceCycleStart
+//---------------------------------------------------------
+
+int JackAudioDevice::framesSinceCycleStart() const
+ {
+ jack_nframes_t n = jack_frames_since_cycle_start(client);
+ return (int)n;
+ }
+
+//---------------------------------------------------------
+// framesDelay
+// TODO
+//---------------------------------------------------------
+
+int JackAudioDevice::frameDelay() const
+ {
+ jack_nframes_t n = (segmentSize * (segmentCount-1)) - jack_frames_since_cycle_start(client);
+ return (int)n;
+ }
+#endif
+
+//---------------------------------------------------------
+// outputPorts
+//---------------------------------------------------------
+
+std::list<QString> JackAudioDevice::outputPorts(bool midi, int aliases)
+ {
+ if (JACK_DEBUG)
+ printf("JackAudioDevice::outputPorts()\n");
+ std::list<QString> clientList;
+ if(!checkJackClient(_client)) return clientList;
+ QString qname;
+ const char* type = midi ? JACK_DEFAULT_MIDI_TYPE : JACK_DEFAULT_AUDIO_TYPE;
+ const char** ports = jack_get_ports(_client, 0, type, JackPortIsOutput);
+ for (const char** p = ports; p && *p; ++p) {
+ jack_port_t* port = jack_port_by_name(_client, *p);
+ //int flags = jack_port_flags(port);
+ //if (!(flags & JackPortIsOutput))
+ // continue;
+ //char buffer[128];
+
+ int nsz = jack_port_name_size();
+ char buffer[nsz];
+
+ strncpy(buffer, *p, nsz);
+ //if (strncmp(buffer, "MusE", 4) == 0)
+ //{
+ // if(debugMsg)
+ // printf("JackAudioDevice::outputPorts ignoring own MusE port: %s\n", *p);
+ // continue;
+ //}
+
+ // Ignore our own client ports.
+ if(jack_port_is_mine(_client, port))
+ {
+ if(debugMsg)
+ printf("JackAudioDevice::outputPorts ignoring own port: %s\n", *p);
+ continue;
+ }
+
+ // p3.3.38
+ if((aliases == 0) || (aliases == 1))
+ {
+ //char a1[nsz];
+ char a2[nsz];
+ char* al[2];
+ //aliases[0] = a1;
+ al[0] = buffer;
+ al[1] = a2;
+ int na = jack_port_get_aliases(port, al);
+ int a = aliases;
+ if(a >= na)
+ {
+ a = na;
+ if(a > 0)
+ a--;
+ }
+ qname = QString(al[a]);
+ }
+ else
+ qname = QString(buffer);
+
+ //clientList.push_back(QString(buffer));
+ clientList.push_back(qname);
+ }
+
+ // p3.3.37
+ if(ports)
+ free(ports);
+
+ return clientList;
+ }
+
+//---------------------------------------------------------
+// inputPorts
+//---------------------------------------------------------
+
+std::list<QString> JackAudioDevice::inputPorts(bool midi, int aliases)
+ {
+ if (JACK_DEBUG)
+ printf("JackAudioDevice::inputPorts()\n");
+ std::list<QString> clientList;
+ if(!checkJackClient(_client)) return clientList;
+ QString qname;
+ const char* type = midi ? JACK_DEFAULT_MIDI_TYPE : JACK_DEFAULT_AUDIO_TYPE;
+ const char** ports = jack_get_ports(_client, 0, type, JackPortIsInput);
+ for (const char** p = ports; p && *p; ++p) {
+ jack_port_t* port = jack_port_by_name(_client, *p);
+ //int flags = jack_port_flags(port);
+ //if (!(flags & JackPortIsInput))
+ // continue;
+ //char buffer[128];
+
+ int nsz = jack_port_name_size();
+ char buffer[nsz];
+
+ strncpy(buffer, *p, nsz);
+ //if (strncmp(buffer, "MusE", 4) == 0)
+ //{
+ // if(debugMsg)
+ // printf("JackAudioDevice::inputPorts ignoring own MusE port: %s\n", *p);
+ // continue;
+ //}
+
+ // Ignore our own client ports.
+ if(jack_port_is_mine(_client, port))
+ {
+ if(debugMsg)
+ printf("JackAudioDevice::inputPorts ignoring own port: %s\n", *p);
+ continue;
+ }
+
+ // p3.3.38
+ if((aliases == 0) || (aliases == 1))
+ {
+ //char a1[nsz];
+ char a2[nsz];
+ char* al[2];
+ //aliases[0] = a1;
+ al[0] = buffer;
+ al[1] = a2;
+ int na = jack_port_get_aliases(port, al);
+ int a = aliases;
+ if(a >= na)
+ {
+ a = na;
+ if(a > 0)
+ a--;
+ }
+ qname = QString(al[a]);
+ }
+ else
+ qname = QString(buffer);
+
+ //clientList.push_back(QString(buffer));
+ clientList.push_back(qname);
+ }
+
+ // p3.3.37
+ if(ports)
+ free(ports);
+
+ return clientList;
+ }
+
+//---------------------------------------------------------
+// portName
+//---------------------------------------------------------
+
+QString JackAudioDevice::portName(void* port)
+ {
+ if (JACK_DEBUG)
+ printf("JackAudioDevice::portName(\n");
+ if(!checkJackClient(_client)) return "";
+ if (!port)
+ return "";
+
+ QString s(jack_port_name((jack_port_t*)port));
+ //printf("Jack::portName %p %s\n", port, s.toLatin1());
+ return s;
+ }
+
+//---------------------------------------------------------
+// unregisterPort
+//---------------------------------------------------------
+
+void JackAudioDevice::unregisterPort(void* p)
+ {
+ if (JACK_DEBUG)
+ printf("JackAudioDevice::unregisterPort(\n");
+ if(!checkJackClient(_client)) return;
+// printf("JACK: unregister Port\n");
+ jack_port_unregister(_client, (jack_port_t*)p);
+ }
+
+//---------------------------------------------------------
+// getState
+//---------------------------------------------------------
+
+int JackAudioDevice::getState()
+ {
+ // If we're not using Jack's transport, just return current state.
+ if(!useJackTransport.value())
+ {
+ //pos.valid = jack_position_bits_t(0);
+ //pos.frame = audio->pos().frame();
+ //return audio->getState();
+ //if (JACK_DEBUG)
+ // printf("JackAudioDevice::getState dummyState:%d\n", dummyState);
+ return dummyState;
+ }
+
+ //if (JACK_DEBUG)
+ // printf("JackAudioDevice::getState ()\n");
+ if(!checkJackClient(_client)) return 0;
+ transportState = jack_transport_query(_client, &pos);
+ //if (JACK_DEBUG)
+ // printf("JackAudioDevice::getState transportState:%d\n", transportState);
+
+ switch (transportState) {
+ case JackTransportStopped:
+ return Audio::STOP;
+ case JackTransportLooping:
+ case JackTransportRolling:
+ return Audio::PLAY;
+ case JackTransportStarting:
+ //printf("JackAudioDevice::getState JackTransportStarting\n");
+
+ return Audio::START_PLAY;
+ //case JackTransportNetStarting:
+ // FIXME: Quick and dirty hack to support both Jack-1 and Jack-2
+ // Really need a config check of version...
+ case 4:
+ //printf("JackAudioDevice::getState JackTransportNetStarting\n");
+
+ return Audio::START_PLAY;
+ break;
+ default:
+ return Audio::STOP;
+ }
+ }
+
+//---------------------------------------------------------
+// setFreewheel
+//---------------------------------------------------------
+
+void JackAudioDevice::setFreewheel(bool f)
+ {
+ if (JACK_DEBUG)
+ printf("JackAudioDevice::setFreewheel(\n");
+ if(!checkJackClient(_client)) return;
+// printf("JACK: setFreewheel %d\n", f);
+ jack_set_freewheel(_client, f);
+ }
+
+//---------------------------------------------------------
+// dummySync
+//---------------------------------------------------------
+
+bool JackAudioDevice::dummySync(int state)
+{
+ // Roughly segment time length.
+ //timespec ts = { 0, (1000000000 * segmentSize) / sampleRate }; // In nanoseconds.
+ unsigned int sl = (1000000 * segmentSize) / sampleRate; // In microseconds.
+
+ double ct = curTime();
+ // Wait for a default maximum of 5 seconds.
+ // Similar to how Jack is supposed to wait a default of 2 seconds for slow clients.
+ // TODO: Make this timeout a 'settings' option so it can be applied both to Jack and here.
+ while((curTime() - ct) < 5.0)
+ {
+ // Is MusE audio ready to roll?
+ if(audio->sync(state, dummyPos))
+ return true;
+
+ // Not ready. Wait a 'segment', try again...
+ //nanosleep(&ts, NULL);
+ usleep(sl); // usleep is supposed to be obsolete!
+ }
+
+ //if(JACK_DEBUG)
+ printf("JackAudioDevice::dummySync Sync timeout - audio not ready!\n");
+
+ return false;
+}
+
+//---------------------------------------------------------
+// startTransport
+//---------------------------------------------------------
+
+void JackAudioDevice::startTransport()
+ {
+ if (JACK_DEBUG)
+ printf("JackAudioDevice::startTransport()\n");
+
+ // If we're not using Jack's transport, just pass PLAY and current frame along
+ // as if processSync was called.
+ if(!useJackTransport.value())
+ {
+ //dummyState = Audio::START_PLAY;
+
+ // Is MusE audio ready to roll?
+ //if(dummySync(dummyState))
+ if(dummySync(Audio::START_PLAY))
+ {
+ // MusE audio is ready to roll. Let's play.
+ dummyState = Audio::PLAY;
+ return;
+ }
+
+ // Ready or not, we gotta roll. Similar to how Jack is supposed to roll anyway.
+ dummyState = Audio::PLAY;
+ return;
+ }
+
+ if(!checkJackClient(_client)) return;
+// printf("JACK: startTransport\n");
+ jack_transport_start(_client);
+ }
+
+//---------------------------------------------------------
+// stopTransport
+//---------------------------------------------------------
+
+void JackAudioDevice::stopTransport()
+ {
+ if (JACK_DEBUG)
+ printf("JackAudioDevice::stopTransport()\n");
+
+ dummyState = Audio::STOP;
+
+ if(!useJackTransport.value())
+ {
+ //dummyState = Audio::STOP;
+ return;
+ }
+
+ if(!checkJackClient(_client)) return;
+ if (transportState != JackTransportStopped) {
+ // printf("JACK: stopTransport\n");
+ jack_transport_stop(_client);
+ transportState=JackTransportStopped;
+ }
+ }
+
+//---------------------------------------------------------
+// seekTransport
+//---------------------------------------------------------
+
+void JackAudioDevice::seekTransport(unsigned frame)
+ {
+ if (JACK_DEBUG)
+ printf("JackAudioDevice::seekTransport() frame:%d\n", frame);
+
+ dummyPos = frame;
+ if(!useJackTransport.value())
+ {
+ // If we're not using Jack's transport, just pass the current state and new frame along
+ // as if processSync was called.
+ //dummyPos = frame;
+ int tempState = dummyState;
+ //dummyState = Audio::START_PLAY;
+
+ // Is MusE audio ready yet?
+ //audio->sync(dummyState, dummyPos);
+ //if(dummySync(dummyState))
+ if(dummySync(Audio::START_PLAY))
+ {
+ dummyState = tempState;
+ return;
+ }
+
+ // Not ready, resume previous state anyway.
+ // FIXME: Observed: Seek during play: Jack transport STOPs on timeout.
+ // Docs say when starting play, transport will roll anyway, ready or not (observed),
+ // but don't mention what should happen on seek during play.
+ // And setting the slow-sync timeout doesn't seem to do anything!
+ // NOTE: Update: It was a bug with QJackCtl. Fixed now.
+ //dummyState = tempState;
+ dummyState = Audio::STOP;
+ return;
+ }
+
+ if(!checkJackClient(_client)) return;
+// printf("JACK: seekTransport %d\n", frame);
+ jack_transport_locate(_client, frame);
+ }
+
+//---------------------------------------------------------
+// seekTransport
+//---------------------------------------------------------
+
+void JackAudioDevice::seekTransport(const Pos &p)
+ {
+ if (JACK_DEBUG)
+ printf("JackAudioDevice::seekTransport() frame:%d\n", p.frame());
+
+ dummyPos = p.frame();
+ if(!useJackTransport.value())
+ {
+ // If we're not using Jack's transport, just pass the current state and new frame along
+ // as if processSync was called.
+ //dummyPos = p.frame();
+ int tempState = dummyState;
+ //dummyState = Audio::START_PLAY;
+
+ // Is MusE audio ready yet?
+ //audio->sync(dummyState, dummyPos);
+ //if(dummySync(dummyState))
+ if(dummySync(Audio::START_PLAY))
+ {
+ dummyState = tempState;
+ return;
+ }
+
+ // Not ready, resume previous state anyway.
+ // FIXME: See fixme in other seekTransport...
+ //dummyState = tempState;
+ dummyState = Audio::STOP;
+ return;
+ }
+
+ if(!checkJackClient(_client)) return;
+
+ /*
+ jack_position_t jp;
+ jp.valid = JackPositionBBT;
+ p.mbt(&jp.bar, &jp.beat, &jp.tick);
+ jp.bar++;
+ jp.beat++;
+ jp.bar_start_tick = Pos(jp.bar, 0, 0).tick();
+ //
+ // dummy:
+ //
+ jp.beats_per_bar = 4;
+ jp.beat_type = 4;
+ jp.ticks_per_beat = 384;
+ int tempo = tempomap.tempo(p.tick());
+ jp.beats_per_minute = (60000000.0 / tempo) * tempomap.globalTempo()/100.0;
+
+ jack_transport_reposition(_client, &jp);
+ */
+ jack_transport_locate(_client, p.frame());
+ }
+
+//---------------------------------------------------------
+// findPort
+//---------------------------------------------------------
+
+void* JackAudioDevice::findPort(const char* name)
+ {
+ if (JACK_DEBUG)
+ printf("JackAudioDevice::findPort(\n");
+ if(!checkJackClient(_client)) return NULL;
+ void* p = jack_port_by_name(_client, name);
+// printf("Jack::findPort <%s>, %p\n", name, p);
+ return p;
+ }
+
+//---------------------------------------------------------
+// setMaster
+//---------------------------------------------------------
+
+int JackAudioDevice::setMaster(bool f)
+{
+ if (JACK_DEBUG)
+ printf("JackAudioDevice::setMaster val:%d\n", f);
+ if(!checkJackClient(_client))
+ return 0;
+
+ int r = 0;
+ if(f)
+ {
+ if(useJackTransport.value())
+ {
+ // Make Muse the Jack timebase master. Do it unconditionally (second param = 0).
+ r = jack_set_timebase_callback(_client, 0, (JackTimebaseCallback) timebase_callback, 0);
+ if(debugMsg || JACK_DEBUG)
+ {
+ if(r)
+ printf("JackAudioDevice::setMaster jack_set_timebase_callback failed: result:%d\n", r);
+ }
+ }
+ else
+ {
+ r = 1;
+ printf("JackAudioDevice::setMaster cannot set master because useJackTransport is false\n");
+ }
+ }
+ else
+ {
+ r = jack_release_timebase(_client);
+ if(debugMsg || JACK_DEBUG)
+ {
+ if(r)
+ printf("JackAudioDevice::setMaster jack_release_timebase failed: result:%d\n", r);
+ }
+ }
+ return r;
+}
+
+//---------------------------------------------------------
+// scanMidiPorts
+//---------------------------------------------------------
+
+void JackAudioDevice::scanMidiPorts()
+{
+ if(debugMsg)
+ printf("JackAudioDevice::scanMidiPorts:\n");
+
+/*
+ const char* type = JACK_DEFAULT_MIDI_TYPE;
+ const char** ports = jack_get_ports(_client, 0, type, 0);
+
+ std::set<std::string> names;
+ for (const char** p = ports; p && *p; ++p)
+ {
+ jack_port_t* port = jack_port_by_name(_client, *p);
+ if(!port)
+ continue;
+ // Ignore our own client ports.
+ if(jack_port_is_mine(_client, port))
+ {
+ if(debugMsg)
+ printf(" ignoring own port: %s\n", *p);
+ continue;
+ }
+
+ int nsz = jack_port_name_size();
+ char buffer[nsz];
+ strncpy(buffer, *p, nsz);
+ // Ignore the MusE Jack port.
+ //if(strncmp(buffer, "MusE", 4) == 0)
+ // continue;
+
+ if(debugMsg)
+ printf(" found port: %s ", buffer);
+
+ // If there are aliases for this port, use the first one - much better for identifying.
+ //char a1[nsz];
+ char a2[nsz];
+ char* aliases[2];
+ //aliases[0] = a1;
+ aliases[0] = buffer;
+ aliases[1] = a2;
+ // To disable aliases, just rem this line.
+ jack_port_get_aliases(port, aliases);
+ //int na = jack_port_get_aliases(port, aliases);
+ //char* namep = (na >= 1) ? aliases[0] : buffer;
+ //char* namep = aliases[0];
+ //names.insert(std::string(*p));
+ if(debugMsg)
+ printf("alias: %s\n", aliases[0]);
+
+ names.insert(std::string(aliases[0]));
+ }
+ if(ports)
+ free(ports);
+
+ std::list<MidiDevice*> to_del;
+ for(iMidiDevice imd = midiDevices.begin(); imd != midiDevices.end(); ++imd)
+ {
+ // Only Jack midi devices.
+ if(dynamic_cast<MidiJackDevice*>(*imd) == 0)
+ continue;
+ if(names.find(std::string((*imd)->name().toLatin1())) == names.end())
+ to_del.push_back(*imd);
+ }
+
+ for(std::list<MidiDevice*>::iterator imd = to_del.begin(); imd != to_del.end(); ++imd)
+ {
+ if(debugMsg)
+ printf(" removing port device:%s\n", (*imd)->name().toLatin1());
+ midiDevices.remove(*imd);
+ // This will close (and unregister) the client port.
+ delete (*imd);
+ }
+
+ //for (const char** p = ports; p && *p; ++p)
+ for(std::set<std::string>::iterator is = names.begin(); is != names.end(); ++is)
+ {
+ //jack_port_t* port = jack_port_by_name(_client, *p);
+ jack_port_t* port = jack_port_by_name(_client, is->c_str());
+ if(!port)
+ continue;
+*/
+
+ /*
+ int nsz = jack_port_name_size();
+ char buffer[nsz];
+ //strncpy(buffer, *p, nsz);
+ strncpy(buffer, is->c_str(), nsz);
+ // Ignore the MusE Jack port.
+ //if(strncmp(buffer, "MusE", 4) == 0)
+ // continue;
+
+ // If there are aliases for this port, use the first one - much better for identifying.
+ //char a1[nsz];
+ char a2[nsz];
+ char* aliases[2];
+ //aliases[0] = a1;
+ aliases[0] = buffer;
+ aliases[1] = a2;
+ // To disable aliases, just rem this line.
+ jack_port_get_aliases(port, aliases);
+ //int na = jack_port_get_aliases(port, aliases);
+ //char* namep = (na >= 1) ? aliases[0] : buffer;
+ char* namep = aliases[0];
+ QString qname(namep);
+ */
+
+/*
+ QString qname(is->c_str());
+
+ // Port already exists?
+ if(midiDevices.find(qname))
+ continue;
+
+ int flags = 0;
+ int pf = jack_port_flags(port);
+ // If Jack port can send data to us...
+ if(pf & JackPortIsOutput)
+ // Mark as input capable.
+ flags |= 2;
+ // If Jack port can receive data from us...
+ if(pf & JackPortIsInput)
+ // Mark as output capable.
+ flags |= 1;
+
+ //JackPort jp(0, QString(buffer), flags);
+ //portList.append(jp);
+
+ if(debugMsg)
+ printf(" adding port device:%s\n", qname.toLatin1());
+
+ MidiJackDevice* dev = new MidiJackDevice(0, qname);
+ dev->setrwFlags(flags);
+ midiDevices.add(dev);
+ }
+*/
+}
+
diff --git a/attic/muse2-oom/muse2/muse/driver/jackaudio.h b/attic/muse2-oom/muse2/muse/driver/jackaudio.h
new file mode 100644
index 00000000..d3132efe
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/driver/jackaudio.h
@@ -0,0 +1,97 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: jackaudio.h,v 1.20.2.4 2009/12/20 05:00:35 terminator356 Exp $
+// (C) Copyright 2002 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __JACKAUDIO_H__
+#define __JACKAUDIO_H__
+
+#include <jack/jack.h>
+#include "audiodev.h"
+
+class MidiPlayEvent;
+
+//---------------------------------------------------------
+// JackAudioDevice
+//---------------------------------------------------------
+bool checkAudioDevice();
+
+class JackAudioDevice : public AudioDevice {
+
+ jack_client_t* _client;
+ double sampleTime;
+ int samplePos;
+ jack_transport_state_t transportState;
+ jack_position_t pos;
+ char jackRegisteredName[16];
+ int dummyState;
+ int dummyPos;
+ // Free-running frame counter incremented always in process.
+ jack_nframes_t _frameCounter;
+
+ static int processAudio(jack_nframes_t frames, void*);
+
+ public:
+ JackAudioDevice(jack_client_t* cl, char * jack_id_string);
+ virtual ~JackAudioDevice();
+ virtual void nullify_client() { _client = 0; }
+
+ virtual inline int deviceType() { return JACK_AUDIO; } // p3.3.52
+
+ void scanMidiPorts();
+
+ //virtual void start();
+ virtual void start(int);
+ virtual void stop ();
+ virtual bool dummySync(int state); // Artificial sync when not using Jack transport.
+
+ virtual int framePos() const;
+ virtual unsigned frameTime() const { return _frameCounter; }
+
+ virtual float* getBuffer(void* port, unsigned long nframes) {
+ return (float*)jack_port_get_buffer((jack_port_t*)port, nframes);
+ }
+
+ virtual std::list<QString> outputPorts(bool midi = false, int aliases = -1);
+ virtual std::list<QString> inputPorts(bool midi = false, int aliases = -1);
+
+ virtual void registerClient();
+ virtual const char* clientName() { return jackRegisteredName; }
+
+ //virtual void* registerOutPort(const char* name);
+ //virtual void* registerInPort(const char* name);
+ virtual void* registerOutPort(const char* /*name*/, bool /*midi*/);
+ virtual void* registerInPort(const char* /*name*/, bool /*midi*/);
+
+ //virtual char* getJackName();
+
+ virtual void unregisterPort(void*);
+ virtual void connect(void*, void*);
+ virtual void disconnect(void*, void*);
+ virtual int connections(void* clientPort) { return jack_port_connected((jack_port_t*)clientPort); }
+ virtual void setPortName(void* p, const char* n) { jack_port_set_name((jack_port_t*)p, n); }
+ virtual void* findPort(const char* name);
+ virtual QString portName(void* port);
+ virtual int getState();
+ virtual unsigned int getCurFrame();
+ virtual bool isRealtime() { return jack_is_realtime(_client); }
+ virtual int realtimePriority() const;
+ virtual void startTransport();
+ virtual void stopTransport();
+ virtual void seekTransport(unsigned frame);
+ virtual void seekTransport(const Pos &p);
+ virtual void setFreewheel(bool f);
+ jack_transport_state_t transportQuery(jack_position_t* pos);
+ void graphChanged();
+ void registrationChanged();
+ void connectJackMidiPorts();
+
+ virtual int setMaster(bool f);
+
+ //static bool jackStarted;
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/driver/jackmidi.cpp b/attic/muse2-oom/muse2/muse/driver/jackmidi.cpp
new file mode 100644
index 00000000..d401c7e1
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/driver/jackmidi.cpp
@@ -0,0 +1,1732 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: jackmidi.cpp,v 1.1.1.1 2010/01/27 09:06:43 terminator356 Exp $
+// (C) Copyright 1999-2010 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QString>
+
+#include <stdio.h>
+
+#include <jack/jack.h>
+//#include <jack/midiport.h>
+
+#include "jackmidi.h"
+#include "song.h"
+#include "globals.h"
+#include "midi.h"
+#include "mididev.h"
+#include "../midiport.h"
+#include "../midiseq.h"
+#include "../midictrl.h"
+#include "../audio.h"
+#include "mpevent.h"
+//#include "sync.h"
+#include "audiodev.h"
+#include "../mplugins/midiitransform.h"
+#include "../mplugins/mitplugin.h"
+#include "xml.h"
+
+// Turn on debug messages.
+//#define JACK_MIDI_DEBUG
+
+extern unsigned int volatile lastExtMidiSyncTick;
+
+///int jackmidi_pi[2];
+///int jackmidi_po[2];
+
+//extern muse_jack_midi_buffer jack_midi_out_data[JACK_MIDI_CHANNELS];
+//extern muse_jack_midi_buffer jack_midi_in_data[JACK_MIDI_CHANNELS];
+///extern jack_port_t *midi_port_in[JACK_MIDI_CHANNELS];
+///extern jack_port_t *midi_port_out[JACK_MIDI_CHANNELS];
+
+///MidiJackDevice* gmdev = NULL;
+
+///int* jackSeq;
+//static snd_seq_addr_t musePort;
+
+//int MidiJackDevice::_nextOutIdNum = 0;
+//int MidiJackDevice::_nextInIdNum = 0;
+
+//int JackMidiPortList::_nextOutIdNum = 0;
+//int JackMidiPortList::_nextInIdNum = 0;
+
+//JackMidiPortList jackMidiClientPorts;
+
+
+/*
+//---------------------------------------------------------
+// JackMidiPortList
+//---------------------------------------------------------
+
+JackMidiPortList::JackMidiPortList()
+{
+
+}
+
+JackMidiPortList::~JackMidiPortList()
+{
+
+}
+
+iJackMidiPort JackMidiPortList::createClientPort(int flags) // 1 = writable, 2 = readable - do not mix
+{
+ if(flags & 1)
+ {
+ char buf[80];
+ snprintf(buf, 80, "muse-jack-midi-out-%d", _nextOutIdNum);
+ jack_port_t* _client_jackport = (jack_port_t*)audioDevice->registerOutPort(buf, true);
+ if(_client_jackport == NULL)
+ {
+ fprintf(stderr, "JackMidiPortList::createClientPort failed to register jack-midi-out\n");
+ //return QString("Could not register jack-midi-out client port");
+ return end();
+ }
+ else
+ {
+ JackMidiPort jmp(_client_jackport, QString(buf), flags);
+ _nextOutIdNum++;
+ return insert(begin(), std::pair<jack_port_t*, JackMidiPort>(_client_jackport, jmp));
+ }
+ }
+ else
+ if(flags & 2)
+ {
+ char buf[80];
+ snprintf(buf, 80, "muse-jack-midi-in-%d", _nextInIdNum);
+ jack_port_t* _client_jackport = (jack_port_t*)audioDevice->registerInPort(buf, true);
+ if(_client_jackport == NULL)
+ {
+ fprintf(stderr, "JackMidiPortList::createClientPort failed to register jack-midi-in\n");
+ return end();
+ }
+ else
+ {
+ JackMidiPort jmp(_client_jackport, QString(buf), flags);
+ _nextInIdNum++;
+ return insert(begin(), std::pair<jack_port_t*, JackMidiPort>(_client_jackport, jmp));
+ }
+ }
+ return end();
+}
+
+// Return true if removed.
+bool JackMidiPortList::removeClientPort(jack_port_t* port)
+{
+ iJackMidiPort ijp = find(port);
+ if(ijp == end())
+ return false;
+
+ // Is output?
+ if(ijp->second._flags & 1)
+ _nextOutIdNum--;
+ // Is input?
+ if(ijp->second._flags & 2)
+ _nextInIdNum--;
+
+ erase(ijp);
+
+ audioDevice->unregisterPort(port);
+
+ return true;
+}
+*/
+
+//---------------------------------------------------------
+// MidiJackDevice
+// in_jack_port or out_jack_port can be null
+//---------------------------------------------------------
+
+//MidiJackDevice::MidiJackDevice(const int& a, const QString& n)
+//MidiJackDevice::MidiJackDevice(jack_port_t* jack_port, const QString& n)
+// p3.3.55
+//MidiJackDevice::MidiJackDevice(jack_port_t* in_jack_port, jack_port_t* out_jack_port, const QString& n)
+MidiJackDevice::MidiJackDevice(const QString& n)
+ : MidiDevice(n)
+{
+ //_client_jackport = 0;
+
+ //_client_jackport = jack_port;
+ // p3.3.55
+ //_in_client_jackport = in_jack_port;
+ //_out_client_jackport = out_jack_port;
+ _in_client_jackport = NULL;
+ _out_client_jackport = NULL;
+
+ //adr = a;
+ init();
+}
+
+MidiJackDevice::~MidiJackDevice()
+{
+ #ifdef JACK_MIDI_DEBUG
+ printf("MidiJackDevice::~MidiJackDevice()\n");
+ #endif
+
+ //if(_client_jackport)
+ // audioDevice->unregisterPort(_client_jackport);
+ // p3.3.55
+
+ if(audioDevice)
+ {
+ if(_in_client_jackport)
+ audioDevice->unregisterPort(_in_client_jackport);
+ if(_out_client_jackport)
+ audioDevice->unregisterPort(_out_client_jackport);
+ }
+
+ //close();
+}
+
+/*
+//---------------------------------------------------------
+// select[RW]fd
+//---------------------------------------------------------
+
+int MidiJackDevice::selectRfd()
+{
+ return jackmidi_pi[0];
+}
+
+int MidiJackDevice::selectWfd()
+{
+ return jackmidi_po[0];
+}
+*/
+
+//---------------------------------------------------------
+// createJackMidiDevice
+// If name parameter is blank, creates a new (locally) unique one.
+//---------------------------------------------------------
+
+//QString MidiJackDevice::createJackMidiDevice(int rwflags) // 1:Writable 2: Readable. Do not mix.
+//MidiDevice* MidiJackDevice::createJackMidiDevice(QString name, int rwflags) // 1:Writable 2: Readable. Do not mix.
+MidiDevice* MidiJackDevice::createJackMidiDevice(QString name, int rwflags) // p3.3.55 1:Writable 2: Readable 3: Writable + Readable
+{
+/// _openFlags &= _rwFlags; // restrict to available bits
+
+/// #ifdef JACK_MIDI_DEBUG
+/// printf("MidiJackDevice::open %s\n", name.toLatin1().constData());
+/// #endif
+
+ //jack_port_t* jp = jack_port_by_name(_client, name().toLatin1().constData());
+/// jack_port_t* jp = (jack_port_t*)audioDevice->findPort(name().toLatin1().constData());
+
+/// if(!jp)
+/// {
+/// printf("MidiJackDevice::open: Jack midi port %s not found!\n", name().toLatin1().constData());
+/// _writeEnable = false;
+/// _readEnable = false;
+/// return QString("Jack midi port not found");
+/// }
+
+/// int pf = jack_port_flags(jp);
+
+ //if(!name.isEmpty())
+ //{
+ // Does not work.
+ // if(audioDevice->findPort(name.toLatin1().constData()))
+ // {
+ // fprintf(stderr, "MidiJackDevice::createJackMidiDevice failed! Given port name %s already exists!\n", name.toLatin1().constData());
+ // return 0;
+ // }
+ //}
+
+ //jack_port_t* client_jackport = NULL;
+ // p3.3.55
+ ///jack_port_t* in_client_jackport = NULL;
+ ///jack_port_t* out_client_jackport = NULL;
+
+ //char buf[80];
+
+
+ // p3.3.55
+ int ni = 0;
+ if(name.isEmpty())
+ {
+ for( ; ni < 65536; ++ni)
+ {
+ name.sprintf("jack-midi-%d", ni);
+ if(!midiDevices.find(name))
+ break;
+ }
+ }
+ if(ni >= 65536)
+ {
+ fprintf(stderr, "MusE: createJackMidiDevice failed! Can't find an unused midi device name 'jack-midi-[0-65535]'.\n");
+ return 0;
+ }
+
+ // If Jack port can receive data from us and we actually want to...
+ //if((pf & JackPortIsInput) && (_openFlags & 1))
+ ///if(rwflags & 1)
+ ///{
+ /* p3.3.55 Removed.
+ if(name.isEmpty())
+ {
+ //snprintf(buf, 80, "muse-jack-midi-out-%d", _nextOutIdNum);
+ for(int i = 0; ; ++i)
+ {
+ //snprintf(buf, 80, "midi-out-%d", i);
+ name.sprintf("midi-out-%d", i);
+
+ if(!midiDevices.find(name))
+ {
+ // Does not work.
+ //if(!audioDevice->findPort(buf))
+ // break;
+ //client_jackport = (jack_port_t*)audioDevice->registerOutPort(buf, true);
+ if(audioDevice->deviceType() == AudioDevice::JACK_AUDIO) // p3.3.52
+ {
+ //client_jackport = (jack_port_t*)audioDevice->registerOutPort(name.toLatin1().constData(), true);
+ out_client_jackport = (jack_port_t*)audioDevice->registerOutPort((name + QString("_out")).toLatin1().constData(), true); // p3.3.55
+ //if(client_jackport)
+ if(out_client_jackport) // p3.3.55
+ break;
+ }
+ else
+ break;
+ }
+
+ if(i == 65535)
+ {
+ fprintf(stderr, "MidiJackDevice::createJackMidiDevice failed! Can't find unused output port name!\n");
+ return 0;
+ }
+ }
+ //name = QString(buf);
+ }
+ else
+ */
+
+ /*
+ {
+ if(audioDevice->deviceType() == AudioDevice::JACK_AUDIO) // p3.3.52
+ {
+ //client_jackport = (jack_port_t*)audioDevice->registerOutPort(name.toLatin1().constData(), true);
+ out_client_jackport = (jack_port_t*)audioDevice->registerOutPort((name + QString(JACK_MIDI_OUT_PORT_SUFFIX)).toLatin1().constData(), true); // p3.3.55
+ //if(!client_jackport)
+ if(!out_client_jackport) // p3.3.55
+ {
+ //fprintf(stderr, "MidiJackDevice::createJackMidiDevice failed creating output port name %s\n", name.toLatin1().constData());
+ fprintf(stderr, "MusE: createJackMidiDevice failed creating output port name %s\n", (name + QString(JACK_MIDI_OUT_PORT_SUFFIX)).toLatin1().constData()); // p3.3.55
+
+ //return 0;
+ rwflags &= ~1; // p3.3.55 Remove the output r/w flag, but continue on...
+ }
+ }
+ }
+ */
+
+ /*
+ else
+ {
+ client_jackport = (jack_port_t*)audioDevice->registerOutPort(name.toLatin1().constData(), true);
+ if(!client_jackport)
+ {
+ for(int i = 0; ; ++i)
+ {
+ snprintf(buf, 80, "midi-out-%d", i);
+ // Does not work!
+ //if(!audioDevice->findPort(buf))
+ // break;
+ client_jackport = (jack_port_t*)audioDevice->registerOutPort(buf, true);
+ if(client_jackport)
+ break;
+
+ if(i == 65535)
+ {
+ fprintf(stderr, "MidiJackDevice::createJackMidiDevice failed! Can't find unused output port name!\n");
+ return 0;
+ }
+ }
+ name = QString(buf);
+ }
+ }
+ */
+
+ //client_jackport = (jack_port_t*)audioDevice->registerOutPort(name.toLatin1().constData(), true);
+ //if(client_jackport == NULL)
+ //{
+ // fprintf(stderr, "MidiJackDevice::createJackMidiDevice failed to register jack midi client output port %s\n", name.toLatin1().constData());
+ // return 0;
+ //}
+ //else
+ // _nextOutIdNum++;
+
+ ///}
+ //else // Note docs say it can't be both input and output. // p3.3.55 Removed
+
+ // If Jack port can send data to us and we actually want it...
+ //if((pf & JackPortIsOutput) && (_openFlags & 2))
+ ///if(rwflags & 2)
+ ///{
+ /* p3.3.55 Removed.
+ if(name.isEmpty())
+ {
+ //snprintf(buf, 80, "muse-jack-midi-in-%d", _nextInIdNum);
+ for(int i = 0; ; ++i)
+ {
+ //snprintf(buf, 80, "midi-in-%d", i);
+ name.sprintf("midi-in-%d", i);
+
+ if(!midiDevices.find(name))
+ {
+ // Does not work.
+ //if(!audioDevice->findPort(buf))
+ // break;
+ //client_jackport = (jack_port_t*)audioDevice->registerInPort(buf, true);
+ if(audioDevice->deviceType() == AudioDevice::JACK_AUDIO) // p3.3.52
+ {
+ //client_jackport = (jack_port_t*)audioDevice->registerInPort(name.toLatin1().constData(), true);
+ in_client_jackport = (jack_port_t*)audioDevice->registerInPort(name.toLatin1().constData(), true); // p3.3.55
+ //if(client_jackport)
+ if(in_client_jackport) // p3.3.55
+ break;
+ }
+ else
+ break;
+ }
+
+ if(i == 65535)
+ {
+ fprintf(stderr, "MidiJackDevice::createJackMidiDevice failed! Can't find unused input port name!\n");
+ return 0;
+ }
+ }
+ //name = QString(buf);
+ }
+ else
+ */
+
+ /*
+ {
+ if(audioDevice->deviceType() == AudioDevice::JACK_AUDIO) // p3.3.52
+ {
+ //client_jackport = (jack_port_t*)audioDevice->registerInPort(name.toLatin1().constData(), true);
+ in_client_jackport = (jack_port_t*)audioDevice->registerInPort((name + QString(JACK_MIDI_IN_PORT_SUFFIX)).toLatin1().constData(), true); // p3.3.55
+ //if(!client_jackport)
+ if(!in_client_jackport) // p3.3.55
+ {
+ //fprintf(stderr, "MidiJackDevice::createJackMidiDevice failed creating input port name %s\n", name.toLatin1().constData());
+ fprintf(stderr, "MusE: createJackMidiDevice failed creating input port name %s\n", (name + QString(JACK_MIDI_IN_PORT_SUFFIX)).toLatin1().constData());
+
+ //return 0;
+ rwflags &= ~2; // p3.3.55 Remove the input r/w flag, but continue on...
+ }
+ }
+ }
+ */
+
+ //client_jackport = (jack_port_t*)audioDevice->registerInPort(name.toLatin1().constData(), true);
+
+ //if(client_jackport == NULL)
+ //{
+ // fprintf(stderr, "MidiJackDevice::createJackMidiDevice failed to register jack midi client input port %s\n", name.toLatin1().constData());
+ //_readEnable = false;
+ //return QString("Could not register jack-midi-in client port");
+ // return 0;
+ //}
+ //else
+ // _nextInIdNum++;
+
+ ///}
+
+ //if(client_jackport == NULL) // p3.3.52 Removed. Allow the device to be created even if Jack isn't running.
+ // return 0;
+
+ //MidiJackDevice* dev = new MidiJackDevice(client_jackport, name);
+ //MidiJackDevice* dev = new MidiJackDevice(in_client_jackport, out_client_jackport, name); // p3.3.55
+ //MidiJackDevice* dev = new MidiJackDevice(NULL, NULL, name); // p3.3.55
+ MidiJackDevice* dev = new MidiJackDevice(name); // p3.3.55
+ dev->setrwFlags(rwflags);
+ midiDevices.add(dev);
+ return dev;
+}
+
+//---------------------------------------------------------
+// setName
+//---------------------------------------------------------
+
+void MidiJackDevice::setName(const QString& s)
+{
+ #ifdef JACK_MIDI_DEBUG
+ printf("MidiJackDevice::setName %s new name:%s\n", name().toLatin1().constData(), s.toLatin1().constData());
+ #endif
+ _name = s;
+
+ //if(clientPort()) // p3.3.52 Added check.
+ // audioDevice->setPortName(clientPort(), s.toLatin1().constData());
+ // p3.3.55
+ if(inClientPort())
+ audioDevice->setPortName(inClientPort(), (s + QString(JACK_MIDI_IN_PORT_SUFFIX)).toLatin1().constData());
+ if(outClientPort())
+ audioDevice->setPortName(outClientPort(), (s + QString(JACK_MIDI_OUT_PORT_SUFFIX)).toLatin1().constData());
+}
+
+//---------------------------------------------------------
+// open
+//---------------------------------------------------------
+
+QString MidiJackDevice::open()
+{
+ _openFlags &= _rwFlags; // restrict to available bits
+
+ #ifdef JACK_MIDI_DEBUG
+ printf("MidiJackDevice::open %s\n", name().toLatin1().constData());
+ #endif
+
+ /*
+ //jack_port_t* jp = jack_port_by_name(_client, name().toLatin1().constData());
+ jack_port_t* jp = (jack_port_t*)audioDevice->findPort(name().toLatin1().constData());
+
+ if(!jp)
+ {
+ printf("MidiJackDevice::open: Jack midi port %s not found!\n", name().toLatin1().constData());
+ _writeEnable = false;
+ _readEnable = false;
+ return QString("Jack midi port not found");
+ }
+
+ int pf = jack_port_flags(jp);
+
+ // If Jack port can receive data from us and we actually want to...
+ if((pf & JackPortIsInput) && (_openFlags & 1))
+ {
+ char buf[80];
+ snprintf(buf, 80, "muse-jack-midi-out-%d", _nextOutIdNum);
+ _client_jackport = (jack_port_t*)audioDevice->registerOutPort(buf, true);
+ if(_client_jackport == NULL)
+ {
+ fprintf(stderr, "MidiJackDevice::open failed to register jack-midi-out\n");
+ _writeEnable = false;
+ return QString("Could not register jack-midi-out client port");
+ }
+ else
+ {
+ _nextOutIdNum++;
+ // src, dest
+ ///audioDevice->connect(_client_jackport, jp);
+ _writeEnable = true;
+ }
+ }
+ else // Note docs say it can't be both input and output.
+ // If Jack port can send data to us and we actually want it...
+ if((pf & JackPortIsOutput) && (_openFlags & 2))
+ {
+ char buf[80];
+ snprintf(buf, 80, "muse-jack-midi-in-%d", _nextInIdNum);
+ _client_jackport = (jack_port_t*)audioDevice->registerInPort(buf, true);
+ if(_client_jackport == NULL)
+ {
+ fprintf(stderr, "MidiJackDevice::open failed to register jack-midi-in\n");
+ _readEnable = false;
+ return QString("Could not register jack-midi-in client port");
+ }
+ else
+ {
+ _nextInIdNum++;
+ ///audioDevice->connect(jp, _client_jackport);
+ _readEnable = true;
+ }
+ }
+ */
+
+
+ QString s;
+ // p3.3.55 Moved from createJackMidiDevice()
+ if(_openFlags & 1)
+ {
+ if(!_out_client_jackport)
+ {
+ if(audioDevice->deviceType() == AudioDevice::JACK_AUDIO)
+ {
+ s = name() + QString(JACK_MIDI_OUT_PORT_SUFFIX);
+ _out_client_jackport = (jack_port_t*)audioDevice->registerOutPort(s.toLatin1().constData(), true);
+ if(!_out_client_jackport)
+ {
+ fprintf(stderr, "MusE: MidiJackDevice::open failed creating output port name %s\n", s.toLatin1().constData());
+ _openFlags &= ~1; // Remove the flag, but continue on...
+ }
+ }
+ }
+ }
+ else
+ {
+ if(_out_client_jackport)
+ {
+ // We want to unregister the port (which will also disconnect it), AND remove Routes, and then NULL-ify _out_client_jackport.
+ // We could let our graph change callback (the gui thread one) remove the Routes (which it would anyway).
+ // But that happens later (gui thread) and it needs a valid _out_client_jackport,
+ // so use of a registration callback would be required to finally NULL-ify _out_client_jackport,
+ // and that would require some MidiDevice setter or re-scanner function.
+ // So instead, manually remove the Routes (in the audio thread), then unregister the port, then immediately NULL-ify _out_client_jackport.
+ // Our graph change callback (the gui thread one) will see a NULL _out_client_jackport
+ // so it cannot possibly remove the Routes, but that won't matter - we are removing them manually.
+ // This is the same technique that is used for audio elsewhere in the code, like Audio::msgSetChannels()
+ // (but not Song::connectJackRoutes() which keeps the Routes for when undoing deletion of a track).
+ //
+ // NOTE: TESTED: Possibly a bug in QJackCtl, with Jack-1 (not Jack-2 !):
+ // After toggling the input/output green lights in the midi ports list (which gets us here), intermittently
+ // qjackctl refuses to draw connections. It allows them to be made (MusE responds) but blanks them out immediately
+ // and does not show 'disconnect', as if it is not properly aware of the connections.
+ // But ALL else is OK - the connection is fine in MusE, verbose Jack messages show all went OK.
+ // Yes, there's no doubt the connections are being made.
+ // When I toggle the lights again (which kills, then recreates the ports here), the problem can disappear or come back again.
+ // Also once observed a weird double connection from the port to two different Jack ports but one of
+ // the connections should not have been there and kept toggling along with the other (like a 'ghost' connection).
+ audio->msgRemoveRoutes(Route(this, 0), Route()); // New function msgRemoveRoutes simply uses Routes, for their pointers.
+ audioDevice->unregisterPort(_out_client_jackport);
+ }
+ _out_client_jackport = NULL;
+ }
+
+ if(_openFlags & 2)
+ {
+ if(!_in_client_jackport)
+ {
+ if(audioDevice->deviceType() == AudioDevice::JACK_AUDIO)
+ {
+ s = name() + QString(JACK_MIDI_IN_PORT_SUFFIX);
+ _in_client_jackport = (jack_port_t*)audioDevice->registerInPort(s.toLatin1().constData(), true);
+ if(!_in_client_jackport)
+ {
+ fprintf(stderr, "MusE: MidiJackDevice::open failed creating input port name %s\n", s.toLatin1().constData());
+ _openFlags &= ~2; // Remove the flag, but continue on...
+ }
+ }
+ }
+ }
+ else
+ {
+ if(_in_client_jackport)
+ {
+ audio->msgRemoveRoutes(Route(), Route(this, 0));
+ audioDevice->unregisterPort(_in_client_jackport);
+ }
+ _in_client_jackport = NULL;
+ }
+
+ //if(client_jackport == NULL) // p3.3.52 Removed. Allow the device to be created even if Jack isn't running.
+ // return 0;
+
+ _writeEnable = bool(_openFlags & 1);
+ _readEnable = bool(_openFlags & 2);
+
+ return QString("OK");
+}
+
+//---------------------------------------------------------
+// close
+//---------------------------------------------------------
+
+void MidiJackDevice::close()
+{
+ #ifdef JACK_MIDI_DEBUG
+ printf("MidiJackDevice::close %s\n", name().toLatin1().constData());
+ #endif
+
+ // p3.3.55 TODO: I don't really want to unregister the
+ // Jack midi ports because then we lose the connections
+ // to Jack every time we click the read/write lights
+ // or change a port's device.
+
+ /*
+ if(_client_jackport)
+ {
+ int pf = jack_port_flags(_client_jackport);
+
+ if(pf & JackPortIsOutput)
+ _nextOutIdNum--;
+ else
+ if(pf & JackPortIsInput)
+ _nextInIdNum--;
+ audioDevice->unregisterPort(_client_jackport);
+ _client_jackport = 0;
+ _writeEnable = false;
+ _readEnable = false;
+ return;
+ }
+ */
+
+ _writeEnable = false;
+ _readEnable = false;
+
+ /*
+ //jack_port_t* jp = jack_port_by_name(_client, name().toLatin1().constData());
+ jack_port_t* jp = (jack_port_t*)audioDevice->findPort(name().toLatin1().constData());
+
+ if(!jp)
+ {
+ printf("MidiJackDevice::close: Jack midi port %s not found!\n", name().toLatin1().constData());
+ _writeEnable = false;
+ _readEnable = false;
+ return;
+ }
+
+ //int pf = jack_port_flags(jp);
+
+ // If Jack port can receive data from us and we actually want to...
+ //if((pf & JackPortIsInput) && (_openFlags & 1))
+ if(jack_port_connected_to(midi_port_out[0], name().toLatin1().constData()))
+ {
+ // src, dest
+/// audioDevice->disconnect(midi_port_out[0], jp);
+ _writeEnable = false;
+ }
+ else // Note docs say it can't be both input and output.
+ // If Jack port can send data to us and we actually want it...
+ //if((pf & JackPortIsOutput) && (_openFlags & 2))
+ if(jack_port_connected_to(midi_port_in[0], name().toLatin1().constData()))
+ {
+/// audioDevice->disconnect(jp, midi_port_in[0]);
+ _readEnable = false;
+ }
+ */
+}
+
+//---------------------------------------------------------
+// writeRouting
+//---------------------------------------------------------
+
+void MidiJackDevice::writeRouting(int level, Xml& xml) const
+{
+ // p3.3.45
+ // If this device is not actually in use by the song, do not write any routes.
+ // This prevents bogus routes from being saved and propagated in the med file.
+ if(midiPort() == -1)
+ return;
+
+ QString s;
+ if(rwFlags() & 2) // Readable
+ {
+ //RouteList* rl = _inRoutes;
+ //for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ for (ciRoute r = _inRoutes.begin(); r != _inRoutes.end(); ++r)
+ {
+ if(!r->name().isEmpty())
+ {
+ xml.tag(level++, "Route");
+
+ //xml.strTag(level, "srcNode", r->name());
+ //xml.tag(level, "source type=\"%d\" name=\"%s\"/", r->type, r->name().toLatin1().constData());
+ s = QT_TRANSLATE_NOOP("@default", "source");
+ if(r->type != Route::TRACK_ROUTE)
+ s += QString(QT_TRANSLATE_NOOP("@default", " type=\"%1\"")).arg(r->type);
+
+ //s += QString(QT_TRANSLATE_NOOP("@default", " name=\"%1\"/")).arg(r->name());
+ s += QString(QT_TRANSLATE_NOOP("@default", " name=\"%1\"/")).arg(Xml::xmlString(r->name()));
+ xml.tag(level, s.toLatin1().constData());
+
+ //xml.strTag(level, "dstNode", name());
+ //xml.tag(level, "dest type=\"%d\" name=\"%s\"/", Route::JACK_MIDI_ROUTE, name().toLatin1().constData());
+ //xml.tag(level, "dest type=\"%d\" name=\"%s\"/", Route::MIDI_DEVICE_ROUTE, name().toLatin1().constData());
+ //xml.tag(level, "dest devtype=\"%d\" name=\"%s\"/", MidiDevice::JACK_MIDI, name().toLatin1().constData());
+ xml.tag(level, "dest devtype=\"%d\" name=\"%s\"/", MidiDevice::JACK_MIDI, Xml::xmlString(name()).toLatin1().constData());
+
+ xml.etag(level--, "Route");
+ }
+ }
+ }
+
+ for (ciRoute r = _outRoutes.begin(); r != _outRoutes.end(); ++r)
+ {
+ if(!r->name().isEmpty())
+ {
+ s = QT_TRANSLATE_NOOP("@default", "Route");
+ if(r->channel != -1)
+ s += QString(QT_TRANSLATE_NOOP("@default", " channel=\"%1\"")).arg(r->channel);
+
+ //xml.tag(level++, "Route");
+ xml.tag(level++, s.toLatin1().constData());
+
+ /*
+ //xml.strTag(level, "srcNode", name());
+ if(r->channel != -1)
+ //xml.tag(level, "source type=\"%d\" channel=\"%d\" name=\"%s\"/", Route::JACK_MIDI_ROUTE, r->channel, name().toLatin1().constData());
+ //xml.tag(level, "source type=\"%d\" channel=\"%d\" name=\"%s\"/", Route::MIDI_DEVICE_ROUTE, r->channel, name().toLatin1().constData());
+ xml.tag(level, "source devtype=\"%d\" channel=\"%d\" name=\"%s\"/", MidiDevice::JACK_MIDI, r->channel, name().toLatin1().constData());
+ else
+ //xml.tag(level, "source type=\"%d\" name=\"%s\"/", Route::JACK_MIDI_ROUTE, name().toLatin1().constData());
+ //xml.tag(level, "source type=\"%d\" name=\"%s\"/", Route::MIDI_DEVICE_ROUTE, name().toLatin1().constData());
+ */
+ //xml.tag(level, "source devtype=\"%d\" name=\"%s\"/", MidiDevice::JACK_MIDI, name().toLatin1().constData());
+ xml.tag(level, "source devtype=\"%d\" name=\"%s\"/", MidiDevice::JACK_MIDI, Xml::xmlString(name()).toLatin1().constData());
+
+ /*
+ //xml.strTag(level, "dstNode", r->name());
+ if(r->channel != -1)
+ {
+ if(r->type == Route::MIDI_DEVICE_ROUTE)
+ xml.tag(level, "dest devtype=\"%d\" channel=\"%d\" name=\"%s\"/", r->device->deviceType(), r->channel, r->name().toLatin1().constData());
+ else
+ xml.tag(level, "dest type=\"%d\" channel=\"%d\" name=\"%s\"/", r->type, r->channel, r->name().toLatin1().constData());
+ }
+ else
+ {
+ if(r->type == Route::MIDI_DEVICE_ROUTE)
+ xml.tag(level, "dest devtype=\"%d\" name=\"%s\"/", r->device->deviceType(), r->name().toLatin1().constData());
+ else
+ xml.tag(level, "dest type=\"%d\" name=\"%s\"/", r->type, r->name().toLatin1().constData());
+ }
+ */
+
+ s = QT_TRANSLATE_NOOP("@default", "dest");
+ if(r->type == Route::MIDI_DEVICE_ROUTE)
+ s += QString(QT_TRANSLATE_NOOP("@default", " devtype=\"%1\"")).arg(r->device->deviceType());
+ else
+ if(r->type != Route::TRACK_ROUTE)
+ s += QString(QT_TRANSLATE_NOOP("@default", " type=\"%1\"")).arg(r->type);
+
+ //s += QString(QT_TRANSLATE_NOOP("@default", " name=\"%1\"/")).arg(r->name());
+ s += QString(QT_TRANSLATE_NOOP("@default", " name=\"%1\"/")).arg(Xml::xmlString(r->name()));
+ xml.tag(level, s.toLatin1().constData());
+
+
+ xml.etag(level--, "Route");
+ }
+ }
+
+ /*
+ else
+ if(rwFlags() & 1) // Writable
+ {
+ //RouteList* rl = _outRoutes;
+ //for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ for (ciRoute r = _outRoutes.begin(); r != _outRoutes.end(); ++r)
+ {
+ if(!r->name().isEmpty())
+ {
+ xml.tag(level++, "Route");
+
+ //xml.strTag(level, "srcNode", name());
+ //if(r->channel != -1)
+ // xml.tag(level, "srcNode type=\"%d\" channel=\"%d\" name=\"%s\"", Route::JACK_MIDI_ROUTE, r->channel, name().toLatin1().constData());
+ //else
+ xml.tag(level, "source type=\"%d\" name=\"%s\"/", Route::JACK_MIDI_ROUTE, name().toLatin1().constData());
+
+ //xml.strTag(level, "dstNode", r->name());
+ xml.tag(level, "dest type=\"%d\" name=\"%s\"/", r->type, r->name().toLatin1().constData());
+
+ xml.etag(level--, "Route");
+ }
+ }
+ }
+ */
+}
+
+//---------------------------------------------------------
+// putEvent
+//---------------------------------------------------------
+
+/* FIX: if we fail to transmit the event,
+ * we return false (indicating OK). Otherwise
+ * it seems muse will retry forever
+ */
+bool MidiJackDevice::putMidiEvent(const MidiPlayEvent& /*event*/)
+{
+ /*
+ int give, channel = event.channel();
+ int x;
+
+ if(channel >= JACK_MIDI_CHANNELS) return false;
+
+ // buffer up events, because jack eats them in chunks, if
+ // the buffer is full, there isn't so much to do, than
+ // drop the event
+
+ give = jack_midi_out_data[channel].give;
+ if(jack_midi_out_data[channel].buffer[give*4+3]){
+ fprintf(stderr, "WARNING: muse-to-jack midi-buffer is full, channel=%u\n", channel);
+ return false;
+ }
+ // copy event(note-on etc..), pitch and volume
+ // see http://www.midi.org/techspecs/midimessages.php
+ switch(event.type()){
+ case ME_NOTEOFF:
+ jack_midi_out_data[channel].buffer[give*4+0] = 0x80;
+ jack_midi_out_data[channel].buffer[give*4+1] = event.dataA() & 0x7f;
+ jack_midi_out_data[channel].buffer[give*4+2] = event.dataB() & 0x7f;
+ break;
+ case ME_NOTEON:
+ jack_midi_out_data[channel].buffer[give*4+0] = 0x90;
+ jack_midi_out_data[channel].buffer[give*4+1] = event.dataA() & 0x7f;
+ jack_midi_out_data[channel].buffer[give*4+2] = event.dataB() & 0x7f;
+ break;
+ case ME_CONTROLLER:
+ jack_midi_out_data[channel].buffer[give*4+0] = 0xb0;
+ jack_midi_out_data[channel].buffer[give*4+1] = event.dataA() & 0x7f;
+ jack_midi_out_data[channel].buffer[give*4+2] = event.dataB() & 0x7f;
+ break;
+ case ME_PROGRAM:
+ jack_midi_out_data[channel].buffer[give*4+0] = 0xc0;
+ jack_midi_out_data[channel].buffer[give*4+1] = event.dataA() & 0x7f;
+ jack_midi_out_data[channel].buffer[give*4+2] = 0;
+ break;
+ case ME_PITCHBEND:
+ jack_midi_out_data[channel].buffer[give*4+0] = 0xE0;
+ // convert muse pitch-bend to midi standard
+ x = 0x2000 + event.dataA();
+ jack_midi_out_data[channel].buffer[give*4+1] = x & 0x7f;
+ jack_midi_out_data[channel].buffer[give*4+2] = (x >> 8) & 0x7f;
+ break;
+ default:
+ fprintf(stderr, "jack-midi-out %u WARNING: unknown event %x\n", channel, event.type());
+ return false;
+ }
+ jack_midi_out_data[channel].buffer[give*4+3] = 1; // mark state of this slot
+ // finally increase give position
+ give++;
+ if(give >= JACK_MIDI_BUFFER_SIZE){
+ give = 0;
+ }
+ jack_midi_out_data[channel].give = give;
+ return false;
+ */
+
+ return false;
+}
+
+/*
+//---------------------------------------------------------
+// putEvent
+// return false if event is delivered
+//---------------------------------------------------------
+
+bool MidiJackDevice::putEvent(int* event)
+{
+ int *y; y = event;
+ return false;
+}
+*/
+
+//---------------------------------------------------------
+// recordEvent
+//---------------------------------------------------------
+
+void MidiJackDevice::recordEvent(MidiRecordEvent& event)
+ {
+ // Set the loop number which the event came in at.
+ //if(audio->isRecording())
+ if(audio->isPlaying())
+ event.setLoopNum(audio->loopCount());
+
+ if (midiInputTrace) {
+ printf("Jack MidiInput: ");
+ event.dump();
+ }
+
+ int typ = event.type();
+
+ if(_port != -1)
+ {
+ int idin = midiPorts[_port].syncInfo().idIn();
+
+ //---------------------------------------------------
+ // filter some SYSEX events
+ //---------------------------------------------------
+
+ if (typ == ME_SYSEX) {
+ const unsigned char* p = event.data();
+ int n = event.len();
+ if (n >= 4) {
+ if ((p[0] == 0x7f)
+ //&& ((p[1] == 0x7f) || (p[1] == rxDeviceId))) {
+ && ((p[1] == 0x7f) || (idin == 0x7f) || (p[1] == idin))) {
+ if (p[2] == 0x06) {
+ //mmcInput(p, n);
+ midiSeq->mmcInput(_port, p, n);
+ return;
+ }
+ if (p[2] == 0x01) {
+ //mtcInputFull(p, n);
+ midiSeq->mtcInputFull(_port, p, n);
+ return;
+ }
+ }
+ else if (p[0] == 0x7e) {
+ //nonRealtimeSystemSysex(p, n);
+ midiSeq->nonRealtimeSystemSysex(_port, p, n);
+ return;
+ }
+ }
+ }
+ else
+ // Trigger general activity indicator detector. Sysex has no channel, don't trigger.
+ midiPorts[_port].syncInfo().trigActDetect(event.channel());
+ }
+
+ //
+ // process midi event input filtering and
+ // transformation
+ //
+
+ processMidiInputTransformPlugins(event);
+
+ if (filterEvent(event, midiRecordType, false))
+ return;
+
+ if (!applyMidiInputTransformation(event)) {
+ if (midiInputTrace)
+ printf(" midi input transformation: event filtered\n");
+ return;
+ }
+
+ //
+ // transfer noteOn events to gui for step recording and keyboard
+ // remote control
+ //
+ if (typ == ME_NOTEON) {
+ int pv = ((event.dataA() & 0xff)<<8) + (event.dataB() & 0xff);
+ song->putEvent(pv);
+ }
+
+ //if(_recordFifo.put(MidiPlayEvent(event)))
+ // printf("MidiJackDevice::recordEvent: fifo overflow\n");
+
+ // p3.3.38
+ // Do not bother recording if it is NOT actually being used by a port.
+ // Because from this point on, process handles things, by selected port.
+ if(_port == -1)
+ return;
+
+ // Split the events up into channel fifos. Special 'channel' number 17 for sysex events.
+ unsigned int ch = (typ == ME_SYSEX)? MIDI_CHANNELS : event.channel();
+ if(_recordFifo[ch].put(MidiPlayEvent(event)))
+ printf("MidiJackDevice::recordEvent: fifo channel %d overflow\n", ch);
+ }
+
+//---------------------------------------------------------
+// midiReceived
+//---------------------------------------------------------
+
+void MidiJackDevice::eventReceived(jack_midi_event_t* ev)
+ {
+ MidiRecordEvent event;
+ event.setB(0);
+
+ // NOTE: From MusE-2. Not done here in Muse-1 (yet).
+ // move all events 2*segmentSize into the future to get
+ // jitterfree playback
+ //
+ // cycle n-1 n n+1
+ // -+----------+----------+----------+-
+ // ^ ^ ^
+ // catch process play
+ //
+// const SeqTime* st = audio->seqTime();
+
+ //unsigned curFrame = st->startFrame() + segmentSize;
+// unsigned curFrame = st->lastFrameTime;
+ //int frameOffset = audio->getFrameOffset();
+ unsigned pos = audio->pos().frame();
+
+ //event.setTime(pos + ev->time);
+ event.setTime(extSyncFlag.value() ? lastExtMidiSyncTick : (pos + ev->time));
+
+ event.setChannel(*(ev->buffer) & 0xf);
+ int type = *(ev->buffer) & 0xf0;
+ int a = *(ev->buffer + 1) & 0x7f;
+ int b = *(ev->buffer + 2) & 0x7f;
+ event.setType(type);
+ switch(type) {
+ case ME_NOTEON:
+ case ME_NOTEOFF:
+ case ME_CONTROLLER:
+ event.setA(*(ev->buffer + 1));
+ event.setB(*(ev->buffer + 2));
+ break;
+ case ME_PROGRAM:
+ case ME_AFTERTOUCH:
+ event.setA(*(ev->buffer + 1));
+ break;
+
+ case ME_PITCHBEND:
+ event.setA(((b << 7) + a) - 8192);
+ break;
+
+ case ME_SYSEX:
+ {
+ int type = *(ev->buffer) & 0xff;
+ switch(type)
+ {
+ case ME_SYSEX:
+
+ // TODO: Deal with large sysex, which are broken up into chunks!
+ // For now, do not accept if the last byte is not EOX, meaning it's a chunk with more chunks to follow.
+ if(*(((unsigned char*)ev->buffer) + ev->size - 1) != ME_SYSEX_END)
+ {
+ printf("MidiJackDevice::eventReceived sysex chunks not supported!\n");
+ return;
+ }
+
+ //event.setTime(0); // mark as used
+ event.setType(ME_SYSEX);
+ event.setData((unsigned char*)(ev->buffer + 1), ev->size - 2);
+ break;
+ case ME_MTC_QUARTER:
+ if(_port != -1)
+ midiSeq->mtcInputQuarter(_port, *(ev->buffer + 1));
+ return;
+ case ME_SONGPOS:
+ if(_port != -1)
+ midiSeq->setSongPosition(_port, *(ev->buffer + 1) | (*(ev->buffer + 2) >> 2 )); // LSB then MSB
+ return;
+ //case ME_SONGSEL:
+ //case ME_TUNE_REQ:
+ //case ME_SENSE:
+ case ME_CLOCK:
+ case ME_TICK:
+ case ME_START:
+ case ME_CONTINUE:
+ case ME_STOP:
+ if(_port != -1)
+ midiSeq->realtimeSystemInput(_port, type);
+ return;
+ //case ME_SYSEX_END:
+ //break;
+ // return;
+ default:
+ printf("MidiJackDevice::eventReceived unsupported system event 0x%02x\n", type);
+ return;
+ }
+ }
+ //return;
+ break;
+ default:
+ printf("MidiJackDevice::eventReceived unknown event 0x%02x\n", type);
+ //printf("MidiJackDevice::eventReceived unknown event 0x%02x size:%d buf:0x%02x 0x%02x 0x%02x ...0x%02x\n", type, ev->size, *(ev->buffer), *(ev->buffer + 1), *(ev->buffer + 2), *(ev->buffer + (ev->size - 1)));
+ return;
+ }
+
+ if (midiInputTrace) {
+ printf("MidiInput<%s>: ", name().toLatin1().constData());
+ event.dump();
+ }
+
+ #ifdef JACK_MIDI_DEBUG
+ printf("MidiJackDevice::eventReceived time:%d type:%d ch:%d A:%d B:%d\n", event.time(), event.type(), event.channel(), event.dataA(), event.dataB());
+ #endif
+
+ // Let recordEvent handle it from here, with timestamps, filtering, gui triggering etc.
+ recordEvent(event);
+ }
+
+//---------------------------------------------------------
+// collectMidiEvents
+//---------------------------------------------------------
+
+void MidiJackDevice::collectMidiEvents()
+{
+ if(!_readEnable)
+ return;
+
+ //if(!_client_jackport)
+ if(!_in_client_jackport) // p3.3.55
+ return;
+
+ //void* port_buf = jack_port_get_buffer(_client_jackport, segmentSize);
+ void* port_buf = jack_port_get_buffer(_in_client_jackport, segmentSize); // p3.3.55
+
+ jack_midi_event_t event;
+ jack_nframes_t eventCount = jack_midi_get_event_count(port_buf);
+ for (jack_nframes_t i = 0; i < eventCount; ++i)
+ {
+ jack_midi_event_get(&event, port_buf, i);
+
+ #ifdef JACK_MIDI_DEBUG
+ printf("MidiJackDevice::collectMidiEvents number:%d time:%d\n", i, event.time);
+ #endif
+
+ eventReceived(&event);
+ }
+}
+
+//---------------------------------------------------------
+// putEvent
+// return true if event cannot be delivered
+//---------------------------------------------------------
+
+bool MidiJackDevice::putEvent(const MidiPlayEvent& ev)
+{
+ if(!_writeEnable)
+ //return true;
+ return false;
+
+ #ifdef JACK_MIDI_DEBUG
+ printf("MidiJackDevice::putEvent time:%d type:%d ch:%d A:%d B:%d\n", ev.time(), ev.type(), ev.channel(), ev.dataA(), ev.dataB());
+ #endif
+
+ bool rv = eventFifo.put(ev);
+ if(rv)
+ printf("MidiJackDevice::putEvent: port overflow\n");
+
+ return rv;
+}
+
+//---------------------------------------------------------
+// queueEvent
+// return true if successful
+//---------------------------------------------------------
+
+//void JackAudioDevice::putEvent(Port port, const MidiEvent& e)
+bool MidiJackDevice::queueEvent(const MidiPlayEvent& e)
+//bool MidiJackDevice::queueEvent(const MidiPlayEvent& e)
+{
+ // Perhaps we can find use for this value later, together with the Jack midi MusE port(s).
+ // No big deal if not. Not used for now.
+ //int port = e.port();
+
+ //if(port >= JACK_MIDI_CHANNELS)
+ // return false;
+
+ //if (midiOutputTrace) {
+ // printf("MidiOut<%s>: jackMidi: ", portName(port).toLatin1().constData());
+ // e.dump();
+ // }
+
+ //if(debugMsg)
+ // printf("MidiJackDevice::queueEvent\n");
+
+ //if(!_client_jackport)
+ if(!_out_client_jackport) // p3.3.55
+ return false;
+ //void* pb = jack_port_get_buffer(_client_jackport, segmentSize);
+ void* pb = jack_port_get_buffer(_out_client_jackport, segmentSize); // p3.3.55
+
+ //unsigned frameCounter = ->frameTime();
+ int frameOffset = audio->getFrameOffset();
+ unsigned pos = audio->pos().frame();
+ int ft = e.time() - frameOffset - pos;
+
+ if (ft < 0)
+ ft = 0;
+ if (ft >= (int)segmentSize) {
+ printf("MidiJackDevice::queueEvent: Event time:%d out of range. offset:%d ft:%d (seg=%d)\n", e.time(), frameOffset, ft, segmentSize);
+ if (ft > (int)segmentSize)
+ ft = segmentSize - 1;
+ }
+
+ #ifdef JACK_MIDI_DEBUG
+ printf("MidiJackDevice::queueEvent time:%d type:%d ch:%d A:%d B:%d\n", e.time(), e.type(), e.channel(), e.dataA(), e.dataB());
+ #endif
+
+ switch(e.type()) {
+ case ME_NOTEON:
+ case ME_NOTEOFF:
+ case ME_POLYAFTER:
+ case ME_CONTROLLER:
+ case ME_PITCHBEND:
+ {
+ #ifdef JACK_MIDI_DEBUG
+ printf("MidiJackDevice::queueEvent note on/off polyafter controller or pitch\n");
+ #endif
+
+ unsigned char* p = jack_midi_event_reserve(pb, ft, 3);
+ if (p == 0) {
+ fprintf(stderr, "MidiJackDevice::queueEvent #1: buffer overflow, event lost\n");
+ return false;
+ }
+ p[0] = e.type() | e.channel();
+ p[1] = e.dataA();
+ p[2] = e.dataB();
+ }
+ break;
+
+ case ME_PROGRAM:
+ case ME_AFTERTOUCH:
+ {
+ #ifdef JACK_MIDI_DEBUG
+ printf("MidiJackDevice::queueEvent program or aftertouch\n");
+ #endif
+
+ unsigned char* p = jack_midi_event_reserve(pb, ft, 2);
+ if (p == 0) {
+ fprintf(stderr, "MidiJackDevice::queueEvent #2: buffer overflow, event lost\n");
+ return false;
+ }
+ p[0] = e.type() | e.channel();
+ p[1] = e.dataA();
+ }
+ break;
+ case ME_SYSEX:
+ {
+ #ifdef JACK_MIDI_DEBUG
+ printf("MidiJackDevice::queueEvent sysex\n");
+ #endif
+
+ const unsigned char* data = e.data();
+ int len = e.len();
+ unsigned char* p = jack_midi_event_reserve(pb, ft, len+2);
+ if (p == 0) {
+ fprintf(stderr, "MidiJackDevice::queueEvent #3: buffer overflow, event lost\n");
+ return false;
+ }
+ p[0] = 0xf0;
+ p[len+1] = 0xf7;
+ memcpy(p+1, data, len);
+ }
+ break;
+ case ME_SONGPOS:
+ case ME_CLOCK:
+ case ME_START:
+ case ME_CONTINUE:
+ case ME_STOP:
+ printf("MidiJackDevice::queueEvent: event type %x not supported\n", e.type());
+ return false;
+ break;
+ }
+
+ return true;
+}
+
+//---------------------------------------------------------
+// processEvent
+//---------------------------------------------------------
+
+void MidiJackDevice::processEvent(const MidiPlayEvent& event)
+{
+ //int frameOffset = audio->getFrameOffset();
+ //unsigned pos = audio->pos().frame();
+
+ int chn = event.channel();
+ unsigned t = event.time();
+ int a = event.dataA();
+ int b = event.dataB();
+ // Perhaps we can find use for this value later, together with the Jack midi MusE port(s).
+ // No big deal if not. Not used for now.
+ int port = event.port();
+
+ // TODO: No sub-tick playback resolution yet, with external sync.
+ // Just do this 'standard midi 64T timing thing' for now until we figure out more precise external timings.
+ // Does require relatively short audio buffers, in order to catch the resolution, but buffer <= 256 should be OK...
+ // Tested OK so far with 128.
+ if(extSyncFlag.value())
+ t = audio->getFrameOffset() + audio->pos().frame();
+ //t = frameOffset + pos;
+
+ #ifdef JACK_MIDI_DEBUG
+ printf("MidiJackDevice::processEvent time:%d type:%d ch:%d A:%d B:%d\n", event.time(), event.type(), event.channel(), event.dataA(), event.dataB());
+ #endif
+
+ if(event.type() == ME_PROGRAM)
+ {
+ // don't output program changes for GM drum channel
+ //if (!(song->mtype() == MT_GM && chn == 9)) {
+ int hb = (a >> 16) & 0xff;
+ int lb = (a >> 8) & 0xff;
+ int pr = a & 0x7f;
+
+ // p3.3.44
+ //printf("MidiJackDevice::processEvent ME_PROGRAM time:%d type:%d ch:%d A:%d B:%d hb:%d lb:%d pr:%d\n",
+ // event.time(), event.type(), event.channel(), event.dataA(), event.dataB(), hb, lb, pr);
+
+ if (hb != 0xff)
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HBANK, hb));
+ if (lb != 0xff)
+ queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LBANK, lb));
+ queueEvent(MidiPlayEvent(t+2, port, chn, ME_PROGRAM, pr, 0));
+ // }
+ }
+ else
+ if(event.type() == ME_PITCHBEND)
+ {
+ int v = a + 8192;
+ // p3.3.44
+ //printf("MidiJackDevice::processEvent ME_PITCHBEND v:%d time:%d type:%d ch:%d A:%d B:%d\n", v, event.time(), event.type(), event.channel(), event.dataA(), event.dataB());
+
+ queueEvent(MidiPlayEvent(t, port, chn, ME_PITCHBEND, v & 0x7f, (v >> 7) & 0x7f));
+ }
+ else
+ if(event.type() == ME_CONTROLLER)
+ {
+ //int a = event.dataA();
+ //int b = event.dataB();
+ // Perhaps we can find use for this value later, together with the Jack midi MusE port(s).
+ // No big deal if not. Not used for now.
+ //int port = event.port();
+
+ int nvh = 0xff;
+ int nvl = 0xff;
+ if(_port != -1)
+ {
+ int nv = midiPorts[_port].nullSendValue();
+ if(nv != -1)
+ {
+ nvh = (nv >> 8) & 0xff;
+ nvl = nv & 0xff;
+ }
+ }
+
+ if(a == CTRL_PITCH)
+ {
+ int v = b + 8192;
+ // p3.3.44
+ //printf("MidiJackDevice::processEvent CTRL_PITCH v:%d time:%d type:%d ch:%d A:%d B:%d\n", v, event.time(), event.type(), event.channel(), event.dataA(), event.dataB());
+
+ queueEvent(MidiPlayEvent(t, port, chn, ME_PITCHBEND, v & 0x7f, (v >> 7) & 0x7f));
+ }
+ else if (a == CTRL_PROGRAM)
+ {
+ // don't output program changes for GM drum channel
+ //if (!(song->mtype() == MT_GM && chn == 9)) {
+ int hb = (b >> 16) & 0xff;
+ int lb = (b >> 8) & 0xff;
+ int pr = b & 0x7f;
+
+ // p3.3.44
+ //printf("MidiJackDevice::processEvent CTRL_PROGRAM time:%d type:%d ch:%d A:%d B:%d hb:%d lb:%d pr:%d\n",
+ // event.time(), event.type(), event.channel(), event.dataA(), event.dataB(), hb, lb, pr);
+
+ if (hb != 0xff)
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HBANK, hb));
+ if (lb != 0xff)
+ queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LBANK, lb));
+ queueEvent(MidiPlayEvent(t+2, port, chn, ME_PROGRAM, pr, 0));
+ // }
+ }
+ /*
+ else if (a == CTRL_MASTER_VOLUME)
+ {
+ unsigned char sysex[] = {
+ 0x7f, 0x7f, 0x04, 0x01, 0x00, 0x00
+ };
+ sysex[1] = deviceId();
+ sysex[4] = b & 0x7f;
+ sysex[5] = (b >> 7) & 0x7f;
+ queueEvent(MidiPlayEvent(t, port, ME_SYSEX, sysex, 6));
+ }
+ */
+ else if (a < CTRL_14_OFFSET)
+ { // 7 Bit Controller
+ queueEvent(event);
+ //queueEvent(museport, MidiPlayEvent(t, port, chn, event));
+ }
+ else if (a < CTRL_RPN_OFFSET)
+ { // 14 bit high resolution controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ int dataH = (b >> 7) & 0x7f;
+ int dataL = b & 0x7f;
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, ctrlH, dataH));
+ queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, ctrlL, dataL));
+ }
+ else if (a < CTRL_NRPN_OFFSET)
+ { // RPN 7-Bit Controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH));
+ queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL));
+ queueEvent(MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, b));
+
+ t += 3;
+ // Select null parameters so that subsequent data controller events do not upset the last *RPN controller.
+ //sendNullRPNParams(chn, false);
+ if(nvh != 0xff)
+ {
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HRPN, nvh & 0x7f));
+ t += 1;
+ }
+ if(nvl != 0xff)
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_LRPN, nvl & 0x7f));
+ }
+ //else if (a < CTRL_RPN14_OFFSET)
+ else if (a < CTRL_INTERNAL_OFFSET)
+ { // NRPN 7-Bit Controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
+ queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL));
+ queueEvent(MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, b));
+
+ t += 3;
+ //sendNullRPNParams(chn, true);
+ if(nvh != 0xff)
+ {
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HNRPN, nvh & 0x7f));
+ t += 1;
+ }
+ if(nvl != 0xff)
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_LNRPN, nvl & 0x7f));
+ }
+ else if (a < CTRL_NRPN14_OFFSET)
+ { // RPN14 Controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ int dataH = (b >> 7) & 0x7f;
+ int dataL = b & 0x7f;
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH));
+ queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL));
+ queueEvent(MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, dataH));
+ queueEvent(MidiPlayEvent(t+3, port, chn, ME_CONTROLLER, CTRL_LDATA, dataL));
+
+ t += 4;
+ //sendNullRPNParams(chn, false);
+ if(nvh != 0xff)
+ {
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HRPN, nvh & 0x7f));
+ t += 1;
+ }
+ if(nvl != 0xff)
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_LRPN, nvl & 0x7f));
+ }
+ else if (a < CTRL_NONE_OFFSET)
+ { // NRPN14 Controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ int dataH = (b >> 7) & 0x7f;
+ int dataL = b & 0x7f;
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
+ queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL));
+ queueEvent(MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, dataH));
+ queueEvent(MidiPlayEvent(t+3, port, chn, ME_CONTROLLER, CTRL_LDATA, dataL));
+
+ t += 4;
+ //sendNullRPNParams(chn, true);
+ if(nvh != 0xff)
+ {
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HNRPN, nvh & 0x7f));
+ t += 1;
+ }
+ if(nvl != 0xff)
+ queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_LNRPN, nvl & 0x7f));
+ }
+ else
+ {
+ printf("MidiJackDevice::processEvent: unknown controller type 0x%x\n", a);
+ }
+ }
+ else
+ {
+ queueEvent(event);
+ //queueEvent(MidiPlayEvent(t, port, chn, event));
+ }
+}
+
+//---------------------------------------------------------
+// processMidi called from audio process only.
+//---------------------------------------------------------
+
+void MidiJackDevice::processMidi()
+{
+ //if(!_client_jackport)
+ if(!_out_client_jackport) // p3.3.55
+ return;
+ //void* port_buf = jack_port_get_buffer(_client_jackport, segmentSize);
+ void* port_buf = jack_port_get_buffer(_out_client_jackport, segmentSize); // p3.3.55
+ jack_midi_clear_buffer(port_buf);
+
+ while(!eventFifo.isEmpty())
+ {
+ MidiPlayEvent e(eventFifo.get());
+ int evTime = e.time();
+ // Is event marked to be played immediately?
+ if(evTime == 0)
+ {
+ // Nothing to do but stamp the event to be queued for frame 0+.
+ //e.setTime(frameOffset + pos);
+ e.setTime(audio->getFrameOffset() + audio->pos().frame());
+ }
+
+ #ifdef JACK_MIDI_DEBUG
+ printf("MidiJackDevice::processMidi eventFifo time:%d type:%d ch:%d A:%d B:%d\n", e.time(), e.type(), e.channel(), e.dataA(), e.dataB());
+ #endif
+
+ //el->insert(eventFifo.get());
+ //el->insert(e);
+ processEvent(e);
+ }
+
+ MPEventList* el = playEvents();
+ if(el->empty())
+ return;
+
+ iMPEvent i = nextPlayEvent();
+ for(; i != el->end(); ++i)
+ {
+ // p3.3.39 Update hardware state so knobs and boxes are updated. Optimize to avoid re-setting existing values.
+ // Same code as in MidiPort::sendEvent()
+ if(_port != -1)
+ {
+ MidiPort* mp = &midiPorts[_port];
+ if(i->type() == ME_CONTROLLER)
+ {
+ int da = i->dataA();
+ int db = i->dataB();
+ db = mp->limitValToInstrCtlRange(da, db);
+ if(!mp->setHwCtrlState(i->channel(), da, db))
+ continue;
+ //mp->setHwCtrlState(i->channel(), da, db);
+ }
+ else
+ if(i->type() == ME_PITCHBEND)
+ {
+ // p3.3.44
+ //printf("MidiJackDevice::processMidi playEvents ME_PITCHBEND time:%d type:%d ch:%d A:%d B:%d\n", (*i).time(), (*i).type(), (*i).channel(), (*i).dataA(), (*i).dataB());
+
+ int da = mp->limitValToInstrCtlRange(CTRL_PITCH, i->dataA());
+ if(!mp->setHwCtrlState(i->channel(), CTRL_PITCH, da))
+ continue;
+ //mp->setHwCtrlState(i->channel(), CTRL_PITCH, da);
+
+ //(MidiPlayEvent(t, port, chn, ME_PITCHBEND, v & 0x7f, (v >> 7) & 0x7f));
+ }
+ else
+ if(i->type() == ME_PROGRAM)
+ {
+ if(!mp->setHwCtrlState(i->channel(), CTRL_PROGRAM, i->dataA()))
+ continue;
+ //mp->setHwCtrlState(i->channel(), CTRL_PROGRAM, i->dataA());
+ }
+ }
+
+ processEvent(*i);
+ }
+
+ setNextPlayEvent(i);
+}
+
+//---------------------------------------------------------
+// initMidiJack
+// return true on error
+//---------------------------------------------------------
+
+bool initMidiJack()
+{
+ /*
+ int adr = 0;
+
+ memset(jack_midi_out_data, 0, JACK_MIDI_CHANNELS * sizeof(muse_jack_midi_buffer));
+ memset(jack_midi_in_data, 0, JACK_MIDI_CHANNELS * sizeof(muse_jack_midi_buffer));
+
+ MidiJackDevice* dev = new MidiJackDevice(adr, QString("jack-midi"));
+ dev->setrwFlags(3); // set read and write flags
+
+ if(pipe(jackmidi_pi) < 0){
+ fprintf(stderr, "cant create midi-jack input pipe\n");
+ }
+ if(pipe(jackmidi_po) < 0){
+ fprintf(stderr, "cant create midi-jack output pipe\n");
+ }
+
+ midiDevices.add(dev);
+
+ gmdev = dev; // proclaim the global jack-midi instance
+
+ //jackScanMidiPorts();
+ */
+
+ return false;
+}
+
+/*
+struct JackPort {
+ int adr;
+ //char* name;
+ QString name;
+ int flags;
+ //JackPort(int a, const char* s, int f) {
+ JackPort(int a, const QString& s, int f) {
+ adr = a;
+ //name = strdup(s);
+ name = QString(s);
+ flags = f;
+ }
+ };
+
+
+static std::list<JackPort> portList;
+
+//---------------------------------------------------------
+// jackScanMidiPorts
+//---------------------------------------------------------
+
+void jackScanMidiPorts()
+{
+ int adr;
+ const char* name;
+
+ portList.clear();
+ adr = 0;
+ name = strdup("namex");
+ portList.push_back(JackPort(adr, name, 0));
+ //
+ // check for devices to add
+ //
+ for (std::list<JackPort>::iterator k = portList.begin(); k != portList.end(); ++k) {
+ iMidiDevice i = midiDevices.begin();
+ for (;i != midiDevices.end(); ++i) {
+ //MidiJackDevice* d = dynamic_cast<MidiJackDevice*>(*i);
+ break;
+ //if (d == 0) continue;
+ //if ((k->adr.client == d->adr.client) && (k->adr.port == d->adr.port)) {
+ // break;
+ //}
+ }
+ if (i == midiDevices.end()) {
+ // add device
+ MidiJackDevice* dev = new MidiJackDevice(k->adr, QString(k->name));
+ dev->setrwFlags(k->flags);
+ midiDevices.add(dev);
+ }
+ }
+}
+*/
+
+/*
+//---------------------------------------------------------
+// processInput
+//---------------------------------------------------------
+static void handle_jack_midi_in(int channel)
+{
+ MidiRecordEvent event;
+ int t,n,v;
+ t = jack_midi_in_data[channel].buffer[0];
+ n = jack_midi_in_data[channel].buffer[1];
+ v = jack_midi_in_data[channel].buffer[2];
+
+ event.setType(0); // mark as unused
+ event.setPort(gmdev->midiPort());
+ event.setB(0);
+
+ if(t == 0x90){ // note on
+ fprintf(stderr, "jackProcessMidiInput note-on\n");
+ event.setChannel(channel);
+ event.setType(ME_NOTEON);
+ event.setA(n);
+ event.setB(v);
+ }else if (t == 0x80){ // note off
+ fprintf(stderr, "jackProcessMidiInput note-off\n");
+ event.setChannel(channel);
+ event.setType(ME_NOTEOFF);
+ event.setA(n);
+ event.setB(v);
+ }else{
+ fprintf(stderr, "WARNING: unknown midi-in on channel %d: %x,%x,%x\n",
+ channel, t, n, v);
+ return;
+ }
+ if(event.type()){
+ gmdev->recordEvent(event);
+ midiPorts[gmdev->midiPort()].syncInfo().trigActDetect(event.channel());
+ }
+}
+
+void MidiJackDevice::processInput()
+{
+ char buf;
+ int i,s;
+ read(gmdev->selectRfd(), &buf, 1);
+
+ s = 1;
+ for(i = 0; i < JACK_MIDI_CHANNELS; i++){
+ if(jack_midi_in_data[i].buffer[3]){
+ s = 0;
+ handle_jack_midi_in(i);
+ jack_midi_in_data[i].buffer[3] = 0;
+ }
+ }
+}
+
+*/
diff --git a/attic/muse2-oom/muse2/muse/driver/jackmidi.h b/attic/muse2-oom/muse2/muse/driver/jackmidi.h
new file mode 100644
index 00000000..f7b5eb94
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/driver/jackmidi.h
@@ -0,0 +1,168 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: jackmidi.h,v 1.1.1.1 2010/01/27 09:06:43 terminator356 Exp $
+// (C) Copyright 1999-2010 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __JACKMIDI_H__
+#define __JACKMIDI_H__
+
+//#include <config.h>
+
+#include <map>
+
+#include <jack/jack.h>
+#include <jack/midiport.h>
+
+#include "mididev.h"
+#include "route.h"
+
+class QString;
+class MidiFifo;
+class MidiRecordEvent;
+class MidiPlayEvent;
+//class RouteList;
+class Xml;
+
+// Turn on to show multiple devices, work in progress,
+// not working fully yet, can't seem to connect...
+//#define JACK_MIDI_SHOW_MULTIPLE_DEVICES
+
+// It appears one client port per remote port will be necessary.
+// Jack doesn't seem to like manipulation of non-local ports buffers.
+//#define JACK_MIDI_USE_MULTIPLE_CLIENT_PORTS
+
+/* jack-midi channels */
+//#define JACK_MIDI_CHANNELS 32
+
+/* jack-midi buffer size */
+//#define JACK_MIDI_BUFFER_SIZE 32
+
+/*
+typedef struct {
+ int give;
+ int take;
+ // 32 parallel midi events, where each event contains three
+ // midi-bytes and one busy-byte
+ char buffer[4 * JACK_MIDI_BUFFER_SIZE];
+} muse_jack_midi_buffer;
+*/
+
+/*
+struct JackMidiPort
+{
+ jack_port_t* _jackPort;
+ QString _name;
+ int _flags; // 1 = writable, 2 = readable - do not mix
+ JackMidiPort(jack_port_t* jp, const QString& s, int f)
+ {
+ _jackPort = jp;
+ _name = QString(s);
+ _flags = f;
+ }
+};
+
+typedef std::map<jack_port_t*, JackMidiPort, std::less<jack_port_t*> >::iterator iJackMidiPort;
+typedef std::map<jack_port_t*, JackMidiPort, std::less<jack_port_t*> >::const_iterator ciJackMidiPort;
+
+class JackMidiPortList : public std::map<jack_port_t*, JackMidiPort, std::less<jack_port_t*> >
+{
+ private:
+ static int _nextOutIdNum;
+ static int _nextInIdNum;
+
+ public:
+ JackMidiPortList();
+ ~JackMidiPortList();
+ iJackMidiPort createClientPort(int flags);
+ bool removeClientPort(jack_port_t* port);
+};
+
+extern JackMidiPortList jackMidiClientPorts;
+*/
+
+//---------------------------------------------------------
+// MidiJackDevice
+//---------------------------------------------------------
+
+class MidiJackDevice : public MidiDevice {
+ public:
+ //int adr;
+
+ private:
+ // fifo for midi events sent from gui
+ // direct to midi port:
+ MidiFifo eventFifo;
+
+ //static int _nextOutIdNum;
+ //static int _nextInIdNum;
+
+ //jack_port_t* _client_jackport;
+ // p3.3.55
+ jack_port_t* _in_client_jackport;
+ jack_port_t* _out_client_jackport;
+
+ //RouteList _routes;
+
+ virtual QString open();
+ virtual void close();
+ //bool putEvent(int*);
+
+ void processEvent(const MidiPlayEvent&);
+ // Port is not midi port, it is the port(s) created for MusE.
+ bool queueEvent(const MidiPlayEvent&);
+
+ virtual bool putMidiEvent(const MidiPlayEvent&);
+ //bool sendEvent(const MidiPlayEvent&);
+
+ void eventReceived(jack_midi_event_t*);
+
+ public:
+ //MidiJackDevice() {} // p3.3.55 Removed.
+ //MidiJackDevice(const int&, const QString& name);
+
+ //MidiJackDevice(jack_port_t* jack_port, const QString& name);
+ //MidiJackDevice(jack_port_t* in_jack_port, jack_port_t* out_jack_port, const QString& name); // p3.3.55 In or out port can be null.
+ MidiJackDevice(const QString& name);
+
+ //static MidiDevice* createJackMidiDevice(QString /*name*/, int /*rwflags*/); // 1:Writable 2: Readable. Do not mix.
+ static MidiDevice* createJackMidiDevice(QString name = "", int rwflags = 3); // p3.3.55 1:Writable 2: Readable 3: Writable + Readable
+
+ virtual inline int deviceType() { return JACK_MIDI; }
+
+ virtual void setName(const QString&);
+
+ virtual void processMidi();
+ virtual ~MidiJackDevice();
+ //virtual int selectRfd();
+ //virtual int selectWfd();
+ //virtual void processInput();
+
+ virtual void recordEvent(MidiRecordEvent&);
+
+ virtual bool putEvent(const MidiPlayEvent&);
+ virtual void collectMidiEvents();
+
+ //virtual jack_port_t* jackPort() { return _jackport; }
+ //virtual jack_port_t* clientJackPort() { return _client_jackport; }
+
+ //virtual void* clientPort() { return (void*)_client_jackport; }
+ // p3.3.55
+ virtual void* inClientPort() { return (void*) _in_client_jackport; }
+ virtual void* outClientPort() { return (void*) _out_client_jackport; }
+
+ //RouteList* routes() { return &_routes; }
+ //bool noRoute() const { return _routes.empty(); }
+ virtual void writeRouting(int, Xml&) const;
+ };
+
+extern bool initMidiJack();
+//extern int jackSelectRfd();
+//extern int jackSelectWfd();
+//extern void jackProcessMidiInput();
+//extern void jackScanMidiPorts();
+
+#endif
+
+
diff --git a/attic/muse2-oom/muse2/muse/driver/rtctimer.cpp b/attic/muse2-oom/muse2/muse/driver/rtctimer.cpp
new file mode 100644
index 00000000..1a3cefa6
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/driver/rtctimer.cpp
@@ -0,0 +1,155 @@
+ //=========================================================
+ // MusE
+ // Linux Music Editor
+ // $Id: rtctimer.cpp,v 1.1.2.11 2009/03/09 02:05:18 terminator356 Exp $
+ //
+ // Most code moved from midiseq.cpp by Werner Schweer.
+ //
+ // (C) Copyright 2004 Robert Jonsson (rj@spamatica.se)
+ // (C) Copyright -2004 Werner Schweer (werner@seh.de)
+ //=========================================================
+
+#include <linux/version.h>
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,0)
+#include <linux/spinlock.h>
+#include <linux/mc146818rtc.h>
+#else
+#include <linux/rtc.h>
+#endif
+#include <stdio.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <poll.h>
+
+
+#include "rtctimer.h"
+#include "globals.h"
+#include "gconfig.h"
+
+
+RtcTimer::RtcTimer()
+ {
+ timerFd = -1;
+ }
+
+RtcTimer::~RtcTimer()
+ {
+ if (timerFd != -1)
+ close(timerFd);
+ }
+
+signed int RtcTimer::initTimer()
+ {
+ if(TIMER_DEBUG)
+ printf("RtcTimer::initTimer()\n");
+ if (timerFd != -1) {
+ fprintf(stderr,"RtcTimer::initTimer(): called on initialised timer!\n");
+ return -1;
+ }
+ doSetuid();
+
+ timerFd = ::open("/dev/rtc", O_RDONLY);
+ if (timerFd == -1) {
+ fprintf(stderr, "fatal error: open /dev/rtc failed: %s\n", strerror(errno));
+ fprintf(stderr, "hint: check if 'rtc' kernel module is loaded, or used by something else\n");
+ undoSetuid();
+ return timerFd;
+ }
+ if (!setTimerFreq(config.rtcTicks)) {
+ // unable to set timer frequency
+ return -1;
+ }
+ // check if timer really works, start and stop it once.
+ if (!startTimer()) {
+ return -1;
+ }
+ if (!stopTimer()) {
+ return -1;
+ }
+ return timerFd;
+ }
+
+unsigned int RtcTimer::setTimerResolution(unsigned int resolution)
+ {
+ if(TIMER_DEBUG)
+ printf("RtcTimer::setTimerResolution(%d)\n",resolution);
+ /* The RTC can take power-of-two frequencies from 2 to 8196 Hz.
+ * It doesn't really have a resolution as such.
+ */
+ return 0;
+ }
+
+unsigned int RtcTimer::setTimerFreq(unsigned int freq)
+ {
+ int rc = ioctl(timerFd, RTC_IRQP_SET, freq);
+ if (rc == -1) {
+ fprintf(stderr, "RtcTimer::setTimerFreq(): cannot set tick on /dev/rtc: %s\n",
+ strerror(errno));
+ fprintf(stderr, " precise timer not available\n");
+ return 0;
+ }
+ return freq;
+ }
+
+unsigned int RtcTimer::getTimerResolution()
+ {
+ /* The RTC doesn't really work with a set resolution as such.
+ * Not sure how this fits into things yet.
+ */
+ return 0;
+ }
+
+unsigned int RtcTimer::getTimerFreq()
+ {
+ unsigned int freq;
+ int rv = ioctl(timerFd, RTC_IRQP_READ, &freq);
+ if (rv < 1)
+ return 0;
+ return freq;
+ }
+
+bool RtcTimer::startTimer()
+ {
+ if(TIMER_DEBUG)
+ printf("RtcTimer::startTimer()\n");
+ if (timerFd == -1) {
+ fprintf(stderr, "RtcTimer::startTimer(): no timer open to start!\n");
+ return false;
+ }
+ if (ioctl(timerFd, RTC_PIE_ON, 0) == -1) {
+ perror("MidiThread: start: RTC_PIE_ON failed");
+ undoSetuid();
+ return false;
+ }
+ return true;
+ }
+
+bool RtcTimer::stopTimer()
+ {
+ if(TIMER_DEBUG)
+ printf("RtcTimer::stopTimer\n");
+ if (timerFd != -1) {
+ ioctl(timerFd, RTC_PIE_OFF, 0);
+ }
+ else {
+ fprintf(stderr,"RtcTimer::stopTimer(): no RTC to stop!\n");
+ return false;
+ }
+ return true;
+ }
+
+unsigned int RtcTimer::getTimerTicks(bool /*printTicks*/)// prevent compiler warning: unused parameter
+ {
+ if(TIMER_DEBUG)
+ printf("getTimerTicks()\n");
+ unsigned long int nn;
+ if (timerFd==-1) {
+ fprintf(stderr,"RtcTimer::getTimerTicks(): no RTC open to read!\n");
+ return 0;
+ }
+ if (read(timerFd, &nn, sizeof(unsigned long)) != sizeof(unsigned long)) {
+ fprintf(stderr,"RtcTimer::getTimerTicks(): error reading RTC\n");
+ return 0;
+ }
+ return nn;
+ }
diff --git a/attic/muse2-oom/muse2/muse/driver/rtctimer.h b/attic/muse2-oom/muse2/muse/driver/rtctimer.h
new file mode 100644
index 00000000..fa58b032
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/driver/rtctimer.h
@@ -0,0 +1,44 @@
+ //=========================================================
+ // MusE
+ // Linux Music Editor
+ // $Id: rtctimer.h,v 1.1.2.3 2005/08/21 18:11:28 spamatica Exp $
+ //
+ // Most code moved from midiseq.cpp
+ //
+ // (C) Copyright 2004 Robert Jonsson (rj@spamatica.se)
+ // (C) Copyright -2004 Werner Schweer (werner@seh.de)
+ //=========================================================
+
+#ifndef __RTCTIMER_H__
+#define __RTCTIMER_H__
+
+#include "timerdev.h"
+
+
+//---------------------------------------------------------
+// AlsaTimer
+//---------------------------------------------------------
+
+class RtcTimer : public Timer{
+
+
+ public:
+ RtcTimer();
+ virtual ~RtcTimer();
+
+ virtual signed int initTimer();
+ virtual unsigned int setTimerResolution(unsigned int resolution);
+ virtual unsigned int getTimerResolution();
+ virtual unsigned int setTimerFreq(unsigned int tick);
+ virtual unsigned int getTimerFreq();
+
+ virtual bool startTimer();
+ virtual bool stopTimer();
+ virtual unsigned int getTimerTicks(bool printTicks=false);
+
+ private:
+ int timerFd;
+
+};
+
+#endif //__ALSATIMER_H__
diff --git a/attic/muse2-oom/muse2/muse/driver/timerdev.h b/attic/muse2-oom/muse2/muse/driver/timerdev.h
new file mode 100644
index 00000000..944bc213
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/driver/timerdev.h
@@ -0,0 +1,41 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: timerdev.h,v 1.1.2.3 2005/08/21 18:11:28 spamatica Exp $
+//
+// Plenty of code borrowed from timer.c example in
+// alsalib 1.0.7
+//
+// (C) Copyright 2004 Robert Jonsson (rj@spamatica.se)
+//=========================================================
+
+#ifndef __TIMERDEV_H__
+#define __TIMERDEV_H__
+
+#include "alsa/asoundlib.h"
+
+#define TIMER_DEBUG 0
+
+//---------------------------------------------------------
+// AlsaTimer
+//---------------------------------------------------------
+
+class Timer {
+
+ public:
+ Timer() {};
+ virtual ~Timer() {};
+
+ virtual signed int initTimer() = 0;
+ virtual unsigned int setTimerResolution(unsigned int resolution) = 0;
+ virtual unsigned int getTimerResolution() = 0;
+ virtual unsigned int setTimerFreq(unsigned int freq) = 0;
+ virtual unsigned int getTimerFreq() = 0;
+
+ virtual bool startTimer() = 0;
+ virtual bool stopTimer() = 0;
+ virtual unsigned int getTimerTicks(bool printTicks = false) = 0;
+
+};
+
+#endif //__ALSATIMER_H__
diff --git a/attic/muse2-oom/muse2/muse/dssihost.cpp b/attic/muse2-oom/muse2/muse/dssihost.cpp
new file mode 100644
index 00000000..986abea1
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/dssihost.cpp
@@ -0,0 +1,3059 @@
+//=============================================================================
+// MusE
+// Linux Music Editor
+// $Id: dssihost.cpp,v 1.15.2.16 2009/12/15 03:39:58 terminator356 Exp $
+//
+// Copyright (C) 2002-2006 by Werner Schweer and others
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//=============================================================================
+
+#include "config.h"
+#ifdef DSSI_SUPPORT
+
+// Turn on debugging messages
+//#define DSSI_DEBUG
+
+// Support vst state saving/loading with vst chunks. Requires patches to DSSI and DSSI-vst!
+//#define DSSI_VST_CHUNK_SUPPORT
+
+#include <string.h>
+#include <signal.h>
+#include <dlfcn.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+//#include <dssi.h>
+//#include <alsa/asoundlib.h>
+
+#include <QDir>
+#include <QFileInfo>
+#include <QMenu>
+
+#include "dssihost.h"
+#include "synth.h"
+#include "audio.h"
+#include "jackaudio.h"
+//#include "../driver/jackaudio.h" // p4.0.2
+#include "midi.h"
+#include "midiport.h"
+#include "stringparam.h"
+#include "plugin.h"
+//#include "al/al.h"
+//#include "al/xml.h"
+#include "xml.h"
+#include "song.h"
+//#include "midictrl.h"
+//#include "ladspaplugin.h"
+
+#include "app.h"
+#include "globals.h"
+#include "globaldefs.h"
+//#include "al/dsp.h"
+#include "gconfig.h"
+
+/*
+static lo_server_thread serverThread;
+static char osc_path_tmp[1024];
+static char* url;
+
+//---------------------------------------------------------
+// oscError
+//---------------------------------------------------------
+
+static void oscError(int num, const char *msg, const char *path)
+ {
+ fprintf(stderr, "MusE: liblo server error %d in path %s: %s\n",
+ num, path, msg);
+ }
+
+//---------------------------------------------------------
+// oscDebugHandler
+//---------------------------------------------------------
+
+static int oscDebugHandler(const char* path, const char* types, lo_arg** argv,
+ int argc, void*, void*)
+ {
+ printf("MusE: got unhandled OSC message:\n path: <%s>\n", path);
+ for (int i = 0; i < argc; i++) {
+ printf(" arg %d '%c' ", i, types[i]);
+ lo_arg_pp(lo_type(types[i]), argv[i]);
+ printf("\n");
+ }
+ return 1;
+ }
+
+//---------------------------------------------------------
+// oscUpdate
+//---------------------------------------------------------
+
+int DssiSynthIF::oscUpdate(lo_arg **argv)
+ {
+ const char *url = (char *)&argv[0]->s;
+
+ if (uiTarget)
+ lo_address_free(uiTarget);
+ char* host = lo_url_get_hostname(url);
+ char* port = lo_url_get_port(url);
+ uiTarget = lo_address_new(host, port);
+ free(host);
+ free(port);
+
+ if (uiOscPath)
+ free(uiOscPath);
+ uiOscPath = lo_url_get_path(url);
+ int pl = strlen(uiOscPath);
+
+ if (uiOscControlPath)
+ free(uiOscControlPath);
+ uiOscControlPath = (char *)malloc(pl + 10);
+ sprintf(uiOscControlPath, "%s/control", uiOscPath);
+
+ if (uiOscConfigurePath)
+ free(uiOscConfigurePath);
+ uiOscConfigurePath = (char *)malloc(pl + 12);
+ sprintf(uiOscConfigurePath, "%s/configure", uiOscPath);
+
+ if (uiOscProgramPath)
+ free(uiOscProgramPath);
+ uiOscProgramPath = (char *)malloc(pl + 10);
+ sprintf(uiOscProgramPath, "%s/program", uiOscPath);
+
+ if (uiOscShowPath)
+ free(uiOscShowPath);
+ uiOscShowPath = (char *)malloc(pl + 10);
+ sprintf(uiOscShowPath, "%s/show", uiOscPath);
+
+ // At this point a more substantial host might also call
+ // configure() on the UI to set any state that it had remembered
+ // for the plugin instance. But we don't remember state for
+ // plugin instances (see our own configure() implementation in
+ // osc_configure_handler), and so we have nothing to send except
+ // the optional project directory.
+
+
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::oscUpdate synth name:%s url:%s uiTarget:%p uiOscPath:%s uiOscConfigurePath:%s museProject:%s\n", synti->name().ascii(), url, uiTarget, uiOscPath, uiOscConfigurePath, museProject.ascii());
+ #endif
+
+ //lo_send(uiTarget, uiOscConfigurePath, "ss",
+ //DSSI_PROJECT_DIRECTORY_KEY, song->projectPath().toAscii().data());
+ lo_send(uiTarget, uiOscConfigurePath, "ss",
+ DSSI_PROJECT_DIRECTORY_KEY, museProject.ascii());
+
+#if 0
+ // Send current bank/program (-FIX- another race...)
+ if (instance->pendingProgramChange < 0) {
+ unsigned long bank = instance->currentBank;
+ unsigned long program = instance->currentProgram;
+ instance->uiNeedsProgramUpdate = 0;
+ if (instance->uiTarget) {
+ lo_send(instance->uiTarget, instance->ui_osc_program_path, "ii", bank, program);
+ }
+ }
+
+ // Send control ports
+ for (i = 0; i < instance->plugin->controlIns; i++) {
+ int in = i + instance->firstControlIn;
+ int port = pluginControlInPortNumbers[in];
+ lo_send(instance->uiTarget, instance->ui_osc_control_path, "if", port,
+ pluginControlIns[in]);
+ // Avoid overloading the GUI if there are lots and lots of ports
+ if ((i+1) % 50 == 0)
+ usleep(300000);
+ }
+#endif
+ return 0;
+ }
+
+//---------------------------------------------------------
+// oscMessageHandler
+//---------------------------------------------------------
+
+int oscMessageHandler(const char* path, const char* types, lo_arg** argv,
+ int argc, void* data, void* user_data)
+ {
+ const char* p = path;
+
+ #ifdef DSSI_DEBUG
+ if(argc)
+ {
+ printf("oscMessageHandler: path:%s argc:%d\n", path, argc);
+ for(int i = 0; i < argc; ++i)
+ {
+ printf(" ");
+ lo_arg_pp((lo_type)types[i], argv[i]);
+ }
+ printf("\n");
+ }
+ else
+ {
+ printf("%s\n", path);
+ printf("oscMessageHandler: no args, path:%s\n", path);
+ }
+ #endif
+
+ if (strncmp(p, "/dssi/", 6))
+ return oscDebugHandler(path, types, argv, argc, data, user_data);
+
+ p += 6;
+ //p = strrchr(p, "/");
+
+ SynthIList* sl = song->syntis();
+ DssiSynthIF* instance = 0;
+ SynthI* synti = 0;
+
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "oscMessageHandler: song->syntis() size:%d\n", sl->size());
+ #endif
+
+ for(int retry = 0; retry < 5; ++retry)
+ {
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "oscMessageHandler: search retry number:%d ...\n", retry);
+ #endif
+
+ //if(uiOscPath)
+ // break;
+
+ for(iSynthI si = sl->begin(); si != sl->end(); ++si)
+ {
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "oscMessageHandler: searching for synth p:%s: checking instances:%s\n", p, (*si)->name().ascii());
+ #endif
+
+ //int l = strlen((*si)->name().toAscii().data());
+ //if (!strncmp(p, (*si)->name().toAscii().data(), l)) {
+ //int l = strlen((*si)->name().ascii());
+ const char* sub = strstr(p, (*si)->name().ascii());
+
+ //if(!strncmp(p, (*si)->name().ascii(), l))
+ if(sub != NULL)
+ {
+ synti = *si;
+ instance = (DssiSynthIF*)(synti->sif());
+
+ //p += l;
+ p = sub + strlen((*si)->name().ascii());
+
+ break;
+ }
+ }
+ if(instance)
+ break;
+
+ sleep(1);
+ }
+
+ if(!instance)
+ {
+ fprintf(stderr, "oscMessageHandler: error: no instance\n");
+ return oscDebugHandler(path, types, argv, argc, data, user_data);
+ }
+
+ if (*p != '/' || *(p + 1) == 0)
+ {
+ fprintf(stderr, "oscMessageHandler: error: end or no /\n");
+ return oscDebugHandler(path, types, argv, argc, data, user_data);
+ }
+
+ ++p;
+
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "oscMessageHandler: method:%s\n", p);
+ #endif
+
+ if (!strcmp(p, "configure") && argc == 2 && !strcmp(types, "ss"))
+ return instance->oscConfigure(argv);
+ else if (!strcmp(p, "control") && argc == 2 && !strcmp(types, "if"))
+ return instance->oscControl(argv);
+ else if (!strcmp(p, "midi") && argc == 1 && !strcmp(types, "m"))
+ return instance->oscMidi(argv);
+ else if (!strcmp(p, "program") && argc == 2 && !strcmp(types, "ii"))
+ return instance->oscProgram(argv);
+ else if (!strcmp(p, "update") && argc == 1 && !strcmp(types, "s"))
+ return instance->oscUpdate(argv);
+ else if (!strcmp(p, "exiting") && argc == 0)
+ return instance->oscExiting(argv);
+ return oscDebugHandler(path, types, argv, argc, data, user_data);
+ }
+*/
+
+//---------------------------------------------------------
+// scanDSSILib
+//---------------------------------------------------------
+
+static void scanDSSILib(QFileInfo& fi) // ddskrjo removed const for argument
+ {
+ //void* handle = dlopen(fi.filePath().toAscii().data(), RTLD_NOW);
+ void* handle = dlopen(fi.filePath().toLatin1().constData(), RTLD_NOW);
+ //void* handle = dlopen(fi.absFilePath().toLatin1().constData(), RTLD_NOW);
+
+ if (handle == 0) {
+ fprintf(stderr, "scanDSSILib: dlopen(%s) failed: %s\n",
+ //fi.filePath().toAscii().data(), dlerror());
+ fi.filePath().toLatin1().constData(), dlerror());
+ //fi.absFilePath().toLatin1().constData(), dlerror());
+
+ return;
+ }
+ DSSI_Descriptor_Function dssi = (DSSI_Descriptor_Function)dlsym(handle, "dssi_descriptor");
+
+ if (!dssi)
+ {
+ /*
+ const char *txt = dlerror();
+ if (txt)
+ {
+ fprintf(stderr,
+ "Unable to find dssi_descriptor() function in plugin "
+ "library file \"%s\": %s.\n"
+ "Are you sure this is a DSSI plugin file?\n",
+ //fi.filePath().toAscii().data(),
+ fi.filePath().ascii(),
+ //fi.absFilePath().toLatin1().constData(),
+
+ txt);
+ dlclose(handle);
+ exit(1);
+ }
+ */
+ dlclose(handle);
+ return;
+ }
+ else
+ {
+ //const DSSI_Descriptor* descr;
+ for (int i = 0;; ++i)
+ {
+ const DSSI_Descriptor* descr;
+
+ // CRAPPY PLUGIN ALERT:
+ // Out of many plugins, with several, Valgrind says something in here is allocated with new.
+ descr = dssi(i);
+ if (descr == 0)
+ break;
+
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "scanDSSILib: name:%s inPlaceBroken:%d\n", descr->LADSPA_Plugin->Name, LADSPA_IS_INPLACE_BROKEN(descr->LADSPA_Plugin->Properties));
+ #endif
+
+ // Listing synths only while excluding effect plugins:
+ // Do the exact opposite of what dssi-vst.cpp does for listing ladspa plugins.
+ // That way we cover all bases - effect plugins and synths.
+ // Non-synths will show up in the ladspa effect dialog, while synths will show up here...
+ // There should be nothing left out...
+ if(descr->run_synth ||
+ descr->run_synth_adding ||
+ descr->run_multiple_synths ||
+ descr->run_multiple_synths_adding)
+
+ {
+ const QString label(descr->LADSPA_Plugin->Label);
+
+ // Make sure it doesn't already exist.
+ std::vector<Synth*>::iterator is;
+ for(is = synthis.begin(); is != synthis.end(); ++is)
+ {
+ Synth* s = *is;
+ //#ifdef DSSI_DEBUG
+ // fprintf(stderr, "scanDSSILib: name:%s listname:%s lib:%s listlib:%s\n",
+ // label.toLatin1().constData(), s->name().toLatin1().constData(), fi.baseName(true).toLatin1().constData(), s->baseName().toLatin1().constData());
+ //#endif
+
+ if(s->name() == label && s->baseName() == fi.completeBaseName())
+ break;
+ }
+ if(is != synthis.end())
+ continue;
+
+ DssiSynth* s = new DssiSynth(fi, descr);
+
+ if(debugMsg)
+ {
+ fprintf(stderr, "scanDSSILib: name:%s listname:%s lib:%s listlib:%s\n",
+ label.toLatin1().constData(), s->name().toLatin1().constData(), fi.completeBaseName().toLatin1().constData(), s->baseName().toLatin1().constData());
+ int ai = 0, ao = 0, ci = 0, co = 0;
+ for(unsigned long pt = 0; pt < descr->LADSPA_Plugin->PortCount; ++pt)
+ {
+ LADSPA_PortDescriptor pd = descr->LADSPA_Plugin->PortDescriptors[pt];
+ if(LADSPA_IS_PORT_INPUT(pd) && LADSPA_IS_PORT_AUDIO(pd))
+ ai++;
+ else
+ if(LADSPA_IS_PORT_OUTPUT(pd) && LADSPA_IS_PORT_AUDIO(pd))
+ ao++;
+ else
+ if(LADSPA_IS_PORT_INPUT(pd) && LADSPA_IS_PORT_CONTROL(pd))
+ ci++;
+ else
+ if(LADSPA_IS_PORT_OUTPUT(pd) && LADSPA_IS_PORT_CONTROL(pd))
+ co++;
+ }
+ fprintf(stderr, "audio ins:%d outs:%d control ins:%d outs:%d\n", ai, ao, ci, co);
+ }
+
+ synthis.push_back(s);
+ }
+ else
+ {
+ // NOTE: Just a test
+ //QFileInfo ffi(fi);
+ //plugins.add(&ffi, LADSPA_Descriptor_Function(NULL), descr->LADSPA_Plugin, false);
+ //plugins.add(&ffi, descr, false);
+ }
+ }
+ }
+ dlclose(handle);
+ }
+
+//---------------------------------------------------------
+// scanVstDir
+//---------------------------------------------------------
+
+static void scanDSSIDir(QString& s) // ddskrjo removed const for argument
+{
+ if(debugMsg)
+ //printf("scan DSSI plugin dir <%s>\n", s.toAscii().data());
+ printf("scanDSSIDir: scan DSSI plugin dir <%s>\n", s.toLatin1().constData());
+
+#ifdef __APPLE__
+ QDir pluginDir(s, QString("*.dylib"), QDir::Unsorted, QDir::Files);
+#else
+ QDir pluginDir(s, QString("*.so"), QDir::Unsorted, QDir::Files);
+#endif
+ if(!pluginDir.exists())
+ return;
+
+ //const QFileInfoList list = pluginDir.entryInfoList();
+ //for (int i = 0; i < list.size(); ++i) {
+ //QFileInfo fi = list.at(i);
+ //scanDSSILib(fi);
+ //}
+
+ QStringList list = pluginDir.entryList();
+ for(int i = 0; i < list.count(); ++i)
+ {
+ if(debugMsg)
+ printf("scanDSSIDir: found %s\n", (s + QString("/") + list[i]).toLatin1().constData());
+
+ QFileInfo fi(s + QString("/") + list[i]);
+ scanDSSILib(fi);
+ }
+}
+
+//---------------------------------------------------------
+// initDSSI
+//---------------------------------------------------------
+
+void initDSSI()
+ {
+ const char* dssiPath = getenv("DSSI_PATH");
+ if (dssiPath == 0)
+ dssiPath = "/usr/local/lib64/dssi:/usr/lib64/dssi:/usr/local/lib/dssi:/usr/lib/dssi";
+
+ //const char* ladspaPath = getenv("LADSPA_PATH");
+ //if (ladspaPath == 0)
+ // ladspaPath = "/usr/local/lib64/ladspa:/usr/lib64/ladspa:/usr/local/lib/ladspa:/usr/lib/ladspa";
+
+ const char* p = dssiPath;
+ //QString pth = QString(dssiPath) + QString(":") + QString(ladspaPath);
+ //const char* p = pth.toLatin1().constData();
+ while (*p != '\0') {
+ const char* pe = p;
+ while (*pe != ':' && *pe != '\0')
+ pe++;
+
+ int n = pe - p;
+ if (n) {
+ char* buffer = new char[n + 1];
+ strncpy(buffer, p, n);
+ buffer[n] = '\0';
+ QString tmpStr(buffer);
+ scanDSSIDir(tmpStr);
+ delete[] buffer;
+ }
+ p = pe;
+ if (*p == ':')
+ p++;
+ }
+
+ // Create OSC thread
+ //serverThread = lo_server_thread_new(0, oscError);
+ //snprintf(osc_path_tmp, 31, "/dssi");
+ //char* tmp = lo_server_thread_get_url(serverThread);
+ //url = (char *)malloc(strlen(tmp) + strlen(osc_path_tmp));
+ //sprintf(url, "%s%s", tmp, osc_path_tmp + 1);
+ //free(tmp);
+ //lo_server_thread_add_method(serverThread, 0, 0, oscMessageHandler, 0);
+ //lo_server_thread_start(serverThread);
+ }
+
+//---------------------------------------------------------
+// DssiSynth
+// Synth.label = plug.Label
+// Synth.descr = plug.Name
+// Synth.maker = plug.maker
+// Synth.version = nil (no such field in ladspa, maybe try copyright instead)
+//---------------------------------------------------------
+
+DssiSynth::DssiSynth(QFileInfo& fi, const DSSI_Descriptor* d) : // ddskrjo removed const from QFileInfo
+ //Synth(fi, label, descr, maker, ver)
+ Synth(fi, QString(d->LADSPA_Plugin->Label), QString(d->LADSPA_Plugin->Name), QString(d->LADSPA_Plugin->Maker), QString())
+{
+ df = 0;
+ handle = 0;
+ dssi = 0;
+ _hasGui = false;
+
+ const LADSPA_Descriptor* descr = d->LADSPA_Plugin;
+
+ _portCount = descr->PortCount;
+ //_portDescriptors = 0;
+ //if(_portCount)
+ // _portDescriptors = new LADSPA_PortDescriptor[_portCount];
+
+ _inports = 0;
+ _outports = 0;
+ _controlInPorts = 0;
+ _controlOutPorts = 0;
+ for(unsigned long k = 0; k < _portCount; ++k)
+ {
+ LADSPA_PortDescriptor pd = descr->PortDescriptors[k];
+ //_portDescriptors[k] = pd;
+ if(pd & LADSPA_PORT_AUDIO)
+ {
+ if(pd & LADSPA_PORT_INPUT)
+ ++_inports;
+ else
+ if(pd & LADSPA_PORT_OUTPUT)
+ ++_outports;
+ }
+ else
+ if(pd & LADSPA_PORT_CONTROL)
+ {
+ if(pd & LADSPA_PORT_INPUT)
+ ++_controlInPorts;
+ else
+ if(pd & LADSPA_PORT_OUTPUT)
+ ++_controlOutPorts;
+ }
+ }
+
+ _inPlaceCapable = !LADSPA_IS_INPLACE_BROKEN(descr->Properties);
+
+ // Blacklist vst plugins in-place configurable for now.
+ if ((_inports != _outports) || (fi.completeBaseName() == QString("dssi-vst") && !config.vstInPlace))
+ _inPlaceCapable = false;
+}
+
+DssiSynth::~DssiSynth()
+{
+
+}
+
+//---------------------------------------------------------
+// createSIF
+//---------------------------------------------------------
+
+SynthIF* DssiSynth::createSIF(SynthI* synti)
+{
+ if (_instances == 0)
+ {
+ //handle = dlopen(info.filePath().toAscii().data(), RTLD_NOW);
+ handle = dlopen(info.filePath().toLatin1().constData(), RTLD_NOW);
+ //handle = dlopen(info.absFilePath().toLatin1().constData(), RTLD_NOW);
+
+ if (handle == 0)
+ {
+ fprintf(stderr, "DssiSynth::createSIF dlopen(%s) failed: %s\n",
+ //info.filePath().toAscii().data(), dlerror());
+ info.filePath().toLatin1().constData(), dlerror());
+ //info.absFilePath().toLatin1().constData(), dlerror());
+
+ return 0;
+ }
+ df = (DSSI_Descriptor_Function)dlsym(handle, "dssi_descriptor");
+
+ if (!df) {
+ const char *txt = dlerror();
+ fprintf(stderr,
+ "Unable to find dssi_descriptor() function in plugin "
+ "library file \"%s\": %s.\n"
+ "Are you sure this is a DSSI plugin file?\n",
+ //info.filePath().toAscii().data(),
+ info.filePath().toLatin1().constData(),
+ //info.absFilePath().toLatin1().constData(),
+
+ txt ? txt : "?");
+ dlclose(handle);
+ handle = 0;
+ return 0;
+ }
+ for (int i = 0;; ++i)
+ {
+ dssi = df(i);
+ if (dssi == 0)
+ break;
+ QString label(dssi->LADSPA_Plugin->Label);
+ if (label == _name)
+ break;
+ }
+
+ if(dssi != 0)
+ {
+ _inports = 0;
+ _outports = 0;
+ _controlInPorts = 0;
+ _controlOutPorts = 0;
+
+ pIdx.clear();
+ opIdx.clear();
+ iIdx.clear();
+ oIdx.clear();
+ rpIdx.clear();
+ iUsedIdx.clear();
+ midiCtl2PortMap.clear();
+ port2MidiCtlMap.clear();
+ //synti->_guiUpdateControls.clear();
+
+ const LADSPA_Descriptor* descr = dssi->LADSPA_Plugin;
+ //#ifdef DSSI_DEBUG
+ // printf("DssiSynth::createSIF ladspa plugin PortCount:%lu\n", d->PortCount);
+ //#endif
+
+ _portCount = descr->PortCount;
+
+ for (unsigned long k = 0; k < _portCount; ++k)
+ {
+ LADSPA_PortDescriptor pd = descr->PortDescriptors[k];
+
+ #ifdef DSSI_DEBUG
+ printf("DssiSynth::createSIF ladspa plugin Port:%ld Name:%s descriptor:%x\n", k, descr->PortNames[k], pd);
+ #endif
+
+ if (LADSPA_IS_PORT_AUDIO(pd))
+ {
+ if (LADSPA_IS_PORT_INPUT(pd))
+ {
+ ++_inports;
+ iIdx.push_back(k);
+ iUsedIdx.push_back(false); // Start out with all false.
+ }
+ else if (LADSPA_IS_PORT_OUTPUT(pd))
+ {
+ ++_outports;
+ oIdx.push_back(k);
+ }
+
+ rpIdx.push_back((unsigned long)-1);
+ }
+ else if (LADSPA_IS_PORT_CONTROL(pd))
+ {
+ if (LADSPA_IS_PORT_INPUT(pd))
+ {
+ rpIdx.push_back(_controlInPorts);
+ ++_controlInPorts;
+ pIdx.push_back(k);
+ // Set to false at first.
+ //synti->_guiUpdateControls.push_back(false);
+ }
+ else if (LADSPA_IS_PORT_OUTPUT(pd))
+ {
+ rpIdx.push_back((unsigned long)-1);
+ ++_controlOutPorts;
+ opIdx.push_back(k);
+ }
+ }
+ }
+
+ _inPlaceCapable = !LADSPA_IS_INPLACE_BROKEN(descr->Properties);
+ // Blacklist vst plugins in-place configurable for now.
+ if((_inports != _outports) || (info.completeBaseName() == QString("dssi-vst") && !config.vstInPlace))
+ _inPlaceCapable = false;
+ }
+ }
+
+ if (dssi == 0)
+ {
+ //fprintf(stderr, "cannot found DSSI synti %s\n", _name.toAscii().data());
+ fprintf(stderr, "cannot find DSSI synti %s\n", _name.toLatin1().constData());
+ dlclose(handle);
+ handle = 0;
+ df = 0;
+ return 0;
+ }
+
+ DssiSynthIF* sif = new DssiSynthIF(synti);
+ ++_instances;
+ sif->init(this);
+
+ //_plugin->incInstances(1);
+
+
+
+// static char oscUrl[1024];
+ //snprintf(oscUrl, 1024, "%s/%s", url, synti->name().toAscii().data());
+ //snprintf(oscUrl, 1024, "%s/%s", url, synti->name().toLatin1().constData());
+// snprintf(oscUrl, 1024, "%s/%s/%s", url, info.baseName().toLatin1().constData(), synti->name().toLatin1().constData());
+ //QString guiPath(info.path() + "/" + info.baseName());
+ QString guiPath(info.path() + "/" + info.baseName());
+ QDir guiDir(guiPath, "*", QDir::Unsorted, QDir::Files);
+ _hasGui = guiDir.exists();
+
+ //sif->initGui();
+
+ return sif;
+}
+
+//---------------------------------------------------------
+// guiVisible
+//---------------------------------------------------------
+
+bool DssiSynthIF::guiVisible() const
+ {
+ //return _guiVisible;
+ #ifdef OSC_SUPPORT
+ return _oscif.oscGuiVisible();
+ #endif
+ return false;
+ }
+
+//---------------------------------------------------------
+// showGui
+//---------------------------------------------------------
+
+void DssiSynthIF::showGui(bool v)
+ {
+ #ifdef OSC_SUPPORT
+
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::showGui(): v:%d visible:%d\n", v, guiVisible());
+ #endif
+
+ _oscif.oscShowGui(v);
+
+ #endif // OSC_SUPPORT
+
+ /*
+ if (v == guiVisible())
+ return;
+
+ //if(guiPid == -1)
+ if((guiQProc == 0) || (!guiQProc->isRunning()))
+ {
+ // We need an indicator that update was called - update must have been called to get new path etc...
+ // If the process is not running this path is invalid, right?
+ if(uiOscPath)
+ free(uiOscPath);
+ uiOscPath = 0;
+
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::showGui(): No QProcess or process not running. Starting gui...\n");
+ #endif
+
+ initGui();
+ }
+
+ //for (int i = 0; i < 5; ++i) {
+ for (int i = 0; i < 10; ++i) { // Give it a wee bit more time?
+ if (uiOscPath)
+ break;
+ sleep(1);
+ }
+ if (uiOscPath == 0) {
+ printf("DssiSynthIF::showGui(): no uiOscPath. Error: Timeout - synth gui did not start within 10 seconds.\n");
+ return;
+ }
+
+ char uiOscGuiPath[strlen(uiOscPath)+6];
+ sprintf(uiOscGuiPath, "%s/%s", uiOscPath, v ? "show" : "hide");
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::showGui(): Sending show/hide uiOscGuiPath:%s\n", uiOscGuiPath);
+ #endif
+
+ lo_send(uiTarget, uiOscGuiPath, "");
+ _guiVisible = v;
+ */
+ }
+
+//---------------------------------------------------------
+// receiveEvent
+//---------------------------------------------------------
+
+//MidiEvent DssiSynthIF::receiveEvent()
+// {
+// return MidiEvent();
+// }
+MidiPlayEvent DssiSynthIF::receiveEvent()
+ {
+ return MidiPlayEvent();
+ }
+
+//---------------------------------------------------------
+// init
+//---------------------------------------------------------
+
+bool DssiSynthIF::init(DssiSynth* s)
+ {
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::init\n");
+ #endif
+
+ synth = s;
+ const DSSI_Descriptor* dssi = synth->dssi;
+ const LADSPA_Descriptor* ld = dssi->LADSPA_Plugin;
+ handle = ld->instantiate(ld, sampleRate);
+
+ #ifdef OSC_SUPPORT
+ _oscif.oscSetSynthIF(this);
+ #endif
+
+ queryPrograms();
+
+ int inports = synth->_inports;
+ if(inports != 0)
+ {
+ audioInBuffers = new float*[inports];
+ for(int k = 0; k < inports; ++k)
+ {
+ //audioInBuffers[k] = new LADSPA_Data[segmentSize];
+ //posix_memalign((void**)(audioInBuffers + k), 16, sizeof(float) * segmentSize);
+ posix_memalign((void**)&audioInBuffers[k], 16, sizeof(float) * segmentSize);
+ memset(audioInBuffers[k], 0, sizeof(float) * segmentSize);
+ ld->connect_port(handle, synth->iIdx[k], audioInBuffers[k]);
+ }
+ }
+
+ int outports = synth->_outports;
+ if(outports != 0)
+ {
+ audioOutBuffers = new float*[outports];
+ for(int k = 0; k < outports; ++k)
+ {
+ //audioOutBuffers[k] = new LADSPA_Data[segmentSize];
+ //posix_memalign((void**)(audioOutBuffers + k), 16, sizeof(float) * segmentSize);
+ posix_memalign((void**)&audioOutBuffers[k], 16, sizeof(float) * segmentSize);
+ memset(audioOutBuffers[k], 0, sizeof(float) * segmentSize);
+ ld->connect_port(handle, synth->oIdx[k], audioOutBuffers[k]);
+ //printf("DssiSynthIF::init output port name: %s\n", ld->PortNames[synth->oIdx[k]]); // out1, out2, out3 etc
+ }
+ }
+
+ int controlPorts = synth->_controlInPorts;
+ int controlOutPorts = synth->_controlOutPorts;
+
+ if(controlPorts != 0)
+ controls = new Port[controlPorts];
+ else
+ controls = 0;
+
+ if(controlOutPorts != 0)
+ controlsOut = new Port[controlOutPorts];
+ else
+ controlsOut = 0;
+
+ synth->midiCtl2PortMap.clear();
+ synth->port2MidiCtlMap.clear();
+ synti->_guiUpdateControls.clear();
+ synti->_guiUpdateProgram = false;
+
+ for (int k = 0; k < controlPorts; ++k) {
+ int i = synth->pIdx[k];
+ //controls[k].val = ladspaDefaultValue(ld, i);
+ ladspaDefaultValue(ld, i, &controls[k].val);
+
+ // Set to false at first.
+ synti->_guiUpdateControls.push_back(false);
+
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::init control port:%d port idx:%d name:%s\n", k, i, ld->PortNames[i]);
+ #endif
+
+ // This code is duplicated in ::getControllerInfo()
+ //
+
+ int ctlnum = DSSI_NONE;
+ if(dssi->get_midi_controller_for_port)
+ ctlnum = dssi->get_midi_controller_for_port(handle, i);
+
+ // No controller number? Try to give it a unique one...
+ if(ctlnum == DSSI_NONE)
+ {
+ // FIXME: Be more careful. Must make sure to pick numbers not already chosen or which WILL BE chosen.
+ // Simple but flawed solution: Start them at 0x60000 + 0x2000 = 0x62000. Max NRPN number is 0x3fff.
+ // TODO: Update: Actually we want to try to use CC Controller7 controllers if possible (or a choice) because what if
+ // the user's controller hardware doesn't support RPN?
+ // If CC Controller7 is chosen we must make sure to use only non-common numbers. An already limited range
+ // of 127 now becomes narrower. See the cool document midi-controllers.txt in the DSSI source for a
+ // nice roundup of numbers and how to choose them and how they relate to synths and DSSI synths etc. !
+ ctlnum = CTRL_NRPN14_OFFSET + 0x2000 + k;
+ }
+ else
+ {
+ int c = ctlnum;
+ // Can be both CC and NRPN! Prefer CC over NRPN.
+ if(DSSI_IS_CC(ctlnum))
+ {
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::init is CC control\n");
+ #endif
+
+ ctlnum = DSSI_CC_NUMBER(c);
+ #ifdef DSSI_DEBUG
+ if(DSSI_IS_NRPN(ctlnum))
+ printf("DssiSynthIF::init is also NRPN control. Using CC.\n");
+ #endif
+ }
+ else
+ if(DSSI_IS_NRPN(ctlnum))
+ {
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::init is NRPN control\n");
+ #endif
+
+ ctlnum = DSSI_NRPN_NUMBER(c) + CTRL_NRPN14_OFFSET;
+ }
+
+ }
+
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::init inserting to midiCtl2PortMap: ctlnum:%d k:%d\n", ctlnum, k);
+ #endif
+
+ // We have a controller number! Insert it and the DSSI port number into both maps.
+ synth->midiCtl2PortMap.insert(std::pair<int, int>(ctlnum, k));
+ synth->port2MidiCtlMap.insert(std::pair<int, int>(k, ctlnum));
+ ld->connect_port(handle, i, &controls[k].val);
+ }
+
+ for (int k = 0; k < controlOutPorts; ++k) {
+ int i = synth->opIdx[k];
+
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::init control output port:%d port idx:%d name:%s\n", k, i, ld->PortNames[i]);
+ #endif
+
+ // p3.3.39 Removed.
+ /*
+
+ //controls[k].val = ladspaDefaultValue(ld, i);
+ ladspaDefaultValue(ld, i, &controlsOut[k].val);
+
+ // This code is duplicated in ::getControllerInfo()
+ //
+
+ int ctlnum = DSSI_NONE;
+ if(dssi->get_midi_controller_for_port)
+ ctlnum = dssi->get_midi_controller_for_port(handle, i);
+
+ // No controller number? Try to give it a unique one...
+ if(ctlnum == DSSI_NONE)
+ {
+ // FIXME: Be more careful. Must make sure to pick numbers not already chosen or which WILL BE chosen.
+ // Simple but flawed solution: Start them at 0x60000 + 0x3000 = 0x63000. Max NRPN number is 0x3fff.
+ // TODO: CC etc. etc.
+ ctlnum = CTRL_NRPN14_OFFSET + 0x3000 + k;
+ }
+ else
+ {
+ int c = ctlnum;
+ // Can be both CC and NRPN! Prefer CC over NRPN.
+ if(DSSI_IS_CC(ctlnum))
+ {
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::init is CC control\n");
+ #endif
+
+ ctlnum = DSSI_CC_NUMBER(c);
+
+ #ifdef DSSI_DEBUG
+ if(DSSI_IS_NRPN(ctlnum))
+ printf("DssiSynthIF::init is also NRPN control. Using CC.\n");
+ #endif
+ }
+ else
+ if(DSSI_IS_NRPN(ctlnum))
+ {
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::init is NRPN control\n");
+ #endif
+
+ ctlnum = DSSI_NRPN_NUMBER(c) + CTRL_NRPN14_OFFSET;
+ }
+
+ }
+
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::init inserting to midiCtl2PortMap: ctlnum:%d k:%d\n", ctlnum, k);
+ #endif
+
+ // We have a controller number! Insert it and the DSSI port number into the map.
+ // p3.3.39 Removed. Doesn't say whether it's in or out! Don't need this for now.
+ //synth->midiCtl2PortMap.insert(std::pair<int, int>(ctlnum, k));
+
+ */
+
+ // - Control outs are not handled but still must be connected to something.
+ ld->connect_port(handle, i, &controlsOut[k].val);
+ }
+
+ // Set the latency to zero.
+ //controls[controlPorts].val = 0.0;
+ // Insert a controller for latency and the DSSI port number into the map.
+ //synth->midiCtl2PortMap.insert(std::pair<int, int>(CTRL_NRPN14_OFFSET + 0x2000, controlPorts));
+ // Connect the port.
+ //ld->connect_port(handle, controlPorts, &controls[controlPorts].val);
+
+ // Just a test. It works! We can instantiate a ladspa plugin for the synth. But it needs more work...
+ //plugins.add(&synth->info, LADSPA_Descriptor_Function(NULL), ld, false);
+
+ if (ld->activate)
+ ld->activate(handle);
+
+ // Set current configuration values.
+ if(dssi->configure)
+ {
+ char *rv = dssi->configure(handle, DSSI_PROJECT_DIRECTORY_KEY,
+ museProject.toLatin1().constData()); //song->projectPath()
+
+ if(rv)
+ {
+ fprintf(stderr, "MusE: Warning: plugin doesn't like project directory: \"%s\"\n", rv);
+ free(rv);
+ }
+
+ for(ciStringParamMap r = synti->_stringParamMap.begin(); r != synti->_stringParamMap.end(); ++r)
+ {
+ rv = 0;
+ rv = dssi->configure(handle, r->first.c_str(), r->second.c_str());
+ if(rv)
+ {
+ fprintf(stderr, "MusE: Warning: plugin config key: %s value: %s \"%s\"\n", r->first.c_str(), r->second.c_str(), rv);
+ free(rv);
+ }
+ }
+ }
+
+ // Set current program.
+ if(dssi->select_program)
+ dssi->select_program(handle, synti->_curBankL, synti->_curProgram);
+
+ //
+ // For stored initial control values, let SynthI::initInstance() take care of that via ::setParameter().
+ //
+
+ return true;
+ }
+
+//---------------------------------------------------------
+// DssiSynthIF
+//---------------------------------------------------------
+
+DssiSynthIF::DssiSynthIF(SynthI* s)
+ : SynthIF(s)
+ {
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::DssiSynthIF\n");
+ #endif
+
+ synth = 0;
+ handle = NULL;
+ controls = 0;
+ controlsOut = 0;
+
+ //_curBank = 0;
+ //_curProgram = 0;
+
+ //#ifdef OSC_SUPPORT
+ //_oscif.setSynthIF(this);
+ //#endif
+
+ //_guiVisible = false;
+ //uiTarget = 0;
+ //uiOscShowPath = 0;
+ //uiOscControlPath = 0;
+ //uiOscConfigurePath = 0;
+ //uiOscProgramPath = 0;
+ //uiOscPath = 0;
+ //guiPid = -1;
+ //guiQProc = 0;
+
+ audioInBuffers = 0;
+ audioOutBuffers = 0;
+ }
+
+//---------------------------------------------------------
+// ~DssiSynthIF
+//---------------------------------------------------------
+
+DssiSynthIF::~DssiSynthIF()
+{
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::~DssiSynthIF\n");
+ #endif
+
+ if(synth)
+ {
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::~DssiSynthIF synth:%p\n", synth);
+ #endif
+
+ if(synth->dssi)
+ {
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::~DssiSynthIF synth->dssi:%p\n", synth->dssi);
+ #endif
+
+ if(synth->dssi->LADSPA_Plugin)
+ {
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::~DssiSynthIFsynth->dssi->LADSPA_Plugin:%p\n", synth->dssi->LADSPA_Plugin);
+ #endif
+ }
+ }
+ }
+
+ if(synth && synth->dssi && synth->dssi->LADSPA_Plugin)
+ {
+ const DSSI_Descriptor* dssi = synth->dssi;
+ const LADSPA_Descriptor* descr = dssi->LADSPA_Plugin;
+
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::~DssiSynthIF checking cleanup function exists\n");
+ #endif
+
+ if(descr->cleanup)
+ {
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::~DssiSynthIF calling cleanup function\n");
+ #endif
+
+ descr->cleanup(handle);
+ }
+ }
+
+ /*
+ //if (guiPid != -1)
+ // kill(guiPid, SIGHUP);
+ if(guiQProc)
+ {
+ if(guiQProc->isRunning())
+ {
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::~DssiSynthIF killing guiQProc\n");
+ #endif
+
+ guiQProc->kill();
+ }
+
+ //delete guiQProc;
+ }
+
+ if(uiOscShowPath)
+ free(uiOscShowPath);
+ if(uiOscControlPath)
+ free(uiOscControlPath);
+ if(uiOscConfigurePath)
+ free(uiOscConfigurePath);
+ if(uiOscProgramPath)
+ free(uiOscProgramPath);
+ if(uiOscPath)
+ free(uiOscPath);
+ if(uiTarget)
+ lo_address_free(uiTarget);
+ */
+
+ if(audioInBuffers)
+ {
+ //for(int i = 0; i < synth->_inports; ++i)
+ //{
+ // if(audioInBuffers[i])
+ // delete[] audioInBuffers[i];
+ //}
+ for(unsigned long i = 0; i < synth->_inports; ++i)
+ {
+ if(audioInBuffers[i])
+ free(audioInBuffers[i]);
+ }
+ delete[] audioInBuffers;
+ }
+
+ if(audioOutBuffers)
+ {
+ //for(int i = 0; i < synth->_outports; ++i)
+ //{
+ // if(audioOutBuffers[i])
+ // delete[] audioOutBuffers[i];
+ //}
+ for(unsigned long i = 0; i < synth->_outports; ++i)
+ {
+ if(audioOutBuffers[i])
+ free(audioOutBuffers[i]);
+ }
+ delete[] audioOutBuffers;
+ }
+
+ if(controls)
+ delete[] controls;
+
+ if(controlsOut)
+ delete[] controlsOut;
+}
+
+//---------------------------------------------------------
+// getParameter
+//---------------------------------------------------------
+
+float DssiSynthIF::getParameter(unsigned long n) const
+{
+ if(n >= synth->_controlInPorts)
+ {
+ printf("DssiSynthIF::getParameter param number %ld out of range of ports:%ld\n", n, synth->_controlInPorts);
+ return 0.0;
+ }
+
+ if(!controls)
+ return 0.0;
+
+ return controls[n].val;
+}
+
+//---------------------------------------------------------
+// setParameter
+//---------------------------------------------------------
+
+void DssiSynthIF::setParameter(unsigned long n, float v)
+{
+ if(n >= synth->_controlInPorts)
+ {
+ printf("DssiSynthIF::setParameter param number %ld out of range of ports:%ld\n", n, synth->_controlInPorts);
+ return;
+ }
+
+ if(!controls)
+ return;
+
+ controls[n].val = v;
+
+ // Notify that changes are to be sent upon heartbeat.
+ // TODO: No, at least not for now. So far, setParameter is only called during loading of stored params,
+ // and we don't want this interfering with oscUpdate which also sends the values.
+ //synti->_guiUpdateControls[n] = true;
+}
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+//void DssiSynthIF::write(Xml&) const
+void DssiSynthIF::write(int level, Xml& xml) const
+{
+ //bool vstsaved = false;
+
+#ifdef DSSI_VST_CHUNK_SUPPORT
+ //---------------------------------------------
+ // dump current state of synth
+ //---------------------------------------------
+ printf("dumping DSSI custom data! %d\n", synth->dssi->getCustomData);
+
+ // this is only needed and supported if
+ // we are talking to a VST plugin at the other end.
+ std::string name = synth->dssi->LADSPA_Plugin->Name;
+ if ((name.length()> 4) && name.substr(name.length() - 4) == " VST")
+ {
+ printf("is vst plugin, commencing data dump, apiversion=%d!\n", synth->dssi->DSSI_API_Version);
+ unsigned long len = 0;
+ void* p = 0;
+ synth->dssi->getCustomData(handle,&p, &len);
+ if (len) {
+ xml.tag(level++, "midistate");
+ xml.nput(level++, "<event type=\"%d\"", Sysex);
+ xml.nput(" datalen=\"%d\">\n", len+7 /*VSTSAVE*/);
+ xml.nput(level, "");
+ xml.nput("56 53 54 53 41 56 45 "); // embed a save marker "string 'VSTSAVE'
+ for (long unsigned int i = 0; i < len; ++i) {
+ if (i && (((i+7) % 16) == 0)) {
+ xml.nput("\n");
+ xml.nput(level, "");
+ }
+ xml.nput("%02x ", ((char*)(p))[i] & 0xff);
+ }
+ xml.nput("\n");
+ xml.tag(level--, "/event");
+ xml.etag(level--, "midistate");
+ //vstsaved = true;
+ }
+ }
+#else
+ printf("support for vst chunks not compiled in!\n");
+#endif
+
+ /*
+ // p3.3.39 Store the state of current program and bank and all input control values, but only if VSTSAVE above didn't do it already!
+ // TODO: Not quite good enough, we would want to store all controls for EACH program, not just the current one.
+ // Need to modify controls array to be inside a program array and act as a cache when the user changes a control on a particular program.
+ if(!vstsaved)
+ {
+ if(synth->_controlInPorts)
+ {
+ // TODO: Hmm, what if these sizes change (platform etc.)? Hard code? Not good - need to store complete value.
+ const int fs = sizeof(float);
+ const int uls = sizeof(unsigned long);
+
+ // Data length: Version major and minor bytes, bank + program, and controllers.
+ const unsigned long len = 2 + 2 * uls + synth->_controlInPorts * fs;
+
+ unsigned long prog = _curBank;
+ unsigned long bnk = _curProgram;
+
+ xml.tag(level++, "midistate");
+ xml.nput(level++, "<event type=\"%d\"", Sysex);
+ xml.nput(" datalen=\"%d\">\n", len+9); // "PARAMSAVE" length + data length.
+ xml.nput(level, "");
+ xml.nput("50 41 52 41 4d 53 41 56 45 "); // Embed a save marker string "PARAMSAVE".
+
+ unsigned long i = 9;
+
+ // Store PARAMSAVE version major...
+ char uc = DSSI_PARAMSAVE_VERSION_MAJOR;
+ if(i && ((i % 16) == 0))
+ {
+ xml.nput("\n");
+ xml.nput(level, "");
+ }
+ xml.nput("%02x ", uc & 0xff);
+ ++i;
+
+ // Store PARAMSAVE version minor...
+ uc = DSSI_PARAMSAVE_VERSION_MINOR;
+ if(i && ((i % 16) == 0))
+ {
+ xml.nput("\n");
+ xml.nput(level, "");
+ }
+ xml.nput("%02x ", uc & 0xff);
+ ++i;
+
+ // Store bank...
+ void* p = &bnk;
+ for(int j = 0; j < uls; ++j)
+ {
+ if(i && ((i % 16) == 0))
+ {
+ xml.nput("\n");
+ xml.nput(level, "");
+ }
+ xml.nput("%02x ", ((char*)(p))[j] & 0xff);
+ ++i;
+ }
+
+ // Store program...
+ p = &prog;
+ for(int j = 0; j < uls; ++j)
+ {
+ if(i && ((i % 16) == 0))
+ {
+ xml.nput("\n");
+ xml.nput(level, "");
+ }
+ xml.nput("%02x ", ((char*)(p))[j] & 0xff);
+ ++i;
+ }
+
+ // Store controls...
+ for(unsigned long c = 0; c < synth->_controlInPorts; ++c)
+ {
+ float v = controls[c].val;
+ p = &v;
+ for(int j = 0; j < fs; ++j)
+ {
+ if(i && ((i % 16) == 0))
+ {
+ xml.nput("\n");
+ xml.nput(level, "");
+ }
+ xml.nput("%02x ", ((char*)(p))[j] & 0xff);
+ ++i;
+ }
+ }
+ xml.nput("\n");
+ xml.tag(level--, "/event");
+ xml.etag(level--, "midistate");
+ }
+ }
+ */
+
+ // Store controls as parameters...
+ for(unsigned long c = 0; c < synth->_controlInPorts; ++c)
+ {
+ float f = controls[c].val;
+ xml.floatTag(level, "param", f);
+ //xml.tag(level, "param name=\"%s\" val=\"%s\"/", name, r->first.c_str(), r->second.c_str());
+ }
+}
+
+//---------------------------------------------------------
+// preProcessAlways
+//---------------------------------------------------------
+
+void DssiSynthIF::preProcessAlways()
+{
+
+}
+
+//---------------------------------------------------------
+// processEvent
+// Return true if event pointer filled.
+//--------------------------------------------------------
+
+bool DssiSynthIF::processEvent(const MidiPlayEvent& e, snd_seq_event_t* event)
+{
+ const DSSI_Descriptor* dssi = synth->dssi;
+
+ int chn = e.channel();
+ int a = e.dataA();
+ int b = e.dataB();
+ //for sysex
+ //QByteArray ba = QByteArray((const char*)e.data(), e.len());
+ //we must had 0xF0 at the beginning and 0xF7 at the end of e.data()
+ //ba.push_front(0xF0);
+ //ba.push_back(0xF7);
+
+ //QByteArray ba();
+ ////ba.assign((const char*)e.data(), e.len());
+ ////ba.duplicate((const char*)e.data(), e.len());
+ ////ba.setRawData((const char*)e.data(), e.len());
+ //int len = e.len() + 2;
+
+ int len = e.len();
+ char ca[len + 2];
+
+ ca[0] = 0xF0;
+ memcpy(ca + 1, (const char*)e.data(), len);
+ ca[len + 1] = 0xF7;
+
+ len += 2;
+
+ //snd_seq_event_t* event = &events[nevents];
+ event->queue = SND_SEQ_QUEUE_DIRECT;
+
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::processEvent midi event type:%d chn:%d a:%d b:%d\n", e.type(), chn, a, b);
+ #endif
+
+ switch(e.type())
+ {
+ case ME_NOTEON:
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::processEvent midi event is ME_NOTEON\n");
+ #endif
+
+ if(b)
+ snd_seq_ev_set_noteon(event, chn, a, b);
+ else
+ snd_seq_ev_set_noteoff(event, chn, a, 0);
+ break;
+ case ME_NOTEOFF:
+ snd_seq_ev_set_noteoff(event, chn, a, 0);
+ break;
+ case ME_PROGRAM:
+ {
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::processEvent midi event is ME_PROGRAM\n");
+ #endif
+
+ int bank = (a >> 8) & 0xff;
+ int prog = a & 0xff;
+ //_curBank = bank;
+ //_curProgram = prog;
+ synti->_curBankH = 0;
+ synti->_curBankL = bank;
+ synti->_curProgram = prog;
+
+ if(dssi->select_program)
+ {
+ dssi->select_program(handle, bank, prog);
+ // Notify that changes are to be sent upon heartbeat.
+ synti->_guiUpdateProgram = true;
+ }
+ // Event pointer not filled. Return false.
+ return false;
+ }
+ break;
+ case ME_CONTROLLER:
+ {
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::processEvent midi event is ME_CONTROLLER\n");
+ #endif
+
+ if((a == 0) || (a == 32))
+ return false;
+
+ if(a == CTRL_PROGRAM)
+ {
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::processEvent midi event is ME_CONTROLLER, dataA is CTRL_PROGRAM\n");
+ #endif
+
+ int bank = (b >> 8) & 0xff;
+ int prog = b & 0xff;
+
+ //_curBank = bank;
+ //_curProgram = prog;
+ synti->_curBankH = 0;
+ synti->_curBankL = bank;
+ synti->_curProgram = prog;
+
+ if(dssi->select_program)
+ {
+ dssi->select_program(handle, bank, prog);
+ // Notify that changes are to be sent upon heartbeat.
+ synti->_guiUpdateProgram = true;
+ }
+ // Event pointer not filled. Return false.
+ return false;
+ }
+
+ if(a == CTRL_PITCH)
+ {
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::processEvent midi event is ME_CONTROLLER, dataA is CTRL_PITCH\n");
+ #endif
+
+ b &= 0x3fff;
+ snd_seq_ev_set_pitchbend(event, chn, b);
+ // Event pointer filled. Return true.
+ return true;
+ }
+
+ const LADSPA_Descriptor* ld = dssi->LADSPA_Plugin;
+
+ ciMidiCtl2LadspaPort ip = synth->midiCtl2PortMap.find(a);
+ // Is it just a regular midi controller, not mapped to a LADSPA port (either by the plugin or by us)?
+ // NOTE: There's no way to tell which of these controllers is supported by the plugin.
+ // For example sustain footpedal or pitch bend may be supported, but not mapped to any LADSPA port.
+ if(ip == synth->midiCtl2PortMap.end())
+ {
+ // p3.3.39 Changed to return false because of crashes with unknown controllers when switching a midi track
+ // among different dssi synths and regular synths etc. For example high RPN offset numbers (set by another
+ // device selected into the midi port before selecting this synth) were passing through here when in fact
+ // the particular synth had no such midi controllers.
+ // ========================== No, that leaves out regular controllers like footpedal
+ //#ifdef DSSI_DEBUG
+ //fprintf(stderr, "DssiSynthIF::processEvent dataA:%d not found in map (not a ladspa controller). Ignoring.\n", a);
+ //#endif
+ //return false;
+
+ //#ifdef DSSI_DEBUG
+ //fprintf(stderr, "DssiSynthIF::processEvent dataA:%d not found in map (not a ladspa controller). Filling event as regular controller.\n", a);
+ //#endif
+ //snd_seq_ev_set_controller(event, chn, a, b);
+ //return true;
+
+ int ctlnum = a;
+ //switch(midiControllerType(a))
+ if(midiControllerType(a) != MidiController::Controller7)
+ return false;
+ else
+ {
+ /*
+ case MidiController::NRPN14:
+ case MidiController::Controller14:
+ case MidiController::Pitch:
+ case MidiController::Program:
+ case MidiController::RPN:
+ case MidiController::RPN14:
+ case MidiController::NRPN:
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::processEvent non-ladspa midi event controller unsupported. DataA:%d\n", a);
+ #endif
+ return false;
+ */
+
+ //case MidiController::Controller7:
+ #ifdef DSSI_DEBUG
+ //fprintf(stderr, "DssiSynthIF::processEvent midi event is Controller7. Changing to DSSI_CC type. Current dataA:%d\n", a);
+ fprintf(stderr, "DssiSynthIF::processEvent non-ladspa midi event is Controller7. Current dataA:%d\n", a);
+ #endif
+ //a = DSSI_CC(a);
+ a &= 0x7f;
+ ctlnum = DSSI_CC_NUMBER(ctlnum);
+ // break;
+
+ /*
+ case MidiController::NRPN14:
+ #ifdef DSSI_DEBUG
+ // fprintf(stderr, "DssiSynthIF::processEvent midi event is NRPN. Changing to DSSI_NRPN type. Current dataA:%d\n", a);
+ fprintf(stderr, "DssiSynthIF::processEvent non-ladspa midi event is NRPN. Current dataA:%d\n", a);
+ #endif
+ //a = DSSI_NRPN(a - CTRL_NRPN14_OFFSET);
+ a &= 0x3fff;
+ ctlnum = DSSI_NRPN_NUMBER(ctlnum);
+ break;
+ case MidiController::Controller14:
+ a &= 0x7f;
+ break;
+ case MidiController::Pitch:
+ // Should be caught above!
+ #ifdef DSSI_DEBUG
+ //fprintf(stderr, "DssiSynthIF::processEvent non-ladspa midi event is Pitch. DataA:%d\n", a);
+ fprintf(stderr, "DssiSynthIF::processEvent Error! non-ladspa midi event is Pitch. Should have been caught already! DataA:%d\n", a);
+ #endif
+ //a &= 0x3fff;
+ //snd_seq_ev_set_pitchbend(event, chn, b);
+ // Event pointer filled. Return true.
+ //return true;
+ // Event pointer not filled. Return false.
+ return false;
+ case MidiController::Program:
+ // Should be caught above!
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::processEvent Error! non-ladspa midi event is Program. Should have been caught already! DataA:%d\n", a);
+ #endif
+ return false;
+ case MidiController::RPN:
+ case MidiController::RPN14:
+ case MidiController::NRPN:
+ default:
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::processEvent non-ladspa midi event is RPN, RPN14, or NRPN type. DataA:%d\n", a);
+ #endif
+ break;
+ */
+ }
+
+ // Verify it's the same number.
+ //if(ctlnum != a)
+ //{
+ // #ifdef DSSI_DEBUG
+ // printf("DssiSynthIF::processEvent Error! non-ladspa midi ctlnum:%d != event dataA:%d\n", ctlnum, a);
+ // #endif
+ // Event not filled. Return false.
+
+ // TEMP: TODO: Turn on later
+ //return false;
+ //}
+
+ // Fill the event.
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::processEvent non-ladspa filling midi event chn:%d dataA:%d dataB:%d\n", chn, a, b);
+ #endif
+ snd_seq_ev_set_controller(event, chn, a, b);
+ return true;
+ }
+
+ //int num = ip->first;
+ unsigned long k = ip->second;
+
+ unsigned long i = synth->pIdx[k];
+
+ int ctlnum = DSSI_NONE;
+ if(dssi->get_midi_controller_for_port)
+ ctlnum = dssi->get_midi_controller_for_port(handle, i);
+
+ // No midi controller for the ladspa port? Send to ladspa control.
+ if(ctlnum == DSSI_NONE)
+ {
+ // Sanity check.
+ if(k > synth->_controlInPorts)
+ return false;
+
+ // TODO: If necessary... choose non-existing numbers...
+ //for(int k = 0; k < controlPorts; ++k)
+ //{
+ // int i = synth->pIdx[k];
+ //}
+
+ // Simple but flawed solution: Start them at 0x60000 + 0x2000 = 0x62000. Max NRPN number is 0x3fff.
+ ctlnum = k + (CTRL_NRPN14_OFFSET + 0x2000);
+ }
+ // p3.3.39
+ else
+ {
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::processEvent plugin requests DSSI-style ctlnum:%x(h) %d(d) be mapped to control port:%ld...\n", ctlnum, ctlnum, i);
+ #endif
+
+ int c = ctlnum;
+ // Can be both CC and NRPN! Prefer CC over NRPN.
+ if(DSSI_IS_CC(ctlnum))
+ {
+ ctlnum = DSSI_CC_NUMBER(c);
+
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::processEvent is CC ctlnum:%d\n", ctlnum);
+ #endif
+
+ #ifdef DSSI_DEBUG
+ if(DSSI_IS_NRPN(ctlnum))
+ printf("DssiSynthIF::processEvent is also NRPN control. Using CC.\n");
+ #endif
+ }
+ else
+ if(DSSI_IS_NRPN(ctlnum))
+ {
+ ctlnum = DSSI_NRPN_NUMBER(c) + CTRL_NRPN14_OFFSET;
+
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::processEvent is NRPN ctlnum:%x(h) %d(d)\n", ctlnum, ctlnum);
+ #endif
+ }
+
+ }
+
+ //{
+ float val = midi2LadspaValue(ld, i, ctlnum, b);
+
+ #ifdef DSSI_DEBUG
+ //fprintf(stderr, "DssiSynthIF::processEvent No midi controller for control port:%d port:%d dataA:%d Converting val from:%d to ladspa:%f\n", i, k, a, b, val);
+ fprintf(stderr, "DssiSynthIF::processEvent control port:%ld port:%ld dataA:%d Converting val from:%d to ladspa:%f\n", i, k, a, b, val);
+ #endif
+
+ // Set the ladspa port value.
+ controls[k].val = val;
+ // FIXME: Testing - Works but is this safe in a RT process callback? Try hooking into gui heartbeat timer instead...
+ //lo_send(uiTarget, uiOscControlPath, "if", i, val);
+ // Notify that changes are to be sent upon heartbeat.
+ synti->_guiUpdateControls[k] = true;
+
+ // Since we absorbed the message as a ladspa control change, return false - the event is not filled.
+ return false;
+ //}
+
+ // p3.3.39 Removed.
+ // "Hosts should not deliver through run_synth any MIDI controller events that have already
+ // been mapped to control port values."
+ // D'oh! My mistake, did not understand that the mapping is only a *request* that the app map MIDI
+ // controller events to a LADSPA port, and must do the conversion, not to actually *send* them via MIDI...
+ /*
+ else
+ {
+ switch(midiControllerType(a))
+ {
+ case MidiController::Controller7:
+ #ifdef DSSI_DEBUG
+ //fprintf(stderr, "DssiSynthIF::processEvent midi event is Controller7. Changing to DSSI_CC type. Current dataA:%d\n", a);
+ fprintf(stderr, "DssiSynthIF::processEvent midi event is Controller7. Current dataA:%d\n", a);
+ #endif
+ //a = DSSI_CC(a);
+ a &= 0x7f;
+ ctlnum = DSSI_CC_NUMBER(ctlnum);
+ break;
+ case MidiController::NRPN14:
+ #ifdef DSSI_DEBUG
+ // fprintf(stderr, "DssiSynthIF::processEvent midi event is NRPN. Changing to DSSI_NRPN type. Current dataA:%d\n", a);
+ fprintf(stderr, "DssiSynthIF::processEvent midi event is NRPN. Current dataA:%d\n", a);
+ #endif
+ //a = DSSI_NRPN(a - CTRL_NRPN14_OFFSET);
+ a &= 0x3fff;
+ ctlnum = DSSI_NRPN_NUMBER(ctlnum);
+ break;
+ case MidiController::Controller14:
+ a &= 0x7f;
+ break;
+ case MidiController::Pitch:
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::processEvent midi event is Pitch. DataA:%d\n", a);
+ #endif
+ a &= 0x3fff;
+ break;
+ case MidiController::Program:
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::processEvent midi event is Program. DataA:%d\n", a);
+ #endif
+ a &= 0x3fff;
+ break;
+ case MidiController::RPN:
+ case MidiController::RPN14:
+ case MidiController::NRPN:
+ default:
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::processEvent midi event is RPN, RPN14, or NRPN type. DataA:%d\n", a);
+ #endif
+ break;
+ }
+
+ // Verify it's the same number.
+ if(ctlnum != a)
+ {
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::processEvent Error! ctlnum:%d != event dataA:%d\n", ctlnum, a);
+ #endif
+ // Event not filled. Return false.
+
+ // TEMP: TODO: Turn on later
+ //return false;
+ }
+
+ // Fill the event.
+ // FIXME: Darn! We get to this point, but no change in sound (later). Nothing happens, at least with LTS -
+ // which is the only one I found so far with midi controllers.
+ // Tried with/without converting to DSSI_CC and DSSI_NRPN. What could be wrong here?
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::processEvent filling event chn:%d dataA:%d dataB:%d\n", chn, a, b);
+ #endif
+ snd_seq_ev_set_controller(event, chn, a, b);
+ }
+ */
+
+ }
+ break;
+ case ME_PITCHBEND:
+ snd_seq_ev_set_pitchbend(event, chn, a);
+ break;
+ case ME_AFTERTOUCH:
+ snd_seq_ev_set_chanpress(event, chn, a);
+ break;
+ case ME_SYSEX:
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::processEvent midi event is ME_SYSEX\n");
+ #endif
+
+ if (QString((const char*)e.data()).startsWith("VSTSAVE")) {
+#ifdef DSSI_VST_CHUNK_SUPPORT
+ printf("loading chunk from sysex %s!\n", e.data()+7);
+ dssi->setCustomData(handle, e.data()+7 /* len of str*/,e.len()-7);
+#else
+ printf("support for vst chunks not compiled in!\n");
+#endif
+ // Event not filled.
+ return false;
+ }
+ /*
+ // p3.3.39 Read the state of current bank and program and all input control values.
+ // TODO: Needs to be better. See write().
+ else
+ if (QString((const char*)e.data()).startsWith("PARAMSAVE"))
+ {
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::processEvent midi event is ME_SYSEX PARAMSAVE\n");
+ #endif
+
+ unsigned long dlen = e.len() - 9; // Minus "PARAMSAVE"
+ if(dlen > 0)
+ {
+ //if(dlen < 2 * sizeof(unsigned long))
+ if(dlen < (2 + 2 * sizeof(unsigned long))) // Version major and minor bytes, bank and program.
+ printf("DssiSynthIF::processEvent Error: PARAMSAVE data length does not include at least version major and minor, bank and program!\n");
+ else
+ {
+ // Not required, yet.
+ //char vmaj = *((char*)(e.data() + 9)); // After "PARAMSAVE"
+ //char vmin = *((char*)(e.data() + 10));
+
+ unsigned long* const ulp = (unsigned long*)(e.data() + 11); // After "PARAMSAVE" + version major and minor.
+ // TODO: TODO: Set plugin bank and program.
+ _curBank = ulp[0];
+ _curProgram = ulp[1];
+
+ dlen -= (2 + 2 * sizeof(unsigned long)); // After the version major and minor, bank and program.
+
+ if(dlen > 0)
+ {
+ if((dlen % sizeof(float)) != 0)
+ printf("DssiSynthIF::processEvent Error: PARAMSAVE float data length not integral multiple of float size!\n");
+ else
+ {
+ const unsigned long n = dlen / sizeof(float);
+ if(n != synth->_controlInPorts)
+ printf("DssiSynthIF::processEvent Warning: PARAMSAVE number of floats:%ld != number of controls:%ld\n", n, synth->_controlInPorts);
+
+ // Point to location after "PARAMSAVE", version major and minor, bank and progam.
+ float* const fp = (float*)(e.data() + 9 + 2 + 2 * sizeof(unsigned long));
+
+ for(unsigned long i = 0; i < synth->_controlInPorts && i < n; ++i)
+ {
+ const float v = fp[i];
+ controls[i].val = v;
+ }
+ }
+ }
+ }
+ }
+ // Event not filled.
+ return false;
+ }
+ */
+ else
+ {
+ // NOTE: There is a limit on the size of a sysex. Got this:
+ // "DssiSynthIF::processEvent midi event is ME_SYSEX"
+ // "WARNING: MIDI event of type ? decoded to 367 bytes, discarding"
+ // That might be ALSA doing that.
+ snd_seq_ev_set_sysex(event, len,
+ //(unsigned char*)ba.data());
+ (unsigned char*)ca);
+ }
+ break;
+ default:
+ if(debugMsg)
+ fprintf(stderr, "DssiSynthIF::processEvent midi event unknown type:%d\n", e.type());
+ // Event not filled.
+ return false;
+ break;
+ }
+
+ return true;
+}
+
+//---------------------------------------------------------
+// getData
+//---------------------------------------------------------
+
+//void DssiSynthIF::getData(MidiEventList* el, unsigned pos, int ch, unsigned samples, float** data)
+iMPEvent DssiSynthIF::getData(MidiPort* /*mp*/, MPEventList* el, iMPEvent /*i*/, unsigned pos, int ports, unsigned n, float** buffer)
+{
+ //#ifdef DSSI_DEBUG
+ // fprintf(stderr, "DssiSynthIF::getData elsize:%d pos:%d ports:%d samples:%d processed already?:%d\n", el->size(), pos, ports, n, synti->processed());
+ //#endif
+
+ //BEGIN: Process midi events
+
+ // FIXME: Add 10(?) for good luck in case volatile size changes (increments) while we're processing.
+ //unsigned long nevents = el->size();
+ unsigned long nevents = el->size() + synti->putFifo.getSize() + 10;
+
+ /*
+ while (!synti->putFifo.isEmpty()) {
+ MidiEvent event = synti->putFifo.get();
+ printf("Dssi: FIFO\n");
+ }
+ */
+
+ snd_seq_event_t events[nevents];
+ memset(events, 0, sizeof(events));
+ nevents = 0;
+
+ //int curPos = pos;
+ //unsigned endPos = pos + samples;
+ unsigned endPos = pos + n;
+ //int off = pos;
+ int frameOffset = audio->getFrameOffset();
+
+ //iMidiEvent i = el->begin();
+ iMPEvent i = el->begin();
+
+ // Process event list events...
+ for(; i != el->end(); ++i)
+ {
+ //if(i->time() >= endPos) // Doesn't work, at least here in muse-1. The event times are all
+ // just slightly after the endPos, EVEN IF transport is stopped.
+ // So it misses all the notes.
+ if(i->time() >= (endPos + frameOffset)) // NOTE: frameOffset? Tested, examined printouts of times: Seems OK for playback.
+ break;
+
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::getData eventlist event time:%d\n", i->time());
+ #endif
+
+ // p3.3.39 Update hardware state so knobs and boxes are updated. Optimize to avoid re-setting existing values.
+ // Same code as in MidiPort::sendEvent()
+ if(synti->midiPort() != -1)
+ {
+ MidiPort* mp = &midiPorts[synti->midiPort()];
+ if(i->type() == ME_CONTROLLER)
+ {
+ int da = i->dataA();
+ int db = i->dataB();
+ db = mp->limitValToInstrCtlRange(da, db);
+ if(!mp->setHwCtrlState(i->channel(), da, db))
+ continue;
+ //mp->setHwCtrlState(i->channel(), da, db);
+ }
+ else
+ if(i->type() == ME_PITCHBEND)
+ {
+ int da = mp->limitValToInstrCtlRange(CTRL_PITCH, i->dataA());
+ if(!mp->setHwCtrlState(i->channel(), CTRL_PITCH, da))
+ continue;
+ //mp->setHwCtrlState(i->channel(), CTRL_PITCH, da);
+ }
+ else
+ if(i->type() == ME_PROGRAM)
+ {
+ if(!mp->setHwCtrlState(i->channel(), CTRL_PROGRAM, i->dataA()))
+ continue;
+ //mp->setHwCtrlState(i->channel(), CTRL_PROGRAM, i->dataA());
+ }
+ }
+
+ if(processEvent(*i, &events[nevents]))
+ ++nevents;
+ }
+
+ // Now process putEvent events...
+ while(!synti->putFifo.isEmpty())
+ {
+ MidiPlayEvent e = synti->putFifo.get();
+
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::getData putFifo event time:%d\n", e.time());
+ #endif
+
+ // Set to the current time.
+ // FIXME: FIXME: Wrong - we should be setting some kind of linear realtime wallclock here, not song pos.
+ e.setTime(pos);
+ if(processEvent(e, &events[nevents]))
+ ++nevents;
+ }
+
+ // Now process OSC gui input control fifo events.
+ // It is probably more important that these are processed last so that they take precedence over all other
+ // events because OSC + DSSI/DSSI-VST are fussy about receiving feedback via these control ports, from GUI changes.
+ #ifdef OSC_SUPPORT
+ unsigned long ctls = synth->_controlInPorts;
+ for(unsigned long k = 0; k < ctls; ++k)
+ {
+ OscControlFifo* cfifo = _oscif.oscFifo(k);
+ if(!cfifo)
+ continue;
+
+ // If there are 'events' in the fifo, get exactly one 'event' per control per process cycle...
+ if(!cfifo->isEmpty())
+ {
+ OscControlValue v = cfifo->get();
+
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::getData OscControlFifo event input control number:%ld value:%f\n", k, v.value);
+ #endif
+
+ // Set the ladspa control port value.
+ controls[k].val = v.value;
+
+ // TODO: (From plugin module, adapt for synth if/when our own plugin gui is added to synths).
+ // Need to update the automation value, otherwise the block above overwrites with the last automation value.
+ ///if(_track)
+ ///{
+ // Since we are now in the audio thread context, there's no need to send a message,
+ // just modify directly.
+ //audio->msgSetPluginCtrlVal(this, genACnum(_id, i), controls[i].val);
+ /// _track->setPluginCtrlVal(k, v.value)
+ ///}
+ }
+ }
+ #endif
+
+/* // This is from MESS... Tried this here, didn't work, need to re-adapt, try again.
+ int evTime = i->time();
+ if(evTime == 0)
+ {
+ printf("DssiSynthIF::getData - time is 0!\n");
+ //continue;
+ evTime=frameOffset; // will cause frame to be zero, problem?
+ }
+
+ int frame = evTime - frameOffset;
+
+ if(frame >= endPos)
+ {
+ printf("DssiSynthIF::getData frame > endPos!! frame = %d >= endPos %d, i->time() %d, frameOffset %d curPos=%d\n", frame, endPos, i->time(), frameOffset,curPos);
+ continue;
+ }
+
+ if(frame > curPos)
+ {
+ if(frame < pos)
+ printf("DssiSynthIF::getData should not happen: missed event %d\n", pos -frame);
+ else
+ {
+*/
+
+/*
+ }
+ curPos = frame;
+ }
+*/
+// }
+
+ el->erase(el->begin(), i);
+ //END: Process midi events
+
+ //BEGIN: Run the synth
+ // All ports must be connected to something!
+
+ // First, copy the given input buffers to our local input buffers.
+ unsigned long np, k;
+ //np = portsin > synth->_inports ? synth->_inports : portsin;
+ //for(k = 0; k < np; ++k)
+ // memcpy(audioInBuffers[k], inbuffer[k], sizeof(float) * n);
+ //for(; k < portsin; ++k)
+ // memset(audioInBuffers[k], 0, sizeof(float) * n);
+
+ // Watch our limits.
+ np = ports > synth->_outports ? synth->_outports : ports;
+
+ const DSSI_Descriptor* dssi = synth->dssi;
+ const LADSPA_Descriptor* descr = dssi->LADSPA_Plugin;
+ k = 0;
+ // Connect the given buffers directly to the ports, up to a max of synth ports.
+ for(; k < np; ++k)
+ descr->connect_port(handle, synth->oIdx[k], buffer[k]);
+ // Connect the remaining ports to some local buffers (not used yet).
+ for(; k < synth->_outports; ++k)
+ descr->connect_port(handle, synth->oIdx[k], audioOutBuffers[k]);
+
+ /*
+ //
+ // p3.3.39 Handle inputs...
+ //
+ //if((song->bounceTrack != this) && !noInRoute())
+ if(!((AudioTrack*)synti)->noInRoute())
+ {
+ RouteList* irl = ((AudioTrack*)synti)->inRoutes();
+ iRoute i = irl->begin();
+ if(!i->track->isMidiTrack())
+ {
+ //if(debugMsg)
+ printf("DssiSynthIF::getData: Error: First route is a midi track route!\n");
+ }
+ else
+ {
+ int ch = i->channel == -1 ? 0 : i->channel;
+ int remch = i->remoteChannel == -1 ? 0 : i->remoteChannel;
+ int chs = i->channels == -1 ? 0 : i->channels;
+
+ // TODO:
+ //if(ch >= synth->_inports)
+ //iUsedIdx[ch] = true;
+ //if(chs == 2)
+ // iUsedIdx[ch + 1] = true;
+
+ //((AudioTrack*)i->track)->copyData(framePos, channels, nframe, bp);
+ ((AudioTrack*)i->track)->copyData(pos, ports,
+ //(i->track->type() == Track::AUDIO_SOFTSYNTH && i->channel != -1) ? i->channel : 0,
+ i->channel,
+ i->channels,
+ n, bp);
+ }
+
+ //unsigned pos, int ports, unsigned n, float** buffer
+
+ ++i;
+ for(; i != irl->end(); ++i)
+ {
+ if(i->track->isMidiTrack())
+ {
+ //if(debugMsg)
+ printf("DssiSynthIF::getData: Error: Route is a midi track route!\n");
+ continue;
+ }
+ //((AudioTrack*)i->track)->addData(framePos, channels, nframe, bp);
+ ((AudioTrack*)i->track)->addData(framePos, channels,
+ //(i->track->type() == Track::AUDIO_SOFTSYNTH && i->channel != -1) ? i->channel : 0,
+ i->channel,
+ i->channels,
+ nframe, bp);
+ }
+ }
+ */
+
+ //#ifdef DSSI_DEBUG
+ //if(nevents)
+ // fprintf(stderr, "DssiSynthIF::getData run nevents:%d\n", nevents);
+ //#endif
+
+ // Run the synth for one segment. This processes events and gets/fills our local buffers...
+ if(synth->dssi->run_synth)
+ {
+ synth->dssi->run_synth(handle, n, events, nevents);
+
+ // NOTE: Just a test
+ //for(int m = 0; m < n; ++m)
+ //{
+ // synth->dssi->run_synth(handle, 1, events, nevents);
+ //}
+
+ }
+ else if (synth->dssi->run_multiple_synths)
+ {
+ snd_seq_event_t* ev = events;
+ synth->dssi->run_multiple_synths(1, &handle, n, &ev, &nevents);
+ }
+ //END: Run the synth
+
+ return i;
+}
+
+//---------------------------------------------------------
+// putEvent
+//---------------------------------------------------------
+
+//bool DssiSynthIF::putEvent(const MidiEvent& ev)
+bool DssiSynthIF::putEvent(const MidiPlayEvent& ev)
+ {
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::putEvent midi event time:%d chn:%d a:%d b:%d\n", ev.time(), ev.channel(), ev.dataA(), ev.dataB());
+ #endif
+
+ if (midiOutputTrace)
+ ev.dump();
+
+ return synti->putFifo.put(ev);
+
+ //return false;
+ }
+
+
+//---------------------------------------------------------
+// incInstances
+//---------------------------------------------------------
+
+void DssiSynth::incInstances(int val)
+{
+ _instances += val;
+ if (_instances == 0)
+ {
+ if (handle)
+ {
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynth::incInstances no more instances, closing library\n");
+ #endif
+
+ dlclose(handle);
+ }
+ handle = 0;
+ dssi = NULL;
+ df = NULL;
+ pIdx.clear();
+ opIdx.clear();
+ iIdx.clear();
+ oIdx.clear();
+ rpIdx.clear();
+ iUsedIdx.clear();
+ midiCtl2PortMap.clear();
+ port2MidiCtlMap.clear();
+ //synti->_guiUpdateControls.clear();
+ }
+}
+
+//---------------------------------------------------------
+// initGui
+//---------------------------------------------------------
+bool DssiSynthIF::initGui()
+{
+ #ifdef OSC_SUPPORT
+ return _oscif.oscInitGui();
+ #endif
+
+ return true;
+
+ /*
+ // Are we already running? We don't want to allow another process do we...
+ if((guiQProc != 0) && (guiQProc->isRunning()))
+ return true;
+
+ //
+ // start gui
+ //
+ static char oscUrl[1024];
+ //snprintf(oscUrl, 1024, "%s/%s", url, synti->name().toAscii().data());
+ //snprintf(oscUrl, 1024, "%s/%s", url, synti->name().toLatin1().constData());
+ snprintf(oscUrl, 1024, "%s/%s/%s", url, synth->info.baseName().toLatin1().constData(), synti->name().toLatin1().constData());
+
+ //QString guiPath(info.path() + "/" + info.baseName());
+ QString guiPath(synth->info.dirPath() + "/" + synth->info.baseName());
+
+ QDir guiDir(guiPath, "*", QDir::Unsorted, QDir::Files);
+ if (guiDir.exists())
+ {
+ //const QFileInfoList list = guiDir.entryInfoList();
+ QStringList list = guiDir.entryList();
+
+ //for (int i = 0; i < list.size(); ++i) {
+ for (unsigned int i = 0; i < list.count(); ++i)
+ {
+
+ //QFileInfo fi = list.at(i);
+ QFileInfo fi(guiPath + QString("/") + list[i]);
+
+ QString gui(fi.filePath());
+ if (gui.contains('_') == 0)
+ continue;
+ struct stat buf;
+
+ //if (stat(gui.toAscii().data(), &buf)) {
+ if (stat(gui.toLatin1().constData(), &buf)) {
+
+ perror("stat failed");
+ continue;
+ }
+
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::initGui %s %s %s %s\n",
+ //fi.filePath().toAscii().data(),
+ //fi.fileName().toAscii().data(),
+ fi.filePath().toLatin1().constData(),
+ //fi.fileName().toLatin1().constData(),
+
+ oscUrl,
+
+ synth->info.filePath().toLatin1().constData(),
+
+ //name().toAscii().data(),
+ synth->name().toLatin1().constData());
+ #endif
+
+ if ((S_ISREG(buf.st_mode) || S_ISLNK(buf.st_mode)) &&
+ (buf.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
+ {
+ // Changed by T356.
+ // fork + execlp were causing the processes to remain after closing gui, requiring manual kill.
+ // Changed to QProcess, works OK now.
+ //if((guiPid = fork()) == 0)
+ {
+ // No QProcess created yet? Do it now. Only once per SynthIF instance. Exists until parent destroyed.
+ if(guiQProc == 0)
+ guiQProc = new QProcess(muse);
+
+ // Don't forget this, he he...
+ guiQProc->clearArguments();
+
+ guiQProc->addArgument(fi.filePath());
+ //guiQProc->addArgument(fi.fileName()); // No conventional 'Arg0' here.
+ guiQProc->addArgument(QString(oscUrl));
+ guiQProc->addArgument(synth->info.filePath());
+ guiQProc->addArgument(synth->name());
+ guiQProc->addArgument(QString("channel 1"));
+
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::initGui starting QProcess\n");
+ #endif
+
+ if(guiQProc->start() == TRUE)
+ {
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::initGui started QProcess\n");
+ #endif
+
+ //guiPid = guiQProc->processIdentifier();
+ }
+ else
+ {
+
+ // execlp(
+ // fi.filePath().toAscii().data(),
+ // fi.fileName().toAscii().data(),
+ // fi.filePath().toLatin1().constData(),
+ // fi.fileName().toLatin1().constData(),
+
+ // oscUrl,
+
+ // info.filePath().toAscii().data(),
+ // name().toAscii().data(),
+ // synth->info.filePath().toLatin1().constData(),
+ // synth->name().toLatin1().constData(),
+
+ // "channel 1", (void*)0);
+
+ fprintf(stderr, "exec %s %s %s %s failed: %s\n",
+ // fi.filePath().toAscii().data(),
+ // fi.fileName().toAscii().data(),
+ fi.filePath().toLatin1().constData(),
+ fi.fileName().toLatin1().constData(),
+ oscUrl,
+ // name().toAscii().data(),
+ synth->name().toLatin1().constData(),
+ strerror(errno));
+
+ // It's Ok, Keep going. So nothing happens. So what. The timeout in showGui will just leave.
+ // Maybe it's a 'busy' issue somewhere - allow to try again later + save work now.
+ // exit(1);
+
+ }
+
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::initGui after QProcess\n");
+ #endif
+ }
+ }
+ }
+ //synth->_hasGui = true;
+ }
+ else {
+ printf("%s: no dir for dssi gui found: %s\n",
+ //name().toAscii().data(), guiPath.toAscii().data());
+ synth->name().toLatin1().constData(), guiPath.toLatin1().constData());
+
+ //synth->_hasGui = false;
+ }
+
+ return true;
+ */
+}
+
+//---------------------------------------------------------
+// guiHeartBeat
+//---------------------------------------------------------
+
+void DssiSynthIF::guiHeartBeat()
+{
+ #ifdef OSC_SUPPORT
+ // Update the gui's program if needed.
+ if(synti->_guiUpdateProgram)
+ {
+ _oscif.oscSendProgram(synti->_curProgram, synti->_curBankL);
+ synti->_guiUpdateProgram = false;
+ }
+
+ // Update the gui's controls if needed.
+ unsigned long ports = synth->_controlInPorts;
+ if(ports > synti->_guiUpdateControls.size())
+ return;
+ for(unsigned long i = 0; i < ports; ++i)
+ {
+ if(synti->_guiUpdateControls[i])
+ {
+ unsigned long k = synth->pIdx[i];
+ _oscif.oscSendControl(k, controls[i].val);
+
+ // Reset.
+ synti->_guiUpdateControls[i] = false;
+ }
+ }
+ #endif
+}
+
+#ifdef OSC_SUPPORT
+//---------------------------------------------------------
+// oscUpdate
+//---------------------------------------------------------
+
+int DssiSynthIF::oscUpdate()
+{
+ // Send project directory.
+ _oscif.oscSendConfigure(DSSI_PROJECT_DIRECTORY_KEY, museProject.toLatin1().constData()); // song->projectPath()
+
+ // Send current string configuration parameters.
+ //StringParamMap& map = synti->_stringParamMap;
+ int i = 0;
+ for(ciStringParamMap r = synti->_stringParamMap.begin(); r != synti->_stringParamMap.end(); ++r)
+ {
+ _oscif.oscSendConfigure(r->first.c_str(), r->second.c_str());
+ // Avoid overloading the GUI if there are lots and lots of params.
+ if((i+1) % 50 == 0)
+ usleep(300000);
+ ++i;
+ }
+
+ // Send current bank and program.
+ //unsigned long bank, prog;
+ //synti->currentProg(&prog, &bank, 0);
+ //_oscif.oscSendProgram(prog, bank);
+ _oscif.oscSendProgram(synti->_curProgram, synti->_curBankL);
+
+ // Send current control values.
+ unsigned long ports = synth->_controlInPorts;
+ for(unsigned long i = 0; i < ports; ++i)
+ {
+ unsigned long k = synth->pIdx[i];
+ _oscif.oscSendControl(k, controls[i].val);
+ // Avoid overloading the GUI if there are lots and lots of ports.
+ if((i+1) % 50 == 0)
+ usleep(300000);
+ }
+
+
+#if 0
+ /* Send current bank/program (-FIX- another race...) */
+ if (instance->pendingProgramChange < 0) {
+ unsigned long bank = instance->currentBank;
+ unsigned long program = instance->currentProgram;
+ instance->uiNeedsProgramUpdate = 0;
+ if (instance->uiTarget) {
+ lo_send(instance->uiTarget, instance->ui_osc_program_path, "ii", bank, program);
+ }
+ }
+
+ /* Send control ports */
+ for (i = 0; i < instance->plugin->controlIns; i++) {
+ int in = i + instance->firstControlIn;
+ int port = pluginControlInPortNumbers[in];
+ lo_send(instance->uiTarget, instance->ui_osc_control_path, "if", port,
+ pluginControlIns[in]);
+ /* Avoid overloading the GUI if there are lots and lots of ports */
+ if ((i+1) % 50 == 0)
+ usleep(300000);
+ }
+#endif
+ return 0;
+}
+
+//---------------------------------------------------------
+// oscProgram
+//---------------------------------------------------------
+
+int DssiSynthIF::oscProgram(unsigned long program, unsigned long bank)
+ {
+ //int bank = argv[0]->i;
+ //int program = argv[1]->i;
+
+ int ch = 0; // TODO: ??
+
+ int port = synti->midiPort();
+
+ //_curBank = bank;
+ //_curProgram = program;
+ synti->_curBankH = 0;
+ synti->_curBankL = bank;
+ synti->_curProgram = program;
+
+ bank &= 0xff;
+ program &= 0xff;
+
+ //MidiEvent event(0, ch, ME_CONTROLLER, CTRL_PROGRAM, (bank << 8) + program);
+
+ if(port != -1)
+ {
+ //MidiPlayEvent event(0, port, ch, ME_CONTROLLER, CTRL_PROGRAM, (bank << 8) + program);
+ MidiPlayEvent event(0, port, ch, ME_PROGRAM, (bank << 8) + program, 0);
+
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::oscProgram midi event chn:%d a:%d b:%d\n", event.channel(), event.dataA(), event.dataB());
+ #endif
+
+ midiPorts[port].sendEvent(event);
+ }
+
+
+
+ //synti->playMidiEvent(&event); // TODO
+ //
+ //MidiDevice* md = dynamic_cast<MidiDevice*>(synti);
+ //if(md)
+ // md->putEvent(event);
+ //
+ //synti->putEvent(event);
+
+ return 0;
+ }
+
+//---------------------------------------------------------
+// oscControl
+//---------------------------------------------------------
+
+int DssiSynthIF::oscControl(unsigned long port, float value)
+ {
+ //int port = argv[0]->i;
+ //LADSPA_Data value = argv[1]->f;
+
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::oscControl received oscControl port:%ld val:%f\n", port, value);
+ #endif
+
+ //int controlPorts = synth->_controlInPorts;
+
+ //if(port >= controlPorts)
+ //if(port < 0 || port >= synth->rpIdx.size())
+ if(port >= synth->rpIdx.size())
+ {
+ //fprintf(stderr, "DssiSynthIF::oscControl: port number:%d is out of range of number of ports:%d\n", port, controlPorts);
+ fprintf(stderr, "DssiSynthIF::oscControl: port number:%ld is out of range of index list size:%zd\n", port, synth->rpIdx.size());
+ return 0;
+ }
+
+ // Convert from DSSI port number to control input port index.
+ unsigned long cport = synth->rpIdx[port];
+
+ if((int)cport == -1)
+ {
+ fprintf(stderr, "DssiSynthIF::oscControl: port number:%ld is not a control input\n", port);
+ return 0;
+ }
+
+ // p3.3.39 Set the DSSI control input port's value.
+ // Observations: With a native DSSI synth like LessTrivialSynth, the native GUI's controls do not change the sound at all
+ // ie. they don't update the DSSI control port values themselves.
+ // Hence in response to the call to this oscControl, sent by the native GUI, it is required to that here.
+/// controls[cport].val = value;
+ // DSSI-VST synths however, unlike DSSI synths, DO change their OWN sound in response to their gui controls.
+ // AND this function is called.
+ // Despite the descrepency we are STILL required to update the DSSI control port values here
+ // because dssi-vst is WAITING FOR A RESPONSE. (A CHANGE in the control port value).
+ // It will output something like "...4 events expected..." and count that number down as 4 actual control port value CHANGES
+ // are done here in response. Normally it says "...0 events expected..." when MusE is the one doing the DSSI control changes.
+ // TODO: (Done) May need FIFOs on each control(!) so that the control changes get sent one per process cycle.
+ // Observed countdown not actually going to zero upon string of changes.
+ //
+ // NOTE: NOTE: This line in RemoteVSTServer::setParameter(int p, float v) in dssi-vst-server.cpp :
+ //
+ // " if (tv.tv_sec > m_lastGuiComms.tv_sec + 10) "
+ //
+ // explains an observation that after ten seconds, the server automatically clears the expected number to 0.
+ // TODO: Now MusE should forget about all the VST fifo events past ten+ (?) seconds. Add event timestamps...
+ // You can't send any 'new' values until either you a): send all the expected events or b): wait ten seconds.
+ // (Because the server simply ignores the 'expected' messages.)
+ //
+ // Well, at least here are the fifos. Try this ...
+ OscControlFifo* cfifo = _oscif.oscFifo(cport);
+ if(cfifo)
+ {
+ OscControlValue cv;
+ //cv.idx = cport;
+ cv.value = value;
+ if(cfifo->put(cv))
+ {
+ fprintf(stderr, "DssiSynthIF::oscControl: fifo overflow: in control number:%ld\n", cport);
+ }
+ }
+
+ //const DSSI_Descriptor* dssi = synth->dssi;
+ //const LADSPA_Descriptor* ld = dssi->LADSPA_Plugin;
+
+ ciMidiCtl2LadspaPort ip = synth->port2MidiCtlMap.find(cport);
+ if(ip != synth->port2MidiCtlMap.end())
+ {
+ // TODO: TODO: Update midi MusE's midi controller knobs, sliders, boxes etc with a call to the midi port's setHwCtrlState() etc.
+ // But first we need a ladspa2MidiValue() function! ...
+ //
+ //
+ //float val = ladspa2MidiValue(ld, i, ?, ?);
+
+ }
+
+#if 0
+ int port = argv[0]->i;
+ LADSPA_Data value = argv[1]->f;
+
+ if (port < 0 || port > instance->plugin->descriptor->LADSPA_Plugin->PortCount) {
+ fprintf(stderr, "MusE: OSC: %s port number (%d) is out of range\n",
+ instance->friendly_name, port);
+ return 0;
+ }
+ if (instance->pluginPortControlInNumbers[port] == -1) {
+ fprintf(stderr, "MusE: OSC: %s port %d is not a control in\n",
+ instance->friendly_name, port);
+ return 0;
+ }
+ pluginControlIns[instance->pluginPortControlInNumbers[port]] = value;
+ if (verbose) {
+ printf("MusE: OSC: %s port %d = %f\n",
+ instance->friendly_name, port, value);
+ }
+#endif
+ return 0;
+ }
+
+/*
+//---------------------------------------------------------
+// oscExiting
+//---------------------------------------------------------
+
+int DssiSynthIF::oscExiting(lo_arg**)
+ {
+ //printf("not impl.: oscExiting\n");
+
+ // The gui is gone now, right?
+ _guiVisible = false;
+
+ //const DSSI_Descriptor* dssi = synth->dssi;
+ //const LADSPA_Descriptor* ld = dssi->LADSPA_Plugin;
+ //if(ld->deactivate)
+ // ld->deactivate(handle);
+
+ if (uiOscPath == 0) {
+ printf("DssiSynthIF::oscExiting(): no uiOscPath\n");
+ return 1;
+ }
+ char uiOscGuiPath[strlen(uiOscPath)+6];
+
+ sprintf(uiOscGuiPath, "%s/%s", uiOscPath, "quit");
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::oscExiting(): sending quit to uiOscGuiPath:%s\n", uiOscGuiPath);
+ #endif
+
+ lo_send(uiTarget, uiOscGuiPath, "");
+
+#if 0
+ int i;
+
+ if (verbose) {
+ printf("MusE: OSC: got exiting notification for instance %d\n",
+ instance->number);
+ }
+
+ if (instance->plugin) {
+
+ // !!! No, this isn't safe -- plugins deactivated in this way
+ // would still be included in a run_multiple_synths call unless
+ // we re-jigged the instance array at the same time -- leave it
+ // for now
+ //if (instance->plugin->descriptor->LADSPA_Plugin->deactivate) {
+ // instance->plugin->descriptor->LADSPA_Plugin->deactivate
+ // (instanceHandles[instance->number]);
+ // }
+ // Leave this flag though, as we need it to determine when to exit
+ instance->inactive = 1;
+ }
+
+ // Do we have any plugins left running?
+
+ for (i = 0; i < instance_count; ++i) {
+ if (!instances[i].inactive)
+ return 0;
+ }
+
+ if (verbose) {
+ printf("MusE: That was the last remaining plugin, exiting...\n");
+ }
+ exiting = 1;
+#endif
+ return 0;
+ }
+*/
+
+//---------------------------------------------------------
+// oscMidi
+//---------------------------------------------------------
+
+int DssiSynthIF::oscMidi(int a, int b, int c)
+ {
+ //int a = argv[0]->m[1];
+ //int b = argv[0]->m[2];
+ //int c = argv[0]->m[3];
+
+ if (a == ME_NOTEOFF) {
+ a = ME_NOTEON;
+ c = 0;
+ }
+ int channel = 0; // TODO: ??
+
+ int port = synti->midiPort();
+
+ //MidiEvent event(0, channel, a, b, c);
+
+ if(port != -1)
+ {
+ MidiPlayEvent event(0, port, channel, a, b, c);
+
+ #ifdef DSSI_DEBUG
+ fprintf(stderr, "DssiSynthIF::oscMidi midi event chn:%d a:%d b:%d\n", event.channel(), event.dataA(), event.dataB());
+ #endif
+
+ midiPorts[port].sendEvent(event);
+ }
+
+ //synti->playMidiEvent(&event); // TODO
+ //
+ //MidiDevice* md = dynamic_cast<MidiDevice*>(synti);
+ //if(md)
+ // md->putEvent(event);
+ //
+ //synti->putEvent(event);
+ //
+
+ return 0;
+ }
+
+//---------------------------------------------------------
+// oscConfigure
+//---------------------------------------------------------
+
+int DssiSynthIF::oscConfigure(const char *key, const char *value)
+ {
+ //const char *key = (const char *)&argv[0]->s;
+ //const char *value = (const char *)&argv[1]->s;
+
+ // This is pretty much the simplest legal implementation of
+ // configure in a DSSI host.
+
+ // The host has the option to remember the set of (key,value)
+ // pairs associated with a particular instance, so that if it
+ // wants to restore the "same" instance on another occasion it can
+ // just call configure() on it for each of those pairs and so
+ // restore state without any input from a GUI. Any real-world GUI
+ // host will probably want to do that. This host doesn't have any
+ // concept of restoring an instance from one run to the next, so
+ // we don't bother remembering these at all.
+
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::oscConfigure synth name:%s key:%s value:%s\n", synti->name().toLatin1().constData(), key, value);
+ #endif
+
+ // Add or modify the configuration map item.
+ synti->_stringParamMap.set(key, value);
+
+ if (!strncmp(key, DSSI_RESERVED_CONFIGURE_PREFIX,
+ strlen(DSSI_RESERVED_CONFIGURE_PREFIX))) {
+ fprintf(stderr, "MusE: OSC: UI for plugin '%s' attempted to use reserved configure key \"%s\", ignoring\n",
+ //synti->name().toAscii().data(), key);
+ synti->name().toLatin1().constData(), key);
+
+ return 0;
+ }
+
+ if (!synth->dssi->configure)
+ return 0;
+
+ char* message = synth->dssi->configure(handle, key, value);
+ if (message) {
+ printf("MusE: on configure '%s' '%s', plugin '%s' returned error '%s'\n",
+ //key, value, synti->name().toAscii().data(), message);
+ key, value, synti->name().toLatin1().constData(), message);
+
+ free(message);
+ }
+
+ // also call back on UIs for plugins other than the one
+ // that requested this:
+ // if (n != instance->number && instances[n].uiTarget) {
+ // lo_send(instances[n].uiTarget,
+ // instances[n].ui_osc_configure_path, "ss", key, value);
+ // }
+
+ // configure invalidates bank and program information, so
+ // we should do this again now:
+ queryPrograms();
+ return 0;
+ }
+#endif // OSC_SUPPORT
+
+//---------------------------------------------------------
+// queryPrograms
+//---------------------------------------------------------
+
+void DssiSynthIF::queryPrograms()
+ {
+ for (std::vector<DSSI_Program_Descriptor>::const_iterator i = programs.begin();
+ i != programs.end(); ++i) {
+ free((void*)(i->Name));
+ }
+ programs.clear();
+
+ //if (!(synth->dssi->get_program && synth->dssi->select_program))
+ if (!synth->dssi->get_program)
+ return;
+
+ for (int i = 0;; ++i) {
+ const DSSI_Program_Descriptor* pd = synth->dssi->get_program(handle, i);
+ if (pd == 0)
+ break;
+ DSSI_Program_Descriptor d;
+ d.Name = strdup(pd->Name);
+ d.Program = pd->Program;
+ d.Bank = pd->Bank;
+ programs.push_back(d);
+ }
+ }
+
+//---------------------------------------------------------
+// getPatchName
+//---------------------------------------------------------
+
+//QString DssiSynthIF::getPatchName(int, int prog)
+const char* DssiSynthIF::getPatchName(int /*chan*/, int prog, MType /*type*/, bool /*drum*/)
+ {
+ unsigned program = prog & 0x7f;
+ int lbank = (prog >> 8) & 0xff;
+ int hbank = (prog >> 16) & 0xff;
+
+ if (lbank == 0xff)
+ lbank = 0;
+ if (hbank == 0xff)
+ hbank = 0;
+ unsigned bank = (hbank << 8) + lbank;
+
+ for (std::vector<DSSI_Program_Descriptor>::const_iterator i = programs.begin();
+ i != programs.end(); ++i) {
+ if (i->Bank == bank && i->Program ==program)
+ return i->Name;
+ }
+ return "?";
+ }
+
+//---------------------------------------------------------
+// populatePatchPopup
+//---------------------------------------------------------
+
+//void DssiSynthIF::populatePatchPopup(QMenu* menu, int)
+void DssiSynthIF::populatePatchPopup(QMenu* menu, int /*ch*/, MType /*type*/, bool /*drum*/)
+ {
+ // The plugin can change the programs, patches etc.
+ // So make sure we're up to date by calling queryPrograms.
+ queryPrograms();
+
+ menu->clear();
+
+ for (std::vector<DSSI_Program_Descriptor>::const_iterator i = programs.begin();
+ i != programs.end(); ++i) {
+ int bank = i->Bank;
+ int prog = i->Program;
+ int id = (bank << 16) + prog;
+
+ QAction *act = menu->addAction(QString(i->Name));
+ act->setData(id);
+ }
+ }
+
+int DssiSynthIF::getControllerInfo(int id, const char** name, int* ctrl, int* min, int* max, int* initval)
+{
+ int controlPorts = synth->_controlInPorts;
+ if(id >= controlPorts)
+ //if(id >= midiCtl2PortMap.size())
+ return 0;
+
+ const DSSI_Descriptor* dssi = synth->dssi;
+ const LADSPA_Descriptor* ld = dssi->LADSPA_Plugin;
+
+ // Hmm, <map> has a weird [] operator. Would it work?
+ // For now just use duplicate code found in ::init()
+ //iMidiCtl2LadspaPort ip = midiCtl2PortMap[id];
+ //int ctlnum = ip->first;
+ //int k = ip->second;
+
+ int i = synth->pIdx[id];
+ //int i = synth->pIdx[k];
+
+ //ladspaDefaultValue(ld, i, &controls[id].val);
+
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::getControllerInfo control port:%d port idx:%d name:%s\n", id, i, ld->PortNames[i]);
+ #endif
+
+ int ctlnum = DSSI_NONE;
+ if(dssi->get_midi_controller_for_port)
+ ctlnum = dssi->get_midi_controller_for_port(handle, i);
+
+
+ // No controller number? Give it one.
+ if(ctlnum == DSSI_NONE)
+ {
+ // TODO: If neccesary... choose non-existing numbers...
+ //for(int k = 0; k < controlPorts; ++k)
+ //{
+ // int i = synth->pIdx[k];
+ //}
+
+ // Simple but flawed solution: Start them at 0x60000 + 0x2000 = 0x62000. Max NRPN number is 0x3fff.
+ ctlnum = CTRL_NRPN14_OFFSET + 0x2000 + id;
+ }
+ else
+ {
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::getControllerInfo ctlnum:%d\n", ctlnum);
+ #endif
+
+ int c = ctlnum;
+ // Can be both CC and NRPN! Prefer CC over NRPN.
+ if(DSSI_IS_CC(ctlnum))
+ {
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::getControllerInfo is CC control\n");
+ #endif
+
+ ctlnum = DSSI_CC_NUMBER(c);
+
+ #ifdef DSSI_DEBUG
+ if(DSSI_IS_NRPN(ctlnum))
+ printf("DssiSynthIF::getControllerInfo is also NRPN control. Using CC.\n");
+ #endif
+ }
+ else
+ if(DSSI_IS_NRPN(ctlnum))
+ {
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::getControllerInfo is NRPN control\n");
+ #endif
+
+ ctlnum = DSSI_NRPN_NUMBER(c) + CTRL_NRPN14_OFFSET;
+ }
+ }
+
+ int def = CTRL_VAL_UNKNOWN;
+ if(ladspa2MidiControlValues(ld, i, ctlnum, min, max, &def))
+ *initval = def;
+ else
+ *initval = CTRL_VAL_UNKNOWN;
+
+ #ifdef DSSI_DEBUG
+ printf("DssiSynthIF::getControllerInfo passed ctlnum:%d min:%d max:%d initval:%d\n", ctlnum, *min, *max, *initval);
+ #endif
+
+ *ctrl = ctlnum;
+ *name = ld->PortNames[i];
+ return ++id;
+
+ /*
+ // ...now create midi controllers for ports which did not define them ...
+ for(int k = 0; k < controlPorts; ++k)
+ {
+ int i = synth->pIdx[k];
+ //controls[k].val = ladspaDefaultValue(ld, i);
+ ladspaDefaultValue(ld, i, &controls[k].val);
+
+ printf("DssiSynthIF::getControllerInfo #2 control port:%d port idx:%d name:%s\n", k, i, ld->PortNames[i]);
+
+ if(!dssi->get_midi_controller_for_port || (dssi->get_midi_controller_for_port(handle, i) == DSSI_NONE))
+ {
+ int ctlnum;
+ //printf("DssiSynthIF::getControllerInfo #2 midi controller number:%d\n", ctlnum);
+ printf("DssiSynthIF::getControllerInfo #2 creating MidiController number:%d\n", ctlnum);
+ MidiController* mc = ladspa2MidiController(ld, i, ctlnum);
+ // Add to MidiInstrument controller list.
+ if(mc)
+ {
+ printf("DssiSynthIF::getControllerInfo #2 adding MidiController to instrument\n");
+ ((MidiInstrument*)synti)->controller()->add(mc);
+ }
+ }
+ else
+ {
+
+ }
+ }
+ */
+
+}
+
+int DssiSynthIF::channels() const
+{
+ return synth->_outports > MAX_CHANNELS ? MAX_CHANNELS : synth->_outports;
+}
+
+int DssiSynthIF::totalOutChannels() const
+{
+ return synth->_outports;
+}
+
+int DssiSynthIF::totalInChannels() const
+{
+ return synth->_inports;
+}
+
+//--------------------------------
+// Methods for PluginIBase:
+//--------------------------------
+
+bool DssiSynthIF::on() const { return true; } // Synth is not part of a rack plugin chain. Always on.
+void DssiSynthIF::setOn(bool /*val*/) { }
+int DssiSynthIF::pluginID() { return (synth && synth->dssi) ? synth->dssi->LADSPA_Plugin->UniqueID : 0; }
+int DssiSynthIF::id() { return 0; } // Synth is not part of a rack plugin chain. Always 0.
+QString DssiSynthIF::pluginLabel() const { return (synth && synth->dssi) ? QString(synth->dssi->LADSPA_Plugin->Label) : QString(); }
+QString DssiSynthIF::name() const { return synti->name(); }
+AudioTrack* DssiSynthIF::track() { return (AudioTrack*)synti; }
+void DssiSynthIF::enableController(int i, bool v) { controls[i].enCtrl = v; }
+bool DssiSynthIF::controllerEnabled(int i) const { return controls[i].enCtrl; }
+bool DssiSynthIF::controllerEnabled2(int i) const { return controls[i].en2Ctrl; }
+void DssiSynthIF::updateControllers() { }
+void DssiSynthIF::writeConfiguration(int /*level*/, Xml& /*xml*/) { }
+bool DssiSynthIF::readConfiguration(Xml& /*xml*/, bool /*readPreset*/) { return false; }
+int DssiSynthIF::parameters() const { return synth ? synth->_controlInPorts : 0; }
+void DssiSynthIF::setParam(int i, double val) { setParameter(i, val); }
+double DssiSynthIF::param(int i) const { return getParameter(i); }
+const char* DssiSynthIF::paramName(int i) { return (synth && synth->dssi) ? synth->dssi->LADSPA_Plugin->PortNames[i] : 0; }
+//LADSPA_PortRangeHint DssiSynthIF::range(int i) { return (synth && synth->dssi) ? synth->dssi->LADSPA_Plugin->PortRangeHints[i] : 0; }
+LADSPA_PortRangeHint DssiSynthIF::range(int i) { return synth->dssi->LADSPA_Plugin->PortRangeHints[i]; }
+
+
+#else //DSSI_SUPPORT
+void initDSSI() {}
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/dssihost.h b/attic/muse2-oom/muse2/muse/dssihost.h
new file mode 100644
index 00000000..c574a719
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/dssihost.h
@@ -0,0 +1,255 @@
+//=============================================================================
+// MusE
+// Linux Music Editor
+// $Id: dssihost.h,v 1.10.2.7 2009/12/06 10:05:00 terminator356 Exp $
+//
+// Copyright (C) 2002-2006 by Werner Schweer and others
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//=============================================================================
+
+#ifndef __DSSIHOST_H__
+#define __DSSIHOST_H__
+
+#include "config.h"
+
+#include <vector>
+#include <map>
+#include <string>
+
+#ifdef OSC_SUPPORT
+#include <lo/lo.h>
+#include "osc.h"
+#endif
+
+#include "ladspa.h"
+#include <dssi.h>
+#include <alsa/asoundlib.h>
+
+#include "midictrl.h"
+#include "synth.h"
+#include "stringparam.h"
+
+#include "plugin.h"
+
+#include <QMenu>
+
+#define DSSI_PARAMSAVE_VERSION_MAJOR 0
+#define DSSI_PARAMSAVE_VERSION_MINOR 1
+
+struct _DSSI;
+class DssiPluginIF;
+
+//class LadspaPort;
+class Port;
+
+//---------------------------------------------------------
+// DssiSynth
+//---------------------------------------------------------
+
+class DssiSynth : public Synth {
+ protected:
+ //char* label;
+ void* handle;
+ const DSSI_Descriptor* dssi;
+ DSSI_Descriptor_Function df;
+ unsigned long _portCount, _inports, _outports, _controlInPorts, _controlOutPorts;
+ std::vector<unsigned long> pIdx; // Control input index to port number.
+ std::vector<unsigned long> opIdx; // Control output index to port number. This is sometimes a latency port and...?
+ std::vector<unsigned long> iIdx; // Audio input index to port number.
+ std::vector<unsigned long> oIdx; // Audio output index to port number.
+ std::vector<bool> iUsedIdx; // During process, tells whether an audio input port was used by any input routes.
+ std::vector<unsigned long> rpIdx; // Port number to control input index. Item is -1 if it's not a control input.
+ //unsigned long* rpIdx;
+ MidiCtl2LadspaPortMap midiCtl2PortMap; // Maps midi controller numbers to DSSI port numbers.
+ MidiCtl2LadspaPortMap port2MidiCtlMap; // Maps DSSI port numbers to midi controller numbers.
+ bool _hasGui;
+ bool _inPlaceCapable;
+
+ public:
+ //DssiSynth(const QFileInfo* fi, QString l) : Synth(fi, l) {
+ //DssiSynth(const QFileInfo& fi, QString l) : Synth(fi, l) {
+ //DssiSynth(const QFileInfo& fi, QString label, QString descr, QString maker, QString ver) :
+ // Synth(fi, label, descr, maker, ver) {
+ // rpIdx = 0;
+ // df = 0;
+ // handle = 0;
+ // dssi = 0;
+ // _hasGui = false;
+ // }
+ //DssiSynth(const QFileInfo& fi, QString label, QString descr, QString maker, QString ver);
+ DssiSynth(QFileInfo&, const DSSI_Descriptor*); // removed const for QFileInfo
+ virtual ~DssiSynth();
+ virtual void incInstances(int);
+
+ //virtual void* instantiate();
+
+ virtual SynthIF* createSIF(SynthI*);
+ //virtual SynthIF* createSIF();
+
+ friend class DssiSynthIF;
+ //float defaultValue(int); // Not required
+ unsigned long inPorts() const { return _inports; }
+ unsigned long outPorts() const { return _outports; }
+ unsigned long inControls() const { return _controlInPorts; }
+ unsigned long outControls() const { return _controlOutPorts; }
+
+ unsigned long inControlPortIdx(unsigned long i) { return pIdx[i]; }
+ };
+
+//---------------------------------------------------------
+// DssiSynthIF
+// VSTi synthesizer instance
+//---------------------------------------------------------
+
+//class DssiSynthIF : public SynthIF
+class DssiSynthIF : public SynthIF, public PluginIBase
+ {
+ //bool _guiVisible;
+ DssiSynth* synth;
+ LADSPA_Handle handle;
+
+ //LadspaPort* controls;
+ Port* controls;
+ Port* controlsOut;
+
+ //unsigned long _curBank;
+ //unsigned long _curProgram;
+
+ #ifdef OSC_SUPPORT
+ OscDssiIF _oscif;
+ #endif
+
+ //void* uiTarget;
+ //char* uiOscShowPath;
+ //char* uiOscControlPath;
+ //char* uiOscConfigurePath;
+ //char* uiOscProgramPath;
+ //char* uiOscPath;
+
+ std::vector<DSSI_Program_Descriptor> programs;
+ void queryPrograms();
+ bool processEvent(const MidiPlayEvent&, snd_seq_event_t*);
+
+ float** audioInBuffers;
+ float** audioOutBuffers;
+
+ protected:
+ //int guiPid;
+ //QProcess* guiQProc;
+
+ public:
+ DssiSynthIF(SynthI* s);
+ //DssiSynthIF();
+
+ virtual ~DssiSynthIF();
+
+ virtual DssiSynth* dssiSynth() { return synth; }
+ virtual SynthI* dssiSynthI() { return synti; }
+
+ virtual bool initGui();
+ virtual void guiHeartBeat();
+ virtual bool guiVisible() const;
+ virtual void showGui(bool v);
+ virtual bool hasGui() const { return synth->_hasGui; }
+ virtual void getGeometry(int*, int*, int*, int*) const {}
+ virtual void setGeometry(int, int, int, int) {}
+
+ virtual void preProcessAlways();
+
+ //virtual void getData(MidiEventList*, unsigned pos, int ports, unsigned n, float** buffer) ;
+ virtual iMPEvent getData(MidiPort*, MPEventList*, iMPEvent, unsigned pos, int ports, unsigned n, float** buffer);
+
+ //virtual bool putEvent(const MidiEvent& ev);
+ virtual bool putEvent(const MidiPlayEvent& ev);
+
+ //virtual MidiEvent receiveEvent();
+ virtual MidiPlayEvent receiveEvent();
+
+ virtual int eventsPending() const { return 0; }
+
+ //virtual int channels() const { return synth->_outports; }
+ virtual int channels() const;
+ virtual int totalOutChannels() const;
+ virtual int totalInChannels() const;
+
+ virtual void deactivate3() {}
+
+ //virtual QString getPatchName(int, int);
+ virtual const char* getPatchName(int, int, int, bool) const { return ""; }
+ virtual const char* getPatchName(int, int, MType, bool);
+
+ //virtual void populatePatchPopup(QMenu*, int);
+ virtual void populatePatchPopup(QMenu*, int, MType, bool);
+
+ //virtual void write(Xml& xml) const;
+ virtual void write(int level, Xml& xml) const;
+
+ virtual float getParameter(unsigned long /*idx*/) const;
+ virtual void setParameter(unsigned long /*idx*/, float /*value*/);
+
+ //virtual int getControllerInfo(int, const char**, int*, int*, int*) { return 0; }
+ virtual int getControllerInfo(int, const char**, int*, int*, int*, int*);
+
+ bool init(DssiSynth* s);
+
+ //StringParamMap& stringParameters() { return synti->stringParameters(); }
+
+ #ifdef OSC_SUPPORT
+ OscDssiIF& oscIF() { return _oscif; }
+ /*
+ int oscProgram(lo_arg**);
+ int oscControl(lo_arg**);
+ int oscMidi(lo_arg**);
+ int oscConfigure(lo_arg**);
+ int oscUpdate(lo_arg**);
+ //int oscExiting(lo_arg**);
+ */
+
+ int oscProgram(unsigned long /*prog*/, unsigned long /*bank*/);
+ int oscControl(unsigned long /*dssiPort*/, float /*val*/);
+ int oscMidi(int /*a*/, int /*b*/, int /*c*/);
+ int oscConfigure(const char */*key*/, const char */*val*/);
+ int oscUpdate();
+ //int oscExiting();
+ #endif
+
+ //-------------------------
+ // Methods for PluginIBase:
+ //-------------------------
+ bool on() const;
+ void setOn(bool /*val*/);
+ int pluginID();
+ int id();
+ QString pluginLabel() const;
+ QString name() const;
+ AudioTrack* track();
+ void enableController(int /*i*/, bool v = true);
+ bool controllerEnabled(int /*i*/) const;
+ bool controllerEnabled2(int /*i*/) const;
+ void updateControllers();
+ void writeConfiguration(int /*level*/, Xml& /*xml*/);
+ bool readConfiguration(Xml& /*xml*/, bool readPreset=false);
+ int parameters() const;
+ void setParam(int /*i*/, double /*val*/);
+ double param(int /*i*/) const;
+ const char* paramName(int /*i*/);
+ LADSPA_PortRangeHint range(int /*i*/);
+
+ friend class DssiSynth;
+ };
+
+extern void initDSSI();
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/evdata.h b/attic/muse2-oom/muse2/muse/evdata.h
new file mode 100644
index 00000000..59155d48
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/evdata.h
@@ -0,0 +1,67 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: evdata.h,v 1.2.2.2 2008/08/18 00:15:23 terminator356 Exp $
+//
+// (C) Copyright 1999-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __EVDATA_H__
+#define __EVDATA_H__
+
+#include <string.h>
+// #include <memory.h>
+
+//---------------------------------------------------------
+// EvData
+// variable len event data (sysex, meta etc.)
+//---------------------------------------------------------
+
+class EvData {
+ int* refCount;
+
+ public:
+ unsigned char* data;
+ int dataLen;
+
+ EvData() {
+ data = 0;
+ dataLen = 0;
+ refCount = new int(1);
+ }
+ EvData(const EvData& ed) {
+ data = ed.data;
+ dataLen = ed.dataLen;
+ refCount = ed.refCount;
+ (*refCount)++;
+ }
+
+ EvData& operator=(const EvData& ed) {
+ if (data == ed.data)
+ return *this;
+ if (--(*refCount) == 0) {
+ delete refCount;
+ delete[] data;
+ }
+ data = ed.data;
+ dataLen = ed.dataLen;
+ refCount = ed.refCount;
+ (*refCount)++;
+ return *this;
+ }
+
+ ~EvData() {
+ if (--(*refCount) == 0) {
+ delete[] data;
+ delete refCount;
+ }
+ }
+ void setData(const unsigned char* p, int l) {
+ data = new unsigned char[l];
+ memcpy(data, p, l);
+ dataLen = l;
+ }
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/event.cpp b/attic/muse2-oom/muse2/muse/event.cpp
new file mode 100644
index 00000000..5d16fde9
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/event.cpp
@@ -0,0 +1,328 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: event.cpp,v 1.8.2.5 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 2000-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+// #include <memory.h>
+//#include "audioconvert.h"
+#include "event.h"
+#include "eventbase.h"
+#include "waveevent.h"
+#include "midievent.h"
+//#include "globals.h"
+
+// Added by Tim. p3.3.20
+//#define USE_SAMPLERATE
+
+//---------------------------------------------------------
+// Event
+//---------------------------------------------------------
+
+EventBase::EventBase(EventType t)
+ {
+ _type = t;
+ Pos::setType(_type == Wave ? FRAMES : TICKS);
+ refCount = 0;
+ _selected = false;
+ }
+
+EventBase::EventBase(const EventBase& ev)
+ : PosLen(ev)
+ {
+ refCount = 0;
+ _selected = ev._selected;
+ _type = ev._type;
+ }
+
+//---------------------------------------------------------
+// move
+//---------------------------------------------------------
+
+void EventBase::move(int tickOffset)
+ {
+ setTick(tick() + tickOffset);
+ }
+
+//---------------------------------------------------------
+// dump
+//---------------------------------------------------------
+
+void EventBase::dump(int n) const
+ {
+ for (int i = 0; i < n; ++i)
+ putchar(' ');
+ printf("Event %p refs:%d ", this, refCount);
+ PosLen::dump(n+2);
+ }
+
+//---------------------------------------------------------
+// clone
+//---------------------------------------------------------
+
+Event Event::clone()
+ {
+ // p3.3.31
+ //printf("Event::clone() this:%p\n", this);
+
+ // p3.3.31
+ //return Event(ev->clone());
+ #ifdef USE_SAMPLERATE
+ return Event(ev->clone(), _audConv);
+ #else
+ return Event(ev->clone());
+ #endif
+ }
+
+Event::Event()
+{
+ ev = 0;
+ //_sfCurFrame = 0;
+ //_audConv = 0;
+}
+
+Event::Event(EventType t) {
+ //_sfCurFrame = 0;
+ //_audConv = 0;
+
+ if (t == Wave)
+ ev = new WaveEventBase(t);
+ else
+ ev = new MidiEventBase(t);
+ ++(ev->refCount);
+ }
+Event::Event(const Event& e) {
+ //_sfCurFrame = 0;
+ //_audConv = 0;
+
+ ev = e.ev;
+ if(ev)
+ ++(ev->refCount);
+
+ #ifdef USE_SAMPLERATE
+ //_audConv = AudioConverter::getAudioConverter(e._audConv);
+ if(e._audConv)
+ _audConv = e._audConv->reference();
+ #endif
+ }
+Event::Event(EventBase* eb) {
+ //_sfCurFrame = 0;
+ //_audConv = 0;
+
+ ev = eb;
+ ++(ev->refCount);
+
+ #ifdef USE_SAMPLERATE
+ if(!ev->sndFile().isNull())
+ //_audConv = AudioConverter::getAudioConverter(eb, SRC_SINC_MEDIUM_QUALITY);
+ //_audConv = new AudioConverter(ev->sndFile().channels(), SRC_SINC_MEDIUM_QUALITY);
+ _audConv = new SRCAudioConverter(ev->sndFile().channels(), SRC_SINC_MEDIUM_QUALITY);
+ #endif
+ }
+#ifdef USE_SAMPLERATE
+Event::Event(EventBase* eb, AudioConverter* cv) {
+ _sfCurFrame = 0;
+ _audConv = 0;
+
+ ev = eb;
+ ++(ev->refCount);
+
+ if(cv)
+ _audConv = cv->reference();
+ }
+#endif
+
+Event::~Event() {
+ if (ev && --(ev->refCount) == 0) {
+ delete ev;
+ ev=0;
+ }
+
+ #ifdef USE_SAMPLERATE
+ AudioConverter::release(_audConv);
+ #endif
+ }
+
+bool Event::empty() const { return ev == 0; }
+EventType Event::type() const { return ev ? ev->type() : Note; }
+
+void Event::setType(EventType t) {
+ if (ev && --(ev->refCount) == 0) {
+ delete ev;
+ ev = 0;
+ }
+ if (t == Wave)
+ ev = new WaveEventBase(t);
+ else
+ ev = new MidiEventBase(t);
+ ++(ev->refCount);
+ }
+
+Event& Event::operator=(const Event& e) {
+ /*
+ if (ev == e.ev)
+ return *this;
+ if (ev && --(ev->refCount) == 0) {
+ delete ev;
+ ev = 0;
+ }
+ ev = e.ev;
+ if (ev)
+ ++(ev->refCount);
+ return *this;
+ */
+
+ if (ev != e.ev)
+ {
+ if (ev && --(ev->refCount) == 0) {
+ delete ev;
+ ev = 0;
+ }
+ ev = e.ev;
+ if (ev)
+ ++(ev->refCount);
+ }
+
+ #ifdef USE_SAMPLERATE
+ if (_audConv != e._audConv)
+ {
+ if(_audConv)
+ AudioConverter::release(_audConv);
+ //_audConv = AudioConverter::getAudioConverter(e._audConv);
+ _audConv = e._audConv->reference();
+ }
+ #endif
+ return *this;
+ }
+
+bool Event::operator==(const Event& e) const {
+ return ev == e.ev;
+ }
+
+int Event::getRefCount() const { return ev->getRefCount(); }
+bool Event::selected() const { return ev->_selected; }
+void Event::setSelected(bool val) { ev->_selected = val; }
+void Event::move(int offset) { ev->move(offset); }
+
+//void Event::read(Xml& xml) { ev->read(xml); }
+void Event::read(Xml& xml)
+{
+ ev->read(xml);
+
+ #ifdef USE_SAMPLERATE
+ if(!ev->sndFile().isNull())
+ {
+ if(_audConv)
+ {
+ _audConv->setChannels(ev->sndFile().channels());
+ }
+ else
+ {
+ //int srcerr;
+ //if(debugMsg)
+ // printf("Event::read Creating samplerate converter with %d channels\n", ev->sndFile().channels());
+ //_src_state = src_new(SRC_SINC_MEDIUM_QUALITY, ev->sndFile().channels(), &srcerr);
+// _audConv = new AudioConverter(ev->sndFile().channels(), SRC_SINC_MEDIUM_QUALITY);
+ _audConv = new SRCAudioConverter(ev->sndFile().channels(), SRC_SINC_MEDIUM_QUALITY);
+ //if(!_src_state)
+ //if(!_audConv)
+ // printf("Event::read Creation of samplerate converter with %d channels failed:%s\n", ev->sndFile().channels(), src_strerror(srcerr));
+ }
+ }
+ #endif
+}
+
+
+//void Event::write(int a, Xml& xml, const Pos& o) const { ev->write(a, xml, o); }
+void Event::write(int a, Xml& xml, const Pos& o, bool forceWavePaths) const { ev->write(a, xml, o, forceWavePaths); }
+void Event::dump(int n) const { ev->dump(n); }
+Event Event::mid(unsigned a, unsigned b) { return Event(ev->mid(a, b)); }
+
+bool Event::isNote() const { return ev->isNote(); }
+bool Event::isNoteOff() const { return ev->isNoteOff(); }
+bool Event::isNoteOff(const Event& e) const { return ev->isNoteOff(e); }
+int Event::dataA() const { return ev->dataA(); }
+int Event::pitch() const { return ev->dataA(); }
+void Event::setA(int val) { ev->setA(val); }
+void Event::setPitch(int val) { ev->setA(val); }
+int Event::dataB() const { return ev->dataB(); }
+int Event::velo() const { return ev->dataB(); }
+void Event::setB(int val) { ev->setB(val); }
+void Event::setVelo(int val) { ev->setB(val); }
+int Event::dataC() const { return ev->dataC(); }
+int Event::veloOff() const { return ev->dataC(); }
+void Event::setC(int val) { ev->setC(val); }
+void Event::setVeloOff(int val) { ev->setC(val); }
+
+const unsigned char* Event::data() const { return ev->data(); }
+int Event::dataLen() const { return ev->dataLen(); }
+void Event::setData(const unsigned char* data, int len) { ev->setData(data, len); }
+const EvData Event::eventData() const { return ev->eventData(); }
+
+const QString Event::name() const { return ev->name(); }
+void Event::setName(const QString& s) { ev->setName(s); }
+int Event::spos() const { return ev->spos(); }
+void Event::setSpos(int s) { ev->setSpos(s); }
+SndFileR Event::sndFile() const { return ev->sndFile(); }
+
+//void Event::setSndFile(SndFileR& sf) { ev->setSndFile(sf); }
+void Event::setSndFile(SndFileR& sf)
+{
+ ev->setSndFile(sf);
+
+ #ifdef USE_SAMPLERATE
+ //if(_audConv)
+// if(_audConv && !sf.isNull())
+// {
+ //_audConv->setSndFile(sf);
+ //if(sf.isNull())
+ // AudioConverter::release(_audConv);
+ //else
+// _audConv->setChannels(sf.channels());
+// }
+
+ if(_audConv)
+ {
+ // Do we release? Or keep the converter around, while gaining speed since no rapid creation/destruction.
+ //if(sf.isNull())
+ // _audConv = AudioConverter::release(_audConv);
+ //else
+ // _audConv->setChannels(sf.channels());
+ if(!sf.isNull())
+ _audConv->setChannels(sf.channels());
+ }
+ else
+ {
+ if(!sf.isNull())
+ _audConv = new SRCAudioConverter(ev->sndFile().channels(), SRC_SINC_MEDIUM_QUALITY);
+ }
+ #endif
+}
+
+//void Event::read(unsigned offset, float** bpp, int channels, int nn, bool overwrite)
+//void Event::readAudio(unsigned offset, float** bpp, int channels, int nn, bool doSeek, bool overwrite)
+// p3.3.33
+void Event::readAudio(WavePart* part, unsigned offset, float** bpp, int channels, int nn, bool doSeek, bool overwrite)
+ {
+ //ev->read(offset, bpp, channels, nn, overwrite);
+ //ev->readAudio(offset, bpp, channels, nn, doSeek, overwrite);
+ //_sfCurFrame = ev->readAudio(_src_state, _sfCurFrame, offset, bpp, channels, nn, doSeek, overwrite);
+ // p3.3.33
+ ev->readAudio(part, offset, bpp, channels, nn, doSeek, overwrite);
+ }
+void Event::setTick(unsigned val) { ev->setTick(val); }
+unsigned Event::tick() const { return ev->tick(); }
+unsigned Event::frame() const { return ev->frame(); }
+void Event::setFrame(unsigned val) { ev->setFrame(val); }
+void Event::setLenTick(unsigned val) { ev->setLenTick(val); }
+void Event::setLenFrame(unsigned val) { ev->setLenFrame(val); }
+unsigned Event::lenTick() const { return ev->lenTick(); }
+unsigned Event::lenFrame() const { return ev->lenFrame(); }
+Pos Event::end() const { return ev->end(); }
+unsigned Event::endTick() const { return ev->end().tick(); }
+unsigned Event::endFrame() const { return ev->end().frame(); }
+void Event::setPos(const Pos& p) { ev->setPos(p); }
+
diff --git a/attic/muse2-oom/muse2/muse/event.h b/attic/muse2-oom/muse2/muse/event.h
new file mode 100644
index 00000000..5a8a74f8
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/event.h
@@ -0,0 +1,151 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: event.h,v 1.7.2.4 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 1999-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __EVENT_H__
+#define __EVENT_H__
+
+#include <map>
+//#include <samplerate.h>
+#include <sys/types.h>
+
+#include "wave.h" // wg. SndFile
+#include "pos.h"
+#include "evdata.h"
+
+enum EventType { Note, Controller, Sysex, PAfter, CAfter, Meta, Wave };
+
+class QString;
+
+class Xml;
+class EventBase;
+//class AudioConverter;
+class WavePart;
+
+//---------------------------------------------------------
+// Event
+//---------------------------------------------------------
+
+class Event {
+ EventBase* ev;
+
+ //off_t _sfCurFrame;
+ //AudioConverter* _audConv;
+
+ public:
+ //Event() { ev = 0; }
+ Event();
+ Event(EventType t);
+ Event(const Event& e);
+ Event(EventBase* eb);
+
+ //#ifdef USE_SAMPLERATE
+ //Event(EventBase* eb, AudioConverter* cv);
+ //#endif
+
+ virtual ~Event();
+
+ bool empty() const;
+ EventType type() const;
+
+ void setType(EventType t);
+ Event& operator=(const Event& e);
+ bool operator==(const Event& e) const;
+
+ int getRefCount() const;
+ bool selected() const;
+ void setSelected(bool val);
+ void move(int offset);
+
+ void read(Xml& xml);
+ //void write(int a, Xml& xml, const Pos& offset) const;
+ void write(int a, Xml& xml, const Pos& offset, bool ForceWavePaths = false) const;
+ void dump(int n = 0) const;
+ Event clone();
+ Event mid(unsigned a, unsigned b);
+
+ bool isNote() const;
+ bool isNoteOff() const;
+ bool isNoteOff(const Event& e) const;
+ int dataA() const;
+ int pitch() const;
+ void setA(int val);
+ void setPitch(int val);
+ int dataB() const;
+ int velo() const;
+ void setB(int val);
+ void setVelo(int val);
+ int dataC() const;
+ int veloOff() const;
+ void setC(int val);
+ void setVeloOff(int val);
+
+ const unsigned char* data() const;
+ int dataLen() const;
+ void setData(const unsigned char* data, int len);
+ const EvData eventData() const;
+
+ const QString name() const;
+ void setName(const QString& s);
+ int spos() const;
+ void setSpos(int s);
+ //AudioConverter* audioConverter() { return _audConv;}
+ SndFileR sndFile() const;
+ virtual void setSndFile(SndFileR& sf);
+
+ //virtual void read(unsigned offset, float** bpp, int channels, int nn, bool overwrite = true);
+ //virtual void readAudio(unsigned /*offset*/, float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/);
+ virtual void readAudio(WavePart* /*part*/, unsigned /*offset*/, float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/);
+
+ void setTick(unsigned val);
+ unsigned tick() const;
+ unsigned frame() const;
+ void setFrame(unsigned val);
+ void setLenTick(unsigned val);
+ void setLenFrame(unsigned val);
+ unsigned lenTick() const;
+ unsigned lenFrame() const;
+ Pos end() const;
+ unsigned endTick() const;
+ unsigned endFrame() const;
+ void setPos(const Pos& p);
+ };
+
+typedef std::multimap <unsigned, Event, std::less<unsigned> > EL;
+typedef EL::iterator iEvent;
+typedef EL::reverse_iterator riEvent;
+typedef EL::const_iterator ciEvent;
+typedef std::pair <iEvent, iEvent> EventRange;
+
+//---------------------------------------------------------
+// EventList
+// tick sorted list of events
+//---------------------------------------------------------
+
+class EventList : public EL {
+ int ref; // number of references to this EventList
+ int aref; // number of active references (exclude undo list)
+ void deselect();
+
+ public:
+ EventList() { ref = 0; aref = 0; }
+ ~EventList() {}
+
+ void incRef(int n) { ref += n; }
+ int refCount() const { return ref; }
+ void incARef(int n) { aref += n; }
+ int arefCount() const { return aref; }
+
+ iEvent find(const Event&);
+ iEvent add(Event& event);
+ void move(Event& event, unsigned tick);
+ void dump() const;
+ void read(Xml& xml, const char* name, bool midi);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/eventbase.h b/attic/muse2-oom/muse2/muse/eventbase.h
new file mode 100644
index 00000000..6684bf57
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/eventbase.h
@@ -0,0 +1,97 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: eventbase.h,v 1.3.2.3 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 1999-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __EVENTBASE_H__
+#define __EVENTBASE_H__
+
+//#include <samplerate.h>
+#include <sys/types.h>
+
+#include "pos.h"
+#include "event.h"
+
+//class AudioConverter;
+class WavePart;
+
+//---------------------------------------------------------
+// EventBase
+//---------------------------------------------------------
+
+class EventBase : public PosLen {
+ EventType _type;
+
+ protected:
+ int refCount;
+ bool _selected;
+
+ public:
+ EventBase(EventType t);
+ EventBase(const EventBase& ev);
+
+ virtual ~EventBase() {}
+
+ int getRefCount() const { return refCount; }
+ EventType type() const { return _type; }
+ void setType(EventType t) { _type = t; }
+ bool selected() const { return _selected; }
+ void setSelected(bool val) { _selected = val; }
+
+ void move(int offset);
+
+ virtual void read(Xml&) = 0;
+ //virtual void write(int, Xml&, const Pos& offset) const = 0;
+ virtual void write(int, Xml&, const Pos& offset, bool forcePath = false) const = 0;
+ virtual void dump(int n = 0) const;
+ virtual EventBase* mid(unsigned, unsigned) = 0;
+ friend class Event;
+
+ virtual bool isNote() const { return false; }
+ virtual bool isNoteOff() const { return false; }
+ virtual bool isNoteOff(const Event&) const { return false; }
+ virtual int pitch() const { return 0; }
+ virtual int program() const { return 0; }
+ virtual int cntrl() const { return 0; }
+ virtual int dataA() const { return 0; }
+ virtual void setA(int) { }
+ virtual void setPitch(int) { }
+
+ virtual int cntrlVal() const { return 0; }
+ virtual int dataB() const { return 0; }
+ virtual int velo() const { return 0; }
+ virtual void setB(int) { }
+ virtual void setVelo(int) { }
+
+ virtual int veloOff() const { return 0; }
+ virtual int dataC() const { return 0; }
+ virtual void setC(int) { }
+ virtual void setVeloOff(int) { }
+
+ virtual const unsigned char* data() const { return 0; }
+ virtual int dataLen() const { return 0; }
+ virtual void setData(const unsigned char*, int) { }
+ virtual const EvData eventData() const { return EvData(); }
+
+ virtual const QString name() const { return QString("?"); }
+ virtual void setName(const QString&) { }
+ virtual int spos() const { return 0; }
+ virtual void setSpos(int) { }
+ virtual SndFileR sndFile() const { return 0; }
+ virtual void setSndFile(SndFileR&) { }
+ virtual EventBase* clone() = 0;
+
+ //virtual void read(unsigned /*offset*/, float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool overwrite = true) {}
+ //virtual void readAudio(unsigned /*offset*/, float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/) {}
+ //virtual off_t readAudio(SRC_STATE* /*src_state*/, off_t /*sfCurFrame*/, unsigned /*offset*/,
+ // float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/) { return 0; }
+ //virtual off_t readAudio(AudioConverter* /*audConv*/, off_t /*sfCurFrame*/, unsigned /*offset*/,
+ // float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/) { return 0; }
+ virtual void readAudio(WavePart* /*part*/, unsigned /*offset*/,
+ float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/) { }
+ };
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/eventlist.cpp b/attic/muse2-oom/muse2/muse/eventlist.cpp
new file mode 100644
index 00000000..23fffc8c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/eventlist.cpp
@@ -0,0 +1,112 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: eventlist.cpp,v 1.7.2.3 2009/11/05 03:14:35 terminator356 Exp $
+//
+// (C) Copyright 2000-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "tempo.h"
+#include "event.h"
+#include "xml.h"
+
+//---------------------------------------------------------
+// readEventList
+//---------------------------------------------------------
+
+void EventList::read(Xml& xml, const char* name, bool midi)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "event") {
+ Event e(midi ? Note : Wave);
+ e.read(xml);
+ add(e);
+ }
+ else
+ xml.unknown("readEventList");
+ break;
+ case Xml::TagEnd:
+ if (tag == name)
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// add
+//---------------------------------------------------------
+
+iEvent EventList::add(Event& event)
+ {
+ // Added by T356. An event list containing wave events should be sorted by
+ // frames. WaveTrack::fetchData() relies on the sorting order, and
+ // there was a bug that waveparts were sometimes muted because of
+ // incorrect sorting order (by ticks).
+ // Also, when the tempo map is changed, every wave event would have to be
+ // re-added to the event list so that the proper sorting order (by ticks)
+ // could be achieved.
+ // Note that in a med file, the tempo list is loaded AFTER all the tracks.
+ // There was a bug that all the wave events' tick values were not correct,
+ // since they were computed BEFORE the tempo map was loaded.
+ if(event.type() == Wave)
+ return std::multimap<unsigned, Event, std::less<unsigned> >::insert(std::pair<const unsigned, Event> (event.frame(), event));
+ else
+
+ return std::multimap<unsigned, Event, std::less<unsigned> >::insert(std::pair<const unsigned, Event> (event.tick(), event));
+ }
+
+//---------------------------------------------------------
+// move
+//---------------------------------------------------------
+
+void EventList::move(Event& event, unsigned tick)
+ {
+ iEvent i = find(event);
+ erase(i);
+
+ // Added by T356.
+ if(event.type() == Wave)
+ std::multimap<unsigned, Event, std::less<unsigned> >::insert(std::pair<const unsigned, Event> (tempomap.tick2frame(tick), event));
+ else
+
+ std::multimap<unsigned, Event, std::less<unsigned> >::insert(std::pair<const unsigned, Event> (tick, event));
+ }
+
+//---------------------------------------------------------
+// find
+//---------------------------------------------------------
+
+iEvent EventList::find(const Event& event)
+ {
+ // Changed by T356.
+ // Changed by Tim. p3.3.8
+ //EventRange range = equal_range(event.tick());
+ EventRange range = equal_range(event.type() == Wave ? event.frame() : event.tick());
+
+
+ for (iEvent i = range.first; i != range.second; ++i) {
+ if (i->second == event)
+ return i;
+ }
+ return end();
+ }
+
+//---------------------------------------------------------
+// dump
+//---------------------------------------------------------
+
+void EventList::dump() const
+ {
+ for (ciEvent i = begin(); i != end(); ++i)
+ i->second.dump();
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/exportmidi.cpp b/attic/muse2-oom/muse2/muse/exportmidi.cpp
new file mode 100644
index 00000000..8065c275
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/exportmidi.cpp
@@ -0,0 +1,388 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: exportmidi.cpp,v 1.9.2.1 2009/04/01 01:37:10 terminator356 Exp $
+//
+// (C) Copyright 1999-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <QString>
+
+#include "al/sig.h" // Tim.
+
+#include "app.h"
+#include "midifile.h"
+#include "midi.h"
+#include "midictrl.h"
+#include "globals.h"
+#include "filedialog.h"
+#include "track.h"
+#include "song.h"
+#include "mpevent.h"
+#include "event.h"
+#include "marker/marker.h"
+#include "drummap.h"
+#include "gconfig.h"
+
+//---------------------------------------------------------
+// addController
+//---------------------------------------------------------
+
+static void addController(MPEventList* l, int tick, int port, int channel, int a, int b)
+ {
+ // p3.3.37
+ //if (a < 0x1000) { // 7 Bit Controller
+ if (a < CTRL_14_OFFSET) { // 7 Bit Controller
+ l->add(MidiPlayEvent(tick, port, channel, ME_CONTROLLER, a, b));
+ }
+ //else if (a < 0x20000) { // 14 Bit Controller
+ else if (a < CTRL_RPN_OFFSET) { // 14 Bit Controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ int dataH = (b >> 7) & 0x7f;
+ int dataL = b & 0x7f;
+ l->add(MidiPlayEvent(tick, port, channel, ME_CONTROLLER, ctrlH, dataH));
+ l->add(MidiPlayEvent(tick+1, port, channel, ME_CONTROLLER, ctrlL, dataL));
+ }
+ //else if (a < 0x30000) { // RPN 7-Bit Controller
+ else if (a < CTRL_NRPN_OFFSET) { // RPN 7-Bit Controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ l->add(MidiPlayEvent(tick, port, channel, ME_CONTROLLER, CTRL_HRPN, ctrlH));
+ l->add(MidiPlayEvent(tick+1, port, channel, ME_CONTROLLER, CTRL_LRPN, ctrlL));
+ l->add(MidiPlayEvent(tick+2, port, channel, ME_CONTROLLER, CTRL_HDATA, b));
+ }
+ //else if (a < 0x40000) { // NRPN 7-Bit Controller
+ else if (a < CTRL_INTERNAL_OFFSET) { // NRPN 7-Bit Controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ l->add(MidiPlayEvent(tick, port, channel, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
+ l->add(MidiPlayEvent(tick+1, port, channel, ME_CONTROLLER, CTRL_LNRPN, ctrlL));
+ l->add(MidiPlayEvent(tick+2, port, channel, ME_CONTROLLER, CTRL_HDATA, b));
+ }
+ else if (a == CTRL_PITCH) {
+ int a = b + 8192;
+ int b = a >> 7;
+ l->add(MidiPlayEvent(tick, port, channel, ME_PITCHBEND, a & 0x7f, b & 0x7f));
+ }
+ else if (a == CTRL_PROGRAM) {
+ int hb = (b >> 16) & 0xff;
+ int lb = (b >> 8) & 0xff;
+ int pr = b & 0x7f;
+ int tickoffset = 0;
+ switch(song->mtype()) {
+ case MT_GM: // no HBANK/LBANK
+ break;
+ case MT_GS:
+ case MT_XG:
+ case MT_UNKNOWN:
+ if (hb != 0xff) {
+ l->add(MidiPlayEvent(tick, port, channel, ME_CONTROLLER, CTRL_HBANK, hb));
+ ++tickoffset;
+ }
+ if (lb != 0xff) {
+ l->add(MidiPlayEvent(tick+tickoffset, port, channel, ME_CONTROLLER, CTRL_LBANK, lb));
+ ++tickoffset;
+ }
+ break;
+ }
+ l->add(MidiPlayEvent(tick+tickoffset, port, channel, ME_PROGRAM, pr, 0));
+ }
+ //else if (a < 0x60000) { // RPN14 Controller
+ else if (a < CTRL_NRPN14_OFFSET) { // RPN14 Controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ int dataH = (b >> 7) & 0x7f;
+ int dataL = b & 0x7f;
+ l->add(MidiPlayEvent(tick, port, channel, ME_CONTROLLER, CTRL_HRPN, ctrlH));
+ l->add(MidiPlayEvent(tick+1, port, channel, ME_CONTROLLER, CTRL_LRPN, ctrlL));
+ l->add(MidiPlayEvent(tick+2, port, channel, ME_CONTROLLER, CTRL_HDATA, dataH));
+ l->add(MidiPlayEvent(tick+3, port, channel, ME_CONTROLLER, CTRL_LDATA, dataL));
+ }
+ //else if (a < 0x70000) { // NRPN14 Controller
+ else if (a < CTRL_NONE_OFFSET) { // NRPN14 Controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ int dataH = (b >> 7) & 0x7f;
+ int dataL = b & 0x7f;
+ l->add(MidiPlayEvent(tick, port, channel, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
+ l->add(MidiPlayEvent(tick+1, port, channel, ME_CONTROLLER, CTRL_LNRPN, ctrlL));
+ l->add(MidiPlayEvent(tick+2, port, channel, ME_CONTROLLER, CTRL_HDATA, dataH));
+ l->add(MidiPlayEvent(tick+3, port, channel, ME_CONTROLLER, CTRL_LDATA, dataL));
+ }
+ }
+
+//---------------------------------------------------------
+// exportMidi
+//---------------------------------------------------------
+
+void MusE::exportMidi()
+ {
+ MFile file(QString("midis"), QString(".mid"));
+
+ //FILE* fp = file.open("w", midi_file_pattern, this, false, true,
+ FILE* fp = file.open("w", midi_file_save_pattern, this, false, true,
+ tr("MusE: Export Midi"));
+ if (fp == 0)
+ return;
+ MidiFile mf(fp);
+
+ MidiTrackList* tl = song->midis();
+ int ntracks = tl->size();
+ MidiFileTrackList* mtl = new MidiFileTrackList;
+
+ int i = 0;
+ for (iMidiTrack im = tl->begin(); im != tl->end(); ++im, ++i) {
+ MidiTrack* track = *im;
+ MidiFileTrack* mft = new MidiFileTrack;
+ mtl->push_back(mft);
+ MPEventList* l = &(mft->events);
+ int port = track->outPort();
+ int channel = track->outChannel();
+
+ //---------------------------------------------------
+ // only first midi track contains
+ // - Track Marker
+ // - copyright
+ // - time signature
+ // - tempo map
+ // - GM/GS/XG Initialization
+ //---------------------------------------------------
+
+ if (i == 0) {
+ //---------------------------------------------------
+ // Write Track Marker
+ //
+ MarkerList* ml = song->marker();
+ for (ciMarker m = ml->begin(); m != ml->end(); ++m) {
+ QByteArray ba = m->second.name().toLatin1();
+ const char* name = ba.constData();
+ int len = strlen(name);
+ MidiPlayEvent ev(m->first, port, ME_META, (unsigned char*)name, len);
+ ev.setA(0x6);
+ l->add(ev);
+ }
+
+ //---------------------------------------------------
+ // Write Copyright
+ //
+ QByteArray ba = config.copyright.toLatin1();
+ const char* copyright = ba.constData();
+ if (copyright && *copyright) {
+ int len = strlen(copyright);
+ MidiPlayEvent ev(0, port, ME_META, (unsigned char*)copyright, len);
+ ev.setA(0x2);
+ l->add(ev);
+ }
+
+ //---------------------------------------------------
+ // Write Coment
+ //
+ QString comment = track->comment();
+ if (!comment.isEmpty()) {
+ int len = comment.length();
+ MidiPlayEvent ev(0, port, ME_META, (const unsigned char*)(comment.toLatin1().constData()), len);
+ ev.setA(0x1);
+ l->add(ev);
+ }
+
+ //---------------------------------------------------
+ // Write Songtype SYSEX: GM/GS/XG
+ //
+
+ switch(song->mtype()) {
+ case MT_GM:
+ l->add(MidiPlayEvent(0, port, ME_SYSEX, gmOnMsg, gmOnMsgLen));
+ break;
+ case MT_GS:
+ l->add(MidiPlayEvent(0, port, ME_SYSEX, gmOnMsg, gmOnMsgLen));
+ l->add(MidiPlayEvent(250, port, ME_SYSEX, gsOnMsg, gsOnMsgLen));
+ break;
+ case MT_XG:
+ l->add(MidiPlayEvent(0, port, ME_SYSEX, gmOnMsg, gmOnMsgLen));
+ l->add(MidiPlayEvent(250, port, ME_SYSEX, xgOnMsg, xgOnMsgLen));
+ break;
+ case MT_UNKNOWN:
+ break;
+ }
+
+ //---------------------------------------------------
+ // Write Tempomap
+ //
+ TempoList* tl = &tempomap;
+ for (ciTEvent e = tl->begin(); e != tl->end(); ++e) {
+ TEvent* event = e->second;
+ unsigned char data[3];
+ int tempo = event->tempo;
+ data[2] = tempo & 0xff;
+ data[1] = (tempo >> 8) & 0xff;
+ data[0] = (tempo >> 16) & 0xff;
+ MidiPlayEvent ev(event->tick, port, ME_META, data, 3);
+ ev.setA(0x51);
+ l->add(ev);
+ }
+
+ //---------------------------------------------------
+ // Write Signatures
+ //
+ ///const SigList* sl = &sigmap;
+ const AL::SigList* sl = &AL::sigmap;
+ ///for (ciSigEvent e = sl->begin(); e != sl->end(); ++e) {
+ for (AL::ciSigEvent e = sl->begin(); e != sl->end(); ++e) {
+ ///SigEvent* event = e->second;
+ AL::SigEvent* event = e->second;
+ int sz = (config.exp2ByteTimeSigs ? 2 : 4); // export 2 byte timesigs instead of 4 ?
+ unsigned char data[sz];
+ data[0] = event->sig.z;
+ switch(event->sig.n) {
+ case 1: data[1] = 0; break;
+ case 2: data[1] = 1; break;
+ case 4: data[1] = 2; break;
+ case 8: data[1] = 3; break;
+ case 16: data[1] = 4; break;
+ case 32: data[1] = 5; break;
+ case 64: data[1] = 6; break;
+ default:
+ fprintf(stderr, "falsche Signatur; nenner %d\n", event->sig.n);
+ break;
+ }
+ // By T356. In muse the metronome pulse is fixed at 24 (once per quarter-note).
+ // The number of 32nd notes per 24 MIDI clock signals (per quarter-note) is 8.
+ if(!config.exp2ByteTimeSigs)
+ {
+ data[2] = 24;
+ data[3] = 8;
+ }
+
+ MidiPlayEvent ev(event->tick, port, ME_META, data, sz);
+
+ ev.setA(0x58);
+ l->add(ev);
+ }
+ }
+
+ //-----------------------------------
+ // track name
+ //-----------------------------------
+
+ if (!track->name().isEmpty()) {
+ QByteArray ba = track->name().toLatin1();
+ const char* name = ba.constData();
+ int len = strlen(name);
+ MidiPlayEvent ev(0, port, ME_META, (unsigned char*)name, len+1);
+ ev.setA(0x3); // Meta Sequence/Track Name
+ l->add(ev);
+ }
+
+ //-----------------------------------
+ // track comment
+ //-----------------------------------
+
+ if (!track->comment().isEmpty()) {
+ QByteArray ba = track->comment().toLatin1();
+ const char* comment = ba.constData();
+ int len = strlen(comment);
+ MidiPlayEvent ev(0, port, ME_META, (unsigned char*)comment, len+1);
+ ev.setA(0xf); // Meta Text
+ l->add(ev);
+ }
+ PartList* parts = track->parts();
+ for (iPart p = parts->begin(); p != parts->end(); ++p) {
+ MidiPart* part = (MidiPart*) (p->second);
+ EventList* evlist = part->events();
+ for (iEvent i = evlist->begin(); i != evlist->end(); ++i) {
+ Event ev = i->second;
+ int tick = ev.tick() + part->tick();
+
+ switch (ev.type()) {
+ case Note:
+ {
+ if (ev.velo() == 0) {
+ printf("Warning: midi note has velocity 0, (ignored)\n");
+ continue;
+ }
+ int pitch;
+ if (track->type() == Track::DRUM) {
+ //
+ // Map drum-notes to the drum-map values
+ //
+ int instr = ev.pitch();
+ pitch = drumMap[instr].anote;
+ // port = drumMap[instr].port;
+ // channel = drumMap[instr].channel;
+ }
+ else
+ pitch = ev.pitch();
+
+ int velo = ev.velo();
+ int len = ev.lenTick();
+
+ //---------------------------------------
+ // apply trackinfo values
+ //---------------------------------------
+
+ if (track->transposition
+ || track->velocity
+ || track->compression != 100
+ || track->len != 100) {
+ pitch += track->transposition;
+ if (pitch > 127)
+ pitch = 127;
+ if (pitch < 0)
+ pitch = 0;
+
+ velo += track->velocity;
+ velo = (velo * track->compression) / 100;
+ if (velo > 127)
+ velo = 127;
+ if (velo < 1) // no off event
+ velo = 1;
+ len = (len * track->len) / 100;
+ }
+ if (len <= 0)
+ len = 1;
+ l->add(MidiPlayEvent(tick, port, channel, ME_NOTEON, pitch, velo));
+
+ if(config.expOptimNoteOffs) // Save space by replacing note offs with note on velocity 0
+ l->add(MidiPlayEvent(tick+len, port, channel, ME_NOTEON, pitch, 0));
+ else
+ l->add(MidiPlayEvent(tick+len, port, channel, ME_NOTEOFF, pitch, velo));
+ }
+ break;
+
+ case Controller:
+ addController(l, tick, port, channel, ev.dataA(), ev.dataB());
+ break;
+
+ case Sysex:
+ l->add(MidiPlayEvent(tick, port, ME_SYSEX, ev.eventData()));
+ break;
+
+ case PAfter:
+ l->add(MidiPlayEvent(tick, port, channel, ME_AFTERTOUCH, ev.dataA(), ev.dataB()));
+ break;
+
+ case CAfter:
+ l->add(MidiPlayEvent(tick, port, channel, ME_POLYAFTER, ev.dataA(), ev.dataB()));
+ break;
+
+ case Meta:
+ {
+ MidiPlayEvent mpev(tick, port, ME_META, ev.eventData());
+ mpev.setA(ev.dataA());
+ l->add(mpev);
+ }
+ break;
+ case Wave:
+ break;
+ }
+ }
+ }
+ }
+ mf.setDivision(config.midiDivision);
+ mf.setMType(song->mtype());
+ mf.setTrackList(mtl, ntracks);
+ mf.write();
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/fastlog.h b/attic/muse2-oom/muse2/muse/fastlog.h
new file mode 100644
index 00000000..23710a8b
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/fastlog.h
@@ -0,0 +1,38 @@
+/* Copyright unknown. Code by Laurent de Soras <laurent@ohmforce.com>.
+ */
+
+#ifndef __pbd_fastlog_h__
+#define __pbd_fastlog_h__
+
+#include <math.h> /* for HUGE_VAL */
+
+static inline float fast_log2 (float val)
+ {
+ /* don't use reinterpret_cast<> because that prevents this
+ from being used by pure C code (for example, GnomeCanvasItems)
+ */
+ union {float f; int i;} t;
+ t.f = val;
+ int* const exp_ptr = &t.i;
+ int x = *exp_ptr;
+ const int log_2 = ((x >> 23) & 255) - 128;
+ x &= ~(255 << 23);
+ x += 127 << 23;
+ *exp_ptr = x;
+ val = ((-1.0f/3) * t.f + 2) * t.f - 2.0f/3;
+ return (val + log_2);
+ }
+
+static inline float fast_log (const float val)
+ {
+ return (fast_log2 (val) * 0.69314718f);
+ }
+
+static inline float fast_log10 (const float val)
+ {
+ return fast_log2(val) / 3.312500f;
+ }
+
+static inline float minus_infinity() { return -HUGE_VAL; }
+
+#endif /* __pbd_fastlog_h__ */
diff --git a/attic/muse2-oom/muse2/muse/gconfig.cpp b/attic/muse2-oom/muse2/muse/gconfig.cpp
new file mode 100644
index 00000000..944035a7
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/gconfig.cpp
@@ -0,0 +1,171 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: gconfig.cpp,v 1.15.2.13 2009/12/01 03:52:40 terminator356 Exp $
+//
+// (C) Copyright 1999-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "gconfig.h"
+
+GlobalConfigValues config = {
+ 190, // globalAlphaBlend
+ {
+ QColor(0xff, 0xff, 0xff), // palette
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff)
+ },
+ {
+ QColor(255, 232, 140), // part colors
+ QColor(0xff, 0x00, 0x00),
+ QColor(0x00, 0xff, 0x00),
+ QColor(0x00, 0x00, 0xff),
+ QColor(0xff, 0xff, 0x00),
+ QColor(0x00, 0xff, 0xff),
+ QColor(0xff, 0x00, 0xff),
+ QColor(0x9f, 0xc7, 0xef),
+ QColor(0x00, 0xff, 0x7f),
+ QColor(0x7f, 0x00, 0x00),
+ QColor(0x00, 0x7f, 0x00),
+ QColor(0x00, 0x00, 0x7f),
+ QColor(0x7f, 0x7f, 0x3f),
+ QColor(0x00, 0x7f, 0x7f),
+ QColor(0x7f, 0x00, 0x7f),
+ QColor(0x00, 0x7f, 0xff),
+ QColor(0x00, 0x3f, 0x3f)
+ },
+ {
+ QString("Default"), // Default part color names
+ QString("Refrain"),
+ QString("Bridge"),
+ QString("Intro"),
+ QString("Coda"),
+ QString("Chorus"),
+ QString("Solo"),
+ QString("Brass"),
+ QString("Percussion"),
+ QString("Drums"),
+ QString("Guitar"),
+ QString("Bass"),
+ QString("Flute"),
+ QString("Strings"),
+ QString("Keyboard"),
+ QString("Piano"),
+ QString("Saxophone")
+ },
+ QColor(0, 0, 255), // transportHandleColor;
+ QColor(255, 0, 0), // bigTimeForegroundColor;
+ QColor(0, 0, 0), // bigTimeBackgroundColor;
+ QColor(200, 200, 200), // waveEditBackgroundColor;
+ {
+ QFont(QString("arial"), 10, QFont::Normal),
+ QFont(QString("arial"), 8, QFont::Normal),
+ QFont(QString("arial"), 10, QFont::Normal),
+ QFont(QString("arial"), 10, QFont::Bold),
+ QFont(QString("arial"), 8, QFont::Bold), // timescale numbers
+ QFont(QString("Lucidatypewriter"), 14, QFont::Bold),
+ QFont(QString("arial"), 8, QFont::Bold, true) // Mixer strip labels. Looks and fits better with bold + italic than bold alone,
+ // at the price of only few more pixels than Normal mode.
+ },
+ QColor(84, 97, 114), // trackBg;
+ QColor(0x80, 0xff, 0x80), // selected track Bg;
+ QColor(0x00, 0x00, 0x00), // selected track Fg;
+
+ QColor(0, 160, 255), // midiTrackLabelBg; // Med blue
+ QColor(0, 160, 255), // drumTrackLabelBg; // Med blue
+ Qt::magenta, // waveTrackLabelBg;
+ Qt::green, // outputTrackLabelBg;
+ Qt::red, // inputTrackLabelBg;
+ Qt::yellow, // groupTrackLabelBg;
+ QColor(120, 255, 255), // auxTrackLabelBg; // Light blue
+ QColor(255, 130, 0), // synthTrackLabelBg; // Med orange
+
+ QColor(220, 220, 220), // midiTrackBg;
+ QColor(220, 220, 220), // drumTrackBg;
+ QColor(220, 220, 220), // waveTrackBg;
+ QColor(189, 220, 193), // outputTrackBg;
+ QColor(189, 220, 193), // inputTrackBg;
+ QColor(220, 220, 220), // groupTrackBg;
+ QColor(220, 220, 220), // auxTrackBg;
+ QColor(220, 220, 220), // synthTrackBg;
+
+ QColor(98, 124, 168), // part canvas bg
+ QColor(255, 170, 0), // ctrlGraphFg; Medium orange
+ QColor(0, 0, 0), // mixerBg;
+
+ 384, // division;
+ 1024, // rtcTicks
+ -60, // int minMeter;
+ -60.0, // double minSlider;
+ false, // use Jack freewheel
+ 20, // int guiRefresh;
+ QString(""), // userInstrumentsDir
+ //QString(""), // helpBrowser; // Obsolete
+ true, // extendedMidi
+ 384, // division for smf export
+ QString(""), // copyright string for smf export
+ 1, // smf export file format
+ false, // midi export file 2 byte timesigs instead of 4
+ true, // optimize midi export file note offs
+ true, // Split imported tracks into multiple parts.
+ 1, // startMode
+ QString(""), // start song path
+ 384, // gui division
+ QRect(0, 0, 400, 300), // GeometryMain;
+ QRect(0, 0, 200, 100), // GeometryTransport;
+ QRect(0, 0, 600, 200), // GeometryBigTime;
+ QRect(0, 0, 400, 300), // GeometryPianoroll;
+ QRect(0, 0, 400, 300), // GeometryDrumedit;
+ //QRect(0, 0, 300, 500), // GeometryMixer; // Obsolete
+ {
+ QString("Mixer A"),
+ QRect(0, 0, 300, 500), // Mixer1
+ true, true, true, true,
+ true, true, true, true
+ },
+ {
+ QString("Mixer B"),
+ QRect(200, 200, 300, 500), // Mixer2
+ true, true, true, true,
+ true, true, true, true
+ },
+ true, // TransportVisible;
+ false, // BigTimeVisible;
+ false, // mixer1Visible;
+ false, // mixer2Visible;
+
+ false, // markerVisible;
+ true, // showSplashScreen
+ 1, // canvasShowPartType 1 - names, 2 events
+ 5, // canvasShowPartEvent
+ true, // canvasShowGrid;
+ QString(""), // canvasBgPixmap;
+ QStringList(), // canvasCustomBgList
+ QString(":/style.qss"), // default styleSheetFile
+ QString(""), // style
+ QString("sweep"), // externalWavEditor
+ false, // useOldStyleStopShortCut
+ true, // moveArmedCheckBox
+ true, // useDenormalBias
+ false, // useOutputLimiter
+ true, // showDidYouKnow
+ false, // vstInPlace Enable VST in-place processing
+ 44100, // Dummy audio preferred sample rate
+ 512, // Dummy audio buffer size
+ QString("./"), // projectBaseFolder
+ true // projectStoreInFolder
+ };
+
diff --git a/attic/muse2-oom/muse2/muse/gconfig.h b/attic/muse2-oom/muse2/muse/gconfig.h
new file mode 100644
index 00000000..2eeea7cb
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/gconfig.h
@@ -0,0 +1,149 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: gconfig.h,v 1.12.2.10 2009/12/01 03:52:40 terminator356 Exp $
+//
+// (C) Copyright 1999-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __CONFIG_H__
+#define __CONFIG_H__
+
+#define NUM_PARTCOLORS 17
+#define NUM_FONTS 7
+
+#include <QColor>
+#include <QFont>
+#include <QRect>
+#include <QString>
+
+class Xml;
+
+//---------------------------------------------------------
+// MixerConfig
+//---------------------------------------------------------
+
+struct MixerConfig {
+ QString name;
+ QRect geometry;
+ bool showMidiTracks;
+ bool showDrumTracks;
+ bool showInputTracks;
+ bool showOutputTracks;
+ bool showWaveTracks;
+ bool showGroupTracks;
+ bool showAuxTracks;
+ bool showSyntiTracks;
+
+ //void write(Xml&, const char* name);
+ //void write(int level, Xml& xml, const char* name);
+ void write(int level, Xml& xml);
+ //void read(QDomNode);
+ //void read(Xml& xml, const QString& name);
+ void read(Xml& xml);
+ };
+
+//---------------------------------------------------------
+// GlobalConfigValues
+//---------------------------------------------------------
+
+struct GlobalConfigValues {
+ int globalAlphaBlend;
+ QColor palette[16];
+ QColor partColors[NUM_PARTCOLORS];
+ QString partColorNames[NUM_PARTCOLORS];
+ QColor transportHandleColor;
+ QColor bigTimeForegroundColor;
+ QColor bigTimeBackgroundColor;
+ QColor waveEditBackgroundColor;
+ //QFont fonts[6];
+ QFont fonts[NUM_FONTS];
+ QColor trackBg;
+ QColor selectTrackBg;
+ QColor selectTrackFg;
+
+ QColor midiTrackLabelBg;
+ QColor drumTrackLabelBg;
+ QColor waveTrackLabelBg;
+ QColor outputTrackLabelBg;
+ QColor inputTrackLabelBg;
+ QColor groupTrackLabelBg;
+ QColor auxTrackLabelBg;
+ QColor synthTrackLabelBg;
+
+ QColor midiTrackBg;
+ QColor drumTrackBg;
+ QColor waveTrackBg;
+ QColor outputTrackBg;
+ QColor inputTrackBg;
+ QColor groupTrackBg;
+ QColor auxTrackBg;
+ QColor synthTrackBg;
+
+ QColor partCanvasBg;
+ QColor ctrlGraphFg;
+ QColor mixerBg;
+
+ int division;
+ int rtcTicks;
+ int minMeter;
+ double minSlider;
+ bool freewheelMode;
+ int guiRefresh;
+ QString userInstrumentsDir;
+
+ bool extendedMidi; // extended smf format
+ int midiDivision; // division for smf export
+ QString copyright; // copyright string for smf export
+ int smfFormat; // smf export file type
+ bool exp2ByteTimeSigs; // Export 2 byte time sigs instead of 4 bytes
+ bool expOptimNoteOffs; // Save space by replacing note offs with note on velocity 0
+ bool importMidiSplitParts; // Split imported tracks into multiple parts.
+
+ int startMode; // 0 - start with last song
+ // 1 - start with default template
+ // 2 - start with song
+ QString startSong; // path for start song
+ int guiDivision; // division for tick display
+
+ QRect geometryMain;
+ QRect geometryTransport;
+ QRect geometryBigTime;
+ QRect geometryPianoroll;
+ QRect geometryDrumedit;
+// QRect geometryMixer;
+ MixerConfig mixer1;
+ MixerConfig mixer2;
+ bool transportVisible;
+ bool bigTimeVisible;
+// bool mixerVisible;
+ bool mixer1Visible;
+ bool mixer2Visible;
+ bool markerVisible;
+
+ bool showSplashScreen;
+ int canvasShowPartType; // 1 - names, 2 events
+ int canvasShowPartEvent; //
+ bool canvasShowGrid;
+ QString canvasBgPixmap;
+ QStringList canvasCustomBgList;
+ QString styleSheetFile;
+ QString style;
+
+ QString externalWavEditor;
+ bool useOldStyleStopShortCut;
+ bool moveArmedCheckBox;
+ bool useDenormalBias;
+ bool useOutputLimiter;
+ bool showDidYouKnow;
+ bool vstInPlace; // Enable VST in-place processing
+ int dummyAudioSampleRate;
+ int dummyAudioBufSize;
+ QString projectBaseFolder;
+ bool projectStoreInFolder;
+ };
+
+extern GlobalConfigValues config;
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/givertcap.c b/attic/muse2-oom/muse2/muse/givertcap.c
new file mode 100644
index 00000000..2511bc6c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/givertcap.c
@@ -0,0 +1,94 @@
+/*
+ * COPYRIGHT
+ *
+ * This file is part of Mustajuuri GPL modules. You may distribute it
+ * with or without other Mustajuuri components.
+ *
+ * Author: Tommi Ilmonen, 2001.
+ * Tommi.Ilmonen@hut.fi
+ *
+ * http://www.tml.hut.fi/~tilmonen/mustajuuri/
+
+ * This app also has its own home page at (installation instruction
+ * etc.): http://www.tml.hut.fi/~tilmonen/givertcap/
+
+ * This file is licensed under the GNU Public License (GPL) version
+ * 2. The GPL can also be found from the givertcap home page. Any
+ * application may call civertcap (regardless of the license of the
+ * calling application).
+
+ * If you want a parallel license (for commercial reasons for example),
+ * you should negotiate the matter with the author(s).
+ *
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+
+#undef _POSIX_SOURCE
+#include <sys/capability.h>
+/* If the compilation fails on the preceding line, then you probably
+ do not have the libcap installed.
+
+*/
+
+static void usage(const char *programName)
+{
+ fprintf(stderr,
+ "usage: %s \n\n"
+ " This program gives real-time application capabilities to the"
+ " parent process\n\n"
+ "[Copyright (c) 2001 Tommi Ilmonen <Tommi.Ilmonen@hut.fi>]\n"
+ "Home page: http://www.tml.hut.fi/~tilmonen/givertcap/\n",
+ programName);
+}
+
+int main(int argc, char **argv)
+{
+ if(argc > 1) {
+ usage(argv[0]);
+ return 1;
+ }
+
+ pid_t parentPid = getppid();
+
+ if(!parentPid)
+ return 1;
+
+ cap_t caps = cap_init();
+
+#define nofCaps 3
+
+ /* We need these capabilities:
+
+ CAP_SYS_NICE -> Real-time priority
+ CAP_SYS_RESOURCE -> RTC above 64 Hz
+ CAP_IPC_LOCK -> mlockall
+ */
+
+ cap_value_t capList[nofCaps] =
+ { CAP_SYS_NICE, CAP_SYS_RESOURCE, CAP_IPC_LOCK} ;
+
+ cap_clear(caps);
+ cap_set_flag(caps, CAP_EFFECTIVE, nofCaps, capList , CAP_SET);
+ cap_set_flag(caps, CAP_INHERITABLE, nofCaps, capList , CAP_SET);
+ cap_set_flag(caps, CAP_PERMITTED, nofCaps, capList , CAP_SET);
+
+ /* If your COMPILATION FAILS here then you probably are not running
+ Linux. the function "capsetp" is not part of the POSIX capability
+ standard, but a Linux-specific extension. */
+ if (capsetp(parentPid, caps)) {
+ perror("mjsucaps: capsetp");
+ return 1;
+ }
+
+ ssize_t x;
+// printf("The process %d was give capabilities %s\n",
+// (int) parentPid, cap_to_text(caps, &x));
+ fflush(0);
+
+ // Don't bother to free the memory...
+
+ return 0;
+}
diff --git a/attic/muse2-oom/muse2/muse/globaldefs.h b/attic/muse2-oom/muse2/muse/globaldefs.h
new file mode 100644
index 00000000..74c18d7d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/globaldefs.h
@@ -0,0 +1,34 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: globaldefs.h,v 1.3.2.1 2009/05/03 04:14:00 terminator356 Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __GLOBALDEFS_H__
+#define __GLOBALDEFS_H__
+
+// Midi Type
+// MT_GM - General Midi
+// MT_GS - Roland GS
+// MT_XG - Yamaha XG
+
+enum MType { MT_UNKNOWN=0, MT_GM, MT_GS, MT_XG };
+
+enum AutomationType {
+ AUTO_OFF, AUTO_READ, AUTO_TOUCH, AUTO_WRITE
+ };
+
+const int MAX_CHANNELS = 2; // max audio channels
+const int MAX_PLUGINS = 4; // plugins in mixer rack
+
+//const int MIDI_PORTS = 32; // max Number of Midi Ports
+const int MIDI_PORTS = 200; // max Number of Midi Ports
+
+#ifndef MIDI_CHANNELS
+#define MIDI_CHANNELS 16 // Channels per Port
+#endif
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/globals.cpp b/attic/muse2-oom/muse2/muse/globals.cpp
new file mode 100644
index 00000000..f53846f9
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/globals.cpp
@@ -0,0 +1,399 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: globals.cpp,v 1.15.2.11 2009/11/25 09:09:43 terminator356 Exp $
+//
+// (C) Copyright 1999-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <errno.h>
+#include <unistd.h>
+#include <stdlib.h>
+
+#include <QActionGroup>
+#include <QDir>
+#include <QFileInfo>
+
+#include "globals.h"
+#include "config.h"
+
+int recFileNumber = 1;
+
+int sampleRate = 44100;
+unsigned segmentSize = 1024U; // segmentSize in frames (set by JACK)
+unsigned fifoLength = 128; // 131072/segmentSize
+ // 131072 - magic number that gives a sufficient buffer size
+int segmentCount = 2;
+
+// denormal bias value used to eliminate the manifestation of denormals by
+// lifting the zero level slightly above zero
+// denormal problems occur when values get extremely close to zero
+const float denormalBias=1e-18;
+
+bool overrideAudioOutput = false;
+bool overrideAudioInput = false;
+
+QTimer* heartBeatTimer;
+
+bool hIsB = true; // call note h "b"
+
+const signed char sharpTab[14][7] = {
+ { 0, 3, -1, 2, 5, 1, 4 },
+ { 0, 3, -1, 2, 5, 1, 4 },
+ { 0, 3, -1, 2, 5, 1, 4 },
+ { 0, 3, -1, 2, 5, 1, 4 },
+ { 2, 5, 1, 4, 7, 3, 6 },
+ { 2, 5, 1, 4, 7, 3, 6 },
+ { 2, 5, 1, 4, 7, 3, 6 },
+ { 4, 0, 3, -1, 2, 5, 1 },
+ { 7, 3, 6, 2, 5, 1, 4 },
+ { 5, 8, 4, 7, 3, 6, 2 },
+ { 3, 6, 2, 5, 1, 4, 7 },
+ { 1, 4, 0, 3, 6, 2, 5 },
+ { 6, 2, 5, 1, 4, 0, 3 },
+ { 0, 3, -1, 2, 5, 1, 4 },
+ };
+const signed char flatTab[14][7] = {
+ { 4, 1, 5, 2, 6, 3, 7 },
+ { 4, 1, 5, 2, 6, 3, 7 },
+ { 4, 1, 5, 2, 6, 3, 7 },
+ { 4, 1, 5, 2, 6, 3, 7 },
+ { 6, 3, 7, 4, 8, 5, 9 },
+ { 6, 3, 7, 4, 8, 5, 9 },
+ { 6, 3, 7, 4, 8, 5, 9 },
+
+ { 1, 5, 2, 6, 3, 7, 4 },
+ { 4, 1, 5, 2, 6, 3, 7 },
+ { 2, 6, 3, 7, 4, 8, 5 },
+ { 7, 4, 1, 5, 2, 6, 3 },
+ { 5, 2, 6, 3, 7, 4, 8 },
+ { 3, 0, 4, 1, 5, 2, 6 },
+ { 4, 1, 5, 2, 6, 3, 7 },
+ };
+
+QString museGlobalLib;
+QString museGlobalShare;
+QString museUser;
+QString museProject;
+QString museProjectInitPath("./");
+QString configName = QString(getenv("HOME")) + QString("/.config/MusE/MusE.cfg");
+QString configPath = QFileInfo(configName).absoluteDir().absolutePath();
+QString museInstruments;
+QString museUserInstruments;
+
+QString lastWavePath(".");
+QString lastMidiPath(".");
+
+bool debugMode = false;
+bool debugMsg = false;
+bool midiInputTrace = false;
+bool midiOutputTrace = false;
+bool realTimeScheduling = false;
+int realTimePriority = 40; // 80
+int midiRTPrioOverride = -1;
+bool loadPlugins = true;
+bool loadVST = true;
+bool loadDSSI = true;
+bool usePythonBridge = false;
+bool useLASH = true;
+
+/*
+const char* midi_file_pattern[] = {
+ QT_TRANSLATE_NOOP("@default", "Midi/Kar (*.mid *.MID *.kar *.KAR *.mid.gz *.mid.bz2)"),
+ QT_TRANSLATE_NOOP("@default", "Midi (*.mid *.MID *.mid.gz *.mid.bz2)"),
+ QT_TRANSLATE_NOOP("@default", "Karaoke (*.kar *.KAR *.kar.gz *.kar.bz2)"),
+ QT_TRANSLATE_NOOP("@default", "All Files (*)"),
+ 0
+ };
+*/
+const QStringList midi_file_pattern =
+ QT_TRANSLATE_NOOP("@default",
+ QString("Midi/Kar (*.mid *.MID *.kar *.KAR *.mid.gz *.mid.bz2);;") +
+ QString("Midi (*.mid *.MID *.mid.gz *.mid.bz2);;") +
+ QString("Karaoke (*.kar *.KAR *.kar.gz *.kar.bz2);;") +
+ QString("All Files (*)")).split(";;");
+
+//FIXME: By T356 01/19/2010
+// If saving as a compressed file (gz or bz2),
+// the file is a pipe, and pipes can't seek !
+// This results in a corrupted midi file from MidiFile::writeTrack().
+// So exporting compressed midi has simply been disabled here for now...
+/*
+const char* midi_file_save_pattern[] = {
+ "Midi (*.mid)",
+ "gzip compressed Midi (*.mid.gz)",
+ "bzip2 compressed Midi (*.mid.bz2)",
+ "Karaoke (*.kar)",
+ "gzip compressed karaoke (*.kar.gz)",
+ "bzip2 compressed karaoke (*.kar.bz2)",
+ "All Files (*)",
+ 0
+ };
+QStringList midi_file_save_pattern =
+ QStringList::split(";;", QT_TRANSLATE_NOOP("@default",
+ QString("Midi (*.mid);;") +
+ QString("gzip compressed Midi (*.mid.gz);;") +
+ QString("bzip2 compressed Midi (*.mid.bz2);;") +
+ QString("Karaoke (*.kar);;") +
+ QString("gzip compressed karaoke (*.kar.gz);;") +
+ QString("bzip2 compressed karaoke (*.kar.bz2);;") +
+ QString("All Files (*)")) );
+*/
+/*
+const char* midi_file_save_pattern[] = {
+ QT_TRANSLATE_NOOP("@default", "Midi (*.mid)"),
+ QT_TRANSLATE_NOOP("@default", "Karaoke (*.kar)"),
+ QT_TRANSLATE_NOOP("@default", "All Files (*)"),
+ 0
+ };
+*/
+const QStringList midi_file_save_pattern =
+ QT_TRANSLATE_NOOP("@default",
+ QString("Midi (*.mid);;") +
+ QString("Karaoke (*.kar);;") +
+ QString("All Files (*)")).split(";;");
+
+/*
+const char* med_file_pattern[] = {
+ QT_TRANSLATE_NOOP("@default", "med Files (*.med *.med.gz *.med.bz2)"),
+ QT_TRANSLATE_NOOP("@default", "Uncompressed med Files (*.med)"),
+ QT_TRANSLATE_NOOP("@default", "gzip compressed med Files (*.med.gz)"),
+ QT_TRANSLATE_NOOP("@default", "bzip2 compressed med Files (*.med.bz2)"),
+ QT_TRANSLATE_NOOP("@default", "All Files (*)"),
+ 0
+ };
+const char* med_file_save_pattern[] = {
+ QT_TRANSLATE_NOOP("@default", "Uncompressed med Files (*.med)"),
+ QT_TRANSLATE_NOOP("@default", "gzip compressed med Files (*.med.gz)"),
+ QT_TRANSLATE_NOOP("@default", "bzip2 compressed med Files (*.med.bz2)"),
+ QT_TRANSLATE_NOOP("@default", "All Files (*)"),
+ 0
+ };
+*/
+const QStringList med_file_pattern =
+ QT_TRANSLATE_NOOP("@default",
+ QString("med Files (*.med *.med.gz *.med.bz2);;") +
+ QString("Uncompressed med Files (*.med);;") +
+ QString("gzip compressed med Files (*.med.gz);;") +
+ QString("bzip2 compressed med Files (*.med.bz2);;") +
+ QString("All Files (*)")).split(";;");
+const QStringList med_file_save_pattern =
+ QT_TRANSLATE_NOOP("@default",
+ QString("Uncompressed med Files (*.med);;") +
+ QString("gzip compressed med Files (*.med.gz);;") +
+ QString("bzip2 compressed med Files (*.med.bz2);;") +
+ QString("All Files (*)")).split(";;");
+
+/*
+const char* image_file_pattern[] = {
+ QT_TRANSLATE_NOOP("@default", "(*.jpg *.gif *.png)"),
+ QT_TRANSLATE_NOOP("@default", "(*.jpg)"),
+ QT_TRANSLATE_NOOP("@default", "(*.gif)"),
+ QT_TRANSLATE_NOOP("@default", "(*.png)"),
+ QT_TRANSLATE_NOOP("@default", "All Files (*)"),
+ 0
+ };
+*/
+const QStringList image_file_pattern =
+ QT_TRANSLATE_NOOP("@default",
+ QString("(*.jpg *.gif *.png);;") +
+ QString("(*.jpg);;") +
+ QString("(*.gif);;") +
+ QString("(*.png);;") +
+ QString("All Files (*)")).split(";;");
+
+// Not used.
+/*
+const char* ctrl_file_pattern[] = {
+ "ctrl Files (*.ctrl *.ctrl.gz *.ctrl.bz2)",
+ "All Files (*)",
+ 0
+ };
+*/
+
+/*
+const char* part_file_pattern[] = {
+ //QT_TRANSLATE_NOOP("@default", "part Files (*.mpt)"),
+ QT_TRANSLATE_NOOP("@default", "part Files (*.mpt *.mpt.gz *.mpt.bz2)"),
+ QT_TRANSLATE_NOOP("@default", "All Files (*)"),
+ 0
+ };
+const char* part_file_save_pattern[] = {
+ QT_TRANSLATE_NOOP("@default", "part Files (*.mpt)"),
+ QT_TRANSLATE_NOOP("@default", "gzip compressed part Files (*.mpt.gz)"),
+ QT_TRANSLATE_NOOP("@default", "bzip2 compressed part Files (*.mpt.bz2)"),
+ QT_TRANSLATE_NOOP("@default", "All Files (*)"),
+ 0
+ };
+*/
+const QStringList part_file_pattern =
+ QT_TRANSLATE_NOOP("@default",
+ QString("part Files (*.mpt *.mpt.gz *.mpt.bz2);;") +
+ QString("All Files (*)")).split(";;");
+
+const QStringList part_file_save_pattern =
+ QT_TRANSLATE_NOOP("@default",
+ QString("part Files (*.mpt);;") +
+ QString("gzip compressed part Files (*.mpt.gz);;") +
+ QString("bzip2 compressed part Files (*.mpt.bz2);;") +
+ QString("All Files (*)")).split(";;");
+
+/*
+const char* plug_file_pattern[] = {
+ QT_TRANSLATE_NOOP("@default", "part Files (*.pre)"),
+ QT_TRANSLATE_NOOP("@default", "All Files (*)"),
+ 0
+ };
+*/
+/*
+const char* preset_file_pattern[] = {
+ QT_TRANSLATE_NOOP("@default", "Presets (*.pre *.pre.gz *.pre.bz2)"),
+ QT_TRANSLATE_NOOP("@default", "All Files (*)"),
+ 0
+ };
+
+const char* preset_file_save_pattern[] = {
+ QT_TRANSLATE_NOOP("@default", "Presets (*.pre)"),
+ QT_TRANSLATE_NOOP("@default", "gzip compressed presets (*.pre.gz)"),
+ QT_TRANSLATE_NOOP("@default", "bzip2 compressed presets (*.pre.bz2)"),
+ QT_TRANSLATE_NOOP("@default", "All Files (*)"),
+ 0
+ };
+*/
+const QStringList preset_file_pattern =
+ QT_TRANSLATE_NOOP("@default",
+ QString("Presets (*.pre *.pre.gz *.pre.bz2);;") +
+ QString("All Files (*)")).split(";;");
+
+const QStringList preset_file_save_pattern =
+ QT_TRANSLATE_NOOP("@default",
+ QString("Presets (*.pre);;") +
+ QString("gzip compressed presets (*.pre.gz);;") +
+ QString("bzip2 compressed presets (*.pre.bz2);;") +
+ QString("All Files (*)")).split(";;");
+
+const QStringList drum_map_file_pattern =
+ QT_TRANSLATE_NOOP("@default",
+ QString("Presets (*.map *.map.gz *.map.bz2);;") +
+ QString("All Files (*)")).split(";;");
+const QStringList drum_map_file_save_pattern =
+ QT_TRANSLATE_NOOP("@default",
+ QString("Presets (*.map);;") +
+ QString("gzip compressed presets (*.map.gz);;") +
+ QString("bzip2 compressed presets (*.map.bz2);;") +
+ QString("All Files (*)")).split(";;");
+
+const QStringList audio_file_pattern =
+ QT_TRANSLATE_NOOP("@default",
+ QString("Wave/Binary (*.wav *.ogg *.bin);;") +
+ QString("Wave (*.wav *.ogg);;") +
+ QString("Binary (*.bin);;") +
+ QString("All Files (*)")).split(";;");
+
+///Qt::ButtonState globalKeyState;
+Qt::KeyboardModifiers globalKeyState;
+
+// Midi Filter Parameter
+int midiInputPorts = 0; // receive from all devices
+int midiInputChannel = 0; // receive all channel
+int midiRecordType = 0; // receive all events
+int midiThruType = 0; // transmit all events
+int midiFilterCtrl1 = 0;
+int midiFilterCtrl2 = 0;
+int midiFilterCtrl3 = 0;
+int midiFilterCtrl4 = 0;
+
+QActionGroup* undoRedo;
+QAction* undoAction;
+QAction* redoAction;
+QActionGroup* transportAction;
+QAction* playAction;
+QAction* startAction;
+QAction* stopAction;
+QAction* rewindAction;
+QAction* forwardAction;
+QAction* loopAction;
+QAction* punchinAction;
+QAction* punchoutAction;
+QAction* recordAction;
+QAction* panicAction;
+
+//AudioMixerApp* audioMixer;
+MusE* muse;
+
+int preMeasures = 2;
+unsigned char measureClickNote = 63;
+unsigned char measureClickVelo = 127;
+unsigned char beatClickNote = 63;
+unsigned char beatClickVelo = 70;
+unsigned char clickChan = 9;
+unsigned char clickPort = 0;
+bool precountEnableFlag = false;
+bool precountFromMastertrackFlag = false;
+int precountSigZ = 4;
+int precountSigN = 4;
+bool precountPrerecord = false;
+bool precountPreroll = false;
+bool midiClickFlag = true;
+bool audioClickFlag = true;
+float audioClickVolume = 0.5f;
+
+bool rcEnable = false;
+unsigned char rcStopNote = 28;
+unsigned char rcRecordNote = 31;
+unsigned char rcGotoLeftMarkNote = 33;
+unsigned char rcPlayNote = 29;
+bool automation = true;
+
+QObject* gRoutingPopupMenuMaster = 0;
+RouteMenuMap gRoutingMenuMap;
+bool gIsOutRoutingPopupMenu = false;
+
+uid_t euid, ruid; // effective user id, real user id
+
+bool midiSeqRunning = false;
+
+//---------------------------------------------------------
+// doSetuid
+// Restore the effective UID to its original value.
+//---------------------------------------------------------
+
+void doSetuid()
+ {
+#ifndef RTCAP
+ int status;
+#ifdef _POSIX_SAVED_IDS
+ status = seteuid (euid);
+#else
+ status = setreuid (ruid, euid);
+#endif
+ if (status < 0) {
+ perror("doSetuid: Couldn't set uid");
+ }
+#endif
+ }
+
+//---------------------------------------------------------
+// undoSetuid
+// Set the effective UID to the real UID.
+//---------------------------------------------------------
+
+void undoSetuid()
+ {
+#ifndef RTCAP
+ int status;
+
+#ifdef _POSIX_SAVED_IDS
+ status = seteuid (ruid);
+#else
+ status = setreuid (euid, ruid);
+#endif
+ if (status < 0) {
+ fprintf(stderr, "undoSetuid: Couldn't set uid (eff:%d,real:%d): %s\n",
+ euid, ruid, strerror(errno));
+ exit (status);
+ }
+#endif
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/globals.h b/attic/muse2-oom/muse2/muse/globals.h
new file mode 100644
index 00000000..cb4da0c5
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/globals.h
@@ -0,0 +1,191 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: globals.h,v 1.10.2.11 2009/11/25 09:09:43 terminator356 Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef GLOBALS_H
+#define GLOBALS_H
+
+#include <sys/types.h>
+
+#include "value.h"
+#include "mtc.h"
+#include "route.h"
+
+#include <unistd.h>
+
+class QString;
+class QAction;
+class QActionGroup;
+class QStringList;
+
+extern const float denormalBias;
+
+extern int recFileNumber;
+
+extern int sampleRate;
+extern unsigned segmentSize;
+extern unsigned fifoLength; // inversely proportional to segmentSize
+extern int segmentCount;
+
+extern bool overrideAudioOutput;
+extern bool overrideAudioInput;
+
+class QTimer;
+extern QTimer* heartBeatTimer;
+
+extern bool hIsB;
+
+extern const signed char sharpTab[14][7];
+extern const signed char flatTab[14][7];
+
+extern QString museGlobalLib;
+extern QString museGlobalShare;
+extern QString museUser;
+extern QString museProject;
+extern QString museProjectInitPath;
+extern QString configName;
+extern QString configPath;
+extern QString museInstruments;
+extern QString museUserInstruments;
+
+extern QString lastWavePath;
+extern QString lastMidiPath;
+
+extern bool debugMode;
+extern bool midiInputTrace;
+extern bool midiOutputTrace;
+extern bool debugMsg;
+extern bool debugSync;
+extern bool loadPlugins;
+extern bool loadVST;
+extern bool loadDSSI;
+extern bool usePythonBridge;
+extern bool useLASH;
+
+extern bool realTimeScheduling;
+extern int realTimePriority;
+extern int midiRTPrioOverride;
+
+/*
+extern const char* midi_file_pattern[]; //!< File name pattern for midi files
+extern const char* midi_file_save_pattern[]; //!< File name pattern for saving midi files
+extern const char* med_file_pattern[]; //!< File name pattern for muse project files
+extern const char* med_file_save_pattern[]; //!< File name pattern for saving muse project files
+extern const char* image_file_pattern[]; //!< File name pattern for image files (gfx)
+//extern const char* ctrl_file_pattern[]; //!< File name pattern for controller-files
+extern const char* part_file_pattern[]; //!< File name pattern for part files
+extern const char* part_file_save_pattern[]; //!< File name pattern for saving part files
+//extern const char* plug_file_pattern[]; //!< File name pattern for plugin files
+extern const char* preset_file_pattern[]; //!< File name pattern for plugin files
+extern const char* preset_file_save_pattern[]; //!< File name pattern for saving plugin files
+*/
+
+extern const QStringList midi_file_pattern;
+extern const QStringList midi_file_save_pattern;
+extern const QStringList med_file_pattern;
+extern const QStringList med_file_save_pattern;
+extern const QStringList image_file_pattern;
+//extern const QStringList ctrl_file_pattern;
+extern const QStringList part_file_pattern;
+extern const QStringList part_file_save_pattern;
+extern const QStringList preset_file_pattern;
+extern const QStringList preset_file_save_pattern;
+extern const QStringList drum_map_file_pattern;
+extern const QStringList drum_map_file_save_pattern;
+extern const QStringList audio_file_pattern;
+
+///extern Qt::ButtonState globalKeyState;
+extern Qt::KeyboardModifiers globalKeyState;
+
+extern int midiInputPorts; //!< receive from all devices
+extern int midiInputChannel; //!< receive all channel
+extern int midiRecordType; //!< receive all events
+
+#define MIDI_FILTER_NOTEON 1
+#define MIDI_FILTER_POLYP 2
+#define MIDI_FILTER_CTRL 4
+#define MIDI_FILTER_PROGRAM 8
+#define MIDI_FILTER_AT 16
+#define MIDI_FILTER_PITCH 32
+#define MIDI_FILTER_SYSEX 64
+
+extern int midiThruType; // transmit all events
+extern int midiFilterCtrl1;
+extern int midiFilterCtrl2;
+extern int midiFilterCtrl3;
+extern int midiFilterCtrl4;
+
+#define CMD_RANGE_ALL 0
+#define CMD_RANGE_SELECTED 1
+#define CMD_RANGE_LOOP 2
+
+extern QActionGroup* undoRedo;
+extern QAction* undoAction;
+extern QAction* redoAction;
+
+extern QActionGroup* transportAction;
+extern QAction* playAction;
+extern QAction* startAction;
+extern QAction* stopAction;
+extern QAction* rewindAction;
+extern QAction* forwardAction;
+extern QAction* loopAction;
+extern QAction* punchinAction;
+extern QAction* punchoutAction;
+extern QAction* recordAction;
+extern QAction* panicAction;
+
+//class AudioMixerApp;
+class MusE;
+//extern AudioMixerApp* audioMixer;
+extern MusE* muse;
+
+extern int preMeasures;
+extern unsigned char measureClickNote;
+extern unsigned char measureClickVelo;
+extern unsigned char beatClickNote;
+extern unsigned char beatClickVelo;
+extern unsigned char clickChan;
+extern unsigned char clickPort;
+extern bool precountEnableFlag;
+extern bool precountFromMastertrackFlag;
+extern int precountSigZ;
+extern int precountSigN;
+extern bool precountPrerecord;
+extern bool precountPreroll;
+extern bool midiClickFlag;
+extern bool audioClickFlag;
+extern float audioClickVolume;
+
+extern bool rcEnable;
+extern unsigned char rcStopNote;
+extern unsigned char rcRecordNote;
+extern unsigned char rcGotoLeftMarkNote;
+extern unsigned char rcPlayNote;
+
+extern bool midiSeqRunning;
+extern bool automation;
+
+class QObject;
+// Which audio strip, midi strip, or midi track info strip
+// was responsible for popping up the routing menu.
+extern QObject* gRoutingPopupMenuMaster;
+// Map of routing popup menu item IDs to Routes.
+extern RouteMenuMap gRoutingMenuMap;
+// Whether the routes popup was shown by clicking the output routes button, or input routes button.
+extern bool gIsOutRoutingPopupMenu;
+
+// p3.3.55
+#define JACK_MIDI_OUT_PORT_SUFFIX "_out"
+#define JACK_MIDI_IN_PORT_SUFFIX "_in"
+
+extern uid_t euid, ruid;
+extern void doSetuid();
+extern void undoSetuid();
+extern bool checkAudioDevice();
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/gui.h b/attic/muse2-oom/muse2/muse/gui.h
new file mode 100644
index 00000000..4deeb748
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/gui.h
@@ -0,0 +1,56 @@
+//=============================================================================
+// MusE
+// Linux Music Editor
+// $Id:$
+//
+// Copyright (C) 2002-2006 by Werner Schweer and others
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//=============================================================================
+
+#ifndef __GUI_H__
+#define __GUI_H__
+
+//
+// GUI constants
+// central point of tweaking the gui
+//
+
+/*
+// size of horizontal and vertical splitter
+//
+static const int splitWidth = 6;
+
+// arranger:
+static const int trackRowHeight = 24;
+static const int minTrackHeight = trackRowHeight + splitWidth + 1;
+static const int defaultTrackHeight = minTrackHeight;
+static const int infoHeight = 20;
+static const int infoWidth = 140;
+static const int trackSeparator = 1;
+static const int yTrackOffset = -2; // -4;
+
+// mixer:
+static const int STRIP_WIDTH = 60;
+static const int LABEL_HEIGHT = 20;
+static const int BUTTON_HEIGHT = STRIP_WIDTH / 3;
+static const int ENTRY_HEIGHT = 17;
+*/
+
+static const int ICON_WIDTH = 18;
+static const QSize ICON_SIZE(ICON_WIDTH, ICON_WIDTH);
+
+#endif
+
+
+
diff --git a/attic/muse2-oom/muse2/muse/help.cpp b/attic/muse2-oom/muse2/muse/help.cpp
new file mode 100644
index 00000000..30803838
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/help.cpp
@@ -0,0 +1,94 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: help.cpp,v 1.7.2.4 2009/07/05 23:06:21 terminator356 Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <unistd.h>
+#include <stdlib.h>
+
+#include <QDesktopServices>
+#include <QMessageBox>
+#include <QUrl>
+
+#include "app.h"
+#include "globals.h"
+#include "gconfig.h"
+#include "icons.h"
+#include "aboutbox_impl.h"
+
+//---------------------------------------------------------
+// startHelpBrowser
+//---------------------------------------------------------
+
+void MusE::startHelpBrowser()
+ {
+ QString lang(getenv("LANG"));
+ QString museHelp = DOCDIR + QString("/html/index_") + lang + QString(".html");
+ if (access(museHelp.toLatin1(), R_OK) != 0) {
+ museHelp = DOCDIR + QString("/html/index.html");
+ if (access(museHelp.toLatin1(), R_OK) != 0) {
+ QString info(tr("no help found at: "));
+ info += museHelp;
+ QMessageBox::critical(this, tr("MusE: Open Help"), info);
+ return;
+ }
+ }
+ launchBrowser(museHelp);
+ }
+
+//---------------------------------------------------------
+// startHelpBrowser
+//---------------------------------------------------------
+
+void MusE::startHomepageBrowser()
+ {
+ QString museHome = QString("http://www.muse-sequencer.org");
+
+ launchBrowser(museHome);
+ }
+
+//---------------------------------------------------------
+// startBugBrowser
+//---------------------------------------------------------
+
+void MusE::startBugBrowser()
+ {
+ //QString museBugPage("http://www.muse-sequencer.org/wiki/index.php/Report_a_bug");
+ QString museBugPage("http://www.muse-sequencer.org/index.php/Report_a_bug");
+ launchBrowser(museBugPage);
+ }
+
+//---------------------------------------------------------
+// about
+//---------------------------------------------------------
+
+void MusE::about()
+ {
+ AboutBoxImpl ab;
+ ab.show();
+ ab.exec();
+ }
+
+//---------------------------------------------------------
+// aboutQt
+//---------------------------------------------------------
+
+void MusE::aboutQt()
+ {
+ QMessageBox::aboutQt(this, QString("MusE"));
+ }
+
+void MusE::launchBrowser(QString &whereTo)
+ {
+ if (! QDesktopServices::openUrl(QUrl(whereTo)))
+ {
+ QMessageBox::information(this, tr("Unable to launch help"),
+ tr("For some reason MusE has to launch the default\n"
+ "browser on your machine."),
+ QMessageBox::Ok, QMessageBox::Ok);
+ printf("Unable to launch help\n");
+ }
+ }
diff --git a/attic/muse2-oom/muse2/muse/helper.cpp b/attic/muse2-oom/muse2/muse/helper.cpp
new file mode 100644
index 00000000..605d6f5c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/helper.cpp
@@ -0,0 +1,40 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: helper.cpp,v 1.1.1.1 2003/10/27 18:51:27 wschweer Exp $
+// (C) Copyright 2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "helper.h"
+
+extern bool hIsB;
+static const char* vall[] = {
+ "c","c#","d","d#","e","f","f#","g","g#","a","a#","h"
+ };
+static const char* valu[] = {
+ "C","C#","D","D#","E","F","F#","G","G#","A","A#","H"
+ };
+
+//---------------------------------------------------------
+// pitch2string
+//---------------------------------------------------------
+
+QString pitch2string(int v)
+ {
+ if (v < 0 || v > 127)
+ return QString("----");
+ int octave = (v / 12) - 2;
+ QString o;
+ o.sprintf("%d", octave);
+ int i = v % 12;
+ QString s(octave < 0 ? valu[i] : vall[i]);
+ if (hIsB) {
+ if (s == "h")
+ s = "b";
+ else if (s == "H")
+ s = "B";
+ }
+ return s + o;
+ }
+
+
diff --git a/attic/muse2-oom/muse2/muse/helper.h b/attic/muse2-oom/muse2/muse/helper.h
new file mode 100644
index 00000000..f772ebf6
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/helper.h
@@ -0,0 +1,16 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: helper.h,v 1.1.1.1 2003/10/27 18:52:11 wschweer Exp $
+// (C) Copyright 2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __HELPER_H__
+#define __HELPER_H__
+
+#include <QString>
+
+extern QString pitch2string(int v);
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/icons.cpp b/attic/muse2-oom/muse2/muse/icons.cpp
new file mode 100644
index 00000000..28386aec
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/icons.cpp
@@ -0,0 +1,711 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: icons.cpp,v 1.13.2.8 2009/11/14 03:37:48 terminator356 Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "globals.h"
+
+#include <QIcon>
+
+#include "xpm/track_comment.xpm"
+#include "xpm/audio_bounce_to_file.xpm"
+#include "xpm/audio_bounce_to_track.xpm"
+#include "xpm/audio_restartaudio.xpm"
+#include "xpm/automation_clear_data.xpm"
+#include "xpm/automation_mixer.xpm"
+#include "xpm/automation_take_snapshot.xpm"
+#include "xpm/edit_midi.xpm"
+#include "xpm/midi_edit_instrument.xpm"
+#include "xpm/midi_init_instr.xpm"
+#include "xpm/midi_inputplugins.xpm"
+#include "xpm/midi_inputplugins_midi_input_filter.xpm"
+#include "xpm/midi_inputplugins_midi_input_transform.xpm"
+#include "xpm/midi_inputplugins_remote_control.xpm"
+#include "xpm/midi_inputplugins_transpose.xpm"
+#include "xpm/midi_inputplugins_random_rhythm_generator.xpm"
+#include "xpm/midi_local_off.xpm"
+#include "xpm/midi_reset_instr.xpm"
+#include "xpm/midi_thru_off3.xpm"
+#include "xpm/midi_thru_on3.xpm"
+#include "xpm/settings_appearance_settings.xpm"
+#include "xpm/settings_configureshortcuts.xpm"
+#include "xpm/settings_follow_song.xpm"
+#include "xpm/settings_globalsettings.xpm"
+#include "xpm/settings_metronome.xpm"
+#include "xpm/settings_midifileexport.xpm"
+#include "xpm/settings_midiport_softsynths.xpm"
+#include "xpm/settings_midisync.xpm"
+#include "xpm/view_bigtime_window.xpm"
+#include "xpm/view_cliplist.xpm"
+#include "xpm/view_marker.xpm"
+#include "xpm/view_mixer.xpm"
+#include "xpm/view_transport_window.xpm"
+
+#include "xpm/pointer.xpm"
+#include "xpm/pencil.xpm"
+#include "xpm/delete.xpm"
+#include "xpm/play.xpm"
+
+#include "xpm/record1.xpm"
+#include "xpm/record.xpm"
+#include "xpm/record_on.xpm"
+#include "xpm/record_off.xpm"
+#include "xpm/stop.xpm"
+#include "xpm/start.xpm"
+#include "xpm/fforward.xpm"
+#include "xpm/frewind.xpm"
+#include "xpm/punchin.xpm"
+#include "xpm/punchout.xpm"
+#include "xpm/punchin1.xpm"
+#include "xpm/punchout1.xpm"
+#include "xpm/loop1.xpm"
+#include "xpm/loop.xpm"
+#include "xpm/dot.xpm"
+#include "xpm/doth.xpm"
+#include "xpm/dot1.xpm"
+#include "xpm/note.xpm"
+#include "xpm/note1.xpm"
+#include "xpm/stick.xpm"
+#include "xpm/wave.xpm"
+#include "xpm/synth.xpm"
+#include "xpm/cmark.xpm"
+#include "xpm/lmark.xpm"
+#include "xpm/rmark.xpm"
+#include "xpm/cut.xpm"
+#include "xpm/steprec.xpm"
+#include "xpm/glue.xpm"
+#include "xpm/draw.xpm"
+#include "xpm/quant.xpm"
+#include "xpm/fileprint.xpm"
+#include "xpm/filesave.xpm"
+#include "xpm/filesaveas.xpm"
+#include "xpm/fileopen.xpm"
+#include "xpm/fileprintS.xpm"
+#include "xpm/filesaveS.xpm"
+#include "xpm/filesaveasS.xpm"
+#include "xpm/fileopenS.xpm"
+#include "xpm/master.xpm"
+#include "xpm/filenew.xpm"
+#include "xpm/filenewS.xpm"
+#include "xpm/home.xpm"
+#include "xpm/back.xpm"
+#include "xpm/forward.xpm"
+
+// #include "xpm/mute.xpm"
+#include "xpm/solobutton_on.xpm"
+#include "xpm/solobutton_off.xpm"
+#include "xpm/solobutton_on_blksq.xpm"
+#include "xpm/solobutton_off_blksq.xpm"
+#include "xpm/mutebutton_on.xpm"
+#include "xpm/mutebutton_off.xpm"
+#include "xpm/rec_echo_on.xpm"
+#include "xpm/rec_echo_off.xpm"
+
+#include "xpm/up.xpm"
+#include "xpm/down.xpm"
+#include "xpm/bold.xpm"
+#include "xpm/italic.xpm"
+#include "xpm/underlined.xpm"
+#include "xpm/gv.xpm"
+#include "xpm/midiin.xpm"
+#include "xpm/sysex.xpm"
+#include "xpm/ctrl.xpm"
+#include "xpm/meta.xpm"
+#include "xpm/pitch.xpm"
+#include "xpm/cafter.xpm"
+#include "xpm/pafter.xpm"
+#include "xpm/flag.xpm"
+#include "xpm/flagS.xpm"
+#include "xpm/lock.xpm"
+#include "xpm/toc.xpm"
+// #include "xpm/piano.xpm" // not used -Orcan
+// #include "xpm/pianoS.xpm"
+#include "xpm/exitS.xpm"
+
+#include "xpm/undo.xpm"
+#include "xpm/redo.xpm"
+#include "xpm/undoS.xpm"
+#include "xpm/redoS.xpm"
+#include "xpm/editcutS.xpm"
+#include "xpm/editcopyS.xpm"
+#include "xpm/editpasteS.xpm"
+#include "xpm/editmute.xpm"
+#include "xpm/editmuteS.xpm"
+#include "xpm/editpastecloneS.xpm"
+#include "xpm/editpaste2trackS.xpm"
+#include "xpm/editpasteclone2trackS.xpm"
+
+/* Not used - Orcan
+#include "xpm/editcut.xpm"
+#include "xpm/editcopy.xpm"
+#include "xpm/editpaste.xpm"
+#include "xpm/editpasteclone.xpm"
+#include "xpm/editpaste2track.xpm"
+#include "xpm/editpasteclone2track.xpm"
+*/
+#include "xpm/speaker.xpm"
+#include "xpm/buttondown.xpm"
+#include "xpm/configure.xpm"
+#include "xpm/panic.xpm"
+
+
+// next two lines will vanish soon
+#include "xpm/solobutton.xpm"
+#include "xpm/newmutebutton.xpm"
+#include "xpm/exit.xpm"
+#include "xpm/exit1.xpm"
+
+#include "xpm/redled.xpm"
+#include "xpm/darkredled.xpm"
+#include "xpm/greendot.xpm"
+//#include "xpm/darkgreendot.xpm"
+#include "xpm/bluedot.xpm"
+#include "xpm/graydot.xpm"
+#include "xpm/off.xpm"
+#include "xpm/blacksquare.xpm"
+#include "xpm/blacksqcheck.xpm"
+
+#include "xpm/mastertrackS.xpm"
+#include "xpm/localoffS.xpm"
+#include "xpm/miditransformS.xpm"
+#include "xpm/midi_plugS.xpm"
+#include "xpm/miditransposeS.xpm"
+#include "xpm/mixerS.xpm"
+#include "xpm/mustangS.xpm"
+#include "xpm/resetS.xpm"
+#include "xpm/track_add.xpm"
+#include "xpm/track_delete.xpm"
+#include "xpm/listS.xpm"
+#include "xpm/inputpluginS.xpm"
+#include "xpm/cliplistS.xpm"
+#include "xpm/mixeraudioS.xpm"
+#include "xpm/initS.xpm"
+
+#include "xpm/addtrack_addmiditrack.xpm"
+#include "xpm/addtrack_audiogroup.xpm"
+#include "xpm/addtrack_audioinput.xpm"
+#include "xpm/addtrack_audiooutput.xpm"
+#include "xpm/addtrack_auxsend.xpm"
+#include "xpm/addtrack_drumtrack.xpm"
+#include "xpm/addtrack_wavetrack.xpm"
+#include "xpm/edit_drumms.xpm"
+#include "xpm/edit_list.xpm"
+#include "xpm/edit_wave.xpm"
+#include "xpm/edit_mastertrack.xpm"
+#include "xpm/edit_pianoroll.xpm"
+#include "xpm/edit_score.xpm"
+#include "xpm/edit_track_add.xpm"
+#include "xpm/edit_track_del.xpm"
+#include "xpm/mastertrack_graphic.xpm"
+#include "xpm/mastertrack_list.xpm"
+#include "xpm/midi_transform.xpm"
+#include "xpm/midi_transpose.xpm"
+#include "xpm/select.xpm"
+#include "xpm/select_all.xpm"
+#include "xpm/select_all_parts_on_track.xpm"
+#include "xpm/select_deselect_all.xpm"
+#include "xpm/select_inside_loop.xpm"
+#include "xpm/select_invert_selection.xpm"
+#include "xpm/select_outside_loop.xpm"
+
+#include "xpm/mono.xpm"
+#include "xpm/stereo.xpm"
+#include "xpm/muse_icon.xpm"
+#include "xpm/about_muse.xpm"
+#include "xpm/muse_leftside_logo.xpm"
+
+#include "xpm/global.xpm"
+#include "xpm/project.xpm"
+#include "xpm/user.xpm"
+
+#include "xpm/sine.xpm"
+#include "xpm/saw.xpm"
+
+#if QT_VERSION >= 0x040600
+#define MPIXMAP(a,b) QPixmap(QIcon::fromTheme(b, QIcon(QPixmap(a))).pixmap(QPixmap(a).width(),QPixmap(a).height()))
+#define MICON(a,b) QIcon(QIcon::fromTheme(b, QIcon(QPixmap(a))))
+#else
+#define MPIXMAP(a,b) QPixmap(a)
+#define MICON(a,b) QIcon(QPixmap(a))
+#endif
+
+/* Quick API reference:
+ -------------------
+
+ QPixmap MPIXMAP(const char * const[] xpm, const QString & name)
+ QIcon MICON(const char * const[] xpm, const QString & name)
+
+ xpm: a valid XPM image data
+ name: filename of a theme icon, without the extension; or NULL
+*/
+
+QPixmap* track_commentIcon;
+QPixmap* mastertrackSIcon;
+QPixmap* localoffSIcon;
+QPixmap* miditransformSIcon;
+QPixmap* midi_plugSIcon;
+QPixmap* miditransposeSIcon;
+QPixmap* midiThruOnIcon;
+QPixmap* midiThruOffIcon;
+QPixmap* mixerSIcon;
+QPixmap* mustangSIcon;
+QPixmap* resetSIcon;
+QPixmap* track_addIcon;
+QPixmap* track_deleteIcon;
+QPixmap* listSIcon;
+QPixmap* inputpluginSIcon;
+QPixmap* cliplistSIcon;
+QPixmap* mixerAudioSIcon;
+QPixmap* initSIcon;
+
+QPixmap* exitIcon;
+QPixmap* exit1Icon;
+QPixmap* newmuteIcon;
+QPixmap* soloIcon;
+
+QPixmap* pointerIcon;
+QPixmap* pencilIcon;
+QPixmap* deleteIcon;
+QPixmap* punchinIcon;
+QPixmap* punchoutIcon;
+QPixmap* punchin1Icon;
+QPixmap* punchout1Icon;
+QPixmap* loopIcon;
+QPixmap* loop1Icon;
+QPixmap* playIcon;
+
+QPixmap* record1_Icon;
+QPixmap* record_on_Icon;
+QPixmap* record_off_Icon;
+QPixmap* recordIcon;
+QPixmap* stopIcon;
+QPixmap* startIcon;
+QPixmap* fforwardIcon;
+QPixmap* frewindIcon;
+QPixmap* dotIcon;
+QPixmap* dothIcon;
+QPixmap* dot1Icon;
+QPixmap* note1Icon;
+QPixmap* noteIcon;
+QPixmap* stickIcon;
+QPixmap* waveIcon;
+QPixmap* synthIcon;
+QPixmap* markIcon[3];
+QPixmap* cutIcon;
+QPixmap* steprecIcon;
+QPixmap* glueIcon;
+QPixmap* drawIcon;
+QPixmap* quantIcon;
+QPixmap* printIcon;
+QPixmap* printIconS;
+QPixmap* openIcon;
+QPixmap* saveIcon;
+QPixmap* saveasIcon;
+QPixmap* openIconS;
+QPixmap* saveIconS;
+QPixmap* saveasIconS;
+QPixmap* masterIcon;
+QPixmap* filenewIcon;
+QPixmap* filenewIconS;
+QPixmap* homeIcon;
+QPixmap* backIcon;
+QPixmap* forwardIcon;
+QPixmap* muteIcon;
+QPixmap* upIcon;
+QPixmap* downIcon;
+QPixmap* boldIcon;
+QPixmap* italicIcon;
+QPixmap* underlinedIcon;
+QPixmap* gvIcon;
+QPixmap* midiinIcon;
+QPixmap* sysexIcon;
+QPixmap* ctrlIcon;
+QPixmap* metaIcon;
+QPixmap* pitchIcon;
+QPixmap* cafterIcon;
+QPixmap* pafterIcon;
+QPixmap* flagIcon;
+QPixmap* flagIconS;
+QPixmap* flagIconSP;
+QPixmap* lockIcon;
+QPixmap* tocIcon;
+QPixmap* exitIconS;
+
+QPixmap* undoIcon;
+QPixmap* redoIcon;
+QPixmap* undoIconS;
+QPixmap* redoIconS;
+
+QPixmap* speakerIcon;
+QPixmap* buttondownIcon;
+QPixmap* configureIcon;
+
+QPixmap* blankRecord;
+QPixmap* preIcon;
+QPixmap* preIconOn;
+QPixmap* mixerIn;
+QPixmap* mixerOut;
+QPixmap* recEchoIconOn;
+QPixmap* recEchoIconOff;
+QPixmap* muteIconOn;
+QPixmap* muteIconOff;
+QPixmap* soloIconOn;
+QPixmap* soloIconOff;
+QPixmap* soloblksqIconOn;
+QPixmap* soloblksqIconOff;
+QIcon* soloIconSet1;
+QIcon* soloIconSet2;
+
+QPixmap* editmuteIcon;
+QPixmap* editmuteSIcon;
+QPixmap* panicIcon;
+
+QPixmap* garbagePCIcon;
+QPixmap* upPCIcon;
+QPixmap* downPCIcon;
+
+QIcon* pianoIconSet;
+QIcon* scoreIconSet;
+QIcon* editcutIconSet;
+QIcon* editmuteIconSet;
+QIcon* editcopyIconSet;
+QIcon* editpasteIconSet;
+QIcon* editpaste2TrackIconSet;
+QIcon* editpasteCloneIconSet;
+QIcon* editpasteClone2TrackIconSet;
+
+/* Not used - Orcan
+QIcon* pianoIcon;
+QIcon* editcutIcon;
+QIcon* editcopyIcon;
+QIcon* editpasteIcon;
+QIcon* editpasteCloneIcon;
+QIcon* editpaste2TrackIcon;
+QIcon* editpasteClone2TrackIcon;
+*/
+
+QPixmap* redLedIcon;
+QPixmap* darkRedLedIcon;
+QPixmap* greendotIcon;
+//QPixmap* darkgreendotIcon;
+QPixmap* graydotIcon;
+QPixmap* bluedotIcon;
+QPixmap* offIcon;
+QPixmap* blacksquareIcon;
+QPixmap* blacksqcheckIcon;
+
+QPixmap* addtrack_addmiditrackIcon;
+QPixmap* addtrack_audiogroupIcon;
+QPixmap* addtrack_audioinputIcon;
+QPixmap* addtrack_audiooutputIcon;
+QPixmap* addtrack_auxsendIcon;
+QPixmap* addtrack_drumtrackIcon;
+QPixmap* addtrack_wavetrackIcon;
+QPixmap* edit_drummsIcon;
+QPixmap* edit_listIcon;
+QPixmap* edit_waveIcon;
+QPixmap* edit_mastertrackIcon;
+QPixmap* edit_pianorollIcon;
+QPixmap* edit_scoreIcon;
+QPixmap* edit_track_addIcon;
+QPixmap* edit_track_delIcon;
+QPixmap* mastertrack_graphicIcon;
+QPixmap* mastertrack_listIcon;
+QPixmap* midi_transformIcon;
+QPixmap* midi_transposeIcon;
+QPixmap* selectIcon;
+QPixmap* select_allIcon;
+QPixmap* select_all_parts_on_trackIcon;
+QPixmap* select_deselect_allIcon;
+QPixmap* select_inside_loopIcon;
+QPixmap* select_invert_selectionIcon;
+QPixmap* select_outside_loopIcon;
+
+QPixmap* audio_bounce_to_fileIcon;
+QPixmap* audio_bounce_to_trackIcon;
+QPixmap* audio_restartaudioIcon;
+QPixmap* automation_clear_dataIcon;
+QPixmap* automation_mixerIcon;
+QPixmap* automation_take_snapshotIcon;
+QPixmap* edit_midiIcon;
+QPixmap* midi_edit_instrumentIcon;
+QPixmap* midi_init_instrIcon;
+QPixmap* midi_inputpluginsIcon;
+QPixmap* midi_inputplugins_midi_input_filterIcon;
+QPixmap* midi_inputplugins_midi_input_transformIcon;
+QPixmap* midi_inputplugins_random_rhythm_generatorIcon;
+QPixmap* midi_inputplugins_remote_controlIcon;
+QPixmap* midi_inputplugins_transposeIcon;
+QPixmap* midi_local_offIcon;
+QPixmap* midi_reset_instrIcon;
+QPixmap* settings_appearance_settingsIcon;
+QPixmap* settings_configureshortcutsIcon;
+QPixmap* settings_follow_songIcon;
+QPixmap* settings_globalsettingsIcon;
+QPixmap* settings_metronomeIcon;
+QPixmap* settings_midifileexportIcon;
+QPixmap* settings_midiport_softsynthsIcon;
+QPixmap* settings_midisyncIcon;
+QPixmap* view_bigtime_windowIcon;
+QPixmap* view_cliplistIcon;
+QPixmap* view_markerIcon;
+QPixmap* view_mixerIcon;
+QPixmap* view_transport_windowIcon;
+
+QPixmap* monoIcon;
+QPixmap* stereoIcon;
+QPixmap* museIcon;
+QPixmap* aboutMuseImage;
+QPixmap* museLeftSideLogo;
+
+QIcon* globalIcon;
+QIcon* projectIcon;
+QIcon* userIcon;
+
+
+QPixmap* sineIcon;
+QPixmap* sawIcon;
+
+//---------------------------------------------------------
+// initIcons
+//---------------------------------------------------------
+
+void initIcons()
+ {
+ track_commentIcon = new MPIXMAP(track_comment_xpm, NULL);
+ pointerIcon = new MPIXMAP(":/images/icons/select.png", NULL);
+ pencilIcon = new MPIXMAP(":/images/icons/pencil.png", NULL);
+ deleteIcon = new MPIXMAP(":/images/icons/eraser.png", "draw-eraser");
+ punchinIcon = new MPIXMAP(punchin_xpm, NULL);
+ punchoutIcon = new MPIXMAP(punchout_xpm, NULL);
+ punchin1Icon = new MPIXMAP(punchin1_xpm, NULL);
+ punchout1Icon = new MPIXMAP(punchout1_xpm, NULL);
+ loopIcon = new MPIXMAP(loop_xpm, NULL);
+ loop1Icon = new MPIXMAP(loop1_xpm, NULL);
+ playIcon = new MPIXMAP(":/images/icons/transport-play.png", "media-playback-start");
+
+ record1_Icon = new MPIXMAP(":/images/icons/mixer-record.png", NULL);
+ record_on_Icon = new MPIXMAP(":/images/icons/mixer-record_on.png", NULL);
+ record_off_Icon = new MPIXMAP(":/images/icons/mixer-record.png", NULL);
+ recordIcon = new MPIXMAP(":/images/icons/transport-record.png", "media-record");
+ stopIcon = new MPIXMAP(":/images/icons/transport-stop.png", "media-playback-stop");
+ startIcon = new MPIXMAP(":/images/icons/transport-rewind-end.png", "media-skip-backward");
+ fforwardIcon = new MPIXMAP(":/images/icons/transport-ffwd.png", "media-seek-forward");
+ frewindIcon = new MPIXMAP(":/images/icons/transport-rewind.png", "media-seek-backward");
+ dotIcon = new MPIXMAP(dot_xpm, "dialog-ok-apply");
+ dothIcon = new MPIXMAP(doth_xpm, "draw-circle");
+ dot1Icon = new MPIXMAP(dot1_xpm, NULL);
+ noteIcon = new MPIXMAP(note_xpm, NULL);
+ note1Icon = new MPIXMAP(note1_xpm, NULL);
+ stickIcon = new MPIXMAP(stick_xpm, NULL);
+ waveIcon = new MPIXMAP(wave_xpm, NULL);
+ synthIcon = new MPIXMAP(synth_xpm, NULL);
+ markIcon[0] = new MPIXMAP(cmark_xpm, NULL);
+ markIcon[1] = new MPIXMAP(lmark_xpm, NULL);
+ markIcon[2] = new MPIXMAP(rmark_xpm, NULL);
+ cutIcon = new MPIXMAP(cut_xpm, "edit-cut");
+ //steprecIcon = new MPIXMAP(steprec_xpm, NULL);
+ steprecIcon = new MPIXMAP(":/images/icons/step_by_step.png", NULL);
+ glueIcon = new MPIXMAP(glue_xpm, NULL);
+ //drawIcon = new MPIXMAP(draw_xpm, NULL);
+ drawIcon = new MPIXMAP(draw_xpm, NULL);
+ quantIcon = new MPIXMAP(quant_xpm, NULL);
+ saveIcon = new MPIXMAP(filesave_xpm, "document-save");
+ saveasIcon = new MPIXMAP(filesaveas_xpm, "document-save-as");
+ printIcon = new MPIXMAP(fileprint_xpm, "document-print");
+ openIcon = new MPIXMAP(fileopen_xpm, "document-open");
+ saveIconS = new MPIXMAP(filesaveS_xpm, "document-save");
+ saveasIconS = new MPIXMAP(filesaveasS_xpm, "document-save-as");
+ printIconS = new MPIXMAP(fileprintS_xpm, "document-print");
+ openIconS = new MPIXMAP(fileopenS_xpm, "document-open");
+ masterIcon = new MPIXMAP(master_xpm, "mixer-master");
+ filenewIcon = new MPIXMAP(filenew_xpm, "document-new");
+ filenewIconS = new MPIXMAP(filenewS_xpm, "document-new");
+ homeIcon = new MPIXMAP(home_xpm, "user-home");
+ backIcon = new MPIXMAP(back_xpm, "go-previous");
+ forwardIcon = new MPIXMAP(forward_xpm, "go-next");
+ muteIcon = new MPIXMAP(editmuteS_xpm, "audio-volume-muted");
+ upIcon = new MPIXMAP(up_xpm, "go-up");
+ downIcon = new MPIXMAP(down_xpm, "go-down");
+ boldIcon = new MPIXMAP(bold_xpm, "format-text-bold");
+ italicIcon = new MPIXMAP(italic_xpm, "format-text-italic");
+ underlinedIcon = new MPIXMAP(underlined_xpm, "format-text-underline");
+ gvIcon = new MPIXMAP(gv_xpm, NULL);
+ midiinIcon = new MPIXMAP(midiin_xpm, NULL);
+ sysexIcon = new MPIXMAP(sysex_xpm, NULL);
+ ctrlIcon = new MPIXMAP(ctrl_xpm, NULL);
+ metaIcon = new MPIXMAP(meta_xpm, NULL);
+ pitchIcon = new MPIXMAP(pitch_xpm, NULL);
+ cafterIcon = new MPIXMAP(cafter_xpm, NULL);
+ pafterIcon = new MPIXMAP(pafter_xpm, NULL);
+ flagIcon = new MPIXMAP(flag_xpm, NULL);
+ flagIconS = new MPIXMAP(flagS_xpm, NULL);
+ flagIconSP = new MPIXMAP(":/images/flagSP.png", NULL);//ProgramChange Flag
+ upPCIcon = new MPIXMAP(":/images/icons/up.png", NULL);//ProgramChange Flag
+ downPCIcon = new MPIXMAP(":/images/icons/down.png", NULL);//ProgramChange Flag
+ garbagePCIcon = new MPIXMAP(":/images/icons/garbage.png", NULL);//ProgramChange Flag
+ lockIcon = new MPIXMAP(lock_xpm, NULL);
+ tocIcon = new MPIXMAP(toc_xpm, NULL);
+ exitIconS = new MPIXMAP(exitS_xpm, "application-exit");
+
+ undoIcon = new MPIXMAP(undo_xpm, "edit-undo");
+ redoIcon = new MPIXMAP(redo_xpm, "edit-redo");
+ undoIconS = new MPIXMAP(undoS_xpm, "edit-undo");
+ redoIconS = new MPIXMAP(redoS_xpm, "edit-redo");
+
+ speakerIcon = new MPIXMAP(speaker_xpm, NULL);
+ buttondownIcon = new MPIXMAP(buttondown_xpm, "arrow-down");
+ configureIcon = new MPIXMAP(configure_xpm, NULL);
+
+ editmuteIcon = new MPIXMAP(editmute_xpm, NULL);
+ editmuteSIcon = new MPIXMAP(editmuteS_xpm, NULL);
+ panicIcon = new MPIXMAP(":/images/icons/transport-panic.png", NULL);
+
+ editcutIconSet = new MICON(editcutS_xpm, "edit-cut"); // ddskrjo
+ editcopyIconSet = new MICON(editcopyS_xpm, "edit-copy");
+ editpasteIconSet = new MICON(editpasteS_xpm, "edit-paste");
+ editmuteIconSet = new MICON(editmuteS_xpm, "audio-volume-muted");
+ editpaste2TrackIconSet = new MICON(editpaste2trackS_xpm, NULL);
+ editpasteCloneIconSet = new MICON(editpastecloneS_xpm, NULL);
+ editpasteClone2TrackIconSet = new MICON(editpasteclone2trackS_xpm, NULL); // ..
+ /* Not used - Orcan
+ pianoIcon = new MICON(piano_xpm, NULL);
+ editcutIcon = new MICON(editcut_xpm, "edit-cut");
+ editcopyIcon = new MICON(editcopy_xpm, "edit-copy");
+ editpasteIcon = new MICON(editpaste_xpm, "edit-paste");
+ editpasteCloneIcon = new MICON(editpasteclone_xpm, NULL);
+ editpaste2TrackIcon = new MICON(editpaste2track_xpm, NULL);
+ editpasteClone2TrackIcon = new MICON(editpasteclone2track_xpm, NULL);
+ */
+ exitIcon = new MPIXMAP(":/images/icons/mixer-exit.png", "application-exit");
+ exit1Icon = new MPIXMAP(":/images/icons/mixer-exit_on.png", "application-exit");
+
+ // 2 lines odd code
+ newmuteIcon = new MPIXMAP(newmutebutton_xpm, NULL);
+ soloIcon = new MPIXMAP(solobutton_xpm, NULL);
+
+ blankRecord = new MPIXMAP(":/images/icons/blank_record.png", NULL);
+ preIcon = new MPIXMAP(":/images/icons/mixer-pre.png", NULL);
+ preIconOn = new MPIXMAP(":/images/icons/mixer-pre_on.png", NULL);
+ mixerIn = new MPIXMAP(":/images/icons/mixer-in.png", NULL);
+ mixerOut = new MPIXMAP(":/images/icons/mixer-out.png", NULL);
+ recEchoIconOn = new MPIXMAP(":/images/icons/mixer-record.png", NULL);
+ recEchoIconOff = new MPIXMAP(":/images/icons/mixer-record.png", NULL);
+ muteIconOn = new MPIXMAP(":/images/icons/mixer-mute.png", NULL);
+ muteIconOff = new MPIXMAP(":/images/icons/mixer-mute_on.png", NULL);
+ soloIconOn = new MPIXMAP(":/images/icons/mixer-solo_on.png", NULL);
+ soloIconOff = new MPIXMAP(":/images/icons/mixer-solo.png", NULL);
+ soloblksqIconOn = new MPIXMAP(":/images/icons/mixer-solo_on.png", NULL);
+ soloblksqIconOff = new MPIXMAP(":/images/icons/mixer-solo.png", NULL);
+ soloIconSet1 = new QIcon();
+ soloIconSet2 = new QIcon();
+ soloIconSet1->addPixmap(*soloIconOn, QIcon::Normal, QIcon::On);
+ soloIconSet1->addPixmap(*soloIconOff, QIcon::Normal, QIcon::Off);
+ soloIconSet2->addPixmap(*soloblksqIconOn, QIcon::Normal, QIcon::On);
+ soloIconSet2->addPixmap(*soloblksqIconOff, QIcon::Normal, QIcon::Off);
+
+ redLedIcon = new MPIXMAP(redled_xpm, NULL);
+ darkRedLedIcon = new MPIXMAP(darkredled_xpm, NULL);
+ greendotIcon = new MPIXMAP(greendot_xpm, NULL);
+ //darkgreendotIcon = new MPIXMAP(darkgreendot_xpm, NULL);
+ bluedotIcon = new MPIXMAP(bluedot_xpm, NULL);
+ graydotIcon = new MPIXMAP(graydot_xpm, NULL);
+ offIcon = new MPIXMAP(off_xpm, NULL);
+ blacksquareIcon = new MPIXMAP(blacksquare_xpm, NULL);
+ blacksqcheckIcon = new MPIXMAP(blacksqcheck_xpm, NULL);
+
+ mastertrackSIcon = new MPIXMAP(mastertrackS_xpm, NULL);
+ localoffSIcon = new MPIXMAP(localoffS_xpm, NULL);
+ miditransformSIcon = new MPIXMAP(miditransformS_xpm, NULL);
+ midi_plugSIcon = new MPIXMAP(midi_plugS_xpm, NULL);
+ miditransposeSIcon = new MPIXMAP(miditransposeS_xpm, NULL);
+ midiThruOnIcon = new MPIXMAP(midi_thru_on3_xpm, NULL);
+ midiThruOffIcon = new MPIXMAP(midi_thru_off3_xpm, NULL);
+
+ mixerSIcon = new MPIXMAP(mixerS_xpm, NULL);
+ mustangSIcon = new MPIXMAP(mustangS_xpm, NULL);
+ resetSIcon = new MPIXMAP(resetS_xpm, NULL);
+ track_addIcon = new MPIXMAP(track_add_xpm, NULL);
+ track_deleteIcon = new MPIXMAP(track_delete_xpm, NULL);
+ listSIcon = new MPIXMAP(listS_xpm, NULL);
+ inputpluginSIcon = new MPIXMAP(inputpluginS_xpm, NULL);
+ cliplistSIcon = new MPIXMAP(cliplistS_xpm, NULL);
+ mixerAudioSIcon = new MPIXMAP(mixerAudioS_xpm, NULL);
+ initSIcon = new MPIXMAP(initS_xpm, NULL);
+
+ addtrack_addmiditrackIcon = new MPIXMAP(addtrack_addmiditrack_xpm, NULL);
+ addtrack_audiogroupIcon = new MPIXMAP(addtrack_audiogroup_xpm, NULL);
+ addtrack_audioinputIcon = new MPIXMAP(addtrack_audioinput_xpm, NULL);
+ addtrack_audiooutputIcon = new MPIXMAP(addtrack_audiooutput_xpm, NULL);
+ addtrack_auxsendIcon = new MPIXMAP(addtrack_auxsend_xpm, NULL);
+ addtrack_drumtrackIcon = new MPIXMAP(addtrack_drumtrack_xpm, NULL);
+ addtrack_wavetrackIcon = new MPIXMAP(addtrack_wavetrack_xpm, NULL);
+ edit_drummsIcon = new MPIXMAP(edit_drumms_xpm, NULL);
+ edit_listIcon = new MPIXMAP(edit_list_xpm, NULL);
+ edit_waveIcon = new MPIXMAP(edit_wave_xpm, NULL);
+ edit_mastertrackIcon = new MPIXMAP(edit_mastertrack_xpm, NULL);
+ edit_pianorollIcon = new MPIXMAP(edit_pianoroll_xpm, NULL);
+ edit_scoreIcon = new MPIXMAP(edit_score_xpm, NULL);
+ edit_track_addIcon = new MPIXMAP(edit_track_add_xpm, NULL);
+ edit_track_delIcon = new MPIXMAP(edit_track_del_xpm, NULL);
+ mastertrack_graphicIcon = new MPIXMAP(mastertrack_graphic_xpm, NULL);
+ mastertrack_listIcon = new MPIXMAP(mastertrack_list_xpm, NULL);
+ midi_transformIcon = new MPIXMAP(midi_transform_xpm, NULL);
+ midi_transposeIcon = new MPIXMAP(midi_transpose_xpm, NULL);
+ selectIcon = new MPIXMAP(select_xpm, NULL);
+ select_allIcon = new MPIXMAP(select_all_xpm, NULL);
+ select_all_parts_on_trackIcon = new MPIXMAP(select_all_parts_on_track_xpm, NULL);
+ select_deselect_allIcon = new MPIXMAP(select_deselect_all, NULL);
+ select_inside_loopIcon = new MPIXMAP(select_inside_loop_xpm, NULL);
+ select_invert_selectionIcon = new MPIXMAP(select_invert_selection, NULL);
+ select_outside_loopIcon = new MPIXMAP(select_outside_loop_xpm, NULL);
+ pianoIconSet = new MICON(edit_pianoroll_xpm, NULL); // ddskrjo
+
+ audio_bounce_to_fileIcon = new MPIXMAP(audio_bounce_to_file_xpm, NULL);
+ audio_bounce_to_trackIcon = new MPIXMAP(audio_bounce_to_track_xpm, NULL);
+ audio_restartaudioIcon = new MPIXMAP(audio_restartaudio_xpm, NULL);
+ automation_clear_dataIcon = new MPIXMAP(automation_clear_data_xpm, NULL);
+ automation_mixerIcon = new MPIXMAP(automation_mixer_xpm, NULL);
+ automation_take_snapshotIcon = new MPIXMAP(automation_take_snapshot_xpm, NULL);
+ edit_midiIcon = new MPIXMAP(edit_midi_xpm, NULL);
+ midi_edit_instrumentIcon = new MPIXMAP(midi_edit_instrument_xpm, NULL);
+ midi_init_instrIcon = new MPIXMAP(midi_init_instr_xpm, NULL);
+ midi_inputpluginsIcon = new MPIXMAP(midi_inputplugins_xpm, NULL);
+ midi_inputplugins_midi_input_filterIcon = new MPIXMAP(midi_inputplugins_midi_input_filter_xpm, NULL);
+ midi_inputplugins_midi_input_transformIcon = new MPIXMAP(midi_inputplugins_midi_input_transform_xpm, NULL);
+ midi_inputplugins_random_rhythm_generatorIcon = new MPIXMAP(midi_inputplugins_random_rhythm_generator_xpm, NULL);
+ midi_inputplugins_remote_controlIcon = new MPIXMAP(midi_inputplugins_remote_control_xpm, NULL);
+ midi_inputplugins_transposeIcon = new MPIXMAP(midi_inputplugins_transpose_xpm, NULL);
+ midi_local_offIcon = new MPIXMAP(midi_local_off_xpm, NULL);
+ midi_reset_instrIcon = new MPIXMAP(midi_reset_instr_xpm, NULL);
+ settings_appearance_settingsIcon = new MPIXMAP(settings_appearance_settings_xpm, NULL);
+ settings_configureshortcutsIcon = new MPIXMAP(settings_configureshortcuts_xpm, NULL);
+ settings_follow_songIcon = new MPIXMAP(settings_follow_song_xpm, NULL);
+ settings_globalsettingsIcon = new MPIXMAP(settings_globalsettings_xpm, NULL);
+ settings_metronomeIcon = new MPIXMAP(settings_metronome_xpm, NULL);
+ settings_midifileexportIcon = new MPIXMAP(settings_midifileexport_xpm, NULL);
+ settings_midiport_softsynthsIcon = new MPIXMAP(settings_midiport_softsynths_xpm, NULL);
+ settings_midisyncIcon = new MPIXMAP(settings_midisync_xpm, NULL);
+ view_bigtime_windowIcon = new MPIXMAP(view_bigtime_window_xpm, NULL);
+ view_cliplistIcon = new MPIXMAP(view_cliplist_xpm, NULL);
+ view_markerIcon = new MPIXMAP(view_marker_xpm, NULL);
+ view_mixerIcon = new MPIXMAP(view_mixer_xpm, NULL);
+ view_transport_windowIcon = new MPIXMAP(view_transport_window_xpm, NULL);
+
+ monoIcon = new MPIXMAP(":/images/icons/mixer-mono.png", NULL);
+ stereoIcon = new MPIXMAP(":/images/icons/mixer-stereo.png", NULL);
+
+ museIcon = new MPIXMAP(muse_icon_xpm, NULL);
+ aboutMuseImage = new MPIXMAP(about_muse_xpm, NULL);
+ museLeftSideLogo = new MPIXMAP(muse_leftside_logo_xpm, NULL);
+ globalIcon = new MICON(global_xpm, "folder");
+ userIcon = new MICON(user_xpm, "user-home");
+ projectIcon = new MICON(project_xpm, "folder-sound");
+
+ sineIcon = new MPIXMAP(sine_xpm, NULL);
+ sawIcon = new MPIXMAP(saw_xpm, NULL);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/icons.h b/attic/muse2-oom/muse2/muse/icons.h
new file mode 100644
index 00000000..2beda37e
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/icons.h
@@ -0,0 +1,250 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: icons.h,v 1.11.2.8 2009/11/14 03:37:48 terminator356 Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef ICONS_H
+#define ICONS_H
+
+class QPixmap;
+class QIcon;
+
+extern QPixmap* track_commentIcon;
+extern QPixmap* pointerIcon;
+extern QPixmap* pencilIcon;
+extern QPixmap* deleteIcon;
+extern QPixmap* punchinIcon;
+extern QPixmap* punchoutIcon;
+extern QPixmap* punchin1Icon;
+extern QPixmap* punchout1Icon;
+extern QPixmap* loopIcon;
+extern QPixmap* loop1Icon;
+extern QPixmap* playIcon;
+extern QPixmap* recordIcon;
+extern QPixmap* stopIcon;
+extern QPixmap* startIcon;
+extern QPixmap* fforwardIcon;
+extern QPixmap* frewindIcon;
+extern QPixmap* dotIcon;
+extern QPixmap* dothIcon;
+extern QPixmap* dot1Icon;
+extern QPixmap* noteIcon;
+extern QPixmap* note1Icon;
+extern QPixmap* stickIcon;
+extern QPixmap* waveIcon;
+extern QPixmap* synthIcon;
+extern QPixmap* markIcon[3];
+
+extern QPixmap* blankRecord;
+extern QPixmap* preIcon;
+extern QPixmap* preIconOn;
+extern QPixmap* mixerIn;
+extern QPixmap* mixerOut;
+extern QPixmap* recEchoIconOn;
+extern QPixmap* recEchoIconOff;
+extern QPixmap* muteIconOn;
+extern QPixmap* muteIconOff;
+extern QPixmap* soloIconOn;
+extern QPixmap* soloIconOff;
+
+extern QPixmap* cutIcon;
+extern QPixmap* steprecIcon;
+extern QPixmap* glueIcon;
+extern QPixmap* drawIcon;
+
+extern QPixmap* quantIcon;
+extern QPixmap* printIcon;
+extern QPixmap* printIconS;
+extern QPixmap* openIcon;
+extern QPixmap* saveIcon;
+extern QPixmap* saveasIcon;
+extern QPixmap* openIconS;
+extern QPixmap* saveIconS;
+extern QPixmap* saveasIconS;
+extern QPixmap* archiveIcon;
+extern QPixmap* findIcon;
+extern QPixmap* masterIcon;
+extern QPixmap* filenewIcon;
+extern QPixmap* filenewIconS;
+extern QPixmap* homeIcon;
+extern QPixmap* backIcon;
+extern QPixmap* forwardIcon;
+extern QPixmap* muteIcon;
+extern QPixmap* upIcon;
+extern QPixmap* downIcon;
+extern QPixmap* boldIcon;
+extern QPixmap* italicIcon;
+extern QPixmap* underlinedIcon;
+extern QPixmap* gvIcon;
+extern QPixmap* midiinIcon;
+extern QPixmap* sysexIcon;
+extern QPixmap* ctrlIcon;
+extern QPixmap* metaIcon;
+extern QPixmap* pitchIcon;
+extern QPixmap* cafterIcon;
+extern QPixmap* pafterIcon;
+extern QPixmap* flagIcon;
+extern QPixmap* flagIconS;
+extern QPixmap* flagIconSP;
+extern QPixmap* lockIcon;
+extern QPixmap* tocIcon;
+extern QPixmap* exitIconS;
+
+extern QPixmap* undoIcon;
+extern QPixmap* redoIcon;
+extern QPixmap* undoIconS;
+extern QPixmap* redoIconS;
+
+extern QPixmap* speakerIcon;
+extern QPixmap* buttondownIcon;
+extern QPixmap* configureIcon;
+
+extern QPixmap* editmuteIcon;
+extern QPixmap* editmuteSIcon;
+extern QPixmap* panicIcon;
+extern QPixmap* upPCIcon;
+extern QPixmap* downPCIcon;
+extern QPixmap* garbagePCIcon;
+
+extern QIcon* pianoIconSet;
+extern QIcon* scoreIconSet;
+extern QIcon* editcutIconSet;
+extern QIcon* editmuteIconSet;
+extern QIcon* editcopyIconSet;
+extern QIcon* editpasteIconSet;
+extern QIcon* editpaste2TrackIconSet;
+extern QIcon* editpasteCloneIconSet;
+extern QIcon* editpasteClone2TrackIconSet;
+
+/* Not used
+extern QIcon* pianoIcon;
+extern QIcon* editcutIcon;
+extern QIcon* editcopyIcon;
+extern QIcon* editpasteIcon;
+extern QIcon* editpasteCloneIcon;
+extern QIcon* editpaste2TrackIcon;
+extern QIcon* editpasteClone2TrackIcon;
+*/
+
+extern QPixmap* exitIcon;
+extern QPixmap* exit1Icon;
+extern QPixmap* record1_Icon;
+extern QPixmap* record_on_Icon;
+extern QPixmap* record_off_Icon;
+extern QPixmap* newmuteIcon;
+extern QPixmap* soloIcon;
+
+extern QPixmap* muteIconOn;
+extern QPixmap* muteIconOff;
+extern QPixmap* soloIconOn;
+extern QPixmap* soloIconOff;
+extern QPixmap* soloblksqIconOn;
+extern QPixmap* soloblksqIconOff;
+extern QIcon* soloIconSet1;
+extern QIcon* soloIconSet2;
+
+extern QPixmap* redLedIcon;
+extern QPixmap* darkRedLedIcon;
+extern QPixmap* greendotIcon;
+//extern QPixmap* darkgreendotIcon;
+extern QPixmap* graydotIcon;
+extern QPixmap* bluedotIcon;
+extern QPixmap* offIcon;
+extern QPixmap* blacksquareIcon;
+extern QPixmap* blacksqcheckIcon;
+
+extern QPixmap* mastertrackSIcon;
+extern QPixmap* localoffSIcon;
+extern QPixmap* miditransformSIcon;
+extern QPixmap* midi_plugSIcon;
+extern QPixmap* miditransposeSIcon;
+extern QPixmap* midiThruOnIcon;
+extern QPixmap* midiThruOffIcon;
+extern QPixmap* mixerSIcon;
+extern QPixmap* mustangSIcon;
+extern QPixmap* resetSIcon;
+extern QPixmap* track_addIcon;
+extern QPixmap* track_deleteIcon;
+extern QPixmap* listSIcon;
+extern QPixmap* inputpluginSIcon;
+extern QPixmap* cliplistSIcon;
+extern QPixmap* mixerAudioSIcon;
+extern QPixmap* initSIcon;
+
+extern QPixmap* addtrack_addmiditrackIcon;
+extern QPixmap* addtrack_audiogroupIcon;
+extern QPixmap* addtrack_audioinputIcon;
+extern QPixmap* addtrack_audiooutputIcon;
+extern QPixmap* addtrack_auxsendIcon;
+extern QPixmap* addtrack_drumtrackIcon;
+extern QPixmap* addtrack_wavetrackIcon;
+extern QPixmap* edit_drummsIcon;
+extern QPixmap* edit_listIcon;
+extern QPixmap* edit_waveIcon;
+extern QPixmap* edit_mastertrackIcon;
+extern QPixmap* edit_pianorollIcon;
+extern QPixmap* edit_scoreIcon;
+extern QPixmap* edit_track_addIcon;
+extern QPixmap* edit_track_delIcon;
+extern QPixmap* mastertrack_graphicIcon;
+extern QPixmap* mastertrack_listIcon;
+extern QPixmap* midi_transformIcon;
+extern QPixmap* midi_transposeIcon;
+extern QPixmap* selectIcon;
+extern QPixmap* select_allIcon;
+extern QPixmap* select_all_parts_on_trackIcon;
+extern QPixmap* select_deselect_allIcon;
+extern QPixmap* select_inside_loopIcon;
+extern QPixmap* select_invert_selectionIcon;
+extern QPixmap* select_outside_loopIcon;
+
+extern QPixmap* audio_bounce_to_fileIcon;
+extern QPixmap* audio_bounce_to_trackIcon;
+extern QPixmap* audio_restartaudioIcon;
+extern QPixmap* automation_clear_dataIcon;
+extern QPixmap* automation_mixerIcon;
+extern QPixmap* automation_take_snapshotIcon;
+extern QPixmap* edit_midiIcon;
+extern QPixmap* midi_edit_instrumentIcon;
+extern QPixmap* midi_init_instrIcon;
+extern QPixmap* midi_inputpluginsIcon;
+extern QPixmap* midi_inputplugins_midi_input_filterIcon;
+extern QPixmap* midi_inputplugins_midi_input_transformIcon;
+extern QPixmap* midi_inputplugins_random_rhythm_generatorIcon;
+extern QPixmap* midi_inputplugins_remote_controlIcon;
+extern QPixmap* midi_inputplugins_transposeIcon;
+extern QPixmap* midi_local_offIcon;
+extern QPixmap* midi_reset_instrIcon;
+extern QPixmap* settings_appearance_settingsIcon;
+extern QPixmap* settings_configureshortcutsIcon;
+extern QPixmap* settings_follow_songIcon;
+extern QPixmap* settings_globalsettingsIcon;
+extern QPixmap* settings_metronomeIcon;
+extern QPixmap* settings_midifileexportIcon;
+extern QPixmap* settings_midiport_softsynthsIcon;
+extern QPixmap* settings_midisyncIcon;
+extern QPixmap* view_bigtime_windowIcon;
+extern QPixmap* view_cliplistIcon;
+extern QPixmap* view_markerIcon;
+extern QPixmap* view_mixerIcon;
+extern QPixmap* view_transport_windowIcon;
+
+extern QPixmap* monoIcon;
+extern QPixmap* stereoIcon;
+
+extern QPixmap* museIcon;
+extern QPixmap* aboutMuseImage;
+extern QPixmap* museLeftSideLogo;
+
+extern QIcon* globalIcon;
+extern QIcon* projectIcon;
+extern QIcon* userIcon;
+
+extern QPixmap* sineIcon;
+extern QPixmap* sawIcon;
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/images/bottom_rack.png b/attic/muse2-oom/muse2/muse/images/bottom_rack.png
new file mode 100644
index 00000000..806d5dfa
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/bottom_rack.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/combo_down_arrow.png b/attic/muse2-oom/muse2/muse/images/combo_down_arrow.png
new file mode 100644
index 00000000..0574719d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/combo_down_arrow.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/down_arrow.png b/attic/muse2-oom/muse2/muse/images/down_arrow.png
new file mode 100644
index 00000000..85004aea
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/down_arrow.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/down_arrow_disabled.png b/attic/muse2-oom/muse2/muse/images/down_arrow_disabled.png
new file mode 100644
index 00000000..d9eefed4
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/down_arrow_disabled.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/flagSP.png b/attic/muse2-oom/muse2/muse/images/flagSP.png
new file mode 100644
index 00000000..691813db
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/flagSP.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/frame.png b/attic/muse2-oom/muse2/muse/images/frame.png
new file mode 100644
index 00000000..3d5d54a5
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/frame.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/frame_clipping.png b/attic/muse2-oom/muse2/muse/images/frame_clipping.png
new file mode 100644
index 00000000..d4be5e05
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/frame_clipping.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/add_tracks.png b/attic/muse2-oom/muse2/muse/images/icons/add_tracks.png
new file mode 100644
index 00000000..194d6056
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/add_tracks.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/blank_record.png b/attic/muse2-oom/muse2/muse/images/icons/blank_record.png
new file mode 100644
index 00000000..1fede66f
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/blank_record.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/delete_track.png b/attic/muse2-oom/muse2/muse/images/icons/delete_track.png
new file mode 100644
index 00000000..98c3cea8
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/delete_track.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/down.png b/attic/muse2-oom/muse2/muse/images/icons/down.png
new file mode 100644
index 00000000..232828ff
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/down.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/eraser.png b/attic/muse2-oom/muse2/muse/images/icons/eraser.png
new file mode 100644
index 00000000..42ca9ae3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/eraser.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/eventfilter.png b/attic/muse2-oom/muse2/muse/images/icons/eventfilter.png
new file mode 100644
index 00000000..2a23cf7c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/eventfilter.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/eventlist.png b/attic/muse2-oom/muse2/muse/images/icons/eventlist.png
new file mode 100644
index 00000000..2e797ac8
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/eventlist.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/garbage.png b/attic/muse2-oom/muse2/muse/images/icons/garbage.png
new file mode 100644
index 00000000..64eb300a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/garbage.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/manage-midi-devices.png b/attic/muse2-oom/muse2/muse/images/icons/manage-midi-devices.png
new file mode 100644
index 00000000..3d5a2a51
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/manage-midi-devices.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/matrix-percussion.png b/attic/muse2-oom/muse2/muse/images/icons/matrix-percussion.png
new file mode 100644
index 00000000..c61d71b5
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/matrix-percussion.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/matrix.png b/attic/muse2-oom/muse2/muse/images/icons/matrix.png
new file mode 100644
index 00000000..79505be5
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/matrix.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/mixer-exit.png b/attic/muse2-oom/muse2/muse/images/icons/mixer-exit.png
new file mode 100644
index 00000000..77816fb7
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/mixer-exit.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/mixer-exit_on.png b/attic/muse2-oom/muse2/muse/images/icons/mixer-exit_on.png
new file mode 100644
index 00000000..1796d72e
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/mixer-exit_on.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/mixer-in.png b/attic/muse2-oom/muse2/muse/images/icons/mixer-in.png
new file mode 100644
index 00000000..5e244200
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/mixer-in.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/mixer-mono.png b/attic/muse2-oom/muse2/muse/images/icons/mixer-mono.png
new file mode 100644
index 00000000..153c6765
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/mixer-mono.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/mixer-mute.png b/attic/muse2-oom/muse2/muse/images/icons/mixer-mute.png
new file mode 100644
index 00000000..4a9ef31c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/mixer-mute.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/mixer-mute_on.png b/attic/muse2-oom/muse2/muse/images/icons/mixer-mute_on.png
new file mode 100644
index 00000000..9b0a34f2
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/mixer-mute_on.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/mixer-out.png b/attic/muse2-oom/muse2/muse/images/icons/mixer-out.png
new file mode 100644
index 00000000..335aeb39
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/mixer-out.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/mixer-pre.png b/attic/muse2-oom/muse2/muse/images/icons/mixer-pre.png
new file mode 100644
index 00000000..d5b9038b
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/mixer-pre.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/mixer-pre_on.png b/attic/muse2-oom/muse2/muse/images/icons/mixer-pre_on.png
new file mode 100644
index 00000000..b627ee02
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/mixer-pre_on.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/mixer-record.png b/attic/muse2-oom/muse2/muse/images/icons/mixer-record.png
new file mode 100644
index 00000000..30ba3319
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/mixer-record.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/mixer-record_on.png b/attic/muse2-oom/muse2/muse/images/icons/mixer-record_on.png
new file mode 100644
index 00000000..4c07b25b
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/mixer-record_on.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/mixer-solo.png b/attic/muse2-oom/muse2/muse/images/icons/mixer-solo.png
new file mode 100644
index 00000000..6b506648
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/mixer-solo.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/mixer-solo_on.png b/attic/muse2-oom/muse2/muse/images/icons/mixer-solo_on.png
new file mode 100644
index 00000000..2140c7b1
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/mixer-solo_on.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/mixer-stereo.png b/attic/muse2-oom/muse2/muse/images/icons/mixer-stereo.png
new file mode 100644
index 00000000..4f82a6dd
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/mixer-stereo.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/move.png b/attic/muse2-oom/muse2/muse/images/icons/move.png
new file mode 100644
index 00000000..aa745419
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/move.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/move_track_down.png b/attic/muse2-oom/muse2/muse/images/icons/move_track_down.png
new file mode 100644
index 00000000..beb8ce8a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/move_track_down.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/move_track_up.png b/attic/muse2-oom/muse2/muse/images/icons/move_track_up.png
new file mode 100644
index 00000000..39ceaa78
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/move_track_up.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/mute-all.png b/attic/muse2-oom/muse2/muse/images/icons/mute-all.png
new file mode 100644
index 00000000..23293a7a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/mute-all.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/pencil.png b/attic/muse2-oom/muse2/muse/images/icons/pencil.png
new file mode 100644
index 00000000..22735ea0
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/pencil.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/programchange.png b/attic/muse2-oom/muse2/muse/images/icons/programchange.png
new file mode 100755
index 00000000..30ecfee4
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/programchange.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/quantize.png b/attic/muse2-oom/muse2/muse/images/icons/quantize.png
new file mode 100644
index 00000000..969bc9e2
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/quantize.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/resize.png b/attic/muse2-oom/muse2/muse/images/icons/resize.png
new file mode 100644
index 00000000..50f68da1
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/resize.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/select.png b/attic/muse2-oom/muse2/muse/images/icons/select.png
new file mode 100644
index 00000000..35e4369e
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/select.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/split.png b/attic/muse2-oom/muse2/muse/images/icons/split.png
new file mode 100644
index 00000000..1e474965
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/split.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/step_by_step.png b/attic/muse2-oom/muse2/muse/images/icons/step_by_step.png
new file mode 100644
index 00000000..228c80dc
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/step_by_step.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/transport-cursor-to-pointer.png b/attic/muse2-oom/muse2/muse/images/icons/transport-cursor-to-pointer.png
new file mode 100644
index 00000000..730bb15d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/transport-cursor-to-pointer.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/transport-ffwd-end.png b/attic/muse2-oom/muse2/muse/images/icons/transport-ffwd-end.png
new file mode 100644
index 00000000..99cf80c3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/transport-ffwd-end.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/transport-ffwd.png b/attic/muse2-oom/muse2/muse/images/icons/transport-ffwd.png
new file mode 100644
index 00000000..130a2736
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/transport-ffwd.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/transport-panic.png b/attic/muse2-oom/muse2/muse/images/icons/transport-panic.png
new file mode 100644
index 00000000..a9545d26
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/transport-panic.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/transport-play.png b/attic/muse2-oom/muse2/muse/images/icons/transport-play.png
new file mode 100644
index 00000000..336d7cbe
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/transport-play.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/transport-pointer-to-cursor.png b/attic/muse2-oom/muse2/muse/images/icons/transport-pointer-to-cursor.png
new file mode 100644
index 00000000..d87e71ea
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/transport-pointer-to-cursor.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/transport-record.png b/attic/muse2-oom/muse2/muse/images/icons/transport-record.png
new file mode 100644
index 00000000..86f74992
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/transport-record.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/transport-rewind-end.png b/attic/muse2-oom/muse2/muse/images/icons/transport-rewind-end.png
new file mode 100644
index 00000000..9fa364b6
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/transport-rewind-end.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/transport-rewind.png b/attic/muse2-oom/muse2/muse/images/icons/transport-rewind.png
new file mode 100644
index 00000000..ef33fc5e
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/transport-rewind.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/transport-solo.png b/attic/muse2-oom/muse2/muse/images/icons/transport-solo.png
new file mode 100644
index 00000000..56909b07
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/transport-solo.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/transport-stop.png b/attic/muse2-oom/muse2/muse/images/icons/transport-stop.png
new file mode 100644
index 00000000..f2716a4a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/transport-stop.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/transport-tracking.png b/attic/muse2-oom/muse2/muse/images/icons/transport-tracking.png
new file mode 100644
index 00000000..c9f5b77a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/transport-tracking.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/un-mute-all.png b/attic/muse2-oom/muse2/muse/images/icons/un-mute-all.png
new file mode 100644
index 00000000..23293a7a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/un-mute-all.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/up.png b/attic/muse2-oom/muse2/muse/images/icons/up.png
new file mode 100644
index 00000000..8178a6b6
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/up.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/icons/velocity.png b/attic/muse2-oom/muse2/muse/images/icons/velocity.png
new file mode 100644
index 00000000..9cd439cb
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/icons/velocity.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/knob.png b/attic/muse2-oom/muse2/muse/images/knob.png
new file mode 100644
index 00000000..a6549113
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/knob.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/knob_aux.png b/attic/muse2-oom/muse2/muse/images/knob_aux.png
new file mode 100644
index 00000000..a93cc306
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/knob_aux.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/slider_thumb.png b/attic/muse2-oom/muse2/muse/images/slider_thumb.png
new file mode 100644
index 00000000..7786fed9
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/slider_thumb.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/slider_thumb.xcf b/attic/muse2-oom/muse2/muse/images/slider_thumb.xcf
new file mode 100644
index 00000000..24036e38
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/slider_thumb.xcf
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/slider_thumb_h.png b/attic/muse2-oom/muse2/muse/images/slider_thumb_h.png
new file mode 100644
index 00000000..7642af9f
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/slider_thumb_h.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/slider_thumb_h.xcf b/attic/muse2-oom/muse2/muse/images/slider_thumb_h.xcf
new file mode 100644
index 00000000..7cd5f53a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/slider_thumb_h.xcf
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/spindown.png b/attic/muse2-oom/muse2/muse/images/spindown.png
new file mode 100644
index 00000000..7ff3c649
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/spindown.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/spindown_hover.png b/attic/muse2-oom/muse2/muse/images/spindown_hover.png
new file mode 100644
index 00000000..1486c4df
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/spindown_hover.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/spindown_off.png b/attic/muse2-oom/muse2/muse/images/spindown_off.png
new file mode 100644
index 00000000..a90ab3f0
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/spindown_off.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/spindown_pressed.png b/attic/muse2-oom/muse2/muse/images/spindown_pressed.png
new file mode 100644
index 00000000..f6271cbd
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/spindown_pressed.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/spinup.png b/attic/muse2-oom/muse2/muse/images/spinup.png
new file mode 100644
index 00000000..1069dd00
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/spinup.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/spinup.png.1 b/attic/muse2-oom/muse2/muse/images/spinup.png.1
new file mode 100644
index 00000000..1069dd00
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/spinup.png.1
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/spinup_hover.png b/attic/muse2-oom/muse2/muse/images/spinup_hover.png
new file mode 100644
index 00000000..884c8d77
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/spinup_hover.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/spinup_off.png b/attic/muse2-oom/muse2/muse/images/spinup_off.png
new file mode 100644
index 00000000..02dad1fb
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/spinup_off.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/spinup_pressed.png b/attic/muse2-oom/muse2/muse/images/spinup_pressed.png
new file mode 100644
index 00000000..b1843e2a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/spinup_pressed.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/toolbar_handle.png b/attic/muse2-oom/muse2/muse/images/toolbar_handle.png
new file mode 100644
index 00000000..90c063a5
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/toolbar_handle.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/top_rack.png b/attic/muse2-oom/muse2/muse/images/top_rack.png
new file mode 100644
index 00000000..208855f5
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/top_rack.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/up_arrow.png b/attic/muse2-oom/muse2/muse/images/up_arrow.png
new file mode 100644
index 00000000..e7f7ddb3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/up_arrow.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/images/up_arrow_disabled.png b/attic/muse2-oom/muse2/muse/images/up_arrow_disabled.png
new file mode 100644
index 00000000..4d2c2777
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/images/up_arrow_disabled.png
Binary files differ
diff --git a/attic/muse2-oom/muse2/muse/importmidi.cpp b/attic/muse2-oom/muse2/muse/importmidi.cpp
new file mode 100644
index 00000000..6917a0fd
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/importmidi.cpp
@@ -0,0 +1,614 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: importmidi.cpp,v 1.26.2.10 2009/11/05 03:14:35 terminator356 Exp $
+//
+// (C) Copyright 1999-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <assert.h>
+#include <errno.h>
+#include <values.h>
+
+#include <QMessageBox>
+
+#include "app.h"
+#include "song.h"
+#include "globals.h"
+#include "filedialog.h"
+#include "midi.h"
+#include "midifile.h"
+#include "midiport.h"
+#include "transport.h"
+#include "arranger.h"
+//#include "arranger/arranger.h" // p4.0.2
+#include "mpevent.h"
+#include "event.h"
+#include "midictrl.h"
+#include "instruments/minstrument.h"
+#include "drummap.h"
+//#include "midiedit/drummap.h" // p4.0.2
+#include "xml.h"
+#include "audio.h"
+#include "gconfig.h"
+
+//---------------------------------------------------------
+// importMidi
+//---------------------------------------------------------
+
+void MusE::importMidi()
+ {
+ QString empty("");
+ importMidi(empty);
+ }
+
+void MusE::importMidi(const QString &file)
+ {
+ QString fn;
+ if (file.isEmpty()) {
+ fn = getOpenFileName(lastMidiPath, midi_file_pattern, this,
+ tr("MusE: Import Midi"), 0);
+ if (fn.isEmpty())
+ return;
+ lastMidiPath = fn;
+ }
+ else
+ fn = file;
+
+ int n = QMessageBox::question(this, appName,
+ tr("Add midi file to current project?\n"),
+ tr("&Add to Project"),
+ tr("&Replace"),
+ tr("&Abort"), 0, 2);
+
+ switch (n) {
+ case 0:
+ importMidi(fn, true);
+ song->update();
+ break;
+ case 1:
+ loadProjectFile(fn, false, false); // replace
+ break;
+ default:
+ return;
+ }
+ }
+
+//---------------------------------------------------------
+// importMidi
+// return true on error
+//---------------------------------------------------------
+
+bool MusE::importMidi(const QString name, bool merge)
+ {
+ bool popenFlag;
+ FILE* fp = fileOpen(this, name, QString(".mid"), "r", popenFlag);
+ if (fp == 0)
+ return true;
+ MidiFile mf(fp);
+ bool rv = mf.read();
+ popenFlag ? pclose(fp) : fclose(fp);
+ if (rv) {
+ QString s(tr("reading midifile\n "));
+ s += name;
+ s += tr("\nfailed: ");
+ s += mf.error();
+ QMessageBox::critical(this, QString("MusE"), s);
+ return rv;
+ }
+ //
+ // evaluate song Type (GM, XG, GS, unknown)
+ //
+ MType t = song->mtype();
+ if (!merge) {
+ t = mf.mtype();
+ song->setMType(t);
+ }
+ MidiInstrument* instr = 0;
+ for (iMidiInstrument i = midiInstruments.begin(); i != midiInstruments.end(); ++i) {
+ MidiInstrument* mi = *i;
+ if ((mi->iname() == "GM" && ((t == MT_UNKNOWN) || (t == MT_GM)))
+ || ((mi->iname() == "GS") && (t == MT_GS))
+ || ((mi->iname() == "XG") && (t == MT_XG))) {
+ instr = mi;
+ break;
+ }
+ }
+ if (instr == 0) {
+ // the standard instrument files (GM, GS, XG) must be present
+ printf("no instrument, type %d\n", t);
+ abort();
+ }
+
+ MidiFileTrackList* etl = mf.trackList();
+ int division = mf.division();
+
+ //
+ // create MidiTrack and copy events to ->events()
+ // - combine note on/off events
+ // - calculate tick value for internal resolution
+ //
+ for (iMidiFileTrack t = etl->begin(); t != etl->end(); ++t) {
+ MPEventList* el = &((*t)->events);
+ if (el->empty())
+ continue;
+ //
+ // if we split the track, SYSEX and META events go into
+ // the first target track
+
+ bool first = true;
+ // somewhat silly and slooow:
+ for (int port = 0; port < MIDI_PORTS; ++port) {
+ for (int channel = 0; channel < MIDI_CHANNELS; ++channel) {
+ //
+ // check if there are any events for port/channel in track:
+ //
+ iMPEvent i;
+ for (i = el->begin(); i != el->end(); ++i) {
+ MidiPlayEvent ev = *i;
+ if (ev.type() != ME_SYSEX && ev.type() != ME_META
+ && ev.channel() == channel && ev.port() == port)
+ break;
+ }
+ if (i == el->end())
+ continue;
+ MidiTrack* track = new MidiTrack();
+ if ((*t)->isDrumTrack)
+ {
+ track->setType(Track::DRUM);
+ }
+
+ track->setOutChannel(channel);
+ track->setOutPort(port);
+
+ MidiPort* mport = &midiPorts[track->outPort()];
+ // this overwrites any instrument set for this port:
+ mport->setInstrument(instr);
+
+ EventList* mel = track->events();
+ //buildMidiEventList(mel, el, track, division, first);
+ // Don't do loops.
+ buildMidiEventList(mel, el, track, division, first, false);
+ first = false;
+
+ // Removed by T356. Handled by addPortCtrlEvents() below.
+ //for (iEvent i = mel->begin(); i != mel->end(); ++i) {
+ // Event event = i->second;
+ // if (event.type() == Controller) {
+ // importController(channel, mport, event.dataA());
+ // midiPorts[track->outPort()].setCtrl(channel, event.tick(), event.dataA(), event.dataB());
+ // }
+ // }
+
+ // Comment Added by T356.
+ // Hmm. buildMidiEventList already takes care of this.
+ // But it seems to work. How? Must test.
+ if (channel == 9 && song->mtype() != MT_UNKNOWN) {
+ track->setType(Track::DRUM);
+ //
+ // remap drum pitch with drumInmap
+ //
+ EventList* tevents = track->events();
+ for (iEvent i = tevents->begin(); i != tevents->end(); ++i) {
+ Event ev = i->second;
+ if (ev.isNote()) {
+ int pitch = drumInmap[ev.pitch()];
+ ev.setPitch(pitch);
+ }
+ else
+ if(ev.type() == Controller)
+ {
+ int ctl = ev.dataA();
+ MidiController *mc = mport->drumController(ctl);
+ if(mc)
+ ev.setA((ctl & ~0xff) | drumInmap[ctl & 0x7f]);
+ }
+ }
+ }
+
+ processTrack(track);
+
+ // Added by T356. Send all controller values to the port's controller value list.
+ // No, done in song->insertTrack2() now.
+ //track->addPortCtrlEvents();
+
+ song->insertTrack0(track, -1);
+ }
+ }
+ if (first) {
+ //
+ // track does only contain non-channel messages
+ // (SYSEX or META)
+ //
+ MidiTrack* track = new MidiTrack();
+ track->setOutChannel(0);
+ track->setOutPort(0);
+ EventList* mel = track->events();
+ //buildMidiEventList(mel, el, track, division, true);
+ // Do SysexMeta. Don't do loops.
+ buildMidiEventList(mel, el, track, division, true, false);
+ processTrack(track);
+ song->insertTrack0(track, -1);
+ }
+ }
+
+ if (!merge) {
+ TrackList* tl = song->tracks();
+ if (!tl->empty()) {
+ Track* track = tl->front();
+ track->setSelected(true);
+ }
+ song->initLen();
+
+ int z, n;
+ ///sigmap.timesig(0, z, n);
+ AL::sigmap.timesig(0, z, n);
+
+ int tempo = tempomap.tempo(0);
+ transport->setTimesig(z, n);
+ transport->setTempo(tempo);
+
+ bool masterF = !tempomap.empty();
+ song->setMasterFlag(masterF);
+ transport->setMasterFlag(masterF);
+
+ song->updatePos();
+
+ arranger->reset();
+ ///arranger->setMode(int(song->mtype())); // p4.0.7 Tim
+ }
+ else {
+ song->initLen();
+ }
+
+ return false;
+ }
+
+//---------------------------------------------------------
+// processTrack
+// divide events into parts
+//---------------------------------------------------------
+
+void MusE::processTrack(MidiTrack* track)
+ {
+ EventList* tevents = track->events();
+ if (tevents->empty())
+ return;
+
+ //---------------------------------------------------
+ // Parts ermitteln
+ // die Midi-Spuren werden in Parts aufgebrochen;
+ // ein neuer Part wird bei einer LÃÂŊÂÂŋÃ‚Â―cke von einem
+ // Takt gebildet; die LÃÂŊÂÂŋÃ‚Â―nge wird jeweils auf
+ // Takte aufgerundet und aligned
+ //---------------------------------------------------
+
+ PartList* pl = track->parts();
+
+ int lastTick = 0;
+ for (iEvent i = tevents->begin(); i != tevents->end(); ++i) {
+ Event event = i->second;
+ int epos = event.tick() + event.lenTick();
+ if (epos > lastTick)
+ lastTick = epos;
+ }
+
+ QString partname = track->name();
+ int len = song->roundUpBar(lastTick+1);
+
+ // p3.3.27
+ if(config.importMidiSplitParts)
+ {
+
+ int bar2, beat;
+ unsigned tick;
+ ///sigmap.tickValues(len, &bar2, &beat, &tick);
+ AL::sigmap.tickValues(len, &bar2, &beat, &tick);
+
+ int lastOff = 0;
+ int st = -1; // start tick current part
+ int x1 = 0; // start tick current measure
+ int x2 = 0; // end tick current measure
+
+ for (int bar = 0; bar < bar2; ++bar, x1 = x2) {
+ ///x2 = sigmap.bar2tick(bar+1, 0, 0);
+ x2 = AL::sigmap.bar2tick(bar+1, 0, 0);
+ if (lastOff > x2) {
+ // this measure is busy!
+ continue;
+ }
+ iEvent i1 = tevents->lower_bound(x1);
+ iEvent i2 = tevents->lower_bound(x2);
+
+ if (i1 == i2) { // empty?
+ if (st != -1) {
+ MidiPart* part = new MidiPart(track);
+ part->setTick(st);
+ part->setLenTick(x1-st);
+ // printf("new part %d len: %d\n", st, x1-st);
+ part->setName(partname);
+ pl->add(part);
+ st = -1;
+ }
+ }
+ else {
+ if (st == -1)
+ st = x1; // begin new part
+ //HACK:
+ //lastOff:
+ for (iEvent i = i1; i != i2; ++i) {
+ Event event = i->second;
+ if (event.type() == Note) {
+ int off = event.tick() + event.lenTick();
+ if (off > lastOff)
+ lastOff = off;
+ }
+ }
+ }
+ }
+ if (st != -1) {
+ MidiPart* part = new MidiPart(track);
+ part->setTick(st);
+ // printf("new part %d len: %d\n", st, x2-st);
+ part->setLenTick(x2-st);
+ part->setName(partname);
+ pl->add(part);
+ }
+ }
+ else
+ {
+ // Just one long part...
+ MidiPart* part = new MidiPart(track);
+ //part->setTick(st);
+ part->setTick(0);
+ part->setLenTick(len);
+ part->setName(partname);
+ pl->add(part);
+ }
+
+ //-------------------------------------------------------------
+ // assign events to parts
+ //-------------------------------------------------------------
+
+ for (iPart p = pl->begin(); p != pl->end(); ++p) {
+ MidiPart* part = (MidiPart*)(p->second);
+ int stick = part->tick();
+ int etick = part->tick() + part->lenTick();
+ iEvent r1 = tevents->lower_bound(stick);
+ iEvent r2 = tevents->lower_bound(etick);
+ int startTick = part->tick();
+
+ EventList* el = part->events();
+ for (iEvent i = r1; i != r2; ++i) {
+ Event ev = i->second;
+ int ntick = ev.tick() - startTick;
+ ev.setTick(ntick);
+ el->add(ev);
+ }
+ tevents->erase(r1, r2);
+ }
+
+ if (tevents->size())
+ printf("-----------events left: %zd\n", tevents->size());
+ for (iEvent i = tevents->begin(); i != tevents->end(); ++i) {
+ printf("%d===\n", i->first);
+ i->second.dump();
+ }
+ // all events should be processed:
+ assert(tevents->empty());
+ }
+
+//---------------------------------------------------------
+// importController
+//---------------------------------------------------------
+
+void MusE::importController(int channel, MidiPort* mport, int n)
+ {
+ MidiInstrument* instr = mport->instrument();
+ MidiCtrlValListList* vll = mport->controller();
+ iMidiCtrlValList i = vll->find(channel, n);
+ if (i != vll->end())
+ return; // controller does already exist
+ MidiController* ctrl = 0;
+ MidiControllerList* mcl = instr->controller();
+// printf("import Ctrl\n");
+ for (iMidiController i = mcl->begin(); i != mcl->end(); ++i) {
+ MidiController* mc = i->second;
+ int cn = mc->num();
+// printf(" %x %x\n", n, cn);
+ if (cn == n) {
+ ctrl = mc;
+ break;
+ }
+ // wildcard?
+ if (((cn & 0xff) == 0xff) && ((cn & ~0xff) == (n & ~0xff))) {
+ ctrl = i->second;
+ break;
+ }
+ }
+ if (ctrl == 0) {
+ printf("controller 0x%x not defined for instrument %s, channel %d\n",
+ n, instr->iname().toLatin1().constData(), channel);
+// TODO: register default Controller
+// MidiController* MidiPort::midiController(int num) const
+ }
+ MidiCtrlValList* newValList = new MidiCtrlValList(n);
+ vll->add(channel, newValList);
+ }
+
+
+//---------------------------------------------------------
+// importPart
+//---------------------------------------------------------
+void MusE::importPart()
+ {
+ unsigned curPos = song->cpos();
+ TrackList* tracks = song->tracks();
+ Track* track = 0;
+ // Get first selected track:
+ for (iTrack i = tracks->begin(); i != tracks->end(); i++) {
+ Track* t = *i;
+ if (t->selected()) {
+ // Changed by T356. Support mixed .mpt files.
+ //if (t->isMidiTrack()) {
+ if (t->isMidiTrack() || t->type() == Track::WAVE) {
+ track = t;
+ break;
+ }
+ else {
+ //QMessageBox::warning(this, QString("MusE"), tr("Import part is only valid for midi tracks!"));
+ QMessageBox::warning(this, QString("MusE"), tr("Import part is only valid for midi and wave tracks!"));
+ return;
+ }
+ }
+ }
+
+ if (track) {
+ bool loadAll;
+ QString filename = getOpenFileName(QString(""), part_file_pattern, this, tr("MusE: load part"), &loadAll);
+ if (!filename.isEmpty()){
+ // Make a backup of the current clone list, to retain any 'copy' items,
+ // so that pasting works properly after.
+ CloneList copyCloneList = cloneList;
+ // Clear the clone list to prevent any dangerous associations with
+ // current non-original parts.
+ cloneList.clear();
+
+ importPartToTrack(filename, curPos, track);
+
+ // Restore backup of the clone list, to retain any 'copy' items,
+ // so that pasting works properly after.
+ cloneList.clear();
+ cloneList = copyCloneList;
+ }
+ }
+ else {
+ QMessageBox::warning(this, QString("MusE"), tr("No track selected for import"));
+ }
+ }
+
+//---------------------------------------------------------
+// importPartToTrack
+//---------------------------------------------------------
+void MusE::importPartToTrack(QString& filename, unsigned tick, Track* track)
+{
+ // Changed by T356
+ /*
+ bool popenFlag = false;
+ FILE* fp = fileOpen(this, filename, ".mpt", "r", popenFlag, false, false);
+
+ if(fp)
+ {
+ MidiPart* importedPart = new MidiPart((MidiTrack*)track);
+ Xml tmpXml = Xml(fp);
+
+ Xml::Token token = tmpXml.parse();
+ const QString& tag = tmpXml.s1();
+ if (token == Xml::TagStart && tag == "part")
+ {
+ // Make a backup of the current clone list, to retain any 'copy' items,
+ // so that pasting works properly after.
+ CloneList copyCloneList = cloneList;
+ // Clear the clone list to prevent any dangerous associations with
+ // current non-original parts.
+ cloneList.clear();
+
+ importedPart->read(tmpXml);
+ importedPart->setTick(tick);
+
+ // Restore backup of the clone list, to retain any 'copy' items,
+ // so that pasting works properly after.
+ cloneList.clear();
+ cloneList = copyCloneList;
+
+ audio->msgAddPart(importedPart);
+ }
+ else
+ {
+ printf("Unknown tag: %s\n", tag.toLatin1().constData());
+ }
+ fclose(fp);
+ }
+ return;
+ */
+
+
+ bool popenFlag = false;
+ FILE* fp = fileOpen(this, filename, ".mpt", "r", popenFlag, false, false);
+
+ if(fp)
+ {
+ Xml xml = Xml(fp);
+ bool firstPart = true;
+ int posOffset = 0;
+ int notDone = 0;
+ int done = 0;
+
+ bool end = false;
+ song->startUndo();
+ for (;;)
+ {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token)
+ {
+ case Xml::Error:
+ case Xml::End:
+ end = true;
+ break;
+ case Xml::TagStart:
+ if (tag == "part") {
+ //MidiPart* p = new MidiPart((MidiTrack*)track);
+ //p->read(xml);
+
+ // Read the part.
+ Part* p = 0;
+ p = readXmlPart(xml, track);
+ // If it could not be created...
+ if(!p)
+ {
+ // Increment the number of parts not done and break.
+ ++notDone;
+ break;
+ }
+
+ // Increment the number of parts done.
+ ++done;
+
+ if(firstPart)
+ {
+ firstPart=false;
+ posOffset = tick - p->tick();
+ }
+ p->setTick(p->tick() + posOffset);
+ //finalPos=p->tick() + p->lenTick();
+ ////pos += p->lenTick();
+ audio->msgAddPart(p,false);
+ }
+ else
+ xml.unknown("MusE::importPartToTrack");
+ break;
+ case Xml::TagEnd:
+ break;
+ default:
+ end = true;
+ break;
+ }
+ if(end)
+ break;
+ }
+ fclose(fp);
+ song->endUndo(SC_PART_INSERTED);
+
+ if(notDone)
+ {
+ int tot = notDone + done;
+ QMessageBox::critical(this, QString("MusE"),
+ QString().setNum(notDone) + (tot > 1 ? (tr(" out of ") + QString().setNum(tot)) : QString("")) +
+ (tot > 1 ? tr(" parts") : tr(" part")) +
+ tr(" could not be imported.\nLikely the track is the wrong type."));
+ }
+
+ return;
+ }
+}
diff --git a/attic/muse2-oom/muse2/muse/instruments/CMakeLists.txt b/attic/muse2-oom/muse2/muse/instruments/CMakeLists.txt
new file mode 100644
index 00000000..b068798a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/instruments/CMakeLists.txt
@@ -0,0 +1,89 @@
+#=============================================================================
+# MusE
+# Linux Music Editor
+# $Id:$
+#
+# Copyright (C) 2002-2006 by Werner Schweer and others
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#=============================================================================
+
+##
+## Expand Qt macros in source files
+##
+QT4_WRAP_CPP ( instruments_mocs
+ editinstrument.h
+ # minstrument.h
+ )
+
+##
+## UI files
+##
+file (GLOB instruments_ui_files
+ # ccontrollerbase.ui # not built. It needs to be converted to Qt4 for revival.
+ editinstrumentbase.ui
+ )
+QT4_WRAP_UI ( instruments_uis ${instruments_ui_files} )
+
+##
+## List of source files to compile
+##
+file (GLOB instruments_source_files
+ editinstrument.cpp
+ editinstrument.h
+ minstrument.cpp
+ minstrument.h
+ )
+
+##
+## Define target
+##
+add_library ( instruments SHARED
+ ${instruments_source_files}
+ ${instruments_mocs}
+ ${instruments_uis}
+ )
+
+##
+## Append to the list of translations
+##
+set (FILES_TO_TRANSLATE
+ ${FILES_TO_TRANSLATE}
+ ${instruments_source_files}
+ ${instruments_ui_files}
+ CACHE INTERNAL ""
+ )
+
+##
+## Compilation flags and target name
+##
+set_target_properties( instruments
+ PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h -fPIC"
+ OUTPUT_NAME muse_instruments
+ )
+
+##
+## Linkage
+##
+target_link_libraries ( instruments
+ ${QT_LIBRARIES}
+ icons
+ )
+
+##
+## Install location
+##
+install(TARGETS instruments
+ DESTINATION ${MusE_MODULES_DIR}
+ )
+
diff --git a/attic/muse2-oom/muse2/muse/instruments/ccontrolbase.ui b/attic/muse2-oom/muse2/muse/instruments/ccontrolbase.ui
new file mode 100644
index 00000000..3094776f
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/instruments/ccontrolbase.ui
@@ -0,0 +1,525 @@
+<!DOCTYPE UI><UI version="3.1" stdsetdef="1">
+<class>MidiControllerEditDialogBase</class>
+<widget class="QDialog">
+ <property name="name">
+ <cstring>MidiControllerEditDialogBase</cstring>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>698</width>
+ <height>457</height>
+ </rect>
+ </property>
+ <property name="caption">
+ <string>MusE: Define Midi Controller</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLayoutWidget" row="3" column="0" rowspan="1" colspan="2">
+ <property name="name">
+ <cstring>Layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonNew</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Add</string>
+ </property>
+ <property name="accel">
+ <string>Alt+A</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>create new entry</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>pressing the New button you create a new entry
+in the MusE list of defined controllers</string>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonDelete</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Delete</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>delete selected entry</string>
+ </property>
+ </widget>
+ <spacer>
+ <property name="name">
+ <cstring>Spacer1</cstring>
+ </property>
+ <property name="orientation">
+ <enum>Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>Expanding</enum>
+ </property>
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonOk</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonApply</cstring>
+ </property>
+ <property name="text">
+ <string>A&amp;pply</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ <widget class="QPushButton">
+ <property name="name">
+ <cstring>buttonCancel</cstring>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>textLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Predefined Controller:</string>
+ </property>
+ </widget>
+ <widget class="QListView" row="1" column="1">
+ <column>
+ <property name="text">
+ <string>Name </string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Type </string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>H-Ctrl</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>false</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>L-Ctrl</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>false</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Min Val</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>false</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Max Val</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>false</bool>
+ </property>
+ </column>
+ <property name="name">
+ <cstring>viewController</cstring>
+ </property>
+ <property name="frameShape">
+ <enum>StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>Sunken</enum>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>list of defined controllers</string>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This is the MusE list of defined controllers.</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="0" column="1">
+ <property name="name">
+ <cstring>layout2</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Managed Controller for Port</string>
+ </property>
+ </widget>
+ <widget class="QComboBox">
+ <property name="name">
+ <cstring>midiPortsList</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>textLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>Channel</string>
+ </property>
+ </widget>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>midiChannel</cstring>
+ </property>
+ <property name="maxValue">
+ <number>16</number>
+ </property>
+ <property name="minValue">
+ <number>1</number>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QListBox" row="1" column="0" rowspan="2" colspan="1">
+ <property name="name">
+ <cstring>listController</cstring>
+ </property>
+ <property name="whatsThis" stdset="0">
+ <string>This is a list of commonly used midi controllers.
+Note that in MusE pitch and program changes are
+handled like normal controllers.</string>
+ </property>
+ </widget>
+ <widget class="QGroupBox" row="2" column="1">
+ <property name="name">
+ <cstring>GroupBox1</cstring>
+ </property>
+ <property name="title">
+ <string>Properties</string>
+ </property>
+ <grid>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <widget class="QLabel" row="0" column="0">
+ <property name="name">
+ <cstring>TextLabel1</cstring>
+ </property>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="2" column="1">
+ <property name="name">
+ <cstring>layout3</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel1_2</cstring>
+ </property>
+ <property name="text">
+ <string>Min Value</string>
+ </property>
+ <property name="indent">
+ <number>10</number>
+ </property>
+ </widget>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>spinboxMin</cstring>
+ </property>
+ <property name="maxValue">
+ <number>16384</number>
+ </property>
+ <property name="minValue">
+ <number>-16385</number>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel2_2</cstring>
+ </property>
+ <property name="text">
+ <string>Max Value</string>
+ </property>
+ <property name="indent">
+ <number>10</number>
+ </property>
+ </widget>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>spinboxMax</cstring>
+ </property>
+ <property name="maxValue">
+ <number>16384</number>
+ </property>
+ <property name="minValue">
+ <number>-16385</number>
+ </property>
+ <property name="value">
+ <number>127</number>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="1" column="0">
+ <property name="name">
+ <cstring>TextLabel2</cstring>
+ </property>
+ <property name="text">
+ <string>Type</string>
+ </property>
+ </widget>
+ <widget class="QLineEdit" row="0" column="1">
+ <property name="name">
+ <cstring>entryName</cstring>
+ </property>
+ </widget>
+ <widget class="QLayoutWidget" row="1" column="1">
+ <property name="name">
+ <cstring>layout5</cstring>
+ </property>
+ <hbox>
+ <property name="name">
+ <cstring>unnamed</cstring>
+ </property>
+ <widget class="QComboBox">
+ <item>
+ <property name="text">
+ <string>Control7</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Control14</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>RPN</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>NRPN</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>RPN14</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>NRPN14</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Pitch</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Program</string>
+ </property>
+ </item>
+ <property name="name">
+ <cstring>comboType</cstring>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel3</cstring>
+ </property>
+ <property name="text">
+ <string>H-Ctrl</string>
+ </property>
+ <property name="indent">
+ <number>10</number>
+ </property>
+ </widget>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>spinboxHCtrlNo</cstring>
+ </property>
+ <property name="maxValue">
+ <number>127</number>
+ </property>
+ <property name="minValue">
+ <number>0</number>
+ </property>
+ <property name="value">
+ <number>1</number>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Midi Controller Number High Byte</string>
+ </property>
+ </widget>
+ <widget class="QLabel">
+ <property name="name">
+ <cstring>TextLabel2_3</cstring>
+ </property>
+ <property name="text">
+ <string>L-Ctrl</string>
+ </property>
+ <property name="indent">
+ <number>10</number>
+ </property>
+ </widget>
+ <widget class="QSpinBox">
+ <property name="name">
+ <cstring>spinboxLCtrlNo</cstring>
+ </property>
+ <property name="maxValue">
+ <number>127</number>
+ </property>
+ <property name="minValue">
+ <number>0</number>
+ </property>
+ <property name="value">
+ <number>1</number>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Midi Controller Number Low Byte</string>
+ </property>
+ </widget>
+ </hbox>
+ </widget>
+ <widget class="QLabel" row="2" column="0">
+ <property name="name">
+ <cstring>textLabel4</cstring>
+ </property>
+ <property name="text">
+ <string>Range</string>
+ </property>
+ </widget>
+ </grid>
+ </widget>
+ </grid>
+</widget>
+<connections>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>MidiControllerEditDialogBase</receiver>
+ <slot>reject()</slot>
+ </connection>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>MidiControllerEditDialogBase</receiver>
+ <slot>accept()</slot>
+ </connection>
+</connections>
+<tabstops>
+ <tabstop>viewController</tabstop>
+ <tabstop>entryName</tabstop>
+ <tabstop>comboType</tabstop>
+ <tabstop>spinboxHCtrlNo</tabstop>
+ <tabstop>spinboxLCtrlNo</tabstop>
+ <tabstop>spinboxMin</tabstop>
+ <tabstop>spinboxMax</tabstop>
+ <tabstop>buttonNew</tabstop>
+ <tabstop>buttonDelete</tabstop>
+ <tabstop>buttonOk</tabstop>
+ <tabstop>buttonApply</tabstop>
+ <tabstop>buttonCancel</tabstop>
+</tabstops>
+<layoutdefaults spacing="6" margin="11"/>
+</UI>
diff --git a/attic/muse2-oom/muse2/muse/instruments/editinstrument.cpp b/attic/muse2-oom/muse2/muse/instruments/editinstrument.cpp
new file mode 100644
index 00000000..c45ac97a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/instruments/editinstrument.cpp
@@ -0,0 +1,3588 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: editinstrument.cpp,v 1.2.2.6 2009/05/31 05:12:12 terminator356 Exp $
+//
+// (C) Copyright 2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <errno.h>
+
+#include <QCloseEvent>
+#include <QDir>
+#include <QFileDialog>
+#include <QFileInfo>
+#include <QInputDialog>
+#include <QMessageBox>
+#include <QLineEdit>
+#include <QWhatsThis>
+
+#include "editinstrument.h"
+#include "minstrument.h"
+#include "globals.h"
+#include "song.h"
+#include "xml.h"
+#include "midictrl.h"
+#include "gconfig.h"
+#include "icons.h"
+
+
+enum {
+ COL_NAME = 0, COL_TYPE,
+ COL_HNUM, COL_LNUM, COL_MIN, COL_MAX, COL_DEF
+ };
+
+//---------------------------------------------------------
+// EditInstrument
+//---------------------------------------------------------
+
+EditInstrument::EditInstrument(QWidget* parent, Qt::WFlags fl)
+ : QMainWindow(parent, fl)
+ {
+ setupUi(this);
+ fileNewAction->setIcon(QIcon(*filenewIcon));
+ fileOpenAction->setIcon(QIcon(*openIcon));
+ fileSaveAction->setIcon(QIcon(*saveIcon));
+ fileSaveAsAction->setIcon(QIcon(*saveasIcon));
+ fileExitAction->setIcon(QIcon(*exitIcon));
+ viewController->setSelectionMode(QAbstractItemView::SingleSelection);
+ toolBar->addAction(QWhatsThis::createAction(this));
+ Help->addAction(QWhatsThis::createAction(this));
+
+ ///patchpopup = new QMenu(patchButton);
+ //patchpopup->setCheckable(false);// Qt4 doc says this is unnecessary.
+
+ // populate instrument list
+ // Populate common controller list.
+ for(int i = 0; i < 128; ++i)
+ {
+ QListWidgetItem *lci = new QListWidgetItem(midiCtrlName(i));
+ listController->addItem(lci);
+ }
+ oldMidiInstrument = 0;
+ oldPatchItem = 0;
+ for (iMidiInstrument i = midiInstruments.begin(); i != midiInstruments.end(); ++i) {
+ // Imperfect, crude way of ignoring internal instruments, soft synths etc. If it has a gui,
+ // it must be an internal instrument. But this will still allow some vst instruments (without a gui)
+ // to show up in the list.
+ // Hmm, try file path instead...
+ //if((*i)->hasGui())
+ if((*i)->filePath().isEmpty())
+ continue;
+
+ QListWidgetItem* item = new QListWidgetItem((*i)->iname());
+ QVariant v = qVariantFromValue((void*)(*i));
+ item->setData(Qt::UserRole, v);
+ instrumentList->addItem(item);
+ }
+ instrumentList->setSelectionMode(QAbstractItemView::SingleSelection);
+ if(instrumentList->item(0))
+ instrumentList->setCurrentItem(instrumentList->item(0));
+ //oldMidiInstrument = (MidiInstrument*)((ListBoxData*)instrumentList->item(0))->data();
+ //oldMidiInstrument = (ListBoxData*)instrumentList->item(0);
+ //oldMidiInstrument = (ListBoxData*)instrumentList->selectedItem();
+
+// MidiInstrument* wip = (MidiInstrument*)((ListBoxData*)instrumentList->item(0))->data();
+// if(wip)
+ // Assignment
+// workingInstrument.assign( *wip );
+
+
+ connect(instrumentList, SIGNAL(itemSelectionChanged()), SLOT(instrumentChanged()));
+ connect(patchView, SIGNAL(itemSelectionChanged()), SLOT(patchChanged()));
+
+ //instrumentChanged();
+ changeInstrument();
+
+ //connect(listController, SIGNAL(selectionChanged()), SLOT(controllerChanged()));
+ connect(viewController, SIGNAL(itemSelectionChanged()), SLOT(controllerChanged()));
+
+ //connect(instrumentName, SIGNAL(textChanged(const QString&)), SLOT(instrumentNameChanged(const QString&)));
+ connect(instrumentName, SIGNAL(returnPressed()), SLOT(instrumentNameReturn()));
+ connect(instrumentName, SIGNAL(lostFocus()), SLOT(instrumentNameReturn()));
+
+ connect(patchNameEdit, SIGNAL(returnPressed()), SLOT(patchNameReturn()));
+ connect(patchNameEdit, SIGNAL(lostFocus()), SLOT(patchNameReturn()));
+ connect(patchDelete, SIGNAL(clicked()), SLOT(deletePatchClicked()));
+ connect(patchNew, SIGNAL(clicked()), SLOT(newPatchClicked()));
+ connect(patchNewGroup, SIGNAL(clicked()), SLOT(newGroupClicked()));
+ //connect(newCategory, SIGNAL(clicked()), SLOT(newCategoryClicked()));
+
+ connect(patchButton, SIGNAL(clicked()), SLOT(patchButtonClicked()));
+ connect(defPatchH, SIGNAL(valueChanged(int)), SLOT(defPatchChanged(int)));
+ connect(defPatchL, SIGNAL(valueChanged(int)), SLOT(defPatchChanged(int)));
+ connect(defPatchProg, SIGNAL(valueChanged(int)), SLOT(defPatchChanged(int)));
+ connect(deleteController, SIGNAL(clicked()), SLOT(deleteControllerClicked()));
+ connect(newController, SIGNAL(clicked()), SLOT(newControllerClicked()));
+ connect(addController, SIGNAL(clicked()), SLOT(addControllerClicked()));
+ connect(listController, SIGNAL(itemDoubleClicked(QListWidgetItem*)), SLOT(addControllerClicked()));
+ connect(ctrlType,SIGNAL(activated(int)), SLOT(ctrlTypeChanged(int)));
+ connect(ctrlName, SIGNAL(returnPressed()), SLOT(ctrlNameReturn()));
+ connect(ctrlName, SIGNAL(lostFocus()), SLOT(ctrlNameReturn()));
+ //connect(ctrlName, SIGNAL(textChanged(const QString&)), SLOT(ctrlNameChanged(const QString&)));
+ connect(spinBoxHCtrlNo, SIGNAL(valueChanged(int)), SLOT(ctrlHNumChanged(int)));
+ connect(spinBoxLCtrlNo, SIGNAL(valueChanged(int)), SLOT(ctrlLNumChanged(int)));
+ connect(spinBoxMin, SIGNAL(valueChanged(int)), SLOT(ctrlMinChanged(int)));
+ connect(spinBoxMax, SIGNAL(valueChanged(int)), SLOT(ctrlMaxChanged(int)));
+ connect(spinBoxDefault, SIGNAL(valueChanged(int)), SLOT(ctrlDefaultChanged(int)));
+ connect(nullParamSpinBoxH, SIGNAL(valueChanged(int)), SLOT(ctrlNullParamHChanged(int)));
+ connect(nullParamSpinBoxL, SIGNAL(valueChanged(int)), SLOT(ctrlNullParamLChanged(int)));
+
+ connect(tabWidget3, SIGNAL(currentChanged(QWidget*)), SLOT(tabChanged(QWidget*)));
+ //connect(sysexList, SIGNAL(selectionChanged()), SLOT(sysexChanged()));
+ //connect(deleteSysex, SIGNAL(clicked()), SLOT(deleteSysexClicked()));
+ //connect(newSysex, SIGNAL(clicked()), SLOT(newSysexClicked()));
+ }
+
+//---------------------------------------------------------
+// helpWhatsThis
+//---------------------------------------------------------
+
+void EditInstrument::helpWhatsThis()
+{
+ whatsThis();
+}
+
+//---------------------------------------------------------
+// fileNew
+//---------------------------------------------------------
+
+void EditInstrument::fileNew()
+ {
+ // Allow these to update...
+ instrumentNameReturn();
+ patchNameReturn();
+ ctrlNameReturn();
+
+ for (int i = 1;; ++i) {
+ QString s = QString("Instrument-%1").arg(i);
+ bool found = false;
+ for (iMidiInstrument i = midiInstruments.begin(); i != midiInstruments.end(); ++i) {
+ if (s == (*i)->iname()) {
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ //if(oldMidiInstrument)
+ //{
+ MidiInstrument* oi = 0;
+ if(oldMidiInstrument)
+ oi = (MidiInstrument*)oldMidiInstrument->data(Qt::UserRole).value<void*>();
+ MidiInstrument* wip = &workingInstrument;
+ //checkDirty(oi);
+ //if(checkDirty(oi))
+ if(checkDirty(wip))
+ // No save was chosen. Restore the actual instrument name.
+ {
+ if(oi)
+ {
+ oldMidiInstrument->setText(oi->iname());
+ //workingInstrument.setIName(oi->iname());
+
+ // No file path? Only a new unsaved instrument can do that. So delete it.
+ if(oi->filePath().isEmpty())
+ // Delete the list item and the instrument.
+ deleteInstrument(oldMidiInstrument);
+
+ }
+ }
+ //else
+ //{
+ // if(oi)
+ // Save was chosen. Assign the working instrument to the actual instrument.
+ // oi->assign(workingInstrument);
+ //}
+
+ //oi->setDirty(false);
+ workingInstrument.setDirty(false);
+ //}
+
+ MidiInstrument* ni = new MidiInstrument(s);
+ //midiInstruments.append(ni);
+ midiInstruments.push_back(ni);
+ //QListWidgetItem* item = new QListWidgetItem(ni->iname());
+ //InstrumentListItem* item = new InstrumentListItem(ni->iname());
+ QListWidgetItem* item = new QListWidgetItem(ni->iname());
+
+ //oldMidiInstrument = item;
+ workingInstrument.assign( *ni );
+ //workingInstrument.setDirty(false);
+
+ //item->setText(ni->iname());
+ QVariant v = qVariantFromValue((void*)(ni));
+ item->setData(Qt::UserRole, v);
+ instrumentList->addItem(item);
+
+ oldMidiInstrument = 0;
+
+ instrumentList->blockSignals(true);
+ instrumentList->setCurrentItem(item);
+ instrumentList->blockSignals(false);
+
+ changeInstrument();
+
+ // We have our new instrument! So set dirty to true.
+ workingInstrument.setDirty(true);
+
+ break;
+ }
+ }
+
+ }
+
+//---------------------------------------------------------
+// fileOpen
+//---------------------------------------------------------
+
+void EditInstrument::fileOpen()
+ {
+ // Allow these to update...
+ //instrumentNameReturn();
+ //patchNameReturn();
+ //ctrlNameReturn();
+
+
+ }
+
+//---------------------------------------------------------
+// fileSave
+//---------------------------------------------------------
+
+void EditInstrument::fileSave()
+{
+ //if (instrument->filePath().isEmpty())
+ if (workingInstrument.filePath().isEmpty())
+ {
+ //fileSaveAs();
+ saveAs();
+ return;
+ }
+
+ // Do not allow a direct overwrite of a 'built-in' muse instrument.
+ QFileInfo qfi(workingInstrument.filePath());
+ if(qfi.absolutePath() == museInstruments)
+ {
+ //fileSaveAs();
+ saveAs();
+ return;
+ }
+
+ //QFile f(instrument->filePath());
+ //if (!f.open(QIODevice::WriteOnly)) {
+ //FILE* f = fopen(instrument->filePath().toLatin1().constData(), "w");
+ FILE* f = fopen(workingInstrument.filePath().toLatin1().constData(), "w");
+ if(f == 0)
+ {
+ //fileSaveAs();
+ saveAs();
+ return;
+ }
+
+ // Allow these to update...
+ instrumentNameReturn();
+ patchNameReturn();
+ ctrlNameReturn();
+
+ //f.close();
+ if(fclose(f) != 0)
+ {
+ //QString s = QString("Creating file:\n") + instrument->filePath() + QString("\nfailed: ")
+ QString s = QString("Creating file:\n") + workingInstrument.filePath() + QString("\nfailed: ")
+ //+ f.errorString();
+ + QString(strerror(errno) );
+ //fprintf(stderr, "poll failed: %s\n", strerror(errno));
+ QMessageBox::critical(this, tr("MusE: Create file failed"), s);
+ return;
+ }
+
+ //if(fileSave(instrument, instrument->filePath()))
+ // instrument->setDirty(false);
+ if(fileSave(&workingInstrument, workingInstrument.filePath()))
+ workingInstrument.setDirty(false);
+}
+
+//---------------------------------------------------------
+// fileSave
+//---------------------------------------------------------
+
+bool EditInstrument::fileSave(MidiInstrument* instrument, const QString& name)
+ {
+ //QFile f(name);
+ //if (!f.open(QIODevice::WriteOnly)) {
+ // QString s("Creating file failed: ");
+ // s += strerror(errno);
+ // QMessageBox::critical(this,
+ // tr("MusE: Create file failed"), s);
+ // return false;
+ // }
+ //Xml xml(&f);
+
+ FILE* f = fopen(name.toAscii().constData(), "w");
+ if(f == 0)
+ {
+ //if(debugMsg)
+ // printf("READ IDF %s\n", fi->filePath().toLatin1().constData());
+ QString s("Creating file failed: ");
+ s += QString(strerror(errno));
+ QMessageBox::critical(this,
+ tr("MusE: Create file failed"), s);
+ return false;
+ }
+
+ Xml xml(f);
+
+ updateInstrument(instrument);
+
+ //instrument->write(xml);
+ instrument->write(0, xml);
+
+ // Assign the working instrument values to the actual current selected instrument...
+ if(oldMidiInstrument)
+ {
+ MidiInstrument* oi = (MidiInstrument*)oldMidiInstrument->data(Qt::UserRole).value<void*>();
+ if(oi)
+ {
+ oi->assign(workingInstrument);
+
+ // Now signal the rest of the app so stuff can change...
+ song->update(SC_CONFIG | SC_MIDI_CONTROLLER);
+ //song->update(SC_CONFIG | SC_MIDI_CONTROLLER | SC_MIDI_CONTROLLER_ADD);
+ }
+ }
+
+ //f.close();
+ //if (f.error()) {
+ if(fclose(f) != 0)
+ {
+ QString s = QString("Write File\n") + name + QString("\nfailed: ")
+ //+ f.errorString();
+ + QString(strerror(errno));
+ //fprintf(stderr, "poll failed: %s\n", strerror(errno));
+ QMessageBox::critical(this, tr("MusE: Write File failed"), s);
+ return false;
+ }
+ return true;
+ }
+
+//---------------------------------------------------------
+// saveAs
+//---------------------------------------------------------
+
+void EditInstrument::saveAs()
+ {
+ // Allow these to update...
+ instrumentNameReturn();
+ patchNameReturn();
+ ctrlNameReturn();
+
+ //QListWidgetItem* item = instrumentList->currentItem();
+// ListBoxData* item = (ListBoxData*)instrumentList->selectedItem();
+// if (item == 0)
+// return;
+ //MidiInstrument* instrument = (MidiInstrument*)item->data(Qt::UserRole).value<void*>();
+// MidiInstrument* instrument = (MidiInstrument*)item->data();
+
+ //QString path = QDir::homePath() + "/" + config.instrumentPath;
+ //QString path = QDir::homeDirPath() + "/" + museGlobalShare;
+ //QString path = museInstruments;
+ QString path = museUserInstruments;
+
+ if(!QDir(museUserInstruments).exists())
+ {
+ if(QMessageBox::question(this,
+ tr("MusE:"),
+ tr("The user instrument directory\n") + museUserInstruments + tr("\ndoes not exist yet. Create it now?\n") +
+ tr("(You can change the user instruments directory at Settings->Global Settings->Midi)"),
+ QMessageBox::Ok | QMessageBox::Default,
+ QMessageBox::Cancel | QMessageBox::Escape,
+ Qt::NoButton) == QMessageBox::Ok)
+ {
+ if(QDir().mkdir(museUserInstruments))
+ printf("Created user instrument directory: %s\n", museUserInstruments.toLatin1().constData());
+ else
+ {
+ printf("Unable to create user instrument directory: %s\n", museUserInstruments.toLatin1().constData());
+ QMessageBox::critical(this, tr("MusE:"), tr("Unable to create user instrument directory\n") + museUserInstruments);
+ //return;
+ path = museUser;
+ }
+ }
+ else
+ // return;
+ path = museUser;
+ }
+
+ //if (instrument->filePath().isEmpty())
+ if (workingInstrument.filePath().isEmpty())
+ path += QString("/%1.idf").arg(workingInstrument.iname());
+ else {
+ //QFileInfo fi(instrument->filePath());
+ QFileInfo fi(workingInstrument.filePath());
+
+ // Prompt for a new instrument name if the name has not been changed, to avoid duplicates.
+ if(oldMidiInstrument)
+ {
+ MidiInstrument* oi = (MidiInstrument*)oldMidiInstrument->data(Qt::UserRole).value<void*>();
+ if(oi)
+ {
+ if(oi->iname() == workingInstrument.iname())
+ {
+ // Prompt only if it's a user instrument, to avoid duplicates in the user instrument dir.
+ // This will still allow a user instrument to override a built-in instrument with the same name.
+ if(fi.absolutePath() != museInstruments)
+ {
+ //QMessageBox::critical(this,
+ // tr("MusE: Bad instrument name"),
+ // tr("Please change the instrument name to a new unique name before saving, to avoid duplicates"),
+ // QMessageBox::Ok,
+ // QMessageBox::NoButton,
+ // QMessageBox::NoButton);
+ printf("EditInstrument::saveAs Error: Instrument name %s already used!\n", workingInstrument.iname().toLatin1().constData());
+ return;
+ }
+ }
+ }
+ }
+ path += QString("/%1.idf").arg(fi.baseName());
+ }
+ //QString s = QFileDialog::getSaveFileName(this,
+ // tr("MusE: Save Instrument Definition"),
+ // path,
+ // tr("Instrument Definition (*.idf)"));
+
+ QString s = QFileDialog::getSaveFileName(this, tr("MusE: Save Instrument Definition").toLatin1().constData(),
+ path, tr("Instrument Definition (*.idf)"));
+ if (s.isEmpty())
+ return;
+ //instrument->setFilePath(s);
+ workingInstrument.setFilePath(s);
+
+ //if (fileSave(instrument, s))
+ // instrument->setDirty(false);
+ if(fileSave(&workingInstrument, s))
+ workingInstrument.setDirty(false);
+ }
+
+//---------------------------------------------------------
+// fileSaveAs
+//---------------------------------------------------------
+
+void EditInstrument::fileSaveAs()
+ {
+ // Is this a new unsaved instrument? Just do a normal save.
+ if(workingInstrument.filePath().isEmpty())
+ {
+ saveAs();
+ return;
+ }
+
+ // Allow these to update...
+ instrumentNameReturn();
+ patchNameReturn();
+ ctrlNameReturn();
+
+ MidiInstrument* oi = 0;
+ if(oldMidiInstrument)
+ oi = (MidiInstrument*)oldMidiInstrument->data(Qt::UserRole).value<void*>();
+
+ int res = checkDirty(&workingInstrument, true);
+ switch(res)
+ {
+ // No save:
+ case 1:
+ //item->setText(instrument->iname());
+ //instrumentList->triggerUpdate(true);
+ //instrument->setDirty(false);
+ workingInstrument.setDirty(false);
+ if(oi)
+ {
+ oldMidiInstrument->setText(oi->iname());
+ //workingInstrument.setIName(oi->iname());
+
+ //workingInstrument.assign(*oi);
+
+ // No file path? Only a new unsaved instrument can do that. So delete it.
+ if(oi->filePath().isEmpty())
+ {
+ // Delete the list item and the instrument.
+ deleteInstrument(oldMidiInstrument);
+ oldMidiInstrument = 0;
+ }
+
+ changeInstrument();
+
+ }
+ return;
+ break;
+
+ // Abort:
+ case 2:
+ return;
+ break;
+
+ // Save:
+ case 0:
+ //if(oi)
+ // oi->assign(workingInstrument);
+ workingInstrument.setDirty(false);
+ break;
+ }
+
+ //QListWidgetItem* item = instrumentList->currentItem();
+// ListBoxData* item = (ListBoxData*)instrumentList->selectedItem();
+// if (item == 0)
+// return;
+ //MidiInstrument* instrument = (MidiInstrument*)item->data(Qt::UserRole).value<void*>();
+// MidiInstrument* instrument = (MidiInstrument*)item->data();
+
+ bool isuser = false;
+ QString so;
+ if(workingInstrument.iname().isEmpty())
+ so = QString("Instrument");
+ else
+ so = workingInstrument.iname();
+
+ for(int i = 1;; ++i)
+ {
+ QString s = so + QString("-%1").arg(i);
+
+ bool found = false;
+ for(iMidiInstrument imi = midiInstruments.begin(); imi != midiInstruments.end(); ++imi)
+ {
+ if(s == (*imi)->iname())
+ {
+ // Allow override of built-in instrument names.
+ QFileInfo fi((*imi)->filePath());
+ if(fi.absolutePath() == museInstruments)
+ break;
+ found = true;
+ break;
+ }
+ }
+ if(found)
+ continue;
+
+ bool ok;
+ s = QInputDialog::getText(this, tr("MusE: Save instrument as"), tr("Enter a new unique instrument name:"),
+ QLineEdit::Normal, s, &ok);
+ if(!ok)
+ return;
+ if(s.isEmpty())
+ {
+ --i;
+ continue;
+ }
+
+ isuser = false;
+ bool builtin = false;
+ found = false;
+ for(iMidiInstrument imi = midiInstruments.begin(); imi != midiInstruments.end(); ++imi)
+ {
+ // If an instrument with the same name is found...
+ if((*imi)->iname() == s)
+ {
+ // If it's not the same name as the working instrument, and it's not an internal instrument (soft synth etc.)...
+ if(s != workingInstrument.iname() && !(*imi)->filePath().isEmpty())
+ {
+ QFileInfo fi((*imi)->filePath());
+ // Allow override of built-in and user instruments:
+ // If it's a user instrument, not a built-in instrument...
+ if(fi.absolutePath() == museUserInstruments)
+ {
+ // No choice really but to overwrite the destination instrument file!
+ // Can not have two user files containing the same instrument name.
+ if(QMessageBox::question(this,
+ tr("MusE: Save instrument as"),
+ tr("The user instrument:\n") + s + tr("\nalready exists. This will overwrite its .idf instrument file.\nAre you sure?"),
+ QMessageBox::Ok | QMessageBox::Default,
+ QMessageBox::Cancel | QMessageBox::Escape,
+ Qt::NoButton) == QMessageBox::Ok)
+ {
+ // Set the working instrument's file path to the found instrument's path.
+ workingInstrument.setFilePath((*imi)->filePath());
+ // Mark as overwriting a user instrument.
+ isuser = true;
+ }
+ else
+ {
+ found = true;
+ break;
+ }
+ }
+ // Assign the found instrument to the working instrument.
+ //workingInstrument.assign(*(*imi));
+ // Assign the found instrument name to the working instrument name.
+ workingInstrument.setIName(s);
+
+ // Find the instrument in the list and set the old instrument to the item.
+ oldMidiInstrument = instrumentList->findItems(s, Qt::MatchExactly)[0];
+
+ // Mark as a built-in instrument.
+ builtin = true;
+ break;
+ }
+ found = true;
+ break;
+ }
+ }
+ if(found)
+ {
+ so = s;
+ i = 0;
+ continue;
+ }
+
+ so = s;
+
+ // If the name does not belong to a built-in instrument...
+ if(!builtin)
+ {
+ MidiInstrument* ni = new MidiInstrument();
+ ni->assign(workingInstrument);
+ ni->setIName(so);
+ ni->setFilePath(QString());
+ //midiInstruments.append(ni);
+ midiInstruments.push_back(ni);
+ //QListWidgetItem* item = new QListWidgetItem(ni->iname());
+ //InstrumentListItem* item = new InstrumentListItem(ni->iname());
+ //ListBoxData* item = new ListBoxData(ni->iname());
+ QListWidgetItem* item = new QListWidgetItem(so);
+
+ //oldMidiInstrument = item;
+ workingInstrument.assign( *ni );
+ //workingInstrument.setDirty(false);
+
+ //item->setText(ni->iname());
+ //item->setData((void*)ni);
+ QVariant v = qVariantFromValue((void*)(ni));
+ item->setData(Qt::UserRole, v);
+ //instrumentList->addItem(item);
+ instrumentList->addItem(item);
+
+ oldMidiInstrument = 0;
+
+ instrumentList->blockSignals(true);
+ instrumentList->setCurrentItem(item);
+ instrumentList->blockSignals(false);
+
+ changeInstrument();
+
+ // We have our new instrument! So set dirty to true.
+ workingInstrument.setDirty(true);
+ }
+
+ break;
+ }
+
+ //QString path = QDir::homePath() + "/" + config.instrumentPath;
+ //QString path = QDir::homeDirPath() + "/" + museGlobalShare;
+ //QString path = museInstruments;
+ QString path = museUserInstruments;
+
+ if(!QDir(museUserInstruments).exists())
+ {
+ if(QMessageBox::question(this,
+ tr("MusE:"),
+ tr("The user instrument directory\n") + museUserInstruments + tr("\ndoes not exist yet. Create it now?\n") +
+ tr("(You can change the user instruments directory at Settings->Global Settings->Midi)"),
+ QMessageBox::Ok | QMessageBox::Default,
+ QMessageBox::Cancel | QMessageBox::Escape,
+ Qt::NoButton) == QMessageBox::Ok)
+ {
+ if(QDir().mkdir(museUserInstruments))
+ printf("Created user instrument directory: %s\n", museUserInstruments.toLatin1().constData());
+ else
+ {
+ printf("Unable to create user instrument directory: %s\n", museUserInstruments.toLatin1().constData());
+ QMessageBox::critical(this, tr("MusE:"), tr("Unable to create user instrument directory\n") + museUserInstruments);
+ //return;
+ path = museUser;
+ }
+ }
+ else
+ // return;
+ path = museUser;
+ }
+ path += QString("/%1.idf").arg(so);
+
+ //QString s = QFileDialog::getSaveFileName(this,
+ // tr("MusE: Save Instrument Definition"),
+ // path,
+ // tr("Instrument Definition (*.idf)"));
+
+ QString sfn;
+ // If we are overwriting a user instrument just force the path.
+ if(isuser)
+ sfn = path;
+ else
+ {
+ sfn = QFileDialog::getSaveFileName(this, tr("MusE: Save Instrument Definition").toLatin1().constData(),
+ path, tr("Instrument Definition (*.idf)"));
+ if (sfn.isEmpty())
+ return;
+ //instrument->setFilePath(s);
+ workingInstrument.setFilePath(sfn);
+ }
+
+ //if (fileSave(instrument, s))
+ // instrument->setDirty(false);
+ if(fileSave(&workingInstrument, sfn))
+ workingInstrument.setDirty(false);
+ }
+
+//---------------------------------------------------------
+// fileExit
+//---------------------------------------------------------
+
+void EditInstrument::fileExit()
+ {
+
+ }
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void EditInstrument::closeEvent(QCloseEvent* ev)
+ {
+ // Allow these to update...
+ instrumentNameReturn();
+ patchNameReturn();
+ ctrlNameReturn();
+
+ //QListWidgetItem* item = instrumentList->currentItem();
+
+// ListBoxData* item = (ListBoxData*)instrumentList->selectedItem();
+
+// if(item)
+// {
+ //MidiInstrument* instrument = (MidiInstrument*)item->data(Qt::UserRole).value<void*>();
+// MidiInstrument* instrument = (MidiInstrument*)item->data();
+// int res = checkDirty(instrument, true);
+ MidiInstrument* oi = 0;
+ if(oldMidiInstrument)
+ oi = (MidiInstrument*)oldMidiInstrument->data(Qt::UserRole).value<void*>();
+
+ int res = checkDirty(&workingInstrument, true);
+ switch(res)
+ {
+ // No save:
+ case 1:
+ //item->setText(instrument->iname());
+ //instrumentList->triggerUpdate(true);
+ //instrument->setDirty(false);
+ workingInstrument.setDirty(false);
+ if(oi)
+ {
+ oldMidiInstrument->setText(oi->iname());
+ //workingInstrument.setIName(oi->iname());
+
+ //workingInstrument.assign(*oi);
+
+ // No file path? Only a new unsaved instrument can do that. So delete it.
+ if(oi->filePath().isEmpty())
+ {
+ // Delete the list item and the instrument.
+ deleteInstrument(oldMidiInstrument);
+ oldMidiInstrument = 0;
+ }
+
+ changeInstrument();
+
+ }
+ break;
+
+ // Abort:
+ case 2:
+ ev->ignore();
+ return;
+ break;
+
+ // Save:
+ case 0:
+ //if(oi)
+ // oi->assign(workingInstrument);
+ workingInstrument.setDirty(false);
+ break;
+
+ }
+
+// }
+
+ QMainWindow::closeEvent(ev);
+ }
+
+//---------------------------------------------------------
+// changeInstrument
+//---------------------------------------------------------
+
+void EditInstrument::changeInstrument()
+{
+ QListWidgetItem* sel = instrumentList->currentItem();
+
+ if(!sel)
+ return;
+
+ //oldMidiInstrument = (MidiInstrument*)sel->data();
+ oldMidiInstrument = sel;
+ // Assignment
+ //workingInstrument = *((MidiInstrument*)sel->data());
+
+ // Assign will 'delete' any existing patches, groups, or controllers.
+ workingInstrument.assign( *((MidiInstrument*)sel->data(Qt::UserRole).value<void*>()) );
+
+ workingInstrument.setDirty(false);
+
+ // populate patch list
+ patchView->blockSignals(true);
+ for (int i = 0; i < patchView->topLevelItemCount(); ++i)
+ qDeleteAll(patchView->topLevelItem(i)->takeChildren());
+ patchView->clear();
+ patchView->blockSignals(false);
+
+ //viewController->blockSignals(true);
+ for (int i = 0; i < viewController->topLevelItemCount(); ++i)
+ qDeleteAll(viewController->topLevelItem(i)->takeChildren());
+ viewController->clear();
+ //viewController->blockSignals(false);
+
+ //listController->clear();
+ //category->clear();
+ //sysexList->clear();
+
+
+ //MidiInstrument* instrument = (MidiInstrument*)sel->data(Qt::UserRole).value<void*>();
+ //MidiInstrument* instrument = (MidiInstrument*)sel->data();
+ //instrument->setDirty(false);
+
+ instrumentName->blockSignals(true);
+ //instrumentName->setText(instrument->iname());
+ instrumentName->setText(workingInstrument.iname());
+ instrumentName->blockSignals(false);
+
+ nullParamSpinBoxH->blockSignals(true);
+ nullParamSpinBoxL->blockSignals(true);
+ int nv = workingInstrument.nullSendValue();
+ if(nv == -1)
+ {
+ nullParamSpinBoxH->setValue(-1);
+ nullParamSpinBoxL->setValue(-1);
+ }
+ else
+ {
+ int nvh = (nv >> 8) & 0xff;
+ int nvl = nv & 0xff;
+ if(nvh == 0xff)
+ nullParamSpinBoxH->setValue(-1);
+ else
+ nullParamSpinBoxH->setValue(nvh & 0x7f);
+ if(nvl == 0xff)
+ nullParamSpinBoxL->setValue(-1);
+ else
+ nullParamSpinBoxL->setValue(nvl & 0x7f);
+ }
+ nullParamSpinBoxH->blockSignals(false);
+ nullParamSpinBoxL->blockSignals(false);
+
+ //std::vector<PatchGroup>* pg = instrument->groups();
+ //PatchGroupList* pg = instrument->groups();
+ PatchGroupList* pg = workingInstrument.groups();
+ //for (std::vector<PatchGroup>::iterator g = pg->begin(); g != pg->end(); ++g) {
+ for (ciPatchGroup g = pg->begin(); g != pg->end(); ++g) {
+ PatchGroup* pgp = *g;
+ if(pgp)
+ {
+ //QTreeWidgetItem* item = new QTreeWidgetItem;
+ QTreeWidgetItem* item = new QTreeWidgetItem(patchView);
+
+ //item->setText(0, g->name);
+ item->setText(0, pgp->name);
+ //QVariant v = QVariant::fromValue((void*)0);
+ //item->setData(0, Qt::UserRole, v);
+ //item->setData((void*)*g);
+ //item->setData((void*)0);
+ //item->setData((void*)&*g);
+ //item->setData((void*)pgp);
+ QVariant v = qVariantFromValue((void*)(pgp));
+ item->setData(0, Qt::UserRole, v);
+ //patchView->addTopLevelItem(item);
+
+ //for (ciPatch p = g->patches.begin(); p != g->patches.end(); ++p)
+ for (ciPatch p = pgp->patches.begin(); p != pgp->patches.end(); ++p)
+ {
+ //const Patch& patch = *p;
+ Patch* patch = *p;
+ if(patch)
+ {
+ //QTreeWidgetItem* sitem = new QTreeWidgetItem;
+ QTreeWidgetItem* sitem = new QTreeWidgetItem(item);
+ //printf("%s \n", qPrintable(patch->name));
+
+ //sitem->setText(0, patch.name);
+ //sitem->setText(0, p->name);
+ sitem->setText(0, patch->name);
+ //QVariant v = QVariant::fromValue((void*)patch);
+ //sitem->setData(0, Qt::UserRole, v);
+ //sitem->setData((void*)&*p);
+ //sitem->setData((void*)patch);
+ QVariant v = QVariant::fromValue((void*)patch);
+ sitem->setData(0, Qt::UserRole, v);
+ //item->addChild(sitem);
+ }
+ }
+ }
+ }
+ //patchView->setSelected(patchView->item(0), true);
+
+ oldPatchItem = 0;
+
+ QTreeWidgetItem* fc = patchView->topLevelItem(0);
+ if(fc)
+ {
+ // This may cause a patchChanged call.
+ //if(patchView->selectedItem() != fc)
+ patchView->blockSignals(true);
+ fc->setSelected(true);
+ patchView->blockSignals(false);
+ //else
+ // patchChanged();
+
+ //patchView->firstChild()->setSelected(true);
+ //patchView->triggerUpdate(true);
+ }
+
+ patchChanged();
+
+// oldPatchItem = (ListViewData*)patchView->selectedItem();
+ //patchChanged();
+// if(oldPatchItem)
+// {
+// if(oldPatchItem->parent())
+// patchNameEdit->setText( ((Patch*)oldPatchItem->data())->name );
+// else
+// patchNameEdit->setText( ((PatchGroup*)oldPatchItem->data())->name );
+// }
+
+ //MidiControllerList* cl = instrument->controller();
+ MidiControllerList* cl = workingInstrument.controller();
+ for (ciMidiController ic = cl->begin(); ic != cl->end(); ++ic) {
+ MidiController* c = ic->second;
+ //QListWidgetItem* item = new QListWidgetItem(c->name());
+ // ListBoxData* item = new ListBoxData(c->name());
+ //QVariant v = QVariant::fromValue((void*)c);
+ //item->setData(Qt::UserRole, v);
+ // item->setData((void*)c);
+ // listController->insertItem(item);
+
+ addControllerToView(c);
+ }
+
+
+ //listController->setItemSelected(listController->item(0), true);
+
+// oldController = 0;
+
+ //ListBoxData* ci = (ListBoxData*)listController->item(0);
+
+ QTreeWidgetItem *ci = viewController->topLevelItem(0);
+
+ if(ci)
+ {
+ // This may cause a controllerChanged call.
+ //if(listController->selectedItem != ci)
+ // listController->blockSignals(true);
+ // listController->setSelected(ci, true);
+ // listController->blockSignals(false);
+ //else
+ // controllerChanged();
+
+ viewController->blockSignals(true);
+ ci->setSelected(true);
+ viewController->blockSignals(false);
+ }
+
+ controllerChanged();
+
+ //oldController = (ListBoxData*)listController->selectedItem();
+
+
+ //controllerChanged(listController->item(0), 0);
+ //controllerChanged();
+
+/*
+ category->addItems(instrument->categories());
+
+ foreach(const SysEx* s, instrument->sysex()) {
+ QListWidgetItem* item = new QListWidgetItem(s->name);
+ QVariant v = QVariant::fromValue((void*)s);
+ item->setData(Qt::UserRole, v);
+ sysexList->addItem(item);
+ }
+
+ sysexList->setItemSelected(sysexList->item(0), true);
+ sysexChanged(sysexList->item(0), 0);
+
+ if (!cl->empty()) {
+ listController->setItemSelected(listController->item(0), true);
+ controllerChanged(listController->item(0), 0);
+ }
+*/
+
+
+}
+
+//---------------------------------------------------------
+// instrumentChanged
+//---------------------------------------------------------
+
+void EditInstrument::instrumentChanged()
+ {
+ QListWidgetItem* sel = instrumentList->currentItem();
+
+ if(!sel)
+ return;
+
+ //printf("instrument changed: %s\n", sel->text().toLatin1().constData());
+
+ //if (old) {
+ //if(oldMidiInstrument)
+ //{
+ MidiInstrument* oi = 0;
+ if(oldMidiInstrument)
+ oi = (MidiInstrument*)oldMidiInstrument->data(Qt::UserRole).value<void*>();
+ MidiInstrument* wip = &workingInstrument;
+ // Returns true if aborted.
+ //checkDirty(oi);
+ //if(checkDirty(oi))
+ if(checkDirty(wip))
+ {
+ // No save was chosen. Abandon changes, or delete if it is new...
+ if(oi)
+ {
+ oldMidiInstrument->setText(oi->iname());
+ //wip->setText(oi->iname());
+
+ // No file path? Only a new unsaved instrument can do that. So delete it.
+ if(oi->filePath().isEmpty())
+ {
+ // Delete the list item and the instrument.
+ deleteInstrument(oldMidiInstrument);
+ oldMidiInstrument = 0;
+ }
+
+ }
+ }
+ //else
+ //{
+ // Save was chosen.
+ // if(oi)
+ // oi->assign(workingInstrument);
+ //}
+
+ //oi->setDirty(false);
+ //wip->setDirty(false);
+ workingInstrument.setDirty(false);
+ //}
+
+ changeInstrument();
+
+ }
+
+//---------------------------------------------------------
+// instrumentNameReturn
+//---------------------------------------------------------
+
+void EditInstrument::instrumentNameReturn()
+//void EditInstrument::instrumentNameChanged(const QString& s)
+{
+ //instrumentNameChanged(instrumentName->text());
+ QListWidgetItem* item = instrumentList->currentItem();
+
+ if (item == 0)
+ return;
+ QString s = instrumentName->text();
+
+ if(s == item->text())
+ return;
+
+ MidiInstrument* curins = (MidiInstrument*)item->data(Qt::UserRole).value<void*>();
+
+ for(iMidiInstrument i = midiInstruments.begin(); i != midiInstruments.end(); ++i)
+ {
+ if((*i) != curins && s == (*i)->iname())
+ {
+ instrumentName->blockSignals(true);
+ // Grab the last valid name from the item text, since the instrument has not been updated yet.
+ //instrumentName->setText(curins->iname());
+ instrumentName->setText(item->text());
+ instrumentName->blockSignals(false);
+
+ QMessageBox::critical(this,
+ tr("MusE: Bad instrument name"),
+ tr("Please choose a unique instrument name.\n(The name might be used by a hidden instrument.)"),
+ QMessageBox::Ok,
+ Qt::NoButton,
+ Qt::NoButton);
+
+ return;
+ }
+ }
+
+ //if (s != workingInstrument.iname()) {
+ item->setText(s);
+ //MidiInstrument* instrument = (MidiInstrument*)item->data(Qt::UserRole).value<void*>();
+ //MidiInstrument* instrument = (MidiInstrument*)item->data();
+ //instrument->setDirty(true);
+ workingInstrument.setIName(s);
+ workingInstrument.setDirty(true);
+ //instrumentList->updateItem(item);
+ //instrumentList->update();
+ // }
+}
+
+//---------------------------------------------------------
+// deleteInstrument
+//---------------------------------------------------------
+
+void EditInstrument::deleteInstrument(QListWidgetItem* item)
+{
+ if(!item)
+ return;
+
+ //ListBoxData* curritem = (ListBoxData*)instrumentList->selectedItem();
+
+ MidiInstrument* ins = (MidiInstrument*)item->data(Qt::UserRole).value<void*>();
+
+ // Be kind to the list item, just in case we install a delete handler or something.
+ //item->setData(0);
+
+ // Delete the list item.
+ // Test this: Is this going to change the current selection?
+ instrumentList->blockSignals(true);
+ delete item;
+ instrumentList->blockSignals(false);
+
+ // Test this: Neccessary?
+ // if(curritem)
+ // instrumentList->setCurrentItem(curritem);
+
+ if(!ins)
+ return;
+
+ // Remove the instrument from the list.
+ midiInstruments.remove(ins);
+
+ // Delete the instrument.
+ delete ins;
+}
+
+//---------------------------------------------------------
+// tabChanged
+// Added so that patch list is updated when switching tabs,
+// so that 'Program' default values and text are current in controller tab.
+//---------------------------------------------------------
+
+void EditInstrument::tabChanged(QWidget* w)
+{
+ if(!w)
+ return;
+
+ // If we're switching to the Patches tab, just ignore.
+ if(QString(w->objectName()) == QString("patchesTab"))
+ return;
+
+ if(oldPatchItem)
+ {
+ // Don't bother calling patchChanged, just update the patch or group.
+ if(oldPatchItem->QTreeWidgetItem::parent())
+ updatePatch(&workingInstrument, (Patch*)oldPatchItem->data(0, Qt::UserRole).value<void*>());
+ else
+ updatePatchGroup(&workingInstrument, (PatchGroup*)oldPatchItem->data(0, Qt::UserRole).value<void*>());
+ }
+
+ // We're still on the same item. No need to set oldPatchItem as in patchChanged...
+
+ // If we're switching to the Controller tab, update the default patch button text in case a patch changed...
+ if(QString(w->objectName()) == QString("controllerTab"))
+ {
+ QTreeWidgetItem* sel = viewController->currentItem();
+
+ if(!sel || !sel->data(0, Qt::UserRole).value<void*>())
+ return;
+
+ MidiController* c = (MidiController*)sel->data(0, Qt::UserRole).value<void*>();
+ MidiController::ControllerType type = midiControllerType(c->num());
+
+ // Grab the controller number from the actual values showing
+ // and set the patch button text.
+ if(type == MidiController::Program)
+ setDefaultPatchName(getDefaultPatchNumber());
+ }
+}
+
+//---------------------------------------------------------
+// patchNameReturn
+//---------------------------------------------------------
+
+void EditInstrument::patchNameReturn()
+{
+ QTreeWidgetItem* item = patchView->currentItem();
+
+ if (item == 0)
+ return;
+
+ QString s = patchNameEdit->text();
+
+ if(item->text(0) == s)
+ return;
+
+ PatchGroupList* pg = workingInstrument.groups();
+ for(iPatchGroup g = pg->begin(); g != pg->end(); ++g)
+ {
+ PatchGroup* pgp = *g;
+ // If the item has a parent, it's a patch item.
+ if(item->QTreeWidgetItem::parent())
+ {
+ Patch* curp = (Patch*)item->data(0, Qt::UserRole).value<void*>();
+ for(iPatch p = pgp->patches.begin(); p != pgp->patches.end(); ++p)
+ {
+ if((*p) != curp && (*p)->name == s)
+ {
+ patchNameEdit->blockSignals(true);
+ // Grab the last valid name from the item text, since the patch has not been updated yet.
+ //patchNameEdit->setText(curp->name);
+ patchNameEdit->setText(item->text(0));
+ patchNameEdit->blockSignals(false);
+
+ QMessageBox::critical(this,
+ tr("MusE: Bad patch name"),
+ tr("Please choose a unique patch name"),
+ QMessageBox::Ok,
+ Qt::NoButton,
+ Qt::NoButton);
+
+ return;
+ }
+ }
+ }
+ else
+ // The item has no parent. It's a patch group item.
+ {
+ PatchGroup* curpg = (PatchGroup*)item->data(0, Qt::UserRole).value<void*>();
+ if(pgp != curpg && pgp->name == s)
+ {
+ patchNameEdit->blockSignals(true);
+ // Grab the last valid name from the item text, since the patch group has not been updated yet.
+ //patchNameEdit->setText(curpg->name);
+ patchNameEdit->setText(item->text(0));
+ patchNameEdit->blockSignals(false);
+
+ QMessageBox::critical(this,
+ tr("MusE: Bad patchgroup name"),
+ tr("Please choose a unique patchgroup name"),
+ QMessageBox::Ok,
+ Qt::NoButton,
+ Qt::NoButton);
+
+ return;
+ }
+ }
+ }
+
+ item->setText(0, s);
+ workingInstrument.setDirty(true);
+
+ // Since the name of the patch/group in the working instrument will be updated later,
+ // there's no need to do manually set the name here now.
+ /*
+ // If the item has a parent, it's a patch item.
+ if(item->parent())
+ {
+ Patch* p = item->data();
+ if(s != p->name)
+ {
+ item->setText(s);
+ p->name = s;
+ workingInstrument.setDirty(true);
+ //patchView->triggerUpdate(true);
+ }
+ }
+ else
+ // The item has no parent. It's a patch group item.
+ {
+ PatchGroup* pg = (PatchGroup*)item->data();
+ if(s != pg->name)
+ {
+ item->setText(s);
+ pg->name = s;
+ workingInstrument.setDirty(true);
+ //patchView->triggerUpdate(true);
+ }
+ }
+ */
+}
+
+//---------------------------------------------------------
+// patchChanged
+//---------------------------------------------------------
+void EditInstrument::patchChanged()
+ {
+ //if (old && old->data(0, Qt::UserRole).value<void*>()) {
+ if(oldPatchItem)
+ {
+ //QListWidgetItem* item = instrumentList->currentItem();
+ //if (item == 0)
+ // return;
+ //MidiInstrument* instrument = (MidiInstrument*)item->data(Qt::UserRole).value<void*>();
+ //Patch* p = (Patch*)old->data(0, Qt::UserRole).value<void*>();
+ //updatePatch(instrument, p);
+ if(oldPatchItem->parent())
+ updatePatch(&workingInstrument, (Patch*)oldPatchItem->data(0, Qt::UserRole).value<void*>());
+ else
+ updatePatchGroup(&workingInstrument, (PatchGroup*)oldPatchItem->data(0, Qt::UserRole).value<void*>());
+ }
+
+ QTreeWidgetItem* sel = patchView->selectedItems().size() ? patchView->selectedItems()[0] : 0;
+ oldPatchItem = sel;
+
+ if(!sel || !sel->data(0, Qt::UserRole).value<void*>())
+ {
+ patchNameEdit->setText("");
+ spinBoxHBank->setEnabled(false);
+ spinBoxLBank->setEnabled(false);
+ spinBoxProgram->setEnabled(false);
+ checkBoxDrum->setEnabled(false);
+ checkBoxGM->setEnabled(false);
+ checkBoxGS->setEnabled(false);
+ checkBoxXG->setEnabled(false);
+ return;
+ }
+
+ // If the item has a parent, it's a patch item.
+ if(sel->parent())
+ {
+ Patch* p = (Patch*)sel->data(0, Qt::UserRole).value<void*>();
+ patchNameEdit->setText(p->name);
+ spinBoxHBank->setEnabled(true);
+ spinBoxLBank->setEnabled(true);
+ spinBoxProgram->setEnabled(true);
+ checkBoxDrum->setEnabled(true);
+ checkBoxGM->setEnabled(true);
+ checkBoxGS->setEnabled(true);
+ checkBoxXG->setEnabled(true);
+
+ int hb = ((p->hbank + 1) & 0xff);
+ int lb = ((p->lbank + 1) & 0xff);
+ int pr = ((p->prog + 1) & 0xff);
+ spinBoxHBank->setValue(hb);
+ spinBoxLBank->setValue(lb);
+ spinBoxProgram->setValue(pr);
+ //checkBoxDrum->setChecked(p->drumMap);
+ checkBoxDrum->setChecked(p->drum);
+ checkBoxGM->setChecked(p->typ & 1);
+ checkBoxGS->setChecked(p->typ & 2);
+ checkBoxXG->setChecked(p->typ & 4);
+ //category->setCurrentIndex(p->categorie);
+ }
+ else
+ // The item is a patch group item.
+ {
+ patchNameEdit->setText( ((PatchGroup*)sel->data(0, Qt::UserRole).value<void*>())->name );
+ spinBoxHBank->setEnabled(false);
+ spinBoxLBank->setEnabled(false);
+ spinBoxProgram->setEnabled(false);
+ checkBoxDrum->setEnabled(false);
+ checkBoxGM->setEnabled(false);
+ checkBoxGS->setEnabled(false);
+ checkBoxXG->setEnabled(false);
+ }
+ }
+
+//---------------------------------------------------------
+// defPatchChanged
+//---------------------------------------------------------
+
+void EditInstrument::defPatchChanged(int)
+{
+ QTreeWidgetItem* item = viewController->currentItem();
+
+ if (!item)
+ return;
+
+ MidiController* c = (MidiController*)item->data(0, Qt::UserRole).value<void*>();
+
+ int val = getDefaultPatchNumber();
+
+ //if(val == c->minVal() - 1)
+ // c->setInitVal(CTRL_VAL_UNKNOWN);
+ //else
+ c->setInitVal(val);
+
+ setDefaultPatchName(val);
+
+ item->setText(COL_DEF, getPatchItemText(val));
+ workingInstrument.setDirty(true);
+}
+
+//---------------------------------------------------------
+// patchButtonClicked
+//---------------------------------------------------------
+
+void EditInstrument::patchButtonClicked()
+{
+ //MidiTrack* track = (MidiTrack*)selected;
+ //int channel = track->outChannel();
+ //int port = track->outPort();
+ //MidiInstrument* instr = midiPorts[port].instrument();
+
+ //patchpopup->clear();
+
+ QMenu* patchpopup = new QMenu;
+
+ PatchGroupList* pg = workingInstrument.groups();
+
+ if (pg->size() > 1) {
+ for (ciPatchGroup i = pg->begin(); i != pg->end(); ++i) {
+ PatchGroup* pgp = *i;
+ QMenu* pm = patchpopup->addMenu(pgp->name);
+ //pm->setCheckable(false);//Qt4 doc says this is unnecessary
+ pm->setFont(config.fonts[0]);
+ const PatchList& pl = pgp->patches;
+ for (ciPatch ipl = pl.begin(); ipl != pl.end(); ++ipl) {
+ const Patch* mp = *ipl;
+ //if ((mp->typ & mask) &&
+ // ((drum && songType != MT_GM) ||
+ // (mp->drum == drumchan)) )
+
+ // {
+ int id = ((mp->hbank & 0xff) << 16)
+ + ((mp->lbank & 0xff) << 8) + (mp->prog & 0xff);
+ QAction *ac1 = pm->addAction(mp->name);
+ ac1->setData(id);
+ // }
+
+ }
+ }
+ }
+ else if (pg->size() == 1 ){
+ // no groups
+ const PatchList& pl = pg->front()->patches;
+ for (ciPatch ipl = pl.begin(); ipl != pl.end(); ++ipl) {
+ const Patch* mp = *ipl;
+ //if (mp->typ & mask) {
+ int id = ((mp->hbank & 0xff) << 16)
+ + ((mp->lbank & 0xff) << 8) + (mp->prog & 0xff);
+ QAction *ac2 = patchpopup->addAction(mp->name);
+ ac2->setData(id);
+ // }
+ }
+ }
+
+ if(patchpopup->actions().count() == 0)
+ {
+ delete patchpopup;
+ return;
+ }
+
+ QAction* act = patchpopup->exec(patchButton->mapToGlobal(QPoint(10,5)));
+ if(!act)
+ {
+ delete patchpopup;
+ return;
+ }
+
+ int rv = act->data().toInt();
+ delete patchpopup;
+
+ if (rv != -1)
+ {
+ //if(rv != workingInstrument.
+
+ setDefaultPatchControls(rv);
+
+ QTreeWidgetItem* item = viewController->currentItem();
+
+ if(item)
+ {
+ MidiController* c = (MidiController*)item->data(0, Qt::UserRole).value<void*>();
+ c->setInitVal(rv);
+
+ item->setText(COL_DEF, getPatchItemText(rv));
+ }
+ workingInstrument.setDirty(true);
+ }
+
+}
+
+//---------------------------------------------------------
+// addControllerToView
+//---------------------------------------------------------
+
+QTreeWidgetItem* EditInstrument::addControllerToView(MidiController* mctrl)
+{
+ QString hnum;
+ QString lnum;
+ QString min;
+ QString max;
+ QString def;
+ int defval = mctrl->initVal();
+ int n = mctrl->num();
+ //int h = (n >> 7) & 0x7f;
+ int h = (n >> 8) & 0x7f;
+ int l = n & 0x7f;
+ if((n & 0xff) == 0xff)
+ l = -1;
+
+ MidiController::ControllerType t = midiControllerType(n);
+ switch(t)
+ {
+ case MidiController::Controller7:
+ //case MidiController::RPN:
+ //case MidiController::NRPN:
+ hnum = "---";
+ if(l == -1)
+ lnum = "*";
+ else
+ lnum.setNum(l);
+ min.setNum(mctrl->minVal());
+ max.setNum(mctrl->maxVal());
+ if(defval == CTRL_VAL_UNKNOWN)
+ def = "---";
+ else
+ def.setNum(defval);
+ break;
+ case MidiController::RPN:
+ case MidiController::NRPN:
+ case MidiController::RPN14:
+ case MidiController::NRPN14:
+ case MidiController::Controller14:
+ hnum.setNum(h);
+ if(l == -1)
+ lnum = "*";
+ else
+ lnum.setNum(l);
+ min.setNum(mctrl->minVal());
+ max.setNum(mctrl->maxVal());
+ if(defval == CTRL_VAL_UNKNOWN)
+ def = "---";
+ else
+ def.setNum(defval);
+ break;
+ case MidiController::Pitch:
+ hnum = "---";
+ lnum = "---";
+ min.setNum(mctrl->minVal());
+ max.setNum(mctrl->maxVal());
+ if(defval == CTRL_VAL_UNKNOWN)
+ def = "---";
+ else
+ def.setNum(defval);
+ break;
+ case MidiController::Program:
+ hnum = "---";
+ lnum = "---";
+ min = "---";
+ max = "---";
+ def = getPatchItemText(defval);
+ break;
+
+ default:
+ hnum = "---";
+ lnum = "---";
+ //min.setNum(0);
+ //max.setNum(0);
+ min = "---";
+ max = "---";
+ def = "---";
+ break;
+ }
+
+ QTreeWidgetItem* ci = new QTreeWidgetItem(viewController, QStringList() << mctrl->name() << int2ctrlType(t) << hnum << lnum << min << max << def);
+ //ListViewData* ci = new ListViewData(viewController, mctrl->name(), int2ctrlType(t),
+ // hnum, lnum, min, max, def);
+ //ci->setData((void*)mctrl);
+ QVariant v = qVariantFromValue((void*)(mctrl));
+ ci->setData(0, Qt::UserRole, v);
+ //setModified(true);
+
+ return ci;
+}
+
+//---------------------------------------------------------
+// controllerChanged
+//---------------------------------------------------------
+
+void EditInstrument::controllerChanged()
+ {
+ //if (old) {
+// if(oldController)
+// {
+ //QListWidgetItem* item = instrumentList->currentItem();
+ //if (item == 0)
+ // return;
+ //MidiInstrument* instrument = (MidiInstrument*)item->data(Qt::UserRole).value<void*>();
+ //MidiController* oc = (MidiController*)old->data(Qt::UserRole).value<void*>();
+ //updateController(instrument, oc);
+// updateController(&workingInstrument, (MidiController*)oldController->data());
+// }
+
+ // ListBoxData* sel = (ListBoxData*)listController->selectedItem();
+
+ QTreeWidgetItem* sel = viewController->selectedItems().size() ? viewController->selectedItems()[0] : 0;
+// oldController = sel;
+
+ if(!sel || !sel->data(0, Qt::UserRole).value<void*>())
+ {
+ ctrlName->blockSignals(true);
+ ctrlName->setText("");
+ ctrlName->blockSignals(false);
+ //ctrlComment->setText("");
+ return;
+ }
+
+ MidiController* c = (MidiController*)sel->data(0, Qt::UserRole).value<void*>();
+
+ ctrlName->blockSignals(true);
+ ctrlName->setText(c->name());
+ ctrlName->blockSignals(false);
+
+ //ctrlComment->setText(c->comment());
+ int ctrlH = (c->num() >> 8) & 0x7f;
+ int ctrlL = c->num() & 0x7f;
+ if((c->num() & 0xff) == 0xff)
+ ctrlL = -1;
+
+ //int type = int(c->type());
+ MidiController::ControllerType type = midiControllerType(c->num());
+
+ //ctrlType->setCurrentIndex(type);
+ ctrlType->blockSignals(true);
+ ctrlType->setCurrentIndex(type);
+ ctrlType->blockSignals(false);
+
+ //ctrlTypeChanged(type);
+
+ spinBoxHCtrlNo->blockSignals(true);
+ spinBoxLCtrlNo->blockSignals(true);
+ spinBoxMin->blockSignals(true);
+ spinBoxMax->blockSignals(true);
+ spinBoxDefault->blockSignals(true);
+
+ //ctrlTypeChanged(type);
+
+ switch (type) {
+ //case MidiController::RPN:
+ //case MidiController::NRPN:
+ case MidiController::Controller7:
+ spinBoxHCtrlNo->setEnabled(false);
+ spinBoxLCtrlNo->setEnabled(true);
+ spinBoxHCtrlNo->setValue(0);
+ spinBoxLCtrlNo->setValue(ctrlL);
+ spinBoxMin->setEnabled(true);
+ spinBoxMax->setEnabled(true);
+ spinBoxMin->setRange(-128, 127);
+ spinBoxMax->setRange(-128, 127);
+ spinBoxMin->setValue(c->minVal());
+ spinBoxMax->setValue(c->maxVal());
+ enableDefaultControls(true, false);
+ break;
+ case MidiController::RPN:
+ case MidiController::NRPN:
+ spinBoxHCtrlNo->setEnabled(true);
+ spinBoxLCtrlNo->setEnabled(true);
+ spinBoxHCtrlNo->setValue(ctrlH);
+ spinBoxLCtrlNo->setValue(ctrlL);
+ spinBoxMin->setEnabled(true);
+ spinBoxMax->setEnabled(true);
+ spinBoxMin->setRange(-128, 127);
+ spinBoxMax->setRange(-128, 127);
+ spinBoxMin->setValue(c->minVal());
+ spinBoxMax->setValue(c->maxVal());
+ enableDefaultControls(true, false);
+ break;
+ case MidiController::Controller14:
+ case MidiController::RPN14:
+ case MidiController::NRPN14:
+ spinBoxHCtrlNo->setEnabled(true);
+ spinBoxLCtrlNo->setEnabled(true);
+ spinBoxHCtrlNo->setValue(ctrlH);
+ spinBoxLCtrlNo->setValue(ctrlL);
+ spinBoxMin->setEnabled(true);
+ spinBoxMax->setEnabled(true);
+ spinBoxMin->setRange(-16384, 16383);
+ spinBoxMax->setRange(-16384, 16383);
+ spinBoxMin->setValue(c->minVal());
+ spinBoxMax->setValue(c->maxVal());
+ enableDefaultControls(true, false);
+ break;
+ case MidiController::Pitch:
+ spinBoxHCtrlNo->setEnabled(false);
+ spinBoxLCtrlNo->setEnabled(false);
+ spinBoxHCtrlNo->setValue(0);
+ spinBoxLCtrlNo->setValue(0);
+ spinBoxMin->setEnabled(true);
+ spinBoxMax->setEnabled(true);
+ spinBoxMin->setRange(-8192, 8191);
+ spinBoxMax->setRange(-8192, 8191);
+ spinBoxMin->setValue(c->minVal());
+ spinBoxMax->setValue(c->maxVal());
+ enableDefaultControls(true, false);
+ break;
+ case MidiController::Program:
+ spinBoxHCtrlNo->setEnabled(false);
+ spinBoxLCtrlNo->setEnabled(false);
+ spinBoxHCtrlNo->setValue(0);
+ spinBoxLCtrlNo->setValue(0);
+ spinBoxMin->setEnabled(false);
+ spinBoxMax->setEnabled(false);
+ spinBoxMin->setRange(0, 0);
+ spinBoxMax->setRange(0, 0);
+ spinBoxMin->setValue(0);
+ spinBoxMax->setValue(0);
+ enableDefaultControls(false, true);
+ break;
+ default:
+ spinBoxHCtrlNo->setEnabled(false);
+ spinBoxLCtrlNo->setEnabled(false);
+ spinBoxMin->setEnabled(false);
+ spinBoxMax->setEnabled(false);
+ enableDefaultControls(false, false);
+ break;
+ }
+
+ if(type == MidiController::Program)
+ {
+ spinBoxDefault->setRange(0, 0);
+ spinBoxDefault->setValue(0);
+ setDefaultPatchControls(c->initVal());
+ }
+ else
+ {
+ spinBoxDefault->setRange(c->minVal() - 1, c->maxVal());
+ if(c->initVal() == CTRL_VAL_UNKNOWN)
+ //spinBoxDefault->setValue(c->minVal() - 1);
+ spinBoxDefault->setValue(spinBoxDefault->minimum());
+ else
+ spinBoxDefault->setValue(c->initVal());
+ }
+
+ //moveWithPart->setChecked(c->moveWithPart());
+
+ spinBoxHCtrlNo->blockSignals(false);
+ spinBoxLCtrlNo->blockSignals(false);
+ spinBoxMin->blockSignals(false);
+ spinBoxMax->blockSignals(false);
+ spinBoxDefault->blockSignals(false);
+ }
+
+//---------------------------------------------------------
+// ctrlNameReturn
+//---------------------------------------------------------
+
+void EditInstrument::ctrlNameReturn()
+//void EditInstrument::ctrlNameChanged(const QString& s)
+{
+ QTreeWidgetItem* item = viewController->currentItem();
+
+ if (item == 0)
+ return;
+ MidiController* c = (MidiController*)item->data(0, Qt::UserRole).value<void*>();
+
+ QString cName = ctrlName->text();
+
+ if(c->name() == cName)
+ return;
+
+ //MidiControllerList* cl = instrument->controller();
+ MidiControllerList* cl = workingInstrument.controller();
+ for(ciMidiController ic = cl->begin(); ic != cl->end(); ++ic)
+ {
+ MidiController* mc = ic->second;
+ if(mc != c && mc->name() == cName)
+ {
+ ctrlName->blockSignals(true);
+ ctrlName->setText(c->name());
+ ctrlName->blockSignals(false);
+
+ QMessageBox::critical(this,
+ tr("MusE: Bad controller name"),
+ tr("Please choose a unique controller name"),
+ QMessageBox::Ok,
+ Qt::NoButton,
+ Qt::NoButton);
+
+ return;
+ }
+ }
+
+ c->setName(ctrlName->text());
+ item->setText(COL_NAME, ctrlName->text());
+ //c->setName(s);
+ //item->setText(COL_NAME, s);
+ workingInstrument.setDirty(true);
+}
+
+//---------------------------------------------------------
+// ctrlTypeChanged
+//---------------------------------------------------------
+
+void EditInstrument::ctrlTypeChanged(int idx)
+ {
+ QTreeWidgetItem* item = viewController->currentItem();
+
+ if (item == 0)
+ return;
+
+ MidiController::ControllerType t = (MidiController::ControllerType)idx;
+ MidiController* c = (MidiController*)item->data(0, Qt::UserRole).value<void*>();
+ if(t == midiControllerType(c->num()))
+ return;
+
+ //if(item)
+ item->setText(COL_TYPE, ctrlType->currentText());
+
+ int hnum = 0, lnum = 0;
+ //int rng = 0;
+ //int min = 0, max = 0;
+
+ spinBoxMin->blockSignals(true);
+ spinBoxMax->blockSignals(true);
+ spinBoxDefault->blockSignals(true);
+
+ switch (t) {
+ //case MidiController::RPN:
+ //case MidiController::NRPN:
+ case MidiController::Controller7:
+ spinBoxHCtrlNo->setEnabled(false);
+ spinBoxLCtrlNo->setEnabled(true);
+ spinBoxMin->setEnabled(true);
+ spinBoxMax->setEnabled(true);
+ enableDefaultControls(true, false);
+ spinBoxMin->setRange(-128, 127);
+ spinBoxMax->setRange(-128, 127);
+
+ spinBoxMin->setValue(0);
+ spinBoxMax->setValue(127);
+ spinBoxDefault->setRange(spinBoxMin->value() - 1, spinBoxMax->value());
+
+ spinBoxDefault->setValue(spinBoxDefault->minimum());
+ lnum = spinBoxLCtrlNo->value();
+ //rng = 127;
+ //min = -128;
+ //max = 127;
+ //if(item)
+ //{
+ //item->setText(COL_LNUM, QString().setNum(spinBoxLCtrlNo->value()));
+ if(lnum == -1)
+ item->setText(COL_LNUM, QString("*"));
+ else
+ item->setText(COL_LNUM, QString().setNum(lnum));
+ item->setText(COL_HNUM, QString("---"));
+ item->setText(COL_MIN, QString().setNum(spinBoxMin->value()));
+ item->setText(COL_MAX, QString().setNum(spinBoxMax->value()));
+ item->setText(COL_DEF, QString("---"));
+ //}
+ break;
+ case MidiController::RPN:
+ case MidiController::NRPN:
+ spinBoxHCtrlNo->setEnabled(true);
+ spinBoxLCtrlNo->setEnabled(true);
+ spinBoxMin->setEnabled(true);
+ spinBoxMax->setEnabled(true);
+ enableDefaultControls(true, false);
+ spinBoxMin->setRange(-128, 127);
+ spinBoxMax->setRange(-128, 127);
+
+ spinBoxMin->setValue(0);
+ spinBoxMax->setValue(127);
+ spinBoxDefault->setRange(spinBoxMin->value() - 1, spinBoxMax->value());
+ spinBoxDefault->setValue(spinBoxDefault->minimum());
+
+ hnum = spinBoxHCtrlNo->value();
+ lnum = spinBoxLCtrlNo->value();
+ //rng = 127;
+ //min = -128;
+ //max = 127;
+ //if(item)
+ //{
+ //item->setText(COL_LNUM, QString().setNum(spinBoxLCtrlNo->value()));
+ //item->setText(COL_HNUM, QString().setNum(spinBoxHCtrlNo->value()));
+ if(lnum == -1)
+ item->setText(COL_LNUM, QString("*"));
+ else
+ item->setText(COL_LNUM, QString().setNum(lnum));
+ item->setText(COL_HNUM, QString().setNum(hnum));
+ item->setText(COL_MIN, QString().setNum(spinBoxMin->value()));
+ item->setText(COL_MAX, QString().setNum(spinBoxMax->value()));
+ item->setText(COL_DEF, QString("---"));
+ //}
+ break;
+ case MidiController::Controller14:
+ case MidiController::RPN14:
+ case MidiController::NRPN14:
+ spinBoxHCtrlNo->setEnabled(true);
+ spinBoxLCtrlNo->setEnabled(true);
+ spinBoxMin->setEnabled(true);
+ spinBoxMax->setEnabled(true);
+ enableDefaultControls(true, false);
+ spinBoxMin->setRange(-16384, 16383);
+ spinBoxMax->setRange(-16384, 16383);
+
+ spinBoxMin->setValue(0);
+ spinBoxMax->setValue(16383);
+ spinBoxDefault->setRange(spinBoxMin->value() - 1, spinBoxMax->value());
+ spinBoxDefault->setValue(spinBoxDefault->minimum());
+
+ hnum = spinBoxHCtrlNo->value();
+ lnum = spinBoxLCtrlNo->value();
+ //rng = 16383;
+ //min = -16384;
+ //max = 16383;
+ //if(item)
+ //{
+ //item->setText(COL_LNUM, QString().setNum(spinBoxLCtrlNo->value()));
+ //item->setText(COL_HNUM, QString().setNum(spinBoxHCtrlNo->value()));
+ if(lnum == -1)
+ item->setText(COL_LNUM, QString("*"));
+ else
+ item->setText(COL_LNUM, QString().setNum(lnum));
+ item->setText(COL_HNUM, QString().setNum(hnum));
+ item->setText(COL_MIN, QString().setNum(spinBoxMin->value()));
+ item->setText(COL_MAX, QString().setNum(spinBoxMax->value()));
+ item->setText(COL_DEF, QString("---"));
+ //}
+ break;
+ case MidiController::Pitch:
+ spinBoxHCtrlNo->setEnabled(false);
+ spinBoxLCtrlNo->setEnabled(false);
+ spinBoxMin->setEnabled(true);
+ spinBoxMax->setEnabled(true);
+ enableDefaultControls(true, false);
+ spinBoxMin->setRange(-8192, 8191);
+ spinBoxMax->setRange(-8192, 8191);
+
+ spinBoxMin->setValue(-8192);
+ spinBoxMax->setValue(8191);
+ spinBoxDefault->setRange(spinBoxMin->value() - 1, spinBoxMax->value());
+ spinBoxDefault->setValue(spinBoxDefault->minimum());
+
+ //rng = 8191;
+ //min = -8192;
+ //max = 8191;
+ //if(item)
+ //{
+ item->setText(COL_LNUM, QString("---"));
+ item->setText(COL_HNUM, QString("---"));
+ item->setText(COL_MIN, QString().setNum(spinBoxMin->value()));
+ item->setText(COL_MAX, QString().setNum(spinBoxMax->value()));
+ item->setText(COL_DEF, QString("---"));
+ //}
+ break;
+ case MidiController::Program:
+ spinBoxHCtrlNo->setEnabled(false);
+ spinBoxLCtrlNo->setEnabled(false);
+ spinBoxMin->setEnabled(false);
+ spinBoxMax->setEnabled(false);
+ enableDefaultControls(false, true);
+ spinBoxMin->setRange(0, 0);
+ spinBoxMax->setRange(0, 0);
+
+ spinBoxMin->setValue(0);
+ spinBoxMax->setValue(0);
+ spinBoxDefault->setRange(0, 0);
+ spinBoxDefault->setValue(0);
+
+ //if(item)
+ //{
+ item->setText(COL_LNUM, QString("---"));
+ item->setText(COL_HNUM, QString("---"));
+ item->setText(COL_MIN, QString("---"));
+ item->setText(COL_MAX, QString("---"));
+
+ //item->setText(COL_DEF, QString("0-0-0"));
+ item->setText(COL_DEF, QString("---"));
+ //}
+ break;
+ // Shouldn't happen...
+ default:
+ spinBoxHCtrlNo->setEnabled(false);
+ spinBoxLCtrlNo->setEnabled(false);
+ spinBoxMin->setEnabled(false);
+ spinBoxMax->setEnabled(false);
+ enableDefaultControls(false, false);
+
+ spinBoxMin->blockSignals(false);
+ spinBoxMax->blockSignals(false);
+ return;
+
+ break;
+ }
+
+ spinBoxMin->blockSignals(false);
+ spinBoxMax->blockSignals(false);
+ spinBoxDefault->blockSignals(false);
+
+ c->setNum(MidiController::genNum(t, hnum, lnum));
+
+ setDefaultPatchControls(0xffffff);
+ if(t == MidiController::Program)
+ {
+ c->setMinVal(0);
+ c->setMaxVal(0xffffff);
+ c->setInitVal(0xffffff);
+ }
+ else
+ {
+ c->setMinVal(spinBoxMin->value());
+ c->setMaxVal(spinBoxMax->value());
+ if(spinBoxDefault->value() == spinBoxDefault->minimum())
+ c->setInitVal(CTRL_VAL_UNKNOWN);
+ else
+ c->setInitVal(spinBoxDefault->value());
+ }
+
+
+ /*
+
+ if(rng != 0)
+ {
+ int mn = c->minVal();
+ int mx = c->maxVal();
+ //if(val > item->text(COL_MAX).toInt())
+ if(mx > max)
+ {
+ c->setMaxVal(max);
+ spinBoxMax->blockSignals(true);
+ spinBoxMax->setValue(max);
+ spinBoxMax->blockSignals(false);
+ if(item)
+ item->setText(COL_MAX, QString().setNum(max));
+ }
+ //else
+ if(mn < min)
+ {
+ c->setMinVal(min);
+ spinBoxMin->blockSignals(true);
+ spinBoxMin->setValue(min);
+ spinBoxMin->blockSignals(false);
+ if(item)
+ item->setText(COL_MIN, QString().setNum(min));
+ }
+ //else
+ if(mx - mn > rng)
+ {
+ //mx = val + rng;
+ c->setMinVal(0);
+ c->setMaxVal(rng);
+ spinBoxMin->blockSignals(true);
+ spinBoxMax->blockSignals(true);
+ spinBoxMin->setValue(0);
+ spinBoxMax->setValue(rng);
+ spinBoxMin->blockSignals(false);
+ spinBoxMax->blockSignals(false);
+ if(item)
+ {
+ item->setText(COL_MIN, QString().setNum(0));
+ item->setText(COL_MAX, QString().setNum(rng));
+ }
+ }
+
+ spinBoxDefault->blockSignals(true);
+
+ spinBoxDefault->setRange(spinBoxMin->value() - 1, spinBoxMax->value());
+ int inval = c->initVal();
+ if(inval == CTRL_VAL_UNKNOWN)
+ spinBoxDefault->setValue(spinBoxDefault->minimum());
+ else
+ {
+ if(inval < c->minVal())
+ {
+ c->setInitVal(c->minVal());
+ spinBoxDefault->setValue(c->minVal());
+ }
+ else
+ if(inval > c->maxVal())
+ {
+ c->setInitVal(c->maxVal());
+ spinBoxDefault->setValue(c->maxVal());
+ }
+ }
+
+ //spinBoxDefault->setRange(c->minVal() - 1, c->maxVal());
+ spinBoxDefault->blockSignals(false);
+
+ }
+
+ */
+
+ workingInstrument.setDirty(true);
+ }
+
+//---------------------------------------------------------
+// ctrlHNumChanged
+//---------------------------------------------------------
+
+void EditInstrument::ctrlHNumChanged(int val)
+ {
+ QTreeWidgetItem* item = viewController->currentItem();
+
+ if (item == 0)
+ return;
+ QString s;
+ s.setNum(val);
+ MidiController* c = (MidiController*)item->data(0, Qt::UserRole).value<void*>();
+ //int n = c->num() & 0xff;
+ int n = c->num() & 0x7fff00ff;
+ c->setNum(n | ((val & 0xff) << 8));
+ item->setText(COL_HNUM, s);
+ workingInstrument.setDirty(true);
+ }
+
+//---------------------------------------------------------
+// ctrlLNumChanged
+//---------------------------------------------------------
+
+void EditInstrument::ctrlLNumChanged(int val)
+ {
+ QTreeWidgetItem* item = viewController->currentItem();
+
+ if (item == 0)
+ return;
+ MidiController* c = (MidiController*)item->data(0, Qt::UserRole).value<void*>();
+ //int n = c->num() & 0xff00;
+ int n = c->num() & ~0xff;
+ c->setNum(n | (val & 0xff));
+ if(val == -1)
+ item->setText(COL_LNUM, QString("*"));
+ else
+ {
+ QString s;
+ s.setNum(val);
+ item->setText(COL_LNUM, s);
+ }
+ workingInstrument.setDirty(true);
+ }
+
+//---------------------------------------------------------
+// ctrlMinChanged
+//---------------------------------------------------------
+
+void EditInstrument::ctrlMinChanged(int val)
+{
+ QTreeWidgetItem* item = viewController->currentItem();
+
+ if (item == 0)
+ return;
+
+ QString s;
+ s.setNum(val);
+ item->setText(COL_MIN, s);
+
+ MidiController* c = (MidiController*)item->data(0, Qt::UserRole).value<void*>();
+ c->setMinVal(val);
+
+ int rng = 0;
+ //switch((MidiController::ControllerType)ctrlType->currentItem())
+ switch(midiControllerType(c->num()))
+ {
+ case MidiController::Controller7:
+ case MidiController::RPN:
+ case MidiController::NRPN:
+ rng = 127;
+ break;
+ case MidiController::Controller14:
+ case MidiController::RPN14:
+ case MidiController::NRPN14:
+ case MidiController::Pitch:
+ rng = 16383;
+ break;
+ default:
+ break;
+ }
+
+ int mx = c->maxVal();
+
+ //if(val > item->text(COL_MAX).toInt())
+ if(val > mx)
+ {
+ c->setMaxVal(val);
+ spinBoxMax->blockSignals(true);
+ spinBoxMax->setValue(val);
+ spinBoxMax->blockSignals(false);
+ item->setText(COL_MAX, s);
+ }
+ else
+ if(mx - val > rng)
+ {
+ mx = val + rng;
+ c->setMaxVal(mx);
+ spinBoxMax->blockSignals(true);
+ spinBoxMax->setValue(mx);
+ spinBoxMax->blockSignals(false);
+ item->setText(COL_MAX, QString().setNum(mx));
+ }
+
+ spinBoxDefault->blockSignals(true);
+
+ spinBoxDefault->setRange(spinBoxMin->value() - 1, spinBoxMax->value());
+
+ int inval = c->initVal();
+ if(inval == CTRL_VAL_UNKNOWN)
+ spinBoxDefault->setValue(spinBoxDefault->minimum());
+ else
+ {
+ if(inval < c->minVal())
+ {
+ c->setInitVal(c->minVal());
+ spinBoxDefault->setValue(c->minVal());
+ }
+ else
+ if(inval > c->maxVal())
+ {
+ c->setInitVal(c->maxVal());
+ spinBoxDefault->setValue(c->maxVal());
+ }
+ }
+
+ spinBoxDefault->blockSignals(false);
+
+ workingInstrument.setDirty(true);
+}
+
+//---------------------------------------------------------
+// ctrlMaxChanged
+//---------------------------------------------------------
+
+void EditInstrument::ctrlMaxChanged(int val)
+{
+ QTreeWidgetItem* item = viewController->currentItem();
+
+ if (item == 0)
+ return;
+
+ QString s;
+ s.setNum(val);
+ item->setText(COL_MAX, s);
+
+ MidiController* c = (MidiController*)item->data(0, Qt::UserRole).value<void*>();
+ c->setMaxVal(val);
+
+ int rng = 0;
+ //switch((MidiController::ControllerType)ctrlType->currentItem())
+ switch(midiControllerType(c->num()))
+ {
+ case MidiController::Controller7:
+ case MidiController::RPN:
+ case MidiController::NRPN:
+ rng = 127;
+ break;
+ case MidiController::Controller14:
+ case MidiController::RPN14:
+ case MidiController::NRPN14:
+ case MidiController::Pitch:
+ rng = 16383;
+ break;
+ default:
+ break;
+ }
+
+ int mn = c->minVal();
+
+ //if(val < item->text(COL_MIN).toInt())
+ if(val < mn)
+ {
+ c->setMinVal(val);
+ spinBoxMin->blockSignals(true);
+ spinBoxMin->setValue(val);
+ spinBoxMin->blockSignals(false);
+ item->setText(COL_MIN, s);
+ }
+ else
+ if(val - mn > rng)
+ {
+ mn = val - rng;
+ c->setMinVal(mn);
+ spinBoxMin->blockSignals(true);
+ spinBoxMin->setValue(mn);
+ spinBoxMin->blockSignals(false);
+ item->setText(COL_MIN, QString().setNum(mn));
+ }
+
+ spinBoxDefault->blockSignals(true);
+
+ spinBoxDefault->setRange(spinBoxMin->value() - 1, spinBoxMax->value());
+
+ int inval = c->initVal();
+ if(inval == CTRL_VAL_UNKNOWN)
+ spinBoxDefault->setValue(spinBoxDefault->minimum());
+ else
+ {
+ if(inval < c->minVal())
+ {
+ c->setInitVal(c->minVal());
+ spinBoxDefault->setValue(c->minVal());
+ }
+ else
+ if(inval > c->maxVal())
+ {
+ c->setInitVal(c->maxVal());
+ spinBoxDefault->setValue(c->maxVal());
+ }
+ }
+
+ spinBoxDefault->blockSignals(false);
+
+ workingInstrument.setDirty(true);
+}
+
+//---------------------------------------------------------
+// ctrlDefaultChanged
+//---------------------------------------------------------
+
+void EditInstrument::ctrlDefaultChanged(int val)
+{
+ QTreeWidgetItem* item = viewController->currentItem();
+
+ if (item == 0)
+ return;
+
+ MidiController* c = (MidiController*)item->data(0, Qt::UserRole).value<void*>();
+
+ if(val == c->minVal() - 1)
+ {
+ c->setInitVal(CTRL_VAL_UNKNOWN);
+ item->setText(COL_DEF, QString("---"));
+ }
+ else
+ {
+ c->setInitVal(val);
+ item->setText(COL_DEF, QString().setNum(val));
+ }
+ workingInstrument.setDirty(true);
+}
+
+//---------------------------------------------------------
+// ctrlNullParamHChanged
+//---------------------------------------------------------
+
+void EditInstrument::ctrlNullParamHChanged(int nvh)
+{
+ int nvl = nullParamSpinBoxL->value();
+ if(nvh == -1)
+ {
+ nullParamSpinBoxL->blockSignals(true);
+ nullParamSpinBoxL->setValue(-1);
+ nullParamSpinBoxL->blockSignals(false);
+ nvl = -1;
+ }
+ else
+ {
+ if(nvl == -1)
+ {
+ nullParamSpinBoxL->blockSignals(true);
+ nullParamSpinBoxL->setValue(0);
+ nullParamSpinBoxL->blockSignals(false);
+ nvl = 0;
+ }
+ }
+ if(nvh == -1 && nvl == -1)
+ workingInstrument.setNullSendValue(-1);
+ else
+ workingInstrument.setNullSendValue((nvh << 8) | nvl);
+ workingInstrument.setDirty(true);
+}
+
+//---------------------------------------------------------
+// ctrlNullParamLChanged
+//---------------------------------------------------------
+
+void EditInstrument::ctrlNullParamLChanged(int nvl)
+{
+ int nvh = nullParamSpinBoxH->value();
+ if(nvl == -1)
+ {
+ nullParamSpinBoxH->blockSignals(true);
+ nullParamSpinBoxH->setValue(-1);
+ nullParamSpinBoxH->blockSignals(false);
+ nvh = -1;
+ }
+ else
+ {
+ if(nvh == -1)
+ {
+ nullParamSpinBoxH->blockSignals(true);
+ nullParamSpinBoxH->setValue(0);
+ nullParamSpinBoxH->blockSignals(false);
+ nvh = 0;
+ }
+ }
+ if(nvh == -1 && nvl == -1)
+ workingInstrument.setNullSendValue(-1);
+ else
+ workingInstrument.setNullSendValue((nvh << 8) | nvl);
+ workingInstrument.setDirty(true);
+}
+
+//---------------------------------------------------------
+// deletePatchClicked
+//---------------------------------------------------------
+
+void EditInstrument::deletePatchClicked()
+ {
+ //QListWidgetItem* item = instrumentList->currentItem();
+// ListBoxData* item = (ListBoxData*)instrumentList->selectedItem();
+// if (item == 0)
+// return;
+ //MidiInstrument* instrument = (MidiInstrument*)item->data(Qt::UserRole).value<void*>();
+// MidiInstrument* instrument = (MidiInstrument*)item->data();
+ //QTreeWidgetItem* pi = patchView->currentItem();
+ QTreeWidgetItem* pi = patchView->currentItem();
+
+ if (pi == 0)
+ return;
+
+ //void* p = pi->data(0, Qt::UserRole).value<void*>();
+// Patch* patch = (Patch*)pi->data();
+ //if (p == 0)
+ // If patch is zero it's a patch group.
+// if(patch == 0)
+
+ // If the item has a parent item, it's a patch item...
+ if(pi->parent())
+ {
+ PatchGroup* group = (PatchGroup*)(pi->parent())->data(0, Qt::UserRole).value<void*>();
+
+ // If there is an allocated patch in the data, delete it.
+ //Patch* patch = (Patch*)pi->auxData();
+ Patch* patch = (Patch*)pi->data(0, Qt::UserRole).value<void*>();
+ if(patch)
+ {
+ if(group)
+ {
+ //for(iPatch ip = group->patches.begin(); ip != group->patches.end(); ++ip)
+ // if(&*ip == patch)
+ // if(*ip == patch)
+ // {
+ //
+ // printf("deletePatchClicked: erasing patch\n");
+ //
+ // group->patches.erase(ip);
+ // break;
+ // }
+ //group->patches.remove( (const Patch&)(*patch) );
+ group->patches.remove(patch);
+ }
+ delete patch;
+ }
+ }
+ else
+ // The item has no parent item, it's a patch group item...
+ {
+ // Is there an allocated patch group in the data?
+ //PatchGroup* group = (PatchGroup*)pi->auxData();
+ PatchGroup* group = (PatchGroup*)pi->data(0, Qt::UserRole).value<void*>();
+ if(group)
+ {
+
+ PatchGroupList* pg = workingInstrument.groups();
+ //for(ciPatchGroup ipg = pg->begin(); ipg != pg->end(); ++ipg)
+ for(iPatchGroup ipg = pg->begin(); ipg != pg->end(); ++ipg)
+ {
+
+ //printf("deletePatchClicked: working patch group name:%s ad:%X group name:%s ad:%X\n", (*ipg)->name.toLatin1().constData(), (unsigned int)(*ipg), group->name.toLatin1().constData(), (unsigned int) group);
+
+ //if(&*ipg == group)
+ if(*ipg == group)
+ {
+ pg->erase(ipg);
+ break;
+ }
+ }
+
+ // Iterate all child list view (patch) items. Find and delete any allocated patches in the items' data.
+// for(ListViewData* i = (ListViewData*)pi->firstChild(); i; i = (ListViewData*)i->nextSibling())
+// {
+ //Patch* patch = (Patch*)i->auxData();
+// Patch* patch = (Patch*)i->data();
+// if(patch)
+// {
+ //delete patch;
+ //group->patches.remove(*patch);
+ const PatchList& pl = group->patches;
+ for(ciPatch ip = pl.begin(); ip != pl.end(); ++ip)
+ {
+// if(&*ip == patch)
+// {
+// group->patches.erase(ip);
+// break;
+// }
+
+ // Delete the patch.
+ if(*ip)
+ delete *ip;
+ }
+
+ //group->patches.clear();
+
+// }
+// }
+
+ // Now delete the group.
+ delete group;
+
+ }
+ }
+
+ //oldPatchItem = (ListViewData*)patchView->selectedItem();
+ //oldPatchItem = 0;
+
+ // Now delete the patch or group item (and any child patch items) from the list view tree.
+ // !!! This will trigger a patchChanged call.
+ patchView->blockSignals(true);
+ delete pi;
+ if(patchView->currentItem())
+ patchView->currentItem()->setSelected(true);
+ patchView->blockSignals(false);
+
+ oldPatchItem = 0;
+ patchChanged();
+
+ //Patch* patch = (Patch*)p;
+
+ //std::vector<PatchGroup>* pg = instrument->groups();
+ //for (std::vector<PatchGroup>::iterator g = pg->begin(); g != pg->end(); ++g) {
+ // for (iPatch p = g->patches.begin(); p != g->patches.end(); ++p) {
+ // if (patch == *p) {
+ // g->patches.erase(p);
+ // delete pi;
+ // instrument->setDirty(true);
+ // return;
+ // }
+ // }
+ // }
+ //printf("fatal: patch not found\n");
+ //delete patch;
+ //delete pi;
+
+
+ workingInstrument.setDirty(true);
+ }
+
+//---------------------------------------------------------
+// newPatchClicked
+//---------------------------------------------------------
+
+void EditInstrument::newPatchClicked()
+ {
+ //QListWidgetItem* item = instrumentList->currentItem();
+// ListBoxData* item = (ListBoxData*)instrumentList->selectedItem();
+// if (item == 0)
+// return;
+
+ if(oldPatchItem)
+ {
+ if(oldPatchItem->parent())
+ updatePatch(&workingInstrument, (Patch*)oldPatchItem->data(0, Qt::UserRole).value<void*>());
+ else
+ updatePatchGroup(&workingInstrument, (PatchGroup*)oldPatchItem->data(0, Qt::UserRole).value<void*>());
+ }
+
+ //MidiInstrument* instrument = (MidiInstrument*)item->data(Qt::UserRole).value<void*>();
+// MidiInstrument* instrument = (MidiInstrument*)item->data();
+ //std::vector<PatchGroup>* pg = instrument->groups();
+// PatchGroupList* pg = instrument->groups();
+ PatchGroupList* pg = workingInstrument.groups();
+ QString patchName;
+ for (int i = 1;; ++i) {
+ patchName = QString("Patch-%1").arg(i);
+ bool found = false;
+
+ //for (std::vector<PatchGroup>::iterator g = pg->begin(); g != pg->end(); ++g) {
+ for (iPatchGroup g = pg->begin(); g != pg->end(); ++g) {
+ PatchGroup* pgp = *g;
+ //for (iPatch p = g->patches.begin(); p != g->patches.end(); ++p) {
+ for (iPatch p = pgp->patches.begin(); p != pgp->patches.end(); ++p) {
+ //if (p->name == patchName) {
+ if ((*p)->name == patchName) {
+ found = true;
+ break;
+ }
+ }
+ if (found)
+ break;
+ }
+ if (!found)
+ break;
+ }
+
+ //
+ // search current patch group
+ //
+ //PatchGroup* pGroup = 0;
+ //QTreeWidgetItem* pi = patchView->currentItem();
+ QTreeWidgetItem* pi = patchView->currentItem();
+
+ if (pi == 0)
+ return;
+
+ // If there is data then pi is a patch item, and there must be a parent patch group item (with null data).
+ //if (pi->data(0, Qt::UserRole).value<void*>())
+ //if (pi->data())
+
+ Patch* selpatch = 0;
+
+ // If there is a parent item then pi is a patch item, and there must be a parent patch group item.
+ if(pi->parent())
+ {
+ // Remember the current selected patch.
+ selpatch = (Patch*)pi->data(0, Qt::UserRole).value<void*>();
+
+ pi = pi->parent();
+ }
+
+ PatchGroup* group = (PatchGroup*)pi->data(0, Qt::UserRole).value<void*>();
+ if(!group)
+ return;
+
+ //for (std::vector<PatchGroup>::iterator g = pg->begin(); g != pg->end(); ++g) {
+// for (ciPatchGroup g = pg->begin(); g != pg->end(); ++g) {
+// if (g->name == pi->text(0)) {
+// pGroup = &*g;
+// break;
+// }
+// }
+// if (pGroup == 0) {
+// printf("group not found\n");
+// return;
+// }
+
+ // Create a new Patch, then store its pointer in a new patch item,
+ // to be added later to the patch group only upon save...
+ //Patch patch;
+ //patch.name = patchName;
+ Patch* patch = new Patch;
+ int hb = -1;
+ int lb = -1;
+ int prg = 0;
+ patch->hbank = hb;
+ patch->lbank = lb;
+ patch->prog = prg;
+ patch->typ = -1;
+ patch->drum = false;
+
+ if(selpatch)
+ {
+ hb = selpatch->hbank;
+ lb = selpatch->lbank;
+ prg = selpatch->prog;
+ patch->typ = selpatch->typ;
+ patch->drum = selpatch->drum;
+ }
+
+ bool found = false;
+
+ // The 129 is to accommodate -1 values. Yes, it may cause one extra redundant loop but hey,
+ // if it hasn't found an available patch number by then, another loop won't matter.
+ for(int k = 0; k < 129; ++k)
+ {
+ for(int j = 0; j < 129; ++j)
+ {
+ for(int i = 0; i < 128; ++i)
+ {
+ found = false;
+
+ for(iPatchGroup g = pg->begin(); g != pg->end(); ++g)
+ {
+ PatchGroup* pgp = *g;
+ for(iPatch ip = pgp->patches.begin(); ip != pgp->patches.end(); ++ip)
+ {
+ Patch* p = *ip;
+ if((p->prog == ((prg + i) & 0x7f)) &&
+ ((p->lbank == -1 && lb == -1) || (p->lbank == ((lb + j) & 0x7f))) &&
+ ((p->hbank == -1 && hb == -1) || (p->hbank == ((hb + k) & 0x7f))))
+ {
+ found = true;
+ break;
+ }
+ }
+ if(found)
+ break;
+ }
+
+ if(!found)
+ {
+ patch->prog = (prg + i) & 0x7f;
+ if(lb == -1)
+ patch->lbank = -1;
+ else
+ patch->lbank = (lb + j) & 0x7f;
+
+ if(hb == -1)
+ patch->hbank = -1;
+ else
+ patch->hbank = (hb + k) & 0x7f;
+
+ //patch->typ = selpatch->typ;
+ //patch->drum = selpatch->drum;
+ break;
+ }
+
+ }
+ if(!found)
+ break;
+ }
+ if(!found)
+ break;
+ }
+
+ patch->name = patchName;
+
+ group->patches.push_back(patch);
+ //Patch* pp = &(group->patches.back());
+
+ //QTreeWidgetItem* sitem = new QTreeWidgetItem;
+ QTreeWidgetItem* sitem = new QTreeWidgetItem(pi);
+ //sitem->setText(0, patch->name);
+ sitem->setText(0, patchName);
+
+ patchNameEdit->setText(patchName);
+
+ //QVariant v = QVariant::fromValue((void*)(patch));
+ //sitem->setData(0, Qt::UserRole, v);
+
+ // Set the list view item's data.
+ //sitem->setData((void*)patch);
+ QVariant v = qVariantFromValue((void*)(patch));
+ sitem->setData(0, Qt::UserRole, v);
+ //sitem->setAuxData((void*)patch);
+ //sitem->setData((void*)pp);
+
+ //pi->addChild(sitem);
+
+ //printf("newPatchClicked: before patchView->setCurrentItem\n");
+
+ //patchView->setCurrentItem(sitem);
+
+ //printf("newPatchClicked: after patchView->setCurrentItem\n");
+
+ //oldPatchItem = 0;
+
+ // May cause patchChanged call.
+ patchView->blockSignals(true);
+ sitem->setSelected(true);
+ patchView->scrollToItem((QTreeWidgetItem*)sitem, QAbstractItemView::EnsureVisible);
+ patchView->blockSignals(false);
+
+ //oldPatchItem = (ListViewData*)patchView->selectedItem();
+ //oldPatchItem = sitem;
+ //oldPatchItem = 0;
+
+ spinBoxHBank->setEnabled(true);
+ spinBoxLBank->setEnabled(true);
+ spinBoxProgram->setEnabled(true);
+ checkBoxDrum->setEnabled(true);
+ checkBoxGM->setEnabled(true);
+ checkBoxGS->setEnabled(true);
+ checkBoxXG->setEnabled(true);
+
+ oldPatchItem = 0;
+ patchChanged();
+
+ //instrument->setDirty(true);
+ workingInstrument.setDirty(true);
+ }
+
+//---------------------------------------------------------
+// newGroupClicked
+//---------------------------------------------------------
+
+void EditInstrument::newGroupClicked()
+ {
+ //QListWidgetItem* item = instrumentList->currentItem();
+// ListBoxData* item = (ListBoxData*)instrumentList->selectedItem();
+// if (item == 0)
+// return;
+
+ if(oldPatchItem)
+ {
+ if(oldPatchItem->parent())
+ updatePatch(&workingInstrument, (Patch*)oldPatchItem->data(0, Qt::UserRole).value<void*>());
+ else
+ updatePatchGroup(&workingInstrument, (PatchGroup*)oldPatchItem->data(0, Qt::UserRole).value<void*>());
+ }
+
+ //MidiInstrument* instrument = (MidiInstrument*)item->data(Qt::UserRole).value<void*>();
+// MidiInstrument* instrument = (MidiInstrument*)item->data();
+ //std::vector<PatchGroup>* pg = instrument->groups();
+// PatchGroupList* pg = instrument->groups();
+ PatchGroupList* pg = workingInstrument.groups();
+ QString groupName;
+ for (int i = 1;; ++i) {
+ groupName = QString("Group-%1").arg(i);
+ bool found = false;
+
+ //for (std::vector<PatchGroup>::iterator g = pg->begin(); g != pg->end(); ++g) {
+ for (ciPatchGroup g = pg->begin(); g != pg->end(); ++g) {
+ //if (g->name == groupName) {
+ if ((*g)->name == groupName) {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ break;
+ }
+
+ // Create a new PatchGroup, then store its pointer in a new patch group item,
+ // to be added later to the instrument only upon save...
+ PatchGroup* group = new PatchGroup;
+ group->name = groupName;
+ //PatchGroup group;
+ //group.name = groupName;
+
+ pg->push_back(group);
+ //PatchGroup* pgp = &(pg->back());
+
+ QTreeWidgetItem* sitem = new QTreeWidgetItem(patchView);
+ sitem->setText(0, groupName);
+
+ patchNameEdit->setText(groupName);
+
+ //QVariant v = QVariant::fromValue((void*)0);
+ //sitem->setData(0, Qt::UserRole, v);
+ //sitem->setData((void*)0);
+
+ // Set the list view item's data.
+ QVariant v = qVariantFromValue((void*)(group));
+ sitem->setData(0, Qt::UserRole, v);
+ //sitem->setAuxData((void*)pgp);
+
+ //patchView->addTopLevelItem(sitem);
+ //patchView->setCurrentItem(sitem);
+
+ //oldPatchItem = 0;
+
+ // May cause patchChanged call.
+ patchView->blockSignals(true);
+ sitem->setSelected(true);
+ patchView->blockSignals(false);
+
+ //oldPatchItem = (ListViewData*)patchView->selectedItem();
+ oldPatchItem = sitem;
+ //oldPatchItem = 0;
+ //patchChanged();
+
+ spinBoxHBank->setEnabled(false);
+ spinBoxLBank->setEnabled(false);
+ spinBoxProgram->setEnabled(false);
+ checkBoxDrum->setEnabled(false);
+ checkBoxGM->setEnabled(false);
+ checkBoxGS->setEnabled(false);
+ checkBoxXG->setEnabled(false);
+
+ //instrument->setDirty(true);
+ workingInstrument.setDirty(true);
+ }
+
+//---------------------------------------------------------
+// deleteControllerClicked
+//---------------------------------------------------------
+
+void EditInstrument::deleteControllerClicked()
+ {
+ //QListWidgetItem* item = instrumentList->currentItem();
+ //ListBoxData* item = (ListBoxData*)instrumentList->selectedItem();
+ //QListWidgetItem* item2 = listController->currentItem();
+// ListBoxData* item = (ListBoxData*)listController->selectedItem();
+ QTreeWidgetItem* item = viewController->currentItem();
+
+ //if (item == 0 || item2 == 0)
+ if(!item)
+ return;
+ //MidiInstrument* instrument = (MidiInstrument*)item->data(Qt::UserRole).value<void*>();
+// MidiInstrument* instrument = (MidiInstrument*)item->data();
+ //MidiController* ctrl = (MidiController*)item2->data(Qt::UserRole).value<void*>();
+ //MidiController* ctrl = (MidiController*)item2->data();
+ //MidiControllerList* cl = instrument->controller();
+ //cl->removeAll(ctrl);
+
+ MidiController* ctrl = (MidiController*)item->data(0, Qt::UserRole).value<void*>();
+ if(!ctrl)
+ return;
+
+ workingInstrument.controller()->erase(ctrl->num());
+ // Now delete the controller.
+ delete ctrl;
+
+ // Now remove the controller item from the list.
+ // This may cause a controllerChanged call.
+// listController->blockSignals(true);
+ viewController->blockSignals(true);
+ delete item;
+ if(viewController->currentItem())
+ viewController->currentItem()->setSelected(true);
+// listController->blockSignals(false);
+ viewController->blockSignals(false);
+
+ //oldController = (ListBoxData*)listController->selectedItem();
+// oldController = 0;
+
+ controllerChanged();
+
+ //instrument->setDirty(true);
+ workingInstrument.setDirty(true);
+ }
+
+//---------------------------------------------------------
+// newControllerClicked
+//---------------------------------------------------------
+
+void EditInstrument::newControllerClicked()
+ {
+ //QListWidgetItem* item = instrumentList->currentItem();
+ //if (item == 0)
+ // return;
+ //MidiInstrument* instrument = (MidiInstrument*)item->data(Qt::UserRole).value<void*>();
+
+// if(oldController)
+// updateController(&workingInstrument, (MidiController*)oldController->data());
+
+ QString cName;
+ //MidiControllerList* cl = instrument->controller();
+ MidiControllerList* cl = workingInstrument.controller();
+ for (int i = 1;; ++i) {
+ //ctrlName = QString("Controller-%d").arg(i);
+ cName = QString("Controller-%1").arg(i);
+ bool found = false;
+ for (iMidiController ic = cl->begin(); ic != cl->end(); ++ic) {
+ MidiController* c = ic->second;
+ if (c->name() == cName) {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ break;
+ }
+
+ MidiController* ctrl = new MidiController();
+ ctrl->setNum(CTRL_MODULATION);
+ ctrl->setMinVal(0);
+ ctrl->setMaxVal(127);
+ ctrl->setInitVal(CTRL_VAL_UNKNOWN);
+
+ QTreeWidgetItem* ci = viewController->currentItem();
+
+ // To allow for quick multiple successive controller creation.
+ // If there's a current controller item selected, copy initial values from it.
+ bool found = false;
+ if(ci)
+ {
+ MidiController* selctl = (MidiController*)ci->data(0, Qt::UserRole).value<void*>();
+ // Assign.
+ // *ctrl = *selctl;
+
+ // Auto increment controller number.
+ //int l = ctrl->num() & 0x7f;
+ //int h = ctrl->num() & 0xffffff00;
+ int l = selctl->num() & 0x7f;
+ int h = selctl->num() & 0xffffff00;
+
+ // Ignore internal controllers and wild cards.
+ //if(((h & 0xff0000) != 0x40000) && ((ctrl->num() & 0xff) != 0xff))
+ if(((h & 0xff0000) != 0x40000) && ((selctl->num() & 0xff) != 0xff))
+ {
+ // Assign.
+ *ctrl = *selctl;
+
+ for (int i = 1; i < 128; ++i)
+ {
+ //ctrlName = QString("Controller-%d").arg(i);
+ //cName = QString("Controller-%1").arg(i);
+ int j = ((i + l) & 0x7f) | h;
+ found = false;
+ for (iMidiController ic = cl->begin(); ic != cl->end(); ++ic)
+ {
+ MidiController* c = ic->second;
+ if(c->num() == j)
+ {
+ found = true;
+ break;
+ }
+ }
+ if(!found)
+ {
+ ctrl->setNum(j);
+ break;
+ }
+ }
+ }
+ }
+
+ ctrl->setName(cName);
+
+ //item = new QListWidgetItem(ctrlName);
+// ListBoxData* item = new ListBoxData(ctrlName);
+
+ //QVariant v = qVariantFromValue((void*)(ctrl));
+ //item->setData(Qt::UserRole, v);
+// item->setData((void*)ctrl);
+ //listController->addItem(item);
+// listController->insertItem(item);
+ //listController->setCurrentItem(item);
+
+ workingInstrument.controller()->add(ctrl);
+ QTreeWidgetItem* item = addControllerToView(ctrl);
+
+// listController->blockSignals(true);
+// listController->setSelected(item, true);
+// listController->blockSignals(false);
+ viewController->blockSignals(true);
+ item->setSelected(true);
+ viewController->blockSignals(false);
+
+ //oldController = (ListBoxData*)listController->selectedItem();
+// oldController = item;
+ //oldController = 0;
+ // MidiController is a class, with itialized values. We have to call this to show the values.
+ // To make multiple entries easier, don't bother calling this.
+ controllerChanged();
+
+ //instrument->setDirty(true);
+ workingInstrument.setDirty(true);
+ }
+
+//---------------------------------------------------------
+// addControllerClicked
+//---------------------------------------------------------
+
+void EditInstrument::addControllerClicked()
+{
+ //int lnum = listController->currentItem();
+ //if(lnum == -1)
+ // return;
+
+ //QString name = midiCtrlName(lnum);
+
+ QListWidgetItem* idx = listController->currentItem();
+ if(idx == 0)
+ return;
+
+ int lnum = -1;
+ QString name = listController->currentItem()->text();
+ for(int i = 0; i < 128; i++)
+ {
+ if(midiCtrlName(i) == name)
+ {
+ lnum = i;
+ break;
+ }
+ }
+ if(lnum == -1)
+ {
+ printf("Add controller: Controller not found: %s\n", name.toLatin1().constData());
+ return;
+ }
+
+ int num = MidiController::genNum(MidiController::Controller7, 0, lnum);
+
+ MidiControllerList* cl = workingInstrument.controller();
+ for(iMidiController ic = cl->begin(); ic != cl->end(); ++ic)
+ {
+ MidiController* c = ic->second;
+ if(c->name() == name)
+ {
+ QMessageBox::critical(this,
+ tr("MusE: Cannot add common controller"),
+ tr("A controller named ") + name + tr(" already exists."),
+ QMessageBox::Ok,
+ Qt::NoButton,
+ Qt::NoButton);
+
+ return;
+ }
+
+ if(c->num() == num)
+ {
+ QMessageBox::critical(this,
+ tr("MusE: Cannot add common controller"),
+ tr("A controller number ") + QString().setNum(num) + tr(" already exists."),
+ QMessageBox::Ok,
+ Qt::NoButton,
+ Qt::NoButton);
+
+ return;
+ }
+ }
+
+ MidiController* ctrl = new MidiController();
+ ctrl->setNum(num);
+ ctrl->setMinVal(0);
+ ctrl->setMaxVal(127);
+ ctrl->setInitVal(CTRL_VAL_UNKNOWN);
+ ctrl->setName(name);
+
+ workingInstrument.controller()->add(ctrl);
+
+ QTreeWidgetItem* item = addControllerToView(ctrl);
+
+ viewController->blockSignals(true);
+ item->setSelected(true);
+ viewController->blockSignals(false);
+
+ controllerChanged();
+
+ workingInstrument.setDirty(true);
+}
+
+/*
+//---------------------------------------------------------
+// deleteSysexClicked
+//---------------------------------------------------------
+
+void EditInstrument::deleteSysexClicked()
+ {
+ //QListWidgetItem* item = instrumentList->currentItem();
+ //QListWidgetItem* item2 = sysexList->currentItem();
+ //if (item == 0 || item2 == 0)
+ // return;
+
+ //MidiInstrument* instrument = (MidiInstrument*)item->data(Qt::UserRole).value<void*>();
+ //SysEx* sysex = (SysEx*)item2->data(Qt::UserRole).value<void*>();
+ //QList<SysEx*> sl = instrument->sysex();
+ //instrument->removeSysex(sysex);
+ //delete item2;
+ //instrument->setDirty(true);
+
+
+
+ ListBoxData* item = (ListBoxData*)sysexList->selectedItem();
+ if(!item)
+ return;
+
+ EventList* el = (EventList*)item->data();
+ if(!el)
+ return;
+
+ }
+*/
+
+//---------------------------------------------------------
+// updatePatchGroup
+//---------------------------------------------------------
+
+void EditInstrument::updatePatchGroup(MidiInstrument* instrument, PatchGroup* pg)
+ {
+ QString a = pg->name;
+ QString b = patchNameEdit->text();
+ if (pg->name != patchNameEdit->text()) {
+ pg->name = patchNameEdit->text();
+ instrument->setDirty(true);
+ }
+ }
+
+//---------------------------------------------------------
+// updatePatch
+//---------------------------------------------------------
+
+void EditInstrument::updatePatch(MidiInstrument* instrument, Patch* p)
+ {
+ if (p->name != patchNameEdit->text()) {
+ p->name = patchNameEdit->text();
+ instrument->setDirty(true);
+ }
+
+ signed char hb = (spinBoxHBank->value() - 1) & 0xff;
+ //if (p->hbank != (spinBoxHBank->value() & 0xff)) {
+ // p->hbank = spinBoxHBank->value() & 0xff;
+ if (p->hbank != hb) {
+ p->hbank = hb;
+
+ instrument->setDirty(true);
+ }
+
+ signed char lb = (spinBoxLBank->value() - 1) & 0xff;
+ //if (p->lbank != (spinBoxLBank->value() & 0xff)) {
+ // p->lbank = spinBoxLBank->value() & 0xff;
+ if (p->lbank != lb) {
+ p->lbank = lb;
+
+ instrument->setDirty(true);
+ }
+
+ signed char pr = (spinBoxProgram->value() - 1) & 0xff;
+ if (p->prog != pr) {
+ p->prog = pr;
+
+ instrument->setDirty(true);
+ }
+
+ if (p->drum != checkBoxDrum->isChecked()) {
+ p->drum = checkBoxDrum->isChecked();
+ instrument->setDirty(true);
+ }
+
+ // there is no logical xor in c++
+ bool a = p->typ & 1;
+ bool b = p->typ & 2;
+ bool c = p->typ & 4;
+ bool aa = checkBoxGM->isChecked();
+ bool bb = checkBoxGS->isChecked();
+ bool cc = checkBoxXG->isChecked();
+ if ((a ^ aa) || (b ^ bb) || (c ^ cc)) {
+ int value = 0;
+ if (checkBoxGM->isChecked())
+ value |= 1;
+ if (checkBoxGS->isChecked())
+ value |= 2;
+ if (checkBoxXG->isChecked())
+ value |= 4;
+ p->typ = value;
+ instrument->setDirty(true);
+ }
+
+ //if (p->categorie != category->currentIndex()) {
+ // p->categorie = category->currentIndex();
+ // instrument->setDirty(true);
+ // }
+ }
+
+/*
+//---------------------------------------------------------
+// updateController
+//---------------------------------------------------------
+
+void EditInstrument::updateController(MidiInstrument* instrument, MidiController* oc)
+ {
+ printf("updateController: A\n");
+
+ int ctrlH = spinBoxHCtrlNo->value();
+ int ctrlL = spinBoxLCtrlNo->value();
+ //MidiController::ControllerType type = (MidiController::ControllerType)ctrlType->currentIndex();
+ MidiController::ControllerType type = (MidiController::ControllerType)ctrlType->currentItem();
+ int num = MidiController::genNum(type, ctrlH, ctrlL);
+ //int num = (ctrlH << 8) & 0x7f + ctrlL & 0x7f;
+
+ printf("updateController: B\n");
+
+ if (num != oc->num()) {
+
+ printf("updateController: num changed, setting dirty. num:%d c->num:%d\n", num, oc->num());
+
+ oc->setNum(num);
+ instrument->setDirty(true);
+ }
+
+ if(type != MidiController::Pitch && type != MidiController::Program)
+ {
+ if (spinBoxMin->value() != oc->minVal()) {
+
+ printf("updateController: min changed, setting dirty. min:%d c->min:%d\n", spinBoxMin->value(), oc->minVal());
+
+ oc->setMinVal(spinBoxMin->value());
+ instrument->setDirty(true);
+ }
+ if (spinBoxMax->value() != oc->maxVal()) {
+
+ printf("updateController: max changed, setting dirty. num:%d max:%d c->max:%d\n", num, spinBoxMax->value(), oc->maxVal());
+
+ oc->setMaxVal(spinBoxMax->value());
+ instrument->setDirty(true);
+ }
+
+ int dv = spinBoxDefault->value();
+ if(dv == oc->minVal() - 1)
+ dv = CTRL_VAL_UNKNOWN;
+
+ //if (spinBoxDefault->value() != oc->initVal()) {
+ if(dv != oc->initVal()) {
+ //oc->setInitVal(spinBoxDefault->value());
+ oc->setInitVal(dv);
+
+ printf("updateController: default changed, setting dirty. def:%d c->init:%d\n", dv, oc->initVal());
+
+ instrument->setDirty(true);
+ }
+ }
+
+
+ printf("updateController: C\n");
+
+ //if (moveWithPart->isChecked() ^ oc->moveWithPart()) {
+ // oc->setMoveWithPart(moveWithPart->isChecked());
+ // instrument->setDirty(true);
+ // }
+ if (ctrlName->text() != oc->name()) {
+ oc->setName(ctrlName->text());
+
+ printf("updateController: name changed, setting dirty. name:%s c->name:%s\n", ctrlName->text().toLatin1().constData(), oc->name().toLatin1().constData());
+
+ instrument->setDirty(true);
+ }
+ //if (ctrlComment->toPlainText() != oc->comment()) {
+ // oc->setComment(ctrlComment->toPlainText());
+ // instrument->setDirty(true);
+ // }
+
+ printf("updateController: D\n");
+
+ }
+*/
+
+//---------------------------------------------------------
+// updateInstrument
+//---------------------------------------------------------
+
+void EditInstrument::updateInstrument(MidiInstrument* instrument)
+ {
+ //QListWidgetItem* sysexItem = sysexList->currentItem();
+ //ListBoxData* sysexItem = sysexList->currentItem();
+ //if (sysexItem) {
+ // SysEx* so = (SysEx*)sysexItem->data(Qt::UserRole).value<void*>();
+ // updateSysex(instrument, so);
+ // }
+
+ //QListWidgetItem* ctrlItem = listController->currentItem();
+ //ListBoxData* ctrlItem = (ListBoxData*)listController->currentItem();
+ //ListBoxData* ctrlItem = (ListBoxData*)listController->selectedItem();
+// ListViewData* ctrlItem = (ListViewData*)viewController->selectedItem();
+
+// if (ctrlItem) {
+ //MidiController* ctrl = (MidiController*)ctrlItem->data(Qt::UserRole).value<void*>();
+
+// printf("updateInstrument: AB\n");
+
+// MidiController* ctrl = (MidiController*)ctrlItem->data();
+
+// printf("updateInstrument: AC\n");
+
+// updateController(instrument, ctrl);
+// }
+
+// printf("updateInstrument: B\n");
+
+ QTreeWidgetItem* patchItem = patchView->currentItem();
+
+ if (patchItem)
+ {
+ //Patch* p = (Patch*)patchItem->data(0, Qt::UserRole).value<void*>();
+
+ // If the item has a parent, it's a patch item.
+ if(patchItem->parent())
+ updatePatch(instrument, (Patch*)patchItem->data(0, Qt::UserRole).value<void*>());
+ else
+ updatePatchGroup(instrument, (PatchGroup*)patchItem->data(0, Qt::UserRole).value<void*>());
+
+ }
+ }
+
+//---------------------------------------------------------
+// checkDirty
+// return true on Abort
+//---------------------------------------------------------
+
+int EditInstrument::checkDirty(MidiInstrument* i, bool isClose)
+ {
+ updateInstrument(i);
+ if (!i->dirty())
+ //return false;
+ return 0;
+ int n;
+ if(isClose)
+ n = QMessageBox::warning(this, tr("MusE"),
+ tr("The current Instrument contains unsaved data\n"
+ "Save Current Instrument?"),
+ tr("&Save"), tr("&Nosave"), tr("&Abort"), 0, 2);
+ else
+ n = QMessageBox::warning(this, tr("MusE"),
+ tr("The current Instrument contains unsaved data\n"
+ "Save Current Instrument?"),
+ tr("&Save"), tr("&Nosave"), 0, 1);
+ if (n == 0) {
+ if (i->filePath().isEmpty())
+ {
+ //fileSaveAs();
+ saveAs();
+ }
+ else {
+ //QFile f(i->filePath());
+ //if (!f.open(QIODevice::WriteOnly))
+ FILE* f = fopen(i->filePath().toLatin1().constData(), "w");
+ if(f == 0)
+ //fileSaveAs();
+ saveAs();
+ else {
+ //f.close();
+ if(fclose(f) != 0)
+ printf("EditInstrument::checkDirty: Error closing file\n");
+
+ if(fileSave(i, i->filePath()))
+ i->setDirty(false);
+ }
+ }
+ //return false;
+ return 0;
+ }
+ //return n == 2;
+ return n;
+ }
+
+//---------------------------------------------------------
+// getPatchItemText
+//---------------------------------------------------------
+
+QString EditInstrument::getPatchItemText(int val)
+{
+ QString s;
+ if(val == CTRL_VAL_UNKNOWN)
+ s = "---";
+ else
+ {
+ int hb = ((val >> 16) & 0xff) + 1;
+ if (hb == 0x100)
+ hb = 0;
+ int lb = ((val >> 8) & 0xff) + 1;
+ if (lb == 0x100)
+ lb = 0;
+ int pr = (val & 0xff) + 1;
+ if (pr == 0x100)
+ pr = 0;
+ s.sprintf("%d-%d-%d", hb, lb, pr);
+ }
+
+ return s;
+}
+
+//---------------------------------------------------------
+// enableDefaultControls
+//---------------------------------------------------------
+
+void EditInstrument::enableDefaultControls(bool enVal, bool enPatch)
+{
+ spinBoxDefault->setEnabled(enVal);
+ patchButton->setEnabled(enPatch);
+ if(!enPatch)
+ {
+ patchButton->blockSignals(true);
+ patchButton->setText("---");
+ patchButton->blockSignals(false);
+ }
+ defPatchH->setEnabled(enPatch);
+ defPatchL->setEnabled(enPatch);
+ defPatchProg->setEnabled(enPatch);
+}
+
+//---------------------------------------------------------
+// setDefaultPatchName
+//---------------------------------------------------------
+
+void EditInstrument::setDefaultPatchName(int val)
+{
+ patchButton->blockSignals(true);
+ patchButton->setText(getPatchName(val));
+ patchButton->blockSignals(false);
+}
+
+//---------------------------------------------------------
+// getDefaultPatchNumber
+//---------------------------------------------------------
+
+int EditInstrument::getDefaultPatchNumber()
+{
+ int hval = defPatchH->value() - 1;
+ int lval = defPatchL->value() - 1;
+ int prog = defPatchProg->value() - 1;
+ if(hval == -1)
+ hval = 0xff;
+ if(lval == -1)
+ lval = 0xff;
+ if(prog == -1)
+ prog = 0xff;
+
+ return ((hval & 0xff) << 16) + ((lval & 0xff) << 8) + (prog & 0xff);
+}
+
+//---------------------------------------------------------
+// setDefaultPatchNumbers
+//---------------------------------------------------------
+
+void EditInstrument::setDefaultPatchNumbers(int val)
+{
+ int hb;
+ int lb;
+ int pr;
+
+ if(val == CTRL_VAL_UNKNOWN)
+ hb = lb = pr = 0;
+ else
+ {
+ hb = ((val >> 16) & 0xff) + 1;
+ if (hb == 0x100)
+ hb = 0;
+ lb = ((val >> 8) & 0xff) + 1;
+ if (lb == 0x100)
+ lb = 0;
+ pr = (val & 0xff) + 1;
+ if (pr == 0x100)
+ pr = 0;
+ }
+
+ defPatchH->blockSignals(true);
+ defPatchL->blockSignals(true);
+ defPatchProg->blockSignals(true);
+ defPatchH->setValue(hb);
+ defPatchL->setValue(lb);
+ defPatchProg->setValue(pr);
+ defPatchH->blockSignals(false);
+ defPatchL->blockSignals(false);
+ defPatchProg->blockSignals(false);
+}
+
+//---------------------------------------------------------
+// setDefaultPatchControls
+//---------------------------------------------------------
+
+void EditInstrument::setDefaultPatchControls(int val)
+{
+ setDefaultPatchNumbers(val);
+ setDefaultPatchName(val);
+}
+
+//---------------------------------------------------------
+// getPatchName
+//---------------------------------------------------------
+
+QString EditInstrument::getPatchName(int prog)
+{
+ int pr = prog & 0xff;
+ if(prog == CTRL_VAL_UNKNOWN || pr == 0xff)
+ return "---";
+
+ //int hbank = (prog >> 16) & 0x7f;
+ //int lbank = (prog >> 8) & 0x7f;
+ int hbank = (prog >> 16) & 0xff;
+ int lbank = (prog >> 8) & 0xff;
+
+ PatchGroupList* pg = workingInstrument.groups();
+
+ for(ciPatchGroup i = pg->begin(); i != pg->end(); ++i) {
+ const PatchList& pl = (*i)->patches;
+ for (ciPatch ipl = pl.begin(); ipl != pl.end(); ++ipl) {
+ const Patch* mp = *ipl;
+ if (//(mp->typ & tmask) &&
+ (pr == mp->prog)
+ //&& ((drum && mode != MT_GM) ||
+ // (mp->drum == drumchan))
+
+ //&& (hbank == mp->hbank || !hb || mp->hbank == -1)
+ //&& (lbank == mp->lbank || !lb || mp->lbank == -1))
+ && (hbank == mp->hbank || mp->hbank == -1)
+ && (lbank == mp->lbank || mp->lbank == -1))
+ return mp->name;
+ }
+ }
+ return "---";
+}
+
diff --git a/attic/muse2-oom/muse2/muse/instruments/editinstrument.h b/attic/muse2-oom/muse2/muse/instruments/editinstrument.h
new file mode 100644
index 00000000..b3c6b5e0
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/instruments/editinstrument.h
@@ -0,0 +1,91 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: editinstrument.h,v 1.1.1.1.2.4 2009/05/31 05:12:12 terminator356 Exp $
+//
+// (C) Copyright 2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __EDITINSTRUMENT_H__
+#define __EDITINSTRUMENT_H__
+
+#include "ui_editinstrumentbase.h"
+#include "minstrument.h"
+#include "midictrl.h"
+
+class QDialog;
+class QMenu;
+class QCloseEvent;
+
+//---------------------------------------------------------
+// EditInstrument
+//---------------------------------------------------------
+
+class EditInstrument : public QMainWindow, public Ui::EditInstrumentBase {
+ Q_OBJECT
+
+ MidiInstrument workingInstrument;
+ QListWidgetItem* oldMidiInstrument;
+ QTreeWidgetItem* oldPatchItem;
+ void closeEvent(QCloseEvent*);
+ int checkDirty(MidiInstrument*, bool isClose = false);
+ bool fileSave(MidiInstrument*, const QString&);
+ void saveAs();
+ void updateInstrument(MidiInstrument*);
+ void updatePatch(MidiInstrument*, Patch*);
+ void updatePatchGroup(MidiInstrument*, PatchGroup*);
+ void changeInstrument();
+ QTreeWidgetItem* addControllerToView(MidiController* mctrl);
+ QString getPatchItemText(int);
+ void enableDefaultControls(bool, bool);
+ void setDefaultPatchName(int);
+ int getDefaultPatchNumber();
+ void setDefaultPatchNumbers(int);
+ void setDefaultPatchControls(int);
+ QString getPatchName(int);
+ void deleteInstrument(QListWidgetItem*);
+ ///QMenu* patchpopup;
+
+ private slots:
+ virtual void fileNew();
+ virtual void fileOpen();
+ virtual void fileSave();
+ virtual void fileSaveAs();
+ virtual void fileExit();
+ virtual void helpWhatsThis();
+ void instrumentChanged();
+ void tabChanged(QWidget*);
+ void patchChanged();
+ void controllerChanged();
+ //void instrumentNameChanged(const QString&);
+ void instrumentNameReturn();
+ void patchNameReturn();
+ void deletePatchClicked();
+ void newPatchClicked();
+ void newGroupClicked();
+ void patchButtonClicked();
+ void defPatchChanged(int);
+ //void newCategoryClicked();
+ void deleteControllerClicked();
+ void newControllerClicked();
+ void addControllerClicked();
+ void ctrlTypeChanged(int);
+ //void ctrlNameChanged(const QString&);
+ void ctrlNameReturn();
+ void ctrlHNumChanged(int);
+ void ctrlLNumChanged(int);
+ void ctrlMinChanged(int);
+ void ctrlMaxChanged(int);
+ void ctrlDefaultChanged(int);
+ //void sysexChanged();
+ //void deleteSysexClicked();
+ //void newSysexClicked();
+ void ctrlNullParamHChanged(int);
+ void ctrlNullParamLChanged(int);
+
+ public:
+ EditInstrument(QWidget* parent = 0, Qt::WFlags fl = Qt::Window);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/instruments/editinstrumentbase.ui b/attic/muse2-oom/muse2/muse/instruments/editinstrumentbase.ui
new file mode 100644
index 00000000..3337cfc0
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/instruments/editinstrumentbase.ui
@@ -0,0 +1,1649 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>EditInstrumentBase</class>
+ <widget class="QMainWindow" name="EditInstrumentBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>802</width>
+ <height>505</height>
+ </rect>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>802</width>
+ <height>464</height>
+ </size>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Instrument Editor</string>
+ </property>
+ <widget class="QWidget" name="widget">
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QSplitter" name="splitter4">
+ <property name="minimumSize">
+ <size>
+ <width>780</width>
+ <height>365</height>
+ </size>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <widget class="QWidget" name="layout26">
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QLabel" name="textLabel2">
+ <property name="text">
+ <string>Instrument Name:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="instrumentName">
+ <property name="toolTip">
+ <string/>
+ </property>
+ <property name="whatsThis">
+ <string>Selected instrument name.</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QListWidget" name="instrumentList">
+ <property name="whatsThis">
+ <string>List of defined instruments.</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QTabWidget" name="tabWidget3">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="patchesTab">
+ <attribute name="title">
+ <string>Pa&amp;tches</string>
+ </attribute>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QSplitter" name="splitter5">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <widget class="QTreeWidget" name="patchView">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string/>
+ </property>
+ <property name="whatsThis">
+ <string>List of groups and patches.</string>
+ </property>
+ <property name="rootIsDecorated">
+ <bool>true</bool>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <column>
+ <property name="text">
+ <string>Group/Patch</string>
+ </property>
+ </column>
+ </widget>
+ <widget class="QWidget" name="layout27">
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QGroupBox" name="groupBox2">
+ <property name="title">
+ <string>Properties</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QLabel" name="textLabelPatchName">
+ <property name="text">
+ <string>Name:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="patchNameEdit">
+ <property name="toolTip">
+ <string>Group or patch name</string>
+ </property>
+ <property name="whatsThis">
+ <string>Group or patch name</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="textLabel2_2">
+ <property name="text">
+ <string>High Bank:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QSpinBox" name="spinBoxHBank">
+ <property name="toolTip">
+ <string>Patch high bank number</string>
+ </property>
+ <property name="whatsThis">
+ <string>Patch high bank number. --- means don't care.</string>
+ </property>
+ <property name="specialValueText">
+ <string comment="dont care">---</string>
+ </property>
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>128</number>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer8">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>373</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="textLabel3_2">
+ <property name="text">
+ <string>Low Bank:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QSpinBox" name="spinBoxLBank">
+ <property name="toolTip">
+ <string>Patch low bank number</string>
+ </property>
+ <property name="whatsThis">
+ <string>Patch low bank number. --- means don't care.</string>
+ </property>
+ <property name="specialValueText">
+ <string>---</string>
+ </property>
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>128</number>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer9">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>373</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="textLabel4_3">
+ <property name="text">
+ <string>Program:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QSpinBox" name="spinBoxProgram">
+ <property name="toolTip">
+ <string>Patch program number</string>
+ </property>
+ <property name="whatsThis">
+ <string>Patch program number</string>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>128</number>
+ </property>
+ <property name="value">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer10">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>373</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QCheckBox" name="checkBoxDrum">
+ <property name="toolTip">
+ <string>Drum patch</string>
+ </property>
+ <property name="whatsThis">
+ <string>If set, the patch is available only for drum channels.</string>
+ </property>
+ <property name="text">
+ <string>Drum</string>
+ </property>
+ <property name="shortcut">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBoxGM">
+ <property name="toolTip">
+ <string>GM patch</string>
+ </property>
+ <property name="whatsThis">
+ <string>If set, the patch is available in a 'GM' or 'NO' midi song type.</string>
+ </property>
+ <property name="text">
+ <string>GM</string>
+ </property>
+ <property name="shortcut">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBoxGS">
+ <property name="toolTip">
+ <string>GS patch</string>
+ </property>
+ <property name="whatsThis">
+ <string>If set, the patch is available in a 'GS' or 'NO' midi song type.</string>
+ </property>
+ <property name="text">
+ <string>GS</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="checkBoxXG">
+ <property name="toolTip">
+ <string>XG patch</string>
+ </property>
+ <property name="whatsThis">
+ <string>If set, the patch is available in an 'XG' or 'NO' midi song type.</string>
+ </property>
+ <property name="text">
+ <string>XG</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer7">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>90</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QToolButton" name="patchDelete">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>Delete group or patch</string>
+ </property>
+ <property name="text">
+ <string>&amp;Delete</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+D</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="patchNew">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>New patch</string>
+ </property>
+ <property name="text">
+ <string>New &amp;Patch</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+P</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="patchNewGroup">
+ <property name="toolTip">
+ <string>New group</string>
+ </property>
+ <property name="text">
+ <string>New &amp;Group</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+G</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer11">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>240</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="controllerTab">
+ <attribute name="title">
+ <string>Contro&amp;ller</string>
+ </attribute>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QSplitter" name="splitter6">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <widget class="QWidget" name="layout13">
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QLabel" name="textLabel1">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Common:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QListWidget" name="listController">
+ <property name="toolTip">
+ <string/>
+ </property>
+ <property name="whatsThis">
+ <string>This is a list of commonly used midi controllers.
+Note that in MusE pitch and program changes are
+handled like normal controllers.</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="layout17">
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QTreeWidget" name="viewController">
+ <property name="toolTip">
+ <string>List of defined controllers</string>
+ </property>
+ <property name="whatsThis">
+ <string>List of defined controllers.</string>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Sunken</enum>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <column>
+ <property name="text">
+ <string>Name </string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Type </string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>H-Ctrl</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>L-Ctrl</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Min </string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Max </string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Def </string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="GroupBox1">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Properties</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QLabel" name="TextLabel1_3">
+ <property name="text">
+ <string>Name:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="ctrlName">
+ <property name="toolTip">
+ <string/>
+ </property>
+ <property name="whatsThis">
+ <string>Midi controller name</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QLabel" name="TextLabel2_4">
+ <property name="text">
+ <string>Type:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="ctrlType">
+ <property name="toolTip">
+ <string>Midi controller type</string>
+ </property>
+ <property name="whatsThis">
+ <string>Midi controller type</string>
+ </property>
+ <item>
+ <property name="text">
+ <string>Control7</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Control14</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>RPN</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>NRPN</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>RPN14</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>NRPN14</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Pitch</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Program</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer15">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="TextLabel3_2">
+ <property name="text">
+ <string>H-Ctrl</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="indent">
+ <number>10</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="spinBoxHCtrlNo">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>Midi controller number high byte</string>
+ </property>
+ <property name="whatsThis">
+ <string>Midi controller number high byte</string>
+ </property>
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer16">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="TextLabel2_3_2">
+ <property name="text">
+ <string>L-Ctrl</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="indent">
+ <number>10</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="spinBoxLCtrlNo">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>Midi controller number low byte (* means drum controller)</string>
+ </property>
+ <property name="whatsThis">
+ <string>Midi controller number low byte.
+If low byte is * then the controller is a
+ 'drum controller'. For drum tracks and
+ GS/XG type songs and instruments.
+Allows controllers for each instrument in
+ Muse's drum map. The low byte will be
+ replaced by the 'ANote' in the drum map.
+Examples: The GS and XG instruments'
+ Drum controllers.</string>
+ </property>
+ <property name="specialValueText">
+ <string comment="wild card">*</string>
+ </property>
+ <property name="minimum">
+ <number>-1</number>
+ </property>
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QLabel" name="textLabel4_2">
+ <property name="text">
+ <string>Range:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer17">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="TextLabel1_2_2">
+ <property name="text">
+ <string>Min</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="indent">
+ <number>10</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="spinBoxMin">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>Minimum value. If negative, auto-translate.</string>
+ </property>
+ <property name="whatsThis">
+ <string>Minimum value. If the minimum value
+ is negative, the range will automatically
+ be translated to a positive range.
+
+Useful for controllers which should be
+ displayed with zero bias. For example,
+'Pan': Minimum: -64 Maximum: 63
+True range: Min: 0 Max: 127 (bias = 64)
+'CoarseTuning': Min: -24 Max: 23
+True range: Min: 40 Max: 87 (bias = 64)
+
+Bias is determined from controller type:
+7-bit Controller7 / RPN: Bias = 64
+14-bit Controller14 / RPN14: Bias = 8192
+
+Type 'Pitch' is the exception. It is biased
+ at zero, even with a negative minimum:
+'Pitch': Min: -8192 Max: 8191
+True range: Min: -8192 Max: 8191 (bias 0)</string>
+ </property>
+ <property name="minimum">
+ <number>-16384</number>
+ </property>
+ <property name="maximum">
+ <number>16383</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer18">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="TextLabel2_2_2">
+ <property name="text">
+ <string>Max</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="indent">
+ <number>10</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="spinBoxMax">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>Maximum value</string>
+ </property>
+ <property name="whatsThis">
+ <string>Maximum value</string>
+ </property>
+ <property name="minimum">
+ <number>-16384</number>
+ </property>
+ <property name="maximum">
+ <number>16383</number>
+ </property>
+ <property name="value">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QGridLayout">
+ <item row="1" column="0" colspan="2">
+ <spacer name="spacer13_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="textLabel1_3">
+ <property name="text">
+ <string>Default:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignVCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="6">
+ <widget class="QLabel" name="textLabel2_4">
+ <property name="text">
+ <string>L-Bank</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="5">
+ <widget class="QSpinBox" name="defPatchH">
+ <property name="specialValueText">
+ <string>off</string>
+ </property>
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>128</number>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="7">
+ <widget class="QSpinBox" name="defPatchL">
+ <property name="specialValueText">
+ <string>off</string>
+ </property>
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>128</number>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="6">
+ <widget class="QLabel" name="textLabel3">
+ <property name="text">
+ <string>Progr.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="7">
+ <widget class="QSpinBox" name="defPatchProg">
+ <property name="specialValueText">
+ <string>off</string>
+ </property>
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>128</number>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2" colspan="4">
+ <widget class="QPushButton" name="patchButton">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>210</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>???</string>
+ </property>
+ <property name="shortcut">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <widget class="QLabel" name="textLabel1_5">
+ <property name="text">
+ <string>H-Bank</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <spacer name="spacer12_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="1" colspan="2">
+ <widget class="QSpinBox" name="spinBoxDefault">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>85</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Default value. Off: No default.</string>
+ </property>
+ <property name="whatsThis">
+ <string>Default (initial) value. Off means no default.
+
+If a default value is chosen, the value will be sent
+ to the controller when the controller is added to
+ the song (in piano roll or event editor). When
+ the song is re-loaded, the value is sent again.
+Otherwise the controller remains at its last value.
+Controllers are also automatically added to a
+ song upon reception of a midi controller event.
+
+Caution! Watch out for controllers such as
+ 'Sustain' and 'ResetAllController' with default
+ values. You should probably turn 'off' their
+ default (in piano roll or drum edit, and
+ instrument editor).</string>
+ </property>
+ <property name="specialValueText">
+ <string comment="dont care">off</string>
+ </property>
+ <property name="minimum">
+ <number>-1</number>
+ </property>
+ <property name="maximum">
+ <number>16383</number>
+ </property>
+ <property name="value">
+ <number>-1</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QToolButton" name="addController">
+ <property name="toolTip">
+ <string>Add common controller</string>
+ </property>
+ <property name="text">
+ <string>&amp;Add</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+A</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="deleteController">
+ <property name="toolTip">
+ <string>Delete controller</string>
+ </property>
+ <property name="text">
+ <string>&amp;Delete</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+D</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="newController">
+ <property name="toolTip">
+ <string>Create a new controller</string>
+ </property>
+ <property name="text">
+ <string>New &amp;Controller</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+C</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer13">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>200</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="nullValLabelH">
+ <property name="text">
+ <string>Null Param Hi:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="nullParamSpinBoxH">
+ <property name="toolTip">
+ <string>Null parameter number High byte</string>
+ </property>
+ <property name="whatsThis">
+ <string>If set, these 'null' parameter numbers will
+ be sent after each RPN/NRPN event.
+This prevents subsequent 'data' events
+ from corrupting the RPN/NRPN controller.
+Typically, set to 127/127, or an unused
+ RPN/NRPN controller number.</string>
+ </property>
+ <property name="specialValueText">
+ <string>off</string>
+ </property>
+ <property name="minimum">
+ <number>-1</number>
+ </property>
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ <property name="value">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer13_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>200</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="nullValLabelL">
+ <property name="text">
+ <string> Lo:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="nullParamSpinBoxL">
+ <property name="toolTip">
+ <string>Null parameter number Low byte</string>
+ </property>
+ <property name="whatsThis">
+ <string>If set, these 'null' parameter numbers will
+ be sent after each RPN/NRPN event.
+This prevents subsequent 'data' events
+ from corrupting the RPN/NRPN controller.
+Typically, set to 127/127, or an unused
+ RPN/NRPN controller number.</string>
+ </property>
+ <property name="specialValueText">
+ <string>off</string>
+ </property>
+ <property name="minimum">
+ <number>-1</number>
+ </property>
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ <property name="value">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="sysExTab">
+ <attribute name="title">
+ <string>S&amp;ysEx</string>
+ </attribute>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QSplitter" name="splitter2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <widget class="QWidget" name="layout12">
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QLabel" name="textLabel2_3">
+ <property name="text">
+ <string>SysEx List:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QListWidget" name="sysexList">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="layout11">
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QLabel" name="textLabel1_4">
+ <property name="text">
+ <string>Name:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="sysexName"/>
+ </item>
+ <item>
+ <widget class="QLabel" name="textLabel1_2">
+ <property name="text">
+ <string>Hex Entry:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="sysexData"/>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QToolButton" name="deleteSysex">
+ <property name="text">
+ <string>&amp;Delete</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+D</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="newSysex">
+ <property name="text">
+ <string>New SysE&amp;x</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+X</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer12">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>60</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QToolBar" name="toolBar">
+ <property name="label" stdset="0">
+ <string>Tools</string>
+ </property>
+ <attribute name="toolBarArea">
+ <enum>TopToolBarArea</enum>
+ </attribute>
+ <attribute name="toolBarBreak">
+ <bool>false</bool>
+ </attribute>
+ <addaction name="fileNewAction"/>
+ <addaction name="fileOpenAction"/>
+ <addaction name="fileSaveAction"/>
+ <addaction name="fileSaveAsAction"/>
+ </widget>
+ <widget class="QMenuBar" name="MenuBar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>802</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <property name="defaultUp">
+ <bool>false</bool>
+ </property>
+ <widget class="QMenu" name="fileMenu">
+ <property name="title">
+ <string>&amp;File</string>
+ </property>
+ <addaction name="fileNewAction"/>
+ <addaction name="fileOpenAction"/>
+ <addaction name="fileSaveAction"/>
+ <addaction name="fileSaveAsAction"/>
+ <addaction name="separator"/>
+ <addaction name="fileExitAction"/>
+ </widget>
+ <widget class="QMenu" name="Help">
+ <property name="title">
+ <string>&amp;Help</string>
+ </property>
+ </widget>
+ <addaction name="fileMenu"/>
+ <addaction name="Help"/>
+ </widget>
+ <action name="fileNewAction">
+ <property name="text">
+ <string>&amp;New</string>
+ </property>
+ <property name="iconText">
+ <string>New</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+N</string>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>fileNewAction</cstring>
+ </property>
+ </action>
+ <action name="fileOpenAction">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Open...</string>
+ </property>
+ <property name="iconText">
+ <string>Open</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+O</string>
+ </property>
+ <property name="visible">
+ <bool>false</bool>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>fileOpenAction</cstring>
+ </property>
+ </action>
+ <action name="fileSaveAction">
+ <property name="text">
+ <string>&amp;Save</string>
+ </property>
+ <property name="iconText">
+ <string>Save</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+S</string>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>fileSaveAction</cstring>
+ </property>
+ </action>
+ <action name="fileSaveAsAction">
+ <property name="text">
+ <string>Save &amp;As...</string>
+ </property>
+ <property name="iconText">
+ <string>Save As</string>
+ </property>
+ <property name="shortcut">
+ <string/>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>fileSaveAsAction</cstring>
+ </property>
+ </action>
+ <action name="fileExitAction">
+ <property name="text">
+ <string>E&amp;xit</string>
+ </property>
+ <property name="iconText">
+ <string>Exit</string>
+ </property>
+ <property name="shortcut">
+ <string/>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>fileExitAction</cstring>
+ </property>
+ </action>
+ <action name="filenew_itemAction">
+ <property name="text">
+ <string>new item</string>
+ </property>
+ <property name="iconText">
+ <string>new item</string>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>filenew_itemAction</cstring>
+ </property>
+ </action>
+ <action name="whatsThisAction">
+ <property name="text">
+ <string>What's this?</string>
+ </property>
+ <property name="iconText">
+ <string>What's this?</string>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>whatsThisAction</cstring>
+ </property>
+ </action>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <tabstops>
+ <tabstop>instrumentName</tabstop>
+ <tabstop>instrumentList</tabstop>
+ <tabstop>tabWidget3</tabstop>
+ <tabstop>patchView</tabstop>
+ <tabstop>patchNameEdit</tabstop>
+ <tabstop>spinBoxHBank</tabstop>
+ <tabstop>spinBoxLBank</tabstop>
+ <tabstop>spinBoxProgram</tabstop>
+ <tabstop>checkBoxDrum</tabstop>
+ <tabstop>checkBoxGM</tabstop>
+ <tabstop>checkBoxGS</tabstop>
+ <tabstop>checkBoxXG</tabstop>
+ <tabstop>listController</tabstop>
+ <tabstop>viewController</tabstop>
+ <tabstop>ctrlName</tabstop>
+ <tabstop>ctrlType</tabstop>
+ <tabstop>spinBoxHCtrlNo</tabstop>
+ <tabstop>spinBoxLCtrlNo</tabstop>
+ <tabstop>spinBoxMin</tabstop>
+ <tabstop>spinBoxMax</tabstop>
+ <tabstop>spinBoxDefault</tabstop>
+ <tabstop>sysexList</tabstop>
+ <tabstop>sysexName</tabstop>
+ <tabstop>sysexData</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>fileNewAction</sender>
+ <signal>activated()</signal>
+ <receiver>EditInstrumentBase</receiver>
+ <slot>fileNew()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>fileOpenAction</sender>
+ <signal>activated()</signal>
+ <receiver>EditInstrumentBase</receiver>
+ <slot>fileOpen()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>fileSaveAction</sender>
+ <signal>activated()</signal>
+ <receiver>EditInstrumentBase</receiver>
+ <slot>fileSave()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>fileSaveAsAction</sender>
+ <signal>activated()</signal>
+ <receiver>EditInstrumentBase</receiver>
+ <slot>fileSaveAs()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>fileExitAction</sender>
+ <signal>activated()</signal>
+ <receiver>EditInstrumentBase</receiver>
+ <slot>fileExit()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>whatsThisAction</sender>
+ <signal>activated()</signal>
+ <receiver>EditInstrumentBase</receiver>
+ <slot>helpWhatsThis()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/instruments/midictrledit.cpp b/attic/muse2-oom/muse2/muse/instruments/midictrledit.cpp
new file mode 100644
index 00000000..9dcac628
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/instruments/midictrledit.cpp
@@ -0,0 +1,725 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midictrledit.cpp,v 1.1.1.1.2.2 2008/08/18 00:15:24 terminator356 Exp $
+//
+// (C) Copyright 2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+
+#include "app.h"
+#include "midiport.h"
+#include "mididev.h"
+#include "midictrl.h"
+#include "midictrledit.h"
+#include "minstrument.h"
+#include "song.h"
+#include "xml.h"
+#include "filedialog.h"
+#include "globals.h"
+
+MidiControllerEditDialog* midiControllerEditDialog;
+
+static MidiController predefinedMidiController[] = {
+ MidiController(QString("Pitch"), 0x40000, -8192, +8191, 0),
+ };
+enum {
+ COL_NAME = 0, COL_TYPE,
+ COL_HNUM, COL_LNUM, COL_MIN, COL_MAX
+ };
+//---------------------------------------------------------
+// addControllerToView
+//---------------------------------------------------------
+
+void MidiControllerEditDialog::addControllerToView(MidiController* mctrl)
+ {
+ QString hnum;
+ QString lnum;
+ QString min;
+ QString max;
+ int n = mctrl->num();
+ int h = (n >> 8) & 0x7f;
+ int l = n & 0x7f;
+ MidiController::ControllerType t = midiControllerType(n);
+ switch(t)
+ {
+ case MidiController::Controller7:
+ hnum = "---";
+ lnum.setNum(l);
+ min.setNum(mctrl->minVal());
+ max.setNum(mctrl->maxVal());
+ break;
+ case MidiController::RPN:
+ case MidiController::NRPN:
+ case MidiController::RPN14:
+ case MidiController::NRPN14:
+ case MidiController::Controller14:
+ hnum.setNum(h);
+ lnum.setNum(l);
+ min.setNum(mctrl->minVal());
+ max.setNum(mctrl->maxVal());
+ break;
+ case MidiController::Pitch:
+ hnum = "---";
+ lnum = "---";
+ min.setNum(mctrl->minVal());
+ max.setNum(mctrl->maxVal());
+ break;
+ default:
+ hnum = "---";
+ lnum = "---";
+ min.setNum(0);
+ max.setNum(0);
+ break;
+ }
+
+ new Q3ListViewItem(viewController,
+ mctrl->name(),
+ int2ctrlType(t),
+ hnum, lnum, min, max
+ );
+
+ }
+//---------------------------------------------------------
+// MidiControllerEditDialog
+//---------------------------------------------------------
+
+MidiControllerEditDialog::MidiControllerEditDialog(QWidget* parent, const char* name, bool modal, Qt::WFlags fl)
+ : MidiControllerEditDialogBase(parent, name, modal, fl)
+ {
+ _lastPort = midiPortsList->currentItem();
+ viewController->setColumnAlignment(COL_HNUM, Qt::AlignCenter);
+ viewController->setColumnAlignment(COL_LNUM, Qt::AlignCenter);
+ viewController->setColumnAlignment(COL_MIN, Qt::AlignCenter);
+ viewController->setColumnAlignment(COL_MAX, Qt::AlignCenter);
+ viewController->setColumnWidthMode(COL_NAME, Q3ListView::Maximum);
+
+ // populate list of predefined controller
+ updatePredefinedList();
+
+ // populate ports pulldown
+ updateMidiPortsList();
+ connect(buttonNew, SIGNAL(clicked()), SLOT(ctrlAdd()));
+ connect(buttonDelete, SIGNAL(clicked()), SLOT(ctrlDelete()));
+ connect(entryName, SIGNAL(textChanged(const QString&)), SLOT(nameChanged(const QString&)));
+ connect(comboType, SIGNAL(activated(const QString&)), SLOT(typeChanged(const QString&)));
+ connect(spinboxHCtrlNo, SIGNAL(valueChanged(int)), SLOT(valueHChanged(int)));
+ connect(spinboxLCtrlNo, SIGNAL(valueChanged(int)), SLOT(valueLChanged(int)));
+ connect(spinboxMin, SIGNAL(valueChanged(int)), SLOT(minChanged(int)));
+ connect(spinboxMax, SIGNAL(valueChanged(int)), SLOT(maxChanged(int)));
+ connect(viewController, SIGNAL(selectionChanged()), SLOT(controllerChanged()));
+ connect(buttonApply, SIGNAL(clicked()), SLOT(apply()));
+ connect(midiPortsList, SIGNAL(activated(int)), SLOT(portChanged(int)));
+
+ updateViewController();
+ _modified = false;
+ buttonApply->setEnabled(false);
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void MidiControllerEditDialog::songChanged(int flags)
+{
+ // Is it simply a midi controller value adjustment? Forget it.
+ if(flags == SC_MIDI_CONTROLLER)
+ return;
+
+ if(flags & (SC_CONFIG | SC_MIDI_CONTROLLER))
+ //if(flags & (SC_CONFIG | SC_MIDI_CONTROLLER_ADD))
+ {
+ //listController->blockSignals(true);
+ midiPortsList->blockSignals(true);
+ //viewController->blockSignals(true);
+ updatePredefinedList();
+ updateMidiPortsList();
+ updateViewController();
+ //viewController->setCurrentItem(viewController->firstChild());
+ //controllerChanged(viewController->currentItem());
+ //listController->blockSignals(false);
+ midiPortsList->blockSignals(false);
+ //viewController->blockSignals(false);
+ }
+}
+
+//---------------------------------------------------------
+// updatePredefinedList
+//---------------------------------------------------------
+
+void MidiControllerEditDialog::updatePredefinedList()
+{
+ listController->clear();
+ int size = sizeof(predefinedMidiController) / sizeof(*predefinedMidiController);
+ for (int i = 0; i < size; ++i)
+ listController->insertItem(predefinedMidiController[i].name());
+ listController->setSelected(0, true);
+}
+
+//---------------------------------------------------------
+// updateMidiPortsList
+//---------------------------------------------------------
+
+void MidiControllerEditDialog::updateMidiPortsList()
+{
+ midiPortsList->clear();
+ for (int i = 0; i < MIDI_PORTS; ++i) {
+ MidiPort* port = &midiPorts[i];
+ MidiDevice* dev = port->device();
+ QString name;
+ name.sprintf("%d(%s)", port->portno()+1,
+ dev ? dev->name().toLatin1() : "none");
+ midiPortsList->insertItem(name, i);
+ }
+ _lastPort = midiPortsList->currentItem();
+}
+
+//---------------------------------------------------------
+// updateViewController
+//---------------------------------------------------------
+
+void MidiControllerEditDialog::updateViewController()
+{
+ //for (iMidiController i = midiControllerList.begin();
+ // i != midiControllerList.end(); ++i) {
+ // addControllerToView(&*i);
+ int mpidx = midiPortsList->currentItem();
+
+ viewController->clear();
+ //MidiControllerList* mcl;
+ MidiInstrument* mi = midiPorts[mpidx].instrument();
+ //if(mi)
+ MidiControllerList* mcl = mi->controller();
+ //else
+ // mcl = &defaultMidiController;
+ for (iMidiController i = mcl->begin(); i != mcl->end(); ++i)
+ addControllerToView(*i);
+
+ viewController->blockSignals(true);
+ viewController->setCurrentItem(viewController->firstChild());
+ controllerChanged(viewController->currentItem());
+ viewController->blockSignals(false);
+
+ setModified(false);
+}
+
+//---------------------------------------------------------
+// reject
+//---------------------------------------------------------
+
+void MidiControllerEditDialog::setModified(bool v)
+{
+ if(v == _modified)
+ return;
+
+ _modified = v;
+
+ if(v)
+ {
+ buttonApply->setEnabled(true);
+ }
+ else
+ {
+ buttonApply->setEnabled(false);
+ }
+}
+
+//---------------------------------------------------------
+// reject
+//---------------------------------------------------------
+
+void MidiControllerEditDialog::reject()
+ {
+ //MidiControllerList* mcl;
+// MidiInstrument* mi = midiPorts[mpidx].instrument();
+ //if(mi)
+// MidiControllerList* mcl = mi->controller();
+ //else
+ // mcl = &defaultMidiController;
+// for (iMidiController i = mcl->begin(); i != mcl->end(); ++i)
+// addControllerToView(*i);
+
+ // Restore the list before closing this dialog.
+ updateViewController();
+ //setModified(false);
+
+ MidiControllerEditDialogBase::reject();
+ }
+
+//---------------------------------------------------------
+// apply
+//---------------------------------------------------------
+
+void MidiControllerEditDialog::apply()
+{
+ int mpidx = midiPortsList->currentItem();
+ //MidiControllerList* mcl;
+ MidiInstrument* mi = midiPorts[mpidx].instrument();
+ //if(mi)
+ MidiControllerList* mcl = mi->controller();
+ //else
+ // mcl = &defaultMidiController;
+ mcl->clear();
+
+
+ Q3ListViewItem* item = viewController->firstChild();
+ int hval;
+ int lval;
+ while (item) {
+ hval = item->text(COL_HNUM).toInt();
+ lval = item->text(COL_LNUM).toInt();
+ MidiController* c = new MidiController();
+ c->setName(item->text(COL_NAME));
+
+ MidiController::ControllerType type = ctrlType2Int(item->text(COL_TYPE));
+
+ switch(type) {
+ case MidiController::Controller7:
+ c->setNum(lval);
+ break;
+ case MidiController::Controller14:
+ c->setNum((hval << 8 | lval) | CTRL_14_OFFSET);
+ break;
+ case MidiController::RPN:
+ c->setNum((hval << 8 | lval) | CTRL_RPN_OFFSET);
+ break;
+ case MidiController::NRPN:
+ c->setNum((hval << 8 | lval) | CTRL_NRPN_OFFSET);
+ break;
+ case MidiController::RPN14:
+ c->setNum((hval << 8 | lval) | CTRL_RPN14_OFFSET);
+ break;
+ case MidiController::NRPN14:
+ c->setNum((hval << 8 | lval) | CTRL_NRPN14_OFFSET);
+ break;
+ case MidiController::Program:
+ c->setNum(CTRL_PROGRAM);
+ break;
+ case MidiController::Pitch:
+ c->setNum(CTRL_PITCH);
+ break;
+ default:
+ break;
+ }
+ if(type == MidiController::Program)
+ {
+ c->setMinVal(0);
+ c->setMaxVal(0xffffff);
+ }
+ else
+ {
+ c->setMinVal(item->text(COL_MIN).toInt());
+ c->setMaxVal(item->text(COL_MAX).toInt());
+ }
+
+ mcl->push_back(c);
+
+ item = item->nextSibling();
+ }
+
+ // Update the list before closing this dialog.
+ //updateViewController();
+ //setModified(false);
+ song->update(SC_CONFIG | SC_MIDI_CONTROLLER);
+}
+
+//---------------------------------------------------------
+// ctrlAdd
+//---------------------------------------------------------
+
+void MidiControllerEditDialog::ctrlAdd()
+ {
+ Q3ListBoxItem* item = listController->selectedItem();
+ if (item == 0)
+ return;
+ QString name = item->text();
+ int size = sizeof(predefinedMidiController) / sizeof(*predefinedMidiController);
+ for (int i = 0; i < size; ++i) {
+ MidiController* c = &predefinedMidiController[i];
+ if (c->name() != name)
+ continue;
+ MidiController::ControllerType t = midiControllerType(c->num());
+ QString type = int2ctrlType(t);
+ QString min, max;
+ QString hno, lno;
+ int h = (c->num() >> 8) & 0x7f;
+ int l = c->num() & 0x7f;
+
+ switch(t) {
+ case MidiController::Controller7:
+ min.setNum(c->minVal());
+ max.setNum(c->maxVal());
+ hno = "---";
+ lno.setNum(l);
+ break;
+ case MidiController::RPN:
+ case MidiController::NRPN:
+ case MidiController::RPN14:
+ case MidiController::NRPN14:
+ case MidiController::Controller14:
+ min.setNum(c->minVal());
+ max.setNum(c->maxVal());
+ hno.setNum(h);
+ lno.setNum(l);
+ break;
+ case MidiController::Pitch:
+ min.setNum(c->minVal());
+ max.setNum(c->maxVal());
+ hno = "---";
+ lno = "---";
+ break;
+ default:
+ hno = "---";
+ lno = "---";
+ min.setNum(0);
+ max.setNum(0);
+ break;
+ }
+
+ Q3ListViewItem* item = new Q3ListViewItem(viewController,
+ name, type, hno, lno, min, max);
+
+ viewController->blockSignals(true);
+ viewController->setCurrentItem(item);
+ controllerChanged(item);
+ viewController->blockSignals(false);
+
+ setModified(true);
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// ctrlDelete
+//---------------------------------------------------------
+
+void MidiControllerEditDialog::ctrlDelete()
+ {
+ Q3ListViewItem* item = viewController->currentItem();
+ if (item == 0)
+ return;
+ delete item;
+
+ setModified(true);
+ }
+
+//---------------------------------------------------------
+// accept
+//---------------------------------------------------------
+
+void MidiControllerEditDialog::accept()
+ {
+ apply();
+ MidiControllerEditDialogBase::accept();
+ }
+
+//---------------------------------------------------------
+// portChanged
+//---------------------------------------------------------
+
+void MidiControllerEditDialog::portChanged(int n)
+ {
+ if(n == _lastPort)
+ return;
+ _lastPort = n;
+
+ //listController->blockSignals(true);
+ //midiPortsList->blockSignals(true);
+ //viewController->blockSignals(true);
+ //updatePredefinedList();
+ //updateMidiPortsList();
+ //reject(); // populate list
+ updateViewController();
+ //viewController->setCurrentItem(viewController->firstChild());
+ //controllerChanged(viewController->currentItem());
+ //listController->blockSignals(false);
+ //midiPortsList->blockSignals(false);
+ //viewController->blockSignals(false);
+ }
+
+//---------------------------------------------------------
+// nameChanged
+//---------------------------------------------------------
+
+void MidiControllerEditDialog::nameChanged(const QString& s)
+ {
+ Q3ListViewItem* item = viewController->currentItem();
+ if (item == 0)
+ return;
+ item->setText(COL_NAME, s);
+
+ setModified(true);
+ }
+
+//---------------------------------------------------------
+// typeChanged
+//---------------------------------------------------------
+
+void MidiControllerEditDialog::typeChanged(const QString& s)
+ {
+ Q3ListViewItem* item = viewController->currentItem();
+ if (item == 0)
+ return;
+ item->setText(COL_TYPE, s);
+ switch(ctrlType2Int(s)) {
+ case MidiController::Controller14:
+ case MidiController::RPN14:
+ case MidiController::NRPN14:
+ item->setText(COL_LNUM, QString("0"));
+ item->setText(COL_HNUM, QString("0"));
+ item->setText(COL_MIN, QString("0"));
+ item->setText(COL_MAX, QString("16383"));
+ break;
+ case MidiController::Controller7:
+ item->setText(COL_MIN, QString("0"));
+ item->setText(COL_MAX, QString("127"));
+ item->setText(COL_LNUM, QString("0"));
+ item->setText(COL_HNUM, QString("---"));
+ break;
+ case MidiController::RPN:
+ case MidiController::NRPN:
+ item->setText(COL_MIN, QString("0"));
+ item->setText(COL_MAX, QString("127"));
+ item->setText(COL_LNUM, QString("0"));
+ item->setText(COL_HNUM, QString("0"));
+ break;
+
+ case MidiController::Program:
+
+ item->setText(COL_MIN, QString("---"));
+ item->setText(COL_MAX, QString("---"));
+ item->setText(COL_LNUM, QString("---"));
+ item->setText(COL_HNUM, QString("---"));
+ break;
+ case MidiController::Pitch:
+ item->setText(COL_MIN, QString("-8192"));
+ item->setText(COL_MAX, QString("8191"));
+ item->setText(COL_LNUM, QString("---"));
+ item->setText(COL_HNUM, QString("---"));
+ break;
+ default:
+ break;
+ }
+
+ setModified(true);
+
+ controllerChanged(item);
+ }
+
+//---------------------------------------------------------
+// valueHChanged
+//---------------------------------------------------------
+
+void MidiControllerEditDialog::valueHChanged(int val)
+ {
+ Q3ListViewItem* item = viewController->currentItem();
+ if (item == 0)
+ return;
+ QString s;
+ s.setNum(val);
+ item->setText(COL_HNUM, s);
+
+ setModified(true);
+ }
+
+//---------------------------------------------------------
+// valueLChanged
+//---------------------------------------------------------
+
+void MidiControllerEditDialog::valueLChanged(int val)
+ {
+ Q3ListViewItem* item = viewController->currentItem();
+ if (item == 0)
+ return;
+ QString s;
+ s.setNum(val);
+ item->setText(COL_LNUM, s);
+
+ setModified(true);
+ }
+
+//---------------------------------------------------------
+// controllerChanged
+//---------------------------------------------------------
+
+void MidiControllerEditDialog::controllerChanged()
+ {
+ Q3ListViewItem* item = viewController->selectedItem();
+ controllerChanged(item);
+ }
+
+void MidiControllerEditDialog::controllerChanged(Q3ListViewItem* item)
+ {
+ if (item == 0) {
+ entryName->setEnabled(false);
+ comboType->setEnabled(false);
+ spinboxHCtrlNo->setEnabled(false);
+ spinboxLCtrlNo->setEnabled(false);
+ spinboxMin->setEnabled(false);
+ spinboxMax->setEnabled(false);
+ return;
+ }
+
+ entryName->blockSignals(true);
+ comboType->blockSignals(true);
+ spinboxHCtrlNo->blockSignals(true);
+ spinboxLCtrlNo->blockSignals(true);
+ spinboxMin->blockSignals(true);
+ spinboxMax->blockSignals(true);
+
+ entryName->setEnabled(true);
+ entryName->setText(item->text(COL_NAME));
+ comboType->setCurrentItem(int(ctrlType2Int(item->text(COL_TYPE))));
+ switch (ctrlType2Int(item->text(COL_TYPE))) {
+ case MidiController::Controller7:
+ comboType->setEnabled(true);
+ spinboxHCtrlNo->setEnabled(false);
+ spinboxLCtrlNo->setEnabled(true);
+ spinboxMin->setEnabled(true);
+ spinboxMax->setEnabled(true);
+ spinboxHCtrlNo->setValue(0);
+ spinboxLCtrlNo->setValue(item->text(COL_LNUM).toInt());
+ spinboxMin->setRange(0, 127);
+ spinboxMax->setRange(0, 127);
+ spinboxMin->setValue(item->text(COL_MIN).toInt());
+ spinboxMax->setValue(item->text(COL_MAX).toInt());
+ break;
+
+ case MidiController::RPN:
+ case MidiController::NRPN:
+ comboType->setEnabled(true);
+ spinboxHCtrlNo->setEnabled(true);
+ spinboxLCtrlNo->setEnabled(true);
+ spinboxMin->setEnabled(true);
+ spinboxMax->setEnabled(true);
+ spinboxHCtrlNo->setValue(item->text(COL_HNUM).toInt());
+ spinboxLCtrlNo->setValue(item->text(COL_LNUM).toInt());
+ spinboxMin->setRange(0, 127);
+ spinboxMax->setRange(0, 127);
+ spinboxMin->setValue(item->text(COL_MIN).toInt());
+ spinboxMax->setValue(item->text(COL_MAX).toInt());
+ break;
+ case MidiController::Controller14:
+ case MidiController::RPN14:
+ case MidiController::NRPN14:
+ comboType->setEnabled(true);
+ spinboxHCtrlNo->setEnabled(true);
+ spinboxLCtrlNo->setEnabled(true);
+ spinboxMin->setEnabled(true);
+ spinboxMax->setEnabled(true);
+
+ spinboxHCtrlNo->setValue(item->text(COL_HNUM).toInt());
+ spinboxLCtrlNo->setValue(item->text(COL_LNUM).toInt());
+ spinboxMin->setRange(0, 16383);
+ spinboxMax->setRange(0, 16383);
+ spinboxMin->setValue(item->text(COL_MIN).toInt());
+ spinboxMax->setValue(item->text(COL_MAX).toInt());
+ break;
+
+ case MidiController::Pitch:
+ comboType->setEnabled(true);
+ spinboxHCtrlNo->setEnabled(false);
+ spinboxLCtrlNo->setEnabled(false);
+ spinboxMin->setEnabled(true);
+ spinboxMax->setEnabled(true);
+ spinboxHCtrlNo->setValue(0);
+ spinboxLCtrlNo->setValue(0);
+ spinboxMin->setRange(-8192, 8191);
+ spinboxMax->setRange(-8192, 8191);
+ spinboxMin->setValue(item->text(COL_MIN).toInt());
+ spinboxMax->setValue(item->text(COL_MAX).toInt());
+ break;
+
+ case MidiController::Program:
+ comboType->setEnabled(true);
+ spinboxHCtrlNo->setEnabled(false);
+ spinboxLCtrlNo->setEnabled(false);
+ spinboxMin->setEnabled(false);
+ spinboxMax->setEnabled(false);
+ spinboxHCtrlNo->setValue(0);
+ spinboxLCtrlNo->setValue(0);
+ spinboxMin->setRange(0, 0);
+ spinboxMax->setRange(0, 0);
+ spinboxMin->setValue(0);
+ spinboxMax->setValue(0);
+ break;
+ default:
+ break;
+ }
+ entryName->blockSignals(false);
+ comboType->blockSignals(false);
+ spinboxHCtrlNo->blockSignals(false);
+ spinboxLCtrlNo->blockSignals(false);
+ spinboxMin->blockSignals(false);
+ spinboxMax->blockSignals(false);
+ }
+
+//---------------------------------------------------------
+// minChanged
+//---------------------------------------------------------
+
+void MidiControllerEditDialog::minChanged(int val)
+ {
+ Q3ListViewItem* item = viewController->currentItem();
+ if (item == 0)
+ return;
+
+ QString s;
+ s.setNum(val);
+ item->setText(COL_MIN, s);
+
+ if(val > item->text(COL_MAX).toInt())
+ {
+ spinboxMax->blockSignals(true);
+ spinboxMax->setValue(val);
+ item->setText(COL_MAX, s);
+ spinboxMax->blockSignals(false);
+ }
+ setModified(true);
+ }
+
+//---------------------------------------------------------
+// maxChanged
+//---------------------------------------------------------
+
+void MidiControllerEditDialog::maxChanged(int val)
+ {
+ Q3ListViewItem* item = viewController->currentItem();
+ if (item == 0)
+ return;
+
+ QString s;
+ s.setNum(val);
+ item->setText(COL_MAX, s);
+
+ if(val < item->text(COL_MIN).toInt())
+ {
+ spinboxMin->blockSignals(true);
+ spinboxMin->setValue(val);
+ item->setText(COL_MIN, s);
+ spinboxMin->blockSignals(false);
+ }
+ setModified(true);
+ }
+
+//---------------------------------------------------------
+// configMidiController
+//---------------------------------------------------------
+
+void configMidiController()
+ {
+ if (midiControllerEditDialog == 0)
+ {
+ midiControllerEditDialog = new MidiControllerEditDialog();
+ midiControllerEditDialog->show();
+ }
+ else
+ {
+ if(midiControllerEditDialog->isShown())
+ midiControllerEditDialog->hide();
+ else
+ midiControllerEditDialog->show();
+ }
+ }
diff --git a/attic/muse2-oom/muse2/muse/instruments/midictrledit.h b/attic/muse2-oom/muse2/muse/instruments/midictrledit.h
new file mode 100644
index 00000000..e1624f29
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/instruments/midictrledit.h
@@ -0,0 +1,56 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midictrledit.h,v 1.1.1.1.2.1 2008/08/18 00:15:25 terminator356 Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MIDICTRLEDIT_H__
+#define __MIDICTRLEDIT_H__
+
+#include "ccontrolbase.h"
+#include "midictrl.h"
+
+//---------------------------------------------------------
+// MidiControllerEditDialog
+//---------------------------------------------------------
+
+class MidiControllerEditDialog : public MidiControllerEditDialogBase {
+ Q_OBJECT
+
+ int _lastPort;
+ bool _modified;
+
+ void addControllerToView(MidiController* mctrl);
+ void mergeReplace(bool replace);
+ void updatePredefinedList();
+ void updateMidiPortsList();
+ void updateViewController();
+ void setModified(bool);
+
+ private slots:
+ void ctrlAdd();
+ void ctrlDelete();
+ virtual void accept();
+ virtual void reject();
+ void apply();
+ void nameChanged(const QString&);
+ void typeChanged(const QString&);
+ void valueHChanged(int);
+ void valueLChanged(int);
+ void controllerChanged(Q3ListViewItem*);
+ void controllerChanged();
+ void minChanged(int);
+ void maxChanged(int);
+ void portChanged(int);
+ void songChanged(int);
+
+ public:
+ MidiControllerEditDialog(QWidget* parent = 0, const char* name = 0, bool modal = false, Qt::WFlags fl = 0);
+ };
+
+extern MidiControllerEditDialog* midiControllerEditDialog;
+extern void configMidiController();
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/instruments/minstrument.cpp b/attic/muse2-oom/muse2/muse/instruments/minstrument.cpp
new file mode 100644
index 00000000..8df7d4c7
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/instruments/minstrument.cpp
@@ -0,0 +1,927 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: minstrument.cpp,v 1.10.2.5 2009/03/28 01:46:10 terminator356 Exp $
+//
+// (C) Copyright 2000-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+
+#include <QAction>
+#include <QDir>
+#include <QFileInfo>
+#include <QMenu>
+#include <QMessageBox>
+#include <QList>
+
+#include "minstrument.h"
+#include "midiport.h"
+#include "globals.h"
+#include "xml.h"
+#include "event.h"
+#include "mpevent.h"
+#include "midictrl.h"
+#include "gconfig.h"
+
+MidiInstrumentList midiInstruments;
+MidiInstrument* genericMidiInstrument;
+
+static const char* gmdrumname = "GM-drums";
+
+//---------------------------------------------------------
+// string2sysex
+//---------------------------------------------------------
+
+int string2sysex(const QString& s, unsigned char** data)
+ {
+ QByteArray ba = s.toLatin1();
+ const char* src = ba.constData();
+ char buffer[2048];
+ char* dst = buffer;
+
+ if(src) {
+ while (*src) {
+ while (*src == ' ' || *src == '\n') {
+ ++src;
+ }
+ char* ep;
+ long val = strtol(src, &ep, 16);
+ if (ep == src) {
+ QMessageBox::information(0,
+ QString("MusE"),
+ QWidget::tr("Cannot convert sysex string"));
+ return 0;
+ }
+ src = ep;
+ *dst++ = val;
+ if (dst - buffer >= 2048) {
+ QMessageBox::information(0,
+ QString("MusE"),
+ QWidget::tr("Hex String too long (2048 bytes limit)"));
+ return 0;
+ }
+ }
+ }
+ int len = dst - buffer;
+ unsigned char* b = new unsigned char[len+1];
+ memcpy(b, buffer, len);
+ b[len] = 0;
+ *data = b;
+ return len;
+ }
+
+//---------------------------------------------------------
+// sysex2string
+//---------------------------------------------------------
+
+QString sysex2string(int len, unsigned char* data)
+ {
+ QString d;
+ QString s;
+ for (int i = 0; i < len; ++i) {
+ if ((i > 0) && ((i % 8)==0)) {
+ d += "\n";
+ }
+ else if (i)
+ d += " ";
+ d += s.sprintf("%02x", data[i]);
+ }
+ return d;
+ }
+
+//---------------------------------------------------------
+// readEventList
+//---------------------------------------------------------
+
+static void readEventList(Xml& xml, EventList* el, const char* name)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "event") {
+ Event e(Note);
+ e.read(xml);
+ el->add(e);
+ }
+ else
+ xml.unknown("readEventList");
+ break;
+ case Xml::TagEnd:
+ if (tag == name)
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+//---------------------------------------------------------
+// loadIDF
+//---------------------------------------------------------
+
+static void loadIDF(QFileInfo* fi)
+ {
+/*
+ QFile qf(fi->filePath());
+ if (!qf.open(IO_ReadOnly)) {
+ printf("cannot open file %s\n", fi->fileName().toLatin1());
+ return;
+ }
+ if (debugMsg)
+ printf(" load instrument definition <%s>\n", fi->filePath().local8Bit().data());
+ QDomDocument doc;
+ int line, column;
+ QString err;
+ if (!doc.setContent(&qf, false, &err, &line, &column)) {
+ QString col, ln, error;
+ col.setNum(column);
+ ln.setNum(line);
+ error = err + " at line: " + ln + " col: " + col;
+ printf("error reading file <%s>:\n %s\n",
+ fi->filePath().toLatin1(), error.toLatin1());
+ return;
+ }
+ QDomNode node = doc.documentElement();
+ while (!node.isNull()) {
+ QDomElement e = node.toElement();
+ if (e.isNull())
+ continue;
+ if (e.tagName() == "muse") {
+ QString version = e.attribute(QString("version"));
+ for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) {
+ QDomElement e = n.toElement();
+ if (e.tagName() == "MidiInstrument") {
+ MidiInstrument* i = new MidiInstrument();
+ i->read(n);
+ i->setFilePath(fi->filePath());
+ bool replaced = false;
+ for (int idx = 0; idx < midiInstruments.size(); ++idx) {
+ if (midiInstruments[idx]->iname() == i->iname()) {
+ midiInstruments.replace(idx, i);
+ replaced = true;
+ if (debugMsg)
+ printf("Midi Instrument Definition <%s> overwritten\n",
+ i->iname().toLocal8Bit().data());
+ break;
+ }
+ }
+ if (!replaced)
+ midiInstruments += i;
+ }
+ }
+ }
+ else
+ printf("MusE:laodIDF: %s not supported\n", e.tagName().toLatin1());
+ node = node.nextSibling();
+ }
+ qf.close();
+*/
+
+ FILE* f = fopen(fi->filePath().toAscii().constData(), "r");
+ if (f == 0)
+ return;
+ if (debugMsg)
+ printf("READ IDF %s\n", fi->filePath().toLatin1().constData());
+ Xml xml(f);
+
+ bool skipmode = true;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (skipmode && tag == "muse")
+ skipmode = false;
+ else if (skipmode)
+ break;
+ else if (tag == "MidiInstrument") {
+ MidiInstrument* i = new MidiInstrument();
+ i->setFilePath(fi->filePath());
+ i->read(xml);
+ // Ignore duplicate named instruments.
+ iMidiInstrument ii = midiInstruments.begin();
+ for(; ii != midiInstruments.end(); ++ii)
+ {
+ if((*ii)->iname() == i->iname())
+ break;
+ }
+ if(ii == midiInstruments.end())
+ midiInstruments.push_back(i);
+ else
+ delete i;
+ }
+ else
+ xml.unknown("muse");
+ break;
+ case Xml::Attribut:
+ break;
+ case Xml::TagEnd:
+ if (!skipmode && tag == "muse") {
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ fclose(f);
+
+
+ }
+
+//---------------------------------------------------------
+// initMidiInstruments
+//---------------------------------------------------------
+
+void initMidiInstruments()
+ {
+ genericMidiInstrument = new MidiInstrument(QWidget::tr("generic midi"));
+ midiInstruments.push_back(genericMidiInstrument);
+ if (debugMsg)
+ printf("load user instrument definitions from <%s>\n", museUserInstruments.toLatin1().constData());
+ QDir usrInstrumentsDir(museUserInstruments, QString("*.idf"));
+ if (usrInstrumentsDir.exists()) {
+ QFileInfoList list = usrInstrumentsDir.entryInfoList();
+ QFileInfoList::iterator it=list.begin(); // ddskrjo
+ while(it != list.end()) { // ddskrjo
+ loadIDF(&*it);
+ ++it;
+ }
+ }
+ //else
+ //{
+ // if(usrInstrumentsDir.mkdir(museUserInstruments))
+ // printf("Created user instrument directory: %s\n", museUserInstruments.toLatin1());
+ // else
+ // printf("Unable to create user instrument directory: %s\n", museUserInstruments.toLatin1());
+ //}
+
+ if (debugMsg)
+ printf("load instrument definitions from <%s>\n", museInstruments.toLatin1().constData());
+ QDir instrumentsDir(museInstruments, QString("*.idf"));
+ if (instrumentsDir.exists()) {
+ QFileInfoList list = instrumentsDir.entryInfoList();
+ QFileInfoList::iterator it=list.begin(); // ddskrjo
+ while(it!=list.end()) {
+ loadIDF(&*it);
+ ++it;
+ }
+ }
+ else
+ printf("Instrument directory not found: %s\n", museInstruments.toLatin1().constData());
+
+ }
+
+//---------------------------------------------------------
+// registerMidiInstrument
+//---------------------------------------------------------
+
+MidiInstrument* registerMidiInstrument(const QString& name)
+ {
+ for (iMidiInstrument i = midiInstruments.begin();
+ i != midiInstruments.end(); ++i) {
+ if ((*i)->iname() == name)
+ return *i;
+ }
+ return genericMidiInstrument;
+ }
+
+//---------------------------------------------------------
+// removeMidiInstrument
+//---------------------------------------------------------
+
+void removeMidiInstrument(const QString& name)
+ {
+ for (iMidiInstrument i = midiInstruments.begin();
+ i != midiInstruments.end(); ++i) {
+ if ((*i)->iname() == name) {
+ midiInstruments.erase(i);
+ return;
+ }
+ }
+ }
+
+void removeMidiInstrument(const MidiInstrument* instr)
+ {
+ for (iMidiInstrument i = midiInstruments.begin();
+ i != midiInstruments.end(); ++i) {
+ if (*i == instr) {
+ midiInstruments.erase(i);
+ return;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// MidiInstrument
+//---------------------------------------------------------
+
+void MidiInstrument::init()
+ {
+ _nullvalue = -1;
+ _initScript = 0;
+ _midiInit = new EventList();
+ _midiReset = new EventList();
+ _midiState = new EventList();
+ _controller = new MidiControllerList;
+
+ // add some default controller to controller list
+ // this controllers are always available for all instruments
+ //
+ MidiController* prog = new MidiController("Program", CTRL_PROGRAM, 0, 0xffffff, 0);
+ _controller->add(prog);
+ _dirty = false;
+ }
+
+MidiInstrument::MidiInstrument()
+ {
+ init();
+ }
+
+//---------------------------------------------------------
+// MidiInstrument
+//---------------------------------------------------------
+
+MidiInstrument::MidiInstrument(const QString& txt)
+ {
+ _name = txt;
+ init();
+ }
+
+//---------------------------------------------------------
+// MidiInstrument
+//---------------------------------------------------------
+
+MidiInstrument::~MidiInstrument()
+ {
+ for (ciPatchGroup g = pg.begin(); g != pg.end(); ++g)
+ {
+ PatchGroup* pgp = *g;
+ const PatchList& pl = pgp->patches;
+ for (ciPatch p = pl.begin(); p != pl.end(); ++p)
+ {
+ delete *p;
+ }
+ delete pgp;
+ }
+
+
+ delete _midiInit;
+ delete _midiReset;
+ delete _midiState;
+ for(iMidiController i = _controller->begin(); i != _controller->end(); ++i)
+ delete i->second;
+ delete _controller;
+
+ if (_initScript)
+ delete _initScript;
+ }
+
+/*
+//---------------------------------------------------------
+// uniqueCopy
+//---------------------------------------------------------
+
+MidiInstrument& MidiInstrument::uniqueCopy(const MidiInstrument& ins)
+{
+ _initScript = 0;
+ _midiInit = new EventList();
+ _midiReset = new EventList();
+ _midiState = new EventList();
+ //---------------------------------------------------------
+ // TODO: Copy the init script, and the lists.
+ //---------------------------------------------------------
+ _controller = new MidiControllerList(*(ins._controller));
+
+ // Assignment
+ pg = ins.pg;
+
+ _name = ins._name;
+ _filePath = ins._filePath;
+
+ // Hmm, dirty, yes? But init sets it to false...
+ //_dirty = ins._dirty;
+ //_dirty = false;
+ _dirty = true;
+
+ return *this;
+}
+*/
+
+//---------------------------------------------------------
+// assign
+//---------------------------------------------------------
+
+MidiInstrument& MidiInstrument::assign(const MidiInstrument& ins)
+{
+ //---------------------------------------------------------
+ // TODO: Copy the _initScript, and _midiInit, _midiReset, and _midiState lists.
+ //---------------------------------------------------------
+
+ for(iMidiController i = _controller->begin(); i != _controller->end(); ++i)
+ delete i->second;
+ _controller->clear();
+
+ _nullvalue = ins._nullvalue;
+
+ // Assignment
+ // *_controller = *(ins._controller);
+ for(ciMidiController i = ins._controller->begin(); i != ins._controller->end(); ++i)
+ {
+ MidiController* mc = i->second;
+ _controller->add(new MidiController(*mc));
+ }
+
+// pg.clear();
+// for(iPatchGroup ipg = pg.begin(); ipg != pg.end(); ++ipg)
+// {
+ //ipg->patches.clear();
+
+ //const PatchGroup& g = *ipg;
+ //for(ciPatch ip = ipg->begin(); ip != ipg->end(); ++ipg)
+ //{
+
+ //}
+// }
+
+ for (ciPatchGroup g = pg.begin(); g != pg.end(); ++g)
+ {
+ PatchGroup* pgp = *g;
+ const PatchList& pl = pgp->patches;
+ for (ciPatch p = pl.begin(); p != pl.end(); ++p)
+ {
+ delete *p;
+ }
+
+ delete pgp;
+ }
+ pg.clear();
+
+ // Assignment
+// pg = ins.pg;
+ for(ciPatchGroup g = ins.pg.begin(); g != ins.pg.end(); ++g)
+ {
+ PatchGroup* pgp = *g;
+ const PatchList& pl = pgp->patches;
+ PatchGroup* npg = new PatchGroup;
+ npg->name = pgp->name;
+ pg.push_back(npg);
+ for (ciPatch p = pl.begin(); p != pl.end(); ++p)
+ {
+ Patch* pp = *p;
+ Patch* np = new Patch;
+ np->typ = pp->typ;
+ np->hbank = pp->hbank;
+ np->lbank = pp->lbank;
+ np->prog = pp->prog;
+ np->name = pp->name;
+ np->drum = pp->drum;
+ npg->patches.push_back(np);
+ }
+ }
+
+ _name = ins._name;
+ _filePath = ins._filePath;
+
+ // Hmm, dirty, yes? But init sets it to false...
+ //_dirty = ins._dirty;
+ //_dirty = false;
+ //_dirty = true;
+
+ return *this;
+}
+
+//---------------------------------------------------------
+// reset
+// send note off to all channels
+//---------------------------------------------------------
+
+void MidiInstrument::reset(int portNo, MType)
+ {
+ MidiPlayEvent ev;
+ ev.setType(0x90);
+ MidiPort* port = &midiPorts[portNo];
+ if (port == 0)
+ return;
+ ev.setPort(portNo);
+ for (int chan = 0; chan < MIDI_CHANNELS; ++chan) {
+ ev.setChannel(chan);
+ for (int pitch = 0; pitch < 128; ++pitch) {
+ ev.setA(pitch);
+ ev.setB(0);
+ port->sendEvent(ev);
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// readPatchGroup
+//---------------------------------------------------------
+
+void PatchGroup::read(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "Patch") {
+ Patch* patch = new Patch;
+ patch->read(xml);
+ patches.push_back(patch);
+ }
+ else
+ xml.unknown("PatchGroup");
+ break;
+ case Xml::Attribut:
+ if (tag == "name")
+ name = xml.s2();
+ break;
+ case Xml::TagEnd:
+ if (tag == "PatchGroup")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+void Patch::read(Xml& xml)
+ {
+ typ = -1;
+ hbank = -1;
+ lbank = -1;
+ prog = 0;
+ drum = false;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ xml.unknown("Patch");
+ break;
+ case Xml::Attribut:
+ if (tag == "name")
+ name = xml.s2();
+ else if (tag == "mode")
+ typ = xml.s2().toInt();
+ else if (tag == "hbank")
+ hbank = xml.s2().toInt();
+ else if (tag == "lbank")
+ lbank = xml.s2().toInt();
+ else if (tag == "prog")
+ prog = xml.s2().toInt();
+ else if (tag == "drum")
+ drum = xml.s2().toInt();
+ break;
+ case Xml::TagEnd:
+ if (tag == "Patch")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+void Patch::write(int level, Xml& xml)
+ {
+ //if (drumMap == 0)
+ //{
+ //QString s = QString("Patch name=\"%1\"").arg(Xml::xmlString(name));
+ //if (typ != -1)
+ // s += QString(" mode=\"%d\"").arg(typ);
+ //s += QString(" hbank=\"%1\" lbank=\"%2\" prog=\"%3\"").arg(hbank).arg(lbank).arg(prog);
+ //xml.tagE(s);
+ xml.nput(level, "<Patch name=\"%s\"", Xml::xmlString(name).toLatin1().constData());
+ if(typ != -1)
+ xml.nput(" mode=\"%d\"", typ);
+
+ if(hbank != -1)
+ xml.nput(" hbank=\"%d\"", hbank);
+
+ if(lbank != -1)
+ xml.nput(" lbank=\"%d\"", lbank);
+
+ xml.nput(" prog=\"%d\"", prog);
+
+ //xml.nput(level, " hbank=\"%d\" lbank=\"%d\" prog=\"%d\"", hbank, lbank, prog);
+ if(drum)
+ //xml.nput(level, " drum=\"%d\"", int(drum));
+ xml.nput(" drum=\"%d\"", int(drum));
+ //xml.put(level, " />");
+ xml.put(" />");
+
+ //return;
+ //}
+
+ //QString s = QString("drummap name=\"%1\"").arg(Xml::xmlString(name));
+ //s += QString(" hbank=\"%1\" lbank=\"%2\" prog=\"%3\"").arg(hbank).arg(lbank).arg(prog);
+ //xml.stag(s);
+ //for (int i = 0; i < DRUM_MAPSIZE; ++i) {
+ // DrumMapEntry* dm = drumMap->entry(i);
+ // dm->write(xml);
+ // }
+ //xml.etag("drummap");
+ }
+
+//---------------------------------------------------------
+// readMidiState
+//---------------------------------------------------------
+
+void MidiInstrument::readMidiState(Xml& xml)
+ {
+ _midiState->read(xml, "midistate", true);
+ }
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+void MidiInstrument::read(Xml& xml)
+ {
+ bool ok;
+ int base = 10;
+ _nullvalue = -1;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "Patch") {
+ Patch* patch = new Patch;
+ patch->read(xml);
+ if (pg.empty()) {
+ PatchGroup* p = new PatchGroup;
+ p->patches.push_back(patch);
+ pg.push_back(p);
+ }
+ else
+ pg[0]->patches.push_back(patch);
+ }
+ else if (tag == "PatchGroup") {
+ PatchGroup* p = new PatchGroup;
+ p->read(xml);
+ pg.push_back(p);
+ }
+ else if (tag == "Controller") {
+ MidiController* mc = new MidiController();
+ mc->read(xml);
+ // Added by Tim. Copied from muse 2.
+ //
+ // HACK: make predefined "Program" controller overloadable
+ //
+ if (mc->name() == "Program") {
+ for (iMidiController i = _controller->begin(); i != _controller->end(); ++i) {
+ if (i->second->name() == mc->name()) {
+ delete i->second;
+ _controller->erase(i);
+ break;
+ }
+ }
+ }
+
+ _controller->add(mc);
+ }
+ else if (tag == "Init")
+ readEventList(xml, _midiInit, "Init");
+ else if (tag == "Reset")
+ readEventList(xml, _midiReset, "Reset");
+ else if (tag == "State")
+ readEventList(xml, _midiState, "State");
+ else if (tag == "InitScript") {
+ if (_initScript)
+ delete _initScript;
+ QByteArray ba = xml.parse1().toLatin1();
+ const char* istr = ba.constData();
+ int len = strlen(istr) +1;
+ if (len > 1) {
+ _initScript = new char[len];
+ memcpy(_initScript, istr, len);
+ }
+ }
+
+ else
+ xml.unknown("MidiInstrument");
+ break;
+ case Xml::Attribut:
+ if (tag == "name")
+ setIName(xml.s2());
+ else if(tag == "nullparam") {
+ _nullvalue = xml.s2().toInt(&ok, base);
+ }
+ break;
+ case Xml::TagEnd:
+ if (tag == "MidiInstrument")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+void MidiInstrument::write(int level, Xml& xml)
+ {
+ xml.header();
+ //xml.stag("muse version=\"2.1\"");
+ xml.tag(level, "muse version=\"1.0\"");
+ //xml.stag(QString("MidiInstrument name=\"%1\"").arg(Xml::xmlString(iname())));
+ level++;
+ //xml.tag(level, "MidiInstrument name=\"%s\"", Xml::xmlString(iname()).toLatin1().constData());
+ xml.nput(level, "<MidiInstrument name=\"%s\"", Xml::xmlString(iname()).toLatin1().constData());
+
+ if(_nullvalue != -1)
+ {
+ QString nv;
+ nv.setNum(_nullvalue);
+ xml.nput(" nullparam=\"%s\"", nv.toLatin1().constData());
+ }
+ xml.put(">");
+
+ // -------------
+ // What about Init, Reset, State, and InitScript ?
+ // -------------
+
+ //std::vector<PatchGroup>* pg = groups();
+ //for (std::vector<PatchGroup>::iterator g = pg->begin(); g != pg->end(); ++g) {
+ level++;
+ //for (std::vector<PatchGroup>::iterator g = pg.begin(); g != pg.end(); ++g) {
+ for (ciPatchGroup g = pg.begin(); g != pg.end(); ++g) {
+ PatchGroup* pgp = *g;
+ const PatchList& pl = pgp->patches;
+ //xml.stag(QString("PatchGroup name=\"%1\"").arg(Xml::xmlString(g->name)));
+ //xml.tag(level, "PatchGroup name=\"%s\"", Xml::xmlString(g->name).toLatin1().constData());
+ xml.tag(level, "PatchGroup name=\"%s\"", Xml::xmlString(pgp->name).toLatin1().constData());
+ level++;
+ //for (iPatch p = g->patches.begin(); p != g->patches.end(); ++p)
+ for (ciPatch p = pl.begin(); p != pl.end(); ++p)
+ //(*p)->write(xml);
+ //p->write(level, xml);
+ (*p)->write(level, xml);
+ level--;
+ //xml.etag("PatchGroup");
+ xml.etag(level, "PatchGroup");
+ }
+ for (iMidiController ic = _controller->begin(); ic != _controller->end(); ++ic)
+ //(*ic)->write(xml);
+ ic->second->write(level, xml);
+ //xml.etag("MidiInstrument");
+ level--;
+ xml.etag(level, "MidiInstrument");
+ //xml.etag("muse");
+ level--;
+ xml.etag(level, "muse");
+ }
+
+//---------------------------------------------------------
+// getPatchName
+//---------------------------------------------------------
+
+QString MidiInstrument::getPatchName(int channel, int prog, MType mode, bool drum)
+ {
+ int pr = prog & 0xff;
+ if(prog == CTRL_VAL_UNKNOWN || pr == 0xff)
+ return "<unknown>";
+
+ int hbank = (prog >> 16) & 0xff;
+ int lbank = (prog >> 8) & 0xff;
+ int tmask = 1;
+ bool drumchan = channel == 9;
+ bool hb = false;
+ bool lb = false;
+ switch (mode) {
+ case MT_GS:
+ tmask = 2;
+ hb = true;
+ break;
+ case MT_XG:
+ hb = true;
+ lb = true;
+ tmask = 4;
+ break;
+ case MT_GM:
+ if(drumchan)
+ return gmdrumname;
+ tmask = 1;
+ break;
+ default:
+ hb = true; // MSB bank matters
+ lb = true; // LSB bank matters
+ break;
+ }
+ for (ciPatchGroup i = pg.begin(); i != pg.end(); ++i) {
+ const PatchList& pl = (*i)->patches;
+ for (ciPatch ipl = pl.begin(); ipl != pl.end(); ++ipl) {
+ const Patch* mp = *ipl;
+ if ((mp->typ & tmask)
+ && (pr == mp->prog)
+ && ((drum && mode != MT_GM) ||
+ (mp->drum == drumchan))
+
+ && (hbank == mp->hbank || !hb || mp->hbank == -1)
+ && (lbank == mp->lbank || !lb || mp->lbank == -1))
+ return mp->name;
+ }
+ }
+ return "<unknown>";
+ }
+
+//---------------------------------------------------------
+// populatePatchPopup
+//---------------------------------------------------------
+
+void MidiInstrument::populatePatchPopup(QMenu* menu, int chan, MType songType, bool drum)
+ {
+ menu->clear();
+ int mask = 0;
+ bool drumchan = chan == 9;
+ switch (songType) {
+ case MT_XG: mask = 4; break;
+ case MT_GS: mask = 2; break;
+ case MT_GM:
+ if(drumchan)
+ return;
+ mask = 1;
+ break;
+ case MT_UNKNOWN: mask = 7; break;
+ }
+ if (pg.size() > 1) {
+ for (ciPatchGroup i = pg.begin(); i != pg.end(); ++i) {
+ PatchGroup* pgp = *i;
+ QMenu* pm = menu->addMenu(pgp->name);
+ pm->setFont(config.fonts[0]);
+ const PatchList& pl = pgp->patches;
+ QString& gname = pgp->name;
+ for (ciPatch ipl = pl.begin(); ipl != pl.end(); ++ipl) {
+ const Patch* mp = *ipl;
+ if ((mp->typ & mask) &&
+ ((drum && songType != MT_GM) ||
+ (mp->drum == drumchan)) )
+ {
+ int id = ((mp->hbank & 0xff) << 16)
+ + ((mp->lbank & 0xff) << 8) + (mp->prog & 0xff);
+ QAction* act = pm->addAction(mp->name);
+ //act->setCheckable(true);
+ QString strId = QString::number(id);
+ QStringList _data = (QStringList() << strId << gname);
+ //_data->append(strId);
+ //_data->append(gname);
+ //act->setData(id);
+ act->setData(_data);
+ }
+
+ }
+ }
+ }
+ else if (pg.size() == 1 ){
+ // no groups
+ const PatchList& pl = pg.front()->patches;
+ for (ciPatch ipl = pl.begin(); ipl != pl.end(); ++ipl) {
+ const Patch* mp = *ipl;
+ if (mp->typ & mask) {
+ int id = ((mp->hbank & 0xff) << 16)
+ + ((mp->lbank & 0xff) << 8) + (mp->prog & 0xff);
+ QAction* act = menu->addAction(mp->name);
+ //act->setCheckable(true);
+ QString strId = QString::number(id);
+ QStringList _data = (QStringList() << strId);
+ //_data->append(strId);
+ //act->setData(id);
+ act->setData(_data);
+ }
+ }
+ }
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/instruments/minstrument.h b/attic/muse2-oom/muse2/muse/instruments/minstrument.h
new file mode 100644
index 00000000..0c37701f
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/instruments/minstrument.h
@@ -0,0 +1,145 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: minstrument.h,v 1.3.2.3 2009/03/09 02:05:18 terminator356 Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MINSTRUMENT_H__
+#define __MINSTRUMENT_H__
+
+#include "globaldefs.h"
+#include <list>
+#include <vector>
+
+class MidiPort;
+class QMenu;
+class MidiPlayEvent;
+class Xml;
+class EventList;
+class MidiControllerList;
+class QString;
+
+//---------------------------------------------------------
+// Patch
+//---------------------------------------------------------
+
+struct Patch {
+ signed char typ; // 1 - GM 2 - GS 4 - XG
+ signed char hbank, lbank, prog;
+ QString name;
+ bool drum;
+ void read(Xml&);
+ void write(int level, Xml&);
+ };
+
+typedef std::list<Patch*> PatchList;
+typedef PatchList::iterator iPatch;
+typedef PatchList::const_iterator ciPatch;
+
+//---------------------------------------------------------
+// PatchGroup
+//---------------------------------------------------------
+
+struct PatchGroup {
+ QString name;
+ PatchList patches;
+ void read(Xml&);
+ };
+
+typedef std::vector<PatchGroup*> PatchGroupList;
+typedef PatchGroupList::iterator iPatchGroup;
+typedef PatchGroupList::const_iterator ciPatchGroup;
+
+struct SysEx {
+ QString name;
+ QString comment;
+ int dataLen;
+ unsigned char* data;
+ };
+
+//---------------------------------------------------------
+// MidiInstrument
+//---------------------------------------------------------
+
+class MidiInstrument {
+ PatchGroupList pg;
+ MidiControllerList* _controller;
+ QList<SysEx*> _sysex;
+ bool _dirty;
+ int _nullvalue;
+
+ void init();
+
+ protected:
+ EventList* _midiInit;
+ EventList* _midiReset;
+ EventList* _midiState;
+ char* _initScript;
+ QString _name;
+ QString _filePath;
+
+ public:
+ MidiInstrument();
+ virtual ~MidiInstrument();
+ MidiInstrument(const QString& txt);
+ const QString& iname() const { return _name; }
+ void setIName(const QString& txt) { _name = txt; }
+
+ //MidiInstrument& uniqueCopy(const MidiInstrument&);
+ // Assign will 'delete' all existing patches and groups from the instrument.
+ MidiInstrument& assign(const MidiInstrument&);
+ QString filePath() const { return _filePath; }
+ void setFilePath(const QString& s) { _filePath = s; }
+ bool dirty() const { return _dirty; }
+ void setDirty(bool v) { _dirty = v; }
+
+ const QList<SysEx*>& sysex() const { return _sysex; }
+ void removeSysex(SysEx* sysex) { _sysex.removeAll(sysex); }
+ void addSysex(SysEx* sysex) { _sysex.append(sysex); }
+
+ EventList* midiInit() const { return _midiInit; }
+ EventList* midiReset() const { return _midiReset; }
+ EventList* midiState() const { return _midiState; }
+ const char* initScript() const { return _initScript; }
+ MidiControllerList* controller() const { return _controller; }
+ int nullSendValue() { return _nullvalue; }
+ void setNullSendValue(int v) { _nullvalue = v; }
+
+ void readMidiState(Xml& xml);
+ virtual bool guiVisible() const { return false; }
+ virtual void showGui(bool) {}
+ virtual bool hasGui() const { return false; }
+ virtual void writeToGui(const MidiPlayEvent&) {}
+
+ virtual void reset(int, MType);
+ virtual QString getPatchName(int,int,MType,bool);
+ virtual void populatePatchPopup(QMenu*, int, MType, bool);
+ void read(Xml&);
+ void write(int level, Xml&);
+
+ PatchGroupList* groups() { return &pg; }
+ };
+
+//---------------------------------------------------------
+// MidiInstrumentList
+//---------------------------------------------------------
+
+class MidiInstrumentList : public std::list<MidiInstrument*> {
+
+ public:
+ MidiInstrumentList() {}
+ };
+
+typedef MidiInstrumentList::iterator iMidiInstrument;
+
+extern MidiInstrumentList midiInstruments;
+extern MidiInstrument* genericMidiInstrument;
+extern void initMidiInstruments();
+extern MidiInstrument* registerMidiInstrument(const QString&);
+extern void removeMidiInstrument(const QString& name);
+extern void removeMidiInstrument(const MidiInstrument* instr);
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/key.cpp b/attic/muse2-oom/muse2/muse/key.cpp
new file mode 100644
index 00000000..0f34f8ea
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/key.cpp
@@ -0,0 +1,35 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: key.cpp,v 1.1.1.1 2003/10/27 18:51:22 wschweer Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include "key.h"
+#include "globals.h"
+
+int NKey::offsets[14] = {
+ 0, 7, 14, -7,
+ -(12),
+ -19, -26, -10, -14, -2, -4, -6, -8, 0
+ };
+
+int NKey::width() const
+ {
+ return 25;
+ }
+
+//---------------------------------------------------------
+// Scale::width
+//---------------------------------------------------------
+
+int Scale::width() const
+ {
+ int i = val;
+ if (i < 0)
+ i = -i;
+ return i * 7;
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/key.h b/attic/muse2-oom/muse2/muse/key.h
new file mode 100644
index 00000000..1c1c4cac
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/key.h
@@ -0,0 +1,54 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: key.h,v 1.1.1.1 2003/10/27 18:51:25 wschweer Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __KEY_H__
+#define __KEY_H__
+
+#include <stdio.h>
+class QPainter;
+class QPoint;
+class Xml;
+
+//---------------------------------------------------------
+// NKey
+//---------------------------------------------------------
+
+class NKey {
+ static int offsets[14];
+ int val;
+ public:
+ NKey() { val = 7; }
+ NKey(int k) { val = k; }
+ void draw(QPainter& p, const QPoint& pt) const;
+ int idx() const { return val; }
+ int offset() const { return offsets[val]; }
+ void read(Xml&);
+ void write(int, Xml&) const;
+ void set(int n) { val = n; }
+ int width() const;
+ };
+
+//---------------------------------------------------------
+// Scale
+//---------------------------------------------------------
+
+class Scale {
+ int val; // 1 = 1 sharp, -1 1 flat
+ bool minor;
+ public:
+ Scale() { val = 0; minor = false; }
+ Scale(int s, bool m = false) { val = s; minor = m; }
+ int idx() const { return val; }
+ void read(Xml&);
+ void write(int, Xml&) const;
+ void set(int n) { val = n; }
+ void setMajorMinor(bool f) { minor = f; } // true == minor
+ int width() const;
+ };
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/ladspa.h b/attic/muse2-oom/muse2/muse/ladspa.h
new file mode 100644
index 00000000..7bbc338f
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/ladspa.h
@@ -0,0 +1,599 @@
+/* ladspa.h
+
+ Linux Audio Developer's Simple Plugin API Version 1.1[provisional,
+ LGPL]. Copyright (C) 2000-2002 Richard W.E. Furse, Paul
+ Barton-Davis, Stefan Westerfeld.
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public License
+ as published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+ USA. */
+
+#ifndef LADSPA_INCLUDED
+#define LADSPA_INCLUDED
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*****************************************************************************/
+
+/* Overview:
+
+ There is a large number of synthesis packages in use or development
+ on the Linux platform at this time. This API (`The Linux Audio
+ Developer's Simple Plugin API') attempts to give programmers the
+ ability to write simple `plugin' audio processors in C/C++ and link
+ them dynamically (`plug') into a range of these packages (`hosts').
+ It should be possible for any host and any plugin to communicate
+ completely through this interface.
+
+ This API is deliberately short and simple. To achieve compatibility
+ with a range of promising Linux sound synthesis packages it
+ attempts to find the `greatest common divisor' in their logical
+ behaviour. Having said this, certain limiting decisions are
+ implicit, notably the use of a fixed type (LADSPA_Data) for all
+ data transfer and absence of a parameterised `initialisation'
+ phase. See below for the LADSPA_Data typedef.
+
+ Plugins are expected to distinguish between control and audio
+ data. Plugins have `ports' that are inputs or outputs for audio or
+ control data and each plugin is `run' for a `block' corresponding
+ to a short time interval measured in samples. Audio data is
+ communicated using arrays of LADSPA_Data, allowing a block of audio
+ to be processed by the plugin in a single pass. Control data is
+ communicated using single LADSPA_Data values. Control data has a
+ single value at the start of a call to the `run()' or `run_adding()'
+ function, and may be considered to remain this value for its
+ duration. The plugin may assume that all its input and output ports
+ have been connected to the relevant data location (see the
+ `connect_port()' function below) before it is asked to run.
+
+ Plugins will reside in shared object files suitable for dynamic
+ linking by dlopen() and family. The file will provide a number of
+ `plugin types' that can be used to instantiate actual plugins
+ (sometimes known as `plugin instances') that can be connected
+ together to perform tasks.
+
+ This API contains very limited error-handling. */
+
+/*****************************************************************************/
+
+/* Fundamental data type passed in and out of plugin. This data type
+ is used to communicate audio samples and control values. It is
+ assumed that the plugin will work sensibly given any numeric input
+ value although it may have a preferred range (see hints below).
+
+ For audio it is generally assumed that 1.0f is the `0dB' reference
+ amplitude and is a `normal' signal level. */
+
+typedef float LADSPA_Data;
+
+/*****************************************************************************/
+
+/* Special Plugin Properties:
+
+ Optional features of the plugin type are encapsulated in the
+ LADSPA_Properties type. This is assembled by ORing individual
+ properties together. */
+
+typedef int LADSPA_Properties;
+
+/* Property LADSPA_PROPERTY_REALTIME indicates that the plugin has a
+ real-time dependency (e.g. listens to a MIDI device) and so its
+ output must not be cached or subject to significant latency. */
+#define LADSPA_PROPERTY_REALTIME 0x1
+
+/* Property LADSPA_PROPERTY_INPLACE_BROKEN indicates that the plugin
+ may cease to work correctly if the host elects to use the same data
+ location for both input and output (see connect_port()). This
+ should be avoided as enabling this flag makes it impossible for
+ hosts to use the plugin to process audio `in-place.' */
+#define LADSPA_PROPERTY_INPLACE_BROKEN 0x2
+
+/* Property LADSPA_PROPERTY_HARD_RT_CAPABLE indicates that the plugin
+ is capable of running not only in a conventional host but also in a
+ `hard real-time' environment. To qualify for this the plugin must
+ satisfy all of the following:
+
+ (1) The plugin must not use malloc(), free() or other heap memory
+ management within its run() or run_adding() functions. All new
+ memory used in run() must be managed via the stack. These
+ restrictions only apply to the run() function.
+
+ (2) The plugin will not attempt to make use of any library
+ functions with the exceptions of functions in the ANSI standard C
+ and C maths libraries, which the host is expected to provide.
+
+ (3) The plugin will not access files, devices, pipes, sockets, IPC
+ or any other mechanism that might result in process or thread
+ blocking.
+
+ (4) The plugin will take an amount of time to execute a run() or
+ run_adding() call approximately of form (A+B*SampleCount) where A
+ and B depend on the machine and host in use. This amount of time
+ may not depend on input signals or plugin state. The host is left
+ the responsibility to perform timings to estimate upper bounds for
+ A and B. */
+#define LADSPA_PROPERTY_HARD_RT_CAPABLE 0x4
+
+#define LADSPA_IS_REALTIME(x) ((x) & LADSPA_PROPERTY_REALTIME)
+#define LADSPA_IS_INPLACE_BROKEN(x) ((x) & LADSPA_PROPERTY_INPLACE_BROKEN)
+#define LADSPA_IS_HARD_RT_CAPABLE(x) ((x) & LADSPA_PROPERTY_HARD_RT_CAPABLE)
+
+/*****************************************************************************/
+
+/* Plugin Ports:
+
+ Plugins have `ports' that are inputs or outputs for audio or
+ data. Ports can communicate arrays of LADSPA_Data (for audio
+ inputs/outputs) or single LADSPA_Data values (for control
+ input/outputs). This information is encapsulated in the
+ LADSPA_PortDescriptor type which is assembled by ORing individual
+ properties together.
+
+ Note that a port must be an input or an output port but not both
+ and that a port must be a control or audio port but not both. */
+
+typedef int LADSPA_PortDescriptor;
+
+/* Property LADSPA_PORT_INPUT indicates that the port is an input. */
+#define LADSPA_PORT_INPUT 0x1
+
+/* Property LADSPA_PORT_OUTPUT indicates that the port is an output. */
+#define LADSPA_PORT_OUTPUT 0x2
+
+/* Property LADSPA_PORT_CONTROL indicates that the port is a control
+ port. */
+#define LADSPA_PORT_CONTROL 0x4
+
+/* Property LADSPA_PORT_AUDIO indicates that the port is a audio
+ port. */
+#define LADSPA_PORT_AUDIO 0x8
+
+#define LADSPA_IS_PORT_INPUT(x) ((x) & LADSPA_PORT_INPUT)
+#define LADSPA_IS_PORT_OUTPUT(x) ((x) & LADSPA_PORT_OUTPUT)
+#define LADSPA_IS_PORT_CONTROL(x) ((x) & LADSPA_PORT_CONTROL)
+#define LADSPA_IS_PORT_AUDIO(x) ((x) & LADSPA_PORT_AUDIO)
+
+/*****************************************************************************/
+
+/* Plugin Port Range Hints:
+
+ The host may wish to provide a representation of data entering or
+ leaving a plugin (e.g. to generate a GUI automatically). To make
+ this more meaningful, the plugin should provide `hints' to the host
+ describing the usual values taken by the data.
+
+ Note that these are only hints. The host may ignore them and the
+ plugin must not assume that data supplied to it is meaningful. If
+ the plugin receives invalid input data it is expected to continue
+ to run without failure and, where possible, produce a sensible
+ output (e.g. a high-pass filter given a negative cutoff frequency
+ might switch to an all-pass mode).
+
+ Hints are meaningful for all input and output ports but hints for
+ input control ports are expected to be particularly useful.
+
+ More hint information is encapsulated in the
+ LADSPA_PortRangeHintDescriptor type which is assembled by ORing
+ individual hint types together. Hints may require further
+ LowerBound and UpperBound information.
+
+ All the hint information for a particular port is aggregated in the
+ LADSPA_PortRangeHint structure. */
+
+typedef int LADSPA_PortRangeHintDescriptor;
+
+/* Hint LADSPA_HINT_BOUNDED_BELOW indicates that the LowerBound field
+ of the LADSPA_PortRangeHint should be considered meaningful. The
+ value in this field should be considered the (inclusive) lower
+ bound of the valid range. If LADSPA_HINT_SAMPLE_RATE is also
+ specified then the value of LowerBound should be multiplied by the
+ sample rate. */
+#define LADSPA_HINT_BOUNDED_BELOW 0x1
+
+/* Hint LADSPA_HINT_BOUNDED_ABOVE indicates that the UpperBound field
+ of the LADSPA_PortRangeHint should be considered meaningful. The
+ value in this field should be considered the (inclusive) upper
+ bound of the valid range. If LADSPA_HINT_SAMPLE_RATE is also
+ specified then the value of UpperBound should be multiplied by the
+ sample rate. */
+#define LADSPA_HINT_BOUNDED_ABOVE 0x2
+
+/* Hint LADSPA_HINT_TOGGLED indicates that the data item should be
+ considered a Boolean toggle. Data less than or equal to zero should
+ be considered `off' or `false,' and data above zero should be
+ considered `on' or `true.' LADSPA_HINT_TOGGLED may not be used in
+ conjunction with any other hint except LADSPA_HINT_DEFAULT_0 or
+ LADSPA_HINT_DEFAULT_1. */
+#define LADSPA_HINT_TOGGLED 0x4
+
+/* Hint LADSPA_HINT_SAMPLE_RATE indicates that any bounds specified
+ should be interpreted as multiples of the sample rate. For
+ instance, a frequency range from 0Hz to the Nyquist frequency (half
+ the sample rate) could be requested by this hint in conjunction
+ with LowerBound = 0 and UpperBound = 0.5. Hosts that support bounds
+ at all must support this hint to retain meaning. */
+#define LADSPA_HINT_SAMPLE_RATE 0x8
+
+/* Hint LADSPA_HINT_LOGARITHMIC indicates that it is likely that the
+ user will find it more intuitive to view values using a logarithmic
+ scale. This is particularly useful for frequencies and gains. */
+#define LADSPA_HINT_LOGARITHMIC 0x10
+
+/* Hint LADSPA_HINT_INTEGER indicates that a user interface would
+ probably wish to provide a stepped control taking only integer
+ values. Any bounds set should be slightly wider than the actual
+ integer range required to avoid floating point rounding errors. For
+ instance, the integer set {0,1,2,3} might be described as [-0.1,
+ 3.1]. */
+#define LADSPA_HINT_INTEGER 0x20
+
+/* The various LADSPA_HINT_HAS_DEFAULT_* hints indicate a `normal'
+ value for the port that is sensible as a default. For instance,
+ this value is suitable for use as an initial value in a user
+ interface or as a value the host might assign to a control port
+ when the user has not provided one. Defaults are encoded using a
+ mask so only one default may be specified for a port. Some of the
+ hints make use of lower and upper bounds, in which case the
+ relevant bound or bounds must be available and
+ LADSPA_HINT_SAMPLE_RATE must be applied as usual. The resulting
+ default must be rounded if LADSPA_HINT_INTEGER is present. Default
+ values were introduced in LADSPA v1.1. */
+#define LADSPA_HINT_DEFAULT_MASK 0x3C0
+
+/* This default values indicates that no default is provided. */
+#define LADSPA_HINT_DEFAULT_NONE 0x0
+
+/* This default hint indicates that the suggested lower bound for the
+ port should be used. */
+#define LADSPA_HINT_DEFAULT_MINIMUM 0x40
+
+/* This default hint indicates that a low value between the suggested
+ lower and upper bounds should be chosen. For ports with
+ LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.75 +
+ log(upper) * 0.25). Otherwise, this should be (lower * 0.75 + upper
+ * 0.25). */
+#define LADSPA_HINT_DEFAULT_LOW 0x80
+
+/* This default hint indicates that a middle value between the
+ suggested lower and upper bounds should be chosen. For ports with
+ LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.5 +
+ log(upper) * 0.5). Otherwise, this should be (lower * 0.5 + upper *
+ 0.5). */
+#define LADSPA_HINT_DEFAULT_MIDDLE 0xC0
+
+/* This default hint indicates that a high value between the suggested
+ lower and upper bounds should be chosen. For ports with
+ LADSPA_HINT_LOGARITHMIC, this should be exp(log(lower) * 0.25 +
+ log(upper) * 0.75). Otherwise, this should be (lower * 0.25 + upper
+ * 0.75). */
+#define LADSPA_HINT_DEFAULT_HIGH 0x100
+
+/* This default hint indicates that the suggested upper bound for the
+ port should be used. */
+#define LADSPA_HINT_DEFAULT_MAXIMUM 0x140
+
+/* This default hint indicates that the number 0 should be used. Note
+ that this default may be used in conjunction with
+ LADSPA_HINT_TOGGLED. */
+#define LADSPA_HINT_DEFAULT_0 0x200
+
+/* This default hint indicates that the number 1 should be used. Note
+ that this default may be used in conjunction with
+ LADSPA_HINT_TOGGLED. */
+#define LADSPA_HINT_DEFAULT_1 0x240
+
+/* This default hint indicates that the number 100 should be used. */
+#define LADSPA_HINT_DEFAULT_100 0x280
+
+/* This default hint indicates that the Hz frequency of `concert A'
+ should be used. This will be 440 unless the host uses an unusual
+ tuning convention, in which case it may be within a few Hz. */
+#define LADSPA_HINT_DEFAULT_440 0x2C0
+
+#define LADSPA_IS_HINT_BOUNDED_BELOW(x) ((x) & LADSPA_HINT_BOUNDED_BELOW)
+#define LADSPA_IS_HINT_BOUNDED_ABOVE(x) ((x) & LADSPA_HINT_BOUNDED_ABOVE)
+#define LADSPA_IS_HINT_TOGGLED(x) ((x) & LADSPA_HINT_TOGGLED)
+#define LADSPA_IS_HINT_SAMPLE_RATE(x) ((x) & LADSPA_HINT_SAMPLE_RATE)
+#define LADSPA_IS_HINT_LOGARITHMIC(x) ((x) & LADSPA_HINT_LOGARITHMIC)
+#define LADSPA_IS_HINT_INTEGER(x) ((x) & LADSPA_HINT_INTEGER)
+
+#define LADSPA_IS_HINT_HAS_DEFAULT(x) ((x) & LADSPA_HINT_DEFAULT_MASK)
+#define LADSPA_IS_HINT_DEFAULT_MINIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
+ == LADSPA_HINT_DEFAULT_MINIMUM)
+#define LADSPA_IS_HINT_DEFAULT_LOW(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
+ == LADSPA_HINT_DEFAULT_LOW)
+#define LADSPA_IS_HINT_DEFAULT_MIDDLE(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
+ == LADSPA_HINT_DEFAULT_MIDDLE)
+#define LADSPA_IS_HINT_DEFAULT_HIGH(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
+ == LADSPA_HINT_DEFAULT_HIGH)
+#define LADSPA_IS_HINT_DEFAULT_MAXIMUM(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
+ == LADSPA_HINT_DEFAULT_MAXIMUM)
+#define LADSPA_IS_HINT_DEFAULT_0(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
+ == LADSPA_HINT_DEFAULT_0)
+#define LADSPA_IS_HINT_DEFAULT_1(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
+ == LADSPA_HINT_DEFAULT_1)
+#define LADSPA_IS_HINT_DEFAULT_100(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
+ == LADSPA_HINT_DEFAULT_100)
+#define LADSPA_IS_HINT_DEFAULT_440(x) (((x) & LADSPA_HINT_DEFAULT_MASK) \
+ == LADSPA_HINT_DEFAULT_440)
+
+typedef struct _LADSPA_PortRangeHint {
+
+ /* Hints about the port. */
+ LADSPA_PortRangeHintDescriptor HintDescriptor;
+
+ /* Meaningful when hint LADSPA_HINT_BOUNDED_BELOW is active. When
+ LADSPA_HINT_SAMPLE_RATE is also active then this value should be
+ multiplied by the relevant sample rate. */
+ LADSPA_Data LowerBound;
+
+ /* Meaningful when hint LADSPA_HINT_BOUNDED_ABOVE is active. When
+ LADSPA_HINT_SAMPLE_RATE is also active then this value should be
+ multiplied by the relevant sample rate. */
+ LADSPA_Data UpperBound;
+
+} LADSPA_PortRangeHint;
+
+/*****************************************************************************/
+
+/* Plugin Handles:
+
+ This plugin handle indicates a particular instance of the plugin
+ concerned. It is valid to compare this to NULL (0 for C++) but
+ otherwise the host should not attempt to interpret it. The plugin
+ may use it to reference internal instance data. */
+
+typedef void * LADSPA_Handle;
+
+/*****************************************************************************/
+
+/* Descriptor for a Type of Plugin:
+
+ This structure is used to describe a plugin type. It provides a
+ number of functions to examine the type, instantiate it, link it to
+ buffers and workspaces and to run it. */
+
+typedef struct _LADSPA_Descriptor {
+
+ /* This numeric identifier indicates the plugin type
+ uniquely. Plugin programmers may reserve ranges of IDs from a
+ central body to avoid clashes. Hosts may assume that IDs are
+ below 0x1000000. */
+ unsigned long UniqueID;
+
+ /* This identifier can be used as a unique, case-sensitive
+ identifier for the plugin type within the plugin file. Plugin
+ types should be identified by file and label rather than by index
+ or plugin name, which may be changed in new plugin
+ versions. Labels must not contain white-space characters. */
+ const char * Label;
+
+ /* This indicates a number of properties of the plugin. */
+ LADSPA_Properties Properties;
+
+ /* This member points to the null-terminated name of the plugin
+ (e.g. "Sine Oscillator"). */
+ const char * Name;
+
+ /* This member points to the null-terminated string indicating the
+ maker of the plugin. This can be an empty string but not NULL. */
+ const char * Maker;
+
+ /* This member points to the null-terminated string indicating any
+ copyright applying to the plugin. If no Copyright applies the
+ string "None" should be used. */
+ const char * Copyright;
+
+ /* This indicates the number of ports (input AND output) present on
+ the plugin. */
+ unsigned long PortCount;
+
+ /* This member indicates an array of port descriptors. Valid indices
+ vary from 0 to PortCount-1. */
+ const LADSPA_PortDescriptor * PortDescriptors;
+
+ /* This member indicates an array of null-terminated strings
+ describing ports (e.g. "Frequency (Hz)"). Valid indices vary from
+ 0 to PortCount-1. */
+ const char * const * PortNames;
+
+ /* This member indicates an array of range hints for each port (see
+ above). Valid indices vary from 0 to PortCount-1. */
+ const LADSPA_PortRangeHint * PortRangeHints;
+
+ /* This may be used by the plugin developer to pass any custom
+ implementation data into an instantiate call. It must not be used
+ or interpreted by the host. It is expected that most plugin
+ writers will not use this facility as LADSPA_Handle should be
+ used to hold instance data. */
+ void * ImplementationData;
+
+ /* This member is a function pointer that instantiates a plugin. A
+ handle is returned indicating the new plugin instance. The
+ instantiation function accepts a sample rate as a parameter. The
+ plugin descriptor from which this instantiate function was found
+ must also be passed. This function must return NULL if
+ instantiation fails.
+
+ Note that instance initialisation should generally occur in
+ activate() rather than here. */
+ LADSPA_Handle (*instantiate)(const struct _LADSPA_Descriptor * Descriptor,
+ unsigned long SampleRate);
+
+ /* This member is a function pointer that connects a port on an
+ instantiated plugin to a memory location at which a block of data
+ for the port will be read/written. The data location is expected
+ to be an array of LADSPA_Data for audio ports or a single
+ LADSPA_Data value for control ports. Memory issues will be
+ managed by the host. The plugin must read/write the data at these
+ locations every time run() or run_adding() is called and the data
+ present at the time of this connection call should not be
+ considered meaningful.
+
+ connect_port() may be called more than once for a plugin instance
+ to allow the host to change the buffers that the plugin is
+ reading or writing. These calls may be made before or after
+ activate() or deactivate() calls.
+
+ connect_port() must be called at least once for each port before
+ run() or run_adding() is called. When working with blocks of
+ LADSPA_Data the plugin should pay careful attention to the block
+ size passed to the run function as the block allocated may only
+ just be large enough to contain the block of samples.
+
+ Plugin writers should be aware that the host may elect to use the
+ same buffer for more than one port and even use the same buffer
+ for both input and output (see LADSPA_PROPERTY_INPLACE_BROKEN).
+ However, overlapped buffers or use of a single buffer for both
+ audio and control data may result in unexpected behaviour. */
+ void (*connect_port)(LADSPA_Handle Instance,
+ unsigned long Port,
+ LADSPA_Data * DataLocation);
+
+ /* This member is a function pointer that initialises a plugin
+ instance and activates it for use. This is separated from
+ instantiate() to aid real-time support and so that hosts can
+ reinitialise a plugin instance by calling deactivate() and then
+ activate(). In this case the plugin instance must reset all state
+ information dependent on the history of the plugin instance
+ except for any data locations provided by connect_port() and any
+ gain set by set_run_adding_gain(). If there is nothing for
+ activate() to do then the plugin writer may provide a NULL rather
+ than an empty function.
+
+ When present, hosts must call this function once before run() (or
+ run_adding()) is called for the first time. This call should be
+ made as close to the run() call as possible and indicates to
+ real-time plugins that they are now live. Plugins should not rely
+ on a prompt call to run() after activate(). activate() may not be
+ called again unless deactivate() is called first. Note that
+ connect_port() may be called before or after a call to
+ activate(). */
+ void (*activate)(LADSPA_Handle Instance);
+
+ /* This method is a function pointer that runs an instance of a
+ plugin for a block. Two parameters are required: the first is a
+ handle to the particular instance to be run and the second
+ indicates the block size (in samples) for which the plugin
+ instance may run.
+
+ Note that if an activate() function exists then it must be called
+ before run() or run_adding(). If deactivate() is called for a
+ plugin instance then the plugin instance may not be reused until
+ activate() has been called again.
+
+ If the plugin has the property LADSPA_PROPERTY_HARD_RT_CAPABLE
+ then there are various things that the plugin should not do
+ within the run() or run_adding() functions (see above). */
+ void (*run)(LADSPA_Handle Instance,
+ unsigned long SampleCount);
+
+ /* This method is a function pointer that runs an instance of a
+ plugin for a block. This has identical behaviour to run() except
+ in the way data is output from the plugin. When run() is used,
+ values are written directly to the memory areas associated with
+ the output ports. However when run_adding() is called, values
+ must be added to the values already present in the memory
+ areas. Furthermore, output values written must be scaled by the
+ current gain set by set_run_adding_gain() (see below) before
+ addition.
+
+ run_adding() is optional. When it is not provided by a plugin,
+ this function pointer must be set to NULL. When it is provided,
+ the function set_run_adding_gain() must be provided also. */
+ void (*run_adding)(LADSPA_Handle Instance,
+ unsigned long SampleCount);
+
+ /* This method is a function pointer that sets the output gain for
+ use when run_adding() is called (see above). If this function is
+ never called the gain is assumed to default to 1. Gain
+ information should be retained when activate() or deactivate()
+ are called.
+
+ This function should be provided by the plugin if and only if the
+ run_adding() function is provided. When it is absent this
+ function pointer must be set to NULL. */
+ void (*set_run_adding_gain)(LADSPA_Handle Instance,
+ LADSPA_Data Gain);
+
+ /* This is the counterpart to activate() (see above). If there is
+ nothing for deactivate() to do then the plugin writer may provide
+ a NULL rather than an empty function.
+
+ Hosts must deactivate all activated units after they have been
+ run() (or run_adding()) for the last time. This call should be
+ made as close to the last run() call as possible and indicates to
+ real-time plugins that they are no longer live. Plugins should
+ not rely on prompt deactivation. Note that connect_port() may be
+ called before or after a call to deactivate().
+
+ Deactivation is not similar to pausing as the plugin instance
+ will be reinitialised when activate() is called to reuse it. */
+ void (*deactivate)(LADSPA_Handle Instance);
+
+ /* Once an instance of a plugin has been finished with it can be
+ deleted using the following function. The instance handle passed
+ ceases to be valid after this call.
+
+ If activate() was called for a plugin instance then a
+ corresponding call to deactivate() must be made before cleanup()
+ is called. */
+ void (*cleanup)(LADSPA_Handle Instance);
+
+} LADSPA_Descriptor;
+
+/**********************************************************************/
+
+/* Accessing a Plugin: */
+
+/* The exact mechanism by which plugins are loaded is host-dependent,
+ however all most hosts will need to know is the name of shared
+ object file containing the plugin types. To allow multiple hosts to
+ share plugin types, hosts may wish to check for environment
+ variable LADSPA_PATH. If present, this should contain a
+ colon-separated path indicating directories that should be searched
+ (in order) when loading plugin types.
+
+ A plugin programmer must include a function called
+ "ladspa_descriptor" with the following function prototype within
+ the shared object file. This function will have C-style linkage (if
+ you are using C++ this is taken care of by the `extern "C"' clause
+ at the top of the file).
+
+ A host will find the plugin shared object file by one means or
+ another, find the ladspa_descriptor() function, call it, and
+ proceed from there.
+
+ Plugin types are accessed by index (not ID) using values from 0
+ upwards. Out of range indexes must result in this function
+ returning NULL, so the plugin count can be determined by checking
+ for the least index that results in NULL being returned. */
+
+const LADSPA_Descriptor * ladspa_descriptor(unsigned long Index);
+
+/* Datatype corresponding to the ladspa_descriptor() function. */
+typedef const LADSPA_Descriptor *
+(*LADSPA_Descriptor_Function)(unsigned long Index);
+
+/**********************************************************************/
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* LADSPA_INCLUDED */
+
+/* EOF */
diff --git a/attic/muse2-oom/muse2/muse/liste/CMakeLists.txt b/attic/muse2-oom/muse2/muse/liste/CMakeLists.txt
new file mode 100644
index 00000000..4c0b61a4
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/liste/CMakeLists.txt
@@ -0,0 +1,97 @@
+#=============================================================================
+# MusE
+# Linux Music Editor
+# $Id:$
+#
+# Copyright (C) 2002-2006 by Werner Schweer and others
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#=============================================================================
+
+##
+## Expand Qt macros in source files
+##
+QT4_WRAP_CPP ( liste_mocs
+ # listedit.h
+ # ctrllistedit.h
+ # tracklistedit.h
+ # partlistedit.h
+ # ieventdialog.h
+ editevent.h
+ listedit.h
+ )
+
+##
+## UI files
+##
+file (GLOB liste_ui_files
+ editctrlbase.ui
+ )
+QT4_WRAP_UI ( liste_uis ${liste_ui_files} )
+
+##
+## List of source files to compile
+##
+file (GLOB liste_source_files
+ # listedit.cpp
+ # ctrllistedit.cpp
+ # partlistedit.cpp
+ # tracklistedit.cpp
+ # ieventdialog.cpp
+ editevent.cpp
+ listedit.cpp
+ )
+
+##
+## Define target
+##
+add_library ( liste SHARED
+ ${liste_source_files}
+ ${liste_mocs}
+ ${liste_uis}
+ )
+
+##
+## Append to the list of translations
+##
+set (FILES_TO_TRANSLATE
+ ${FILES_TO_TRANSLATE}
+ ${liste_source_files}
+ ${liste_ui_files}
+ CACHE INTERNAL ""
+ )
+
+##
+## Compilation flags and target name
+##
+set_target_properties( liste
+ PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h -fPIC"
+ OUTPUT_NAME muse_liste
+ )
+
+##
+## Linkage
+##
+target_link_libraries ( liste
+ ${QT_LIBRARIES}
+ awl
+ widgets
+ )
+
+##
+## Install location
+##
+install(TARGETS liste
+ DESTINATION ${MusE_MODULES_DIR}
+ )
+
diff --git a/attic/muse2-oom/muse2/muse/liste/editctrlbase.ui b/attic/muse2-oom/muse2/muse/liste/editctrlbase.ui
new file mode 100644
index 00000000..7b4d68ec
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/liste/editctrlbase.ui
@@ -0,0 +1,875 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>EditCtrlBase</class>
+ <widget class="QDialog" name="EditCtrlBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>601</width>
+ <height>413</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Edit Controller Event</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <layout class="QGridLayout">
+ <item row="0" column="3">
+ <widget class="QLabel" name="textLabel1">
+ <property name="text">
+ <string>Time Position</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" colspan="2">
+ <widget class="QLabel" name="textLabel1_2">
+ <property name="text">
+ <string>Available Controller:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QPushButton" name="buttonNewController">
+ <property name="text">
+ <string>Create New Controller</string>
+ </property>
+ <property name="shortcut">
+ <string/>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <widget class="Awl::PosEdit" name="timePos"/>
+ </item>
+ <item row="1" column="3" rowspan="2" colspan="2">
+ <widget class="QStackedWidget" name="widgetStack">
+ <property name="palette">
+ <palette>
+ <active>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Button">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>238</red>
+ <green>234</green>
+ <blue>222</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Light">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Midlight">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>246</red>
+ <green>244</green>
+ <blue>238</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Dark">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>119</red>
+ <green>117</green>
+ <blue>111</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Mid">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>158</red>
+ <green>155</green>
+ <blue>147</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Text">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="BrightText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="ButtonText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Base">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Window">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>104</red>
+ <green>137</green>
+ <blue>236</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Shadow">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Highlight">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>128</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="HighlightedText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Link">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="LinkVisited">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </active>
+ <inactive>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Button">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>238</red>
+ <green>234</green>
+ <blue>222</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Light">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Midlight">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Dark">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>119</red>
+ <green>117</green>
+ <blue>111</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Mid">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>158</red>
+ <green>155</green>
+ <blue>147</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Text">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="BrightText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="ButtonText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Base">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Window">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>104</red>
+ <green>137</green>
+ <blue>236</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Shadow">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Highlight">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>128</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="HighlightedText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Link">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>192</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="LinkVisited">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>128</red>
+ <green>0</green>
+ <blue>128</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </inactive>
+ <disabled>
+ <colorrole role="WindowText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>128</red>
+ <green>128</green>
+ <blue>128</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Button">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>238</red>
+ <green>234</green>
+ <blue>222</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Light">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Midlight">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Dark">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>119</red>
+ <green>117</green>
+ <blue>111</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Mid">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>158</red>
+ <green>155</green>
+ <blue>147</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Text">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>128</red>
+ <green>128</green>
+ <blue>128</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="BrightText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="ButtonText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>128</red>
+ <green>128</green>
+ <blue>128</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Base">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Window">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>104</red>
+ <green>137</green>
+ <blue>236</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Shadow">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>0</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Highlight">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>128</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="HighlightedText">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>255</red>
+ <green>255</green>
+ <blue>255</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="Link">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>0</red>
+ <green>0</green>
+ <blue>192</blue>
+ </color>
+ </brush>
+ </colorrole>
+ <colorrole role="LinkVisited">
+ <brush brushstyle="SolidPattern">
+ <color alpha="255">
+ <red>128</red>
+ <green>0</green>
+ <blue>128</blue>
+ </color>
+ </brush>
+ </colorrole>
+ </disabled>
+ </palette>
+ </property>
+ <widget class="QWidget" name="WStackPage">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>140</width>
+ <height>349</height>
+ </rect>
+ </property>
+ <layout class="QGridLayout">
+ <item row="3" column="0" colspan="2">
+ <widget class="QSlider" name="valSlider">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="controllerName">
+ <property name="frameShadow">
+ <enum>QFrame::Sunken</enum>
+ </property>
+ <property name="text">
+ <string>textLabel3</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="textLabel4">
+ <property name="text">
+ <string>Value</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="textLabel2">
+ <property name="text">
+ <string>Controller</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QSpinBox" name="valSpinBox">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <spacer name="spacer2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="WStackPage2">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>100</width>
+ <height>30</height>
+ </rect>
+ </property>
+ <layout class="QGridLayout">
+ <item row="2" column="0">
+ <widget class="QLabel" name="textLabel2_2">
+ <property name="text">
+ <string>H-Bank</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="textLabel3">
+ <property name="text">
+ <string>L-Bank</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="textLabel4_2">
+ <property name="text">
+ <string>Program</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QSpinBox" name="hbank">
+ <property name="specialValueText">
+ <string>off</string>
+ </property>
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>128</number>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QSpinBox" name="lbank">
+ <property name="specialValueText">
+ <string>off</string>
+ </property>
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>128</number>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QSpinBox" name="program">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>128</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0" colspan="2">
+ <spacer name="spacer4">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>140</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <widget class="QPushButton" name="patchName">
+ <property name="text">
+ <string>pushButton4</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item row="4" column="0" colspan="5">
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <spacer name="Horizontal Spacing2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonOk">
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="shortcut">
+ <string/>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonCancel">
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="shortcut">
+ <string/>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="3" column="0" colspan="5">
+ <widget class="Line" name="line1">
+ <property name="frameShape">
+ <enum>QFrame::HLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <property name="lineWidth">
+ <number>3</number>
+ </property>
+ <property name="midLineWidth">
+ <number>2</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <widget class="QListWidget" name="ctrlList">
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <spacer name="spacer3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>60</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="0" column="2" rowspan="3">
+ <widget class="Line" name="line2">
+ <property name="frameShape">
+ <enum>QFrame::VLine</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <property name="lineWidth">
+ <number>3</number>
+ </property>
+ <property name="midLineWidth">
+ <number>2</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <customwidgets>
+ <customwidget>
+ <class>Awl::PosEdit</class>
+ <extends>QWidget</extends>
+ <header>awl/posedit.h</header>
+ <container>0</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>MyDialog</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>MyDialog</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>valSlider</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>valSpinBox</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>valSpinBox</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>valSlider</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/liste/editevent.cpp b/attic/muse2-oom/muse2/muse/liste/editevent.cpp
new file mode 100644
index 00000000..b162a3e6
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/liste/editevent.cpp
@@ -0,0 +1,897 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: editevent.cpp,v 1.12.2.6 2009/02/02 21:38:00 terminator356 Exp $
+// (C) Copyright 1999-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+
+#include <QBoxLayout>
+#include <QHBoxLayout>
+#include <QGridLayout>
+#include <QLabel>
+#include <QListWidget>
+#include <QMenu>
+#include <QMessageBox>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QSlider>
+#include <QSpinBox>
+#include <QTextEdit>
+#include <QVBoxLayout>
+
+#include "awl/posedit.h"
+
+#include "song.h"
+#include "event.h"
+#include "midictrl.h"
+#include "editevent.h"
+#include "pitchedit.h"
+#include "intlabel.h"
+#include "globals.h"
+///#include "posedit.h"
+#include "gconfig.h"
+#include "midiport.h"
+#include "midiedit/drummap.h"
+#include "instruments/minstrument.h"
+#include "midi.h"
+
+//---------------------------------------------------------
+// string2qhex
+//---------------------------------------------------------
+
+QString string2hex(const unsigned char* data, int len)
+ {
+ QString d;
+ QString s;
+ for (int i = 0; i < len; ++i) {
+ if ((i > 0) && ((i % 8)==0)) {
+ d += "\n";
+ }
+ else if (i)
+ d += " ";
+ d += s.sprintf("%02x", data[i]);
+ }
+ return d;
+ }
+
+//---------------------------------------------------------
+// hex2string
+//---------------------------------------------------------
+
+char* hex2string(QWidget* parent, const char* src, int& len)
+ {
+ char buffer[2048];
+ char* dst = buffer;
+
+ while (*src) {
+ while (*src == ' ' || *src == '\n')
+ ++src;
+ char* ep;
+ long val = strtol(src, &ep, 16);
+ if (ep == src) {
+ QMessageBox::information(parent,
+ QString("MusE"),
+ QWidget::tr("Cannot convert sysex string"));
+ return 0;
+ }
+ src = ep;
+ *dst++ = val;
+ if (dst - buffer >= 2048) {
+ QMessageBox::information(parent,
+ QString("MusE"),
+ QWidget::tr("Hex String too long (2048 bytes limit)"));
+ return 0;
+ }
+ }
+ len = dst - buffer;
+ if(len == 0)
+ return 0;
+ char* b = new char[len+1];
+ memcpy(b, buffer, len);
+ b[len] = 0;
+ return b;
+ }
+
+//---------------------------------------------------------
+// getEvent
+//---------------------------------------------------------
+
+Event EditNoteDialog::getEvent(int tick, const Event& event, QWidget* parent)
+ {
+ EditNoteDialog* dlg = new EditNoteDialog(tick, event, parent);
+ Event nevent;
+ if (dlg->exec() == QDialog::Accepted) {
+ nevent = dlg->event();
+ }
+ delete dlg;
+ return nevent;
+ }
+
+Event EditSysexDialog::getEvent(int tick, const Event& event, QWidget* parent)
+ {
+ EditSysexDialog* dlg = new EditSysexDialog(tick, event, parent);
+ Event nevent;
+ if (dlg->exec() == QDialog::Accepted) {
+ nevent = dlg->event();
+ }
+ delete dlg;
+ return nevent;
+ }
+
+Event EditMetaDialog::getEvent(int tick, const Event& event, QWidget* parent)
+ {
+ EditEventDialog* dlg = new EditMetaDialog(tick, event, parent);
+ Event nevent;
+ if (dlg->exec() == QDialog::Accepted) {
+ nevent = dlg->event();
+ }
+ delete dlg;
+ return nevent;
+ }
+
+Event EditCAfterDialog::getEvent(int tick, const Event& event, QWidget* parent)
+ {
+ EditEventDialog* dlg = new EditCAfterDialog(tick, event, parent);
+ Event nevent;
+ if (dlg->exec() == QDialog::Accepted) {
+ nevent = dlg->event();
+ }
+ delete dlg;
+ return nevent;
+ }
+
+Event EditPAfterDialog::getEvent(int tick, const Event& event, QWidget* parent)
+ {
+ EditEventDialog* dlg = new EditPAfterDialog(tick, event, parent);
+ Event nevent;
+ if (dlg->exec() == QDialog::Accepted) {
+ nevent = dlg->event();
+ }
+ delete dlg;
+ return nevent;
+ }
+
+//---------------------------------------------------------
+// EditEventDialog
+//---------------------------------------------------------
+
+EditEventDialog::EditEventDialog(QWidget* parent)
+ : QDialog(parent)
+ {
+ QVBoxLayout* xlayout = new QVBoxLayout;
+ layout1 = new QGridLayout; // ddskrjo this
+ xlayout->addLayout(layout1);
+
+ //---------------------------------------------------
+ // Ok, Cancel
+ //---------------------------------------------------
+
+ QBoxLayout* w5 = new QHBoxLayout; // ddskrjo this
+ QPushButton* okB = new QPushButton(tr("Ok"));
+ okB->setDefault(true);
+ QPushButton* cancelB = new QPushButton(tr("Cancel"));
+ okB->setFixedWidth(80);
+ cancelB->setFixedWidth(80);
+ w5->addWidget(okB);
+ w5->addSpacing(12);
+ w5->addWidget(cancelB);
+ w5->addStretch(1);
+ xlayout->addLayout(w5);
+ setLayout(xlayout);
+ connect(cancelB, SIGNAL(clicked()), SLOT(reject()));
+ connect(okB, SIGNAL(clicked()), SLOT(accept()));
+ }
+
+//---------------------------------------------------------
+// EditNoteDialog
+//---------------------------------------------------------
+
+EditNoteDialog::EditNoteDialog(int tick, const Event& event,
+ QWidget* parent)
+ : QDialog(parent)
+ {
+ setupUi(this);
+ if (!event.empty()) {
+ epos->setValue(tick);
+ il1->setValue(event.lenTick());
+ pl->setValue(event.pitch());
+ il2->setValue(event.velo());
+ il3->setValue(event.veloOff());
+ }
+ else {
+ epos->setValue(tick);
+ il1->setValue(96);
+ pl->setValue(64);
+ il2->setValue(100);
+ il3->setValue(0);
+ }
+ }
+
+//---------------------------------------------------------
+// EditNoteDialog::event
+//---------------------------------------------------------
+
+Event EditNoteDialog::event()
+ {
+ Event event(Note);
+ event.setTick(epos->pos().tick());
+ event.setA(pl->value());
+ event.setB(il2->value());
+ event.setC(il3->value());
+ event.setLenTick(il1->value());
+ return event;
+ }
+
+//---------------------------------------------------------
+// EditSysExDialog
+//---------------------------------------------------------
+
+EditSysexDialog::EditSysexDialog(int tick, const Event& event,
+ QWidget* parent)
+ : QDialog(parent)
+ {
+ setupUi(this);
+ sysex = 0;
+ if (!event.empty()) {
+ epos->setValue(tick);
+ edit->setText(string2hex(event.data(), event.dataLen()));
+ }
+ else {
+ epos->setValue(tick);
+ }
+ }
+
+//---------------------------------------------------------
+// ~EditSysexDialog
+//---------------------------------------------------------
+
+EditSysexDialog::~EditSysexDialog()
+ {
+ if (sysex)
+ delete sysex;
+ }
+
+//---------------------------------------------------------
+// EditSysExDialog::event
+//---------------------------------------------------------
+
+Event EditSysexDialog::event()
+ {
+ Event event(Sysex);
+ event.setTick(epos->pos().tick());
+ event.setData(sysex, len);
+ return event;
+ }
+
+//---------------------------------------------------------
+// accept
+//---------------------------------------------------------
+
+void EditSysexDialog::accept()
+ {
+ QString qsrc = edit->toPlainText();
+ QByteArray ba = qsrc.toLatin1();
+ const char* src = ba.constData();
+
+ sysex = (unsigned char*)hex2string(this, src, len);
+ if (sysex)
+ QDialog::accept();
+ }
+
+//---------------------------------------------------------
+// EditMetaDialog
+//---------------------------------------------------------
+
+EditMetaDialog::EditMetaDialog(int tick, const Event& ev,
+ QWidget* parent)
+ : EditEventDialog(parent)
+ {
+ meta = 0;
+ setWindowTitle(tr("MusE: Enter Meta Event"));
+
+ QLabel* l1 = new QLabel(tr("Time Position"));
+ ///epos = new PosEdit;
+ epos = new Awl::PosEdit;
+
+ QLabel* l2 = new QLabel(tr("Meta Type"));
+ il2 = new IntLabel(-1, 0, 127, this, -1);
+ il2->setFixedWidth(100);
+ il2->setFrame(true);
+ il2->setDark();
+ typeLabel = new QLabel;
+ typeLabel->setAlignment(Qt::AlignLeft | Qt::AlignVCenter);
+ QHBoxLayout* typeLayout = new QHBoxLayout;
+ typeLayout->addWidget(il2);
+ typeLayout->addWidget(typeLabel);
+ typeLayout->addStretch();
+
+ hexButton = new QRadioButton(tr("Enter Hex"));
+ hexButton->setChecked(true);
+ connect(hexButton, SIGNAL(toggled(bool)), SLOT(toggled(bool)));
+
+ edit = new QTextEdit;
+ edit->setFont(config.fonts[5]);
+
+ if (!ev.empty()) {
+ epos->setValue(tick);
+ il2->setValue(ev.dataA());
+ toggled(true);
+ edit->setText(string2hex(ev.data(), ev.dataLen()));
+ }
+ else {
+ epos->setValue(tick);
+ il2->setValue(0);
+ }
+
+ typeChanged(il2->value());
+ connect(il2, SIGNAL(valueChanged(int)), SLOT(typeChanged(int)));
+
+ layout1->addWidget(l1, 0, 0);
+ layout1->addWidget(epos, 0, 1, Qt::AlignLeft);
+ layout1->addWidget(l2, 1, 0);
+
+ //layout1->addWidget(il2, 1, 1, AlignLeft);
+ layout1->addLayout(typeLayout, 1, 1);
+
+ //layout1->addMultiCellWidget(hexButton, 2, 2, 0, 1);
+ //layout1->addMultiCellWidget(edit, 3, 3, 0, 1);
+ layout1->addWidget(hexButton, 2, 0, 1, 2);
+ layout1->addWidget(edit, 3, 0, 1, 2);
+ }
+
+//---------------------------------------------------------
+// typeChanged
+//---------------------------------------------------------
+
+void EditMetaDialog::typeChanged(int val)
+{
+ typeLabel->setText(midiMetaName(val));
+}
+
+//---------------------------------------------------------
+// toggled
+//---------------------------------------------------------
+
+void EditMetaDialog::toggled(bool flag)
+ {
+ QString qsrc = edit->toPlainText();
+ QByteArray ba = qsrc.toLatin1();
+ const char* src = ba.constData();
+ edit->clear();
+
+ QString dst;
+ if (flag) { // convert to hex
+ dst = string2hex((unsigned char*)src, strlen(src));
+ }
+ else { // convert to string
+ int len;
+ dst = hex2string(this, src, len);
+ }
+ edit->setText(dst);
+ }
+
+//---------------------------------------------------------
+// ~EditMetaDialog
+//---------------------------------------------------------
+
+EditMetaDialog::~EditMetaDialog()
+ {
+ if (meta)
+ delete meta;
+ }
+
+//---------------------------------------------------------
+// EditMetaDialog::event
+//---------------------------------------------------------
+
+Event EditMetaDialog::event()
+ {
+ Event event(Meta);
+ event.setTick(epos->pos().tick());
+ event.setA(il2->value());
+ event.setData(meta, len); // TODO ??
+ return event;
+ }
+
+//---------------------------------------------------------
+// accept
+//---------------------------------------------------------
+
+void EditMetaDialog::accept()
+ {
+ QString qsrc = edit->toPlainText();
+ QByteArray ba = qsrc.toLatin1();
+ const char* src = ba.constData();
+ if (!hexButton->isChecked()) {
+ meta = (unsigned char*)strdup(src);
+ len = strlen(src);
+ QDialog::accept();
+ return;
+ }
+
+ meta = (unsigned char*)hex2string(this, src, len);
+ if (meta)
+ QDialog::accept();
+ }
+
+//---------------------------------------------------------
+// EditCAfterDialog
+//---------------------------------------------------------
+
+EditCAfterDialog::EditCAfterDialog(int tick, const Event& event,
+ QWidget* parent)
+ : EditEventDialog(parent)
+ {
+ setWindowTitle(tr("MusE: Enter Channel Aftertouch"));
+
+ QLabel* l1 = new QLabel(tr("Time Position"));
+ ///epos = new PosEdit;
+ epos = new Awl::PosEdit;
+
+ QLabel* l2 = new QLabel(tr("Pressure"));
+ il2 = new IntLabel(-1, 0, 127, this, -1);
+ il2->setFrame(true);
+ il2->setDark();
+
+ QSlider* slider = new QSlider(Qt::Horizontal);
+ slider->setMinimum(0);
+ slider->setMaximum(127);
+ slider->setPageStep(1);
+ slider->setValue(0);
+
+ connect(slider, SIGNAL(valueChanged(int)), il2, SLOT(setValue(int)));
+ connect(il2, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int)));
+
+ if (!event.empty()) {
+ epos->setValue(tick);
+ il2->setValue(event.dataA());
+ slider->setValue(event.dataA());
+ }
+ else {
+ epos->setValue(tick);
+ il2->setValue(64);
+ slider->setValue(64);
+ }
+
+ layout1->addWidget(l1, 0, 0);
+ layout1->addWidget(epos, 0, 1, Qt::AlignLeft);
+ layout1->addWidget(l2, 1, 0);
+ layout1->addWidget(il2, 1, 1, Qt::AlignLeft);
+ //layout1->addMultiCellWidget(slider, 2, 2, 0, 1);
+ layout1->addWidget(slider, 2, 0, 1, 2);
+ }
+
+//---------------------------------------------------------
+// EditCAfterDialog::event
+//---------------------------------------------------------
+
+Event EditCAfterDialog::event()
+ {
+ Event event(CAfter);
+ event.setTick(epos->pos().tick());
+ event.setA(il2->value());
+ return event;
+ }
+
+//---------------------------------------------------------
+// EditPAfterDialog
+//---------------------------------------------------------
+
+EditPAfterDialog::EditPAfterDialog(int tick, const Event& event,
+ QWidget* parent)
+ : EditEventDialog(parent)
+ {
+ setWindowTitle(tr("MusE: Enter Poly Aftertouch"));
+
+ QLabel* l1 = new QLabel(tr("Time Position"));
+ ///epos = new PosEdit;
+ epos = new Awl::PosEdit;
+
+ QLabel* l2 = new QLabel(tr("Pitch"));
+ pl = new PitchEdit;
+ QLabel* l3 = new QLabel(tr("Pressure"));
+ il2 = new IntLabel(-1, 0, 127, this, -1);
+ il2->setFrame(true);
+ il2->setDark();
+
+ QSlider* slider = new QSlider(Qt::Horizontal);
+ slider->setMinimum(0);
+ slider->setMaximum(127);
+ slider->setPageStep(1);
+ slider->setValue(0);
+
+ connect(slider, SIGNAL(valueChanged(int)), il2, SLOT(setValue(int)));
+ connect(il2, SIGNAL(valueChanged(int)), slider, SLOT(setValue(int)));
+
+ if (!event.empty()) {
+ epos->setValue(tick);
+ pl->setValue(event.pitch());
+ il2->setValue(event.dataB());
+ slider->setValue(event.dataB());
+ }
+ else {
+ epos->setValue(tick);
+ pl->setValue(64);
+ il2->setValue(64);
+ slider->setValue(64);
+ }
+
+ layout1->addWidget(l1, 0, 0);
+ layout1->addWidget(epos, 0, 1, Qt::AlignLeft);
+ layout1->addWidget(l2, 1, 0);
+ layout1->addWidget(pl, 1, 1, Qt::AlignLeft);
+ layout1->addWidget(l3, 2, 0);
+ layout1->addWidget(il2, 2, 1, Qt::AlignLeft);
+ //layout1->addMultiCellWidget(slider, 3, 3, 0, 1);
+ layout1->addWidget(slider, 3, 0, 1, 2);
+ }
+
+//---------------------------------------------------------
+// EditPAfterDialog::event
+//---------------------------------------------------------
+
+Event EditPAfterDialog::event()
+ {
+ Event event(PAfter);
+ event.setTick(epos->pos().tick());
+ event.setA(pl->value());
+ event.setB(il2->value());
+ return event;
+ }
+//---------------------------------------------------------
+// getEvent
+//---------------------------------------------------------
+
+Event EditCtrlDialog::getEvent(int tick, const Event& event,
+ const MidiPart* part, QWidget* parent)
+ {
+ EditCtrlDialog* dlg = new EditCtrlDialog(tick, event, part, parent);
+ Event nevent;
+ if (dlg->exec() == QDialog::Accepted) {
+ nevent = dlg->event();
+ }
+ delete dlg;
+ return nevent;
+ }
+
+//---------------------------------------------------------
+// EditCtrlDialog::event
+//---------------------------------------------------------
+
+Event EditCtrlDialog::event()
+ {
+ Event event(Controller);
+ event.setTick(timePos->pos().tick());
+ event.setA(num);
+ if (num == CTRL_PROGRAM)
+ event.setB(val);
+ else
+ event.setB(valSlider->value() + midiPorts[part->track()->outPort()].midiController(num)->bias());
+ return event;
+ }
+
+//---------------------------------------------------------
+// EditCtrlDialog
+// PosEdit* timePos;
+// QSlider* valSlider;
+// QSpinBox* valSpinBox;
+// QLabel* controllerName;
+// QListWidget* ctrlList;
+// QPushButton* buttonNewController;
+//---------------------------------------------------------
+
+EditCtrlDialog::EditCtrlDialog(int tick, const Event& event,
+ const MidiPart* p, QWidget* parent)
+ : QDialog(parent), part(p)
+ {
+ setupUi(this);
+ widgetStack->setAutoFillBackground(true);
+ val = 0;
+ num = 0;
+ if (!event.empty()) {
+ num = event.dataA();
+ val = event.dataB();
+ }
+
+ ///pop = new QMenu(this);
+ //pop->setCheckable(false);//not necessary in Qt4
+
+ MidiTrack* track = part->track();
+ int portn = track->outPort();
+ MidiPort* port = &midiPorts[portn];
+ bool isDrum = track->type() == Track::DRUM;
+ MidiCtrlValListList* cll = port->controller();
+
+ ctrlList->clear();
+ ctrlList->setSelectionMode(QAbstractItemView::SingleSelection);
+
+ //
+ // populate list of available controller
+ //
+
+ std::list<QString> sList;
+ typedef std::list<QString>::iterator isList;
+
+ for (iMidiCtrlValList i = cll->begin(); i != cll->end(); ++i) {
+ MidiCtrlValList* cl = i->second;
+ int num = cl->num();
+
+ // dont show drum specific controller if not a drum track
+ if ((num & 0xff) == 0xff) {
+ if (!isDrum)
+ continue;
+ }
+ MidiController* c = port->midiController(num);
+ isList i = sList.begin();
+ for (; i != sList.end(); ++i) {
+ if (*i == c->name())
+ break;
+ }
+ if (i == sList.end())
+ sList.push_back(c->name());
+ }
+ MidiController* mc = port->midiController(num);
+ int idx = 0;
+ int selectionIndex = 0;
+ for (isList i = sList.begin(); i != sList.end(); ++i, ++idx) {
+ ctrlList->addItem(*i);
+ if (mc->name() == *i)
+ selectionIndex = idx;
+ }
+ ctrlList->item(selectionIndex)->setSelected(true);
+
+ valSlider->setRange(mc->minVal(), mc->maxVal());
+ valSpinBox->setRange(mc->minVal(), mc->maxVal());
+
+ controllerName->setText(mc->name());
+
+ if(!event.empty())
+ {
+ if(num == CTRL_PROGRAM)
+ {
+ widgetStack->setCurrentIndex(1);
+ updatePatch();
+ }
+ else
+ {
+ widgetStack->setCurrentIndex(0);
+ valSlider->setValue(val - mc->bias());
+ }
+ }
+ else
+ ctrlListClicked(ctrlList->selectedItems()[0]);
+ connect(ctrlList, SIGNAL(itemClicked(QListWidgetItem*)), SLOT(ctrlListClicked(QListWidgetItem*)));
+ connect(buttonNewController, SIGNAL(clicked()), SLOT(newController()));
+ connect(hbank, SIGNAL(valueChanged(int)), SLOT(programChanged()));
+ connect(lbank, SIGNAL(valueChanged(int)), SLOT(programChanged()));
+ connect(program, SIGNAL(valueChanged(int)), SLOT(programChanged()));
+ connect(patchName, SIGNAL(released()), SLOT(instrPopup()));
+ connect(buttonCancel, SIGNAL(clicked()), SLOT(reject()));
+ connect(buttonOk, SIGNAL(clicked()), SLOT(accept()));
+ timePos->setValue(tick);
+
+ }
+//---------------------------------------------------------
+// newController
+//---------------------------------------------------------
+
+void EditCtrlDialog::newController()
+ {
+ QMenu* pup = new QMenu(this);
+ //pup->setCheckable(this);//not necessary in Qt4
+ //
+ // populate popup with all controllers available for
+ // current instrument
+ //
+ MidiTrack* track = part->track();
+ int portn = track->outPort();
+ MidiPort* port = &midiPorts[portn];
+ MidiInstrument* instr = port->instrument();
+ MidiControllerList* mcl = instr->controller();
+
+ MidiCtrlValListList* cll = port->controller();
+ int channel = track->outChannel();
+ int nn = 0;
+ for (iMidiController ci = mcl->begin(); ci != mcl->end(); ++ci)
+ {
+ if(cll->find(channel, ci->second->num()) == cll->end())
+ {
+ QAction* act = pup->addAction(ci->second->name());
+ act->setData(nn);
+ ++nn;
+ }
+ }
+ QAction* rv = pup->exec(buttonNewController->mapToGlobal(QPoint(0,0)));
+ if (rv) {
+ QString s = rv->text();
+ for (iMidiController ci = mcl->begin(); ci != mcl->end(); ++ci) {
+ MidiController* mc = ci->second;
+ if (mc->name() == s) {
+ if(cll->find(channel, mc->num()) == cll->end())
+ {
+ MidiCtrlValList* vl = new MidiCtrlValList(mc->num());
+ cll->add(channel, vl);
+ //song->update(SC_MIDI_CONTROLLER_ADD);
+ }
+ for (int idx = 0; ;++idx) {
+ QString str = ctrlList->item(idx)->text();
+ if (s == str)
+ {
+ ctrlList->item(idx)->setSelected(true);
+ ctrlListClicked(ctrlList->item(idx));
+ break;
+ }
+ if (str.isNull()) {
+ ctrlList->addItem(s);
+ ctrlList->item(idx)->setSelected(true);
+ ctrlListClicked(ctrlList->item(idx));
+ break;
+ }
+ }
+
+ break;
+ }
+ }
+ }
+ delete pup;
+ }
+//---------------------------------------------------------
+// ctrlListClicked
+//---------------------------------------------------------
+
+void EditCtrlDialog::ctrlListClicked(QListWidgetItem* item)
+ {
+ if (item == 0)
+ return;
+ QString s(item->text());
+
+ MidiTrack* track = part->track();
+ int portn = track->outPort();
+ MidiPort* port = &midiPorts[portn];
+ MidiCtrlValListList* cll = port->controller();
+
+ iMidiCtrlValList i;
+ for (i = cll->begin(); i != cll->end(); ++i) {
+ MidiCtrlValList* cl = i->second;
+ num = cl->num();
+ MidiController* c = port->midiController(num);
+ if (s == c->name()) {
+ if (num == CTRL_PROGRAM) {
+ widgetStack->setCurrentIndex(1);
+
+ val = c->initVal();
+ if(val == CTRL_VAL_UNKNOWN)
+ val = 0;
+ updatePatch();
+ }
+ else {
+ widgetStack->setCurrentIndex(0);
+ valSlider->setRange(c->minVal(), c->maxVal());
+ valSpinBox->setRange(c->minVal(), c->maxVal());
+ controllerName->setText(s);
+ val = c->initVal();
+
+ if(val == CTRL_VAL_UNKNOWN || val == 0)
+ {
+ switch(num)
+ {
+ case CTRL_PANPOT:
+ val = 64 - c->bias();
+ break;
+ case CTRL_VOLUME:
+ val = 100;
+ break;
+ default:
+ val = 0;
+ break;
+ }
+ }
+ valSlider->setValue(val);
+ }
+ break;
+ }
+ }
+ if (i == cll->end())
+ printf("controller %s not found!\n", s.toLatin1().constData());
+ }
+
+//---------------------------------------------------------
+// updatePatch
+//---------------------------------------------------------
+
+void EditCtrlDialog::updatePatch()
+ {
+ MidiTrack* track = part->track();
+ int port = track->outPort();
+ int channel = track->outChannel();
+ MidiInstrument* instr = midiPorts[port].instrument();
+ patchName->setText(instr->getPatchName(channel, val, song->mtype(), track->type() == Track::DRUM));
+
+ int hb = ((val >> 16) & 0xff) + 1;
+ if (hb == 0x100)
+ hb = 0;
+ int lb = ((val >> 8) & 0xff) + 1;
+ if (lb == 0x100)
+ lb = 0;
+ int pr = (val & 0xff) + 1;
+ if (pr == 0x100)
+ pr = 0;
+
+ hbank->blockSignals(true);
+ lbank->blockSignals(true);
+ program->blockSignals(true);
+
+ hbank->setValue(hb);
+ lbank->setValue(lb);
+ program->setValue(pr);
+
+ hbank->blockSignals(false);
+ lbank->blockSignals(false);
+ program->blockSignals(false);
+ }
+
+//---------------------------------------------------------
+// instrPopup
+//---------------------------------------------------------
+
+void EditCtrlDialog::instrPopup()
+ {
+ MidiTrack* track = part->track();
+ int channel = track->outChannel();
+ int port = track->outPort();
+ MidiInstrument* instr = midiPorts[port].instrument();
+
+ ///instr->populatePatchPopup(pop, channel, song->mtype(), track->type() == Track::DRUM);
+ QMenu* pup = new QMenu(this);
+ instr->populatePatchPopup(pup, channel, song->mtype(), track->type() == Track::DRUM);
+
+ ///if(pop->actions().count() == 0)
+ /// return;
+ if(pup->actions().count() == 0)
+ {
+ delete pup;
+ return;
+ }
+
+ ///QAction* rv = pop->exec(patchName->mapToGlobal(QPoint(10,5)));
+ QAction* rv = pup->exec(patchName->mapToGlobal(QPoint(10,5)));
+ if (rv) {
+ val = rv->data().toInt();
+ updatePatch();
+ }
+
+ delete pup;
+ }
+
+//---------------------------------------------------------
+// programChanged
+//---------------------------------------------------------
+
+void EditCtrlDialog::programChanged()
+ {
+// MidiTrack* track = part->track();
+// int channel = track->outChannel();
+// int port = track->outPort();
+ int hb = hbank->value();
+ int lb = lbank->value();
+ int prog = program->value();
+
+ if (hb > 0 && hb < 129)
+ hb -= 1;
+ else
+ hb = 0xff;
+ if (lb > 0 && lb < 129)
+ lb -= 1;
+ else
+ lb = 0xff;
+ if (prog > 0 && prog < 129)
+ prog -= 1;
+ else
+ prog = 0xff;
+
+ val = (hb << 16) + (lb << 8) + prog;
+ updatePatch();
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/liste/editevent.h b/attic/muse2-oom/muse2/muse/liste/editevent.h
new file mode 100644
index 00000000..454e6a69
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/liste/editevent.h
@@ -0,0 +1,198 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: editevent.h,v 1.6.2.1 2008/05/21 00:28:53 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __EDIT_EVENT_H__
+#define __EDIT_EVENT_H__
+
+#include "ui_editnotedialogbase.h"
+#include "ui_editsysexdialogbase.h"
+#include "ui_editctrlbase.h"
+#include "event.h"
+
+namespace Awl {
+ class PosEdit;
+ };
+
+///class PosEdit;
+class IntLabel;
+class PitchEdit;
+class QDialog;
+class QLabel;
+class QGridLayout;
+class QTextEdit;
+class QRadioButton;
+class MidiPart;
+class QListWidgetItem;
+class QMenu;
+//---------------------------------------------------------
+// EditEventDialog
+//---------------------------------------------------------
+
+class EditEventDialog : public QDialog {
+ Q_OBJECT
+
+ protected:
+ QGridLayout* layout1;
+
+ public:
+ EditEventDialog(QWidget* parent=0);
+ virtual Event event() = 0;
+ };
+
+//---------------------------------------------------------
+// EditNoteDialog
+//---------------------------------------------------------
+
+class EditNoteDialog : public QDialog, public Ui::EditNoteDialogBase {
+ Q_OBJECT
+
+ public:
+ EditNoteDialog(int tick, const Event&,
+ QWidget* parent=0);
+ static Event getEvent(int tick, const Event&,
+ QWidget* parent = 0);
+ virtual Event event();
+ };
+
+//---------------------------------------------------------
+// EditSysExDialog
+//---------------------------------------------------------
+
+class EditSysexDialog : public QDialog, public Ui::EditSysexDialogBase {
+ Q_OBJECT
+
+ unsigned char* sysex;
+ int len;
+
+ protected:
+ QGridLayout* layout;
+
+ private slots:
+ virtual void accept();
+
+ public:
+ EditSysexDialog(int tick, const Event&,
+ QWidget* parent=0);
+ ~EditSysexDialog();
+ static Event getEvent(int tick, const Event&,
+ QWidget* parent = 0);
+ virtual Event event();
+ };
+
+//---------------------------------------------------------
+// EditCtrlDialog
+//---------------------------------------------------------
+
+class EditCtrlDialog : public QDialog, public Ui::EditCtrlBase {
+ Q_OBJECT
+
+ int num; // controller number
+ int val; // controller value (for prog. changes)
+
+ const MidiPart* part;
+ ///QMenu* pop;
+
+ void updatePatch();
+
+ private slots:
+ void ctrlListClicked(QListWidgetItem*);
+ void newController();
+ void programChanged();
+ void instrPopup();
+
+ protected:
+ QGridLayout* layout;
+
+
+ public:
+ EditCtrlDialog(int tick, const Event&,
+ const MidiPart*, QWidget* parent=0);
+ static Event getEvent(int tick, const Event&, const MidiPart*,
+ QWidget* parent = 0);
+ virtual Event event();
+ };
+
+//---------------------------------------------------------
+// EditMetaDialog
+//---------------------------------------------------------
+
+class EditMetaDialog : public EditEventDialog {
+ Q_OBJECT
+
+ unsigned char* meta;
+ int len;
+ ///PosEdit* epos;
+ Awl::PosEdit* epos;
+ QTextEdit* edit;
+ IntLabel* il2;
+ QRadioButton* hexButton;
+ QLabel* typeLabel;
+
+ protected:
+ QGridLayout* layout;
+
+ private slots:
+ virtual void accept();
+ void toggled(bool);
+ void typeChanged(int);
+
+ public:
+ EditMetaDialog(int tick, const Event&,
+ QWidget* parent=0);
+ ~EditMetaDialog();
+ static Event getEvent(int tick, const Event&,
+ QWidget* parent = 0);
+ virtual Event event();
+ };
+
+//---------------------------------------------------------
+// EditCAfterDialog
+//---------------------------------------------------------
+
+class EditCAfterDialog : public EditEventDialog {
+ Q_OBJECT
+
+ ///PosEdit* epos;
+ Awl::PosEdit* epos;
+ IntLabel* il2;
+
+ protected:
+ QGridLayout* layout;
+
+ public:
+ EditCAfterDialog(int tick, const Event&,
+ QWidget* parent=0);
+ static Event getEvent(int tick, const Event&,
+ QWidget* parent = 0);
+ virtual Event event();
+ };
+
+//---------------------------------------------------------
+// EditPAfterDialog
+//---------------------------------------------------------
+
+class EditPAfterDialog : public EditEventDialog {
+ Q_OBJECT
+
+ ///PosEdit* epos;
+ Awl::PosEdit* epos;
+ PitchEdit* pl;
+ IntLabel* il2;
+
+ protected:
+ QGridLayout* layout;
+
+ public:
+ EditPAfterDialog(int tick, const Event&,
+ QWidget* parent=0);
+ static Event getEvent(int tick, const Event&,
+ QWidget* parent = 0);
+ virtual Event event();
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/liste/listedit.cpp b/attic/muse2-oom/muse2/muse/liste/listedit.cpp
new file mode 100644
index 00000000..3f29176c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/liste/listedit.cpp
@@ -0,0 +1,927 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: listedit.cpp,v 1.11.2.11 2009/05/24 21:43:44 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QAction>
+#include <QActionGroup>
+#include <QCloseEvent>
+#include <QKeyEvent>
+#include <QMenu>
+#include <QMenuBar>
+#include <QSignalMapper>
+#include <QToolBar>
+#include <QTreeWidgetItem>
+
+#include "listedit.h"
+#include "mtscale.h"
+#include "globals.h"
+#include "icons.h"
+#include "editevent.h"
+#include "xml.h"
+#include "pitchedit.h"
+#include "song.h"
+#include "audio.h"
+#include "shortcuts.h"
+#include "midi.h"
+#include "event.h"
+#include "midiport.h"
+#include "midictrl.h"
+
+//---------------------------------------------------------
+// EventListItem
+//---------------------------------------------------------
+
+class EventListItem : public QTreeWidgetItem {
+ public:
+ Event event;
+ MidiPart* part;
+
+ EventListItem(QTreeWidget* parent, Event ev, MidiPart* p)
+ : QTreeWidgetItem(parent) {
+ event = ev;
+ part = p;
+ }
+ virtual QString text(int col) const;
+
+
+ virtual bool operator< ( const QTreeWidgetItem & other ) const
+ {
+ int col = other.treeWidget()->sortColumn();
+ EventListItem* eli = (EventListItem*) &other;
+ switch(col)
+ {
+ case 0:
+ return event.tick() < eli->event.tick();
+ break;
+ case 1:
+ return part->tick() + event.tick() < (eli->part->tick() + eli->event.tick());
+ break;
+ case 2:
+ return text(col).localeAwareCompare(other.text(col)) < 0;
+ break;
+ case 3:
+ return part->track()->outChannel() < eli->part->track()->outChannel();
+ break;
+ case 4:
+ return event.dataA() < eli->event.dataA();
+ break;
+ case 5:
+ return event.dataB() < eli->event.dataB();
+ break;
+ case 6:
+ return event.dataC() < eli->event.dataC();
+ break;
+ case 7:
+ return event.lenTick() < eli->event.lenTick();
+ break;
+ case 8:
+ return text(col).localeAwareCompare(other.text(col)) < 0;
+ break;
+ default:
+ break;
+ }
+ return 0;
+ }
+ };
+
+/*---------------------------------------------------------
+ * midi_meta_name
+ *---------------------------------------------------------*/
+
+static QString midiMetaComment(const Event& ev)
+ {
+ int meta = ev.dataA();
+ QString s = midiMetaName(meta);
+
+ switch (meta) {
+ case 0:
+ case 0x2f:
+ case 0x51:
+ case 0x54:
+ case 0x58:
+ case 0x59:
+ case 0x74:
+ case 0x7f: return s;
+
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 5:
+ case 6:
+ case 7:
+ case 8:
+ case 9:
+ case 0x0a:
+ case 0x0b:
+ case 0x0c:
+ case 0x0d:
+ case 0x0e:
+ case 0x0f:
+ {
+ s += QString(": ");
+ const char* txt = (char*)(ev.data());
+ int len = ev.dataLen();
+ char buffer[len+1];
+ memcpy(buffer, txt, len);
+ buffer[len] = 0;
+
+ for (int i = 0; i < len; ++i) {
+ if (buffer[i] == '\n' || buffer[i] == '\r')
+ buffer[i] = ' ';
+ }
+ return s + QString(buffer);
+ }
+
+ case 0x20:
+ case 0x21:
+ default:
+ {
+ s += QString(": ");
+ int i;
+ int len = ev.lenTick();
+ int n = len > 10 ? 10 : len;
+ for (i = 0; i < n; ++i) {
+ if (i >= ev.dataLen())
+ break;
+ s += QString(" 0x");
+ QString k;
+ k.setNum(ev.data()[i] & 0xff, 16);
+ s += k;
+ }
+ if (i == 10)
+ s += QString("...");
+ return s;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void ListEdit::closeEvent(QCloseEvent* e)
+ {
+ emit deleted((unsigned long)this);
+ e->accept();
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void ListEdit::songChanged(int type)
+ {
+ if (type == 0)
+ return;
+ if (type & (SC_PART_REMOVED | SC_PART_MODIFIED
+ | SC_PART_INSERTED | SC_EVENT_REMOVED | SC_EVENT_MODIFIED
+ | SC_EVENT_INSERTED | SC_SELECTION)) {
+ if (type & (SC_PART_REMOVED | SC_PART_INSERTED))
+ genPartlist();
+ // close window if editor has no parts anymore
+ if (parts()->empty()) {
+ close();
+ return;
+ }
+ liste->setSortingEnabled(false);
+ if (type == SC_SELECTION) {
+ bool update = false;
+ QTreeWidgetItem* ci = 0;
+ for (int row = 0; row < liste->topLevelItemCount(); ++row) {
+ QTreeWidgetItem* i = liste->topLevelItem(row);
+ if (i->isSelected() ^ ((EventListItem*)i)->event.selected()) {
+ i->setSelected(((EventListItem*)i)->event.selected());
+ if (i->isSelected())
+ ci = i;
+ update = true;
+ }
+ }
+ if (update) {
+ if (ci)
+ liste->setCurrentItem(ci);
+ //liste->update();
+ }
+ }
+ else {
+ curPart = 0;
+ curTrack = 0;
+ liste->clear();
+ for (iPart p = parts()->begin(); p != parts()->end(); ++p) {
+ MidiPart* part = (MidiPart*) (p->second);
+ if (part->sn() == curPartId)
+ curPart = part;
+ EventList* el = part->events();
+ for (iEvent i = el->begin(); i != el->end(); ++i) {
+ EventListItem* item = new EventListItem(liste, i->second, part);
+ for (int col = 0; col < liste->columnCount(); ++col)
+ item->setText(col, item->text(col));
+ item->setSelected(i->second.selected());
+ if (item->event.tick() == (unsigned) selectedTick) { //prevent compiler warning: comparison of signed/unsigned)
+ liste->setCurrentItem(item);
+ item->setSelected(true);
+ liste->scrollToItem(item, QAbstractItemView::EnsureVisible);
+ }
+ }
+ }
+ }
+
+ // p3.3.34
+ //if (curPart == 0)
+ // curPart = (MidiPart*)(parts()->begin()->second);
+ //curTrack = curPart->track();
+ if(!curPart)
+ {
+ if(!parts()->empty())
+ {
+ curPart = (MidiPart*)(parts()->begin()->second);
+ if(curPart)
+ curTrack = curPart->track();
+ else
+ curPart = 0;
+ }
+ }
+ }
+ liste->setSortingEnabled(true);
+ }
+
+//---------------------------------------------------------
+// text
+//---------------------------------------------------------
+
+QString EventListItem::text(int col) const
+ {
+ QString s;
+ QString commentLabel;
+ switch(col) {
+ case 0:
+ s.setNum(event.tick());
+ break;
+ case 1:
+ {
+ int t = event.tick() + part->tick();
+ int bar, beat;
+ unsigned tick;
+ AL::sigmap.tickValues(t, &bar, &beat, &tick);
+ s.sprintf("%04d.%02d.%03d", bar+1, beat+1, tick);
+ }
+ break;
+ case 2:
+ switch(event.type()) {
+ case Note:
+ s = QString("Note");
+ break;
+ case Controller:
+ {
+ const char* cs;
+ switch (midiControllerType(event.dataA())) {
+ case MidiController::Controller7: cs = "Ctrl7"; break;
+ case MidiController::Controller14: cs = "Ctrl14"; break;
+ case MidiController::RPN: cs = "RPN"; break;
+ case MidiController::NRPN: cs = "NRPN"; break;
+ case MidiController::Pitch: cs = "Pitch"; break;
+ case MidiController::Program: cs = "Program"; break;
+ case MidiController::RPN14: cs = "RPN14"; break;
+ case MidiController::NRPN14: cs = "NRPN14"; break;
+ default: cs = "Ctrl?"; break;
+ }
+ s = QString(cs);
+ }
+ break;
+ case Sysex:
+ {
+ commentLabel = QString("len ");
+ QString k;
+ k.setNum(event.dataLen());
+ commentLabel += k;
+ commentLabel += QString(" ");
+
+ commentLabel += nameSysex(event.dataLen(), event.data());
+ int i;
+ for (i = 0; i < 10; ++i) {
+ if (i >= event.dataLen())
+ break;
+ commentLabel += QString(" 0x");
+ QString k;
+ k.setNum(event.data()[i] & 0xff, 16);
+ commentLabel += k;
+ }
+ if (i == 10)
+ commentLabel += QString("...");
+ }
+ s = QString("SysEx");
+ break;
+ case PAfter:
+ s = QString("PoAT");
+ break;
+ case CAfter:
+ s = QString("ChAT");
+ break;
+ case Meta:
+ commentLabel = midiMetaComment(event);
+ s = QString("Meta");
+ break;
+ case Wave:
+ break;
+ default:
+ printf("unknown event type %d\n", event.type());
+ }
+ break;
+ case 3:
+ s.setNum(part->track()->outChannel() + 1);
+ break;
+ case 4:
+ if (event.isNote() || event.type() == PAfter)
+ s = pitch2string(event.dataA());
+ else if (event.type() == Controller)
+ s.setNum(event.dataA() & 0xffff); // mask off type bits
+ else
+ s.setNum(event.dataA());
+ break;
+ case 5:
+ if(event.type() == Controller &&
+ midiControllerType(event.dataA()) == MidiController::Program)
+ {
+ int val = event.dataB();
+ int hb = ((val >> 16) & 0xff) + 1;
+ if (hb == 0x100)
+ hb = 0;
+ int lb = ((val >> 8) & 0xff) + 1;
+ if (lb == 0x100)
+ lb = 0;
+ int pr = (val & 0xff) + 1;
+ if (pr == 0x100)
+ pr = 0;
+ s.sprintf("%d-%d-%d", hb, lb, pr);
+ }
+ else
+ s.setNum(event.dataB());
+ break;
+ case 6:
+ s.setNum(event.dataC());
+ break;
+ case 7:
+ s.setNum(event.lenTick());
+ break;
+ case 8:
+ switch(event.type()) {
+ case Controller:
+ {
+ MidiPort* mp = &midiPorts[part->track()->outPort()];
+ MidiController* mc = mp->midiController(event.dataA());
+ s = mc->name();
+ }
+ break;
+ case Sysex:
+ {
+ s = QString("len ");
+ QString k;
+ k.setNum(event.dataLen());
+ s += k;
+ s += QString(" ");
+
+ commentLabel += nameSysex(event.dataLen(), event.data());
+ int i;
+ for (i = 0; i < 10; ++i) {
+ if (i >= event.dataLen())
+ break;
+ s += QString(" 0x");
+ QString k;
+ k.setNum(event.data()[i] & 0xff, 16);
+ s += k;
+ }
+ if (i == 10)
+ s += QString("...");
+ }
+ break;
+ case Meta:
+ s = midiMetaComment(event);
+ break;
+ default:
+ break;
+ }
+ break;
+
+ }
+ return s;
+ }
+
+//---------------------------------------------------------
+// ListEdit
+//---------------------------------------------------------
+
+ListEdit::ListEdit(PartList* pl)
+ : MidiEditor(0, 0, pl)
+ {
+ insertItems = new QActionGroup(this);
+ insertItems->setExclusive(false);
+ insertNote = new QAction(QIcon(*note1Icon), tr("insert Note"), insertItems);
+ insertSysEx = new QAction(QIcon(*sysexIcon), tr("insert SysEx"), insertItems);
+ insertCtrl = new QAction(QIcon(*ctrlIcon), tr("insert Ctrl"), insertItems);
+ insertMeta = new QAction(QIcon(*metaIcon), tr("insert Meta"), insertItems);
+ insertCAfter = new QAction(QIcon(*cafterIcon), tr("insert Channel Aftertouch"), insertItems);
+ insertPAfter = new QAction(QIcon(*pafterIcon), tr("insert Poly Aftertouch"), insertItems);
+
+ connect(insertNote, SIGNAL(activated()), SLOT(editInsertNote()));
+ connect(insertSysEx, SIGNAL(activated()), SLOT(editInsertSysEx()));
+ connect(insertCtrl, SIGNAL(activated()), SLOT(editInsertCtrl()));
+ connect(insertMeta, SIGNAL(activated()), SLOT(editInsertMeta()));
+ connect(insertCAfter, SIGNAL(activated()), SLOT(editInsertCAfter()));
+ connect(insertPAfter, SIGNAL(activated()), SLOT(editInsertPAfter()));
+
+ //---------Pulldown Menu----------------------------
+
+ QSignalMapper *editSignalMapper = new QSignalMapper(this);
+
+ menuEdit = menuBar()->addMenu(tr("&Edit"));
+ menuEdit->addActions(undoRedo->actions());
+
+ menuEdit->addSeparator();
+#if 0
+ QAction *cutAction = menuEdit->addAction(QIcon(*editcutIconSet), tr("Cut"));
+ connect(cutAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ editSignalMapper->setMapping(cutAction, EList::CMD_CUT);
+ cutAction->setShortcut(Qt::CTRL+Qt::Key_X);
+ QAction *copyAction = menuEdit->addAction(QIcon(*editcopyIconSet), tr("Copy"));
+ connect(copyAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ editSignalMapper->setMapping(cutAction, EList::CMD_COPY);
+ copyAction->setShortcut(Qt::CTRL+Qt::Key_C);
+ QAction *pasteAction = menuEdit->addAction(QIcon(*editpasteIconSet), tr("Paste"));
+ connect(pasteAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ editSignalMapper->setMapping(cutAction, EList::CMD_PASTE);
+ pasteAction->setShortcut(Qt::CTRL+Qt::Key_V);
+ menuEdit->insertSeparator();
+#endif
+ QAction *deleteAction = menuEdit->addAction(tr("Delete Events"));
+ connect(deleteAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ editSignalMapper->setMapping(deleteAction, CMD_DELETE);
+ deleteAction->setShortcut(Qt::Key_Delete);
+ menuEdit->addSeparator();
+
+ menuEdit->addActions(insertItems->actions());
+
+ connect(editSignalMapper, SIGNAL(mapped(int)), SLOT(cmd(int)));
+
+ //---------ToolBar----------------------------------
+
+ listTools = addToolBar(tr("List tools"));
+ listTools->addActions(undoRedo->actions());
+
+ QToolBar* insertTools = addToolBar(tr("Insert tools"));
+ insertTools->addActions(insertItems->actions());
+
+ //
+ //---------------------------------------------------
+ // liste
+ //---------------------------------------------------
+ //
+
+ liste = new QTreeWidget(mainw);
+ QFontMetrics fm(liste->font());
+ int n = fm.width('9');
+ int b = 24;
+ int c = fm.width(QString("Val B"));
+ int sortIndW = n * 3;
+ liste->setAllColumnsShowFocus(true);
+ liste->sortByColumn(0, Qt::AscendingOrder);
+
+ liste->setSelectionMode(QAbstractItemView::ExtendedSelection);
+
+ QStringList columnnames;
+ columnnames << tr("Tick")
+ << tr("Bar")
+ << tr("Type")
+ << tr("Ch")
+ << tr("Val A")
+ << tr("Val B")
+ << tr("Val C")
+ << tr("Len")
+ << tr("Comment");
+
+ liste->setHeaderLabels(columnnames);
+
+ liste->setColumnWidth(0, n * 6 + b);
+ liste->setColumnWidth(1, fm.width(QString("9999.99.999")) + b);
+ liste->setColumnWidth(2, fm.width(QString("Program")) + b);
+ liste->setColumnWidth(3, n * 2 + b + sortIndW);
+ liste->setColumnWidth(4, c + b + sortIndW);
+ liste->setColumnWidth(5, c + b + sortIndW);
+ liste->setColumnWidth(6, c + b + sortIndW);
+ liste->setColumnWidth(7, n * 4 + b + sortIndW);
+ liste->setColumnWidth(8, fm.width(QString("MainVolume")) + 70);
+
+ connect(liste, SIGNAL(itemSelectionChanged()), SLOT(selectionChanged()));
+ connect(liste, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), SLOT(doubleClicked(QTreeWidgetItem*)));
+ //---------------------------------------------------
+ // Rest
+ //---------------------------------------------------
+
+ mainGrid->setRowStretch(1, 100);
+ mainGrid->setColumnStretch(0, 100);
+ mainGrid->addWidget(liste, 1, 0, 2, 1);
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+ songChanged(-1);
+
+ // p3.3.34
+ // Was crashing because of -1 stored, because there was an invalid
+ // part pointer stored.
+ //curPart = (MidiPart*)(pl->begin()->second);
+ if(pl->empty())
+ {
+ curPart = 0;
+ curPartId = -1;
+ }
+ else
+ {
+ curPart = (MidiPart*)pl->begin()->second;
+ if(curPart)
+ curPartId = curPart->sn();
+ else
+ {
+ curPart = 0;
+ curPartId = -1;
+ }
+ }
+
+ initShortcuts();
+ }
+
+//---------------------------------------------------------
+// ~ListEdit
+//---------------------------------------------------------
+
+ListEdit::~ListEdit()
+ {
+ // undoRedo->removeFrom(listTools); // p4.0.6 Removed
+ }
+
+//---------------------------------------------------------
+// editInsertNote
+//---------------------------------------------------------
+
+void ListEdit::editInsertNote()
+ {
+ // p3.3.34
+ if(!curPart)
+ return;
+
+ Event event = EditNoteDialog::getEvent(curPart->tick(), Event(), this);
+ if (!event.empty()) {
+ //No events before beginning of part + take Part offset into consideration
+ unsigned tick = event.tick();
+ if (tick < curPart->tick())
+ tick = 0;
+ else
+ tick-= curPart->tick();
+ event.setTick(tick);
+ // Indicate do undo, and do not handle port controller values.
+ //audio->msgAddEvent(event, curPart);
+ audio->msgAddEvent(event, curPart, true, false, false);
+ }
+ }
+
+//---------------------------------------------------------
+// editInsertSysEx
+//---------------------------------------------------------
+
+void ListEdit::editInsertSysEx()
+ {
+ // p3.3.34
+ if(!curPart)
+ return;
+
+ Event event = EditSysexDialog::getEvent(curPart->tick(), Event(), this);
+ if (!event.empty()) {
+ //No events before beginning of part + take Part offset into consideration
+ unsigned tick = event.tick();
+ if (tick < curPart->tick())
+ tick = 0;
+ else
+ tick-= curPart->tick();
+ event.setTick(tick);
+ // Indicate do undo, and do not handle port controller values.
+ //audio->msgAddEvent(event, curPart);
+ audio->msgAddEvent(event, curPart, true, false, false);
+ }
+ }
+
+//---------------------------------------------------------
+// editInsertCtrl
+//---------------------------------------------------------
+
+void ListEdit::editInsertCtrl()
+ {
+ // p3.3.34
+ if(!curPart)
+ return;
+
+ Event event = EditCtrlDialog::getEvent(curPart->tick(), Event(), curPart, this);
+ if (!event.empty()) {
+ //No events before beginning of part + take Part offset into consideration
+ unsigned tick = event.tick();
+ if (tick < curPart->tick())
+ tick = 0;
+ else
+ tick-= curPart->tick();
+ event.setTick(tick);
+ // Indicate do undo, and do port controller values and clone parts.
+ //audio->msgAddEvent(event, curPart);
+ audio->msgAddEvent(event, curPart, true, true, true);
+ }
+ }
+
+//---------------------------------------------------------
+// editInsertMeta
+//---------------------------------------------------------
+
+void ListEdit::editInsertMeta()
+ {
+ // p3.3.34
+ if(!curPart)
+ return;
+
+ Event event = EditMetaDialog::getEvent(curPart->tick(), Event(), this);
+ if (!event.empty()) {
+ //No events before beginning of part + take Part offset into consideration
+ unsigned tick = event.tick();
+ if (tick < curPart->tick())
+ tick = 0;
+ else
+ tick-= curPart->tick();
+ event.setTick(tick);
+ // Indicate do undo, and do not handle port controller values.
+ //audio->msgAddEvent(event, curPart);
+ audio->msgAddEvent(event, curPart, true, false, false);
+ }
+ }
+
+//---------------------------------------------------------
+// editInsertCAfter
+//---------------------------------------------------------
+
+void ListEdit::editInsertCAfter()
+ {
+ // p3.3.34
+ if(!curPart)
+ return;
+
+ Event event = EditCAfterDialog::getEvent(curPart->tick(), Event(), this);
+ if (!event.empty()) {
+ //No events before beginning of part + take Part offset into consideration
+ unsigned tick = event.tick();
+ if (tick < curPart->tick())
+ tick = 0;
+ else
+ tick-= curPart->tick();
+ event.setTick(tick);
+ // Indicate do undo, and do not handle port controller values.
+ //audio->msgAddEvent(event, curPart);
+ audio->msgAddEvent(event, curPart, true, false, false);
+ }
+ }
+
+//---------------------------------------------------------
+// editInsertPAfter
+//---------------------------------------------------------
+
+void ListEdit::editInsertPAfter()
+ {
+ // p3.3.34
+ if(!curPart)
+ return;
+
+ Event ev;
+ Event event = EditPAfterDialog::getEvent(curPart->tick(), ev, this);
+ if (!event.empty()) {
+ //No events before beginning of part + take Part offset into consideration
+ unsigned tick = event.tick();
+ if (tick < curPart->tick())
+ tick = 0;
+ else
+ tick-= curPart->tick();
+ event.setTick(tick);
+ // Indicate do undo, and do not handle port controller values.
+ //audio->msgAddEvent(event, curPart);
+ audio->msgAddEvent(event, curPart, true, false, false);
+ }
+ }
+
+//---------------------------------------------------------
+// editEvent
+//---------------------------------------------------------
+
+void ListEdit::editEvent(Event& event, MidiPart* part)
+ {
+ int tick = event.tick() + part->tick();
+ Event nevent;
+ switch(event.type()) {
+ case Note:
+ nevent = EditNoteDialog::getEvent(tick, event, this);
+ break;
+ case Controller:
+ nevent = EditCtrlDialog::getEvent(tick, event, part, this);
+ break;
+ case Sysex:
+ nevent = EditSysexDialog::getEvent(tick, event, this);
+ break;
+ case PAfter:
+ nevent = EditPAfterDialog::getEvent(tick, event, this);
+ break;
+ case CAfter:
+ nevent = EditCAfterDialog::getEvent(tick, event, this);
+ break;
+ case Meta:
+ nevent = EditMetaDialog::getEvent(tick, event, this);
+ break;
+ default:
+ return;
+ }
+ if (!nevent.empty()) {
+ // TODO: check for event != nevent
+ int tick = nevent.tick() - part->tick();
+ nevent.setTick(tick);
+ if (tick < 0)
+ printf("event not in part %d - %d - %d, not changed\n", part->tick(),
+ nevent.tick(), part->tick() + part->lenTick());
+ else
+ {
+ if(event.type() == Controller)
+ // Indicate do undo, and do port controller values and clone parts.
+ //audio->msgChangeEvent(event, nevent, part);
+ audio->msgChangeEvent(event, nevent, part, true, true, true);
+ else
+ // Indicate do undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(event, nevent, part);
+ audio->msgChangeEvent(event, nevent, part, true, false, false);
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// readStatus
+//---------------------------------------------------------
+
+void ListEdit::readStatus(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ if (token == Xml::Error || token == Xml::End)
+ break;
+ switch (token) {
+ case Xml::TagStart:
+ if (tag == "midieditor")
+ MidiEditor::readStatus(xml);
+ else
+ xml.unknown("ListEdit");
+ break;
+ case Xml::TagEnd:
+ if (tag == "listeditor")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// writeStatus
+//---------------------------------------------------------
+
+void ListEdit::writeStatus(int level, Xml& xml) const
+ {
+ writePartList(level, xml);
+ xml.tag(level++, "listeditor");
+ MidiEditor::writeStatus(level, xml);
+ xml.tag(level, "/listeditor");
+ }
+
+//---------------------------------------------------------
+// selectionChanged
+//---------------------------------------------------------
+
+void ListEdit::selectionChanged()
+ {
+ bool update = false;
+ for (int row = 0; row < liste->topLevelItemCount(); ++row) {
+ QTreeWidgetItem* i = liste->topLevelItem(row);
+ if (i->isSelected() ^ ((EventListItem*)i)->event.selected()) {
+ ((EventListItem*)i)->event.setSelected(i->isSelected());
+ update = true;
+ }
+ }
+ if (update)
+ song->update(SC_SELECTION);
+ }
+
+//---------------------------------------------------------
+// doubleClicked
+//---------------------------------------------------------
+
+void ListEdit::doubleClicked(QTreeWidgetItem* item)
+ {
+ EventListItem* ev = (EventListItem*) item;
+ selectedTick = ev->event.tick();
+ editEvent(ev->event, ev->part);
+ }
+
+//---------------------------------------------------------
+// cmd
+//---------------------------------------------------------
+
+void ListEdit::cmd(int cmd)
+ {
+ switch(cmd) {
+ case CMD_DELETE:
+ bool found = false;
+ for (int row = 0; row < liste->topLevelItemCount(); ++row)
+ {
+ QTreeWidgetItem* i = liste->topLevelItem(row);
+ EventListItem *item = (EventListItem *) i;
+ if (i->isSelected() || item->event.selected())
+ {
+ found = true;
+ break;
+ }
+ }
+ if(!found)
+ break;
+ song->startUndo();
+
+ EventListItem *deletedEvent=NULL;
+ for (int row = 0; row < liste->topLevelItemCount(); ++row) {
+ QTreeWidgetItem* i = liste->topLevelItem(row);
+ EventListItem *item = (EventListItem *) i;
+
+ if (i->isSelected() || item->event.selected()) {
+ deletedEvent=item;
+ // Indicate no undo, and do port controller values and clone parts.
+ //audio->msgDeleteEvent(item->event, item->part, false);
+ audio->msgDeleteEvent(item->event, item->part, false, true, true);
+ }
+ }
+
+ unsigned int nextTick=0;
+ // find biggest tick
+ for (int row = 0; row < liste->topLevelItemCount(); ++row) {
+ QTreeWidgetItem* i = liste->topLevelItem(row);
+ EventListItem *item = (EventListItem *) i;
+ if (item->event.tick() > nextTick && item != deletedEvent)
+ nextTick=item->event.tick();
+ }
+ // check if there's a tick that is "just" bigger than the deleted
+ for (int row = 0; row < liste->topLevelItemCount(); ++row) {
+ QTreeWidgetItem* i = liste->topLevelItem(row);
+ EventListItem *item = (EventListItem *) i;
+ if (item->event.tick() >= deletedEvent->event.tick() &&
+ item->event.tick() < nextTick &&
+ item != deletedEvent ) {
+ nextTick=item->event.tick();
+ }
+ }
+ selectedTick=nextTick;
+ song->endUndo(SC_EVENT_MODIFIED);
+ //printf("selected tick = %d\n", selectedTick);
+ //emit selectionChanged();
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// configChanged
+//---------------------------------------------------------
+
+void ListEdit::configChanged()
+ {
+ initShortcuts();
+ }
+
+//---------------------------------------------------------
+// initShortcuts
+//---------------------------------------------------------
+
+void ListEdit::initShortcuts()
+ {
+ insertNote->setShortcut(shortcuts[SHRT_LE_INS_NOTES].key);
+ insertSysEx->setShortcut(shortcuts[SHRT_LE_INS_SYSEX].key);
+ insertCtrl->setShortcut(shortcuts[SHRT_LE_INS_CTRL].key);
+ insertMeta->setShortcut(shortcuts[SHRT_LE_INS_META].key);
+ insertCAfter->setShortcut(shortcuts[SHRT_LE_INS_CHAN_AFTERTOUCH].key);
+ insertPAfter->setShortcut(shortcuts[SHRT_LE_INS_POLY_AFTERTOUCH].key);
+ }
+
+//---------------------------------------------------------
+// viewKeyPressEvent
+//---------------------------------------------------------
+
+void ListEdit::keyPressEvent(QKeyEvent* event)
+ {
+int key = event->key();
+if (key == Qt::Key_Escape) {
+ close();
+ return;
+ }
+ }
diff --git a/attic/muse2-oom/muse2/muse/liste/listedit.h b/attic/muse2-oom/muse2/muse/liste/listedit.h
new file mode 100644
index 00000000..5cf60a59
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/liste/listedit.h
@@ -0,0 +1,79 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: listedit.h,v 1.3.2.3 2006/09/19 22:03:33 spamatica Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __LIST_EDIT_H__
+#define __LIST_EDIT_H__
+
+#include "midieditor.h"
+#include "noteinfo.h"
+#include "cobject.h"
+
+class QAction;
+class QActionGroup;
+class QCloseEvent;
+class QKeyEvent;
+class QTreeWidget;
+class QTreeWidgetItem;
+
+
+class Event;
+class MidiTrack;
+class PartList;
+class MidiPart;
+class MidiPart;
+class Xml;
+
+//---------------------------------------------------------
+// ListEdit
+//---------------------------------------------------------
+
+class ListEdit : public MidiEditor {
+ QTreeWidget* liste;
+ QMenu* menuEdit;
+ QActionGroup* insertItems;
+ QToolBar* listTools;
+ MidiTrack* curTrack;
+ MidiPart* curPart;
+ int selectedTick;
+ int curPartId;
+
+ enum { CMD_DELETE };
+
+ Q_OBJECT
+ virtual void closeEvent(QCloseEvent*);
+ virtual void keyPressEvent(QKeyEvent*);
+ void initShortcuts();
+ QAction *insertNote, *insertSysEx, *insertCtrl, *insertMeta, *insertCAfter, *insertPAfter;
+
+ private slots:
+ void editInsertNote();
+ void editInsertSysEx();
+ void editInsertCtrl();
+ void editInsertMeta();
+ void editInsertCAfter();
+ void editInsertPAfter();
+ void editEvent(Event&, MidiPart*);
+ void selectionChanged();
+ void doubleClicked(QTreeWidgetItem*);
+ void cmd(int cmd);
+ void configChanged();
+
+ public slots:
+ void songChanged(int);
+
+ signals:
+ void deleted(unsigned long);
+
+ public:
+ ListEdit(PartList*);
+ ~ListEdit();
+ virtual void readStatus(Xml&);
+ virtual void writeStatus(int, Xml&) const;
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/main.cpp b/attic/muse2-oom/muse2/muse/main.cpp
new file mode 100644
index 00000000..936a8aa3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/main.cpp
@@ -0,0 +1,495 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: app.cpp,v 1.113.2.68 2009/12/21 14:51:51 spamatica Exp $
+//
+// (C) Copyright 1999-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QApplication>
+#include <QDir>
+#include <QKeyEvent>
+#include <QMessageBox>
+#include <QLocale>
+#include <QSplashScreen>
+#include <QTimer>
+#include <QTranslator>
+
+#include <sys/mman.h>
+#include <alsa/asoundlib.h>
+
+#include "al/dsp.h"
+#include "app.h"
+#include "audio.h"
+#include "audiodev.h"
+#include "gconfig.h"
+#include "globals.h"
+#include "icons.h"
+#include "sync.h"
+
+extern bool initDummyAudio();
+extern void initIcons();
+extern bool initJackAudio();
+extern void initMidiController();
+extern void initMetronome();
+extern void initOSC();
+extern void initVST();
+extern void initPlugins();
+extern void initShortCuts();
+extern void initDSSI();
+extern void readConfiguration();
+
+static QString locale_override;
+
+#ifdef HAVE_LASH
+#include <lash/lash.h>
+extern lash_client_t * lash_client;
+extern snd_seq_t * alsaSeq;
+#endif
+
+//---------------------------------------------------------
+// getCapabilities
+//---------------------------------------------------------
+
+static void getCapabilities()
+ {
+#ifdef RTCAP
+#ifdef __linux__
+ const char* napp = getenv("GIVERTCAP");
+ if (napp == 0)
+ napp = "givertcap";
+ int pid = fork();
+ if (pid == 0) {
+ if (execlp(napp, napp, 0) == -1)
+ perror("exec givertcap failed");
+ }
+ else if (pid == -1) {
+ perror("fork givertcap failed");
+ }
+ else {
+ waitpid(pid, 0, 0);
+ }
+#endif // __linux__
+#endif
+ }
+
+//---------------------------------------------------------
+// printVersion
+//---------------------------------------------------------
+
+static void printVersion(const char* prog)
+ {
+ fprintf(stderr, "%s: Linux Music Editor; Version %s, (svn revision %s)\n", prog, VERSION, SVNVERSION);
+ }
+
+//---------------------------------------------------------
+// MuseApplication
+//---------------------------------------------------------
+
+class MuseApplication : public QApplication {
+ MusE* muse;
+
+ public:
+ MuseApplication(int& argc, char** argv)
+ : QApplication(argc, argv)
+ {
+ muse = 0;
+ }
+
+
+ void setMuse(MusE* m) {
+ muse = m;
+#ifdef HAVE_LASH
+ if(useLASH)
+ startTimer (300);
+#endif
+ }
+
+ bool notify(QObject* receiver, QEvent* event) {
+ //if (event->type() == QEvent::KeyPress)
+ // printf("notify key press before app::notify accepted:%d\n", event->isAccepted()); // REMOVE Tim
+ bool flag = QApplication::notify(receiver, event);
+ if (event->type() == QEvent::KeyPress) {
+ //printf("notify key press after app::notify accepted:%d\n", event->isAccepted()); // REMOVE Tim
+ QKeyEvent* ke = (QKeyEvent*)event;
+ ///globalKeyState = ke->stateAfter();
+ globalKeyState = ke->modifiers();
+ bool accepted = ke->isAccepted();
+ if (!accepted) {
+ int key = ke->key();
+ ///if (ke->state() & Qt::ShiftModifier)
+ //if (globalKeyState & Qt::ShiftModifier)
+ if (((QInputEvent*)ke)->modifiers() & Qt::ShiftModifier)
+ key += Qt::SHIFT;
+ ///if (ke->state() & Qt::AltModifier)
+ //if (globalKeyState & Qt::AltModifier)
+ if (((QInputEvent*)ke)->modifiers() & Qt::AltModifier)
+ key += Qt::ALT;
+ ///if (ke->state() & Qt::ControlModifier)
+ //if (globalKeyState & Qt::ControlModifier)
+ if (((QInputEvent*)ke)->modifiers() & Qt::ControlModifier)
+ key+= Qt::CTRL;
+ muse->kbAccel(key);
+ return true;
+ }
+ }
+ if (event->type() == QEvent::KeyRelease) {
+ QKeyEvent* ke = (QKeyEvent*)event;
+ ///globalKeyState = ke->stateAfter();
+ globalKeyState = ke->modifiers();
+ }
+
+ return flag;
+ }
+
+#ifdef HAVE_LASH
+ virtual void timerEvent (QTimerEvent * /* e */) {
+ if(useLASH)
+ muse->lash_idle_cb ();
+ }
+#endif /* HAVE_LASH */
+
+ };
+
+//---------------------------------------------------------
+// localeList
+//---------------------------------------------------------
+
+static QString localeList()
+ {
+ // Find out what translations are available:
+ QStringList deliveredLocaleListFiltered;
+ QString distLocale = museGlobalShare + "/locale";
+ QFileInfo distLocaleFi(distLocale);
+ if (distLocaleFi.isDir()) {
+ QDir dir = QDir(distLocale);
+ QStringList deliveredLocaleList = dir.entryList();
+ for(QStringList::iterator it = deliveredLocaleList.begin(); it != deliveredLocaleList.end(); ++it) {
+ QString item = *it;
+ if (item.endsWith(".qm")) {
+ int inipos = item.indexOf("muse_") + 5;
+ int finpos = item.lastIndexOf(".qm");
+ deliveredLocaleListFiltered << item.mid(inipos, finpos - inipos);
+ }
+ }
+ return deliveredLocaleListFiltered.join(",");
+ }
+ return QString("No translations found!");
+ }
+
+//---------------------------------------------------------
+// usage
+//---------------------------------------------------------
+
+static void usage(const char* prog, const char* txt)
+ {
+ fprintf(stderr, "%s: %s\nusage: %s flags midifile\n Flags:\n",
+ prog, txt, prog);
+ fprintf(stderr, " -h this help\n");
+ fprintf(stderr, " -v print version\n");
+ fprintf(stderr, " -d debug mode: no threads, no RT\n");
+ fprintf(stderr, " -D debug mode: enable some debug messages\n");
+ fprintf(stderr, " -m debug mode: trace midi Input\n");
+ fprintf(stderr, " -M debug mode: trace midi Output\n");
+ fprintf(stderr, " -s debug mode: trace sync\n");
+ fprintf(stderr, " -a no audio\n");
+ //fprintf(stderr, " -P n set real time priority to n (default: 50)\n");
+ fprintf(stderr, " -P n set audio driver real time priority to n (Dummy only, default 40. Else fixed by Jack.)\n");
+ fprintf(stderr, " -Y n force midi real time priority to n (default: audio driver prio +2)\n");
+ fprintf(stderr, " -p don't load LADSPA plugins\n");
+#ifdef ENABLE_PYTHON
+ fprintf(stderr, " -y enable Python control support\n");
+#endif
+#ifdef VST_SUPPORT
+ fprintf(stderr, " -V don't load VST plugins\n");
+#endif
+#ifdef DSSI_SUPPORT
+ fprintf(stderr, " -I don't load DSSI plugins\n");
+#endif
+#ifdef HAVE_LASH
+ fprintf(stderr, " -L don't use LASH\n");
+#endif
+ fprintf(stderr, " -l xx force locale to the given language/country code (xx = %s)\n", localeList().toLatin1().constData());
+ }
+
+//---------------------------------------------------------
+// main
+//---------------------------------------------------------
+
+int main(int argc, char* argv[])
+ {
+
+// error = ErrorHandler::create(argv[0]);
+ ruid = getuid();
+ euid = geteuid();
+ undoSetuid();
+ getCapabilities();
+ int noAudio = false;
+
+ museUser = QString(getenv("HOME"));
+ museGlobalLib = QString(LIBDIR);
+ museGlobalShare = QString(SHAREDIR);
+ museProject = museProjectInitPath; //getcwd(0, 0);
+ museInstruments = museGlobalShare + QString("/instruments");
+
+ // Create config dir if it doesn't exists
+ QDir cPath = QDir(configPath);
+ if (! cPath.exists())
+ cPath.mkpath(".");
+
+#ifdef HAVE_LASH
+ lash_args_t * lash_args = 0;
+ if(useLASH)
+ lash_args = lash_extract_args (&argc, &argv);
+#endif
+
+ srand(time(0)); // initialize random number generator
+// signal(SIGCHLD, catchSignal); // interferes with initVST()
+ initMidiController();
+ QApplication::setColorSpec(QApplication::ManyColor);
+ MuseApplication app(argc, argv);
+
+ initShortCuts();
+ readConfiguration();
+
+ museUserInstruments = config.userInstrumentsDir;
+
+ if (config.useDenormalBias)
+ printf("Denormal protection enabled.\n");
+ // SHOW MUSE SPLASH SCREEN
+ if (config.showSplashScreen) {
+ QPixmap splsh(museGlobalShare + "/splash.png");
+
+ if (!splsh.isNull()) {
+ QSplashScreen* muse_splash = new QSplashScreen(splsh,
+ Qt::WindowStaysOnTopHint);
+ muse_splash->setAttribute(Qt::WA_DeleteOnClose); // Possibly also Qt::X11BypassWindowManagerHint
+ muse_splash->show();
+ QTimer* stimer = new QTimer(0);
+ muse_splash->connect(stimer, SIGNAL(timeout()), muse_splash, SLOT(close()));
+ stimer->setSingleShot(true);
+ stimer->start(6000);
+ }
+ }
+
+ int i;
+
+ QString optstr("ahvdDmMsP:Y:l:py");
+#ifdef VST_SUPPORT
+ optstr += QString("V");
+#endif
+#ifdef DSSI_SUPPORT
+ optstr += QString("I");
+#endif
+#ifdef HAVE_LASH
+ optstr += QString("L");
+#endif
+
+//#ifdef VST_SUPPORT
+// while ((i = getopt(argc, argv, "ahvdDmMsVP:py")) != EOF) {
+//#else
+// while ((i = getopt(argc, argv, "ahvdDmMsP:py")) != EOF) {
+//#endif
+
+ while ((i = getopt(argc, argv, optstr.toLatin1().constData())) != EOF) {
+ char c = (char)i;
+ switch (c) {
+ case 'v': printVersion(argv[0]); return 0;
+ case 'd':
+ debugMode = true;
+ realTimeScheduling = false;
+ break;
+ case 'a':
+ noAudio = true;
+ break;
+ case 'D': debugMsg = true; break;
+ case 'm': midiInputTrace = true; break;
+ case 'M': midiOutputTrace = true; break;
+ case 's': debugSync = true; break;
+ case 'P': realTimePriority = atoi(optarg); break;
+ case 'Y': midiRTPrioOverride = atoi(optarg); break;
+ case 'p': loadPlugins = false; break;
+ case 'V': loadVST = false; break;
+ case 'I': loadDSSI = false; break;
+ case 'L': useLASH = false; break;
+ case 'y': usePythonBridge = true; break;
+ case 'l': locale_override = QString(optarg); break;
+ case 'h': usage(argv[0], argv[1]); return -1;
+ default: usage(argv[0], "bad argument"); return -1;
+ }
+ }
+
+ /*
+ if(!config.styleSheetFile.isEmpty())
+ {
+ if(debugMsg)
+ printf("loading style sheet <%s> \n", qPrintable(config.styleSheetFile));
+ QFile cf(config.styleSheetFile);
+ if (cf.open(QIODevice::ReadOnly)) {
+ QByteArray ss = cf.readAll();
+ QString sheet(QString::fromUtf8(ss.data()));
+ app.setStyleSheet(sheet);
+ cf.close();
+ }
+ else
+ printf("loading style sheet <%s> failed\n", qPrintable(config.styleSheetFile));
+ }
+ */
+
+ AL::initDsp();
+
+ if (debugMsg)
+ printf("Start euid: %d ruid: %d, Now euid %d\n",
+ euid, ruid, geteuid());
+ if (debugMode) {
+ initDummyAudio();
+ realTimeScheduling = false;
+ }
+ else if (noAudio) {
+ initDummyAudio();
+ realTimeScheduling = true;
+ //if (debugMode) { // ??
+ // realTimeScheduling = false;
+ // }
+ }
+ else if (initJackAudio()) {
+ if (!debugMode)
+ {
+ QMessageBox::critical(NULL, "MusE fatal error", "MusE <b>failed</b> to find a <b>Jack audio server</b>.<br><br>"
+ "<i>MusE will continue without audio support (-a switch)!</i><br><br>"
+ "If this was not intended check that Jack was started. "
+ "If Jack <i>was</i> started check that it was\n"
+ "started as the same user as MusE.\n");
+
+ initDummyAudio();
+ noAudio = true;
+ realTimeScheduling = true;
+ if (debugMode) {
+ realTimeScheduling = false;
+ }
+ }
+ else
+ {
+ fprintf(stderr, "fatal error: no JACK audio server found\n");
+ fprintf(stderr, "no audio functions available\n");
+ fprintf(stderr, "*** experimental mode -- no play possible ***\n");
+ initDummyAudio();
+ //realTimeScheduling = audioDevice->isRealtime();
+ }
+ realTimeScheduling = true;
+ }
+ else
+ realTimeScheduling = audioDevice->isRealtime();
+
+ useJackTransport.setValue(true);
+ // setup the prefetch fifo length now that the segmentSize is known
+ // Changed by Tim. p3.3.17
+ // Changed to 4 *, JUST FOR TEST!!!
+ fifoLength = 131072/segmentSize;
+ //fifoLength = (131072/segmentSize) * 4;
+
+
+ argc -= optind;
+ ++argc;
+
+ if (debugMsg) {
+ printf("global lib: <%s>\n", museGlobalLib.toLatin1().constData());
+ printf("global share: <%s>\n", museGlobalShare.toLatin1().constData());
+ printf("muse home: <%s>\n", museUser.toLatin1().constData());
+ printf("project dir: <%s>\n", museProject.toLatin1().constData());
+ printf("user instruments: <%s>\n", museUserInstruments.toLatin1().constData());
+ }
+
+ static QTranslator translator(0);
+ QString locale(QApplication::keyboardInputLocale().name());
+ if (locale_override.length())
+ locale = locale_override;
+ if (locale != "C") {
+ QString loc("muse_");
+ loc += locale;
+ if (translator.load(loc, QString(".")) == false) {
+ QString lp(museGlobalShare);
+ lp += QString("/locale");
+ if (translator.load(loc, lp) == false) {
+ printf("no locale <%s>/<%s>\n", loc.toLatin1().constData(), lp.toLatin1().constData());
+ }
+ }
+ app.installTranslator(&translator);
+ }
+
+ if (locale == "de") {
+ printf("locale de\n");
+ hIsB = false;
+ }
+
+ if (loadPlugins)
+ initPlugins();
+
+ if (loadVST)
+ initVST();
+
+ if(loadDSSI)
+ initDSSI();
+
+ // p3.3.39
+ initOSC();
+
+ initIcons();
+
+ initMetronome();
+
+ //QApplication::clipboard()->setSelectionMode(false); ddskrjo obsolete even in Qt3
+
+ QApplication::addLibraryPath(museGlobalLib + "/qtplugins");
+ if (debugMsg) {
+ QStringList list = app.libraryPaths();
+ QStringList::Iterator it = list.begin();
+ printf("QtLibraryPath:\n");
+ while(it != list.end()) {
+ printf(" <%s>\n", (*it).toLatin1().constData());
+ ++it;
+ }
+ }
+
+ muse = new MusE(argc, &argv[optind]);
+ app.setMuse(muse);
+ muse->setWindowIcon(*museIcon);
+
+ // Added by Tim. p3.3.22
+ if (!debugMode) {
+ if (mlockall(MCL_CURRENT | MCL_FUTURE))
+ perror("WARNING: Cannot lock memory:");
+ }
+
+ muse->show();
+ muse->seqStart();
+
+#ifdef HAVE_LASH
+ {
+ lash_client = 0;
+ if(useLASH)
+ {
+ int lash_flags = LASH_Config_File;
+ const char *muse_name = PACKAGE_NAME;
+ lash_client = lash_init (lash_args, muse_name, lash_flags, LASH_PROTOCOL(2,0));
+ lash_alsa_client_id (lash_client, snd_seq_client_id (alsaSeq));
+ if (!noAudio) {
+ // p3.3.38
+ //char *jack_name = ((JackAudioDevice*)audioDevice)->getJackName();
+ const char *jack_name = audioDevice->clientName();
+ lash_jack_client_name (lash_client, jack_name);
+ }
+ }
+ }
+#endif /* HAVE_LASH */
+ QTimer::singleShot(100, muse, SLOT(showDidYouKnowDialog()));
+
+ int rv = app.exec();
+ if(debugMsg)
+ printf("app.exec() returned:%d\nDeleting main MusE object\n", rv);
+ delete muse;
+ if(debugMsg)
+ printf("Finished! Exiting main, return value:%d\n", rv);
+ return rv;
+
+ }
diff --git a/attic/muse2-oom/muse2/muse/marker/CMakeLists.txt b/attic/muse2-oom/muse2/muse/marker/CMakeLists.txt
new file mode 100644
index 00000000..7ed5a40a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/marker/CMakeLists.txt
@@ -0,0 +1,76 @@
+#=============================================================================
+# MusE
+# Linux Music Editor
+# $Id:$
+#
+# Copyright (C) 2002-2006 by Werner Schweer and others
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#=============================================================================
+
+##
+## Expand Qt macros in source files
+##
+QT4_WRAP_CPP ( marker_mocs
+ markerview.h
+ )
+
+##
+## List of source files to compile
+##
+file (GLOB marker_source_files
+ marker.cpp
+ markerview.cpp
+ )
+
+##
+## Define target
+##
+add_library ( marker SHARED
+ ${marker_source_files}
+ # ${marker_ui_headers}
+ ${marker_mocs}
+ )
+
+##
+## Append to the list of translations
+##
+set (FILES_TO_TRANSLATE
+ ${FILES_TO_TRANSLATE}
+ ${marker_source_files}
+ CACHE INTERNAL ""
+ )
+
+##
+## Compilation flags and target name
+##
+set_target_properties( marker
+ PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h -fPIC"
+ OUTPUT_NAME muse_marker
+ )
+
+##
+## Linkage
+##
+target_link_libraries ( marker
+ ${QT_LIBRARIES}
+ awl
+ icons
+ )
+
+##
+## Install location
+##
+install(TARGETS marker
+ DESTINATION ${MusE_MODULES_DIR}
+ )
diff --git a/attic/muse2-oom/muse2/muse/marker/marker.cpp b/attic/muse2-oom/muse2/muse/marker/marker.cpp
new file mode 100644
index 00000000..e34e03dd
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/marker/marker.cpp
@@ -0,0 +1,90 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: marker.cpp,v 1.2 2003/12/10 18:34:22 wschweer Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "marker.h"
+#include "xml.h"
+
+Marker* MarkerList::add(const Marker& marker)
+ {
+ iMarker i = insert(std::pair<const int, Marker> (marker.tick(), Marker(marker)));
+ return &i->second;
+ }
+
+Marker* MarkerList::add(const QString& s, int t, bool lck)
+ {
+ Marker marker(s);
+ marker.setType(lck ? Pos::FRAMES : Pos::TICKS);
+ marker.setTick(t);
+ iMarker i = insert(std::pair<const int, Marker> (t, marker));
+ return &i->second;
+ }
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+void Marker::read(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ xml.unknown("Marker");
+ break;
+ case Xml::Attribut:
+ if (tag == "tick")
+ setTick(xml.s2().toInt());
+ else if (tag == "lock")
+ setType(xml.s2().toInt() ? FRAMES:TICKS);
+ else if (tag == "name")
+ {
+ _name = xml.s2();
+ }
+ break;
+ case Xml::TagEnd:
+ if (xml.s1() == "marker")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+void MarkerList::write(int level, Xml& xml) const
+ {
+ for (ciMarker i = begin(); i != end(); ++i) {
+ const Marker& m = i->second;
+ xml.put(level, "<marker tick=\"%d\" lock=\"%d\" name=\"%s\" />",
+ //m.tick(), m.type()==Pos::FRAMES, m.name().toLatin1().constData());
+ m.tick(), m.type()==Pos::FRAMES, Xml::xmlString(m.name()).toLatin1().constData());
+ }
+ }
+
+//---------------------------------------------------------
+// remove
+//---------------------------------------------------------
+
+void MarkerList::remove(Marker* m)
+ {
+ for (iMarker i = begin(); i != end(); ++i) {
+ Marker* mm = &i->second;
+ if (mm == m) {
+ erase(i);
+ return;
+ }
+ }
+ printf("MarkerList::remove(): marker not found\n");
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/marker/marker.h b/attic/muse2-oom/muse2/muse/marker/marker.h
new file mode 100644
index 00000000..f1a587f7
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/marker/marker.h
@@ -0,0 +1,53 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: marker.h,v 1.2 2003/12/15 11:41:00 wschweer Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MARKER_H__
+#define __MARKER_H__
+
+#include <map>
+
+#include "xml.h"
+#include "pos.h"
+
+class QString;
+
+//---------------------------------------------------------
+// Marker
+//---------------------------------------------------------
+
+class Marker : public Pos {
+ QString _name;
+ bool _current;
+
+ public:
+ Marker() : _current(false) {}
+ Marker(const QString& s, bool cur = false)
+ : _name(s), _current(cur) {}
+ void read(Xml&);
+ const QString name() const { return _name; }
+ void setName(const QString& s) { _name = s; }
+ bool current() const { return _current; }
+ void setCurrent(bool f) { _current = f; }
+ };
+
+//---------------------------------------------------------
+// MarkerList
+//---------------------------------------------------------
+
+class MarkerList : public std::multimap<unsigned, Marker, std::less<unsigned> > {
+ public:
+ Marker* add(const Marker& m);
+ Marker* add(const QString& s, int t, bool lck);
+ void write(int, Xml&) const;
+ void remove(Marker*);
+ };
+
+typedef std::multimap<unsigned, Marker, std::less<unsigned> >::iterator iMarker;
+typedef std::multimap<unsigned, Marker, std::less<unsigned> >::const_iterator ciMarker;
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/marker/markerview.cpp b/attic/muse2-oom/muse2/muse/marker/markerview.cpp
new file mode 100644
index 00000000..d22807b6
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/marker/markerview.cpp
@@ -0,0 +1,614 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: markerview.cpp,v 1.7.2.6 2009/08/25 20:28:45 spamatica Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "al/sig.h" // Tim.
+
+#include "marker.h"
+#include "markerview.h"
+#include "xml.h"
+#include "globals.h"
+#include "sync.h"
+#include "icons.h"
+#include "song.h"
+///#include "posedit.h"
+#include "awl/posedit.h"
+
+#include <QCloseEvent>
+#include <QGroupBox>
+#include <QHeaderView>
+#include <QLineEdit>
+#include <QMenu>
+#include <QMenuBar>
+#include <QHBoxLayout>
+#include <QToolBar>
+#include <QToolButton>
+#include <QVBoxLayout>
+
+
+enum { COL_TICK = 0, COL_SMPTE, COL_LOCK, COL_NAME };
+
+//---------------------------------------------------------
+// tick
+//---------------------------------------------------------
+
+unsigned MarkerItem::tick() const
+ {
+ return _marker->tick();
+ }
+
+//---------------------------------------------------------
+// name
+//---------------------------------------------------------
+
+const QString MarkerItem::name() const
+ {
+ return _marker->name();
+ }
+
+//---------------------------------------------------------
+// lock
+//---------------------------------------------------------
+
+bool MarkerItem::lock() const
+ {
+ return _marker->type() == Pos::FRAMES;
+ }
+
+//---------------------------------------------------------
+// MarkerItem
+//---------------------------------------------------------
+
+MarkerItem::MarkerItem(QTreeWidget* parent, Marker* m)
+ : QTreeWidgetItem(parent)
+ {
+ _marker = m;
+ setText(COL_NAME, m->name());
+ setTick(m->tick());
+ if (m->type() == Pos::FRAMES)
+ setIcon(COL_LOCK, QIcon(*lockIcon));
+ setLock(m->type() == Pos::FRAMES);
+ }
+
+//---------------------------------------------------------
+// setName
+//---------------------------------------------------------
+
+void MarkerItem::setName(const QString& s)
+ {
+ setText(COL_NAME, s);
+ _marker = song->setMarkerName(_marker, s);
+ }
+
+//---------------------------------------------------------
+// setLock
+//---------------------------------------------------------
+
+void MarkerItem::setLock(bool lck)
+ {
+ setIcon(COL_LOCK, QIcon(lck ? *lockIcon : 0));
+ _marker = song->setMarkerLock(_marker, lck);
+ }
+
+//---------------------------------------------------------
+// setTick
+//---------------------------------------------------------
+
+void MarkerItem::setTick(unsigned v)
+ {
+ if (_marker->tick() != v)
+ _marker = song->setMarkerTick(_marker, v);
+ QString s;
+ int bar, beat;
+ unsigned tick;
+ ///sigmap.tickValues(v, &bar, &beat, &tick);
+ AL::sigmap.tickValues(v, &bar, &beat, &tick);
+ s.sprintf("%04d.%02d.%03d", bar+1, beat+1, tick);
+ setText(COL_TICK, s);
+
+ double time = double(tempomap.tick2frame(v))/double(sampleRate);
+ int hour = int(time) / 3600;
+ int min = (int(time) % 3600)/60;
+ int sec = int(time) % 60;
+ double rest = time - (hour*3600 + min * 60 + sec);
+ switch(mtcType) {
+ case 0: // 24 frames sec
+ rest *= 24;
+ break;
+ case 1: // 25
+ rest *= 25;
+ break;
+ case 2: // 30 drop frame
+ rest *= 30;
+ break;
+ case 3: // 30 non drop frame
+ rest *= 30;
+ break;
+ }
+ int frame = int(rest);
+ int subframe = int((rest-frame)*100);
+ s.sprintf("%02d:%02d:%02d:%02d:%02d",
+ hour, min, sec, frame, subframe);
+ setText(COL_SMPTE, s);
+ }
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void MarkerView::closeEvent(QCloseEvent* e)
+ {
+ emit deleted((unsigned long)this);
+ emit closed();
+ e->accept();
+ }
+
+//---------------------------------------------------------
+// MarkerView
+//---------------------------------------------------------
+
+MarkerView::MarkerView(QWidget* parent)
+ : TopWin(parent, "markerview", Qt::Window /*| WDestructiveClose*/)
+ {
+ //setAttribute(Qt::WA_DeleteOnClose);
+
+ setWindowTitle(tr("MusE: Marker"));
+
+ QAction* markerAdd = new QAction(QIcon(*flagIcon), tr("add marker"), this);
+ connect(markerAdd, SIGNAL(activated()), SLOT(addMarker()));
+
+ QAction* markerDelete = new QAction(QIcon(*deleteIcon), tr("delete marker"), this);
+ connect(markerDelete, SIGNAL(activated()), SLOT(deleteMarker()));
+
+ //---------Pulldown Menu----------------------------
+ /* We probably don't need an empty menu - Orcan
+ QMenu* fileMenu = new QMenu(tr("&File"));
+ menuBar()->addMenu(fileMenu);
+ */
+ QMenu* editMenu = menuBar()->addMenu(tr("&Edit"));
+
+ editMenu->addAction(markerAdd);
+ editMenu->addAction(markerDelete);
+
+ //---------ToolBar----------------------------------
+ tools = addToolBar(tr("marker-tools"));
+ tools->addActions(undoRedo->actions());
+
+ QToolBar* edit = addToolBar(tr("edit tools"));
+ edit->addAction(markerAdd);
+ edit->addAction(markerDelete);
+
+ //---------------------------------------------------
+ // master
+ //---------------------------------------------------
+
+ QWidget* w = new QWidget;
+ setCentralWidget(w);
+ QVBoxLayout* vbox = new QVBoxLayout(w);
+
+ table = new QTreeWidget(w);
+ table->setAllColumnsShowFocus(true);
+ table->setSelectionMode(QAbstractItemView::SingleSelection);
+
+ QStringList columnnames;
+ columnnames << tr("Bar:Beat:Tick")
+ << tr("Hr:Mn:Sc:Fr:Sf")
+ << tr("Lock")
+ << tr("Text");
+
+ table->setHeaderLabels(columnnames);
+ table->setColumnWidth(2, 40);
+ table->header()->setStretchLastSection(true);
+
+ connect(table, SIGNAL(itemSelectionChanged()),
+ SLOT(markerSelectionChanged()));
+ connect(table, SIGNAL(itemClicked(QTreeWidgetItem*, int)),
+ SLOT(clicked(QTreeWidgetItem*)));
+
+ QGroupBox* props = new QGroupBox(tr("Marker Properties"));
+ QHBoxLayout *hbox = new QHBoxLayout;
+
+ ///editTick = new PosEdit;
+ editTick = new Awl::PosEdit;
+ editTick->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
+ QSizePolicy::Fixed));
+
+ ///editSMPTE = new PosEdit;
+ editSMPTE = new Awl::PosEdit;
+ editSMPTE->setSmpte(true);
+ editSMPTE->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
+ QSizePolicy::Fixed));
+
+ lock = new QToolButton;
+ lock->setIcon(*lockIcon);
+ lock->setCheckable(true);
+
+ editName = new QLineEdit;
+ editName->setSizePolicy(QSizePolicy(QSizePolicy::Expanding,
+ QSizePolicy::Preferred));
+
+ hbox->addWidget(editTick);
+ hbox->addWidget(editSMPTE);
+ hbox->addWidget(lock);
+ hbox->addWidget(editName);
+ props->setLayout(hbox);
+
+ connect(editName, SIGNAL(textChanged(const QString&)),
+ SLOT(nameChanged(const QString&)));
+ connect(editTick, SIGNAL(valueChanged(const Pos&)),
+ SLOT(tickChanged(const Pos&)));
+ connect(editSMPTE, SIGNAL(valueChanged(const Pos&)),
+ SLOT(tickChanged(const Pos&)));
+ connect(editSMPTE, SIGNAL(valueChanged(const Pos&)),
+ editTick, SLOT(setValue(const Pos&)));
+ connect(editTick, SIGNAL(valueChanged(const Pos&)),
+ editSMPTE, SLOT(setValue(const Pos&)));
+ connect(lock, SIGNAL(toggled(bool)),
+ SLOT(lockChanged(bool)));
+ connect(song, SIGNAL(markerChanged(int)),
+ SLOT(markerChanged(int)));
+
+ vbox->addWidget(table);
+ vbox->addWidget(props);
+
+ //---------------------------------------------------
+ // Rest
+ //---------------------------------------------------
+
+ //connect(song, SIGNAL(songChanged(int)), SLOT(updateList()));
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+
+ updateList();
+
+ // work around for probable QT/WM interaction bug.
+ // for certain window managers, e.g xfce, this window is
+ // is displayed although not specifically set to show();
+ // bug: 2811156 Softsynth GUI unclosable with XFCE4 (and a few others)
+ show();
+ hide();
+
+ }
+
+//---------------------------------------------------------
+// MArkerView
+//---------------------------------------------------------
+
+MarkerView::~MarkerView()
+ {
+ //printf("MarkerView::~MarkerView() before undoRedo->removeFrom(tools)\n");
+
+ // undoRedo->removeFrom(tools); // p4.0.6 Removed
+ }
+
+//---------------------------------------------------------
+// readStatus
+//---------------------------------------------------------
+
+void MarkerView::readStatus(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ if (token == Xml::Error || token == Xml::End)
+ break;
+ switch (token) {
+ case Xml::TagStart:
+ xml.unknown("Marker");
+ break;
+ case Xml::TagEnd:
+ if (tag == "marker")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// writeStatus
+//---------------------------------------------------------
+
+void MarkerView::writeStatus(int level, Xml& xml) const
+ {
+ xml.tag(level++, "marker");
+ xml.tag(level, "/marker");
+ }
+
+//---------------------------------------------------------
+// addMarker
+//---------------------------------------------------------
+void MarkerView::addMarker()
+ {
+ addMarker(-1);
+ }
+void MarkerView::addMarker(int i)
+ {
+ if( i==-1 ) i = song->cpos();
+
+ // Changed p3.3.43 Let Song::addMarker emit markerChanged(MARKER_ADD)
+ // and handle it in MarkerView::markerChanged(int)
+ //Marker* m = song->addMarker(QString(""), i, false);
+ //MarkerItem* newItem = new MarkerItem(table, m);
+ //table->setSelected(newItem, true);
+ //
+ song->addMarker(QString(""), i, false);
+ }
+
+//---------------------------------------------------------
+// deleteMarker
+//---------------------------------------------------------
+
+void MarkerView::deleteMarker()
+ {
+ MarkerItem* item = (MarkerItem*)table->currentItem();
+ if (item) {
+ table->blockSignals(true);
+ song->removeMarker(item->marker());
+ table->blockSignals(false);
+ // Removed p3.3.43 Let Song::removeMarker emit markerChanged(MARKER_REMOVE)
+ // and handle it in MarkerView::markerChanged(int)
+ //delete item;
+ }
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void MarkerView::songChanged(int flags)
+{
+ // Is it simply a midi controller value adjustment? Forget it.
+ if(flags == SC_MIDI_CONTROLLER)
+ return;
+
+ updateList();
+}
+
+//---------------------------------------------------------
+// updateList
+//---------------------------------------------------------
+
+void MarkerView::updateList()
+{
+ // Added p3.3.43 Manage selected item, due to clearing of table...
+ MarkerList* marker = song->marker();
+ MarkerItem* selitem = (MarkerItem*)table->currentItem();
+ Marker* selm = selitem ? selitem->marker() : 0;
+ // p3.3.44 Look for removed markers before added markers...
+ if(selitem)
+ {
+ MarkerItem* mitem = (MarkerItem*)table->topLevelItem(0);
+ while(mitem)
+ {
+ bool found = false;
+ for(iMarker i = marker->begin(); i != marker->end(); ++i)
+ {
+ Marker* m = &i->second;
+ if(m == mitem->marker())
+ {
+ found = true;
+ break;
+ }
+ }
+ // Anything removed from the marker list?
+ if(!found)
+ {
+ // If it is the current selected item, it no longer exists. Make the next item be selected.
+ if(mitem == selitem)
+ {
+ MarkerItem* mi = (MarkerItem*)table->itemBelow(selitem);
+ if(mi)
+ {
+ selitem = mi;
+ selm = selitem->marker();
+ }
+ }
+ }
+ mitem = (MarkerItem*)table->itemBelow(mitem);
+ }
+ }
+ // Look for added markers...
+ for(iMarker i = marker->begin(); i != marker->end(); ++i)
+ {
+ Marker* m = &i->second;
+ bool found = false;
+ MarkerItem* item = (MarkerItem*)table->topLevelItem(0);
+ while(item)
+ {
+ if(item->marker() == m)
+ {
+ found = true;
+ break;
+ }
+ item = (MarkerItem*)table->itemBelow(item);
+ }
+ // Anything new found in the marker list?
+ if(!found)
+ selm = m;
+ }
+
+ // Block signals added. Triggers itemSelectionChanged() causing crash. Tim.
+ table->blockSignals(true);
+ table->clear();
+ table->blockSignals(false);
+
+ //MarkerList* marker = song->marker();
+ for (iMarker i = marker->begin(); i != marker->end(); ++i)
+ {
+ Marker* m = &i->second;
+
+ // Changed p3.3.43
+ //QString tick;
+ //tick.setNum(i->first);
+ //new MarkerItem(table, m);
+ MarkerItem* item = new MarkerItem(table, m);
+ if(m == selm)
+ {
+ m->setCurrent(true);
+ table->setCurrentItem(item);
+ }
+ else
+ {
+ m->setCurrent(false);
+ }
+ }
+}
+
+//---------------------------------------------------------
+// markerSelected
+//---------------------------------------------------------
+
+void MarkerView::markerSelectionChanged()
+ {
+ MarkerItem* item = (MarkerItem*)table->currentItem();
+ if (item == 0) { // never triggered
+ editTick->setValue(0);
+ editSMPTE->setValue(0);
+ editName->setText(QString(""));
+ lock->setChecked(false);
+ editSMPTE->setEnabled(false);
+ editTick->setEnabled(false);
+ lock->setEnabled(false);
+ editName->setEnabled(false);
+ }
+ else {
+ editTick->setValue(item->tick());
+ editSMPTE->setValue(item->tick());
+ editName->setText(item->name());
+ editName->setEnabled(true);
+ lock->setChecked(item->lock());
+ lock->setEnabled(true);
+
+ //printf("MarkerView::markerSelectionChanged item->lock:%d\n", item->lock());
+
+ editSMPTE->setEnabled(item->lock());
+ editTick->setEnabled(!item->lock());
+ }
+ }
+
+void MarkerView::clicked(QTreeWidgetItem* i)
+ {
+ MarkerItem* item = (MarkerItem*)i;
+ if (item == 0) {
+ table->clearSelection();
+ return;
+ }
+ Pos p(item->tick(), true);
+ song->setPos(0, p, true, true, false);
+ }
+
+//---------------------------------------------------------
+// nameChanged
+//---------------------------------------------------------
+
+void MarkerView::nameChanged(const QString& s)
+ {
+ MarkerItem* item = (MarkerItem*)table->currentItem();
+ if (item)
+ item->setName(s);
+ }
+
+//---------------------------------------------------------
+// tickChanged
+//---------------------------------------------------------
+
+void MarkerView::tickChanged(const Pos& pos)
+ {
+ MarkerItem* item = (MarkerItem*)table->currentItem();
+ if (item) {
+ item->setTick(pos.tick());
+ Pos p(pos.tick(), true);
+ song->setPos(0, p, true, true, false);
+ table->sortByColumn(COL_TICK, Qt::AscendingOrder);
+ }
+ }
+
+//---------------------------------------------------------
+// lockChanged
+//---------------------------------------------------------
+
+void MarkerView::lockChanged(bool lck)
+ {
+ MarkerItem* item = (MarkerItem*)table->currentItem();
+ if (item) {
+ item->setLock(lck);
+ editSMPTE->setEnabled(item->lock());
+ editTick->setEnabled(!item->lock());
+ }
+ }
+
+//---------------------------------------------------------
+// posChanged
+// select appropriate Marker
+//---------------------------------------------------------
+
+void MarkerView::markerChanged(int val)
+{
+ //if (val != Song::MARKER_CUR)
+ // return;
+ // p3.3.43
+ switch(val)
+ {
+ // MARKER_CUR, MARKER_ADD, MARKER_REMOVE, MARKER_NAME,
+ // MARKER_TICK, MARKER_LOCK
+ case Song::MARKER_ADD:
+ case Song::MARKER_REMOVE:
+ updateList();
+ break; // Try falling through and let it try to select something. No, let updateList() do it...
+
+ case Song::MARKER_CUR:
+ {
+
+ MarkerList* marker = song->marker();
+ for (iMarker i = marker->begin(); i != marker->end(); ++i) {
+ if (i->second.current()) {
+ MarkerItem* item = (MarkerItem*)table->topLevelItem(0);
+ while (item) {
+ if (item->marker() == &i->second) {
+ table->setCurrentItem(item);
+ return;
+ }
+ item = (MarkerItem*)table->itemBelow(item);
+ }
+ }
+ }
+ }
+ break;
+
+ default:
+ break;
+ }
+}
+
+void MarkerView::nextMarker()
+ {
+ unsigned int curPos = song->cpos();//prevent compiler warning: comparison of sigend/unsigned
+ unsigned int nextPos = 0xFFFFFFFF;
+ MarkerList* marker = song->marker();
+ for (iMarker i = marker->begin(); i != marker->end(); ++i) {
+ if (i->second.tick() > curPos && i->second.tick() < nextPos)
+ nextPos = i->second.tick();
+ }
+ if (nextPos == 0xFFFFFFFF)
+ return;
+ Pos p(nextPos, true);
+ song->setPos(0, p, true, true, false);
+
+ }
+void MarkerView::prevMarker()
+ {
+ unsigned int curPos = song->cpos();//prevent compiler warning: comparison of sigend/unsigned
+ unsigned int nextPos = 0;
+ MarkerList* marker = song->marker();
+ for (iMarker i = marker->begin(); i != marker->end(); ++i) {
+ if (i->second.tick() < curPos && i->second.tick() > nextPos)
+ nextPos = i->second.tick();
+ }
+/* if (nextPos == 0)
+ return;*/
+ Pos p(nextPos, true);
+ song->setPos(0, p, true, true, false);
+ }
diff --git a/attic/muse2-oom/muse2/muse/marker/markerview.h b/attic/muse2-oom/muse2/muse/marker/markerview.h
new file mode 100644
index 00000000..a271873c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/marker/markerview.h
@@ -0,0 +1,91 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: markerview.h,v 1.4.2.3 2008/08/18 00:15:25 terminator356 Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MARKERVIEW_H__
+#define __MARKERVIEW_H__
+
+#include "cobject.h"
+
+#include <QTreeWidgetItem>
+
+class QCloseEvent;
+class QLineEdit;
+class QToolBar;
+class QToolButton;
+class QTreeWidget;
+
+namespace Awl {
+ class PosEdit;
+ };
+
+class Marker;
+///class PosEdit;
+class Pos;
+
+//---------------------------------------------------------
+// MarkerItem
+//---------------------------------------------------------
+
+class MarkerItem : public QTreeWidgetItem {
+ Marker* _marker;
+
+ public:
+ MarkerItem(QTreeWidget* parent, Marker* m);
+ Marker* marker() const { return _marker; }
+ unsigned tick() const;
+ const QString name() const;
+ bool lock() const;
+ void setName(const QString& s);
+ void setTick(unsigned t);
+ void setLock(bool lck);
+ };
+
+//---------------------------------------------------------
+// MarkerView
+//---------------------------------------------------------
+
+class MarkerView : public TopWin {
+ QTreeWidget* table;
+ QLineEdit* editName;
+ ///PosEdit* editSMPTE;
+ ///PosEdit* editTick;
+ Awl::PosEdit* editSMPTE;
+ Awl::PosEdit* editTick;
+ QToolButton* lock;
+ QToolBar* tools;
+
+ Q_OBJECT
+ virtual void closeEvent(QCloseEvent*);
+
+ private slots:
+ void addMarker();
+ void addMarker(int);
+ void deleteMarker();
+ void markerSelectionChanged();
+ void nameChanged(const QString&);
+ void tickChanged(const Pos&);
+ void lockChanged(bool);
+ void markerChanged(int);
+ void clicked(QTreeWidgetItem*);
+ void updateList();
+ void songChanged(int);
+
+ signals:
+ void deleted(unsigned long);
+ void closed();
+
+ public:
+ MarkerView(QWidget* parent);
+ ~MarkerView();
+ virtual void readStatus(Xml&);
+ virtual void writeStatus(int, Xml&) const;
+ void nextMarker();
+ void prevMarker();
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/master/CMakeLists.txt b/attic/muse2-oom/muse2/muse/master/CMakeLists.txt
new file mode 100644
index 00000000..bf2cebb7
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/master/CMakeLists.txt
@@ -0,0 +1,81 @@
+#=============================================================================
+# MusE
+# Linux Music Editor
+# $Id:$
+#
+# Copyright (C) 2002-2006 by Werner Schweer and others
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#=============================================================================
+
+##
+## Expand Qt macros in source files
+##
+QT4_WRAP_CPP ( master_mocs
+ lmaster.h
+ masteredit.h
+ master.h
+ tscale.h
+ )
+
+##
+## List of source files to compile
+##
+file (GLOB master_source_files
+ lmaster.cpp
+ masteredit.cpp
+ master.cpp
+ tscale.cpp
+ )
+
+##
+## Define target
+##
+add_library ( master SHARED
+ ${master_source_files}
+ ${master_mocs}
+ )
+
+##
+## Append to the list of translations
+##
+set (FILES_TO_TRANSLATE
+ ${FILES_TO_TRANSLATE}
+ ${master_source_files}
+ CACHE INTERNAL ""
+ )
+
+##
+## Compilation flags and target name
+##
+set_target_properties( master
+ PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h -fPIC"
+ OUTPUT_NAME muse_master
+ )
+
+##
+## Linkage
+##
+target_link_libraries ( master
+ ${QT_LIBRARIES}
+ al
+ awl
+ widgets
+ )
+
+##
+## Install location
+##
+install(TARGETS master
+ DESTINATION ${MusE_MODULES_DIR}
+ )
diff --git a/attic/muse2-oom/muse2/muse/master/lmaster.cpp b/attic/muse2-oom/muse2/muse/master/lmaster.cpp
new file mode 100644
index 00000000..00a09d13
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/master/lmaster.cpp
@@ -0,0 +1,750 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: lmaster.cpp,v 1.2.2.8 2009/03/09 02:05:18 terminator356 Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "awl/posedit.h"
+#include "awl/sigedit.h"
+
+#include "lmaster.h"
+#include "xml.h"
+#include "song.h"
+#include "globals.h"
+#include "audio.h"
+///#include "posedit.h"
+///#include "sigedit.h"
+#include "shortcuts.h"
+#include "debug.h"
+
+#include <QCloseEvent>
+#include <QGridLayout>
+#include <QHeaderView>
+#include <QLineEdit>
+#include <QMenu>
+#include <QMenuBar>
+#include <QMessageBox>
+#include <QSignalMapper>
+#include <QStyle>
+#include <QToolBar>
+#include <QToolButton>
+#include <QTreeWidget>
+
+#define LMASTER_BEAT_COL 0
+#define LMASTER_TIME_COL 1
+#define LMASTER_TYPE_COL 2
+#define LMASTER_VAL_COL 3
+
+#define LMASTER_MSGBOX_STRING "MusE: List Editor"
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void LMaster::closeEvent(QCloseEvent* e)
+ {
+ emit deleted((unsigned long)this);
+ e->accept();
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void LMaster::songChanged(int type)
+ {
+ if (type & (SC_SIG | SC_TEMPO))
+ updateList();
+ }
+
+//---------------------------------------------------------
+// LMaster
+//---------------------------------------------------------
+
+LMaster::LMaster()
+ : MidiEditor(0, 0, 0)
+ {
+ pos_editor = 0;
+ editor = 0;
+ sig_editor = 0;
+ editedItem = 0;
+ editingNewItem = false;
+ setWindowTitle(tr("MusE: Mastertrack"));
+ setMinimumHeight(100);
+ setFixedWidth(400);
+
+ //---------Pulldown Menu----------------------------
+ menuEdit = menuBar()->addMenu(tr("&Edit"));
+ QSignalMapper *signalMapper = new QSignalMapper(this);
+ menuEdit->addActions(undoRedo->actions());
+ menuEdit->addSeparator();
+ tempoAction = menuEdit->addAction(tr("Insert Tempo"));
+ signAction = menuEdit->addAction(tr("Insert Signature"));
+ posAction = menuEdit->addAction(tr("Edit Positon"));
+ valAction = menuEdit->addAction(tr("Edit Value"));
+ delAction = menuEdit->addAction(tr("Delete Event"));
+ delAction->setShortcut(Qt::Key_Delete);
+
+ connect(tempoAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+ connect(signAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+ connect(posAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+ connect(valAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+ connect(delAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+
+ signalMapper->setMapping(tempoAction, CMD_INSERT_TEMPO);
+ signalMapper->setMapping(signAction, CMD_INSERT_SIG);
+ signalMapper->setMapping(posAction, CMD_EDIT_BEAT);
+ signalMapper->setMapping(valAction, CMD_EDIT_VALUE);
+ signalMapper->setMapping(delAction, CMD_DELETE);
+
+ connect(signalMapper, SIGNAL(mapped(int)), SLOT(cmd(int)));
+
+ //---------ToolBar----------------------------------
+ tools = addToolBar(tr("Master tools"));
+ tools->addActions(undoRedo->actions());
+
+ //QToolBar* edit = new QToolBar(this, "edit tools");
+ QToolBar* edit = addToolBar(tr("Edit tools"));
+ //QToolButton* tempoButton = new QToolButton(edit);
+ QToolButton* tempoButton = new QToolButton();
+ //QToolButton* timeSigButton = new QToolButton(edit);
+ QToolButton* timeSigButton = new QToolButton();
+ tempoButton->setText(tr("Tempo"));
+ timeSigButton->setText(tr("Timesig"));
+ tempoButton->setToolTip(tr("new tempo"));
+ timeSigButton->setToolTip(tr("new signature"));
+ edit->addWidget(tempoButton);
+ edit->addWidget(timeSigButton);
+
+ ///Q3Accel* qa = new Q3Accel(this);
+ ///qa->connectItem(qa->insertItem(Qt::CTRL+Qt::Key_Z), song, SLOT(undo()));
+ ///qa->connectItem(qa->insertItem(Qt::CTRL+Qt::Key_Y), song, SLOT(redo()));
+
+ //---------------------------------------------------
+ // master
+ //---------------------------------------------------
+
+ view = new QTreeWidget;
+ view->setAllColumnsShowFocus(true);
+ view->setSelectionMode(QAbstractItemView::SingleSelection);
+ QStringList columnnames;
+ columnnames << tr("Meter")
+ << tr("Time")
+ << tr("Type")
+ << tr("Value");
+ view->setHeaderLabels(columnnames);
+ view->setColumnWidth(2,80);
+ view->header()->setStretchLastSection(true);
+
+ //---------------------------------------------------
+ // Rest
+ //---------------------------------------------------
+
+// QSizeGrip* corner = new QSizeGrip(mainw);
+
+ mainGrid->setRowStretch(0, 100);
+ mainGrid->setColumnStretch(0, 100);
+
+ mainGrid->addWidget(view, 0, 0);
+// mainGrid->addWidget(corner, 1, 1, AlignBottom | AlignRight);
+ updateList();
+
+ connect(view, SIGNAL(currentItemChanged(QTreeWidgetItem*, QTreeWidgetItem*)), SLOT(select(QTreeWidgetItem*, QTreeWidgetItem*)));
+ connect(view, SIGNAL(itemPressed(QTreeWidgetItem*, int)), SLOT(itemPressed(QTreeWidgetItem*, int)));
+ connect(view, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)), SLOT(itemDoubleClicked(QTreeWidgetItem*)));
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+ connect(tempoButton, SIGNAL(clicked()), SLOT(tempoButtonClicked()));
+ connect(timeSigButton, SIGNAL(clicked()), SLOT(timeSigButtonClicked()));
+
+ initShortcuts();
+ }
+
+//---------------------------------------------------------
+// ~LMaster
+//---------------------------------------------------------
+
+LMaster::~LMaster()
+ {
+ //undoRedo->removeFrom(tools); // p4.0.6 Removed
+ }
+
+//---------------------------------------------------------
+// insertSig
+//---------------------------------------------------------
+
+void LMaster::insertSig(const AL::SigEvent* ev)
+ {
+ new LMasterSigEventItem(view, ev);
+ }
+
+//---------------------------------------------------------
+// insertTempo
+//---------------------------------------------------------
+
+void LMaster::insertTempo(const TEvent* ev)
+ {
+ new LMasterTempoItem(view, ev);
+ }
+
+//---------------------------------------------------------
+// updateList
+//---------------------------------------------------------
+
+void LMaster::updateList()
+ {
+ LMasterLViewItem* selected = (LMasterLViewItem*) view->currentItem();
+ LMASTER_LVTYPE type = LMASTER_TEMPO;
+ unsigned tick = 0;
+
+ if (selected) {
+ type = selected->getType();
+ tick = selected->tick();
+ }
+
+ view->clear();
+ const TempoList* t = &tempomap;
+ const AL::SigList* s = &AL::sigmap;
+
+ criTEvent it = t->rbegin();
+ AL::criSigEvent is = s->rbegin();
+ for (;;) {
+ if (it == t->rend()) {
+ while(is != s->rend()) {
+ insertSig(is->second);
+ ++is;
+ }
+ break;
+ }
+ if (is == s->rend()) {
+ while (it != t->rend()) {
+ insertTempo(it->second);
+ ++it;
+ }
+ break;
+ }
+ if (is->second->tick > it->second->tick) {
+ insertSig(is->second);
+ ++is;
+ }
+ else {
+ insertTempo(it->second);
+ ++it;
+ }
+ }
+
+ // Try to reselect the previous selection:
+ if(selected)
+ {
+ LMasterLViewItem* tmp = getItemAtPos(tick, type);
+ if (tmp) {
+ view->clearSelection();
+ view->setCurrentItem(tmp);
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// readStatus
+//---------------------------------------------------------
+
+void LMaster::readStatus(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ if (token == Xml::Error || token == Xml::End)
+ break;
+ switch (token) {
+ case Xml::TagStart:
+ if (tag == "midieditor")
+ MidiEditor::readStatus(xml);
+ else
+ xml.unknown("LMaster");
+ break;
+ case Xml::TagEnd:
+ if (tag == "lmaster")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// writeStatus
+//---------------------------------------------------------
+
+void LMaster::writeStatus(int level, Xml& xml) const
+ {
+ xml.tag(level++, "lmaster");
+ MidiEditor::writeStatus(level, xml);
+ xml.tag(level, "/lmaster");
+ }
+
+//---------------------------------------------------------
+// select
+//---------------------------------------------------------
+
+void LMaster::select(QTreeWidgetItem* /*item*/, QTreeWidgetItem* /*previous_item*/)
+ {
+// printf("select %x\n", unsigned(item));
+ }
+
+//---------------------------------------------------------
+// cmd
+//---------------------------------------------------------
+
+void LMaster::cmd(int cmd)
+ {
+ switch(cmd) {
+ case CMD_DELETE: {
+ LMasterLViewItem* l = (LMasterLViewItem*) view->currentItem();
+ if (!l)
+ return;
+ // Delete item:
+ if (l->tick() != 0) {
+ if (l == view->topLevelItem(view->topLevelItemCount() - 1))
+ view->setCurrentItem(view->itemAbove(l));
+ else
+ view->setCurrentItem(view->itemBelow(l));
+
+ switch (l->getType()) {
+ case LMASTER_TEMPO:
+ {
+ LMasterTempoItem* t = (LMasterTempoItem*) l;
+ audio->msgDeleteTempo(t->tick(), t->tempo(), true);
+ break;
+ }
+ case LMASTER_SIGEVENT:
+ {
+ LMasterSigEventItem* s = (LMasterSigEventItem*) l;
+ audio->msgRemoveSig(s->tick(), s->z(), s->n());
+ break;
+ }
+ default:
+ M_ERROR("Default switch statement reached");
+ break;
+ }
+ }
+ break;
+ }
+ case CMD_INSERT_TEMPO:
+ tempoButtonClicked();
+ break;
+ case CMD_INSERT_SIG:
+ timeSigButtonClicked();
+ break;
+ case CMD_EDIT_BEAT:
+ case CMD_EDIT_VALUE:
+ cmd == CMD_EDIT_VALUE ? editorColumn = LMASTER_VAL_COL : editorColumn = LMASTER_BEAT_COL;
+ if (view->currentItem() && !editedItem) {
+ itemDoubleClicked(view->currentItem());
+ }
+ break;
+ }
+ }
+
+/*!
+ \fn LMaster::itemPressed(QListViewItem* i, const QPoint& p, int column)
+ */
+void LMaster::itemPressed(QTreeWidgetItem* i, int column)
+ {
+ //printf("itemPressed, column: %d\n", column);
+ if (editedItem) {
+ if (editorColumn != column || editedItem != i)
+ returnPressed();
+ }
+ else
+ editorColumn = column;
+ }
+
+//---------------------------------------------------------
+// itemDoubleClicked(QListViewItem* item)
+//! Sets lmaster in edit mode, and opens editor for selected value
+//---------------------------------------------------------
+void LMaster::itemDoubleClicked(QTreeWidgetItem* i)
+ {
+ //printf("itemDoubleClicked\n");
+
+ if (!editedItem && editorColumn == LMASTER_VAL_COL) {
+ editedItem = (LMasterLViewItem*) i;
+ QRect itemRect = view->visualItemRect(editedItem);
+ int x1 = view->columnWidth(LMASTER_BEAT_COL) + view->columnWidth(LMASTER_TIME_COL)
+ + view->columnWidth(LMASTER_TYPE_COL);
+ itemRect.setX(x1);
+ //Qt makes crazy things with itemRect if this is called directly..
+ if (editingNewItem) {
+ QFontMetrics fm(font());
+ int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth,0 , this); // ddskrjo 0
+ int h = fm.height() + fw * 2;
+ itemRect.setWidth(view->columnWidth(LMASTER_VAL_COL));
+ itemRect.setY(1);
+ itemRect.setHeight(h);
+ }
+
+
+ // Edit tempo value:
+ if (editedItem->getType() == LMASTER_TEMPO) {
+ if (!editor)
+ editor = new QLineEdit(view->viewport());
+ editor->setText(editedItem->text(LMASTER_VAL_COL));
+ editor->setGeometry(itemRect);
+ editor->show();
+ editor->setFocus();
+ editor->selectAll();
+ connect(editor, SIGNAL(returnPressed()), SLOT(returnPressed()));
+ }
+ else { // Edit signatur value:
+ if (!sig_editor)
+ sig_editor = new SigEdit(view->viewport());
+ sig_editor->setValue(editedItem->text(LMASTER_VAL_COL));
+ sig_editor->setGeometry(itemRect);
+ sig_editor->show();
+ sig_editor->setFocus();
+ connect(sig_editor, SIGNAL(returnPressed()), SLOT(returnPressed()));
+ }
+ }
+ // Edit tempo or signal position:
+ else if (!editedItem && editorColumn == LMASTER_BEAT_COL) {
+ editedItem = (LMasterLViewItem*) i;
+ // Don't allow movement of initial values:
+ if (editedItem->tick() == 0) {
+ QMessageBox::information(this, tr(LMASTER_MSGBOX_STRING),
+ tr("Reposition of the initial tempo and signature events is not allowed") );
+ editedItem = 0;
+ }
+ // Everything OK
+ else {
+ if (!pos_editor)
+ ///pos_editor = new PosEdit(view->viewport());
+ pos_editor = new Awl::PosEdit(view->viewport());
+ pos_editor->setValue(editedItem->tick());
+ QRect itemRect = view->visualItemRect(editedItem);
+ itemRect.setX(0);
+ itemRect.setWidth(view->columnWidth(LMASTER_BEAT_COL));
+ pos_editor->setGeometry(itemRect);
+ pos_editor->show();
+ pos_editor->setFocus();
+ connect(pos_editor, SIGNAL(returnPressed()), SLOT(returnPressed()));
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// returnPressed()
+//! called when editor is closed
+//---------------------------------------------------------
+
+void LMaster::returnPressed()
+ {
+ if (!editedItem)
+ return;
+
+ setFocus();
+ // Tempo event:
+ if (editedItem->getType() == LMASTER_TEMPO && editorColumn == LMASTER_VAL_COL) {
+ QString input = editor->text();
+ editor->hide();
+ repaint();
+ LMasterTempoItem* e = (LMasterTempoItem*) editedItem;
+ const TEvent* t = e->getEvent();
+ unsigned tick = t->tick;
+ bool conversionOK;
+ double dbl_input = input.toDouble(&conversionOK);
+ if (conversionOK && dbl_input < 250.0) {
+ int tempo = (int) ((1000000.0 * 60.0)/dbl_input);
+
+ if (!editingNewItem) {
+ song->startUndo();
+ audio->msgDeleteTempo(tick, e->tempo(), false);
+ audio->msgAddTempo(tick, tempo, false);
+ song->endUndo(SC_TEMPO);
+ }
+ //
+ // New item edited:
+ //
+ else {
+ audio->msgAddTempo(tick, tempo, true);
+ }
+ }
+ else {
+ QMessageBox::warning(this, tr("MusE: List Editor"),
+ tr("Input error, conversion not OK or value out of range"),
+ QMessageBox::Ok, Qt::NoButton
+ );
+ }
+ }
+ //
+ // Beat column, change position of a particular tempo or signature event
+ //
+ else if (editorColumn == LMASTER_BEAT_COL) {
+ int oldtick = editedItem->tick();
+ int newtick = pos_editor->pos().tick();
+ if (newtick == 0) { // Do not allow change of position to beginning of song
+ QMessageBox::warning(this, tr(LMASTER_MSGBOX_STRING),
+ tr("Reposition of tempo and signature events to start position is not allowed!"),
+ QMessageBox::Ok, Qt::NoButton
+ );
+ }
+ else if (oldtick != newtick) { // Ignore if tick hasn't changed
+ if (editedItem->getType() == LMASTER_TEMPO) {
+ LMasterTempoItem* t = (LMasterTempoItem*) editedItem;
+ int tempo = t->tempo();
+ song->startUndo();
+ audio->msgDeleteTempo(oldtick, tempo, false);
+ audio->msgAddTempo(newtick, tempo, false);
+ song->endUndo(SC_TEMPO);
+ // Select the item:
+ QTreeWidgetItem* newSelected = (QTreeWidgetItem*) getItemAtPos(newtick, LMASTER_TEMPO);
+ if (newSelected) {
+ view->clearSelection();
+ view->setCurrentItem(newSelected);
+ }
+ }
+ else if (editedItem->getType() == LMASTER_SIGEVENT) {
+ LMasterSigEventItem* t = (LMasterSigEventItem*) editedItem;
+ int z = t->z();
+ int n = t->n();
+ if (!editingNewItem) {
+ song->startUndo();
+ audio->msgRemoveSig(oldtick, z, n, false); //Delete first, in order to get sane tick-value
+ newtick = pos_editor->pos().tick();
+ audio->msgAddSig(newtick, z, n, false);
+ song->endUndo(SC_SIG);
+ }
+ else
+ audio->msgAddSig(newtick, z, n, false);
+ //audio->msgAddSig(newtick, z, n, true);
+
+ // Select the item:
+ QTreeWidgetItem* newSelected = (QTreeWidgetItem*) getItemAtPos(newtick, LMASTER_SIGEVENT);
+ if (newSelected) {
+ view->clearSelection();
+ view->setCurrentItem(newSelected);
+ }
+ }
+
+ }
+ pos_editor->hide();
+ repaint();
+ }
+ //
+ // SigEvent, value changed:
+ //
+ else if (editedItem->getType() == LMASTER_SIGEVENT && editorColumn == LMASTER_VAL_COL)
+ {
+ ///Sig newSig = sig_editor->sig();
+ AL::TimeSignature newSig = sig_editor->sig();
+
+ sig_editor->hide();
+
+ // Added p3.3.43 Prevents aborting with 0 z or n.
+ if(newSig.isValid())
+ {
+
+ LMasterSigEventItem* e = (LMasterSigEventItem*) editedItem;
+ int tick = e->tick();
+ if (!editingNewItem) {
+ song->startUndo();
+ if (tick > 0)
+ audio->msgRemoveSig(tick, e->z(), e->n(), false);
+ audio->msgAddSig(tick, newSig.z, newSig.n, false);
+ song->endUndo(SC_SIG);
+ }
+ else
+ audio->msgAddSig(tick, newSig.z, newSig.n, true);
+ }
+ }
+
+ view->setFocus();
+ // No item edited now:
+ editedItem = 0;
+ editorColumn = -1;
+ editingNewItem = false;
+
+ }
+
+
+/*!
+ \fn LMasterLViewItem::text(int column)
+ \brief Returns the initialized text to the View
+ */
+QString LMasterLViewItem::text(int column) const
+ {
+ QString ret = "?";
+ switch (column) {
+ case LMASTER_BEAT_COL:
+ ret = c1;
+ break;
+ case LMASTER_TIME_COL:
+ ret = c2;
+ break;
+ case LMASTER_TYPE_COL:
+ ret = c3;
+ break;
+ case LMASTER_VAL_COL:
+ ret = c4;
+ break;
+ default:
+ fprintf(stderr,"LMasterLViewItem::text(int): Default switch statement reached... Unknown column.\n");
+ break;
+ }
+ return ret;
+ }
+
+//---------------------------------------------------------
+// LMasterTempoItem
+//! Initializes a LMasterTempoItem with a TEvent
+//---------------------------------------------------------
+LMasterTempoItem::LMasterTempoItem(QTreeWidget* parent, const TEvent* ev)
+ : LMasterLViewItem(parent)
+ {
+ tempoEvent = ev;
+ unsigned t = ev->tick;
+ //QString c1, c2, c3, c4;
+ int bar, beat;
+ unsigned tick;
+ AL::sigmap.tickValues(t, &bar, &beat, &tick);
+ c1.sprintf("%04d.%02d.%03d", bar+1, beat+1, tick);
+
+ double time = double(ev->frame) / double(sampleRate);
+ int min = int(time) / 60;
+ int sec = int(time) % 60;
+ int msec = int((time - (min*60 + sec)) * 1000.0);
+ c2.sprintf("%03d:%02d:%03d", min, sec, msec);
+ c3 = "Tempo";
+ double dt = (1000000.0 * 60.0)/ev->tempo;
+ c4.setNum(dt, 'f', 3);
+ setText(0, c1);
+ setText(1, c2);
+ setText(2, c3);
+ setText(3, c4);
+ }
+
+//---------------------------------------------------------
+// LMasterSigEventItem
+//! Initializes a ListView item with a SigEvent
+//---------------------------------------------------------
+LMasterSigEventItem::LMasterSigEventItem(QTreeWidget* parent, const AL::SigEvent* ev)
+ : LMasterLViewItem(parent)
+ {
+ sigEvent = ev;
+ unsigned t = ev->tick;
+ int bar, beat;
+ unsigned tick;
+ AL::sigmap.tickValues(t, &bar, &beat, &tick);
+ c1.sprintf("%04d.%02d.%03d", bar+1, beat+1, tick);
+
+ double time = double(tempomap.tick2frame(t)) / double (sampleRate);
+ int min = int(time) / 60;
+ int sec = int(time) % 60;
+ int msec = int((time - (min*60 + sec)) * 1000.0);
+ c2.sprintf("%03d:%02d:%03d", min, sec, msec);
+ c3 = "Timesig";
+ c4.sprintf("%d/%d", ev->sig.z, ev->sig.n);
+ setText(0, c1);
+ setText(1, c2);
+ setText(2, c3);
+ setText(3, c4);
+ }
+
+//---------------------------------------------------------
+// tempoButtonClicked()
+//! inserts a new tempo-item in the list and starts the editor for it
+//---------------------------------------------------------
+void LMaster::tempoButtonClicked()
+ {
+ LMasterTempoItem* lastTempo = (LMasterTempoItem*) getLastOfType(LMASTER_TEMPO);
+ QString beatString = ((LMasterLViewItem*)lastTempo)->text(LMASTER_BEAT_COL);
+ int m, b, t;
+ Pos p = Pos(beatString);
+ p.mbt(&m, &b, &t);
+ m++; //Next bar
+ int newTick = AL::sigmap.bar2tick(m, b, t);
+ TEvent* ev = new TEvent(lastTempo->tempo(), newTick);
+ new LMasterTempoItem(view, ev);
+ QTreeWidgetItem* newTempoItem = view->topLevelItem(0);
+ //LMasterTempoItem* newTempoItem = new LMasterTempoItem(view, ev);
+
+ editingNewItem = true; // State
+ editorColumn = LMASTER_VAL_COL; // Set that we edit editorColumn
+ view->clearSelection();
+ view->setCurrentItem(newTempoItem);
+ itemDoubleClicked(newTempoItem);
+ }
+
+
+//---------------------------------------------------------
+// tempoButtonClicked()
+//! inserts a new sig-item in the list and starts the editor for it
+//---------------------------------------------------------
+void LMaster::timeSigButtonClicked()
+ {
+ LMasterSigEventItem* lastSig = (LMasterSigEventItem*) getLastOfType(LMASTER_SIGEVENT);
+ QString beatString = ((LMasterLViewItem*)lastSig)->text(LMASTER_BEAT_COL);
+ int m, b, t;
+ Pos p = Pos(beatString);
+ p.mbt(&m, &b, &t);
+ m++;
+ int newTick = AL::sigmap.bar2tick(m, b, t);
+ AL::SigEvent* ev = new AL::SigEvent(AL::TimeSignature(lastSig->z(), lastSig->n()), newTick);
+ new LMasterSigEventItem(view, ev);
+ QTreeWidgetItem* newSigItem = view->topLevelItem(0);
+ //LMasterSigEventItem* newSigItem = new LMasterSigEventItem(view, ev);
+
+ editingNewItem = true; // State
+ editorColumn = LMASTER_VAL_COL; // Set that we edit editorColumn
+ view->clearSelection();
+ view->setCurrentItem(newSigItem);
+ itemDoubleClicked(newSigItem);
+ }
+
+
+/*!
+ \fn LMaster::getLastOfType(LMASTER_LVTYPE t)
+ */
+LMasterLViewItem* LMaster::getLastOfType(LMASTER_LVTYPE t)
+ {
+ LMasterLViewItem* tmp = (LMasterLViewItem*) view->topLevelItem(view->topLevelItemCount() - 1);
+ while (tmp->getType() != t) {
+ tmp = (LMasterLViewItem*) view->itemAbove(tmp);
+ }
+ return tmp;
+ }
+
+
+/*!
+ \fn LMaster::getItemAtPos(unsigned tick, LMASTER_LVTYPE t)
+ */
+LMasterLViewItem* LMaster::getItemAtPos(unsigned tick, LMASTER_LVTYPE t)
+ {
+ LMasterLViewItem* tmp = (LMasterLViewItem*) view->topLevelItem(0);
+ while (tmp) {
+ if (tmp->getType() == t && tmp->tick() == tick)
+ return tmp;
+ tmp = (LMasterLViewItem*) view->itemBelow(tmp);
+ }
+
+ return 0;
+ }
+
+
+/*!
+ \fn LMaster::configChanged()
+ */
+void LMaster::configChanged()
+ {
+ initShortcuts();
+ }
+
+
+/*!
+ \fn LMaster::initShortcuts()
+ */
+void LMaster::initShortcuts()
+ {
+ tempoAction->setShortcut(shortcuts[SHRT_LM_INS_TEMPO].key);
+ signAction->setShortcut(shortcuts[SHRT_LM_INS_SIG].key);
+ posAction->setShortcut(shortcuts[SHRT_LM_EDIT_BEAT].key);
+ valAction->setShortcut(shortcuts[SHRT_LM_EDIT_VALUE].key);
+ }
diff --git a/attic/muse2-oom/muse2/muse/master/lmaster.h b/attic/muse2-oom/muse2/muse/master/lmaster.h
new file mode 100644
index 00000000..cd687e45
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/master/lmaster.h
@@ -0,0 +1,146 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: lmaster.h,v 1.1.1.1.2.5 2005/12/11 21:29:23 spamatica Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __LMASTER_EDIT_H__
+#define __LMASTER_EDIT_H__
+
+#include "midieditor.h"
+#include "noteinfo.h"
+#include "cobject.h"
+#include "tempo.h"
+///#include "sig.h"
+//#include "al/sig.h"
+
+#include <QTreeWidgetItem>
+
+namespace AL {
+ class SigEvent;
+ };
+using AL::SigEvent;
+
+namespace Awl {
+ class PosEdit;
+ class SigEdit;
+ };
+using Awl::PosEdit;
+using Awl::SigEdit;
+
+class QLineEdit;
+
+enum LMASTER_LVTYPE
+ {
+ LMASTER_TEMPO = 0,
+ LMASTER_SIGEVENT
+ };
+
+//---------------------------------------------------------
+// LMasterLViewItem
+//! QListViewItem base class for LMasterTempoItem and LMasterSigEventItem
+//---------------------------------------------------------
+class LMasterLViewItem : public QTreeWidgetItem {
+ protected:
+ QString c1, c2, c3, c4;
+
+ public:
+ LMasterLViewItem(QTreeWidget* parent)
+ : QTreeWidgetItem(QTreeWidgetItem::UserType) {parent->insertTopLevelItem(0, this);}
+ virtual QString text(int column) const;
+ virtual LMASTER_LVTYPE getType() = 0;
+ virtual unsigned tick() = 0;
+ };
+
+//---------------------------------------------------------
+// LMasterTempoItem
+//! QListViewItem which holds data for a TEvent
+//---------------------------------------------------------
+class LMasterTempoItem : public LMasterLViewItem {
+
+ private:
+ const TEvent* tempoEvent;
+
+ public:
+ LMasterTempoItem(QTreeWidget* parent, const TEvent* t);
+ virtual LMASTER_LVTYPE getType() { return LMASTER_TEMPO; }
+ const TEvent* getEvent() { return tempoEvent; }
+ virtual unsigned tick() { return tempoEvent->tick; }
+ int tempo() { return tempoEvent->tempo; }
+ };
+
+//---------------------------------------------------------
+// LMasterTempoItem
+//! QListViewItem which holds data for a SigEvent
+//---------------------------------------------------------
+class LMasterSigEventItem : public LMasterLViewItem {
+
+ private:
+ const SigEvent* sigEvent;
+
+ public:
+ LMasterSigEventItem(QTreeWidget* parent, const SigEvent* s);
+ virtual LMASTER_LVTYPE getType() { return LMASTER_SIGEVENT; }
+ const SigEvent* getEvent() { return sigEvent; }
+ virtual unsigned tick() { return sigEvent->tick; }
+ int z() { return sigEvent->sig.z; }
+ int n() { return sigEvent->sig.n; }
+ };
+
+
+//---------------------------------------------------------
+// LMaster
+//---------------------------------------------------------
+
+class LMaster : public MidiEditor {
+ QTreeWidget* view;
+ QToolBar* tools;
+ QMenu* menuEdit;
+
+ enum { CMD_DELETE, CMD_INSERT_SIG, CMD_INSERT_TEMPO, CMD_EDIT_BEAT, CMD_EDIT_VALUE };
+
+ Q_OBJECT
+ virtual void closeEvent(QCloseEvent*);
+ void updateList();
+ void insertTempo(const TEvent*);
+ void insertSig(const SigEvent*);
+ LMasterLViewItem* getItemAtPos(unsigned tick, LMASTER_LVTYPE t);
+ void initShortcuts();
+ QLineEdit* editor;
+ PosEdit* pos_editor;
+ // State-like members:
+ LMasterLViewItem* editedItem;
+ SigEdit* sig_editor;
+ int editorColumn;
+ bool editingNewItem;
+
+ QAction *tempoAction, *signAction, *posAction, *valAction, *delAction;
+
+ private slots:
+ void select(QTreeWidgetItem*, QTreeWidgetItem*);
+ void itemDoubleClicked(QTreeWidgetItem* item);
+ void returnPressed();
+ void itemPressed(QTreeWidgetItem* i, int column);
+ void tempoButtonClicked();
+ void timeSigButtonClicked();
+ void cmd(int cmd);
+
+ public slots:
+ void songChanged(int);
+ void configChanged();
+
+ signals:
+ void deleted(unsigned long);
+
+ public:
+ LMaster();
+ ~LMaster();
+ virtual void readStatus(Xml&);
+ virtual void writeStatus(int, Xml&) const;
+ LMasterLViewItem* getLastOfType(LMASTER_LVTYPE t);
+ };
+
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/master/master.cpp b/attic/muse2-oom/muse2/muse/master/master.cpp
new file mode 100644
index 00000000..4a33a8c4
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/master/master.cpp
@@ -0,0 +1,338 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: master.cpp,v 1.3 2004/04/11 13:03:32 wschweer Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <values.h>
+
+#include <QCursor>
+#include <QEvent>
+#include <QMouseEvent>
+#include <QPainter>
+
+#include "globals.h"
+#include "master.h"
+#include "song.h"
+#include "scrollscale.h"
+#include "midi.h"
+#include "midieditor.h"
+#include "icons.h"
+#include "audio.h"
+
+extern void drawTickRaster(QPainter& p, int x, int y,
+ int w, int h, int quant);
+
+//---------------------------------------------------------
+// Master
+//---------------------------------------------------------
+
+Master::Master(MidiEditor* e, QWidget* parent, int xmag, int ymag)
+ : View(parent, xmag, ymag)
+ {
+ editor = e;
+ setBg(Qt::white);
+ vscroll = 0;
+ pos[0] = 0;
+ pos[1] = 0;
+ pos[2] = 0;
+ setFocusPolicy(Qt::StrongFocus); // Tim.
+ setMouseTracking(true);
+ connect(song, SIGNAL(posChanged(int, unsigned, bool)), this, SLOT(setPos(int, unsigned, bool)));
+ connect(song, SIGNAL(songChanged(int)), this, SLOT(redraw()));
+ }
+
+//---------------------------------------------------------
+// setPos
+//---------------------------------------------------------
+
+void Master::setPos(int idx, unsigned val, bool adjustScrollbar)
+ {
+ if (pos[idx] == val)
+ return;
+
+ int opos = mapx(pos[idx]);
+ int npos = mapx(val);
+
+ if (adjustScrollbar && idx == 0) {
+ switch (song->follow()) {
+ case Song::NO:
+ break;
+ case Song::JUMP:
+ if (npos >= width()) {
+ int ppos = val - rmapxDev(width()/8);
+ if (ppos < 0)
+ ppos = 0;
+ emit followEvent(ppos);
+ opos = mapx(pos[idx]);
+ npos = mapx(val);
+ }
+ else if (npos < 0) {
+ int ppos = val - rmapxDev(width()*3/4);
+ if (ppos < 0)
+ ppos = 0;
+ emit followEvent(ppos);
+ opos = mapx(pos[idx]);
+ npos = mapx(val);
+ }
+ break;
+ case Song::CONTINUOUS:
+ if (npos > (width()/2)) {
+ int ppos = pos[idx] - rmapxDev(width()/2);
+ if (ppos < 0)
+ ppos = 0;
+ emit followEvent(ppos);
+ opos = mapx(pos[idx]);
+ npos = mapx(val);
+ }
+ else if (npos < (width()/2)) {
+ int ppos = pos[idx] - rmapxDev(width()/2);
+ if (ppos < 0)
+ ppos = 0;
+ emit followEvent(ppos);
+ opos = mapx(pos[idx]);
+ npos = mapx(val);
+ }
+ break;
+ }
+ }
+
+ int x;
+ int w = 1;
+ if (opos > npos) {
+ w += opos - npos;
+ x = npos;
+ }
+ else {
+ w += npos - opos;
+ x = opos;
+ }
+ pos[idx] = val;
+ redraw(QRect(x-1, 0, w+2, height()));
+ }
+
+//---------------------------------------------------------
+// leaveEvent
+//---------------------------------------------------------
+
+void Master::leaveEvent(QEvent*)
+ {
+ emit tempoChanged(-1);
+ emit timeChanged(MAXINT);
+ }
+
+//---------------------------------------------------------
+// pdraw
+//---------------------------------------------------------
+
+void Master::pdraw(QPainter& p, const QRect& rect)
+ {
+ View::pdraw(p, rect); // calls draw()
+ p.resetTransform();
+
+ int x = rect.x();
+ int y = rect.y();
+ int w = rect.width() + 2;
+ int h = rect.height();
+
+ int wh = height();
+ //---------------------------------------------------
+ // draw Canvas Items
+ //---------------------------------------------------
+
+ const TempoList* tl = &tempomap;
+ for (ciTEvent i = tl->begin(); i != tl->end(); ++i) {
+ TEvent* e = i->second;
+ int etick = mapx(i->first);
+ int stick = mapx(i->second->tick);
+ int tempo = mapy(280000 - int(60000000000.0/(e->tempo)));
+
+ if (tempo < 0)
+ tempo = 0;
+ if (tempo < wh) {
+ p.fillRect(stick, tempo, etick-stick, wh, Qt::blue);
+ }
+ }
+
+ //---------------------------------------------------
+ // draw marker
+ //---------------------------------------------------
+
+ int xp = mapx(pos[0]);
+ if (xp >= x && xp < x+w) {
+ p.setPen(Qt::red);
+ p.drawLine(xp, y, xp, y+h);
+ }
+ xp = mapx(pos[1]);
+ if (xp >= x && xp < x+w) {
+ p.setPen(Qt::blue);
+ p.drawLine(xp, y, xp, y+h);
+ }
+ xp = mapx(pos[2]);
+ if (xp >= x && xp < x+w) {
+ p.setPen(Qt::blue);
+ p.drawLine(xp, y, xp, y+h);
+ }
+ }
+
+//---------------------------------------------------------
+// draw
+//---------------------------------------------------------
+
+void Master::draw(QPainter& p, const QRect& rect)
+ {
+ drawTickRaster(p, rect.x(), rect.y(),
+ rect.width(), rect.height(), 0);
+ }
+
+//---------------------------------------------------------
+// viewMousePressEvent
+//---------------------------------------------------------
+
+void Master::viewMousePressEvent(QMouseEvent* event)
+ {
+ start = event->pos();
+ Tool activeTool = tool;
+// bool shift = event->state() & ShiftButton;
+
+ switch (activeTool) {
+ case PointerTool:
+ drag = DRAG_LASSO_START;
+ break;
+
+ case PencilTool:
+ drag = DRAG_NEW;
+ song->startUndo();
+ newVal(start.x(), start.x(), start.y());
+ break;
+
+ case RubberTool:
+ drag = DRAG_DELETE;
+ song->startUndo();
+ deleteVal(start.x(), start.x());
+ break;
+
+ default:
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// viewMouseMoveEvent
+//---------------------------------------------------------
+
+void Master::viewMouseMoveEvent(QMouseEvent* event)
+ {
+ QPoint pos = event->pos();
+// QPoint dist = pos - start;
+// bool moving = dist.y() >= 3 || dist.y() <= 3 || dist.x() >= 3 || dist.x() <= 3;
+
+ switch (drag) {
+ case DRAG_NEW:
+ newVal(start.x(), pos.x(), pos.y());
+ start = pos;
+ break;
+
+ case DRAG_DELETE:
+ deleteVal(start.x(), pos.x());
+ start = pos;
+ break;
+
+ default:
+ break;
+ }
+ emit tempoChanged(280000 - event->y());
+ int x = pos.x();
+ if (x < 0)
+ x = 0;
+ emit timeChanged(editor->rasterVal(x));
+ }
+
+//---------------------------------------------------------
+// viewMouseReleaseEvent
+//---------------------------------------------------------
+
+void Master::viewMouseReleaseEvent(QMouseEvent*)
+ {
+ switch (drag) {
+ case DRAG_RESIZE:
+ case DRAG_NEW:
+ case DRAG_DELETE:
+ song->endUndo(SC_TEMPO);
+ break;
+ default:
+ break;
+ }
+ drag = DRAG_OFF;
+ }
+
+//---------------------------------------------------------
+// deleteVal
+//---------------------------------------------------------
+
+bool Master::deleteVal1(unsigned int x1, unsigned int x2)
+ {
+ bool songChanged = false;
+
+ TempoList* tl = &tempomap;
+ for (iTEvent i = tl->begin(); i != tl->end(); ++i) {
+ if (i->first < x1)
+ continue;
+ if (i->first >= x2)
+ break;
+ iTEvent ii = i;
+ ++ii;
+ if (ii != tl->end()) {
+ int tempo = ii->second->tempo;
+ audio->msgDeleteTempo(i->first, tempo, false);
+ songChanged = true;
+ }
+ }
+ return songChanged;
+ }
+
+void Master::deleteVal(int x1, int x2)
+ {
+ if (deleteVal1(editor->rasterVal1(x1), x2))
+ redraw();
+ }
+
+//---------------------------------------------------------
+// setTool
+//---------------------------------------------------------
+
+void Master::setTool(int t)
+ {
+ if (tool == Tool(t))
+ return;
+ tool = Tool(t);
+ switch(tool) {
+ case PencilTool:
+ setCursor(QCursor(*pencilIcon, 4, 15));
+ break;
+ default:
+ setCursor(QCursor(Qt::ArrowCursor));
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// newVal
+//---------------------------------------------------------
+
+void Master::newVal(int x1, int x2, int y)
+ {
+ int xx1 = editor->rasterVal1(x1);
+ int xx2 = editor->rasterVal2(x2);
+
+ if (xx1 > xx2) {
+ int tmp = xx2;
+ xx2 = xx1;
+ xx1 = tmp;
+ }
+ deleteVal1(xx1, xx2);
+ audio->msgAddTempo(xx1, int(60000000000.0/(280000 - y)), false);
+ redraw();
+ }
diff --git a/attic/muse2-oom/muse2/muse/master/master.h b/attic/muse2-oom/muse2/muse/master/master.h
new file mode 100644
index 00000000..52040aeb
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/master/master.h
@@ -0,0 +1,68 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: master.h,v 1.3 2004/04/11 13:03:32 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MASTER_H__
+#define __MASTER_H__
+
+#include "view.h"
+#include "song.h"
+#include "tools.h"
+
+class QMouseEvent;
+class QPainter;
+class QPoint;
+class QRect;
+class QToolBar;
+
+class MidiEditor;
+class ScrollScale;
+
+//---------------------------------------------------------
+// Master
+//---------------------------------------------------------
+
+class Master : public View {
+ enum DragMode { DRAG_OFF, DRAG_NEW, DRAG_MOVE_START, DRAG_MOVE,
+ DRAG_DELETE, DRAG_COPY_START, DRAG_COPY,
+ DRAG_RESIZE, DRAG_LASSO_START, DRAG_LASSO
+ };
+ ScrollScale* vscroll;
+ unsigned pos[3];
+ QPoint start;
+ Tool tool;
+ DragMode drag;
+ MidiEditor* editor;
+
+ Q_OBJECT
+ virtual void pdraw(QPainter&, const QRect&);
+ virtual void viewMouseMoveEvent(QMouseEvent* event);
+ virtual void leaveEvent(QEvent*e);
+ virtual void viewMousePressEvent(QMouseEvent* event);
+ virtual void viewMouseReleaseEvent(QMouseEvent*);
+
+ void draw(QPainter&, const QRect&);
+ void newVal(int x1, int x2, int y);
+ bool deleteVal1(unsigned int x1, unsigned int x2);
+ void deleteVal(int x1, int x2);
+
+ signals:
+ void followEvent(int);
+ void xposChanged(int);
+ void yposChanged(int);
+ void timeChanged(unsigned);
+ void tempoChanged(int);
+
+ public slots:
+ void setPos(int, unsigned, bool adjustScrollbar);
+ void setTool(int t);
+
+ public:
+ Master(MidiEditor*, QWidget* parent, int xmag, int ymag);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/master/masteredit.cpp b/attic/muse2-oom/muse2/muse/master/masteredit.cpp
new file mode 100644
index 00000000..2b91ae90
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/master/masteredit.cpp
@@ -0,0 +1,406 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: masteredit.cpp,v 1.4.2.5 2009/07/01 22:14:56 spamatica Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "awl/sigedit.h"
+
+#include "masteredit.h"
+#include "mtscale.h"
+#include "hitscale.h"
+#include "sigscale.h"
+#include "scrollscale.h"
+#include "poslabel.h"
+#include "master.h"
+#include "utils.h"
+#include "tscale.h"
+#include "tempolabel.h"
+#include "xml.h"
+#include "lcombo.h"
+#include "doublelabel.h"
+///#include "sigedit.h"
+#include "globals.h"
+
+#include <values.h>
+
+#include <QActionGroup>
+#include <QCloseEvent>
+#include <QGridLayout>
+#include <QLabel>
+#include <QToolBar>
+#include <QToolButton>
+
+int MasterEdit::_rasterInit = 0;
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void MasterEdit::closeEvent(QCloseEvent* e)
+ {
+ emit deleted((unsigned long)this);
+ e->accept();
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void MasterEdit::songChanged(int type)
+ {
+ if (type & SC_TEMPO) {
+ int tempo = tempomap.tempo(song->cpos());
+ curTempo->blockSignals(true);
+ curTempo->setValue(double(60000000.0/tempo));
+
+ curTempo->blockSignals(false);
+ }
+ if (type & SC_SIG) {
+ int z, n;
+ AL::sigmap.timesig(song->cpos(), z, n);
+ curSig->blockSignals(true);
+ curSig->setValue(AL::TimeSignature(z, n));
+ curSig->blockSignals(false);
+ sign->redraw();
+ }
+ if (type & SC_MASTER) {
+ enableButton->blockSignals(true);
+ enableButton->setChecked(song->masterFlag());
+ enableButton->blockSignals(false);
+ }
+ }
+
+//---------------------------------------------------------
+// MasterEdit
+//---------------------------------------------------------
+
+MasterEdit::MasterEdit()
+ : MidiEditor(0, _rasterInit, 0)
+ {
+ setWindowTitle(tr("MusE: Mastertrack"));
+ _raster = 0; // measure
+ setMinimumSize(400, 300);
+ resize(500, 350);
+
+ //---------Pulldown Menu----------------------------
+// QPopupMenu* file = new QPopupMenu(this);
+// menuBar()->insertItem("&File", file);
+
+ //---------ToolBar----------------------------------
+
+ tools = addToolBar(tr("Master tools"));
+ tools->addActions(undoRedo->actions());
+
+ EditToolBar* tools2 = new EditToolBar(this, PointerTool | PencilTool | RubberTool);
+ addToolBar(tools2);
+
+ QToolBar* enableMaster = addToolBar(tr("Enable master"));
+ enableButton = new QToolButton();
+ enableButton->setCheckable(true);
+ enableButton->setText(tr("Enable"));
+ enableButton->setToolTip(tr("Enable usage of master track"));
+ enableButton->setChecked(song->masterFlag());
+ enableMaster->addWidget(enableButton);
+ connect(enableButton, SIGNAL(toggled(bool)), song, SLOT(setMasterFlag(bool)));
+
+ QToolBar* info = addToolBar(tr("Info"));
+ QLabel* label = new QLabel(tr("Cursor"));
+ label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+ label->setIndent(3);
+ info->addWidget(label);
+
+ cursorPos = new PosLabel(0);
+ cursorPos->setFixedHeight(22);
+ cursorPos->setToolTip(tr("time at cursor position"));
+ info->addWidget(cursorPos);
+ tempo = new TempoLabel(0);
+ tempo->setFixedHeight(22);
+ tempo->setToolTip(tr("tempo at cursor position"));
+ info->addWidget(tempo);
+
+ const char* rastval[] = {
+ QT_TRANSLATE_NOOP("@default", "Off"), "Bar", "1/2", "1/4", "1/8", "1/16"
+ };
+ rasterLabel = new LabelCombo(tr("Snap"), 0);
+ rasterLabel->setFocusPolicy(Qt::NoFocus);
+ for (int i = 0; i < 6; i++)
+ rasterLabel->insertItem(i, tr(rastval[i]));
+ rasterLabel->setCurrentIndex(1);
+ info->addWidget(rasterLabel);
+ connect(rasterLabel, SIGNAL(activated(int)), SLOT(_setRaster(int)));
+
+ //---------values for current position---------------
+ info->addWidget(new QLabel(tr("CurPos ")));
+ curTempo = new TempoEdit(0);
+ curSig = new SigEdit(0);
+ curSig->setValue(AL::TimeSignature(4, 4));
+ curTempo->setToolTip(tr("tempo at current position"));
+ curSig->setToolTip(tr("time signature at current position"));
+ info->addWidget(curTempo);
+ info->addWidget(curSig);
+ ///connect(curSig, SIGNAL(valueChanged(int,int)), song, SLOT(setSig(int,int)));
+ connect(curSig, SIGNAL(valueChanged(const AL::TimeSignature&)), song, SLOT(setSig(const AL::TimeSignature&)));
+
+ ///connect(curTempo, SIGNAL(valueChanged(double)), song, SLOT(setTempo(double)));
+ connect(curTempo, SIGNAL(tempoChanged(double)), song, SLOT(setTempo(double)));
+
+ //---------------------------------------------------
+ // master
+ //---------------------------------------------------
+
+ int xscale = -20;
+ int yscale = -500;
+ hscroll = new ScrollScale(-100, -2, xscale, song->len(), Qt::Horizontal, mainw);
+ vscroll = new ScrollScale(-1000, -100, yscale, 120000, Qt::Vertical, mainw);
+ vscroll->setRange(30000, 250000);
+ time1 = new MTScale(&_raster, mainw, xscale);
+ sign = new SigScale(&_raster, mainw, xscale);
+// thits = new HitScale(&_raster, mainw, xscale);
+
+ canvas = new Master(this, mainw, xscale, yscale);
+
+// zhits = new HitScale(&_raster, mainw, xscale);
+ time2 = new MTScale(&_raster, mainw, xscale);
+ tscale = new TScale(mainw, yscale);
+ time2->setBarLocator(true);
+
+ //---------------------------------------------------
+ // Rest
+ //---------------------------------------------------
+
+// QSizeGrip* corner = new QSizeGrip(mainw);
+
+ mainGrid->setRowStretch(5, 100);
+ mainGrid->setColumnStretch(1, 100);
+
+ mainGrid->addWidget(hLine(mainw), 0, 1);
+ mainGrid->addWidget(time1, 1, 1);
+ mainGrid->addWidget(hLine(mainw), 2, 1);
+ mainGrid->addWidget(sign, 3, 1);
+ mainGrid->addWidget(hLine(mainw), 4, 1);
+// mainGrid->addWidget(thits, 5, 1);
+// mainGrid->addWidget(hLine(mainw), 6, 1);
+ mainGrid->addWidget(canvas, 5, 1);
+ mainGrid->addWidget(tscale, 5, 0);
+ mainGrid->addWidget(hLine(mainw), 6, 1);
+// mainGrid->addWidget(zhits, 9, 1);
+// mainGrid->addWidget(hLine(mainw), 7, 1);
+ mainGrid->addWidget(time2, 7, 1);
+ mainGrid->addWidget(hscroll, 8, 1);
+ mainGrid->addWidget(vscroll, 0, 2, 10, 1);
+// mainGrid->addWidget(corner, 9, 2, AlignBottom | AlignRight);
+
+ canvas->setFocus(); // Tim.
+
+ connect(tools2, SIGNAL(toolChanged(int)), canvas, SLOT(setTool(int)));
+ connect(vscroll, SIGNAL(scrollChanged(int)), canvas, SLOT(setYPos(int)));
+ connect(vscroll, SIGNAL(scaleChanged(int)), canvas, SLOT(setYMag(int)));
+
+ connect(vscroll, SIGNAL(scrollChanged(int)), tscale, SLOT(setYPos(int)));
+ connect(vscroll, SIGNAL(scaleChanged(int)), tscale, SLOT(setYMag(int)));
+
+ connect(hscroll, SIGNAL(scrollChanged(int)), time1, SLOT(setXPos(int)));
+ connect(hscroll, SIGNAL(scrollChanged(int)), sign, SLOT(setXPos(int)));
+// connect(hscroll, SIGNAL(scrollChanged(int)), thits, SLOT(setXPos(int)));
+ connect(hscroll, SIGNAL(scrollChanged(int)), canvas, SLOT(setXPos(int)));
+// connect(hscroll, SIGNAL(scrollChanged(int)), zhits, SLOT(setXPos(int)));
+ connect(hscroll, SIGNAL(scrollChanged(int)), time2, SLOT(setXPos(int)));
+
+ connect(hscroll, SIGNAL(scaleChanged(int)), time1, SLOT(setXMag(int)));
+ connect(hscroll, SIGNAL(scaleChanged(int)), sign, SLOT(setXMag(int)));
+// connect(hscroll, SIGNAL(scaleChanged(int)), thits, SLOT(setXMag(int)));
+ connect(hscroll, SIGNAL(scaleChanged(int)), canvas, SLOT(setXMag(int)));
+// connect(hscroll, SIGNAL(scaleChanged(int)), zhits, SLOT(setXMag(int)));
+ connect(hscroll, SIGNAL(scaleChanged(int)), time2, SLOT(setXMag(int)));
+
+ connect(time1, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
+// connect(sign, SIGNAL(timeChanged(unsigned)), pos, SLOT(setValue(unsigned)));
+// connect(thits, SIGNAL(timeChanged(unsigned)), pos, SLOT(setValue(unsigned)));
+// connect(canvas, SIGNAL(timeChanged(unsigned)), pos, SLOT(setValue(unsigned)));
+// connect(zhits, SIGNAL(timeChanged(unsigned)), pos, SLOT(setValue(unsigned)));
+ connect(time2, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
+
+ connect(tscale, SIGNAL(tempoChanged(int)), SLOT(setTempo(int)));
+ connect(canvas, SIGNAL(tempoChanged(int)), SLOT(setTempo(int)));
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+ connect(song, SIGNAL(posChanged(int,unsigned,bool)), SLOT(posChanged(int,unsigned,bool)));
+
+ connect(canvas, SIGNAL(followEvent(int)), hscroll, SLOT(setOffset(int)));
+ connect(canvas, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
+ }
+
+//---------------------------------------------------------
+// ~MasterEdit
+//---------------------------------------------------------
+
+MasterEdit::~MasterEdit()
+ {
+ //undoRedo->removeFrom(tools); // p4.0.6 Removed
+ }
+
+//---------------------------------------------------------
+// readStatus
+//---------------------------------------------------------
+
+void MasterEdit::readStatus(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "midieditor")
+ MidiEditor::readStatus(xml);
+ else if (tag == "ypos")
+ vscroll->setPos(xml.parseInt());
+ else if (tag == "ymag") {
+ // vscroll->setMag(xml.parseInt());
+ int mag = xml.parseInt();
+ vscroll->setMag(mag);
+ }
+ else
+ xml.unknown("MasterEdit");
+ break;
+ case Xml::TagEnd:
+ if (tag == "master") {
+ // raster setzen
+ int item = 0;
+ switch(_raster) {
+ case 1: item = 0; break;
+ case 0: item = 1; break;
+ case 768: item = 2; break;
+ case 384: item = 3; break;
+ case 192: item = 4; break;
+ case 96: item = 5; break;
+ }
+ _rasterInit = _raster;
+ rasterLabel->setCurrentIndex(item);
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// writeStatus
+//---------------------------------------------------------
+
+void MasterEdit::writeStatus(int level, Xml& xml) const
+ {
+ xml.tag(level++, "master");
+ xml.intTag(level, "ypos", vscroll->pos());
+ xml.intTag(level, "ymag", vscroll->mag());
+ MidiEditor::writeStatus(level, xml);
+ xml.tag(level, "/master");
+ }
+
+//---------------------------------------------------------
+// readConfiguration
+//---------------------------------------------------------
+
+void MasterEdit::readConfiguration(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "raster")
+ _rasterInit = xml.parseInt();
+ else
+ xml.unknown("MasterEdit");
+ break;
+ case Xml::TagEnd:
+ if (tag == "masteredit")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// writeConfiguration
+//---------------------------------------------------------
+
+void MasterEdit::writeConfiguration(int level, Xml& xml)
+ {
+ xml.tag(level++, "masteredit");
+ xml.intTag(level, "raster", _rasterInit);
+ xml.tag(level, "/masteredit");
+ }
+
+//---------------------------------------------------------
+// _setRaster
+//---------------------------------------------------------
+
+void MasterEdit::_setRaster(int index)
+ {
+ static int rasterTable[] = {
+ 1, 0, 768, 384, 192, 96
+ };
+ _raster = rasterTable[index];
+ _rasterInit = _raster;
+ }
+
+//---------------------------------------------------------
+// posChanged
+//---------------------------------------------------------
+
+void MasterEdit::posChanged(int idx, unsigned val, bool)
+ {
+ if (idx == 0) {
+ int z, n;
+ int tempo = tempomap.tempo(val);
+ AL::sigmap.timesig(val, z, n);
+ curTempo->blockSignals(true);
+ curSig->blockSignals(true);
+
+ curTempo->setValue(double(60000000.0/tempo));
+ curSig->setValue(AL::TimeSignature(z, n));
+
+ curTempo->blockSignals(false);
+ curSig->blockSignals(false);
+ }
+ }
+
+//---------------------------------------------------------
+// setTime
+//---------------------------------------------------------
+
+void MasterEdit::setTime(unsigned tick)
+ {
+ if (tick == MAXINT)
+ cursorPos->setEnabled(false);
+ else {
+ cursorPos->setEnabled(true);
+ cursorPos->setValue(tick);
+ time1->setPos(3, tick, false);
+ time2->setPos(3, tick, false);
+ }
+ }
+
+//---------------------------------------------------------
+// setTempo
+//---------------------------------------------------------
+
+void MasterEdit::setTempo(int val)
+ {
+ if (val == -1)
+ tempo->setEnabled(false);
+ else {
+ tempo->setEnabled(true);
+ tempo->setValue(val);
+ }
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/master/masteredit.h b/attic/muse2-oom/muse2/muse/master/masteredit.h
new file mode 100644
index 00000000..af43c7b0
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/master/masteredit.h
@@ -0,0 +1,86 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: masteredit.h,v 1.3.2.2 2009/04/01 01:37:11 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MASTER_EDIT_H__
+#define __MASTER_EDIT_H__
+
+#include "midieditor.h"
+#include "noteinfo.h"
+#include "cobject.h"
+
+namespace Awl {
+ class SigEdit;
+ };
+using Awl::SigEdit;
+
+class QCloseEvent;
+class QToolBar;
+class QToolButton;
+
+class Master;
+class ScrollScale;
+class MTScale;
+class SigScale;
+class HitScale;
+class TScale;
+class TempoEdit;
+class LabelCombo;
+class PosLabel;
+class TempoLabel;
+
+//---------------------------------------------------------
+// MasterEdit
+//---------------------------------------------------------
+
+class MasterEdit : public MidiEditor {
+ Master* canvas;
+ ScrollScale* hscroll;
+ ScrollScale* vscroll;
+ MTScale* time1;
+ MTScale* time2;
+ SigScale* sign;
+ HitScale* thits;
+ HitScale* zhits;
+ TScale* tscale;
+
+ TempoEdit* curTempo;
+ SigEdit* curSig;
+ LabelCombo* rasterLabel;
+ QToolBar* tools;
+ PosLabel* cursorPos;
+ TempoLabel* tempo;
+ QToolButton* enableButton;
+
+ static int _rasterInit;
+
+ Q_OBJECT
+ virtual void closeEvent(QCloseEvent*);
+
+ private slots:
+ void _setRaster(int);
+ void posChanged(int,unsigned,bool);
+ void setTime(unsigned);
+ void setTempo(int);
+
+ public slots:
+ void songChanged(int);
+// void tempoChanged(double);
+
+ signals:
+ void deleted(unsigned long);
+
+ public:
+ MasterEdit();
+ ~MasterEdit();
+ virtual void readStatus(Xml&);
+ virtual void writeStatus(int, Xml&) const;
+ static void readConfiguration(Xml&);
+ static void writeConfiguration(int, Xml&);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/master/tscale.cpp b/attic/muse2-oom/muse2/muse/master/tscale.cpp
new file mode 100644
index 00000000..d37d5924
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/master/tscale.cpp
@@ -0,0 +1,61 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: tscale.cpp,v 1.2 2003/12/17 11:04:14 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include "tscale.h"
+#include "globals.h"
+#include "gconfig.h"
+
+#include <QMouseEvent>
+#include <QPainter>
+
+//---------------------------------------------------------
+// TScale
+//---------------------------------------------------------
+
+TScale::TScale(QWidget* parent, int ymag)
+ : View(parent, 1, ymag)
+ {
+ setFont(config.fonts[3]);
+ int w = 4 * QFontMetrics(config.fonts[4]).width('0');
+ setFixedWidth(w);
+ setMouseTracking(true);
+ }
+
+//---------------------------------------------------------
+// draw
+//---------------------------------------------------------
+
+void TScale::pdraw(QPainter& p, const QRect& r)
+ {
+ int y = r.y();
+ int h = r.height();
+ p.setFont(config.fonts[4]);
+ QString s;
+ for (int i = 30000; i <= 250000; i += 10000) {
+ int yy = mapy(280000 - i);
+ if (yy < y)
+ break;
+ if (yy-15 > y+h)
+ continue;
+ p.drawLine(0, yy, width(), yy);
+ s.setNum(i/1000);
+ QFontMetrics fm(config.fonts[4]);
+ p.drawText(width() - fm.width(s) - 1, yy-2, s);
+ }
+ }
+
+void TScale::viewMouseMoveEvent(QMouseEvent* event)
+ {
+ emit tempoChanged(280000 - event->y());
+ }
+
+void TScale::leaveEvent(QEvent*)
+ {
+ emit tempoChanged(-1);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/master/tscale.h b/attic/muse2-oom/muse2/muse/master/tscale.h
new file mode 100644
index 00000000..35fa39f2
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/master/tscale.h
@@ -0,0 +1,35 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: tscale.h,v 1.1.1.1 2003/10/27 18:52:36 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __TSCALE_H__
+#define __TSCALE_H__
+
+#include "view.h"
+
+//---------------------------------------------------------
+// Tscale
+//---------------------------------------------------------
+
+class TScale : public View {
+ double curTempo;
+ Q_OBJECT
+
+ virtual void viewMouseMoveEvent(QMouseEvent* event);
+ virtual void leaveEvent(QEvent*e);
+
+ protected:
+ virtual void pdraw(QPainter&, const QRect&);
+
+ signals:
+ void tempoChanged(int);
+
+ public:
+ TScale(QWidget*, int);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/memory.cpp b/attic/muse2-oom/muse2/muse/memory.cpp
new file mode 100644
index 00000000..6a5b5c0c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/memory.cpp
@@ -0,0 +1,100 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: memory.cpp,v 1.1.1.1.2.2 2009/12/19 23:35:39 spamatica Exp $
+//
+// (C) Copyright 2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "memory.h"
+
+Pool audioRTmemoryPool;
+Pool midiRTmemoryPool;
+
+//---------------------------------------------------------
+// Pool
+//---------------------------------------------------------
+
+Pool::Pool()
+ {
+ for (int idx = 0; idx < dimension; ++idx) {
+ head[idx] = 0;
+ chunks[idx] = 0;
+ grow(idx); // preallocate
+ }
+ }
+
+//---------------------------------------------------------
+// ~Pool
+//---------------------------------------------------------
+
+Pool::~Pool()
+ {
+ for (int i = 0; i < dimension; ++i) {
+ Chunk* n = chunks[i];
+ while (n) {
+ Chunk* p = n;
+ n = n->next;
+ delete p;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// grow
+//---------------------------------------------------------
+
+void Pool::grow(int idx)
+ {
+// printf("grow memory idx %d\n", idx);
+
+ int esize = (idx+1) * sizeof(unsigned long);
+
+ Chunk* n = new Chunk;
+ n->next = chunks[idx];
+ chunks[idx] = n;
+
+ const int nelem = Chunk::size / esize;
+ char* start = n->mem;
+ char* last = &start[(nelem-1) * esize];
+
+ for (char* p = start; p < last; p += esize)
+ reinterpret_cast<Verweis*>(p)->next =
+ reinterpret_cast<Verweis*>(p + esize);
+ reinterpret_cast<Verweis*>(last)->next = 0;
+ head[idx] = reinterpret_cast<Verweis*>(start);
+ }
+
+
+#ifdef TEST
+//=========================================================
+// TEST
+//=========================================================
+
+struct mops {
+ char a, c;
+ int b;
+ mops(int x) : b(x) {}
+ };
+
+typedef std::list<struct mops, RTalloc<struct mops> > List;
+// typedef std::vector<struct mops> List;
+typedef List::iterator iList;
+
+//---------------------------------------------------------
+// main
+// 2.8 s normal 0.7 vector
+// 2.5 s RTalloc
+// 1.18 alle optimierungen (0.97)
+//---------------------------------------------------------
+
+int main()
+ {
+ List l;
+
+ for (int i = 0; i < 10000000; ++i)
+ l.push_back(mops(i));
+ return 0;
+ }
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/memory.h b/attic/muse2-oom/muse2/muse/memory.h
new file mode 100644
index 00000000..e2ffb150
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/memory.h
@@ -0,0 +1,180 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: memory.h,v 1.4.2.3 2009/12/15 22:08:50 spamatica Exp $
+//
+// (C) Copyright 2003-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MEMORY_H__
+#define __MEMORY_H__
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <map>
+
+// most of the following code is based on examples
+// from Bjarne Stroustrup: "Die C++ Programmiersprache"
+
+//---------------------------------------------------------
+// Pool
+//---------------------------------------------------------
+
+class Pool {
+ struct Verweis {
+ Verweis* next;
+ };
+ struct Chunk {
+ enum { size = 4 * 1024 };
+ Chunk* next;
+ char mem[size];
+ };
+ enum { dimension = 21 };
+ Chunk* chunks[dimension];
+ Verweis* head[dimension];
+ Pool(Pool&);
+ void operator=(Pool&);
+ void grow(int idx);
+
+ public:
+ Pool();
+ ~Pool();
+ void* alloc(size_t n);
+ void free(void* b, size_t n);
+ };
+
+//---------------------------------------------------------
+// alloc
+//---------------------------------------------------------
+
+inline void* Pool::alloc(size_t n)
+ {
+ if (n == 0)
+ return 0;
+ int idx = ((n + sizeof(unsigned long) - 1) / sizeof(unsigned long)) - 1;
+ if (idx >= dimension) {
+ printf("panic: alloc %zd %d %d\n", n, idx, dimension);
+ exit(-1);
+ }
+ if (head[idx] == 0)
+ grow(idx);
+ Verweis* p = head[idx];
+ head[idx] = p->next;
+ return p;
+ }
+
+//---------------------------------------------------------
+// free
+//---------------------------------------------------------
+
+inline void Pool::free(void* b, size_t n)
+ {
+ if (b == 0 || n == 0)
+ return;
+ int idx = ((n + sizeof(unsigned long) - 1) / sizeof(unsigned long)) - 1;
+ if (idx >= dimension) {
+ printf("panic: free %zd %d %d\n", n, idx, dimension);
+ exit(-1);
+ }
+ Verweis* p = static_cast<Verweis*>(b);
+ p->next = head[idx];
+ head[idx] = p;
+ }
+
+extern Pool audioRTmemoryPool;
+extern Pool midiRTmemoryPool;
+
+//---------------------------------------------------------
+// audioRTalloc
+//---------------------------------------------------------
+
+template <class T> class audioRTalloc
+ {
+ public:
+ typedef T value_type;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+
+ typedef T* pointer;
+ typedef const T* const_pointer;
+
+ typedef T& reference;
+ typedef const T& const_reference;
+
+ pointer address(reference x) const { return &x; }
+ const_pointer address(const_reference x) const { return &x; }
+
+ audioRTalloc();
+ template <class U> audioRTalloc(const audioRTalloc<U>&) {}
+ ~audioRTalloc() {}
+
+ pointer allocate(size_type n, void * = 0) {
+ return static_cast<T*>(audioRTmemoryPool.alloc(n * sizeof(T)));
+ }
+ void deallocate(pointer p, size_type n) {
+ audioRTmemoryPool.free(p, n * sizeof(T));
+ }
+
+ audioRTalloc<T>& operator=(const audioRTalloc&) { return *this; }
+ void construct(pointer p, const T& val) {
+ new ((T*) p) T(val);
+ }
+ void destroy(pointer p) {
+ p->~T();
+ }
+ size_type max_size() const { return size_t(-1); }
+
+ template <class U> struct rebind { typedef audioRTalloc<U> other; };
+ template <class U> audioRTalloc& operator=(const audioRTalloc<U>&) { return *this; }
+ };
+
+template <class T> audioRTalloc<T>::audioRTalloc() {}
+
+//---------------------------------------------------------
+// midiRTalloc
+//---------------------------------------------------------
+
+template <class T> class midiRTalloc
+ {
+ public:
+ typedef T value_type;
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+
+ typedef T* pointer;
+ typedef const T* const_pointer;
+
+ typedef T& reference;
+ typedef const T& const_reference;
+
+ pointer address(reference x) const { return &x; }
+ const_pointer address(const_reference x) const { return &x; }
+
+ midiRTalloc();
+ template <class U> midiRTalloc(const midiRTalloc<U>&) {}
+ ~midiRTalloc() {}
+
+ pointer allocate(size_type n, void * = 0) {
+ return static_cast<T*>(midiRTmemoryPool.alloc(n * sizeof(T)));
+ }
+ void deallocate(pointer p, size_type n) {
+ midiRTmemoryPool.free(p, n * sizeof(T));
+ }
+
+ midiRTalloc<T>& operator=(const midiRTalloc&) { return *this; }
+ void construct(pointer p, const T& val) {
+ new ((T*) p) T(val);
+ }
+ void destroy(pointer p) {
+ p->~T();
+ }
+ size_type max_size() const { return size_t(-1); }
+
+ template <class U> struct rebind { typedef midiRTalloc<U> other; };
+ template <class U> midiRTalloc& operator=(const midiRTalloc<U>&) { return *this; }
+ };
+
+template <class T> midiRTalloc<T>::midiRTalloc() {}
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/midi.cpp b/attic/muse2-oom/muse2/muse/midi.cpp
new file mode 100644
index 00000000..e339f29b
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midi.cpp
@@ -0,0 +1,1550 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midi.cpp,v 1.43.2.22 2009/11/09 20:28:28 terminator356 Exp $
+//
+// (C) Copyright 1999/2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <cmath>
+#include <errno.h>
+#include <values.h>
+#include <assert.h>
+
+#include "song.h"
+#include "midi.h"
+#include "drummap.h"
+//#include "midiedit/drummap.h" // p4.0.2
+#include "event.h"
+#include "globals.h"
+#include "midictrl.h"
+#include "marker/marker.h"
+#include "midiport.h"
+#include "midictrl.h"
+#include "audio.h"
+#include "mididev.h"
+#include "driver/alsamidi.h"
+#include "driver/jackmidi.h"
+#include "wave.h"
+#include "synth.h"
+#include "sync.h"
+#include "midiseq.h"
+#include "gconfig.h"
+#include "ticksynth.h"
+
+extern void dump(const unsigned char* p, int n);
+
+const unsigned char gmOnMsg[] = { 0x7e, 0x7f, 0x09, 0x01 };
+const unsigned char gsOnMsg[] = { 0x41, 0x10, 0x42, 0x12, 0x40, 0x00, 0x7f, 0x00, 0x41 };
+const unsigned char gsOnMsg2[] = { 0x41, 0x10, 0x42, 0x12, 0x40, 0x01, 0x33, 0x50, 0x3c };
+const unsigned char gsOnMsg3[] = { 0x41, 0x10, 0x42, 0x12, 0x40, 0x01, 0x34, 0x50, 0x3b };
+const unsigned char xgOnMsg[] = { 0x43, 0x10, 0x4c, 0x00, 0x00, 0x7e, 0x00 };
+const unsigned int gmOnMsgLen = sizeof(gmOnMsg);
+const unsigned int gsOnMsgLen = sizeof(gsOnMsg);
+const unsigned int gsOnMsg2Len = sizeof(gsOnMsg2);
+const unsigned int gsOnMsg3Len = sizeof(gsOnMsg3);
+const unsigned int xgOnMsgLen = sizeof(xgOnMsg);
+
+const unsigned char mmcDeferredPlayMsg[] = { 0x7f, 0x7f, 0x06, 0x03 };
+const unsigned char mmcStopMsg[] = { 0x7f, 0x7f, 0x06, 0x01 };
+const unsigned char mmcLocateMsg[] = { 0x7f, 0x7f, 0x06, 0x44, 0x06, 0x01, 0, 0, 0, 0, 0 };
+
+const unsigned int mmcDeferredPlayMsgLen = sizeof(mmcDeferredPlayMsg);
+const unsigned int mmcStopMsgLen = sizeof(mmcStopMsg);
+const unsigned int mmcLocateMsgLen = sizeof(mmcLocateMsg);
+
+#define CALC_TICK(the_tick) lrintf((float(the_tick) * float(config.division) + float(div/2)) / float(div));
+/*---------------------------------------------------------
+ * midi_meta_name
+ *---------------------------------------------------------*/
+
+QString midiMetaName(int meta)
+ {
+ const char* s = "";
+ switch (meta) {
+ case 0: s = "Sequence Number"; break;
+ case 1: s = "Text Event"; break;
+ case 2: s = "Copyright"; break;
+ case 3: s = "Sequence/Track Name"; break;
+ case 4: s = "Instrument Name"; break;
+ case 5: s = "Lyric"; break;
+ case 6: s = "Marker"; break;
+ case 7: s = "Cue Point"; break;
+ case 8:
+ case 9:
+ case 0x0a:
+ case 0x0b:
+ case 0x0c:
+ case 0x0d:
+ case 0x0e:
+ case 0x0f: s = "Text"; break;
+ case 0x20: s = "Channel Prefix"; break;
+ case 0x21: s = "Port Change"; break;
+ case 0x2f: s = "End of Track"; break;
+ case 0x51: s = "Set Tempo"; break;
+ case 0x54: s = "SMPTE Offset"; break;
+ case 0x58: s = "Time Signature"; break;
+ case 0x59: s = "Key Signature"; break;
+ case 0x74: s = "Sequencer-Specific1"; break;
+ case 0x7f: s = "Sequencer-Specific2"; break;
+ default:
+ break;
+ }
+ return QString(s);
+ }
+
+//---------------------------------------------------------
+// QString nameSysex
+//---------------------------------------------------------
+
+QString nameSysex(unsigned int len, const unsigned char* buf)
+ {
+ QString s;
+ if(len == 0)
+ return s;
+ switch(buf[0]) {
+ case 0x00:
+ if(len < 3)
+ return s;
+ if (buf[1] == 0 && buf[2] == 0x41)
+ s = "Microsoft";
+ break;
+ case 0x01: s = "Sequential Circuits: "; break;
+ case 0x02: s = "Big Briar: "; break;
+ case 0x03: s = "Octave / Plateau: "; break;
+ case 0x04: s = "Moog: "; break;
+ case 0x05: s = "Passport Designs: "; break;
+ case 0x06: s = "Lexicon: "; break;
+ case 0x07: s = "Kurzweil"; break;
+ case 0x08: s = "Fender"; break;
+ case 0x09: s = "Gulbransen"; break;
+ case 0x0a: s = "Delta Labas"; break;
+ case 0x0b: s = "Sound Comp."; break;
+ case 0x0c: s = "General Electro"; break;
+ case 0x0d: s = "Techmar"; break;
+ case 0x0e: s = "Matthews Research"; break;
+ case 0x10: s = "Oberheim"; break;
+ case 0x11: s = "PAIA: "; break;
+ case 0x12: s = "Simmons: "; break;
+ case 0x13: s = "DigiDesign"; break;
+ case 0x14: s = "Fairlight: "; break;
+ case 0x15: s = "JL Cooper"; break;
+ case 0x16: s = "Lowery"; break;
+ case 0x17: s = "Lin"; break;
+ case 0x18: s = "Emu"; break;
+ case 0x1b: s = "Peavy"; break;
+ case 0x20: s = "Bon Tempi: "; break;
+ case 0x21: s = "S.I.E.L: "; break;
+ case 0x23: s = "SyntheAxe: "; break;
+ case 0x24: s = "Hohner"; break;
+ case 0x25: s = "Crumar"; break;
+ case 0x26: s = "Solton"; break;
+ case 0x27: s = "Jellinghaus Ms"; break;
+ case 0x28: s = "CTS"; break;
+ case 0x29: s = "PPG"; break;
+ case 0x2f: s = "Elka"; break;
+ case 0x36: s = "Cheetah"; break;
+ case 0x3e: s = "Waldorf"; break;
+ case 0x40: s = "Kawai: "; break;
+ case 0x41: s = "Roland: "; break;
+ case 0x42: s = "Korg: "; break;
+ case 0x43: s = "Yamaha: "; break;
+ case 0x44: s = "Casio"; break;
+ case 0x45: s = "Akai"; break;
+ case 0x7c: s = "MusE Soft Synth"; break;
+ case 0x7d: s = "Educational Use"; break;
+ case 0x7e: s = "Universal: Non Real Time"; break;
+ case 0x7f: s = "Universal: Real Time"; break;
+ default: s = "??: "; break;
+ }
+ //
+ // following messages should not show up in event list
+ // they are filtered while importing midi files
+ //
+ if ((len == gmOnMsgLen) && memcmp(buf, gmOnMsg, gmOnMsgLen) == 0)
+ s += "GM-ON";
+ else if ((len == gsOnMsgLen) && memcmp(buf, gsOnMsg, gsOnMsgLen) == 0)
+ s += "GS-ON";
+ else if ((len == xgOnMsgLen) && memcmp(buf, xgOnMsg, xgOnMsgLen) == 0)
+ s += "XG-ON";
+ return s;
+ }
+
+//---------------------------------------------------------
+// buildMidiEventList
+// TODO:
+// parse data increment/decrement controller
+// NRPN/RPN fine/course data 7/14 Bit
+// must we set datah/datal to zero after change
+// of NRPN/RPN register?
+// generally: how to handle incomplete messages
+//---------------------------------------------------------
+
+void buildMidiEventList(EventList* del, const MPEventList* el, MidiTrack* track,
+ int div, bool addSysexMeta, bool doLoops)
+ {
+ int hbank = 0xff;
+ int lbank = 0xff;
+ int rpnh = -1;
+ int rpnl = -1;
+ int datah = 0;
+ int datal = 0;
+ int dataType = 0; // 0 : disabled, 0x20000 : rpn, 0x30000 : nrpn
+
+ EventList mel;
+
+ for (iMPEvent i = el->begin(); i != el->end(); ++i) {
+ MidiPlayEvent ev = *i;
+ if (!addSysexMeta && (ev.type() == ME_SYSEX || ev.type() == ME_META))
+ continue;
+ if (!(ev.type() == ME_SYSEX || ev.type() == ME_META
+ || ((ev.channel() == track->outChannel()) && (ev.port() == track->outPort()))))
+ continue;
+ unsigned tick = ev.time();
+ // Added by Tim. p3.3.8
+
+ // Added by T356.
+ if(doLoops)
+ {
+ if(tick >= song->lPos().tick() && tick < song->rPos().tick())
+ {
+ int loopn = ev.loopNum();
+ int loopc = audio->loopCount();
+ int cmode = song->cycleMode(); // CYCLE_NORMAL, CYCLE_MIX, CYCLE_REPLACE
+ // If we want REPLACE and the event was recorded in a previous loop,
+ // just ignore it. This will effectively ignore ALL previous loop events inside
+ // the left and right markers, regardless of where recording was started or stopped.
+ // We want to keep any loop 0 note-offs from notes which crossed over the left marker.
+ // To avoid more searching here, just keep ALL note-offs from loop 0, and let code below
+ // sort out and keep which ones had note-ons.
+ if(!(ev.isNoteOff() && loopn == 0))
+ {
+ if(cmode == Song::CYCLE_REPLACE && loopn < loopc)
+ {
+ // Added by Tim. p3.3.8
+ //printf("buildMidiEventList: CYCLE_REPLACE t:%d type:%d A:%d B:%d ln:%d lc:%d\n", tick, ev.type(), ev.dataA(), ev.dataB(), loopn, loopc);
+
+ continue;
+ }
+ // If we want NORMAL, same as REPLACE except keep all events from the previous loop
+ // from rec stop position to right marker (and beyond).
+ if(cmode == Song::CYCLE_NORMAL)
+ {
+ // Not sure of accuracy here. Adjust? Adjusted when used elsewhere?
+ unsigned endRec = audio->getEndRecordPos().tick();
+ if((tick < endRec && loopn < loopc) || (tick >= endRec && loopn < (loopc - 1)))
+ {
+ // Added by Tim. p3.3.8
+ //printf("buildMidiEventList: CYCLE_NORMAL t:%d type:%d A:%d B:%d ln:%d lc:%d\n", tick, ev.type(), ev.dataA(), ev.dataB(), loopn, loopc);
+
+ continue;
+ }
+ }
+ }
+ }
+ }
+
+ Event e;
+ switch(ev.type()) {
+ case ME_NOTEON:
+ e.setType(Note);
+
+ if (track->type() == Track::DRUM) {
+ int instr = drumInmap[ev.dataA()];
+ e.setPitch(instr);
+ }
+ else
+ {
+ e.setPitch(ev.dataA());
+ }
+
+ e.setVelo(ev.dataB());
+ e.setLenTick(0);
+ break;
+ case ME_NOTEOFF:
+ e.setType(Note);
+ if (track->type() == Track::DRUM) {
+ int instr = drumInmap[ev.dataA()];
+ e.setPitch(instr);
+ }
+ else
+ e.setPitch(ev.dataA());
+ e.setVelo(0);
+ e.setVeloOff(ev.dataB());
+ e.setLenTick(0);
+ break;
+ case ME_POLYAFTER:
+ e.setType(PAfter);
+ e.setA(ev.dataA());
+ e.setB(ev.dataB());
+ break;
+ case ME_CONTROLLER:
+ {
+ int val = ev.dataB();
+ switch(ev.dataA()) {
+ case CTRL_HBANK:
+ hbank = val;
+ break;
+
+ case CTRL_LBANK:
+ lbank = val;
+ break;
+
+ case CTRL_HDATA:
+ datah = val;
+ // check if a CTRL_LDATA follows
+ // e.g. wie have a 14 bit controller:
+ {
+ iMPEvent ii = i;
+ ++ii;
+ bool found = false;
+ for (; ii != el->end(); ++ii) {
+ MidiPlayEvent ev = *ii;
+ if (ev.type() == ME_CONTROLLER) {
+ if (ev.dataA() == CTRL_LDATA) {
+ // handle later
+ found = true;
+ }
+ break;
+ }
+ }
+ if (!found) {
+ if (rpnh == -1 || rpnl == -1) {
+ printf("parameter number not defined, data 0x%x\n", datah);
+ }
+ else {
+ int ctrl = dataType | (rpnh << 8) | rpnl;
+ e.setType(Controller);
+ e.setA(ctrl);
+ e.setB(datah);
+ }
+ }
+ }
+ break;
+
+ case CTRL_LDATA:
+ datal = val;
+
+ if (rpnh == -1 || rpnl == -1) {
+ printf("parameter number not defined, data 0x%x 0x%x, tick %d, channel %d\n",
+ datah, datal, tick, track->outChannel());
+ break;
+ }
+ // assume that the sequence is always
+ // CTRL_HDATA - CTRL_LDATA
+ // eg. that LDATA is always send last
+
+ e.setType(Controller);
+ // 14 Bit RPN/NRPN
+ e.setA((dataType+0x30000) | (rpnh << 8) | rpnl);
+ e.setB((datah << 7) | datal);
+ break;
+
+ case CTRL_HNRPN:
+ rpnh = val;
+ dataType = 0x30000;
+ break;
+
+ case CTRL_LNRPN:
+ rpnl = val;
+ dataType = 0x30000;
+ break;
+
+ case CTRL_HRPN:
+ rpnh = val;
+ dataType = 0x20000;
+ break;
+
+ case CTRL_LRPN:
+ rpnl = val;
+ dataType = 0x20000;
+ break;
+
+ default:
+ e.setType(Controller);
+ int ctl = ev.dataA();
+ e.setA(ctl);
+
+ if(track->type() == Track::DRUM)
+ {
+ // Is it a drum controller event, according to the track port's instrument?
+ MidiController *mc = midiPorts[track->outPort()].drumController(ctl);
+ if(mc)
+ // Store an index into the drum map.
+ e.setA((ctl & ~0xff) | drumInmap[ctl & 0x7f]);
+ }
+
+ e.setB(val);
+ break;
+ }
+ }
+ break;
+
+ case ME_PROGRAM:
+ e.setType(Controller);
+ e.setA(CTRL_PROGRAM);
+ e.setB((hbank << 16) | (lbank << 8) | ev.dataA());
+ break;
+
+ case ME_AFTERTOUCH:
+ e.setType(CAfter);
+ e.setA(ev.dataA());
+ break;
+
+ case ME_PITCHBEND:
+ e.setType(Controller);
+ e.setA(CTRL_PITCH);
+ e.setB(ev.dataA());
+ break;
+
+ case ME_SYSEX:
+ e.setType(Sysex);
+ e.setData(ev.data(), ev.len());
+ break;
+
+ case ME_META:
+ {
+ const unsigned char* data = ev.data();
+ switch (ev.dataA()) {
+ case 0x01: // Text
+ if (track->comment().isEmpty())
+ track->setComment(QString((const char*)data));
+ else
+ track->setComment(track->comment() + "\n" + QString((const char*)data));
+ break;
+ case 0x03: // Sequence-/TrackName
+ track->setName(QString((char*)data));
+ break;
+ case 0x6: // Marker
+ {
+ unsigned ltick = CALC_TICK(tick);//(tick * config.division + div/2) / div;
+ song->addMarker(QString((const char*)(data)), ltick, false);
+ }
+ break;
+ case 0x5: // Lyrics
+ case 0x8: // text
+ case 0x9:
+ case 0xa:
+ break;
+
+ case 0x0f: // Track Comment
+ track->setComment(QString((char*)data));
+ break;
+ case 0x51: // Tempo
+ {
+ unsigned tempo = data[2] + (data[1] << 8) + (data[0] <<16);
+ unsigned ltick = CALC_TICK(tick);// (unsigned(tick) * unsigned(config.division) + unsigned(div/2)) / unsigned(div);
+ // After ca 10 mins 32 bits will not be enough... This expression has to be changed/factorized or so in some "sane" way...
+ tempomap.addTempo(ltick, tempo);
+ }
+ break;
+ case 0x58: // Time Signature
+ {
+ int timesig_z = data[0];
+ int n = data[1];
+ int timesig_n = 1;
+ for (int i = 0; i < n; i++)
+ timesig_n *= 2;
+ int ltick = CALC_TICK(tick);//(tick * config.division + div/2) / div;
+ ///sigmap.add(ltick, timesig_z, timesig_n);
+ AL::sigmap.add(ltick, AL::TimeSignature(timesig_z, timesig_n));
+ }
+ break;
+ case 0x59: // Key Signature
+ // track->scale.set(data[0]);
+ // track->scale.setMajorMinor(data[1]);
+ break;
+ default:
+ printf("unknown Meta 0x%x %d\n", ev.dataA(), ev.dataA());
+ }
+ }
+ break;
+ } // switch(ev.type()
+ if (!e.empty()) {
+ e.setTick(tick);
+ // Added by Tim. p3.3.8
+ //printf("buildMidiEventList: mel adding t:%d type:%d A:%d B:%d C:%d\n", tick, e.type(), e.dataA(), e.dataB(), e.dataC());
+
+ mel.add(e);
+ }
+ } // i != el->end()
+
+ //---------------------------------------------------
+ // resolve NoteOff events
+ //---------------------------------------------------
+
+// for (iEvent i = mel.begin(); i != mel.end(); ++i) {
+// Event event = i->second;
+// if (event.isNote())
+// event.setLenTick(0);
+// }
+
+ // Added by Tim. p3.3.8
+
+ // The loop is a safe way to delete while iterating.
+ bool loop;
+ do
+ {
+ loop = false;
+
+ for (iEvent i = mel.begin(); i != mel.end(); ++i) {
+ Event ev = i->second;
+ if (ev.isNote()) {
+ if (ev.isNoteOff()) {
+ iEvent k;
+ bool found = false;
+ for (k = i; k != mel.end(); ++k) {
+ Event event = k->second;
+ if (event.tick() > ev.tick())
+ break;
+ if (event.isNoteOff(ev)) {
+ ev.setLenTick(1);
+ ev.setVelo(event.velo());
+ ev.setVeloOff(0);
+ // Added by Tim. p3.3.8
+ //printf("buildMidiEventList: found note off: event t:%d len:%d type:%d A:%d B:%d C:%d ev t:%d len:%d type:%d A:%d B:%d C:%d\n", event.tick(), event.lenTick(), event.type(), event.dataA(), event.dataB(), event.dataC(), ev.tick(), ev.lenTick(), ev.type(), ev.dataA(), ev.dataB(), ev.dataC());
+
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ printf("NOTE OFF without Note ON tick %d type %d %d %d\n",
+ ev.tick(), ev.type(), ev.pitch(), ev.velo());
+ }
+ else {
+ mel.erase(k);
+
+ // Changed by Tim. p3.3.8
+ //continue;
+ loop = true;
+ break;
+
+ }
+ }
+ // Added by Tim. p3.3.8
+
+ // If the event length is not zero, it means the event and its
+ // note on/off have already been taken care of. So ignore it.
+ if(ev.lenTick() != 0)
+ {
+ continue;
+ }
+
+ iEvent k;
+ for (k = mel.lower_bound(ev.tick()); k != mel.end(); ++k) {
+ Event event = k->second;
+ if (ev.isNoteOff(event)) {
+ int t = k->first - i->first;
+ if (t <= 0) {
+ if (debugMsg) {
+ printf("Note len is (%d-%d)=%d, set to 1\n",
+ k->first, i->first, k->first - i->first);
+ ev.dump();
+ event.dump();
+ }
+ t = 1;
+ }
+ ev.setLenTick(t);
+ ev.setVeloOff(event.veloOff());
+ // Added by Tim. p3.3.8
+ //printf("buildMidiEventList: set len and velOff: event t:%d len:%d type:%d A:%d B:%d C:%d ev t:%d len:%d type:%d A:%d B:%d C:%d\n", event.tick(), event.lenTick(), event.type(), event.dataA(), event.dataB(), event.dataC(), ev.tick(), ev.lenTick(), ev.type(), ev.dataA(), ev.dataB(), ev.dataC());
+
+ break;
+ }
+ }
+ if (k == mel.end()) {
+ printf("-no note-off! %d pitch %d velo %d\n",
+ ev.tick(), ev.pitch(), ev.velo());
+ //
+ // switch off at end of measure
+ //
+ int endTick = song->roundUpBar(ev.tick()+1);
+ ev.setLenTick(endTick-ev.tick());
+ }
+ else {
+ mel.erase(k);
+ // Added by Tim. p3.3.8
+ loop = true;
+ break;
+
+ }
+ }
+ }
+ }
+ while (loop);
+
+// DEBUG: any note offs left?
+
+ // Removed by Tim. p3.3.8
+ //for (iEvent i = mel.begin(); i != mel.end(); ++i) {
+ // Event ev = i->second;
+ // if (ev.isNoteOff()) {
+ // printf("+extra note-off! %d pitch %d velo %d\n",
+ // i->first, ev.pitch(), ev.velo());
+// ev.dump();
+ // }
+ // }
+
+ for (iEvent i = mel.begin(); i != mel.end(); ++i) {
+ Event ev = i->second;
+ if (ev.isNoteOff()) {
+ printf("+extra note-off! %d pitch %d velo %d\n",
+ i->first, ev.pitch(), ev.velo());
+// ev.dump();
+ continue;
+ }
+ int tick = CALC_TICK(ev.tick()); //(ev.tick() * config.division + div/2) / div;
+ if (ev.isNote()) {
+ int lenTick = CALC_TICK(ev.lenTick()); //(ev.lenTick() * config.division + div/2) / div;
+ ev.setLenTick(lenTick);
+ }
+ ev.setTick(tick);
+ del->add(ev);
+ }
+ }
+
+//---------------------------------------------------------
+// midiPortsChanged
+//---------------------------------------------------------
+
+void Audio::midiPortsChanged()
+ {
+ write(sigFd, "P", 1);
+ }
+
+//---------------------------------------------------------
+// sendLocalOff
+//---------------------------------------------------------
+
+void Audio::sendLocalOff()
+ {
+ for (int k = 0; k < MIDI_PORTS; ++k) {
+ for (int i = 0; i < MIDI_CHANNELS; ++i)
+ midiPorts[k].sendEvent(MidiPlayEvent(0, k, i, ME_CONTROLLER, CTRL_LOCAL_OFF, 0));
+ }
+ }
+
+//---------------------------------------------------------
+// panic
+//---------------------------------------------------------
+
+void Audio::panic()
+ {
+ for (int i = 0; i < MIDI_PORTS; ++i) {
+ MidiPort* port = &midiPorts[i];
+ if (port == 0) // ??
+ continue;
+ for (int chan = 0; chan < MIDI_CHANNELS; ++chan) {
+ port->sendEvent(MidiPlayEvent(0, i, chan, ME_CONTROLLER, CTRL_ALL_SOUNDS_OFF, 0));
+ port->sendEvent(MidiPlayEvent(0, i, chan, ME_CONTROLLER, CTRL_RESET_ALL_CTRL, 0));
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// initDevices
+// - called on seek to position 0
+// - called from arranger pulldown menu
+//---------------------------------------------------------
+
+void Audio::initDevices()
+ {
+ //
+ // mark all used ports
+ //
+ bool activePorts[MIDI_PORTS];
+ for (int i = 0; i < MIDI_PORTS; ++i)
+ activePorts[i] = false;
+
+ MidiTrackList* tracks = song->midis();
+ for (iMidiTrack it = tracks->begin(); it != tracks->end(); ++it) {
+ MidiTrack* track = *it;
+ activePorts[track->outPort()] = true;
+ }
+ if (song->click())
+ activePorts[clickPort] = true;
+
+ //
+ // test for explicit instrument initialization
+ //
+
+ for (int i = 0; i < MIDI_PORTS; ++i) {
+ if (!activePorts[i])
+ continue;
+
+ MidiPort* port = &midiPorts[i];
+ MidiInstrument* instr = port->instrument();
+ MidiDevice* md = port->device();
+
+ if (instr && md) {
+ EventList* events = instr->midiInit();
+ if (events->empty())
+ continue;
+ for (iEvent ie = events->begin(); ie != events->end(); ++ie) {
+ MidiPlayEvent ev(0, i, 0, ie->second);
+ md->putEvent(ev);
+ }
+ activePorts[i] = false; // no standard initialization
+ }
+ }
+ //
+ // damit Midi-Devices, die mehrere Ports besitzen, wie z.B.
+ // das Korg NS5R, nicht mehrmals zwischen GM und XG/GS hin und
+ // hergeschaltet werden, wird zunÃÂÂŊÂÂÂŋÃƒÂ‚Ã‚Â―hst auf allen Ports GM
+ // initialisiert, und dann erst XG/GS
+ //
+
+ // Standard initialization...
+ for (int i = 0; i < MIDI_PORTS; ++i) {
+ if (!activePorts[i])
+ continue;
+ MidiPort* port = &midiPorts[i];
+ switch(song->mtype()) {
+ case MT_GS:
+ case MT_UNKNOWN:
+ break;
+ case MT_GM:
+ case MT_XG:
+ port->sendGmOn();
+ break;
+ }
+ }
+ for (int i = 0; i < MIDI_PORTS; ++i) {
+ if (!activePorts[i])
+ continue;
+ MidiPort* port = &midiPorts[i];
+ switch(song->mtype()) {
+ case MT_UNKNOWN:
+ break;
+ case MT_GM:
+ port->sendGmInitValues();
+ break;
+ case MT_GS:
+ port->sendGsOn();
+ port->sendGsInitValues();
+ break;
+ case MT_XG:
+ port->sendXgOn();
+ port->sendXgInitValues();
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// collectEvents
+// collect events for next audio segment
+//---------------------------------------------------------
+
+void Audio::collectEvents(MidiTrack* track, unsigned int cts, unsigned int nts)
+ {
+ int port = track->outPort();
+ int channel = track->outChannel();
+ int defaultPort = port;
+
+ MidiDevice* md = midiPorts[port].device();
+ MPEventList* playEvents = md->playEvents();
+ MPEventList* stuckNotes = md->stuckNotes();
+
+ PartList* pl = track->parts();
+ for (iPart p = pl->begin(); p != pl->end(); ++p) {
+ MidiPart* part = (MidiPart*)(p->second);
+ // dont play muted parts
+ if (part->mute())
+ continue;
+ EventList* events = part->events();
+ unsigned partTick = part->tick();
+ unsigned partLen = part->lenTick();
+ int delay = track->delay;
+
+ if (cts > nts) {
+ printf("processMidi: FATAL: cur > next %d > %d\n",
+ cts, nts);
+ return;
+ }
+ unsigned offset = delay + partTick;
+ if (offset > nts)
+ continue;
+ unsigned stick = (offset > cts) ? 0 : cts - offset;
+ unsigned etick = nts - offset;
+ // By T356. Do not play events which are past the end of this part.
+ if(etick > partLen)
+ continue;
+
+ iEvent ie = events->lower_bound(stick);
+ iEvent iend = events->lower_bound(etick);
+
+ for (; ie != iend; ++ie) {
+ Event ev = ie->second;
+ port = defaultPort; //Reset each loop
+ //
+ // dont play any meta events
+ //
+ if (ev.type() == Meta)
+ continue;
+ if (track->type() == Track::DRUM) {
+ int instr = ev.pitch();
+ // ignore muted drums
+ if (ev.isNote() && drumMap[instr].mute)
+ continue;
+ }
+ unsigned tick = ev.tick() + offset;
+ unsigned frame = tempomap.tick2frame(tick) + frameOffset;
+ switch (ev.type()) {
+ case Note:
+ {
+ int len = ev.lenTick();
+ int pitch = ev.pitch();
+ int velo = ev.velo();
+ if (track->type() == Track::DRUM) {
+ //
+ // Map drum-notes to the drum-map values
+ //
+ int instr = ev.pitch();
+ pitch = drumMap[instr].anote;
+ port = drumMap[instr].port; //This changes to non-default port
+ channel = drumMap[instr].channel;
+ velo = int(double(velo) * (double(drumMap[instr].vol) / 100.0)) ;
+ }
+ else {
+ //
+ // transpose non drum notes
+ //
+ pitch += (track->transposition + song->globalPitchShift());
+ }
+
+ if (pitch > 127)
+ pitch = 127;
+ if (pitch < 0)
+ pitch = 0;
+ velo += track->velocity;
+ velo = (velo * track->compression) / 100;
+ if (velo > 127)
+ velo = 127;
+ if (velo < 1) // no off event
+ velo = 1;
+ len = (len * track->len) / 100;
+ if (len <= 0) // dont allow zero length
+ len = 1;
+ int veloOff = ev.veloOff();
+
+ if (port == defaultPort) {
+ //printf("Adding event normally: frame=%d port=%d channel=%d pitch=%d velo=%d\n",frame, port, channel, pitch, velo);
+
+ // p3.3.25
+ // If syncing to external midi sync, we cannot use the tempo map.
+ // Therefore we cannot get sub-tick resolution. Just use ticks instead of frames.
+ if(extSyncFlag.value())
+ playEvents->add(MidiPlayEvent(tick, port, channel, 0x90, pitch, velo));
+ else
+
+ playEvents->add(MidiPlayEvent(frame, port, channel, 0x90, pitch, velo));
+
+ stuckNotes->add(MidiPlayEvent(tick + len, port, channel,
+ veloOff ? 0x80 : 0x90, pitch, veloOff));
+ }
+ else { //Handle events to different port than standard.
+ MidiDevice* mdAlt = midiPorts[port].device();
+ if (mdAlt) {
+
+ // p3.3.25
+ if(extSyncFlag.value())
+ mdAlt->playEvents()->add(MidiPlayEvent(tick, port, channel, 0x90, pitch, velo));
+ else
+
+ mdAlt->playEvents()->add(MidiPlayEvent(frame, port, channel, 0x90, pitch, velo));
+
+ mdAlt->stuckNotes()->add(MidiPlayEvent(tick + len, port, channel,
+ veloOff ? 0x80 : 0x90, pitch, veloOff));
+ }
+ }
+
+ if(velo > track->activity())
+ track->setActivity(velo);
+ }
+ break;
+
+ // Added by T356.
+ case Controller:
+ {
+ //int len = ev.lenTick();
+ //int pitch = ev.pitch();
+ if (track->type() == Track::DRUM)
+ {
+ int ctl = ev.dataA();
+ // Is it a drum controller event, according to the track port's instrument?
+ MidiController *mc = midiPorts[defaultPort].drumController(ctl);
+ if(mc)
+ {
+ int instr = ctl & 0x7f;
+ ctl &= ~0xff;
+ int pitch = drumMap[instr].anote & 0x7f;
+ port = drumMap[instr].port; //This changes to non-default port
+ channel = drumMap[instr].channel;
+ MidiDevice* mdAlt = midiPorts[port].device();
+ if(mdAlt)
+ {
+ // p3.3.25
+ // If syncing to external midi sync, we cannot use the tempo map.
+ // Therefore we cannot get sub-tick resolution. Just use ticks instead of frames.
+ if(extSyncFlag.value())
+ mdAlt->playEvents()->add(MidiPlayEvent(tick, port, channel,
+ ME_CONTROLLER, ctl | pitch, ev.dataB()));
+ else
+
+ //playEvents->add(MidiPlayEvent(frame, port, channel, ev));
+ mdAlt->playEvents()->add(MidiPlayEvent(frame, port, channel,
+ ME_CONTROLLER, ctl | pitch, ev.dataB()));
+
+ }
+ break;
+ }
+ }
+ // p3.3.25
+ if(extSyncFlag.value())
+ playEvents->add(MidiPlayEvent(tick, port, channel, ev));
+ else
+
+ playEvents->add(MidiPlayEvent(frame, port, channel, ev));
+ }
+ break;
+
+
+ default:
+ // p3.3.25
+ if(extSyncFlag.value())
+ playEvents->add(MidiPlayEvent(tick, port, channel, ev));
+ else
+
+ playEvents->add(MidiPlayEvent(frame, port, channel, ev));
+
+ break;
+ }
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// processMidi
+// - collects midi events for current audio segment and
+// sends them to midi thread
+// - current audio segment position is (curTickPos, nextTickPos)
+// - called from midiseq thread,
+// executed in audio thread
+//---------------------------------------------------------
+
+void Audio::processMidi()
+ {
+ midiBusy=true;
+ //
+ // TODO: syntis should directly write into recordEventList
+ //
+ for (iMidiDevice id = midiDevices.begin(); id != midiDevices.end(); ++id) {
+ MidiDevice* md = *id;
+
+ MPEventList* playEvents = md->playEvents();
+ //
+ // erase already played events:
+ //
+ iMPEvent nextPlayEvent = md->nextPlayEvent();
+ playEvents->erase(playEvents->begin(), nextPlayEvent);
+
+ // klumsy hack for synti devices:
+ if(md->isSynti())
+ {
+ SynthI* s = (SynthI*)md;
+ while (s->eventsPending())
+ {
+ MidiRecordEvent ev = s->receiveEvent();
+ md->recordEvent(ev);
+ }
+ }
+
+ // Is it a Jack midi device?
+ //MidiJackDevice* mjd = dynamic_cast<MidiJackDevice*>(md);
+ //if(mjd)
+ // mjd->collectMidiEvents();
+ md->collectMidiEvents();
+
+ // Take snapshots of the current sizes of the recording fifos,
+ // because they may change while here in process, asynchronously.
+ md->beforeProcess();
+ }
+
+ MPEventList* playEvents = metronome->playEvents();
+ iMPEvent nextPlayEvent = metronome->nextPlayEvent();
+ playEvents->erase(playEvents->begin(), nextPlayEvent);
+
+ // p3.3.25
+ bool extsync = extSyncFlag.value();
+
+ for (iMidiTrack t = song->midis()->begin(); t != song->midis()->end(); ++t)
+ {
+ MidiTrack* track = *t;
+ int port = track->outPort();
+ MidiDevice* md = midiPorts[port].device();
+
+ // Changed by Tim. p3.3.8
+ //if(md == 0)
+ // continue;
+ //MPEventList* playEvents = md->playEvents();
+ //if (playEvents == 0)
+ // continue;
+ //if (!track->isMute())
+ MPEventList* playEvents = 0;
+ if(md)
+ {
+ playEvents = md->playEvents();
+
+ // only add track events if the track is unmuted
+ if(!track->isMute())
+ {
+ if(isPlaying() && (curTickPos < nextTickPos))
+ collectEvents(track, curTickPos, nextTickPos);
+ }
+ }
+
+ //
+ //----------midi recording
+ //
+ if (track->recordFlag())
+ {
+ //int portMask = track->inPortMask();
+ // p3.3.38 Removed
+ //unsigned int portMask = track->inPortMask();
+ //int channelMask = track->inChannelMask();
+
+ MPEventList* rl = track->mpevents();
+ MidiPort* tport = &midiPorts[port];
+
+ // p3.3.38
+ //for (iMidiDevice id = midiDevices.begin(); id != midiDevices.end(); ++id)
+ //{
+ RouteList* irl = track->inRoutes();
+ for(ciRoute r = irl->begin(); r != irl->end(); ++r)
+ {
+ //if(!r->isValid() || (r->type != Route::ALSA_MIDI_ROUTE && r->type != Route::JACK_MIDI_ROUTE))
+ //if(!r->isValid() || (r->type != Route::MIDI_DEVICE_ROUTE))
+ if(!r->isValid() || (r->type != Route::MIDI_PORT_ROUTE)) // p3.3.49
+ continue;
+
+ int devport = r->midiPort; // p3.3.49
+ if (devport == -1)
+ continue;
+
+ //MidiDevice* dev = *id;
+ //MidiDevice* dev = r->device;
+ MidiDevice* dev = midiPorts[devport].device(); // p3.3.49
+ if(!dev)
+ continue;
+
+
+ // p3.3.50 Removed
+ //int channel = r->channel;
+ // NOTE: TODO: Special for input device sysex 'channel' marked as -1, ** IF we end up going with that method **.
+ // This would mean having a separate 'System' channel listed in the routing popups.
+ // The other alternative is to accept sysex from a device as long as ANY regular channel is routed from it,
+ // this does not require a 'System' channel listed in the routing popups.
+ // But that requires more code below... Done.
+ //if(channel == -1)
+ //channel = MIDI_CHANNELS; // Special channel '17'
+ // continue;
+
+ //int devport = dev->midiPort();
+
+ // record only from ports marked in portMask:
+ //if (devport == -1 || !(portMask & (1 << devport)))
+ //if (devport == -1)
+ // continue;
+
+ //MREventList* el = dev->recordEvents();
+ //MidiFifo& rf = dev->recordEvents();
+
+
+ int channelMask = r->channel; // p3.3.50
+ if(channelMask == -1 || channelMask == 0)
+ continue;
+ for(int channel = 0; channel < MIDI_CHANNELS; ++channel) // p3.3.50
+ {
+ if(!(channelMask & (1 << channel)))
+ continue;
+
+ if(!dev->sysexFIFOProcessed())
+ {
+ // Set to the sysex fifo at first.
+ MidiFifo& rf = dev->recordEvents(MIDI_CHANNELS);
+ // Get the frozen snapshot of the size.
+ int count = dev->tmpRecordCount(MIDI_CHANNELS);
+
+ for(int i = 0; i < count; ++i)
+ {
+ MidiPlayEvent event(rf.peek(i));
+
+ //unsigned time = event.time() + segmentSize*(segmentCount-1);
+ //unsigned time = event.time() + (extsync ? config.division/24 : segmentSize*(segmentCount-1));
+ //unsigned time = extsync ? curTickPos : (event.time() + segmentSize*(segmentCount-1));
+ //event.setTime(time);
+ //if(!extsync)
+ // event.setTime(event.time() + segmentSize*(segmentCount-1));
+
+ event.setPort(port);
+
+ // dont't echo controller changes back to software
+ // synthesizer:
+ if(!dev->isSynti() && md && track->recEcho())
+ playEvents->add(event);
+
+ // If syncing externally the event time is already in units of ticks, set above.
+ if(!extsync)
+ {
+ //time = tempomap.frame2tick(event.time());
+ //event.setTime(time); // set tick time
+ event.setTime(tempomap.frame2tick(event.time())); // set tick time
+ }
+
+ if(recording)
+ rl->add(event);
+ }
+
+ dev->setSysexFIFOProcessed(true);
+ }
+
+ // Set to the sysex fifo at first.
+ ///MidiFifo& rf = dev->recordEvents(MIDI_CHANNELS);
+ // Get the frozen snapshot of the size.
+ ///int count = dev->tmpRecordCount(MIDI_CHANNELS);
+
+ // Iterate once for sysex fifo (if needed), once for channel fifos.
+ ///for(int sei = 0; sei < 2; ++sei)
+ {
+ // If on first pass, do sysex fifo.
+ /*
+ if(sei == 0)
+ {
+ // Ignore any further channel routes on this device if already done here.
+ if(dev->sysexFIFOProcessed())
+ continue;
+ // Go ahead and set this now.
+ dev->setSysexFIFOProcessed(true);
+ // Allow it to fall through with the sysex fifo and count...
+ }
+ else
+ {
+ // We're on the second pass, do channel fifos.
+ rf = dev->recordEvents(channel);
+ // Get the frozen snapshot of the size.
+ count = dev->tmpRecordCount(channel);
+ }
+ */
+
+ MidiFifo& rf = dev->recordEvents(channel);
+ int count = dev->tmpRecordCount(channel);
+
+ //for (iMREvent ie = el->begin(); ie != el->end(); ++ie)
+ for(int i = 0; i < count; ++i)
+ {
+ MidiPlayEvent event(rf.peek(i));
+
+ //int channel = ie->channel();
+ ///int channel = event.channel();
+
+ int defaultPort = devport;
+ ///if (!(channelMask & (1 << channel)))
+ ///{
+ /// continue;
+ ///}
+
+ //MidiPlayEvent event(*ie);
+ int drumRecPitch=0; //prevent compiler warning: variable used without initialization
+ MidiController *mc = 0;
+ int ctl = 0;
+
+ //Hmmm, hehhh...
+ // TODO: Clean up a bit around here when it comes to separate events for rec & for playback.
+ // But not before 0.7 (ml)
+
+ int prePitch = 0, preVelo = 0;
+
+ event.setChannel(track->outChannel());
+
+ if (event.isNote() || event.isNoteOff())
+ {
+ //
+ // apply track values
+ //
+
+ //Apply drum inkey:
+ if (track->type() == Track::DRUM)
+ {
+ int pitch = event.dataA();
+ //Map note that is played according to drumInmap
+ drumRecPitch = drumMap[(unsigned int)drumInmap[pitch]].enote;
+ devport = drumMap[(unsigned int)drumInmap[pitch]].port;
+ event.setPort(devport);
+ channel = drumMap[(unsigned int)drumInmap[pitch]].channel;
+ event.setA(drumMap[(unsigned int)drumInmap[pitch]].anote);
+ event.setChannel(channel);
+ }
+ else
+ { //Track transpose if non-drum
+ prePitch = event.dataA();
+ int pitch = prePitch + track->transposition;
+ if (pitch > 127)
+ pitch = 127;
+ if (pitch < 0)
+ pitch = 0;
+ event.setA(pitch);
+ }
+
+ if (!event.isNoteOff())
+ {
+ preVelo = event.dataB();
+ int velo = preVelo + track->velocity;
+ velo = (velo * track->compression) / 100;
+ if (velo > 127)
+ velo = 127;
+ if (velo < 1)
+ velo = 1;
+ event.setB(velo);
+ }
+ }
+ // Added by T356.
+ else
+ if(event.type() == ME_CONTROLLER)
+ {
+ if(track->type() == Track::DRUM)
+ {
+ ctl = event.dataA();
+ // Regardless of what port the event came from, is it a drum controller event
+ // according to the track port's instrument?
+ mc = tport->drumController(ctl);
+ if(mc)
+ {
+ int pitch = ctl & 0x7f;
+ ctl &= ~0xff;
+ int dmindex = drumInmap[pitch] & 0x7f;
+ //Map note that is played according to drumInmap
+ drumRecPitch = drumMap[dmindex].enote;
+ devport = drumMap[dmindex].port;
+ event.setPort(devport);
+ channel = drumMap[dmindex].channel;
+ event.setA(ctl | drumMap[dmindex].anote);
+ event.setChannel(channel);
+ }
+ }
+ }
+
+ // p3.3.25
+ // MusE uses a fixed clocks per quarternote of 24.
+ // At standard 384 ticks per quarternote for example,
+ // 384/24=16 for a division of 16 sub-frames (16 MusE 'ticks').
+ // That is what we'll use if syncing externally.
+ //unsigned time = event.time() + segmentSize*(segmentCount-1);
+ //unsigned time = event.time() + (extsync ? config.division/24 : segmentSize*(segmentCount-1));
+ // p3.3.34
+ // Oops, use the current tick.
+ //unsigned time = extsync ? curTickPos : (event.time() + segmentSize*(segmentCount-1));
+ //event.setTime(time);
+ // p3.3.35
+ // If ext sync, events are now time-stamped with last tick in MidiDevice::recordEvent().
+ // TODO: Tested, but record resolution not so good. Switch to wall clock based separate list in MidiDevice.
+ // p3.3.36
+ //if(!extsync)
+ // event.setTime(event.time() + segmentSize*(segmentCount-1));
+
+ // dont't echo controller changes back to software
+ // synthesizer:
+
+ if (!dev->isSynti())
+ {
+ //Check if we're outputting to another port than default:
+ if (devport == defaultPort) {
+ event.setPort(port);
+ if(md && track->recEcho())
+ playEvents->add(event);
+ }
+ else {
+ // Hmm, this appears to work, but... Will this induce trouble with md->setNextPlayEvent??
+ MidiDevice* mdAlt = midiPorts[devport].device();
+ if(mdAlt && track->recEcho())
+ mdAlt->playEvents()->add(event);
+ }
+ // Shall we activate meters even while rec echo is off? Sure, why not...
+ if(event.isNote() && event.dataB() > track->activity())
+ track->setActivity(event.dataB());
+ }
+
+ // p3.3.25
+ // If syncing externally the event time is already in units of ticks, set above.
+ if(!extsync)
+ {
+ // p3.3.35
+ //time = tempomap.frame2tick(event.time());
+ //event.setTime(time); // set tick time
+ event.setTime(tempomap.frame2tick(event.time())); // set tick time
+ }
+
+ // Special handling of events stored in rec-lists. a bit hACKish. TODO: Clean up (after 0.7)! :-/ (ml)
+ if (recording)
+ {
+ // In these next steps, it is essential to set the recorded event's port
+ // to the track port so buildMidiEventList will accept it. Even though
+ // the port may have no device "<none>".
+ //
+ if (track->type() == Track::DRUM)
+ {
+ // Is it a drum controller event?
+ if(mc)
+ {
+ MidiPlayEvent drumRecEvent = event;
+ drumRecEvent.setA(ctl | drumRecPitch);
+ // In this case, preVelo is simply the controller value.
+ drumRecEvent.setB(preVelo);
+ drumRecEvent.setPort(port); //rec-event to current port
+ drumRecEvent.setChannel(track->outChannel()); //rec-event to current channel
+ rl->add(drumRecEvent);
+ }
+ else
+ {
+
+ MidiPlayEvent drumRecEvent = event;
+ drumRecEvent.setA(drumRecPitch);
+ drumRecEvent.setB(preVelo);
+ // Changed by T356.
+ // Tested: Events were not being recorded for a drum map entry pointing to a
+ // different port. This must have been wrong - buildMidiEventList would ignore this.
+ //drumRecEvent.setPort(devport);
+ drumRecEvent.setPort(port); //rec-event to current port
+
+ drumRecEvent.setChannel(track->outChannel()); //rec-event to current channel
+ rl->add(drumRecEvent);
+ }
+ }
+ else
+ {
+ // Restore record-pitch to non-transposed value since we don't want the note transposed twice next
+ MidiPlayEvent recEvent = event;
+ if (prePitch)
+ recEvent.setA(prePitch);
+ if (preVelo)
+ recEvent.setB(preVelo);
+ recEvent.setPort(port);
+ recEvent.setChannel(track->outChannel());
+
+ rl->add(recEvent);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ // Added by Tim. p3.3.8
+ if(md)
+ {
+
+ md->setNextPlayEvent(playEvents->begin());
+ }
+ }
+
+ //
+ // clear all recorded events in midiDevices
+ // process stuck notes
+ //
+ for (iMidiDevice id = midiDevices.begin(); id != midiDevices.end(); ++id) {
+ MidiDevice* md = *id;
+
+ ///md->recordEvents()->clear();
+ // By T356. Done processing this rec buffer, now flip to the other one.
+ ///md->flipRecBuffer();
+ // We are done with the 'frozen' recording fifos, remove the events.
+ md->afterProcess();
+
+ MPEventList* stuckNotes = md->stuckNotes();
+ MPEventList* playEvents = md->playEvents();
+
+ iMPEvent k;
+ for (k = stuckNotes->begin(); k != stuckNotes->end(); ++k) {
+ if (k->time() >= nextTickPos)
+ break;
+ MidiPlayEvent ev(*k);
+
+ // p3.3.25
+ //int frame = tempomap.tick2frame(k->time()) + frameOffset;
+ if(extsync)
+ {
+ ev.setTime(k->time());
+ }
+ else
+ {
+ int frame = tempomap.tick2frame(k->time()) + frameOffset;
+ ev.setTime(frame);
+ }
+
+ // p3.3.25
+ //ev.setTime(frame);
+
+ playEvents->add(ev);
+ }
+ stuckNotes->erase(stuckNotes->begin(), k);
+ md->setNextPlayEvent(playEvents->begin());
+ }
+
+ //---------------------------------------------------
+ // insert metronome clicks
+ //---------------------------------------------------
+
+ MidiDevice* md = 0;
+ if (midiClickFlag)
+ md = midiPorts[clickPort].device();
+ if (song->click() && (isPlaying() || state == PRECOUNT)) {
+ MPEventList* playEvents = 0;
+ MPEventList* stuckNotes = 0;
+ if (md) {
+ playEvents = md->playEvents();
+ stuckNotes = md->stuckNotes();
+ }
+ int bar, beat;
+ unsigned tick;
+ bool isMeasure = false;
+ while (midiClick < nextTickPos) {
+ if (isPlaying()) {
+ ///sigmap.tickValues(midiClick, &bar, &beat, &tick);
+ AL::sigmap.tickValues(midiClick, &bar, &beat, &tick);
+ isMeasure = beat == 0;
+ }
+ else if (state == PRECOUNT) {
+ isMeasure = (clickno % clicksMeasure) == 0;
+ }
+ // p3.3.25
+ //int frame = tempomap.tick2frame(midiClick) + frameOffset;
+ int evtime = extsync ? midiClick : tempomap.tick2frame(midiClick) + frameOffset;
+
+ // p3.3.25
+ //MidiPlayEvent ev(frame, clickPort, clickChan, ME_NOTEON,
+ MidiPlayEvent ev(evtime, clickPort, clickChan, ME_NOTEON,
+ beatClickNote, beatClickVelo);
+
+ if (md) {
+ // p3.3.25
+ //MidiPlayEvent ev(frame, clickPort, clickChan, ME_NOTEON,
+ MidiPlayEvent ev(evtime, clickPort, clickChan, ME_NOTEON,
+ beatClickNote, beatClickVelo);
+
+ if (isMeasure) {
+ ev.setA(measureClickNote);
+ ev.setB(measureClickVelo);
+ }
+ playEvents->add(ev);
+ }
+ if (audioClickFlag) {
+ // p3.3.25
+ //MidiPlayEvent ev1(frame, 0, 0, ME_NOTEON, 0, 0);
+ MidiPlayEvent ev1(evtime, 0, 0, ME_NOTEON, 0, 0);
+
+ ev1.setA(isMeasure ? 0 : 1);
+ metronome->playEvents()->add(ev1);
+ }
+ if (md) {
+ ev.setB(0);
+ // p3.3.25
+ // Removed. Why was this here?
+ //frame = tempomap.tick2frame(midiClick+20) + frameOffset;
+ //
+ // Does it mean this should be changed too?
+ // No, stuck notes are in units of ticks, not frames like (normal, non-external) play events...
+ ev.setTime(midiClick+10);
+
+ if (md)
+ stuckNotes->add(ev);
+ }
+
+ if (isPlaying())
+ ///midiClick = sigmap.bar2tick(bar, beat+1, 0);
+ midiClick = AL::sigmap.bar2tick(bar, beat+1, 0);
+ else if (state == PRECOUNT) {
+ midiClick += ticksBeat;
+ if (clickno)
+ --clickno;
+ else
+ state = START_PLAY;
+ }
+ }
+ if (md)
+ md->setNextPlayEvent(playEvents->begin());
+ if (audioClickFlag)
+ metronome->setNextPlayEvent(metronome->playEvents()->begin());
+ }
+
+ if (state == STOP) {
+ //---------------------------------------------------
+ // end all notes
+ //---------------------------------------------------
+
+ for (iMidiDevice imd = midiDevices.begin(); imd != midiDevices.end(); ++imd) {
+ MidiDevice* md = *imd;
+ MPEventList* playEvents = md->playEvents();
+ MPEventList* stuckNotes = md->stuckNotes();
+ for (iMPEvent k = stuckNotes->begin(); k != stuckNotes->end(); ++k) {
+ MidiPlayEvent ev(*k);
+ ev.setTime(0); // play now
+ playEvents->add(ev);
+ }
+ stuckNotes->clear();
+ }
+ }
+
+
+ // p3.3.36
+ //int tickpos = audio->tickPos();
+ //bool extsync = extSyncFlag.value();
+ //
+ // Special for Jack midi devices: Play all Jack midi events up to curFrame.
+ //
+ for(iMidiDevice id = midiDevices.begin(); id != midiDevices.end(); ++id)
+ {
+ //MidiDevice* md = *id;
+ // Is it a Jack midi device?
+ //MidiJackDevice* mjd = dynamic_cast<MidiJackDevice*>(md);
+ //if(!mjd)
+ // continue;
+ //mjd->processMidi();
+ (*id)->processMidi();
+
+ /*
+ int port = md->midiPort();
+ MidiPort* mp = port != -1 ? &midiPorts[port] : 0;
+ MPEventList* el = md->playEvents();
+ if (el->empty())
+ continue;
+ iMPEvent i = md->nextPlayEvent();
+ for(; i != el->end(); ++i)
+ {
+ // If syncing to external midi sync, we cannot use the tempo map.
+ // Therefore we cannot get sub-tick resolution. Just use ticks instead of frames.
+ //if(i->time() > curFrame)
+ if(i->time() > (extsync ? tickpos : curFrame))
+ {
+ //printf(" curT %d frame %d\n", i->time(), curFrame);
+ break; // skip this event
+ }
+
+ if(mp)
+ {
+ if(mp->sendEvent(*i))
+ break;
+ }
+ else
+ {
+ if(md->putEvent(*i))
+ break;
+ }
+ }
+ md->setNextPlayEvent(i);
+ */
+ }
+
+ midiBusy=false;
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/midi.h b/attic/muse2-oom/muse2/muse/midi.h
new file mode 100644
index 00000000..ab649377
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midi.h
@@ -0,0 +1,73 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midi.h,v 1.4.2.2 2009/11/09 20:28:28 terminator356 Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MIDI_H__
+#define __MIDI_H__
+
+#include <unistd.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+class QString;
+
+enum {
+ ME_NOTEOFF = 0x80,
+ ME_NOTEON = 0x90,
+ ME_POLYAFTER = 0xa0,
+ ME_CONTROLLER = 0xb0,
+ ME_PROGRAM = 0xc0,
+ ME_AFTERTOUCH = 0xd0,
+ ME_PITCHBEND = 0xe0,
+ ME_SYSEX = 0xf0,
+ ME_META = 0xff,
+ ME_MTC_QUARTER = 0xf1,
+ ME_SONGPOS = 0xf2,
+ ME_SONGSEL = 0xf3,
+ ME_TUNE_REQ = 0xf6,
+ ME_SYSEX_END = 0xf7,
+ ME_CLOCK = 0xf8,
+ ME_TICK = 0xf9,
+ ME_START = 0xfa,
+ ME_CONTINUE = 0xfb,
+ ME_STOP = 0xfc,
+ ME_SENSE = 0xfe
+ };
+
+#define ME_TIMESIG 0x58
+
+extern const unsigned char gmOnMsg[];
+
+extern const unsigned char gsOnMsg[];
+extern const unsigned char gsOnMsg2[];
+extern const unsigned char gsOnMsg3[];
+extern const unsigned char xgOnMsg[];
+extern const unsigned char mmcDeferredPlayMsg[];
+extern const unsigned char mmcStopMsg[];
+extern const unsigned char mmcLocateMsg[];
+
+extern const unsigned int gmOnMsgLen;
+extern const unsigned int gsOnMsgLen;
+extern const unsigned int gsOnMsg2Len;
+extern const unsigned int gsOnMsg3Len;
+extern const unsigned int xgOnMsgLen;
+extern const unsigned int mmcDeferredPlayMsgLen;
+extern const unsigned int mmcStopMsgLen;
+extern const unsigned int mmcLocateMsgLen;
+
+QString nameSysex(unsigned int len, const unsigned char* buf);
+QString midiMetaName(int);
+
+class EventList;
+class MPEventList;
+class MidiTrack;
+//extern void buildMidiEventList(EventList* mel, const MPEventList* el, MidiTrack* track, int division, bool);
+extern void buildMidiEventList(EventList* mel, const MPEventList* el, MidiTrack* track, int division, bool /*addSysexMeta*/, bool /*doLoops*/);
+// extern bool checkSysex(MidiTrack* track, unsigned int len, unsigned char* buf);
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/midictrl.cpp b/attic/muse2-oom/muse2/muse/midictrl.cpp
new file mode 100644
index 00000000..b96fcda6
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midictrl.cpp
@@ -0,0 +1,780 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midictrl.cpp,v 1.17.2.10 2009/06/10 00:34:59 terminator356 Exp $
+//
+// (C) Copyright 2001-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <assert.h>
+#include <stdio.h>
+
+#include "midictrl.h"
+#include "xml.h"
+#include "globals.h"
+
+static const char* ctrlName[] = {
+ "BankSelMSB", "Modulation", "BreathCtrl", "Control 3", "Foot Ctrl",
+ "Porta Time", "DataEntMSB", "MainVolume", "Balance", "Control 9",
+/*10*/ "Pan", "Expression", "Control 12", "Control 13", "Control 14",
+ "Control 15", "Gen.Purp.1", "Gen.Purp.2", "Gen.Purp.3", "Gen.Purp.4",
+/*20*/ "Control 20", "Control 21", "Control 22", "Control 23", "Control 24",
+ "Control 25", "Control 26", "Control 27", "Control 28", "Control 29",
+/*30*/ "Control 30", "Control 31", "BankSelLSB", "Modul. LSB", "BrthCt.LSB",
+ "Control 35", "FootCt.LSB", "Port.T LSB", "DataEntLSB", "MainVolLSB",
+ "BalanceLSB", "Control 41", "Pan LSB", "Expr. LSB", "Control 44",
+ "Control 45", "Control 46", "Control 47", "Gen.P.1LSB", "Gen.P.2LSB",
+/*50*/ "Gen.P.3LSB", "Gen.P.4LSB", "Control 52", "Control 53", "Control 54",
+ "Control 55", "Control 56", "Control 57", "Control 58", "Control 59",
+ "Control 60", "Control 61", "Control 62", "Control 63", "Sustain",
+ "Porta Ped", "Sostenuto", "Soft Pedal", "Control 68", "Hold 2",
+ "Control 70", "HarmonicCo", "ReleaseTime", "Attack Time", "Brightness",
+ "Control 75", "Control 76", "Control 77", "Control 78", "Control 79",
+ "Gen.Purp.5", "Gen.Purp.6", "Gen.Purp.7", "Gen.Purp.8", "Porta Ctrl",
+ "Control 85", "Control 86", "Control 87", "Control 88", "Control 89",
+ "Control 90", "Effect1Dep", "Effect2Dep", "Effect3Dep", "Effect4Dep",
+ "Phaser Dep", "Data Incr", "Data Decr", "NRPN LSB", "NRPN MSB",
+/*100*/ "RPN LSB", "RPN MSB", "Control102", "Control103", "Control104",
+ "Control105", "Control106", "Control107", "Control108", "Control109",
+ "Control110", "Control111", "Control112", "Control113", "Control114",
+ "Control115", "Control116", "Control117", "Control118", "Control119",
+ "AllSndOff", "Reset Ctrl", "Local Ctrl", "AllNoteOff", "OmniModOff",
+ "OmniModeOn", "MonoModeOn", "PolyModeOn"
+ };
+
+#if 0
+static const char* ctrl14Name[] = {
+ "BankSel", "Modulation", "BreathCtrl",
+ "Control 3", "Foot Ctrl", "Porta Time", "DataEntry",
+ "MainVolume", "Balance", "Control 9", "Pan",
+ "Expression", "Control 12", "Control 13", "Control 14",
+ "Control 15", "Gen.Purp.1", "Gen.Purp.2", "Gen.Purp.3",
+ "Gen.Purp.4", "Control 20", "Control 21", "Control 22",
+ "Control 23", "Control 24", "Control 25", "Control 26",
+ "Control 27", "Control 28", "Control 29", "Control 30",
+ "Control 31",
+ };
+#endif
+
+enum {
+ COL_NAME = 0, COL_TYPE,
+ COL_HNUM, COL_LNUM, COL_MIN, COL_MAX
+ };
+
+MidiControllerList defaultMidiController;
+//
+// some global controller which are always available:
+//
+MidiController veloCtrl("Velocity", CTRL_VELOCITY, 0, 127, 0);
+static MidiController pitchCtrl("PitchBend", CTRL_PITCH, -8192, +8191, 0);
+static MidiController programCtrl("Program", CTRL_PROGRAM, 0, 0xffffff, 0);
+// Removed p3.3.37
+//static MidiController mastervolCtrl("MasterVolume", CTRL_MASTER_VOLUME, 0, 0x3fff, 0x3000);
+static MidiController volumeCtrl("MainVolume", CTRL_VOLUME, 0, 127, 100);
+static MidiController panCtrl("Pan", CTRL_PANPOT, -64, 63, 0);
+
+
+//---------------------------------------------------------
+// ctrlType2Int
+// int2ctrlType
+//---------------------------------------------------------
+
+static struct {
+ MidiController::ControllerType type;
+ QString name;
+ } ctrlTypes[] = {
+ { MidiController::Controller7, QString("Control7") },
+ { MidiController::Controller14, QString("Control14") },
+ { MidiController::RPN, QString("RPN") },
+ { MidiController::NRPN, QString("NRPN") },
+ { MidiController::RPN14, QString("RPN14") },
+ { MidiController::NRPN14, QString("NRPN14") },
+ { MidiController::Pitch, QString("Pitch") },
+ { MidiController::Program, QString("Program") },
+ { MidiController::Controller7, QString("Control") }, // alias
+ };
+
+//---------------------------------------------------------
+// ctrlType2Int
+//---------------------------------------------------------
+
+MidiController::ControllerType ctrlType2Int(const QString& s)
+ {
+ int n = sizeof(ctrlTypes)/sizeof(*ctrlTypes);
+ for (int i = 0; i < n; ++i) {
+ if (ctrlTypes[i].name == s)
+ return ctrlTypes[i].type;
+ }
+ return MidiController::ControllerType(0);
+ }
+
+//---------------------------------------------------------
+// int2ctrlType
+//---------------------------------------------------------
+
+const QString& int2ctrlType(int n)
+ {
+ static QString dontKnow("?T?");
+ int size = sizeof(ctrlTypes)/sizeof(*ctrlTypes);
+ for (int i = 0; i < size; ++i) {
+ if (ctrlTypes[i].type == n)
+ return ctrlTypes[i].name;
+ }
+ return dontKnow;
+ }
+
+//---------------------------------------------------------
+// initMidiController
+//---------------------------------------------------------
+
+void initMidiController()
+ {
+ defaultMidiController.add(&veloCtrl);
+ defaultMidiController.add(&pitchCtrl);
+ defaultMidiController.add(&programCtrl);
+ // Removed p3.3.37
+ //defaultMidiController.add(&mastervolCtrl);
+ defaultMidiController.add(&volumeCtrl);
+ defaultMidiController.add(&panCtrl);
+ }
+
+//---------------------------------------------------------
+// midiCtrlName
+//---------------------------------------------------------
+
+QString midiCtrlName(int ctrl)
+ {
+ if (ctrl < 0x10000)
+ return QString(ctrlName[ctrl]);
+ return QString("?N?");
+ }
+
+//---------------------------------------------------------
+// MidiController
+//---------------------------------------------------------
+
+MidiController::MidiController()
+ : _name(QString(QT_TRANSLATE_NOOP("@default", "Velocity")))
+ {
+ _num = CTRL_VELOCITY;
+ _minVal = 0;
+ _maxVal = 127;
+ _initVal = 0;
+ updateBias();
+ }
+
+MidiController::MidiController(const QString& s, int n, int min, int max, int init)
+ : _name(s), _num(n), _minVal(min), _maxVal(max), _initVal(init)
+ {
+ updateBias();
+ }
+
+MidiController::MidiController(const MidiController& mc)
+{
+ copy(mc);
+}
+
+//---------------------------------------------------------
+// copy
+//---------------------------------------------------------
+
+void MidiController::copy(const MidiController &mc)
+{
+ _name = mc._name;
+ _num = mc._num;
+ _minVal = mc._minVal;
+ _maxVal = mc._maxVal;
+ _initVal = mc._initVal;
+ //updateBias();
+ _bias = mc._bias;
+}
+
+//---------------------------------------------------------
+// operator =
+//---------------------------------------------------------
+
+MidiController& MidiController::operator=(const MidiController &mc)
+{
+ copy(mc);
+ return *this;
+}
+
+//---------------------------------------------------------
+// type
+//---------------------------------------------------------
+
+MidiController::ControllerType midiControllerType(int num)
+ {
+ // p3.3.37
+ //if (num < 0x10000)
+ if (num < CTRL_14_OFFSET)
+ return MidiController::Controller7;
+ //if (num < 0x20000)
+ if (num < CTRL_RPN_OFFSET)
+ return MidiController::Controller14;
+ //if (num < 0x30000)
+ if (num < CTRL_NRPN_OFFSET)
+ return MidiController::RPN;
+ //if (num < 0x40000)
+ if (num < CTRL_INTERNAL_OFFSET)
+ return MidiController::NRPN;
+ if (num == CTRL_PITCH)
+ return MidiController::Pitch;
+ if (num == CTRL_PROGRAM)
+ return MidiController::Program;
+ if (num == CTRL_VELOCITY)
+ return MidiController::Velo;
+ //if (num < 0x60000)
+ if (num < CTRL_NRPN14_OFFSET)
+ return MidiController::RPN14;
+ //if (num < 0x70000)
+ if (num < CTRL_NONE_OFFSET)
+ return MidiController::NRPN14;
+ return MidiController::Controller7;
+ }
+
+//---------------------------------------------------------
+// updateBias
+//---------------------------------------------------------
+
+void MidiController::updateBias()
+{
+ // If the specified minimum value is negative, we will
+ // translate to a positive-biased range.
+ // Cue: A controller like 'coarse tuning', is meant to be displayed
+ // as -24/+24, but really is centered on 64 and goes from 40 to 88.
+ int b;
+ int mn, mx;
+ ControllerType t = midiControllerType(_num);
+ switch (t)
+ {
+ case RPN:
+ case NRPN:
+ case Controller7:
+ b = 64;
+ mn = 0;
+ mx = 127;
+ break;
+ case Controller14:
+ case RPN14:
+ case NRPN14:
+ b = 8192;
+ mn = 0;
+ mx = 16383;
+ break;
+ case Program:
+ b = 0x800000;
+ mn = 0;
+ mx = 0xffffff;
+ break;
+ case Pitch:
+ b = 0;
+ mn = -8192;
+ mx = 8191;
+ break;
+ //case Velo: // cannot happen
+ default:
+ b = 64;
+ mn = 0;
+ mx = 127;
+ break;
+ }
+
+ // Special handling of pan: Only thing to do is force the range!
+ //if(_num == CTRL_PANPOT)
+ //{
+ // _minVal = -64;
+ // _maxVal = 63;
+ // _initVal = 0;
+ //}
+
+ // TODO: Limit _minVal and _maxVal to range.
+
+ if(_minVal >= 0)
+ _bias = 0;
+ else
+ {
+ _bias = b;
+
+ if(t != Program && t != Pitch)
+ {
+ // Adjust bias to fit desired range.
+ if(_minVal + _bias < mn)
+ //_minVal = mn - _bias;
+ _bias += mn - _minVal + _bias;
+ else
+ if(_maxVal + _bias > mx)
+ //_maxVal = mx - _bias;
+ _bias -= _maxVal + _bias - mx;
+ }
+ }
+}
+
+
+//---------------------------------------------------------
+// MidiController::write
+//---------------------------------------------------------
+
+void MidiController::write(int level, Xml& xml) const
+{
+ ControllerType t = midiControllerType(_num);
+ if(t == Velo)
+ return;
+
+ QString type(int2ctrlType(t));
+
+ int h = (_num >> 8) & 0x7f;
+ int l = _num & 0x7f;
+
+ QString sl;
+ if ((_num & 0xff) == 0xff)
+ sl = "pitch";
+ else
+ sl.setNum(l);
+
+ xml.nput(level, "<Controller name=\"%s\"", Xml::xmlString(_name).toLatin1().constData());
+ if(t != Controller7)
+ xml.nput(" type=\"%s\"", type.toLatin1().constData());
+
+ int mn = 0;
+ int mx = 0;
+ switch (t)
+ {
+ case RPN:
+ case NRPN:
+ xml.nput(" h=\"%d\"", h);
+ xml.nput(" l=\"%s\"", sl.toLatin1().constData());
+ mx = 127;
+ break;
+ case Controller7:
+ xml.nput(" l=\"%s\"", sl.toLatin1().constData());
+ mx = 127;
+ break;
+ case Controller14:
+ case RPN14:
+ case NRPN14:
+ xml.nput(" h=\"%d\"", h);
+ xml.nput(" l=\"%s\"", sl.toLatin1().constData());
+ mx = 16383;
+ break;
+ case Pitch:
+ mn = -8192;
+ mx = 8191;
+ break;
+ case Program:
+ case Velo: // Cannot happen
+ break;
+ }
+
+ if(t == Program)
+ {
+ if(_initVal != CTRL_VAL_UNKNOWN && _initVal != 0xffffff)
+ xml.nput(" init=\"0x%x\"", _initVal);
+ }
+ else
+ {
+ if(_minVal != mn)
+ xml.nput(" min=\"%d\"", _minVal);
+ if(_maxVal != mx)
+ xml.nput(" max=\"%d\"", _maxVal);
+
+ if(_initVal != CTRL_VAL_UNKNOWN)
+ xml.nput(" init=\"%d\"", _initVal);
+ }
+ //xml.put(level, " />");
+ xml.put(" />");
+}
+
+//---------------------------------------------------------
+// MidiController::read
+//---------------------------------------------------------
+
+void MidiController::read(Xml& xml)
+ {
+ ControllerType t = Controller7;
+ _initVal = CTRL_VAL_UNKNOWN;
+ static const int NOT_SET = 0x100000;
+ _minVal = NOT_SET;
+ _maxVal = NOT_SET;
+ int h = 0;
+ int l = 0;
+ bool ok;
+ int base = 10;
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::Attribut:
+ {
+ QString s = xml.s2();
+ if (s.left(2) == "0x")
+ base = 16;
+ if (tag == "name")
+ _name = xml.s2();
+ else if (tag == "type")
+ t = ctrlType2Int(xml.s2());
+ else if (tag == "h")
+ h = xml.s2().toInt(&ok, base);
+ else if (tag == "l") {
+ // By T356 08/16/08. Changed wildcard to '*'.
+ // Changed back to 'pitch' again.
+ // Support instrument files with '*' as wildcard.
+ if ((xml.s2() == "*") || (xml.s2() == "pitch"))
+ l = 0xff;
+ else
+ l = xml.s2().toInt(&ok, base);
+ }
+ else if (tag == "min")
+ _minVal = xml.s2().toInt(&ok, base);
+ else if (tag == "max")
+ _maxVal = xml.s2().toInt(&ok, base);
+ else if (tag == "init")
+ _initVal = xml.s2().toInt(&ok, base);
+ }
+ break;
+ case Xml::TagStart:
+ xml.unknown("MidiController");
+ break;
+ case Xml::TagEnd:
+ if (tag == "Controller") {
+ _num = (h << 8) + l;
+ switch (t) {
+ case RPN:
+ if (_maxVal == NOT_SET)
+ _maxVal = 127;
+ // p3.3.37
+ //_num |= 0x20000;
+ _num |= CTRL_RPN_OFFSET;
+ break;
+ case NRPN:
+ if (_maxVal == NOT_SET)
+ _maxVal = 127;
+ //_num |= 0x30000;
+ _num |= CTRL_NRPN_OFFSET;
+ break;
+ case Controller7:
+ if (_maxVal == NOT_SET)
+ _maxVal = 127;
+ break;
+ case Controller14:
+ //_num |= 0x10000;
+ _num |= CTRL_14_OFFSET;
+ if (_maxVal == NOT_SET)
+ _maxVal = 16383;
+ break;
+ case RPN14:
+ if (_maxVal == NOT_SET)
+ _maxVal = 16383;
+ //_num |= 0x50000;
+ _num |= CTRL_RPN14_OFFSET;
+ break;
+ case NRPN14:
+ if (_maxVal == NOT_SET)
+ _maxVal = 16383;
+ //_num |= 0x60000;
+ _num |= CTRL_NRPN14_OFFSET;
+ break;
+ case Pitch:
+ if (_maxVal == NOT_SET)
+ _maxVal = 8191;
+ if (_minVal == NOT_SET)
+ _minVal = -8192;
+ _num = CTRL_PITCH;
+ break;
+ case Program:
+ if (_maxVal == NOT_SET)
+ _maxVal = 0xffffff;
+ _num = CTRL_PROGRAM;
+ break;
+ case Velo: // cannot happen
+ break;
+ }
+ if (_minVal == NOT_SET)
+ _minVal = 0;
+
+ updateBias();
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// genNum
+//---------------------------------------------------------
+
+int MidiController::genNum(MidiController::ControllerType t, int h, int l)
+ {
+ int val = (h << 8) + l;
+ switch(t) {
+ case Controller7:
+ return l;
+ case Controller14:
+ return val + CTRL_14_OFFSET;
+ case RPN:
+ //return l + CTRL_RPN_OFFSET;
+ return val + CTRL_RPN_OFFSET;
+ case NRPN:
+ //return l + CTRL_NRPN_OFFSET;
+ return val + CTRL_NRPN_OFFSET;
+ case RPN14:
+ return val + CTRL_RPN14_OFFSET;
+ case NRPN14:
+ return val + CTRL_NRPN14_OFFSET;
+ case Pitch:
+ return CTRL_PITCH;
+ case Program:
+ return CTRL_PROGRAM;
+ default:
+ return -1;
+ }
+ }
+
+//---------------------------------------------------------
+// MidiCtrlValList
+//---------------------------------------------------------
+
+MidiCtrlValList::MidiCtrlValList(int c)
+ {
+ ctrlNum = c;
+ _hwVal = CTRL_VAL_UNKNOWN;
+ _lastValidHWVal = CTRL_VAL_UNKNOWN;
+ }
+
+//---------------------------------------------------------
+// clearDelete
+//---------------------------------------------------------
+
+void MidiCtrlValListList::clearDelete(bool deleteLists)
+{
+ for(iMidiCtrlValList imcvl = begin(); imcvl != end(); ++imcvl)
+ {
+ if(imcvl->second)
+ {
+ imcvl->second->clear();
+ if(deleteLists)
+ delete imcvl->second;
+ }
+ }
+ if(deleteLists)
+ clear();
+}
+
+//---------------------------------------------------------
+// setHwVal
+// Returns false if value is already equal, true if value is changed.
+//---------------------------------------------------------
+
+bool MidiCtrlValList::setHwVal(const int v)
+{
+ if(_hwVal == v)
+ return false;
+
+ _hwVal = v;
+ if(_hwVal != CTRL_VAL_UNKNOWN)
+ _lastValidHWVal = _hwVal;
+
+ return true;
+}
+
+//---------------------------------------------------------
+// setHwVals
+// Sets current and last HW values.
+// Handy for forcing labels to show 'off' and knobs to show specific values
+// without having to send two messages.
+// Returns false if both values are already set, true if either value is changed.
+//---------------------------------------------------------
+
+bool MidiCtrlValList::setHwVals(const int v, int const lastv)
+{
+ if(_hwVal == v && _lastValidHWVal == lastv)
+ return false;
+
+ _hwVal = v;
+ // Don't want to break our own rules - _lastValidHWVal can't be unknown while _hwVal is valid...
+ // But _hwVal can be unknown while _lastValidHWVal is valid...
+ if(lastv == CTRL_VAL_UNKNOWN)
+ _lastValidHWVal = _hwVal;
+ else
+ _lastValidHWVal = lastv;
+
+ return true;
+}
+
+//---------------------------------------------------------
+// partAtTick
+//---------------------------------------------------------
+
+Part* MidiCtrlValList::partAtTick(int tick) const
+{
+ // Determine (first) part at tick. Return 0 if none found.
+
+ ciMidiCtrlVal i = lower_bound(tick);
+ if (i == end() || i->first != tick) {
+ if (i == begin())
+ return 0;
+ --i;
+ }
+ return i->second.part;
+}
+
+//---------------------------------------------------------
+// iValue
+//---------------------------------------------------------
+
+iMidiCtrlVal MidiCtrlValList::iValue(int tick)
+{
+ // Determine value at tick, using values stored by ANY part...
+
+ iMidiCtrlVal i = lower_bound(tick);
+ if (i == end() || i->first != tick) {
+ if (i == begin())
+ return end();
+ --i;
+ }
+ return i;
+}
+
+//---------------------------------------------------------
+// value
+//---------------------------------------------------------
+
+int MidiCtrlValList::value(int tick) const
+{
+ // Determine value at tick, using values stored by ANY part...
+
+ ciMidiCtrlVal i = lower_bound(tick);
+ if (i == end() || i->first != tick) {
+ if (i == begin())
+ return CTRL_VAL_UNKNOWN;
+ --i;
+ }
+ return i->second.val;
+}
+
+int MidiCtrlValList::value(int tick, Part* part) const
+{
+ // Determine value at tick, using values stored by the SPECIFIC part...
+
+ // Get the first value found with with a tick equal or greater than specified tick.
+ ciMidiCtrlVal i = lower_bound(tick);
+ // Since values from different parts can have the same tick, scan for part in all values at that tick.
+ for(ciMidiCtrlVal j = i; j != end() && j->first == tick; ++j)
+ {
+ if(j->second.part == part)
+ return j->second.val;
+ }
+ // Scan for part in all previous values, regardless of tick.
+ while(i != begin())
+ {
+ --i;
+ if(i->second.part == part)
+ return i->second.val;
+ }
+ // No previous values were found belonging to the specified part.
+ return CTRL_VAL_UNKNOWN;
+}
+
+//---------------------------------------------------------
+// add
+// return true if new controller value added or replaced
+//---------------------------------------------------------
+
+// Changed by T356.
+//bool MidiCtrlValList::add(int tick, int val)
+bool MidiCtrlValList::addMCtlVal(int tick, int val, Part* part)
+ {
+ iMidiCtrlVal e = findMCtlVal(tick, part);
+
+ if (e != end()) {
+ if(e->second.val != val)
+ {
+ e->second.val = val;
+ return true;
+ }
+ return false;
+ }
+
+ MidiCtrlVal v;
+ v.val = val;
+ v.part = part;
+ insert(std::pair<const int, MidiCtrlVal> (tick, v));
+ return true;
+ }
+
+//---------------------------------------------------------
+// del
+//---------------------------------------------------------
+
+// Changed by T356.
+//void MidiCtrlValList::del(int tick)
+void MidiCtrlValList::delMCtlVal(int tick, Part* part)
+{
+ iMidiCtrlVal e = findMCtlVal(tick, part);
+ if (e == end()) {
+ if(debugMsg)
+ printf("MidiCtrlValList::delMCtlVal(%d): not found (size %zd)\n", tick, size());
+ return;
+ }
+ erase(e);
+}
+
+//---------------------------------------------------------
+// find
+//---------------------------------------------------------
+
+// Changed by T356.
+//iMidiCtrlVal MidiCtrlValList::find(int tick, Part* part)
+iMidiCtrlVal MidiCtrlValList::findMCtlVal(int tick, Part* part)
+{
+ MidiCtrlValRange range = equal_range(tick);
+ for(iMidiCtrlVal i = range.first; i != range.second; ++i)
+ {
+ if(i->second.part == part)
+ return i;
+ }
+ return end();
+}
+
+//---------------------------------------------------------
+// MidiControllerList
+//---------------------------------------------------------
+
+MidiControllerList::MidiControllerList(const MidiControllerList& mcl) : std::map<int, MidiController*>()
+{
+ //copy(mcl);
+
+ for(ciMidiController i = mcl.begin(); i != mcl.end(); ++i)
+ {
+ MidiController* mc = i->second;
+ add(new MidiController(*mc));
+ }
+}
+
+//---------------------------------------------------------
+// copy
+//---------------------------------------------------------
+//void MidiControllerList::copy(const MidiControllerList &mcl)
+//{
+// clear();
+// for(ciMidiController i = mcl.begin(); i != mcl.end(); ++i)
+// {
+// MidiController* mc = *i;
+// push_back(new MidiController(*mc));
+// }
+//}
+
+//---------------------------------------------------------
+// operator =
+//---------------------------------------------------------
+//MidiControllerList& MidiControllerList::operator= (const MidiControllerList &mcl)
+//{
+// copy(mcl);
+// return *this;
+//}
diff --git a/attic/muse2-oom/muse2/muse/midictrl.h b/attic/muse2-oom/muse2/muse/midictrl.h
new file mode 100644
index 00000000..4c08fbe0
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midictrl.h
@@ -0,0 +1,256 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midictrl.h,v 1.16.2.8 2009/11/25 09:09:43 terminator356 Exp $
+//
+// (C) Copyright 1999-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MIDICTRL_H__
+#define __MIDICTRL_H__
+
+#include <list>
+#include <map>
+
+#include <QString>
+
+const int CTRL_HBANK = 0x00;
+const int CTRL_LBANK = 0x20;
+
+const int CTRL_HDATA = 0x06;
+const int CTRL_LDATA = 0x26;
+
+const int CTRL_HNRPN = 0x63;
+const int CTRL_LNRPN = 0x62;
+
+const int CTRL_HRPN = 0x65;
+const int CTRL_LRPN = 0x64;
+
+const int CTRL_MODULATION = 0x01;
+const int CTRL_PORTAMENTO_TIME = 0x05;
+const int CTRL_VOLUME = 0x07;
+const int CTRL_PANPOT = 0x0a;
+const int CTRL_EXPRESSION = 0x0b;
+const int CTRL_SUSTAIN = 0x40;
+const int CTRL_PORTAMENTO = 0x41;
+const int CTRL_SOSTENUTO = 0x42;
+const int CTRL_SOFT_PEDAL = 0x43;
+const int CTRL_HARMONIC_CONTENT = 0x47;
+const int CTRL_RELEASE_TIME = 0x48;
+const int CTRL_ATTACK_TIME = 0x49;
+
+const int CTRL_BRIGHTNESS = 0x4a;
+const int CTRL_PORTAMENTO_CONTROL = 0x54;
+const int CTRL_REVERB_SEND = 0x5b;
+const int CTRL_CHORUS_SEND = 0x5d;
+const int CTRL_VARIATION_SEND = 0x5e;
+
+const int CTRL_ALL_SOUNDS_OFF = 0x78; // 120
+const int CTRL_RESET_ALL_CTRL = 0x79; // 121
+const int CTRL_LOCAL_OFF = 0x7a; // 122
+
+// controller types 0x10000 - 0x1ffff are 14 bit controller with
+// 0x1xxyy
+// xx - MSB controller
+// yy - LSB controller
+
+// RPN - registered parameter numbers 0x20000 -
+// NRPN - non registered parameter numbers 0x30000 -
+
+// internal controller types:
+const int CTRL_INTERNAL_OFFSET = 0x40000;
+
+// p3.3.37
+//const int CTRL_PITCH = 0x40000;
+//const int CTRL_PROGRAM = 0x40001;
+//const int CTRL_VELOCITY = 0x40002;
+//const int CTRL_MASTER_VOLUME = 0x40003;
+const int CTRL_PITCH = CTRL_INTERNAL_OFFSET;
+const int CTRL_PROGRAM = CTRL_INTERNAL_OFFSET + 1;
+const int CTRL_VELOCITY = CTRL_INTERNAL_OFFSET + 2;
+//const int CTRL_MASTER_VOLUME = CTRL_INTERNAL_OFFSET + 3;
+
+const int CTRL_VAL_UNKNOWN = 0x10000000; // used as unknown hwVal
+
+const int CTRL_14_OFFSET = 0x10000;
+const int CTRL_RPN_OFFSET = 0x20000;
+const int CTRL_NRPN_OFFSET = 0x30000;
+const int CTRL_RPN14_OFFSET = 0x50000;
+const int CTRL_NRPN14_OFFSET = 0x60000;
+const int CTRL_NONE_OFFSET = 0x70000;
+
+class Xml;
+class Part;
+
+//---------------------------------------------------------
+// MidiController
+//---------------------------------------------------------
+
+class MidiController {
+ public:
+ //
+ // mapping of midi controller types to
+ // controller number:
+ //
+ enum ControllerType {
+ Controller7, // num values from 0 - 0x7f
+ Controller14, // values from 0x10000 - 0x12fff
+ RPN, // registered parameter 0x20000 -
+ NRPN, // non registered parameter 0x30000 -
+ RPN14, // registered parameter 0x50000
+ NRPN14, // non registered parameter 0x60000 -
+ Pitch, // num value = CTRL_PITCH
+ Program, // num value = CTRL_PROGRAM
+ Velo // not assigned
+ };
+ private:
+ QString _name;
+ int _num; // Controller Number
+ int _minVal; // controller value range (used in gui)
+ int _maxVal;
+ int _initVal;
+ int _bias;
+ void updateBias();
+
+ public:
+ MidiController();
+ MidiController(const QString& n, int num, int min, int max, int init);
+ MidiController(const MidiController& mc);
+ void copy(const MidiController &mc);
+ MidiController& operator= (const MidiController &mc);
+
+ const QString& name() const { return _name; }
+ int num() const { return _num; }
+ void setName(const QString& s) { _name = s; }
+ void setNum(int v) { _num = v; }
+ void write(int level, Xml& xml) const;
+ void read(Xml& xml);
+ int minVal() const { return _minVal; }
+ int maxVal() const { return _maxVal; }
+ int initVal() const { return _initVal; }
+ void setInitVal(int val) { _initVal = val; }
+ void setMinVal(int val) { _minVal = val; updateBias(); }
+ void setMaxVal(int val) { _maxVal = val; updateBias(); }
+ int bias() const { return _bias; }
+ static int genNum(ControllerType, int, int);
+ };
+
+// Added by T356.
+struct MidiCtrlVal
+{
+ // The part containing the event which this value came from. Used for searching and deleting.
+ Part* part;
+ // The stored value.
+ int val;
+};
+
+//---------------------------------------------------------
+// MidiCtrlValList
+// arrange controller events of a specific type in a
+// list for easy retrieval
+//---------------------------------------------------------
+
+// Changed by T356.
+//typedef std::map<int, int, std::less<int> >::iterator iMidiCtrlVal;
+//typedef std::map<int, int, std::less<int> >::const_iterator ciMidiCtrlVal;
+typedef std::multimap<int, MidiCtrlVal, std::less<int> >::iterator iMidiCtrlVal;
+typedef std::multimap<int, MidiCtrlVal, std::less<int> >::const_iterator ciMidiCtrlVal;
+
+typedef std::pair <iMidiCtrlVal, iMidiCtrlVal> MidiCtrlValRange;
+// Changed by T356.
+//class MidiCtrlValList : public std::map<int, int, std::less<int> > {
+class MidiCtrlValList : public std::multimap<int, MidiCtrlVal, std::less<int> > {
+
+ int ctrlNum;
+ int _lastValidHWVal;
+ int _hwVal; // current set value in midi hardware
+ // can be CTRL_VAL_UNKNOWN
+
+ // Hide built-in finds.
+ iMidiCtrlVal find(const int&) { return end(); };
+ ciMidiCtrlVal find(const int&) const { return end(); };
+
+ public:
+ MidiCtrlValList(int num);
+
+ Part* partAtTick(int tick) const;
+
+ iMidiCtrlVal iValue(int tick);
+ int value(int tick) const;
+ //int value(int tick, Part** part = 0) const;
+ int value(int tick, Part* part) const;
+ // Changed by T356.
+ //bool add(int tick, int value);
+ //void del(int tick);
+ bool addMCtlVal(int tick, int value, Part* part);
+ void delMCtlVal(int tick, Part* part);
+
+ iMidiCtrlVal findMCtlVal(int tick, Part* part);
+
+ int hwVal() const { return _hwVal; }
+ bool setHwVal(const int v);
+ bool setHwVals(const int v, const int lastv);
+ int num() const { return ctrlNum; }
+ int lastValidHWVal() const { return _lastValidHWVal; }
+ };
+
+//---------------------------------------------------------
+// MidiCtrlValListList
+// List of midi controller value lists.
+// This list represents the controller state of a
+// midi port.
+// index = (channelNumber << 24) + ctrlNumber
+//---------------------------------------------------------
+
+typedef std::map<int, MidiCtrlValList*, std::less<int> >::iterator iMidiCtrlValList;
+typedef std::map<int, MidiCtrlValList*, std::less<int> >::const_iterator ciMidiCtrlValList;
+
+class MidiCtrlValListList : public std::map<int, MidiCtrlValList*, std::less<int> > {
+ public:
+ void add(int channel, MidiCtrlValList* vl) {
+ insert(std::pair<const int, MidiCtrlValList*>((channel << 24) + vl->num(), vl));
+ }
+ iMidiCtrlValList find(int channel, int ctrl) {
+ return std::map<int, MidiCtrlValList*, std::less<int> >::find((channel << 24) + ctrl);
+ }
+ void clearDelete(bool deleteLists);
+ };
+
+//---------------------------------------------------------
+// MidiControllerList
+// this is a list of used midi controllers created
+// - excplicit by user
+// - implicit during import of a midi file
+//---------------------------------------------------------
+
+class MidiControllerList : public std::map<int, MidiController*, std::less<int> >
+{
+ public:
+ MidiControllerList() {}
+ MidiControllerList(const MidiControllerList& mcl);
+
+ void add(MidiController* mc) { insert(std::pair<int, MidiController*>(mc->num(), mc)); }
+};
+
+typedef MidiControllerList::iterator iMidiController;
+typedef MidiControllerList::const_iterator ciMidiController;
+typedef MidiControllerList MidiControllerList;
+
+extern MidiControllerList defaultMidiController;
+extern void initMidiController();
+extern MidiController::ControllerType midiControllerType(int num);
+
+
+extern const QString& int2ctrlType(int n);
+extern MidiController::ControllerType ctrlType2Int(const QString& s);
+extern QString midiCtrlName(int ctrl);
+extern MidiController veloCtrl;
+
+
+typedef std::map<int, int, std::less<int> > MidiCtl2LadspaPortMap;
+typedef MidiCtl2LadspaPortMap::iterator iMidiCtl2LadspaPort;
+typedef MidiCtl2LadspaPortMap::const_iterator ciMidiCtl2LadspaPort;
+
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/mididev.cpp b/attic/muse2-oom/muse2/muse/mididev.cpp
new file mode 100644
index 00000000..0aab9a71
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mididev.cpp
@@ -0,0 +1,549 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mididev.cpp,v 1.10.2.6 2009/11/05 03:14:35 terminator356 Exp $
+//
+// (C) Copyright 1999-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <config.h>
+
+#include <QMessageBox>
+#include <stdio.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include "midictrl.h"
+#include "song.h"
+#include "midi.h"
+#include "midiport.h"
+#include "mididev.h"
+#include "config.h"
+#include "globals.h"
+#include "audio.h"
+#include "midiseq.h"
+//#include "sync.h"
+#include "midiitransform.h"
+
+#ifdef MIDI_DRIVER_MIDI_SERIAL
+extern void initMidiSerial();
+#endif
+extern bool initMidiAlsa();
+extern bool initMidiJack();
+
+MidiDeviceList midiDevices;
+extern void processMidiInputTransformPlugins(MEvent&);
+
+extern unsigned int volatile lastExtMidiSyncTick;
+
+//---------------------------------------------------------
+// initMidiDevices
+//---------------------------------------------------------
+
+void initMidiDevices()
+ {
+#ifdef MIDI_DRIVER_MIDI_SERIAL
+ initMidiSerial();
+#endif
+ if(initMidiAlsa())
+ {
+ QMessageBox::critical(NULL, "MusE fatal error.", "MusE failed to initialize the\n"
+ "Alsa midi subsystem, check\n"
+ "your configuration.");
+ exit(-1);
+ }
+
+ if(initMidiJack())
+ {
+ QMessageBox::critical(NULL, "MusE fatal error.", "MusE failed to initialize the\n"
+ "Jack midi subsystem, check\n"
+ "your configuration.");
+ exit(-1);
+ }
+ }
+
+//---------------------------------------------------------
+// init
+//---------------------------------------------------------
+
+void MidiDevice::init()
+ {
+ _readEnable = false;
+ _writeEnable = false;
+ _rwFlags = 3;
+ _openFlags = 3;
+ _port = -1;
+ _nextPlayEvent = _playEvents.begin();
+ }
+
+//---------------------------------------------------------
+// MidiDevice
+//---------------------------------------------------------
+
+MidiDevice::MidiDevice()
+ {
+ ///_recBufFlipped = false;
+ //_tmpRecordCount = 0;
+ for(unsigned int i = 0; i < MIDI_CHANNELS + 1; ++i)
+ _tmpRecordCount[i] = 0;
+
+ _sysexFIFOProcessed = false;
+ //_sysexWritingChunks = false;
+ _sysexReadingChunks = false;
+
+ init();
+ }
+
+MidiDevice::MidiDevice(const QString& n)
+ : _name(n)
+ {
+ ///_recBufFlipped = false;
+ //_tmpRecordCount = 0;
+ for(unsigned int i = 0; i < MIDI_CHANNELS + 1; ++i)
+ _tmpRecordCount[i] = 0;
+
+ _sysexFIFOProcessed = false;
+ //_sysexWritingChunks = false;
+ _sysexReadingChunks = false;
+
+ init();
+ }
+
+//---------------------------------------------------------
+// filterEvent
+// return true if event filtered
+//---------------------------------------------------------
+
+//static bool filterEvent(const MEvent& event, int type, bool thru)
+bool filterEvent(const MEvent& event, int type, bool thru)
+ {
+ switch(event.type()) {
+ case ME_NOTEON:
+ case ME_NOTEOFF:
+ if (type & MIDI_FILTER_NOTEON)
+ return true;
+ break;
+ case ME_POLYAFTER:
+ if (type & MIDI_FILTER_POLYP)
+ return true;
+ break;
+ case ME_CONTROLLER:
+ if (type & MIDI_FILTER_CTRL)
+ return true;
+ if (!thru && (midiFilterCtrl1 == event.dataA()
+ || midiFilterCtrl2 == event.dataA()
+ || midiFilterCtrl3 == event.dataA()
+ || midiFilterCtrl4 == event.dataA())) {
+ return true;
+ }
+ break;
+ case ME_PROGRAM:
+ if (type & MIDI_FILTER_PROGRAM)
+ return true;
+ break;
+ case ME_AFTERTOUCH:
+ if (type & MIDI_FILTER_AT)
+ return true;
+ break;
+ case ME_PITCHBEND:
+ if (type & MIDI_FILTER_PITCH)
+ return true;
+ break;
+ case ME_SYSEX:
+ if (type & MIDI_FILTER_SYSEX)
+ return true;
+ break;
+ default:
+ break;
+ }
+ return false;
+ }
+
+//---------------------------------------------------------
+// afterProcess
+// clear all recorded events after a process cycle
+//---------------------------------------------------------
+
+void MidiDevice::afterProcess()
+{
+ //while (_tmpRecordCount--)
+ // _recordFifo.remove();
+
+ for(unsigned int i = 0; i < MIDI_CHANNELS + 1; ++i)
+ {
+ while (_tmpRecordCount[i]--)
+ _recordFifo[i].remove();
+ }
+}
+
+//---------------------------------------------------------
+// beforeProcess
+// "freeze" fifo for this process cycle
+//---------------------------------------------------------
+
+void MidiDevice::beforeProcess()
+{
+ //if (!jackPort(0).isZero())
+ // audioDriver->collectMidiEvents(this, jackPort(0));
+
+ //_tmpRecordCount = _recordFifo.getSize();
+ for(unsigned int i = 0; i < MIDI_CHANNELS + 1; ++i)
+ _tmpRecordCount[i] = _recordFifo[i].getSize();
+
+ // Reset this.
+ _sysexFIFOProcessed = false;
+}
+
+/*
+//---------------------------------------------------------
+// getEvents
+//---------------------------------------------------------
+
+void MidiDevice::getEvents(unsigned , unsigned , int ch, MPEventList* dst) //from //to
+{
+ for (int i = 0; i < _tmpRecordCount; ++i) {
+ const MidiPlayEvent& ev = _recordFifo.peek(i);
+ if (ch == -1 || (ev.channel() == ch))
+ dst->insert(ev);
+ }
+
+ //while(!recordFifo.isEmpty())
+ //{
+ // MidiPlayEvent e(recordFifo.get());
+ // if (ch == -1 || (e.channel() == ch))
+ // dst->insert(e);
+ //}
+}
+*/
+
+/*
+//---------------------------------------------------------
+// recordEvent
+//---------------------------------------------------------
+
+MREventList* MidiDevice::recordEvents()
+{
+ // Return which list is NOT currently being filled with incoming midi events. By T356.
+ if(_recBufFlipped)
+ return &_recordEvents;
+ else
+ return &_recordEvents2;
+}
+*/
+
+//---------------------------------------------------------
+// recordEvent
+//---------------------------------------------------------
+
+void MidiDevice::recordEvent(MidiRecordEvent& event)
+ {
+ // p3.3.35
+ // TODO: Tested, but record resolution not so good. Switch to wall clock based separate list in MidiDevice. And revert this line.
+ //event.setTime(audio->timestamp());
+ event.setTime(extSyncFlag.value() ? lastExtMidiSyncTick : audio->timestamp());
+
+ //printf("MidiDevice::recordEvent event time:%d\n", event.time());
+
+ // Added by Tim. p3.3.8
+
+ // By T356. Set the loop number which the event came in at.
+ //if(audio->isRecording())
+ if(audio->isPlaying())
+ event.setLoopNum(audio->loopCount());
+
+ if (midiInputTrace) {
+ printf("MidiInput: ");
+ event.dump();
+ }
+
+ int typ = event.type();
+
+ if(_port != -1)
+ {
+ int idin = midiPorts[_port].syncInfo().idIn();
+
+// p3.3.26 1/23/10 Section was disabled, enabled by Tim.
+//#if 0
+
+ //---------------------------------------------------
+ // filter some SYSEX events
+ //---------------------------------------------------
+
+ if (typ == ME_SYSEX) {
+ const unsigned char* p = event.data();
+ int n = event.len();
+ if (n >= 4) {
+ if ((p[0] == 0x7f)
+ //&& ((p[1] == 0x7f) || (p[1] == rxDeviceId))) {
+ && ((p[1] == 0x7f) || (idin == 0x7f) || (p[1] == idin))) {
+ if (p[2] == 0x06) {
+ //mmcInput(p, n);
+ midiSeq->mmcInput(_port, p, n);
+ return;
+ }
+ if (p[2] == 0x01) {
+ //mtcInputFull(p, n);
+ midiSeq->mtcInputFull(_port, p, n);
+ return;
+ }
+ }
+ else if (p[0] == 0x7e) {
+ //nonRealtimeSystemSysex(p, n);
+ midiSeq->nonRealtimeSystemSysex(_port, p, n);
+ return;
+ }
+ }
+ }
+ else
+ // p3.3.26 1/23/10 Moved here from alsaProcessMidiInput(). Anticipating Jack midi support, so don't make it ALSA specific. Tim.
+ // Trigger general activity indicator detector. Sysex has no channel, don't trigger.
+ midiPorts[_port].syncInfo().trigActDetect(event.channel());
+
+//#endif
+
+ }
+
+ //
+ // process midi event input filtering and
+ // transformation
+ //
+
+ processMidiInputTransformPlugins(event);
+
+ if (filterEvent(event, midiRecordType, false))
+ return;
+
+ if (!applyMidiInputTransformation(event)) {
+ if (midiInputTrace)
+ printf(" midi input transformation: event filtered\n");
+ return;
+ }
+
+ //
+ // transfer noteOn events to gui for step recording and keyboard
+ // remote control
+ //
+ if (typ == ME_NOTEON) {
+ int pv = ((event.dataA() & 0xff)<<8) + (event.dataB() & 0xff);
+ song->putEvent(pv);
+ }
+
+ ///if(_recBufFlipped)
+ /// _recordEvents2.add(event); // add event to secondary list of recorded events
+ ///else
+ /// _recordEvents.add(event); // add event to primary list of recorded events
+
+ //if(_recordFifo.put(MidiPlayEvent(event)))
+ // printf("MidiDevice::recordEvent: fifo overflow\n");
+
+ // p3.3.38
+ // Do not bother recording if it is NOT actually being used by a port.
+ // Because from this point on, process handles things, by selected port.
+ if(_port == -1)
+ return;
+
+ // Split the events up into channel fifos. Special 'channel' number 17 for sysex events.
+ unsigned int ch = (typ == ME_SYSEX)? MIDI_CHANNELS : event.channel();
+ if(_recordFifo[ch].put(MidiPlayEvent(event)))
+ printf("MidiDevice::recordEvent: fifo channel %d overflow\n", ch);
+ }
+
+//---------------------------------------------------------
+// find
+//---------------------------------------------------------
+
+MidiDevice* MidiDeviceList::find(const QString& s, int typeHint)
+ {
+ for (iMidiDevice i = begin(); i != end(); ++i)
+ if( (typeHint == -1 || typeHint == (*i)->deviceType()) && ((*i)->name() == s) )
+ return *i;
+ return 0;
+ }
+
+iMidiDevice MidiDeviceList::find(const MidiDevice* dev)
+ {
+ for (iMidiDevice i = begin(); i != end(); ++i)
+ if (*i == dev)
+ return i;
+ return end();
+ }
+
+//---------------------------------------------------------
+// add
+//---------------------------------------------------------
+
+void MidiDeviceList::add(MidiDevice* dev)
+ {
+ bool gotUniqueName=false;
+ int increment = 0;
+ QString origname = dev->name();
+ while (!gotUniqueName) {
+ gotUniqueName = true;
+ // check if the name's been taken
+ for (iMidiDevice i = begin(); i != end(); ++i) {
+ const QString s = (*i)->name();
+ if (s == dev->name())
+ {
+ char incstr[4];
+ sprintf(incstr,"_%d",++increment);
+ //dev->setName(origname + incstr);
+ dev->setName(origname + QString(incstr)); // p4.0.0
+ gotUniqueName = false;
+ }
+ }
+ }
+
+ push_back(dev);
+ }
+
+//---------------------------------------------------------
+// remove
+//---------------------------------------------------------
+
+void MidiDeviceList::remove(MidiDevice* dev)
+ {
+ for (iMidiDevice i = begin(); i != end(); ++i) {
+ if (*i == dev) {
+ erase(i);
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// sendNullRPNParams
+//---------------------------------------------------------
+
+bool MidiDevice::sendNullRPNParams(int chn, bool nrpn)
+{
+ if(_port == -1)
+ return false;
+
+ int nv = midiPorts[_port].nullSendValue();
+ if(nv == -1)
+ return false;
+
+ int nvh = (nv >> 8) & 0xff;
+ int nvl = nv & 0xff;
+ if(nvh != 0xff)
+ {
+ if(nrpn)
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_HNRPN, nvh & 0x7f));
+ else
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_HRPN, nvh & 0x7f));
+ }
+ if(nvl != 0xff)
+ {
+ if(nrpn)
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_LNRPN, nvl & 0x7f));
+ else
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_LRPN, nvl & 0x7f));
+ }
+ return true;
+}
+
+//---------------------------------------------------------
+// putEvent
+// return true if event cannot be delivered
+// TODO: retry on controller putMidiEvent
+//---------------------------------------------------------
+
+bool MidiDevice::putEvent(const MidiPlayEvent& ev)
+ {
+ if(!_writeEnable)
+ //return true;
+ return false;
+
+ if (ev.type() == ME_CONTROLLER) {
+ int a = ev.dataA();
+ int b = ev.dataB();
+ int chn = ev.channel();
+ if (a == CTRL_PITCH) {
+ return putMidiEvent(MidiPlayEvent(0, 0, chn, ME_PITCHBEND, b, 0));
+ }
+ if (a == CTRL_PROGRAM) {
+ // don't output program changes for GM drum channel
+ if (!(song->mtype() == MT_GM && chn == 9)) {
+ int hb = (b >> 16) & 0xff;
+ int lb = (b >> 8) & 0xff;
+ int pr = b & 0x7f;
+ if (hb != 0xff)
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_HBANK, hb));
+ if (lb != 0xff)
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_LBANK, lb));
+ return putMidiEvent(MidiPlayEvent(0, 0, chn, ME_PROGRAM, pr, 0));
+ }
+ }
+#if 1 // if ALSA cannot handle RPN NRPN etc.
+
+ // p3.3.37
+ //if (a < 0x1000) { // 7 Bit Controller
+ if (a < CTRL_14_OFFSET) { // 7 Bit Controller
+ //putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, a, b));
+ putMidiEvent(ev);
+ }
+ //else if (a < 0x20000) { // 14 bit high resolution controller
+ else if (a < CTRL_RPN_OFFSET) { // 14 bit high resolution controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ int dataH = (b >> 7) & 0x7f;
+ int dataL = b & 0x7f;
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, ctrlH, dataH));
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, ctrlL, dataL));
+ }
+ //else if (a < 0x30000) { // RPN 7-Bit Controller
+ else if (a < CTRL_NRPN_OFFSET) { // RPN 7-Bit Controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH));
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL));
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_HDATA, b));
+
+ // Added by T356. Select null parameters so that subsequent data controller
+ // events do not upset the last *RPN controller.
+ sendNullRPNParams(chn, false);
+ }
+ //else if (a < 0x40000) { // NRPN 7-Bit Controller
+ else if (a < CTRL_INTERNAL_OFFSET) { // NRPN 7-Bit Controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL));
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_HDATA, b));
+
+ sendNullRPNParams(chn, true);
+ }
+ //else if (a < 0x60000) { // RPN14 Controller
+ else if (a < CTRL_NRPN14_OFFSET) { // RPN14 Controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ int dataH = (b >> 7) & 0x7f;
+ int dataL = b & 0x7f;
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH));
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL));
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_HDATA, dataH));
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_LDATA, dataL));
+
+ sendNullRPNParams(chn, false);
+ }
+ //else if (a < 0x70000) { // NRPN14 Controller
+ else if (a < CTRL_NONE_OFFSET) { // NRPN14 Controller
+ int ctrlH = (a >> 8) & 0x7f;
+ int ctrlL = a & 0x7f;
+ int dataH = (b >> 7) & 0x7f;
+ int dataL = b & 0x7f;
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH));
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL));
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_HDATA, dataH));
+ putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_LDATA, dataL));
+
+ sendNullRPNParams(chn, true);
+ }
+ else {
+ printf("putEvent: unknown controller type 0x%x\n", a);
+ }
+ return false;
+#endif
+ }
+ return putMidiEvent(ev);
+ }
diff --git a/attic/muse2-oom/muse2/muse/mididev.h b/attic/muse2-oom/muse2/muse/mididev.h
new file mode 100644
index 00000000..16e834f2
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mididev.h
@@ -0,0 +1,162 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mididev.h,v 1.3.2.4 2009/04/04 01:49:50 terminator356 Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MIDIDEV_H__
+#define __MIDIDEV_H__
+
+#include <list>
+
+#include "mpevent.h"
+//#include "sync.h"
+#include "route.h"
+#include "globaldefs.h"
+
+#include <QString>
+
+//class RouteList;
+class Xml;
+
+//---------------------------------------------------------
+// MidiDevice
+//---------------------------------------------------------
+
+class MidiDevice {
+ MPEventList _stuckNotes;
+ MPEventList _playEvents;
+ iMPEvent _nextPlayEvent;
+ ///MREventList _recordEvents;
+ ///MREventList _recordEvents2;
+
+ // Used for multiple reads of fifos during process.
+ //int _tmpRecordCount;
+ int _tmpRecordCount[MIDI_CHANNELS + 1];
+ bool _sysexFIFOProcessed;
+
+ ///bool _recBufFlipped;
+ // Holds sync settings and detection monitors.
+ //MidiSyncInfo _syncInfo;
+
+ protected:
+ QString _name;
+ int _port; // connected to midi port; -1 - not connected
+ int _rwFlags; // possible open flags, 1 write, 2 read, 3 rw
+ int _openFlags; // configured open flags
+ bool _readEnable; // set when opened/closed.
+ bool _writeEnable; //
+ //int _sysexWriteChunk;
+ //int _sysexReadChunk;
+ //bool _sysexWritingChunks;
+ bool _sysexReadingChunks;
+
+ // Recording fifo.
+ //MidiFifo _recordFifo;
+ // Recording fifos. To speed up processing, one per channel plus one special system 'channel' for channel-less events like sysex.
+ MidiFifo _recordFifo[MIDI_CHANNELS + 1];
+
+ RouteList _inRoutes, _outRoutes;
+
+ void init();
+ virtual bool putMidiEvent(const MidiPlayEvent&) = 0;
+
+ public:
+ enum { ALSA_MIDI=0, JACK_MIDI=1, SYNTH_MIDI=2 };
+
+ MidiDevice();
+ MidiDevice(const QString& name);
+ virtual ~MidiDevice() {}
+
+ virtual int deviceType() = 0;
+
+ //virtual void* clientPort() { return 0; }
+ // p3.3.55
+ virtual void* inClientPort() { return 0; }
+ virtual void* outClientPort() { return 0; }
+
+ virtual QString open() = 0;
+ virtual void close() = 0;
+ virtual void writeRouting(int, Xml&) const { };
+
+ RouteList* inRoutes() { return &_inRoutes; }
+ RouteList* outRoutes() { return &_outRoutes; }
+ bool noInRoute() const { return _inRoutes.empty(); }
+ bool noOutRoute() const { return _outRoutes.empty(); }
+
+ const QString& name() const { return _name; }
+ virtual void setName(const QString& s) { _name = s; }
+
+ int midiPort() const { return _port; }
+ void setPort(int p) { _port = p; }
+
+ int rwFlags() const { return _rwFlags; }
+ int openFlags() const { return _openFlags; }
+ void setOpenFlags(int val) { _openFlags = val; }
+ void setrwFlags(int val) { _rwFlags = val; }
+ //MidiSyncInfo& syncInfo() { return _syncInfo; }
+
+ virtual bool isSynti() const { return false; }
+ virtual int selectRfd() { return -1; }
+ virtual int selectWfd() { return -1; }
+ virtual int bytesToWrite() { return 0; }
+ virtual void flush() {}
+ virtual void processInput() {}
+ virtual void discardInput() {}
+
+ virtual void recordEvent(MidiRecordEvent&);
+
+ virtual bool putEvent(const MidiPlayEvent&);
+
+ // For Jack-based devices - called in Jack audio process callback
+ virtual void collectMidiEvents() {}
+ virtual void processMidi() {}
+
+ MPEventList* stuckNotes() { return &_stuckNotes; }
+ MPEventList* playEvents() { return &_playEvents; }
+
+ ///MREventList* recordEvents();
+ ///void flipRecBuffer() { _recBufFlipped = _recBufFlipped ? false : true; }
+ ///bool recBufFlipped() { return _recBufFlipped; }
+ void beforeProcess();
+ void afterProcess();
+ //int tmpRecordCount() { return _tmpRecordCount; }
+ int tmpRecordCount(const unsigned int ch) { return _tmpRecordCount[ch]; }
+ //MidiFifo& recordEvents() { return _recordFifo; }
+ MidiFifo& recordEvents(const unsigned int ch) { return _recordFifo[ch]; }
+ bool sysexFIFOProcessed() { return _sysexFIFOProcessed; }
+ void setSysexFIFOProcessed(bool v) { _sysexFIFOProcessed = v; }
+ //bool sysexWritingChunks() { return _sysexWritingChunks; }
+ //void setSysexWritingChunks(bool v) { _sysexWritingChunks = v; }
+ bool sysexReadingChunks() { return _sysexReadingChunks; }
+ void setSysexReadingChunks(bool v) { _sysexReadingChunks = v; }
+ //virtual void getEvents(unsigned /*from*/, unsigned /*to*/, int /*channel*/, MPEventList* /*dst*/);
+
+ iMPEvent nextPlayEvent() { return _nextPlayEvent; }
+ void setNextPlayEvent(iMPEvent i) { _nextPlayEvent = i; }
+ bool sendNullRPNParams(int, bool);
+ };
+
+//---------------------------------------------------------
+// MidiDeviceList
+//---------------------------------------------------------
+
+typedef std::list<MidiDevice*>::iterator iMidiDevice;
+
+class MidiDeviceList : public std::list<MidiDevice*>
+{
+ public:
+ void add(MidiDevice* dev);
+ void remove(MidiDevice* dev);
+ MidiDevice* find(const QString& name, int typeHint = -1);
+ iMidiDevice find(const MidiDevice* dev);
+};
+
+extern MidiDeviceList midiDevices;
+extern void initMidiDevices();
+extern bool filterEvent(const MEvent& event, int type, bool thru);
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/midiedit/CMakeLists.txt b/attic/muse2-oom/muse2/muse/midiedit/CMakeLists.txt
new file mode 100644
index 00000000..94bed2b2
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/CMakeLists.txt
@@ -0,0 +1,105 @@
+#=============================================================================
+# MusE
+# Linux Music Editor
+# $Id:$
+#
+# Copyright (C) 2002-2006 by Werner Schweer and others
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#=============================================================================
+
+##
+## Expand Qt macros in source files
+##
+QT4_WRAP_CPP ( midiedit_mocs
+ # gatetime.h
+ # midicmd.h
+ # midieditor.h
+ # miditracker.h
+ # trackpattern.h
+ # velocity.h
+ dcanvas.h
+ dlist.h
+ drumedit.h
+ ecanvas.h
+ piano.h
+ pianoroll.h
+ prcanvas.h
+ quantconfig.h
+ )
+
+##
+## List of source files to compile
+##
+file (GLOB midiedit_source_files
+ # citem.cpp
+ # gatetime.cpp
+ # midicmd.cpp
+ # midieditor.cpp
+ # miditracker.cpp
+ # trackpattern.cpp
+ # velocity.cpp
+ dcanvas.cpp
+ dlist.cpp
+ drumedit.cpp
+ drummap.cpp
+ ecanvas.cpp
+ piano.cpp
+ pianoroll.cpp
+ prcanvas.cpp
+ quantconfig.cpp
+ )
+
+##
+## Define target
+##
+add_library ( midiedit SHARED
+ ${midiedit_source_files}
+ ${midiedit_mocs}
+ )
+
+##
+## Append to the list of translations
+##
+set (FILES_TO_TRANSLATE
+ ${FILES_TO_TRANSLATE}
+ ${midiedit_source_files}
+ CACHE INTERNAL ""
+ )
+
+##
+## Compilation flags and target name
+##
+set_target_properties( midiedit
+ PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h -fPIC"
+ OUTPUT_NAME muse_midiedit
+ )
+
+##
+## Linkage
+##
+target_link_libraries ( midiedit
+ ${QT_LIBRARIES}
+ al
+ ctrl
+ icons
+ widgets
+ ctrl
+ )
+
+##
+## Install location
+##
+install(TARGETS midiedit
+ DESTINATION ${MusE_MODULES_DIR}
+ )
diff --git a/attic/muse2-oom/muse2/muse/midiedit/cmd.h b/attic/muse2-oom/muse2/muse/midiedit/cmd.h
new file mode 100644
index 00000000..8339b7ae
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/cmd.h
@@ -0,0 +1,28 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: cmd.h,v 1.1.1.1 2003/10/27 18:52:20 wschweer Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __CMD_H__
+#define __CMD_H__
+
+#define CMD_LEFT 0
+#define CMD_RIGHT 1
+#define CMD_INSERT 2
+#define CMD_DELETE 3
+#define CMD_1 4
+#define CMD_2 5
+#define CMD_3 6
+#define CMD_4 7
+#define CMD_5 8
+#define CMD_6 9
+#define CMD_7 10
+#define CMD_T 11
+#define CMD_period 12
+#define CMD_LEFT_NOSNAP 13
+#define CMD_RIGHT_NOSNAP 14
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/midiedit/dcanvas.cpp b/attic/muse2-oom/muse2/muse/midiedit/dcanvas.cpp
new file mode 100644
index 00000000..34622296
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/dcanvas.cpp
@@ -0,0 +1,1351 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: dcanvas.cpp,v 1.16.2.10 2009/10/15 22:45:50 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QPainter>
+#include <QApplication>
+#include <QClipboard>
+#include <QDrag>
+#include <QDragLeaveEvent>
+#include <QPolygon>
+#include <QDragEnterEvent>
+#include <QDragMoveEvent>
+#include <QDropEvent>
+#include <QResizeEvent>
+
+#include <stdio.h>
+#include <values.h>
+#include <errno.h>
+//#include <sys/stat.h>
+//#include <sys/mman.h>
+
+#include "dcanvas.h"
+#include "midieditor.h"
+#include "drummap.h"
+#include "event.h"
+#include "mpevent.h"
+#include "xml.h"
+#include "globals.h"
+#include "midiport.h"
+#include "audio.h"
+#include "velocity.h"
+
+#define CARET 10
+#define CARET2 5
+
+//---------------------------------------------------------
+// DEvent
+//---------------------------------------------------------
+
+DEvent::DEvent(Event e, Part* p)
+ : CItem(e, p)
+ {
+ int instr = e.pitch();
+ int y = instr * TH + TH/2;
+ int tick = e.tick() + p->tick();
+ setPos(QPoint(tick, y));
+ setBBox(QRect(-CARET2, -CARET2, CARET, CARET));
+ }
+
+//---------------------------------------------------------
+// addItem
+//---------------------------------------------------------
+
+void DrumCanvas::addItem(Part* part, Event& event)
+ {
+ if (signed(event.tick())<0) {
+ printf("ERROR: trying to add event before current part!\n");
+ return;
+ }
+
+ DEvent* ev = new DEvent(event, part);
+ items.add(ev);
+
+ int diff = event.endTick()-part->lenTick();
+ if (diff > 0) {// too short part? extend it
+ //printf("addItem - this code should not be run!\n");
+ //Part* newPart = part->clone();
+ //newPart->setLenTick(newPart->lenTick()+diff);
+ //audio->msgChangePart(part, newPart,false);
+ //part = newPart;
+ part->setLenTick(part->lenTick()+diff);
+ }
+ }
+
+//---------------------------------------------------------
+// DrumCanvas
+//---------------------------------------------------------
+
+DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx,
+ int sy, const char* name)
+ : EventCanvas(pr, parent, sx, sy, name)
+ {
+ setVirt(false);
+ songChanged(SC_TRACK_INSERTED);
+ }
+
+//---------------------------------------------------------
+// moveCanvasItems
+//---------------------------------------------------------
+
+void DrumCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtype, int* pflags)
+{
+ if(editor->parts()->empty())
+ return;
+
+ PartsToChangeMap parts2change;
+
+ int modified = 0;
+ for(iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip)
+ {
+ Part* part = ip->second;
+ if(!part)
+ continue;
+
+ int npartoffset = 0;
+ for(iCItem ici = items.begin(); ici != items.end(); ++ici)
+ {
+ CItem* ci = ici->second;
+ if(ci->part() != part)
+ continue;
+
+ int x = ci->pos().x() + dx;
+ int y = pitch2y(y2pitch(ci->pos().y()) + dp);
+ QPoint newpos = raster(QPoint(x, y));
+
+ // Test moving the item...
+ DEvent* nevent = (DEvent*) ci;
+ Event event = nevent->event();
+ x = newpos.x();
+ if(x < 0)
+ x = 0;
+ int ntick = editor->rasterVal(x) - part->tick();
+ if(ntick < 0)
+ ntick = 0;
+ int diff = ntick + event.lenTick() - part->lenTick();
+
+ // If moving the item would require a new part size...
+ if(diff > npartoffset)
+ npartoffset = diff;
+ }
+
+ if(npartoffset > 0)
+ {
+ // Create new part...
+ // if there are several events that are moved outside the part, it will be recreated for each
+ // so the part _in_ the event will not be valid, ask the authority.
+// Part* newPart = part->clone();
+ //Part* newPart = Canvas::part()->clone();
+
+// newPart->setLenTick(newPart->lenTick() + npartoffset);
+ //audio->msgChangePart(part, newPart,false);
+
+// modified = SC_PART_MODIFIED;
+
+ // BUG FIX: #1650953
+ // Added by T356.
+ // Fixes posted "select and drag past end of part - crashing" bug
+// for(iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip)
+// {
+// if(ip->second == part)
+// {
+// editor->parts()->erase(ip);
+// break;
+// }
+// }
+
+// editor->parts()->add(newPart);
+// audio->msgChangePart(part, newPart,false);
+
+// if(parts2change.find(part) == parts2change.end())
+// parts2change.insert(std::pair<Part*, Part*> (part, newPart));
+ iPartToChange ip2c = parts2change.find(part);
+ if(ip2c == parts2change.end())
+ {
+ PartToChange p2c = {0, npartoffset};
+ parts2change.insert(std::pair<Part*, PartToChange> (part, p2c));
+ }
+ else
+ ip2c->second.xdiff = npartoffset;
+
+
+ //part = newPart; // reassign
+ //item->setPart(part);
+ //item->setEvent(newEvent);
+ //curPart = part;
+ //curPartId = curPart->sn();
+
+ }
+ }
+
+ for(iPartToChange ip2c = parts2change.begin(); ip2c != parts2change.end(); ++ip2c)
+ {
+ Part* opart = ip2c->first;
+ int diff = ip2c->second.xdiff;
+
+ Part* newPart = opart->clone();
+
+ newPart->setLenTick(newPart->lenTick() + diff);
+
+ modified = SC_PART_MODIFIED;
+
+ // BUG FIX: #1650953
+ // Added by T356.
+ // Fixes posted "select and drag past end of part - crashing" bug
+ for(iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip)
+ {
+ if(ip->second == opart)
+ {
+ editor->parts()->erase(ip);
+ break;
+ }
+ }
+
+ editor->parts()->add(newPart);
+ // Indicate no undo, and do port controller values but not clone parts.
+ //audio->msgChangePart(opart, newPart, false);
+ audio->msgChangePart(opart, newPart, false, true, false);
+
+ ip2c->second.npart = newPart;
+
+ }
+
+ iPartToChange icp = parts2change.find(curPart);
+ if(icp != parts2change.end())
+ {
+ curPart = icp->second.npart;
+ curPartId = curPart->sn();
+ }
+
+ std::vector< CItem* > doneList;
+ typedef std::vector< CItem* >::iterator iDoneList;
+
+ for(iCItem ici = items.begin(); ici != items.end(); ++ici)
+ {
+ CItem* ci = ici->second;
+
+ // If this item's part is in the parts2change list, change the item's part to the new part.
+ Part* pt = ci->part();
+ iPartToChange ip2c = parts2change.find(pt);
+ if(ip2c != parts2change.end())
+ ci->setPart(ip2c->second.npart);
+
+ int x = ci->pos().x();
+ int y = ci->pos().y();
+ int nx = x + dx;
+ int ny = pitch2y(y2pitch(y) + dp);
+ QPoint newpos = raster(QPoint(nx, ny));
+ selectItem(ci, true);
+
+ iDoneList idl;
+ for(idl = doneList.begin(); idl != doneList.end(); ++idl)
+ // This compares EventBase pointers to see if they're the same...
+ if((*idl)->event() == ci->event())
+ break;
+
+ // Do not process if the event has already been processed (meaning it's an event in a clone part)...
+ //if(moveItem(ci, newpos, dtype))
+ if(idl != doneList.end())
+ // Just move the canvas item.
+ ci->move(newpos);
+ else
+ {
+ // Currently moveItem always returns true.
+ if(moveItem(ci, newpos, dtype))
+ {
+ // Add the canvas item to the list of done items.
+ doneList.push_back(ci);
+ // Move the canvas item.
+ ci->move(newpos);
+ }
+ }
+
+ if(moving.size() == 1) {
+ itemReleased(curItem, newpos);
+ }
+ if(dtype == MOVE_COPY || dtype == MOVE_CLONE)
+ selectItem(ci, false);
+ }
+
+ if(pflags)
+ *pflags = modified;
+}
+
+//---------------------------------------------------------
+// moveItem
+//---------------------------------------------------------
+
+// Changed by T356.
+//bool DrumCanvas::moveItem(CItem* item, const QPoint& pos, DragType dtype, int* pflags)
+bool DrumCanvas::moveItem(CItem* item, const QPoint& pos, DragType dtype)
+ {
+ DEvent* nevent = (DEvent*) item;
+
+ // Changed by T356.
+ //MidiPart* part = (MidiPart*)Canvas::part(); // part can be dynamically recreated, ask the authority
+ MidiPart* part = (MidiPart*)nevent->part();
+
+ Event event = nevent->event();
+ int x = pos.x();
+ if (x < 0)
+ x = 0;
+ int ntick = editor->rasterVal(x) - part->tick();
+ if (ntick < 0)
+ ntick = 0;
+ int npitch = y2pitch(pos.y());
+ Event newEvent = event.clone();
+
+ newEvent.setPitch(npitch);
+ newEvent.setTick(ntick);
+
+ // Removed by T356.
+ /*
+ // Added by T356.
+ int modified = 0;
+ //song->startUndo();
+ int diff = newEvent.endTick()-part->lenTick();
+ if (diff > 0) // too short part? extend it
+ {
+ // if there are several events that are moved outside the part, it will be recreated for each
+ // so the part _in_ the event will not be valid, ask the authority.
+ //Part* newPart = part->clone();
+ MidiPart* newPart = (MidiPart*)Canvas::part()->clone();
+ newPart->setLenTick(newPart->lenTick()+diff);
+ audio->msgChangePart(Canvas::part(), newPart,false);
+
+ modified = SC_PART_MODIFIED;
+ part = newPart; // reassign
+ for(iPart i = editor->parts()->begin(); i != editor->parts()->end(); ++i)
+ {
+ if(i->second == Canvas::part())
+ {
+ editor->parts()->erase(i);
+ break;
+ }
+ }
+ editor->parts()->add(part);
+ item->setPart(part);
+ item->setEvent(newEvent);
+ curPart = part;
+ curPartId = curPart->sn();
+ }
+ */
+
+ // Added by T356.
+ // msgAddEvent and msgChangeEvent (below) will set these, but set them here first?
+ //item->setPart(part);
+ item->setEvent(newEvent);
+
+ // Added by T356.
+ if(((int)newEvent.endTick() - (int)part->lenTick()) > 0)
+ printf("DrumCanvas::moveItem Error! New event end:%d exceeds length:%d of part:%s\n", newEvent.endTick(), part->lenTick(), part->name().toLatin1().constData());
+
+ if (dtype == MOVE_COPY || dtype == MOVE_CLONE) {
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgAddEvent(newEvent, part, false);
+ audio->msgAddEvent(newEvent, part, false, false, false);
+ }
+ else {
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(event, newEvent, part, false);
+ audio->msgChangeEvent(event, newEvent, part, false, false, false);
+ }
+
+ // Removed by T356.
+ //if(pflags)
+ // *pflags = modified;
+
+ return true;
+ }
+
+//---------------------------------------------------------
+// newItem
+//---------------------------------------------------------
+
+CItem* DrumCanvas::newItem(const QPoint& p, int state)
+ {
+ int instr = y2pitch(p.y()); //drumInmap[y2pitch(p.y())];
+ int velo = drumMap[instr].lv4;
+ if (state == Qt::ShiftModifier)
+ velo = drumMap[instr].lv3;
+ else if (state == Qt::ControlModifier)
+ velo = drumMap[instr].lv2;
+ else if (state == (Qt::ControlModifier | Qt::ShiftModifier))
+ velo = drumMap[instr].lv1;
+ int tick = editor->rasterVal(p.x());
+ tick -= curPart->tick();
+ Event e(Note);
+ e.setTick(tick);
+ e.setPitch(instr);
+ e.setVelo(velo);
+ e.setLenTick(drumMap[instr].len);
+ return new DEvent(e, curPart);
+ }
+
+//---------------------------------------------------------
+// resizeItem
+//---------------------------------------------------------
+
+void DrumCanvas::resizeItem(CItem* item, bool)
+ {
+ DEvent* nevent = (DEvent*) item;
+ Event ev = nevent->event();
+ // Indicate do undo, and do not do port controller values and clone parts.
+ //audio->msgDeleteEvent(ev, nevent->part());
+ audio->msgDeleteEvent(ev, nevent->part(), true, false, false);
+ }
+
+//---------------------------------------------------------
+// newItem
+//---------------------------------------------------------
+
+void DrumCanvas::newItem(CItem* item, bool noSnap)
+ {
+ DEvent* nevent = (DEvent*) item;
+ Event event = nevent->event();
+ int x = item->x();
+ if (!noSnap)
+ x = editor->rasterVal(x);
+ event.setTick(x - nevent->part()->tick());
+ //int npitch = drumMap[y2pitch(item->y())].enote;
+ int npitch = event.pitch();
+ event.setPitch(npitch);
+
+ //
+ // check for existing event
+ // if found change command semantic from insert to delete
+ //
+ EventList* el = nevent->part()->events();
+ iEvent lower = el->lower_bound(event.tick());
+ iEvent upper = el->upper_bound(event.tick());
+
+ for (iEvent i = lower; i != upper; ++i) {
+ Event ev = i->second;
+ // Added by T356. Only do notes.
+ if(!ev.isNote())
+ continue;
+
+ if (ev.pitch() == npitch) {
+ // Indicate do undo, and do not do port controller values and clone parts.
+ //audio->msgDeleteEvent(ev, nevent->part());
+ audio->msgDeleteEvent(ev, nevent->part(), true, false, false);
+ return;
+ }
+ }
+
+ // Added by T356.
+ Part* part = nevent->part();
+ song->startUndo();
+ int modified=SC_EVENT_MODIFIED;
+ int diff = event.endTick()-part->lenTick();
+ if (diff > 0) {// too short part? extend it
+ //printf("extend Part!\n");
+ Part* newPart = part->clone();
+ newPart->setLenTick(newPart->lenTick()+diff);
+ // Indicate no undo, and do port controller values but not clone parts.
+ //audio->msgChangePart(part, newPart,false);
+ audio->msgChangePart(part, newPart, false, true, false);
+ modified=modified|SC_PART_MODIFIED;
+ part = newPart; // reassign
+ }
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgAddEvent(event, part,false);
+ audio->msgAddEvent(event, part, false, false, false);
+ song->endUndo(modified);
+
+ //audio->msgAddEvent(event, nevent->part());
+ }
+
+//---------------------------------------------------------
+// deleteItem
+//---------------------------------------------------------
+
+bool DrumCanvas::deleteItem(CItem* item)
+ {
+ Event ev = ((DEvent*)item)->event();
+ // Indicate do undo, and do not do port controller values and clone parts.
+ //audio->msgDeleteEvent(ev, ((DEvent*)item)->part());
+ audio->msgDeleteEvent(ev, ((DEvent*)item)->part(), true, false, false);
+ return false;
+ }
+
+//---------------------------------------------------------
+// drawItem
+//---------------------------------------------------------
+
+void DrumCanvas::drawItem(QPainter&p, const CItem*item, const QRect& rect)
+ {
+ DEvent* e = (DEvent*) item;
+ int x = 0, y = 0;
+ x = mapx(item->pos().x());
+ y = mapy(item->pos().y());
+ QPolygon pa(4);
+ pa.setPoint(0, x - CARET2, y);
+ pa.setPoint(1, x, y - CARET2);
+ pa.setPoint(2, x + CARET2, y);
+ pa.setPoint(3, x, y + CARET2);
+ QRect r(pa.boundingRect());
+ r = r.intersect(rect);
+ if(!r.isValid())
+ return;
+
+ p.setPen(Qt::black);
+
+ if (e->part() != curPart)
+ {
+ if(item->isMoving())
+ p.setBrush(Qt::gray);
+ else if(item->isSelected())
+ p.setBrush(Qt::black);
+ else
+ p.setBrush(Qt::lightGray);
+ }
+ else if (item->isMoving()) {
+ p.setBrush(Qt::gray);
+ }
+ else if (item->isSelected())
+ {
+ p.setBrush(Qt::black);
+ }
+ else
+ {
+ int velo = e->event().velo();
+ DrumMap* dm = &drumMap[y2pitch(y)]; //Get the drum item
+ QColor color;
+ if (velo < dm->lv1)
+ color.setRgb(240, 240, 255);
+ else if (velo < dm->lv2)
+ color.setRgb(200, 200, 255);
+ else if (velo < dm->lv3)
+ color.setRgb(170, 170, 255);
+ else
+ color.setRgb(0, 0, 255);
+ p.setBrush(color);
+ }
+
+ p.drawPolygon(pa);
+ }
+
+//---------------------------------------------------------
+// drawMoving
+// draws moving items
+//---------------------------------------------------------
+
+void DrumCanvas::drawMoving(QPainter& p, const CItem* item, const QRect& rect)
+ {
+ //if(((DEvent*)item)->part() != curPart)
+ // return;
+ //if(!item->isMoving())
+ // return;
+ QPolygon pa(4);
+ QPoint pt = map(item->mp());
+ int x = pt.x();
+ int y = pt.y();
+ pa.setPoint(0, x-CARET2, y + TH/2);
+ pa.setPoint(1, x, y + TH/2+CARET2);
+ pa.setPoint(2, x+CARET2, y + TH/2);
+ pa.setPoint(3, x, y + (TH-CARET)/2);
+ QRect mr(pa.boundingRect());
+ mr = mr.intersect(rect);
+ if(!mr.isValid())
+ return;
+ p.setPen(Qt::black);
+ p.setBrush(Qt::black);
+ p.drawPolygon(pa);
+ }
+
+//---------------------------------------------------------
+// drawCanvas
+//---------------------------------------------------------
+
+extern void drawTickRaster(QPainter& p, int, int, int, int, int);
+
+void DrumCanvas::drawCanvas(QPainter& p, const QRect& rect)
+ {
+ int x = rect.x();
+ int y = rect.y();
+ int w = rect.width();
+ int h = rect.height();
+
+ //---------------------------------------------------
+ // horizontal lines
+ //---------------------------------------------------
+
+ int yy = ((y-1) / TH) * TH + TH;
+ for (; yy < y + h; yy += TH) {
+ p.setPen(Qt::gray);
+ p.drawLine(x, yy, x + w, yy);
+ }
+
+ //---------------------------------------------------
+ // vertical lines
+ //---------------------------------------------------
+
+ drawTickRaster(p, x, y, w, h, editor->raster());
+ }
+
+//---------------------------------------------------------
+// y2pitch
+//---------------------------------------------------------
+
+int DrumCanvas::y2pitch(int y) const
+ {
+ int pitch = y/TH;
+ if (pitch >= DRUM_MAPSIZE)
+ pitch = DRUM_MAPSIZE-1;
+ return pitch;
+ }
+
+//---------------------------------------------------------
+// pitch2y
+//---------------------------------------------------------
+
+int DrumCanvas::pitch2y(int pitch) const
+ {
+ return pitch * TH;
+ }
+
+//---------------------------------------------------------
+// cmd
+//---------------------------------------------------------
+
+void DrumCanvas::cmd(int cmd)
+ {
+ switch(cmd) {
+ case CMD_CUT:
+ copy();
+ song->startUndo();
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ if (!i->second->isSelected())
+ continue;
+ DEvent* e = (DEvent*)(i->second);
+ Event event = e->event();
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgDeleteEvent(event, e->part(), false);
+ audio->msgDeleteEvent(event, e->part(), false, false, false);
+ }
+ song->endUndo(SC_EVENT_REMOVED);
+ break;
+ case CMD_COPY:
+ copy();
+ break;
+ case CMD_PASTE:
+ paste();
+ break;
+ case CMD_SELECT_ALL: // select all
+ for (iCItem k = items.begin(); k != items.end(); ++k) {
+ if (!k->second->isSelected())
+ selectItem(k->second, true);
+ }
+ break;
+ case CMD_SELECT_NONE: // select none
+ deselectAll();
+ break;
+ case CMD_SELECT_INVERT: // invert selection
+ for (iCItem k = items.begin(); k != items.end(); ++k) {
+ selectItem(k->second, !k->second->isSelected());
+ }
+ break;
+ case CMD_SELECT_ILOOP: // select inside loop
+ for (iCItem k = items.begin(); k != items.end(); ++k) {
+ DEvent* nevent =(DEvent*)(k->second);
+ Part* part = nevent->part();
+ Event event = nevent->event();
+ unsigned tick = event.tick() + part->tick();
+ if (tick < song->lpos() || tick >= song->rpos())
+ selectItem(k->second, false);
+ else
+ selectItem(k->second, true);
+ }
+ break;
+ case CMD_SELECT_OLOOP: // select outside loop
+ for (iCItem k = items.begin(); k != items.end(); ++k) {
+ DEvent* nevent = (DEvent*)(k->second);
+ Part* part = nevent->part();
+ Event event = nevent->event();
+ unsigned tick = event.tick() + part->tick();
+ if (tick < song->lpos() || tick >= song->rpos())
+ selectItem(k->second, true);
+ else
+ selectItem(k->second, false);
+ }
+ break;
+ case CMD_SELECT_PREV_PART: // select previous part
+ {
+ Part* pt = editor->curCanvasPart();
+ Part* newpt = pt;
+ PartList* pl = editor->parts();
+ for(iPart ip = pl->begin(); ip != pl->end(); ++ip)
+ if(ip->second == pt)
+ {
+ if(ip == pl->begin())
+ ip = pl->end();
+ --ip;
+ newpt = ip->second;
+ break;
+ }
+ if(newpt != pt)
+ editor->setCurCanvasPart(newpt);
+ }
+ break;
+ case CMD_SELECT_NEXT_PART: // select next part
+ {
+ Part* pt = editor->curCanvasPart();
+ Part* newpt = pt;
+ PartList* pl = editor->parts();
+ for(iPart ip = pl->begin(); ip != pl->end(); ++ip)
+ if(ip->second == pt)
+ {
+ ++ip;
+ if(ip == pl->end())
+ ip = pl->begin();
+ newpt = ip->second;
+ break;
+ }
+ if(newpt != pt)
+ editor->setCurCanvasPart(newpt);
+ }
+ break;
+ case CMD_DEL:
+ if (selectionSize()) {
+ song->startUndo();
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ if (!i->second->isSelected())
+ continue;
+ Event ev = i->second->event();
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgDeleteEvent(ev, i->second->part(), false);
+ audio->msgDeleteEvent(ev, i->second->part(), false, false, false);
+ }
+ song->endUndo(SC_EVENT_REMOVED);
+ }
+ return;
+
+ case CMD_SAVE:
+ case CMD_LOAD:
+ printf("DrumCanvas:: cmd not implemented %d\n", cmd);
+ break;
+
+ case CMD_FIXED_LEN: //Set notes to the length specified in the drummap
+ if (!selectionSize())
+ break;
+ song->startUndo();
+ for (iCItem k = items.begin(); k != items.end(); ++k) {
+ if (k->second->isSelected()) {
+ DEvent* devent = (DEvent*)(k->second);
+ Event event = devent->event();
+ Event newEvent = event.clone();
+ newEvent.setLenTick(drumMap[event.pitch()].len);
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(event, newEvent, devent->part() , false);
+ audio->msgChangeEvent(event, newEvent, devent->part(), false, false, false);
+ }
+ }
+ song->endUndo(SC_EVENT_MODIFIED);
+ break;
+ case CMD_LEFT:
+ {
+ int spos = pos[0];
+ if(spos > 0)
+ {
+ spos -= 1; // Nudge by -1, then snap down with raster1.
+ spos = AL::sigmap.raster1(spos, editor->rasterStep(pos[0]));
+ }
+ if(spos < 0)
+ spos = 0;
+ Pos p(spos,true);
+ song->setPos(0, p, true, true, true);
+ }
+ break;
+ case CMD_RIGHT:
+ {
+ int spos = AL::sigmap.raster2(pos[0] + 1, editor->rasterStep(pos[0])); // Nudge by +1, then snap up with raster2.
+ Pos p(spos,true);
+ song->setPos(0, p, true, true, true);
+ }
+ break;
+ case CMD_LEFT_NOSNAP:
+ {
+ int spos = pos[0] - editor->rasterStep(pos[0]);
+ if (spos < 0)
+ spos = 0;
+ Pos p(spos,true);
+ song->setPos(0, p, true, true, true); //CDW
+ }
+ break;
+ case CMD_RIGHT_NOSNAP:
+ {
+ Pos p(pos[0] + editor->rasterStep(pos[0]), true);
+ //if (p > part->tick())
+ // p = part->tick();
+ song->setPos(0, p, true, true, true); //CDW
+ }
+ break;
+ case CMD_MODIFY_VELOCITY:
+ {
+ Velocity w;
+ w.setRange(0); //TODO: Make this work! Probably put _to & _toInit in ecanvas instead
+ if (!w.exec())
+ break;
+ int range = w.range(); // all, selected, looped, sel+loop
+ int rate = w.rateVal();
+ int offset = w.offsetVal();
+
+ song->startUndo();
+ for (iCItem k = items.begin(); k != items.end(); ++k) {
+ DEvent* devent = (DEvent*)(k->second);
+ Event event = devent->event();
+ if (event.type() != Note)
+ continue;
+ unsigned tick = event.tick();
+ bool selected = k->second->isSelected();
+ bool inLoop = (tick >= song->lpos()) && (tick < song->rpos());
+
+ if ((range == 0)
+ || (range == 1 && selected)
+ || (range == 2 && inLoop)
+ || (range == 3 && selected && inLoop)) {
+ int velo = event.velo();
+
+ //velo = rate ? (velo * 100) / rate : 64;
+ velo = (velo * rate) / 100;
+ velo += offset;
+
+ if (velo <= 0)
+ velo = 1;
+ if (velo > 127)
+ velo = 127;
+ if (event.velo() != velo) {
+ Event newEvent = event.clone();
+ newEvent.setVelo(velo);
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(event, newEvent, devent->part(), false);
+ audio->msgChangeEvent(event, newEvent, devent->part(), false, false, false);
+ }
+ }
+ }
+ song->endUndo(SC_EVENT_MODIFIED);
+ }
+ break;
+ }
+ updateSelection();
+ redraw();
+ }
+
+/*
+//---------------------------------------------------------
+// getTextDrag
+//---------------------------------------------------------
+
+Q3TextDrag* DrumCanvas::getTextDrag(QWidget* parent)
+ {
+ //---------------------------------------------------
+ // generate event list from selected events
+ //---------------------------------------------------
+
+ EventList el;
+ unsigned startTick = MAXINT;
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ if (!i->second->isSelected())
+ continue;
+ DEvent* ne = (DEvent*)(i->second);
+ Event e = ne->event();
+ if (startTick == MAXINT)
+ startTick = e.tick();
+ el.add(e);
+ }
+
+ //---------------------------------------------------
+ // write events as XML into tmp file
+ //---------------------------------------------------
+
+ FILE* tmp = tmpfile();
+ if (tmp == 0) {
+ fprintf(stderr, "EventCanvas::copy() fopen failed: %s\n",
+ strerror(errno));
+ return 0;
+ }
+ Xml xml(tmp);
+
+ int level = 0;
+ for (ciEvent e = el.begin(); e != el.end(); ++e)
+ e->second.write(level, xml, -startTick);
+
+ //---------------------------------------------------
+ // read tmp file into QTextDrag Object
+ //---------------------------------------------------
+
+ fflush(tmp);
+ struct stat f_stat;
+ if (fstat(fileno(tmp), &f_stat) == -1) {
+ fprintf(stderr, "EventCanvas::copy() fstat failes:<%s>\n",
+ strerror(errno));
+ fclose(tmp);
+ return 0;
+ }
+ int n = f_stat.st_size;
+ char* fbuf = (char*)mmap(0, n+1, PROT_READ|PROT_WRITE,
+ MAP_PRIVATE, fileno(tmp), 0);
+ fbuf[n] = 0;
+ Q3TextDrag* drag = new Q3TextDrag(QString(fbuf), parent);
+ drag->setSubtype("eventlist");
+ munmap(fbuf, n);
+ fclose(tmp);
+ return drag;
+ }
+*/
+
+//---------------------------------------------------------
+// copy
+// cut copy paste
+//---------------------------------------------------------
+
+void DrumCanvas::copy()
+ {
+ //QDrag* drag = getTextDrag();
+ QMimeData* md = getTextDrag();
+
+ if (md)
+ QApplication::clipboard()->setMimeData(md, QClipboard::Clipboard);
+ }
+
+/*
+//---------------------------------------------------------
+// paste
+//---------------------------------------------------------
+
+int DrumCanvas::pasteAt(const QString& pt, int pos)
+ {
+ QByteArray ba = pt.toLatin1();
+ const char* p = ba.constData();
+ Xml xml(p);
+
+ // Added by T356.
+ int modified = SC_EVENT_INSERTED;
+
+ song->startUndo();
+ for (;;) {
+ Xml::Token token = xml.parse();
+ QString tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ song->endUndo(modified);
+ return pos;
+ case Xml::TagStart:
+ if (tag == "event") {
+ Event e(Note);
+ e.read(xml);
+
+ // Added by T356.
+ int tick = e.tick() + pos - curPart->tick();
+ if (tick<0) {
+ printf("DrumCanvas::pasteAt ERROR: trying to add event before current part!\n");
+ song->endUndo(SC_EVENT_INSERTED);
+ //delete el;
+ return pos;
+ }
+ e.setTick(tick);
+ int diff = e.endTick() - curPart->lenTick();
+ if (diff > 0) {// too short part? extend it
+ Part* newPart = curPart->clone();
+ newPart->setLenTick(newPart->lenTick()+diff);
+ // Indicate no undo, and do port controller values but not clone parts.
+ audio->msgChangePart(curPart, newPart, false, true, false);
+
+ modified=modified|SC_PART_MODIFIED;
+ curPart = newPart; // reassign
+ }
+
+ // Indicate no undo, and do not do port controller values and clone parts.
+ audio->msgAddEvent(e, curPart, false, false, false);
+ }
+ else
+ xml.unknown("DCanvas::pasteAt");
+ break;
+ case Xml::TagEnd:
+ default:
+ break;
+ }
+ }
+ }
+*/
+
+//---------------------------------------------------------
+// paste
+// paste events
+//---------------------------------------------------------
+
+void DrumCanvas::paste()
+ {
+/*
+// Q3CString subtype("eventlist"); // ddskrjo
+ QString subtype("eventlist");
+ QMimeSource* ms = QApplication::clipboard()->data();
+ QString pt;
+ if (!Q3TextDrag::decode(ms, pt, subtype)) {
+ printf("cannot paste: bad data type\n");
+ return;
+ }
+ pasteAt(pt, song->cpos());
+*/
+ QString stype("x-muse-eventlist");
+
+ //QString s = QApplication::clipboard()->text(stype, QClipboard::Selection);
+ QString s = QApplication::clipboard()->text(stype, QClipboard::Clipboard); // TODO CHECK Tim.
+
+ pasteAt(s, song->cpos());
+ }
+
+//---------------------------------------------------------
+// startDrag
+//---------------------------------------------------------
+
+void DrumCanvas::startDrag(CItem* /* item*/, bool copymode)
+ {
+ QMimeData* md = getTextDrag();
+ //QDrag* drag = getTextDrag();
+
+ if (md) {
+// QApplication::clipboard()->setData(drag, QClipboard::Clipboard); // This line NOT enabled in muse-1
+ //QApplication::clipboard()->setMimeData(md); // TODO CHECK Tim.
+ //QApplication::clipboard()->setMimeData(drag->mimeData()); //
+
+ // "Note that setMimeData() assigns ownership of the QMimeData object to the QDrag object.
+ // The QDrag must be constructed on the heap with a parent QWidget to ensure that Qt can
+ // clean up after the drag and drop operation has been completed. "
+ QDrag* drag = new QDrag(this);
+ drag->setMimeData(md);
+
+ if (copymode)
+ drag->exec(Qt::CopyAction);
+ else
+ drag->exec(Qt::MoveAction);
+ }
+ }
+
+//---------------------------------------------------------
+// dragEnterEvent
+//---------------------------------------------------------
+
+void DrumCanvas::dragEnterEvent(QDragEnterEvent* event)
+ {
+ ///event->accept(Q3TextDrag::canDecode(event));
+ event->acceptProposedAction(); // TODO CHECK Tim.
+ }
+
+//---------------------------------------------------------
+// dragMoveEvent
+//---------------------------------------------------------
+
+void DrumCanvas::dragMoveEvent(QDragMoveEvent*)
+ {
+ //printf("drag move %x\n", this); // REMOVE Tim
+ //event->acceptProposedAction();
+ }
+
+//---------------------------------------------------------
+// dragLeaveEvent
+//---------------------------------------------------------
+
+void DrumCanvas::dragLeaveEvent(QDragLeaveEvent*)
+ {
+ //printf("drag leave\n"); // REMOVE Tim
+ //event->acceptProposedAction();
+ }
+
+/*
+//---------------------------------------------------------
+// dropEvent
+//---------------------------------------------------------
+
+void DrumCanvas::viewDropEvent(QDropEvent* event)
+ {
+ QString text;
+ if (event->source() == this) {
+ printf("local DROP\n"); // REMOVE Tim
+ //event->acceptProposedAction();
+ //event->ignore(); // TODO CHECK Tim.
+ return;
+ }
+ //if (event->mimeData()->hasText()) {
+ if (event->mimeData()->hasFormat("text/x-muse-eventlist")) {
+
+ //text = event->mimeData()->text();
+ text = QString(event->mimeData()->data("text/x-muse-eventlist"));
+
+// printf("drop <%s>\n", text.ascii());
+ int x = editor->rasterVal(event->pos().x());
+ if (x < 0)
+ x = 0;
+ pasteAt(text, x);
+ //event->accept(); // TODO
+ }
+ else {
+ printf("cannot decode drop\n");
+ //event->acceptProposedAction();
+ //event->ignore(); // TODO CHECK Tim.
+ }
+ }
+*/
+
+//---------------------------------------------------------
+// keyPressed
+//---------------------------------------------------------
+
+void DrumCanvas::keyPressed(int index, bool)
+ {
+ int port = drumMap[index].port;
+ int channel = drumMap[index].channel;
+ int pitch = drumMap[index].anote;
+
+ // play note:
+ MidiPlayEvent e(0, port, channel, 0x90, pitch, 127);
+ audio->msgPlayMidiEvent(&e);
+ }
+
+//---------------------------------------------------------
+// keyReleased
+//---------------------------------------------------------
+
+void DrumCanvas::keyReleased(int index, bool)
+ {
+ int port = drumMap[index].port;
+ int channel = drumMap[index].channel;
+ int pitch = drumMap[index].anote;
+
+ // release note:
+ MidiPlayEvent e(0, port, channel, 0x90, pitch, 0);
+ audio->msgPlayMidiEvent(&e);
+ }
+
+//---------------------------------------------------------
+// mapChanged
+//---------------------------------------------------------
+
+void DrumCanvas::mapChanged(int spitch, int dpitch)
+ {
+ //TODO: Circumvent undo behaviour, since this isn't really a true change of the events,
+ // but merely a change in pitch because the pitch relates to the order of the dlist.
+ // Right now the sequencer spits out internalError: undoOp without startUndo() if start/stopundo is there, which is misleading
+ // If start/stopundo is there, undo misbehaves since it doesn't undo but messes things up
+ // Other solution: implement a specific undo-event for this (SC_DRUMMAP_MODIFIED or something) which undoes movement of
+ // dlist-items (ml)
+
+ std::vector< std::pair<Part*, Event*> > delete_events;
+ std::vector< std::pair<Part*, Event> > add_events;
+
+ typedef std::vector< std::pair<Part*, Event*> >::iterator idel_ev;
+ typedef std::vector< std::pair<Part*, Event> >::iterator iadd_ev;
+
+ /*
+ class delete_events : public std::vector< Part*, Event* >
+ {
+ public:
+ idel_ev find(Part* p, Event* e)
+ {
+
+ };
+ };
+ class add_events : public std::vector< Part*, Event >
+ {
+ public:
+ iadd_ev find(Part* p, Event& e)
+ {
+
+ };
+ };
+ */
+
+ MidiTrackList* tracks = song->midis();
+ for (ciMidiTrack t = tracks->begin(); t != tracks->end(); t++) {
+ MidiTrack* curTrack = *t;
+ if (curTrack->type() != Track::DRUM)
+ continue;
+
+ MidiPort* mp = &midiPorts[curTrack->outPort()];
+ PartList* parts= curTrack->parts();
+ for (iPart part = parts->begin(); part != parts->end(); ++part) {
+ EventList* events = part->second->events();
+ Part* thePart = part->second;
+ for (iEvent i = events->begin(); i != events->end(); ++i) {
+ Event event = i->second;
+ if(event.type() != Controller && event.type() != Note)
+ continue;
+ int pitch = event.pitch();
+ bool drc = false;
+ // Is it a drum controller event, according to the track port's instrument?
+ if(event.type() == Controller && mp->drumController(event.dataA()))
+ {
+ drc = true;
+ pitch = event.dataA() & 0x7f;
+ }
+
+ if (pitch == spitch) {
+ Event* spitch_event = &(i->second);
+ delete_events.push_back(std::pair<Part*, Event*>(thePart, spitch_event));
+ Event newEvent = spitch_event->clone();
+ if(drc)
+ newEvent.setA((newEvent.dataA() & ~0xff) | dpitch);
+ else
+ newEvent.setPitch(dpitch);
+ add_events.push_back(std::pair<Part*, Event>(thePart, newEvent));
+ }
+ else if (pitch == dpitch) {
+ Event* dpitch_event = &(i->second);
+ delete_events.push_back(std::pair<Part*, Event*>(thePart, dpitch_event));
+ Event newEvent = dpitch_event->clone();
+ if(drc)
+ newEvent.setA((newEvent.dataA() & ~0xff) | spitch);
+ else
+ newEvent.setPitch(spitch);
+ add_events.push_back(std::pair<Part*, Event>(thePart, newEvent));
+ }
+ }
+ }
+ }
+
+ song->startUndo();
+ for (idel_ev i = delete_events.begin(); i != delete_events.end(); i++) {
+ //std::pair<Part*, Event*> pair = *i;
+ //Part* thePart = pair.first;
+ //Event* theEvent = pair.second;
+ Part* thePart = (*i).first;
+ Event* theEvent = (*i).second;
+ // Indicate no undo, and do port controller values but not clone parts.
+ //audio->msgDeleteEvent(*theEvent, thePart, false);
+ audio->msgDeleteEvent(*theEvent, thePart, false, true, false);
+ }
+
+ DrumMap dm = drumMap[spitch];
+ drumMap[spitch] = drumMap[dpitch];
+ drumMap[dpitch] = dm;
+ drumInmap[int(drumMap[spitch].enote)] = spitch;
+ drumOutmap[int(drumMap[int(spitch)].anote)] = spitch;
+ drumInmap[int(drumMap[int(dpitch)].enote)] = dpitch;
+ drumOutmap[int(drumMap[int(dpitch)].anote)] = dpitch;
+
+ for (iadd_ev i = add_events.begin(); i != add_events.end(); i++) {
+ //std::pair<Part*, Event> pair = *i;
+ //Part* thePart = pair.first;
+ //Event& theEvent = pair.second;
+ Part* thePart = (*i).first;
+ Event& theEvent = (*i).second;
+ // Indicate no undo, and do port controller values but not clone parts.
+ //audio->msgAddEvent(theEvent, thePart, false);
+ audio->msgAddEvent(theEvent, thePart, false, true, false);
+ }
+
+ song->endUndo(SC_EVENT_MODIFIED);
+ song->update(SC_DRUMMAP);
+ }
+
+//---------------------------------------------------------
+// resizeEvent
+//---------------------------------------------------------
+
+void DrumCanvas::resizeEvent(QResizeEvent* ev)
+ {
+ if (ev->size().width() != ev->oldSize().width())
+ emit newWidth(ev->size().width());
+ EventCanvas::resizeEvent(ev);
+ }
+
+
+//---------------------------------------------------------
+// modifySelected
+//---------------------------------------------------------
+
+void DrumCanvas::modifySelected(NoteInfo::ValType type, int delta)
+ {
+ audio->msgIdle(true);
+ song->startUndo();
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ if (!(i->second->isSelected()))
+ continue;
+ DEvent* e = (DEvent*)(i->second);
+ Event event = e->event();
+ if (event.type() != Note)
+ continue;
+
+ MidiPart* part = (MidiPart*)(e->part());
+ Event newEvent = event.clone();
+
+ switch (type) {
+ case NoteInfo::VAL_TIME:
+ {
+ int newTime = event.tick() + delta;
+ if (newTime < 0)
+ newTime = 0;
+ newEvent.setTick(newTime);
+ }
+ break;
+ case NoteInfo::VAL_LEN:
+ /*
+ {
+ int len = event.lenTick() + delta;
+ if (len < 1)
+ len = 1;
+ newEvent.setLenTick(len);
+ }
+ */
+ printf("DrumCanvas::modifySelected - NoteInfo::VAL_LEN not implemented\n");
+ break;
+ case NoteInfo::VAL_VELON:
+ /*
+ {
+ int velo = event->velo() + delta;
+ if (velo > 127)
+ velo = 127;
+ else if (velo < 0)
+ velo = 0;
+ newEvent.setVelo(velo);
+ }
+ */
+ printf("DrumCanvas::modifySelected - NoteInfo::VAL_VELON not implemented\n");
+ break;
+ case NoteInfo::VAL_VELOFF:
+ /*
+ {
+ int velo = event.veloOff() + delta;
+ if (velo > 127)
+ velo = 127;
+ else if (velo < 0)
+ velo = 0;
+ newEvent.setVeloOff(velo);
+ }
+ */
+ printf("DrumCanvas::modifySelected - NoteInfo::VAL_VELOFF not implemented\n");
+ break;
+ case NoteInfo::VAL_PITCH:
+ {
+ int pitch = event.pitch() - delta; // Reversing order since the drumlist is displayed in increasing order
+ if (pitch > 127)
+ pitch = 127;
+ else if (pitch < 0)
+ pitch = 0;
+ newEvent.setPitch(pitch);
+ }
+ break;
+ }
+ song->changeEvent(event, newEvent, part);
+ // Indicate do not do port controller values and clone parts.
+ //song->undoOp(UndoOp::ModifyEvent, newEvent, event, part);
+ song->undoOp(UndoOp::ModifyEvent, newEvent, event, part, false, false);
+ }
+ song->endUndo(SC_EVENT_MODIFIED);
+ audio->msgIdle(false);
+ }
+
+//---------------------------------------------------------
+// curPartChanged
+//---------------------------------------------------------
+
+void DrumCanvas::curPartChanged()
+ {
+ editor->setWindowTitle(getCaption());
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/midiedit/dcanvas.h b/attic/muse2-oom/muse2/muse/midiedit/dcanvas.h
new file mode 100644
index 00000000..0b81df68
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/dcanvas.h
@@ -0,0 +1,90 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: dcanvas.h,v 1.8.2.2 2009/02/02 21:38:00 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __DCANVAS_H__
+#define __DCANVAS_H__
+
+#include "ecanvas.h"
+#include "song.h"
+
+#define TH 18
+
+
+class QResizeEvent;
+class QDragEnterEvent;
+class QDropEvent;
+class QDragMoveEvent;
+class QDragLeaveEvent;
+
+class MidiEditor;
+
+//---------------------------------------------------------
+// DEvent
+// ''visual'' Drum Event
+//---------------------------------------------------------
+
+class DEvent : public CItem {
+ public:
+ DEvent(Event e, Part* p);
+ };
+
+class ScrollScale;
+class PianoRoll;
+
+//---------------------------------------------------------
+// DrumCanvas
+//---------------------------------------------------------
+
+class DrumCanvas : public EventCanvas {
+
+ Q_OBJECT
+ virtual void drawCanvas(QPainter&, const QRect&);
+ virtual void drawItem(QPainter&, const CItem*, const QRect&);
+ virtual void drawMoving(QPainter&, const CItem*, const QRect&);
+ virtual void moveCanvasItems(CItemList&, int, int, DragType, int*);
+ // Changed by T356.
+ //virtual bool moveItem(CItem*, const QPoint&, DragType, int*);
+ virtual bool moveItem(CItem*, const QPoint&, DragType);
+ virtual CItem* newItem(const QPoint&, int);
+ virtual void resizeItem(CItem*, bool);
+ virtual void newItem(CItem*, bool);
+ virtual bool deleteItem(CItem*);
+
+ int y2pitch(int y) const;
+ int pitch2y(int pitch) const;
+ void copy();
+ void paste();
+ void startDrag(CItem*, bool copymode);
+ void dragEnterEvent(QDragEnterEvent* event);
+ void dragMoveEvent(QDragMoveEvent*);
+ void dragLeaveEvent(QDragLeaveEvent*);
+ virtual void addItem(Part*, Event&);
+ virtual void resizeEvent(QResizeEvent*);
+ virtual void curPartChanged();
+
+ signals:
+ void newWidth(int);
+
+ public slots:
+ void mapChanged(int, int);
+ void keyPressed(int, bool);
+ void keyReleased(int, bool);
+
+ public:
+ enum {
+ CMD_CUT, CMD_COPY, CMD_PASTE, CMD_SAVE, CMD_LOAD, CMD_RESET,
+ CMD_SELECT_ALL, CMD_SELECT_NONE, CMD_SELECT_INVERT,
+ CMD_SELECT_ILOOP, CMD_SELECT_OLOOP, CMD_SELECT_PREV_PART, CMD_SELECT_NEXT_PART,
+ CMD_DEL, CMD_FIXED_LEN, CMD_RIGHT, CMD_LEFT, CMD_RIGHT_NOSNAP, CMD_LEFT_NOSNAP, CMD_MODIFY_VELOCITY
+ };
+ DrumCanvas(MidiEditor*, QWidget*, int, int,
+ const char* name = 0);
+ void cmd(int);
+ virtual void modifySelected(NoteInfo::ValType type, int delta);
+ };
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/midiedit/dlist.cpp b/attic/muse2-oom/muse2/muse/midiedit/dlist.cpp
new file mode 100644
index 00000000..ee8c8e50
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/dlist.cpp
@@ -0,0 +1,752 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: dlist.cpp,v 1.9.2.7 2009/10/16 21:50:16 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QCursor>
+#include <QHeaderView>
+#include <QMenu>
+#include <QMouseEvent>
+#include <QPainter>
+#include <QPixmap>
+
+#include <stdio.h>
+
+#include "audio.h"
+#include "pitchedit.h"
+#include "midiport.h"
+#include "drummap.h"
+#include "icons.h"
+#include "dlist.h"
+#include "song.h"
+#include "scrollscale.h"
+
+// enum DCols { COL_MUTE=0, COL_NAME, COL_QNT, COL_ENOTE, COL_LEN,
+// COL_ANOTE, COL_CHANNEL, COL_PORT,
+// COL_LV1, COL_LV2, COL_LV3, COL_LV4, COL_NONE=-1};
+
+//---------------------------------------------------------
+// draw
+//---------------------------------------------------------
+
+void DList::draw(QPainter& p, const QRect& rect)
+ {
+ int x = rect.x();
+ int y = rect.y();
+ int w = rect.width();
+ int h = rect.height();
+
+ //---------------------------------------------------
+ // Tracks
+ //---------------------------------------------------
+
+ p.setPen(Qt::black);
+
+ for (int i = 0; i < DRUM_MAPSIZE; ++i) {
+ int yy = i * TH;
+ if (yy+TH < y)
+ continue;
+ if (yy > y + h)
+ break;
+ DrumMap* dm = &drumMap[i];
+// if (dm->selected)
+ if (dm == currentlySelected)
+ p.fillRect(x, yy, w, TH, Qt::yellow);
+// else
+// p.eraseRect(x, yy, w, TH);
+ QHeaderView *h = header;
+ for (int k = 0; k < h->count(); ++k) {
+ int x = h->sectionPosition(k);
+ int w = h->sectionSize(k);
+ ///QRect r = p.xForm(QRect(x+2, yy, w-4, TH));
+ QRect r = p.combinedTransform().mapRect(QRect(x+2, yy, w-4, TH));
+ QString s;
+ int align = Qt::AlignVCenter | Qt::AlignHCenter;
+
+ p.save();
+ ///p.setWorldXForm(false);
+ p.setWorldMatrixEnabled(false);
+ switch (k) {
+ case COL_VOL:
+ s.setNum(dm->vol);
+ break;
+ case COL_QNT:
+ s.setNum(dm->quant);
+ break;
+ case COL_LEN:
+ s.setNum(dm->len);
+ break;
+ case COL_ANOTE:
+ s = pitch2string(dm->anote);
+ break;
+ case COL_ENOTE:
+ s = pitch2string(dm->enote);
+ break;
+ case COL_LV1:
+ s.setNum(dm->lv1);
+ break;
+ case COL_LV2:
+ s.setNum(dm->lv2);
+ break;
+ case COL_LV3:
+ s.setNum(dm->lv3);
+ break;
+ case COL_LV4:
+ s.setNum(dm->lv4);
+ break;
+ case COL_MUTE:
+ if (dm->mute) {
+ p.setPen(Qt::red);
+ const QPixmap& pm = *muteIcon;
+ p.drawPixmap(
+ r.x() + r.width()/2 - pm.width()/2,
+ r.y() + r.height()/2 - pm.height()/2,
+ pm);
+ p.setPen(Qt::black);
+ }
+ break;
+ case COL_NAME:
+ s = dm->name;
+ align = Qt::AlignVCenter | Qt::AlignLeft;
+ break;
+ case COL_CHANNEL:
+ s.setNum(dm->channel+1);
+ break;
+ case COL_PORT:
+ s.sprintf("%d:%s", dm->port+1, midiPorts[dm->port].portname().toLatin1().constData());
+ align = Qt::AlignVCenter | Qt::AlignLeft;
+ break;
+ }
+ if (!s.isEmpty())
+ p.drawText(r, align, s);
+ p.restore();
+ }
+ }
+
+ //---------------------------------------------------
+ // horizontal lines
+ //---------------------------------------------------
+
+ p.setPen(Qt::gray);
+ int yy = (y / TH) * TH;
+ for (; yy < y + h; yy += TH) {
+ p.drawLine(x, yy, x + w, yy);
+ }
+
+ if (drag == DRAG) {
+ int y = (startY/TH) * TH;
+ int dy = startY - y;
+ int yy = curY - dy;
+ p.setPen(Qt::green);
+ p.drawLine(x, yy, x + w, yy);
+ p.drawLine(x, yy+TH, x + w, yy+TH);
+ p.setPen(Qt::gray);
+ }
+
+ //---------------------------------------------------
+ // vertical Lines
+ //---------------------------------------------------
+
+ ///p.setWorldXForm(false);
+ p.setWorldMatrixEnabled(false);
+ int n = header->count();
+ x = 0;
+ for (int i = 0; i < n; i++) {
+ //x += header->sectionSize(i);
+ x += header->sectionSize(header->visualIndex(i));
+ p.drawLine(x, 0, x, height());
+ }
+ ///p.setWorldXForm(true);
+ p.setWorldMatrixEnabled(true);
+ }
+
+//---------------------------------------------------------
+// devicesPopupMenu
+//---------------------------------------------------------
+
+void DList::devicesPopupMenu(DrumMap* t, int x, int y, bool changeAll)
+ {
+ QMenu* p = midiPortsPopup();
+ QAction* act = p->exec(mapToGlobal(QPoint(x, y)), 0);
+ bool doemit = false;
+ if (act) {
+ int n = act->data().toInt();
+ if (!changeAll)
+ {
+ if(n != t->port)
+ {
+ audio->msgIdle(true);
+ //audio->msgRemapPortDrumCtlEvents(getSelectedInstrument(), -1, -1, n);
+ song->remapPortDrumCtrlEvents(getSelectedInstrument(), -1, -1, n);
+ audio->msgIdle(false);
+ t->port = n;
+ doemit = true;
+ }
+ }
+ else {
+ audio->msgIdle(true);
+ // Delete all port controller events.
+ //audio->msgChangeAllPortDrumCtrlEvents(false);
+ song->changeAllPortDrumCtrlEvents(false);
+
+ for (int i = 0; i < DRUM_MAPSIZE; i++)
+ drumMap[i].port = n;
+ // Add all port controller events.
+ //audio->msgChangeAllPortDrumCtrlEvents(true);
+ song->changeAllPortDrumCtrlEvents(true);
+
+ audio->msgIdle(false);
+ doemit = true;
+ }
+ }
+ delete p;
+ if(doemit)
+ {
+ int instr = getSelectedInstrument();
+ if(instr != -1)
+ //emit curDrumInstrumentChanged(instr);
+ song->update(SC_DRUMMAP);
+ }
+ }
+
+//---------------------------------------------------------
+// viewMousePressEvent
+//---------------------------------------------------------
+
+void DList::viewMousePressEvent(QMouseEvent* ev)
+ {
+ int x = ev->x();
+ int y = ev->y();
+ int button = ev->button();
+ ///bool shift = ev->state() & Qt::ShiftButton;
+ bool shift = ev->modifiers() & Qt::ShiftModifier;
+ unsigned pitch = y / TH;
+ DrumMap* dm = &drumMap[pitch];
+
+ setCurDrumInstrument(pitch);
+
+ startY = y;
+ sPitch = pitch;
+ drag = START_DRAG;
+
+ DCols col = DCols(x2col(x));
+
+ int val;
+ int incVal = 0;
+ if (button == Qt::RightButton)
+ incVal = 1;
+ else if (button == Qt::MidButton)
+ incVal = -1;
+
+ // Check if we're already editing anything and have pressed the mouse
+ // elsewhere
+ // In that case, treat it as if a return was pressed
+
+ if (button == Qt::LeftButton) {
+ if (((editEntry && editEntry != dm) || col != selectedColumn) && editEntry != 0) {
+ returnPressed();
+ }
+ }
+
+ switch (col) {
+ case COL_NONE:
+ break;
+ case COL_MUTE:
+ if (button == Qt::LeftButton)
+ dm->mute = !dm->mute;
+ break;
+ case COL_PORT:
+ if (button == Qt::RightButton) {
+ ///bool changeAll = ev->state() & Qt::ControlButton;
+ bool changeAll = ev->modifiers() & Qt::ControlModifier;
+ devicesPopupMenu(dm, mapx(x), mapy(pitch * TH), changeAll);
+ }
+ break;
+ case COL_VOL:
+ val = dm->vol + incVal;
+ if (val < 0)
+ val = 0;
+ else if (val > 200)
+ val = 200;
+ dm->vol = (unsigned char)val;
+ break;
+ case COL_QNT:
+ dm->quant += incVal;
+ // ?? range
+ break;
+ case COL_ENOTE:
+ val = dm->enote + incVal;
+ if (val < 0)
+ val = 0;
+ else if (val > 127)
+ val = 127;
+ //Check if there is any other drumMap with the same inmap value (there should be one (and only one):-)
+ //If so, switch the inmap between the instruments
+ for (int i=0; i<DRUM_MAPSIZE; i++) {
+ if (drumMap[i].enote == val && &drumMap[i] != dm) {
+ drumInmap[int(dm->enote)] = i;
+ drumMap[i].enote = dm->enote;
+ break;
+ }
+ }
+ //TODO: Set all the notes on the track with pitch=dm->enote to pitch=val
+ dm->enote = val;
+ drumInmap[val] = pitch;
+ break;
+ case COL_LEN:
+ val = dm->len + incVal;
+ if (val < 0)
+ val = 0;
+ dm->len = val;
+ break;
+ case COL_ANOTE:
+ val = dm->anote + incVal;
+ if (val < 0)
+ val = 0;
+ else if (val > 127)
+ val = 127;
+ if(val != dm->anote)
+ {
+ audio->msgIdle(true);
+ //audio->msgRemapPortDrumCtlEvents(pitch, val, -1, -1);
+ song->remapPortDrumCtrlEvents(pitch, val, -1, -1);
+ audio->msgIdle(false);
+ dm->anote = val;
+ song->update(SC_DRUMMAP);
+ }
+ emit keyPressed(pitch, shift);//(dm->anote, shift);
+ break;
+ case COL_CHANNEL:
+ val = dm->channel + incVal;
+ if (val < 0)
+ val = 0;
+ else if (val > 127)
+ val = 127;
+
+ ///if (ev->state() & Qt::ControlButton) {
+ if (ev->modifiers() & Qt::ControlModifier) {
+ audio->msgIdle(true);
+ // Delete all port controller events.
+ //audio->msgChangeAllPortDrumCtrlEvents(false);
+ song->changeAllPortDrumCtrlEvents(false, true);
+
+ for (int i = 0; i < DRUM_MAPSIZE; i++)
+ drumMap[i].channel = val;
+ // Add all port controller events.
+ //audio->msgChangeAllPortDrumCtrlEvents(true);
+ song->changeAllPortDrumCtrlEvents(true, true);
+ audio->msgIdle(false);
+ song->update(SC_DRUMMAP);
+ }
+ else
+ {
+ if(val != dm->channel)
+ {
+ audio->msgIdle(true);
+ //audio->msgRemapPortDrumCtlEvents(pitch, -1, val, -1);
+ song->remapPortDrumCtrlEvents(pitch, -1, val, -1);
+ audio->msgIdle(false);
+ dm->channel = val;
+ song->update(SC_DRUMMAP);
+ }
+ }
+ break;
+ case COL_LV1:
+ val = dm->lv1 + incVal;
+ if (val < 0)
+ val = 0;
+ else if (val > 127)
+ val = 127;
+ dm->lv1 = val;
+ break;
+ case COL_LV2:
+ val = dm->lv2 + incVal;
+ if (val < 0)
+ val = 0;
+ else if (val > 127)
+ val = 127;
+ dm->lv2 = val;
+ break;
+ case COL_LV3:
+ val = dm->lv3 + incVal;
+ if (val < 0)
+ val = 0;
+ else if (val > 127)
+ val = 127;
+ dm->lv3 = val;
+ break;
+ case COL_LV4:
+ val = dm->lv4 + incVal;
+ if (val < 0)
+ val = 0;
+ else if (val > 127)
+ val = 127;
+ dm->lv4 = val;
+ break;
+ case COL_NAME:
+ emit keyPressed(pitch, shift); //Mapping done on other side, send index
+ break;
+#if 0
+ case COL_CHANNEL:
+ {
+ int channel = t->channel();
+ if (button == Qt::RightButton) {
+ if (channel < 15)
+ ++channel;
+ }
+ else if (button == Qt::MidButton) {
+ if (channel > 0)
+ --channel;
+ }
+ if (channel != t->channel()) {
+ t->setChannel(channel);
+ emit channelChanged();
+ }
+ }
+#endif
+ default:
+ break;
+ }
+ redraw();
+ }
+
+//---------------------------------------------------------
+// viewMouseDoubleClickEvent
+//---------------------------------------------------------
+
+void DList::viewMouseDoubleClickEvent(QMouseEvent* ev)
+ {
+ int x = ev->x();
+ int y = ev->y();
+// int button = ev->button();
+ unsigned pitch = y / TH;
+
+ int section = header->logicalIndexAt(x);
+
+ if ((section == COL_NAME || section == COL_VOL || section == COL_LEN || section == COL_LV1 ||
+ section == COL_LV2 || section == COL_LV3 || section == COL_LV4) && (ev->button() == Qt::LeftButton))
+ {
+ lineEdit(pitch, section);
+ }
+ else
+ viewMousePressEvent(ev);
+ }
+
+
+
+//---------------------------------------------------------
+// lineEdit
+//---------------------------------------------------------
+void DList::lineEdit(int line, int section)
+ {
+ DrumMap* dm = &drumMap[line];
+ editEntry = dm;
+ if (editor == 0) {
+ editor = new DLineEdit(this);
+ connect(editor, SIGNAL(returnPressed()),
+ SLOT(returnPressed()));
+ editor->setFrame(true);
+ }
+ int colx = mapx(header->sectionPosition(section));
+ int colw = rmapx(header->sectionSize(section));
+ int coly = mapy(line * TH);
+ int colh = rmapy(TH);
+ selectedColumn = section; //Store selected column to have an idea of which one was selected when return is pressed
+ switch (section) {
+ case COL_NAME:
+ editor->setText(dm->name);
+ break;
+
+ case COL_VOL: {
+ editor->setText(QString::number(dm->vol));
+ break;
+ }
+
+ case COL_LEN: {
+ editor->setText(QString::number(dm->len));
+ break;
+ }
+
+ case COL_LV1:
+ editor->setText(QString::number(dm->lv1));
+ break;
+
+ case COL_LV2:
+ editor->setText(QString::number(dm->lv2));
+ break;
+
+ case COL_LV3:
+ editor->setText(QString::number(dm->lv3));
+ break;
+
+ case COL_LV4:
+ editor->setText(QString::number(dm->lv4));
+ break;
+ }
+
+ // editor->setText(dm->name);
+ editor->end(false);
+ editor->setGeometry(colx, coly, colw, colh);
+ // In all cases but the column name, select all text:
+ if (section != COL_NAME)
+ editor->selectAll();
+ editor->show();
+ editor->setFocus();
+
+ }
+
+
+//---------------------------------------------------------
+// x2col
+//---------------------------------------------------------
+
+int DList::x2col(int x) const
+ {
+ int col = 0;
+ int w = 0;
+ for (; col < header->count(); col++) {
+ w += header->sectionSize(col);
+ if (x < w)
+ break;
+ }
+ if (col == header->count())
+ return -1;
+ return header->logicalIndex(col);
+ }
+
+//---------------------------------------------------------
+// setCurDrumInstrument
+//---------------------------------------------------------
+
+void DList::setCurDrumInstrument(int instr)
+ {
+ if (instr < 0 || instr >= DRUM_MAPSIZE -1)
+ return; // illegal instrument
+ DrumMap* dm = &drumMap[instr];
+ if (currentlySelected != dm) {
+ currentlySelected = &drumMap[instr];
+ emit curDrumInstrumentChanged(instr);
+ song->update(SC_DRUMMAP);
+ }
+ }
+
+//---------------------------------------------------------
+// sizeChange
+//---------------------------------------------------------
+
+void DList::sizeChange(int, int, int)
+ {
+ redraw();
+ }
+
+//---------------------------------------------------------
+// returnPressed
+//---------------------------------------------------------
+
+void DList::returnPressed()
+ {
+ int val = -1;
+ if (selectedColumn != COL_NAME)
+ {
+ ///val = atoi(editor->text().ascii());
+ val = atoi(editor->text().toAscii().constData());
+ if (selectedColumn != COL_LEN)
+ {
+ if(selectedColumn == COL_VOL)
+ {
+ if (val > 200) //Check bounds for volume
+ val = 200;
+ if (val < 0)
+ val = 0;
+ }
+ else
+ {
+ if (val > 127) //Check bounds for lv1-lv4 values
+ val = 127;
+ if (val < 0)
+ val = 0;
+ }
+ }
+ }
+
+ switch(selectedColumn) {
+ case COL_NAME:
+ editEntry->name = editor->text();
+ break;
+
+ case COL_LEN:
+ ///editEntry->len = atoi(editor->text().ascii());
+ editEntry->len = atoi(editor->text().toAscii().constData());
+ break;
+
+ case COL_VOL:
+ editEntry->vol = val;
+ break;
+
+ case COL_LV1:
+ editEntry->lv1 = val;
+ break;
+
+ case COL_LV2:
+ editEntry->lv2 = val;
+ break;
+
+ case COL_LV3:
+ editEntry->lv3 = val;
+ break;
+
+ case COL_LV4:
+ editEntry->lv4 = val;
+ break;
+
+ default:
+ printf("Return pressed in unknown column\n");
+ break;
+ }
+ selectedColumn = -1;
+ editor->hide();
+ editEntry = 0;
+ setFocus();
+ redraw();
+ }
+
+//---------------------------------------------------------
+// moved
+//---------------------------------------------------------
+
+void DList::moved(int, int, int)
+ {
+ redraw();
+ }
+
+//---------------------------------------------------------
+// tracklistChanged
+//---------------------------------------------------------
+
+void DList::tracklistChanged()
+ {
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void DList::songChanged(int flags)
+ {
+ if (flags & SC_DRUMMAP) {
+ redraw();
+ }
+ }
+
+//---------------------------------------------------------
+// DList
+//---------------------------------------------------------
+
+DList::DList(QHeaderView* h, QWidget* parent, int ymag)
+ : View(parent, 1, ymag)
+ {
+ setBg(Qt::white);
+ if (!h){
+ h = new QHeaderView(Qt::Horizontal, parent);}
+ header = h;
+ scroll = 0;
+ //ORCAN- CHECK if really needed: header->setTracking(true);
+ connect(header, SIGNAL(sectionResized(int,int,int)),
+ SLOT(sizeChange(int,int,int)));
+ connect(header, SIGNAL(sectionMoved(int, int,int)), SLOT(moved(int,int,int)));
+ setFocusPolicy(Qt::StrongFocus);
+ drag = NORMAL;
+ editor = 0;
+ editEntry = 0;
+ // always select a drum instrument
+ currentlySelected = &drumMap[0];
+ selectedColumn = -1;
+ }
+
+//---------------------------------------------------------
+// ~DList
+//---------------------------------------------------------
+
+DList::~DList()
+ {
+// if (currentlySelected != 0)
+// currentlySelected->selected = false; //Reset the global thingie
+ }
+
+//---------------------------------------------------------
+// viewMouseMoveEvent
+//---------------------------------------------------------
+
+void DList::viewMouseMoveEvent(QMouseEvent* ev)
+ {
+ curY = ev->y();
+ int delta = curY - startY;
+ switch (drag) {
+ case START_DRAG:
+ if (delta < 0)
+ delta = -delta;
+ if (delta <= 2)
+ return;
+ drag = DRAG;
+ setCursor(QCursor(Qt::SizeVerCursor));
+ redraw();
+ break;
+ case NORMAL:
+ break;
+ case DRAG:
+ redraw();
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// viewMouseReleaseEvent
+//---------------------------------------------------------
+
+void DList::viewMouseReleaseEvent(QMouseEvent* ev)
+ {
+ if (drag == DRAG) {
+ int y = ev->y();
+ unsigned dPitch = y / TH;
+ setCursor(QCursor(Qt::ArrowCursor));
+ currentlySelected = &drumMap[int(dPitch)];
+ emit curDrumInstrumentChanged(dPitch);
+ emit mapChanged(sPitch, dPitch); //Track pitch change done in canvas
+ }
+ drag = NORMAL;
+//?? redraw();
+ if (editEntry)
+ editor->setFocus();
+ int x = ev->x();
+ int y = ev->y();
+ ///bool shift = ev->state() & Qt::ShiftButton;
+ bool shift = ev->modifiers() & Qt::ShiftModifier;
+ unsigned pitch = y / TH;
+
+ DCols col = DCols(x2col(x));
+
+ switch (col) {
+ case COL_NAME:
+ emit keyReleased(pitch, shift);
+ break;
+ case COL_ANOTE:
+ emit keyReleased(pitch, shift);
+ break;
+ default:
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// getSelectedInstrument
+//---------------------------------------------------------
+
+int DList::getSelectedInstrument()
+ {
+ if (currentlySelected == 0)
+ return -1;
+ return drumInmap[int(currentlySelected->enote)];
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/midiedit/dlist.h b/attic/muse2-oom/muse2/muse/midiedit/dlist.h
new file mode 100644
index 00000000..f0dda0d4
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/dlist.h
@@ -0,0 +1,106 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: dlist.h,v 1.5.2.3 2009/10/16 21:50:16 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __DLIST_H__
+#define __DLIST_H__
+
+#include <QKeyEvent>
+#include <QLineEdit>
+
+#include "view.h"
+
+#define TH 18 // normal Track-hight
+
+class QHeaderView;
+class QMouseEvent;
+class QPainter;
+
+class ScrollScale;
+class Device;
+class QLineEdit;
+class DrumMap;
+
+
+//---------------------------------------------------------
+// DLineEdit
+//---------------------------------------------------------
+class DLineEdit: public QLineEdit
+{
+ public:
+ DLineEdit(QWidget* parent) : QLineEdit(parent) {}
+ virtual ~DLineEdit() {};
+
+ virtual void keyPressEvent(QKeyEvent* keyItem) {
+ if(keyItem->key() == Qt::Key_Escape) {
+ parentWidget()->setFocus();
+ hide();
+ }
+ else
+ QLineEdit::keyPressEvent(keyItem);
+
+ }
+};
+
+//---------------------------------------------------------
+// DList
+//---------------------------------------------------------
+
+class DList : public View {
+ QHeaderView* header;
+ ScrollScale* scroll;
+ QLineEdit* editor;
+ DrumMap* editEntry;
+ DrumMap* currentlySelected;
+ int selectedColumn;
+
+
+ int startY;
+ int curY;
+ int sPitch;
+ enum { NORMAL, START_DRAG, DRAG } drag;
+
+ virtual void draw(QPainter& p, const QRect&);
+ virtual void viewMousePressEvent(QMouseEvent* event);
+ virtual void viewMouseReleaseEvent(QMouseEvent* event);
+ virtual void viewMouseDoubleClickEvent(QMouseEvent*);
+ virtual void viewMouseMoveEvent(QMouseEvent*);
+
+ int x2col(int x) const;
+ void devicesPopupMenu(DrumMap* t, int x, int y, bool changeAll);
+ Q_OBJECT
+ //void setCurDrumInstrument(int n);
+
+ private slots:
+ void sizeChange(int, int, int);
+ void returnPressed();
+ void moved(int, int, int);
+
+ signals:
+ void channelChanged();
+ void mapChanged(int, int);
+ void keyPressed(int, bool);
+ void keyReleased(int, bool);
+ void curDrumInstrumentChanged(int);
+
+ public slots:
+ void tracklistChanged();
+ void songChanged(int);
+ public:
+ void lineEdit(int line, int section);
+ void setCurDrumInstrument(int n);
+ DList(QHeaderView*, QWidget* parent, int ymag);
+ ~DList();
+ void setScroll(ScrollScale* s) { scroll = s; }
+ int getSelectedInstrument();
+
+enum DCols { COL_MUTE=0, COL_NAME, COL_VOL, COL_QNT, COL_ENOTE, COL_LEN,
+ COL_ANOTE, COL_CHANNEL, COL_PORT,
+ COL_LV1, COL_LV2, COL_LV3, COL_LV4, COL_NONE=-1};
+ };
+
+#endif // __DLIST_H_
+
diff --git a/attic/muse2-oom/muse2/muse/midiedit/drumedit.cpp b/attic/muse2-oom/muse2/muse/midiedit/drumedit.cpp
new file mode 100644
index 00000000..7bdac223
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/drumedit.cpp
@@ -0,0 +1,1225 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: drumedit.cpp,v 1.22.2.21 2009/11/16 11:29:33 lunar_shuttle Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QAction>
+#include <QClipboard>
+#include <QCloseEvent>
+#include <QGridLayout>
+#include <QKeyEvent>
+#include <QList>
+#include <QMenu>
+#include <QMenuBar>
+#include <QMessageBox>
+#include <QPushButton>
+#include <QResizeEvent>
+#include <QSignalMapper>
+#include <QSizeGrip>
+#include <QToolButton>
+#include <QWhatsThis>
+
+#include "drumedit.h"
+#include "mtscale.h"
+#include "scrollscale.h"
+#include "xml.h"
+#include "dlist.h"
+#include "dcanvas.h"
+#include "ttoolbar.h"
+#include "tb1.h"
+#include "splitter.h"
+#include "utils.h"
+#include "../ctrl/ctrledit.h"
+#include "vscale.h"
+#include "swidget.h"
+#include "globals.h"
+#include "icons.h"
+#include "filedialog.h"
+#include "drummap.h"
+#include "audio.h"
+#include "gconfig.h"
+
+/*
+static const char* map_file_pattern[] = {
+ "Presets (*.map *.map.gz *.map.bz2)",
+ "All Files (*)",
+ 0
+ };
+static const char* map_file_save_pattern[] = {
+ "Presets (*.map)",
+ "gzip compressed presets (*.map.gz)",
+ "bzip2 compressed presets (*.map.bz2)",
+ "All Files (*)",
+ 0
+ };
+*/
+
+int DrumEdit::_quantInit = 96;
+int DrumEdit::_rasterInit = 96;
+int DrumEdit::_widthInit = 600;
+int DrumEdit::_heightInit = 400;
+int DrumEdit::_dlistWidthInit = 50;
+int DrumEdit::_dcanvasWidthInit = 300;
+int DrumEdit::_toInit = 0;
+
+static const int xscale = -10;
+static const int yscale = 1;
+static const int drumeditTools = PointerTool | PencilTool | RubberTool;
+
+enum DrumColumn {
+ COL_MUTE = 0,
+ COL_NAME,
+ COL_VOLUME,
+ COL_QUANT,
+ COL_INPUTTRIGGER,
+ COL_NOTELENGTH,
+ COL_NOTE,
+ COL_OUTCHANNEL,
+ COL_OUTPORT,
+ COL_LEVEL1,
+ COL_LEVEL2,
+ COL_LEVEL3,
+ COL_LEVEL4,
+ COL_NONE = -1
+};
+
+//---------------------------------------------------------
+// setHeaderWhatsThis
+//---------------------------------------------------------
+
+void DrumEdit::setHeaderWhatsThis()
+ {
+ header->setWhatsThis(COL_MUTE, tr("mute instrument"));
+ header->setWhatsThis(COL_NAME, tr("sound name"));
+ header->setWhatsThis(COL_VOLUME, tr("volume percent"));
+ header->setWhatsThis(COL_QUANT, tr("quantisation"));
+ header->setWhatsThis(COL_INPUTTRIGGER, tr("this input note triggers the sound"));
+ header->setWhatsThis(COL_NOTELENGTH, tr("note length"));
+ header->setWhatsThis(COL_NOTE, tr("this is the note which is played"));
+ header->setWhatsThis(COL_OUTCHANNEL, tr("output channel (hold ctl to affect all rows)"));
+ header->setWhatsThis(COL_OUTPORT, tr("output port"));
+ header->setWhatsThis(COL_LEVEL1, tr("shift + control key: draw velocity level 1"));
+ header->setWhatsThis(COL_LEVEL2, tr("control key: draw velocity level 2"));
+ header->setWhatsThis(COL_LEVEL3, tr("shift key: draw velocity level 3"));
+ header->setWhatsThis(COL_LEVEL4, tr("draw velocity level 4"));
+ }
+
+//---------------------------------------------------------
+// setHeaderToolTips
+//---------------------------------------------------------
+
+void DrumEdit::setHeaderToolTips()
+ {
+ header->setToolTip(COL_MUTE, tr("mute instrument"));
+ header->setToolTip(COL_NAME, tr("sound name"));
+ header->setToolTip(COL_VOLUME, tr("volume percent"));
+ header->setToolTip(COL_QUANT, tr("quantisation"));
+ header->setToolTip(COL_INPUTTRIGGER, tr("this input note triggers the sound"));
+ header->setToolTip(COL_NOTELENGTH, tr("note length"));
+ header->setToolTip(COL_NOTE, tr("this is the note which is played"));
+ header->setToolTip(COL_OUTCHANNEL, tr("output channel (ctl: affect all rows)"));
+ header->setToolTip(COL_OUTPORT, tr("output port"));
+ header->setToolTip(COL_LEVEL1, tr("shift + control key: draw velocity level 1"));
+ header->setToolTip(COL_LEVEL2, tr("control key: draw velocity level 2"));
+ header->setToolTip(COL_LEVEL3, tr("shift key: draw velocity level 3"));
+ header->setToolTip(COL_LEVEL4, tr("draw velocity level 4"));
+ }
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void DrumEdit::closeEvent(QCloseEvent* e)
+ {
+ //Store values of the horizontal splitter
+ QList<int> sizes = split2->sizes();
+ QList<int>::iterator it = sizes.begin();
+ _dlistWidthInit = *it; //There are only 2 values stored in the sizelist, size of dlist widget and dcanvas widget
+ it++;
+ _dcanvasWidthInit = *it;
+ emit deleted((unsigned long)this);
+ e->accept();
+ }
+
+//---------------------------------------------------------
+// DrumEdit
+//---------------------------------------------------------
+
+DrumEdit::DrumEdit(PartList* pl, QWidget* parent, const char* name, unsigned initPos)
+ : MidiEditor(_quantInit, _rasterInit, pl, parent, name)
+ {
+ split1w1 = 0;
+ resize(_widthInit, _heightInit);
+ selPart = 0;
+ _to = _toInit;
+ QSignalMapper *signalMapper = new QSignalMapper(this);
+
+ //---------Pulldown Menu----------------------------
+ menuFile = menuBar()->addMenu(tr("&File"));
+
+ loadAction = menuFile->addAction(QIcon(*openIcon), tr("Load Map"));
+ saveAction = menuFile->addAction(QIcon(*saveIcon), tr("Save Map"));
+ resetAction = menuFile->addAction(tr("Reset GM Map"));
+
+ connect(loadAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+ connect(saveAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+ connect(resetAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+
+ signalMapper->setMapping(loadAction, DrumCanvas::CMD_LOAD);
+ signalMapper->setMapping(saveAction, DrumCanvas::CMD_SAVE);
+ signalMapper->setMapping(resetAction, DrumCanvas::CMD_RESET);
+
+ menuEdit = menuBar()->addMenu(tr("&Edit"));
+ menuEdit->addActions(undoRedo->actions());
+
+ menuEdit->addSeparator();
+ cutAction = menuEdit->addAction(QIcon(*editcutIconSet), tr("Cut"));
+ copyAction = menuEdit->addAction(QIcon(*editcopyIconSet), tr("Copy"));
+ pasteAction = menuEdit->addAction(QIcon(*editpasteIconSet), tr("Paste"));
+ menuEdit->addSeparator();
+ deleteAction = menuEdit->addAction(tr("Delete Events"));
+
+ connect(cutAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+ connect(copyAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+ connect(pasteAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+ connect(deleteAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+
+ signalMapper->setMapping(cutAction, DrumCanvas::CMD_CUT);
+ signalMapper->setMapping(copyAction, DrumCanvas::CMD_COPY);
+ signalMapper->setMapping(pasteAction, DrumCanvas::CMD_PASTE);
+ signalMapper->setMapping(deleteAction, DrumCanvas::CMD_DEL);
+
+ menuSelect = menuEdit->addMenu(QIcon(*selectIcon), tr("&Select"));
+
+ sallAction = menuSelect->addAction(QIcon(*select_allIcon), tr("Select All"));
+ snoneAction = menuSelect->addAction(QIcon(*select_deselect_allIcon), tr("Select None"));
+ invAction = menuSelect->addAction(QIcon(*select_invert_selectionIcon), tr("Invert"));
+ menuSelect->addSeparator();
+ inAction = menuSelect->addAction(QIcon(*select_inside_loopIcon), tr("Inside Loop"));
+ outAction = menuSelect->addAction(QIcon(*select_outside_loopIcon), tr("Outside Loop"));
+
+ menuSelect->addSeparator();
+
+ prevAction = menuSelect->addAction(QIcon(*select_all_parts_on_trackIcon), tr("Previous Part"));
+ nextAction = menuSelect->addAction(QIcon(*select_all_parts_on_trackIcon), tr("Next Part"));
+
+ connect(sallAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+ connect(snoneAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+ connect(invAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+ connect(inAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+ connect(outAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+ connect(prevAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+ connect(nextAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+
+ signalMapper->setMapping(sallAction, DrumCanvas::CMD_SELECT_ALL);
+ signalMapper->setMapping(snoneAction, DrumCanvas::CMD_SELECT_NONE);
+ signalMapper->setMapping(invAction, DrumCanvas::CMD_SELECT_INVERT);
+ signalMapper->setMapping(inAction, DrumCanvas::CMD_SELECT_ILOOP);
+ signalMapper->setMapping(outAction, DrumCanvas::CMD_SELECT_OLOOP);
+ signalMapper->setMapping(prevAction, DrumCanvas::CMD_SELECT_PREV_PART);
+ signalMapper->setMapping(nextAction, DrumCanvas::CMD_SELECT_NEXT_PART);
+
+ // Functions
+ menuFunctions = menuBar()->addMenu(tr("&Functions"));
+
+ menuFunctions->setTearOffEnabled(true);
+
+ fixedAction = menuFunctions->addAction(tr("Set Fixed Length"));
+ veloAction = menuFunctions->addAction(tr("Modify Velocity"));
+
+ connect(fixedAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+ connect(veloAction, SIGNAL(triggered()), signalMapper, SLOT(map()));
+
+ signalMapper->setMapping(fixedAction, DrumCanvas::CMD_FIXED_LEN);
+ signalMapper->setMapping(veloAction, DrumCanvas::CMD_MODIFY_VELOCITY);
+
+ QMenu* menuScriptPlugins = menuBar()->addMenu(tr("&Plugins"));
+ song->populateScriptMenu(menuScriptPlugins, this);
+
+ connect(signalMapper, SIGNAL(mapped(int)), SLOT(cmd(int)));
+
+ //---------------------------------------------------
+ // Toolbars
+ //---------------------------------------------------
+
+ tools = addToolBar(tr("Drum tools"));
+
+ QToolButton *ldm = new QToolButton();
+ ldm->setToolTip(tr("Load Drummap"));
+ ldm->setIcon(*openIcon);
+ connect(ldm, SIGNAL(clicked()), SLOT(load()));
+ tools->addWidget(ldm);
+
+ QToolButton *sdm = new QToolButton();
+ sdm->setToolTip(tr("Store Drummap"));
+ sdm->setIcon(*saveIcon);
+ connect(sdm, SIGNAL(clicked()), SLOT(save()));
+ tools->addWidget(sdm);
+
+ tools->addAction(QWhatsThis::createAction());
+
+ tools->addSeparator();
+ tools->addActions(undoRedo->actions());
+ tools->addSeparator();
+
+ srec = new QToolButton();
+ srec->setToolTip(tr("Step Record"));
+ srec->setIcon(*steprecIcon);
+ srec->setCheckable(true);
+ tools->addWidget(srec);
+
+ midiin = new QToolButton();
+ midiin->setToolTip(tr("Midi Input"));
+ midiin->setIcon(*midiinIcon);
+ midiin->setCheckable(true);
+ tools->addWidget(midiin);
+
+ tools2 = new EditToolBar(this, drumeditTools);
+ addToolBar(tools2);
+
+ QToolBar* panicToolbar = addToolBar(tr("panic"));
+ panicToolbar->addAction(panicAction);
+
+ QToolBar* transport = addToolBar(tr("transport"));
+ transport->addActions(transportAction->actions());
+
+ addToolBarBreak();
+ // don't show pitch value in toolbar
+ toolbar = new Toolbar1(this, _rasterInit, _quantInit, false);
+ addToolBar(toolbar);
+
+ addToolBarBreak();
+ info = new NoteInfo(this);
+ addToolBar(info);
+
+ //---------------------------------------------------
+ // split
+ //---------------------------------------------------
+
+ split1 = new Splitter(Qt::Vertical, mainw, "split1");
+ QPushButton* ctrl = new QPushButton(tr("ctrl"), mainw);
+ ctrl->setObjectName("Ctrl");
+ ctrl->setFont(config.fonts[3]);
+ hscroll = new ScrollScale(-25, -2, xscale, 20000, Qt::Horizontal, mainw);
+ ctrl->setFixedSize(40, hscroll->sizeHint().height());
+ ctrl->setToolTip(tr("Add Controller View"));
+
+ QSizeGrip* corner = new QSizeGrip(mainw);
+ corner->setFixedHeight(hscroll->sizeHint().height());
+
+ mainGrid->setRowStretch(0, 100);
+ mainGrid->setColumnStretch(1, 100);
+
+ mainGrid->addWidget(split1, 0, 0, 1, 3);
+ mainGrid->addWidget(ctrl, 1, 0);
+ mainGrid->addWidget(hscroll, 1, 1);
+ mainGrid->addWidget(corner, 1, 2, Qt::AlignBottom|Qt::AlignRight);
+// mainGrid->addRowSpacing(1, hscroll->sizeHint().height());
+// mainGrid->addItem(new QSpacerItem(0, hscroll->sizeHint().height()), 1, 0);
+
+ split2 = new Splitter(Qt::Horizontal, split1, "split2");
+ split1w1 = new QWidget(split2);
+ QWidget* split1w2 = new QWidget(split2);
+ QGridLayout* gridS1 = new QGridLayout(split1w1);
+ QGridLayout* gridS2 = new QGridLayout(split1w2);
+ gridS1->setContentsMargins(0, 0, 0, 0);
+ gridS1->setSpacing(0);
+ gridS2->setContentsMargins(0, 0, 0, 0);
+ gridS2->setSpacing(0);
+ time = new MTScale(&_raster, split1w2, xscale);
+ canvas = new DrumCanvas(this, split1w2, xscale, yscale);
+ vscroll = new ScrollScale(-4, 1, yscale, DRUM_MAPSIZE*TH, Qt::Vertical, split1w2);
+ int offset = -(config.division/4);
+ canvas->setOrigin(offset, 0);
+ canvas->setCanvasTools(drumeditTools);
+ canvas->setFocus();
+ connect(canvas, SIGNAL(toolChanged(int)), tools2, SLOT(set(int)));
+ time->setOrigin(offset, 0);
+
+ QList<int> mops;
+ mops.append(_dlistWidthInit);
+ mops.append(_dcanvasWidthInit);
+ split2->setSizes(mops);
+ // By T356. Not much choice but to disable this for now, to stop runaway resize bug.
+ // Can't seem to get the splitter to readjust when manually setting sizes.
+ //split2->setResizeMode(split1w1, QSplitter::KeepSize);
+
+ gridS2->setRowStretch(1, 100);
+ gridS2->setColumnStretch(0, 100);
+
+ gridS2->addWidget(time, 0, 0, 1, 2);
+ gridS2->addWidget(hLine(split1w2), 1, 0, 1, 2);
+ gridS2->addWidget(canvas, 2, 0);
+
+ gridS2->addWidget(vscroll, 2, 1);
+ //
+ // Reihenfolge in dlist.c festgeschrieben ("Dcols")
+ //
+ header = new Header(split1w1, "header");
+ header->setFixedHeight(31);
+ header->setColumnLabel(tr("M"), COL_MUTE, 20);
+ header->setColumnLabel(tr("Sound"), COL_NAME, 120);
+ header->setColumnLabel(tr("Vol"), COL_VOLUME);
+ header->setColumnLabel(tr("QNT"), COL_QUANT, 30);
+ header->setColumnLabel(tr("E-Note"), COL_INPUTTRIGGER, 50);
+ header->setColumnLabel(tr("Len"), COL_NOTELENGTH);
+ header->setColumnLabel(tr("A-Note"), COL_NOTE, 50);
+ header->setColumnLabel(tr("Ch"), COL_OUTCHANNEL);
+ header->setColumnLabel(tr("Port"), COL_OUTPORT, 70);
+ header->setColumnLabel(tr("LV1"), COL_LEVEL1);
+ header->setColumnLabel(tr("LV2"), COL_LEVEL2);
+ header->setColumnLabel(tr("LV3"), COL_LEVEL3);
+ header->setColumnLabel(tr("LV4"), COL_LEVEL4);
+
+ setHeaderToolTips();
+ setHeaderWhatsThis();
+
+ dlist = new DList(header, split1w1, yscale);
+ // p3.3.44
+ setCurDrumInstrument(dlist->getSelectedInstrument());
+
+ connect(dlist, SIGNAL(keyPressed(int, bool)), canvas, SLOT(keyPressed(int, bool)));
+ connect(dlist, SIGNAL(keyReleased(int, bool)), canvas, SLOT(keyReleased(int, bool)));
+ connect(dlist, SIGNAL(mapChanged(int, int)), canvas, SLOT(mapChanged(int, int)));
+
+ gridS1->setRowStretch(1, 100);
+ gridS1->setColumnStretch(0, 100);
+ gridS1->addWidget(header, 0, 0);
+ gridS1->addWidget(dlist, 1, 0);
+
+ connect(canvas, SIGNAL(newWidth(int)), SLOT(newCanvasWidth(int)));
+ connect(canvas, SIGNAL(verticalScroll(unsigned)), vscroll, SLOT(setPos(unsigned)));
+ connect(canvas, SIGNAL(horizontalScroll(unsigned)),hscroll, SLOT(setPos(unsigned)));
+ connect(canvas, SIGNAL(horizontalScrollNoLimit(unsigned)),hscroll, SLOT(setPosNoLimit(unsigned)));
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged1(int)));
+ connect(song, SIGNAL(songChanged(int)), dlist, SLOT(songChanged(int)));
+ connect(vscroll, SIGNAL(scrollChanged(int)), canvas, SLOT(setYPos(int)));
+ connect(vscroll, SIGNAL(scaleChanged(int)), canvas, SLOT(setYMag(int)));
+ connect(vscroll, SIGNAL(scaleChanged(int)), dlist, SLOT(setYMag(int)));
+ connect(hscroll, SIGNAL(scrollChanged(int)), canvas, SLOT(setXPos(int)));
+ connect(hscroll, SIGNAL(scaleChanged(int)), canvas, SLOT(setXMag(int)));
+ connect(srec, SIGNAL(toggled(bool)), canvas, SLOT(setSteprec(bool)));
+ connect(midiin, SIGNAL(toggled(bool)), canvas, SLOT(setMidiin(bool)));
+
+ connect(vscroll, SIGNAL(scrollChanged(int)), dlist, SLOT(setYPos(int)));
+ connect(hscroll, SIGNAL(scrollChanged(int)), time, SLOT(setXPos(int)));
+ connect(hscroll, SIGNAL(scaleChanged(int)), time, SLOT(setXMag(int)));
+
+ connect(tools2, SIGNAL(toolChanged(int)), canvas, SLOT(setTool(int)));
+
+ connect(canvas, SIGNAL(selectionChanged(int, Event&, Part*)), this,
+ SLOT(setSelection(int, Event&, Part*)));
+ connect(canvas, SIGNAL(followEvent(int)), SLOT(follow(int)));
+
+ connect(hscroll, SIGNAL(scaleChanged(int)), SLOT(updateHScrollRange()));
+ setWindowTitle(canvas->getCaption());
+
+ updateHScrollRange();
+
+ // connect toolbar
+ connect(canvas, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
+ connect(time, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
+ connect(toolbar, SIGNAL(quantChanged(int)), SLOT(setQuant(int)));
+ connect(toolbar, SIGNAL(rasterChanged(int)), SLOT(setRaster(int)));
+ connect(toolbar, SIGNAL(soloChanged(bool)), SLOT(soloChanged(bool)));
+ connect(info, SIGNAL(valueChanged(NoteInfo::ValType, int)), SLOT(noteinfoChanged(NoteInfo::ValType, int)));
+
+ connect(ctrl, SIGNAL(clicked()), SLOT(addCtrl()));
+
+ QClipboard* cb = QApplication::clipboard();
+ connect(cb, SIGNAL(dataChanged()), SLOT(clipboardChanged()));
+
+ clipboardChanged(); // enable/disable "Paste"
+ selectionChanged(); // enable/disable "Copy" & "Paste"
+ initShortcuts();
+
+ const Pos cpos=song->cPos();
+ canvas->setPos(0, cpos.tick(), true);
+ canvas->selectAtTick(cpos.tick());
+ //canvas->selectFirst();
+
+ if(canvas->track())
+ toolbar->setSolo(canvas->track()->solo());
+
+ unsigned pos;
+ if(initPos >= MAXINT)
+ pos = song->cpos();
+ else
+ pos = initPos;
+ if(pos > MAXINT)
+ pos = MAXINT;
+ hscroll->setOffset((int)pos);
+ }
+
+//---------------------------------------------------------
+// songChanged1
+//---------------------------------------------------------
+
+void DrumEdit::songChanged1(int bits)
+ {
+ if (bits & SC_SOLO)
+ {
+ toolbar->setSolo(canvas->track()->solo());
+ return;
+ }
+ songChanged(bits);
+
+ }
+
+//---------------------------------------------------------
+// updateHScrollRange
+//---------------------------------------------------------
+
+void DrumEdit::updateHScrollRange()
+{
+ int s, e;
+ canvas->range(&s, &e);
+ // Show one more measure.
+ e += AL::sigmap.ticksMeasure(e);
+ // Show another quarter measure due to imprecise drawing at canvas end point.
+ e += AL::sigmap.ticksMeasure(e) / 4;
+ // Compensate for drum list, splitter handle, and vscroll widths.
+ e += canvas->rmapxDev(dlist->width() + split2->handleWidth() - vscroll->width());
+ int s1, e1;
+ hscroll->range(&s1, &e1);
+ if(s != s1 || e != e1)
+ hscroll->setRange(s, e);
+}
+
+//---------------------------------------------------------
+// follow
+//---------------------------------------------------------
+
+void DrumEdit::follow(int pos)
+ {
+ int s, e;
+ canvas->range(&s, &e);
+
+ if (pos < e && pos >= s)
+ hscroll->setOffset(pos);
+ if (pos < s)
+ hscroll->setOffset(s);
+ }
+
+//---------------------------------------------------------
+// setTime
+//---------------------------------------------------------
+
+void DrumEdit::setTime(unsigned tick)
+ {
+ toolbar->setTime(tick);
+ time->setPos(3, tick, false);
+ }
+
+//---------------------------------------------------------
+// ~DrumEdit
+//---------------------------------------------------------
+
+DrumEdit::~DrumEdit()
+ {
+ //undoRedo->removeFrom(tools); // p4.0.6 Removed
+ }
+
+//---------------------------------------------------------
+// setSelection
+// update Info Line
+//---------------------------------------------------------
+
+void DrumEdit::setSelection(int tick, Event& e, Part* p)
+ {
+ selEvent = e;
+ selPart = (MidiPart*)p;
+ selTick = tick;
+ info->setEnabled(!e.empty());
+ if (!e.empty()) {
+ info->setValues(tick,
+ selEvent.lenTick(),
+ selEvent.pitch(),
+ selEvent.velo(),
+ selEvent.veloOff());
+ }
+ selectionChanged();
+ }
+
+//---------------------------------------------------------
+// soloChanged
+//---------------------------------------------------------
+
+void DrumEdit::soloChanged(bool flag)
+ {
+ audio->msgSetSolo(canvas->track(), flag);
+ song->update(SC_SOLO);
+ }
+
+//---------------------------------------------------------
+// setRaster
+//---------------------------------------------------------
+
+void DrumEdit::setRaster(int val)
+ {
+ _rasterInit = val;
+ MidiEditor::setRaster(val);
+ canvas->redrawGrid();
+ }
+
+//---------------------------------------------------------
+// setQuant
+//---------------------------------------------------------
+
+void DrumEdit::setQuant(int val)
+ {
+ _quantInit = val;
+ MidiEditor::setQuant(val);
+ }
+
+//---------------------------------------------------------
+// edit currently selected Event
+//---------------------------------------------------------
+
+void DrumEdit::noteinfoChanged(NoteInfo::ValType type, int val)
+ {
+ if (selEvent.empty()) {
+ printf("noteinfoChanged while note is zero %d\n", type);
+ return;
+ }
+ Event event = selEvent.clone();
+ switch (type) {
+ case NoteInfo::VAL_TIME:
+ event.setTick(val - selPart->tick());
+ break;
+ case NoteInfo::VAL_LEN:
+ event.setLenTick(val);
+ break;
+ case NoteInfo::VAL_VELON:
+ event.setVelo(val);
+ break;
+ case NoteInfo::VAL_VELOFF:
+ event.setVeloOff(val);
+ break;
+ case NoteInfo::VAL_PITCH:
+ event.setPitch(val);
+ break;
+ }
+ // Indicate do undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(selEvent, event, selPart);
+ audio->msgChangeEvent(selEvent, event, selPart, true, false, false);
+ }
+
+//---------------------------------------------------------
+// writeStatus
+//---------------------------------------------------------
+
+void DrumEdit::writeStatus(int level, Xml& xml) const
+ {
+ writePartList(level, xml);
+ xml.tag(level++, "drumedit");
+ MidiEditor::writeStatus(level, xml);
+
+ for (std::list<CtrlEdit*>::const_iterator i = ctrlEditList.begin();
+ i != ctrlEditList.end(); ++i) {
+ (*i)->writeStatus(level, xml);
+ }
+
+ split1->writeStatus(level, xml);
+ split2->writeStatus(level, xml);
+
+ header->writeStatus(level, xml);
+ xml.intTag(level, "steprec", canvas->steprec());
+ xml.intTag(level, "midiin", canvas->midiin());
+ xml.intTag(level, "xpos", hscroll->pos());
+ xml.intTag(level, "xmag", hscroll->mag());
+ xml.intTag(level, "ypos", vscroll->pos());
+ xml.intTag(level, "ymag", vscroll->mag());
+ xml.tag(level, "/drumedit");
+ }
+
+//---------------------------------------------------------
+// readStatus
+//---------------------------------------------------------
+
+void DrumEdit::readStatus(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "steprec") {
+ int val = xml.parseInt();
+ canvas->setSteprec(val);
+ srec->setChecked(val);
+ }
+ else if (tag == "midiin") {
+ int val = xml.parseInt();
+ canvas->setMidiin(val);
+ midiin->setChecked(val);
+ }
+ else if (tag == "ctrledit") {
+ CtrlEdit* ctrl = addCtrl();
+ ctrl->readStatus(xml);
+ }
+ else if (tag == split1->objectName())
+ split1->readStatus(xml);
+ else if (tag == split2->objectName())
+ split2->readStatus(xml);
+ else if (tag == "midieditor")
+ MidiEditor::readStatus(xml);
+ else if (tag == header->objectName())
+ header->readStatus(xml);
+ else if (tag == "xmag")
+ hscroll->setMag(xml.parseInt());
+ else if (tag == "xpos")
+ hscroll->setPos(xml.parseInt());
+ else if (tag == "ymag")
+ vscroll->setMag(xml.parseInt());
+ else if (tag == "ypos")
+ vscroll->setPos(xml.parseInt());
+ else
+ xml.unknown("DrumEdit");
+ break;
+ case Xml::TagEnd:
+ if (tag == "drumedit") {
+ _quantInit = _quant;
+ _rasterInit = _raster;
+ toolbar->setRaster(_raster);
+ toolbar->setQuant(_quant);
+ canvas->redrawGrid();
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// readConfiguration
+//---------------------------------------------------------
+
+void DrumEdit::readConfiguration(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "quant")
+ _quantInit = xml.parseInt();
+ else if (tag == "raster")
+ _rasterInit = xml.parseInt();
+ else if (tag == "width")
+ _widthInit = xml.parseInt();
+ else if (tag == "height")
+ _heightInit = xml.parseInt();
+ else if (tag == "dcanvaswidth")
+ _dcanvasWidthInit = xml.parseInt();
+ else if (tag == "dlistwidth")
+ _dlistWidthInit = xml.parseInt();
+ else if (tag == "to") {
+ _toInit = xml.parseInt();
+ }
+ else
+ xml.unknown("DrumEdit");
+ break;
+ case Xml::TagEnd:
+ if (tag == "drumedit") {
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// writeConfiguration
+//---------------------------------------------------------
+
+void DrumEdit::writeConfiguration(int level, Xml& xml)
+ {
+ xml.tag(level++, "drumedit");
+ xml.intTag(level, "quant", _quantInit);
+ xml.intTag(level, "raster", _rasterInit);
+ xml.intTag(level, "width", _widthInit);
+ xml.intTag(level, "height", _heightInit);
+ xml.intTag(level, "dlistwidth", _dlistWidthInit);
+ xml.intTag(level, "dcanvaswidth", _dcanvasWidthInit);
+ xml.intTag(level, "to", _toInit);
+ xml.tag(level, "/drumedit");
+ }
+
+//---------------------------------------------------------
+// load
+//---------------------------------------------------------
+
+void DrumEdit::load()
+ {
+ //QString fn = getOpenFileName("drummaps", map_file_pattern,
+ QString fn = getOpenFileName("drummaps", drum_map_file_pattern,
+ this, tr("Muse: Load Drum Map"), 0);
+ if (fn.isEmpty())
+ return;
+ bool popenFlag;
+ FILE* f = fileOpen(this, fn, QString(".map"), "r", popenFlag, true);
+ if (f == 0)
+ return;
+
+ Xml xml(f);
+ int mode = 0;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (mode == 0 && tag == "muse")
+ mode = 1;
+ else if (mode == 1 && tag == "drummap") {
+ readDrumMap(xml, true);
+ mode = 0;
+ }
+ else
+ xml.unknown("DrumEdit");
+ break;
+ case Xml::Attribut:
+ break;
+ case Xml::TagEnd:
+ if (!mode && tag == "muse")
+ goto ende;
+ default:
+ break;
+ }
+ }
+ende:
+ if (popenFlag)
+ pclose(f);
+ else
+ fclose(f);
+ dlist->redraw();
+ canvas->redraw();
+ }
+
+//---------------------------------------------------------
+// save
+//---------------------------------------------------------
+
+void DrumEdit::save()
+ {
+ //QString fn = getSaveFileName(QString("drummaps"), map_file_pattern,
+ QString fn = getSaveFileName(QString("drummaps"), drum_map_file_save_pattern,
+ this, tr("MusE: Store Drum Map"));
+ if (fn.isEmpty())
+ return;
+ bool popenFlag;
+ FILE* f = fileOpen(this, fn, QString(".map"), "w", popenFlag, false, true);
+ if (f == 0)
+ return;
+ Xml xml(f);
+ xml.header();
+ xml.tag(0, "muse version=\"1.0\"");
+ writeDrumMap(1, xml, true);
+ xml.tag(1, "/muse");
+
+ if (popenFlag)
+ pclose(f);
+ else
+ fclose(f);
+ }
+
+//---------------------------------------------------------
+// reset
+//---------------------------------------------------------
+
+void DrumEdit::reset()
+{
+ if(QMessageBox::warning(this, tr("Drum map"),
+ tr("Reset the drum map with GM defaults?"),
+ QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok) == QMessageBox::Ok)
+ {
+ resetGMDrumMap();
+ dlist->redraw();
+ canvas->redraw();
+ }
+}
+
+//---------------------------------------------------------
+// cmd
+// pulldown menu commands
+//---------------------------------------------------------
+
+void DrumEdit::cmd(int cmd)
+ {
+ switch(cmd) {
+ case DrumCanvas::CMD_LOAD:
+ load();
+ break;
+ case DrumCanvas::CMD_SAVE:
+ save();
+ break;
+ case DrumCanvas::CMD_RESET:
+ reset();
+ break;
+ default:
+ ((DrumCanvas*)(canvas))->cmd(cmd);
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// clipboardChanged
+//---------------------------------------------------------
+
+void DrumEdit::clipboardChanged()
+ {
+ pasteAction->setEnabled(QApplication::clipboard()->mimeData()->hasFormat(QString("text/x-muse-eventlist")));
+ }
+
+//---------------------------------------------------------
+// selectionChanged
+//---------------------------------------------------------
+
+void DrumEdit::selectionChanged()
+ {
+ bool flag = canvas->selectionSize() > 0;
+ cutAction->setEnabled(flag);
+ copyAction->setEnabled(flag);
+ deleteAction->setEnabled(flag);
+ }
+
+//---------------------------------------------------------
+// addCtrl
+//---------------------------------------------------------
+
+CtrlEdit* DrumEdit::addCtrl()
+ {
+ CtrlEdit* ctrlEdit = new CtrlEdit(split1, this, xscale, true, "drumCtrlEdit");
+ connect(hscroll, SIGNAL(scrollChanged(int)), ctrlEdit, SLOT(setXPos(int)));
+ connect(hscroll, SIGNAL(scaleChanged(int)), ctrlEdit, SLOT(setXMag(int)));
+ connect(ctrlEdit, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
+ connect(ctrlEdit, SIGNAL(destroyedCtrl(CtrlEdit*)), SLOT(removeCtrl(CtrlEdit*)));
+ connect(ctrlEdit, SIGNAL(yposChanged(int)), toolbar, SLOT(setInt(int)));
+ connect(tools2, SIGNAL(toolChanged(int)), ctrlEdit, SLOT(setTool(int)));
+ connect(dlist, SIGNAL(curDrumInstrumentChanged(int)), SLOT(setCurDrumInstrument(int)));
+
+ //printf("DrumEdit::addCtrl curDrumInstrument:%d\n", dlist->getSelectedInstrument());
+
+ setCurDrumInstrument(dlist->getSelectedInstrument());
+
+ // p3.3.44
+ ctrlEdit->setTool(tools2->curTool());
+
+ ctrlEdit->setXPos(hscroll->pos());
+ ctrlEdit->setXMag(hscroll->getScaleValue());
+
+ if(split1w1)
+ {
+ ///split2->setCollapsible(split1w1, false);
+ split2->setCollapsible(split2->indexOf(split1w1), false);
+ split1w1->setMinimumWidth(CTRL_PANEL_FIXED_WIDTH);
+ }
+
+ int dw = vscroll->width() - 18;// 18 is the fixed width of the CtlEdit VScale widget.
+ if(dw < 1)
+ dw = 1;
+ ctrlEdit->setCanvasWidth(canvas->width() + dw);
+
+ ctrlEdit->show();
+ ctrlEditList.push_back(ctrlEdit);
+ return ctrlEdit;
+ }
+
+//---------------------------------------------------------
+// removeCtrl
+//---------------------------------------------------------
+
+void DrumEdit::removeCtrl(CtrlEdit* ctrl)
+ {
+ for (std::list<CtrlEdit*>::iterator i = ctrlEditList.begin();
+ i != ctrlEditList.end(); ++i) {
+ if (*i == ctrl) {
+ ctrlEditList.erase(i);
+ break;
+ }
+ }
+
+ if(split1w1)
+ {
+ if(ctrlEditList.empty())
+ {
+ split1w1->setMinimumWidth(0);
+ ///split2->setCollapsible(split1w1, true);
+ split2->setCollapsible(split2->indexOf(split1w1), true);
+ }
+ }
+ }
+//---------------------------------------------------------
+// newCanvasWidth
+//---------------------------------------------------------
+
+void DrumEdit::newCanvasWidth(int w)
+ {
+ int nw = w + (vscroll->width() - 18); // 18 is the fixed width of the CtlEdit VScale widget.
+ if(nw < 1)
+ nw = 1;
+
+ for (std::list<CtrlEdit*>::iterator i = ctrlEditList.begin();
+ i != ctrlEditList.end(); ++i) {
+ // Changed by Tim. p3.3.7
+ //(*i)->setCanvasWidth(w);
+ (*i)->setCanvasWidth(nw);
+ }
+
+ updateHScrollRange();
+ }
+
+//---------------------------------------------------------
+// resizeEvent
+//---------------------------------------------------------
+
+void DrumEdit::resizeEvent(QResizeEvent* ev)
+ {
+ QWidget::resizeEvent(ev);
+ _widthInit = ev->size().width();
+ _heightInit = ev->size().height();
+
+ //TODO: Make the dlist not expand/shrink, but the canvas instead
+ }
+
+
+//---------------------------------------------------------
+// configChanged
+//---------------------------------------------------------
+
+void DrumEdit::configChanged()
+ {
+ initShortcuts();
+ }
+
+static int rasterTable[] = {
+ //-9----8- 7 6 5 4 3(1/4) 2 1
+ 4, 8, 16, 32, 64, 128, 256, 512, 1024, // triple
+ 6, 12, 24, 48, 96, 192, 384, 768, 1536,
+ 9, 18, 36, 72, 144, 288, 576, 1152, 2304 // dot
+ };
+
+//---------------------------------------------------------
+// keyPressEvent
+//---------------------------------------------------------
+void DrumEdit::keyPressEvent(QKeyEvent* event)
+ {
+ DrumCanvas* dc = (DrumCanvas*)canvas;
+ int index = 0;
+ int n = sizeof(rasterTable);
+ for (; index < n; ++index)
+ if (rasterTable[index] == raster())
+ break;
+ int off = (index / 9) * 9;
+ index = index % 9;
+ int val;
+ int key = event->key();
+
+ if (((QInputEvent*)event)->modifiers() & Qt::ShiftModifier)
+ key += Qt::SHIFT;
+ if (((QInputEvent*)event)->modifiers() & Qt::AltModifier)
+ key += Qt::ALT;
+ if (((QInputEvent*)event)->modifiers() & Qt::ControlModifier)
+ key+= Qt::CTRL;
+
+ if (key == Qt::Key_Escape) {
+ close();
+ return;
+ }
+ else if (key == Qt::Key_Up) {
+ dlist->setCurDrumInstrument(dlist->getSelectedInstrument()-1);
+ dlist->redraw();
+ return;
+ }
+ else if (key == Qt::Key_F2) {
+ dlist->lineEdit(dlist->getSelectedInstrument(),(int)DList::COL_NAME);
+ return;
+ }
+ else if (key == Qt::Key_Down) {
+ dlist->setCurDrumInstrument(dlist->getSelectedInstrument()+1);
+ dlist->redraw();
+ return;
+ }
+
+ else if (key == shortcuts[SHRT_POS_INC].key) {
+ dc->cmd(DrumCanvas::CMD_RIGHT);
+ return;
+ }
+ else if (key == shortcuts[SHRT_POS_DEC].key) {
+ dc->cmd(DrumCanvas::CMD_LEFT);
+ return;
+ }
+
+ else if (key == shortcuts[SHRT_POS_INC_NOSNAP].key) {
+ dc->cmd(DrumCanvas::CMD_RIGHT_NOSNAP);
+ return;
+ }
+ else if (key == shortcuts[SHRT_POS_DEC_NOSNAP].key) {
+ dc->cmd(DrumCanvas::CMD_LEFT_NOSNAP);
+ return;
+ }
+
+ else if (key == shortcuts[SHRT_TOOL_POINTER].key) {
+ tools2->set(PointerTool);
+ return;
+ }
+ else if (key == shortcuts[SHRT_TOOL_PENCIL].key) {
+ tools2->set(PencilTool);
+ return;
+ }
+ else if (key == shortcuts[SHRT_TOOL_RUBBER].key) {
+ tools2->set(RubberTool);
+ return;
+ }
+ else if (key == shortcuts[SHRT_ZOOM_IN].key) {
+ int mag = hscroll->mag();
+ int zoomlvl = ScrollScale::getQuickZoomLevel(mag);
+ if (zoomlvl < 23)
+ zoomlvl++;
+
+ int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl);
+ hscroll->setMag(newmag);
+ //printf("mag = %d zoomlvl = %d newmag = %d\n", mag, zoomlvl, newmag);
+ return;
+ }
+ else if (key == shortcuts[SHRT_ZOOM_OUT].key) {
+ int mag = hscroll->mag();
+ int zoomlvl = ScrollScale::getQuickZoomLevel(mag);
+ if (zoomlvl > 1)
+ zoomlvl--;
+
+ int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl);
+ hscroll->setMag(newmag);
+ //printf("mag = %d zoomlvl = %d newmag = %d\n", mag, zoomlvl, newmag);
+ return;
+ }
+ else if (key == shortcuts[SHRT_SCROLL_LEFT].key) {
+ int pos = hscroll->pos() - config.division;
+ if (pos < 0)
+ pos = 0;
+ hscroll->setPos(pos);
+ return;
+ }
+ else if (key == shortcuts[SHRT_SCROLL_RIGHT].key) {
+ int pos = hscroll->pos() + config.division;
+ hscroll->setPos(pos);
+ return;
+ }
+
+ /*
+ else if (key == shortcuts[SHRT_INSERT_AT_LOCATION].key) {
+ pc->pianoCmd(CMD_INSERT);
+ return;
+ }
+ */
+ else if (key == shortcuts[SHRT_SET_QUANT_1].key)
+ val = rasterTable[8 + off];
+ else if (key == shortcuts[SHRT_SET_QUANT_2].key)
+ val = rasterTable[7 + off];
+ else if (key == shortcuts[SHRT_SET_QUANT_3].key)
+ val = rasterTable[6 + off];
+ else if (key == shortcuts[SHRT_SET_QUANT_4].key)
+ val = rasterTable[5 + off];
+ else if (key == shortcuts[SHRT_SET_QUANT_5].key)
+ val = rasterTable[4 + off];
+ else if (key == shortcuts[SHRT_SET_QUANT_6].key)
+ val = rasterTable[3 + off];
+ else if (key == shortcuts[SHRT_SET_QUANT_7].key)
+ val = rasterTable[2 + off];
+ else if (key == shortcuts[SHRT_TOGGLE_TRIOL].key)
+ val = rasterTable[index + ((off == 0) ? 9 : 0)];
+ /*
+ else if (key == shortcuts[SHRT_EVENT_COLOR].key) {
+ if (colorMode == 0)
+ colorMode = 1;
+ else if (colorMode == 1)
+ colorMode = 2;
+ else
+ colorMode = 0;
+ setEventColorMode(colorMode);
+ return;
+ }*/
+ else if (key == shortcuts[SHRT_TOGGLE_PUNCT].key)
+ val = rasterTable[index + ((off == 18) ? 9 : 18)];
+
+ else if (key == shortcuts[SHRT_TOGGLE_PUNCT2].key) {//CDW
+ if ((off == 18) && (index > 2)) {
+ val = rasterTable[index + 9 - 1];
+ }
+ else if ((off == 9) && (index < 8)) {
+ val = rasterTable[index + 18 + 1];
+ }
+ else
+ return;
+ }
+ else { //Default:
+ event->ignore();
+ return;
+ }
+ setQuant(val);
+ setRaster(val);
+ toolbar->setQuant(_quant);
+ toolbar->setRaster(_raster);
+ }
+
+
+
+//---------------------------------------------------------
+// initShortcuts
+//---------------------------------------------------------
+
+void DrumEdit::initShortcuts()
+ {
+ loadAction->setShortcut(shortcuts[SHRT_OPEN].key);
+ saveAction->setShortcut(shortcuts[SHRT_SAVE].key);
+
+ cutAction->setShortcut(shortcuts[SHRT_CUT].key);
+ copyAction->setShortcut(shortcuts[SHRT_COPY].key);
+ pasteAction->setShortcut(shortcuts[SHRT_PASTE].key);
+ deleteAction->setShortcut(shortcuts[SHRT_DELETE].key);
+
+ fixedAction->setShortcut(shortcuts[SHRT_FIXED_LEN].key);
+ veloAction->setShortcut(shortcuts[SHRT_MODIFY_VELOCITY].key);
+
+ sallAction->setShortcut(shortcuts[SHRT_SELECT_ALL].key);
+ snoneAction->setShortcut(shortcuts[SHRT_SELECT_NONE].key);
+ invAction->setShortcut(shortcuts[SHRT_SELECT_INVERT].key);
+ inAction->setShortcut(shortcuts[SHRT_SELECT_ILOOP].key);
+ outAction->setShortcut(shortcuts[SHRT_SELECT_OLOOP].key);
+
+ prevAction->setShortcut(shortcuts[SHRT_SELECT_PREV_PART].key);
+ nextAction->setShortcut(shortcuts[SHRT_SELECT_NEXT_PART].key);
+ }
+
+//---------------------------------------------------------
+// execDeliveredScript
+//---------------------------------------------------------
+void DrumEdit::execDeliveredScript(int id)
+{
+ //QString scriptfile = QString(INSTPREFIX) + SCRIPTSSUFFIX + deliveredScriptNames[id];
+ QString scriptfile = song->getScriptPath(id, true);
+ song->executeScript(scriptfile.toLatin1().constData(), parts(), quant(), true);
+}
+
+//---------------------------------------------------------
+// execUserScript
+//---------------------------------------------------------
+void DrumEdit::execUserScript(int id)
+{
+ QString scriptfile = song->getScriptPath(id, false);
+ song->executeScript(scriptfile.toLatin1().constData(), parts(), quant(), true);
+}
+
diff --git a/attic/muse2-oom/muse2/muse/midiedit/drumedit.h b/attic/muse2-oom/muse2/muse/midiedit/drumedit.h
new file mode 100644
index 00000000..5d2df9f6
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/drumedit.h
@@ -0,0 +1,128 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: drumedit.h,v 1.9.2.7 2009/11/16 11:29:33 lunar_shuttle Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __DRUM_EDIT_H__
+#define __DRUM_EDIT_H__
+
+#include <values.h>
+#include "midieditor.h"
+#include "noteinfo.h"
+#include "cobject.h"
+#include "tools.h"
+#include "header.h"
+#include "shortcuts.h"
+#include "event.h"
+
+class QCloseEvent;
+class QLabel;
+class QMenu;
+class QKeyEvent;
+class QResizeEvent;
+class QToolButton;
+class QWidget;
+
+class MidiPart;
+class DrumCanvas;
+class ScrollScale;
+class ScoreConfig;
+class MTScale;
+class Splitter;
+class PartList;
+class Toolbar1;
+class CtrlCanvas;
+class Xml;
+class DList;
+class Header;
+class CtrlEdit;
+class Part;
+class SNode;
+
+//---------------------------------------------------------
+// DrumEdit
+//---------------------------------------------------------
+
+class DrumEdit : public MidiEditor {
+ Event selEvent;
+ MidiPart* selPart;
+ int selTick;
+ QMenu* menuEdit, *menuFunctions, *menuFile, *menuSelect;
+
+ NoteInfo* info;
+ QToolButton* srec;
+ QToolButton* midiin;
+ EditToolBar* tools2;
+
+ Toolbar1* toolbar;
+ Splitter* split1;
+ Splitter* split2;
+ QWidget* split1w1;
+ DList* dlist;
+ Header* header;
+ QToolBar* tools;
+
+ static int _quantInit, _rasterInit;
+ static int _widthInit, _heightInit;
+ static int _dlistWidthInit, _dcanvasWidthInit;
+
+ static int _toInit; //Used in function dialog for applying modification to selection
+
+ QAction *loadAction, *saveAction, *resetAction;
+ QAction *cutAction, *copyAction, *pasteAction, *deleteAction;
+ QAction *fixedAction, *veloAction;
+ QAction *sallAction, *snoneAction, *invAction, *inAction , *outAction;
+ QAction *prevAction, *nextAction;
+
+ Q_OBJECT
+ void initShortcuts();
+
+ virtual void closeEvent(QCloseEvent*);
+ QWidget* genToolbar(QWidget* parent);
+ virtual void resizeEvent(QResizeEvent*);
+ virtual void keyPressEvent(QKeyEvent*);
+ int _to;//TODO: Make this work
+ void setHeaderToolTips();
+ void setHeaderWhatsThis();
+
+ private slots:
+ void setRaster(int);
+ void setQuant(int);
+ void noteinfoChanged(NoteInfo::ValType type, int val);
+ //CtrlEdit* addCtrl();
+ void removeCtrl(CtrlEdit* ctrl);
+ void cmd(int);
+ void clipboardChanged(); // enable/disable "Paste"
+ void selectionChanged(); // enable/disable "Copy" & "Paste"
+ void load();
+ void save();
+ void reset();
+ void setTime(unsigned);
+ void follow(int);
+ void newCanvasWidth(int);
+ void configChanged();
+ void songChanged1(int);
+
+ public slots:
+ void setSelection(int, Event&, Part*);
+ void soloChanged(bool); // called by Solo button
+ void execDeliveredScript(int);
+ void execUserScript(int);
+ CtrlEdit* addCtrl();
+
+ virtual void updateHScrollRange();
+ signals:
+ void deleted(unsigned long);
+
+ public:
+ DrumEdit(PartList*, QWidget* parent = 0, const char* name = 0, unsigned initPos = MAXINT);
+ virtual ~DrumEdit();
+ virtual void readStatus(Xml&);
+ virtual void writeStatus(int, Xml&) const;
+ static void readConfiguration(Xml& xml);
+ static void writeConfiguration(int, Xml&);
+ };
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/midiedit/drummap.cpp b/attic/muse2-oom/muse2/muse/midiedit/drummap.cpp
new file mode 100644
index 00000000..46bf2057
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/drummap.cpp
@@ -0,0 +1,503 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: drummap.cpp,v 1.3.2.6 2009/10/29 02:14:37 terminator356 Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "audio.h"
+#include "drummap.h"
+#include "xml.h"
+#include "song.h"
+
+char drumOutmap[DRUM_MAPSIZE];
+char drumInmap[128];
+
+DrumMap drumMap[DRUM_MAPSIZE];
+
+//---------------------------------------------------------
+// GM default drum map
+//---------------------------------------------------------
+
+const DrumMap blankdm = { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 127, 127, false };
+
+const DrumMap idrumMap[DRUM_MAPSIZE] = {
+ { QString("Acoustic Bass Drum"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 35, 35, false },
+ { QString("Bass Drum 1"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 36, 36, false },
+ { QString("Side Stick"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 37, 37, false },
+ { QString("Acoustic Snare"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 38, 38, false },
+ { QString("Hand Clap"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 39, 39, false },
+ { QString("Electric Snare"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 40, 40, false },
+ { QString("Low Floor Tom"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 41, 41, false },
+ { QString("Closed Hi-Hat"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 42, 42, false },
+ { QString("High Floor Tom"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 43, 43, false },
+ { QString("Pedal Hi-Hat"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 44, 44, false },
+ { QString("Low Tom"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 45, 45, false },
+ { QString("Open Hi-Hat"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 46, 46, false },
+ { QString("Low-Mid Tom"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 47, 47, false },
+ { QString("Hi-Mid Tom"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 48, 48, false },
+ { QString("Crash Cymbal 1"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 49, 49, false },
+ { QString("High Tom"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 50, 50, false },
+
+ { QString("Ride Cymbal 1"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 51, 51, false },
+ { QString("Chinese Cymbal"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 52, 52, false },
+ { QString("Ride Bell"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 53, 53, false },
+ { QString("Tambourine"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 54, 54, false },
+ { QString("Splash Cymbal"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 55, 55, false },
+ { QString("Cowbell"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 56, 56, false },
+ { QString("Crash Cymbal 2"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 57, 57, false },
+ { QString("Vibraslap"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 58, 58, false },
+ { QString("Ride Cymbal 2"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 59, 59, false },
+ { QString("Hi Bongo"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 60, 60, false },
+ { QString("Low Bongo"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 61, 61, false },
+ { QString("Mute Hi Conga"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 62, 62, false },
+ { QString("Open Hi Conga"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 63, 63, false },
+ { QString("Low Conga"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 64, 64, false },
+ { QString("High Timbale"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 65, 65, false },
+ { QString("Low Timbale"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 66, 66, false },
+
+ { QString("High Agogo"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 67, 67, false },
+ { QString("Low Agogo"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 68, 68, false },
+ { QString("Cabasa"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 69, 69, false },
+ { QString("Maracas"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 70, 70, false },
+ { QString("Short Whistle"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 71, 71, false },
+ { QString("Long Whistle"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 72, 72, false },
+ { QString("Short Guiro"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 73, 73, false },
+ { QString("Long Guiro"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 74, 74, false },
+ { QString("Claves"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 75, 75, false },
+ { QString("Hi Wood Block"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 76, 76, false },
+ { QString("Low Wood Block"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 77, 77, false },
+ { QString("Mute Cuica"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 78, 78, false },
+ { QString("Open Cuica"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 79, 79, false },
+ { QString("Mute Triangle"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 80, 80, false },
+ { QString("Open Triangle"), 100, 16, 32, 9, 0, 70, 90, 127, 110, 81, 81, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 82, 82, false },
+
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 83, 83, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 84, 84, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 85, 85, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 86, 86, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 87, 87, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 88, 88, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 89, 89, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 90, 90, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 91, 91, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 92, 92, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 93, 93, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 94, 94, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 95, 95, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 96, 96, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 97, 97, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 98, 98, false },
+
+ /*
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 83, 83, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 84, 84, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 85, 85, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 86, 86, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 87, 87, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 88, 88, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 89, 89, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 90, 90, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 91, 91, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 92, 92, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 93, 93, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 94, 94, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 95, 95, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 96, 96, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 97, 97, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 98, 98, false },
+
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 83, 83, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 84, 84, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 85, 85, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 86, 86, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 87, 87, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 88, 88, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 89, 89, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 90, 90, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 91, 91, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 92, 92, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 93, 93, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 94, 94, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 95, 95, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 96, 96, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 97, 97, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 98, 98, false },
+
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 83, 83, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 84, 84, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 85, 85, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 86, 86, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 87, 87, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 88, 88, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 89, 89, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 90, 90, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 91, 91, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 92, 92, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 93, 93, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 94, 94, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 95, 95, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 96, 96, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 97, 97, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 98, 98, false },
+
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 83, 83, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 84, 84, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 85, 85, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 86, 86, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 87, 87, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 88, 88, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 89, 89, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 90, 90, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 91, 91, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 92, 92, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 93, 93, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 94, 94, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 95, 95, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 96, 96, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 97, 97, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 98, 98, false }
+ };
+ */
+
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 99, 99, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 100, 100, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 101, 101, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 102, 102, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 103, 103, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 104, 104, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 105, 105, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 106, 106, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 107, 107, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 108, 108, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 109, 109, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 110, 110, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 111, 111, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 112, 112, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 113, 113, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 114, 114, false },
+
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 115, 115, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 116, 116, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 117, 117, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 118, 118, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 119, 119, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 120, 120, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 121, 121, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 122, 122, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 123, 123, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 124, 124, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 125, 125, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 126, 126, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 127, 127, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 0, 0, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 1, 1, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 2, 2, false },
+
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 3, 3, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 4, 4, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 5, 5, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 6, 6, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 7, 7, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 8, 8, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 9, 9, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 10, 10, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 11, 11, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 12, 12, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 13, 13, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 14, 14, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 15, 15, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 16, 16, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 17, 17, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 18, 18, false },
+
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 19, 19, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 20, 20, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 21, 21, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 22, 22, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 23, 23, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 24, 24, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 25, 25, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 26, 26, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 27, 27, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 28, 28, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 29, 29, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 30, 30, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 31, 31, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 32, 32, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 33, 33, false },
+ { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 34, 34, false }
+ };
+
+
+//---------------------------------------------------------
+// initDrumMap
+// populate Inmap and Outmap
+//---------------------------------------------------------
+
+void initDrumMap()
+ {
+ for (int i = 0; i < DRUM_MAPSIZE; ++i) {
+ DrumMap d = drumMap[i];
+ //Make sure we're not overwriting any values loaded
+ //On init, all these values are zero. If so, just set the drummap entry to the initial drummap entry.
+ if (!(d.vol || d.len || d.channel || d.port || d.lv1 || d.lv2 || d.lv3 || d.lv4 || d.enote || d.anote || d.mute))
+ drumMap[i] = idrumMap[i];
+ }
+ //Finally, setup the inMap, outMap-values
+ memset(drumInmap, 0, sizeof(drumInmap));
+ memset(drumOutmap, 0, sizeof(drumOutmap));
+ for (int i = 0; i < DRUM_MAPSIZE; ++i) {
+ drumInmap[(unsigned int)(drumMap[i].enote)] = i;
+ drumOutmap[(unsigned int)(drumMap[i].anote)] = i;
+ }
+ }
+
+//---------------------------------------------------------
+// resetGMDrumMap
+//---------------------------------------------------------
+
+void resetGMDrumMap()
+ {
+ audio->msgIdle(true);
+ // Delete all port controller events.
+ //audio->msgChangeAllPortDrumCtrlEvents(false);
+ song->changeAllPortDrumCtrlEvents(false);
+
+ for(int i = 0; i < DRUM_MAPSIZE; ++i)
+ drumMap[i] = idrumMap[i];
+ memset(drumInmap, 0, sizeof(drumInmap));
+ memset(drumOutmap, 0, sizeof(drumOutmap));
+ for (int i = 0; i < DRUM_MAPSIZE; ++i) {
+ drumInmap[(unsigned int)(drumMap[i].enote)] = i;
+ drumOutmap[(unsigned int)(drumMap[i].anote)] = i;
+ }
+ // Add all port controller events.
+ //audio->msgChangeAllPortDrumCtrlEvents(true);
+ song->changeAllPortDrumCtrlEvents(true);
+ audio->msgIdle(false);
+ }
+
+//---------------------------------------------------------
+// operator ==
+//---------------------------------------------------------
+
+//bool const DrumMap::operator==(const DrumMap& map) const
+bool DrumMap::operator==(const DrumMap& map) const
+ {
+ return
+ (name == map.name)
+ && vol == map.vol
+ && quant == map.quant
+ && len == map.len
+ && channel == map.channel
+ && port == map.port
+ && lv1 == map.lv1
+ && lv2 == map.lv2
+ && lv3 == map.lv3
+ && lv4 == map.lv4
+ && enote == map.enote
+ && anote == map.anote
+ && mute == map.mute;
+ }
+
+//---------------------------------------------------------
+// writeDrumMap
+//---------------------------------------------------------
+
+void writeDrumMap(int level, Xml& xml, bool external)
+ {
+ xml.tag(level++, "drummap");
+ for (int i = 0; i < DRUM_MAPSIZE; ++i) {
+ DrumMap* dm = &drumMap[i];
+ const DrumMap* idm = &idrumMap[i];
+
+ if (external) {
+ xml.tag(level++, "entry");
+ xml.strTag(level, "name", dm->name);
+ xml.intTag(level, "vol", dm->vol);
+ xml.intTag(level, "quant", dm->quant);
+ xml.intTag(level, "len", dm->len);
+ xml.intTag(level, "channel", dm->channel);
+ xml.intTag(level, "port", dm->port);
+ xml.intTag(level, "lv1", dm->lv1);
+ xml.intTag(level, "lv2", dm->lv2);
+ xml.intTag(level, "lv3", dm->lv3);
+ xml.intTag(level, "lv4", dm->lv4);
+ xml.intTag(level, "enote", dm->enote);
+ xml.intTag(level, "anote", dm->anote);
+ }
+ else {
+ // write only, if entry is different from initial entry
+ if (!external && *dm == *idm)
+ continue;
+ xml.tag(level++, "entry idx=\"%d\"", i);
+ if (dm->name != idm->name)
+ xml.strTag(level, "name", dm->name);
+ if (dm->vol != idm->vol)
+ xml.intTag(level, "vol", dm->vol);
+ if (dm->quant != idm->quant)
+ xml.intTag(level, "quant", dm->quant);
+ if (dm->len != idm->len)
+ xml.intTag(level, "len", dm->len);
+ if (dm->channel != idm->channel)
+ xml.intTag(level, "channel", dm->channel);
+ if (dm->port != idm->port)
+ xml.intTag(level, "port", dm->port);
+ if (dm->lv1 != idm->lv1)
+ xml.intTag(level, "lv1", dm->lv1);
+ if (dm->lv2 != idm->lv2)
+ xml.intTag(level, "lv2", dm->lv2);
+ if (dm->lv3 != idm->lv3)
+ xml.intTag(level, "lv3", dm->lv3);
+ if (dm->lv4 != idm->lv4)
+ xml.intTag(level, "lv4", dm->lv4);
+ if (dm->enote != idm->enote)
+ xml.intTag(level, "enote", dm->enote);
+ if (dm->anote != idm->anote)
+ xml.intTag(level, "anote", dm->anote);
+ if (dm->mute != idm->mute)
+ xml.intTag(level, "mute", dm->mute);
+ }
+ xml.tag(level--, "/entry");
+ }
+ xml.tag(level--, "/drummap");
+ }
+
+//---------------------------------------------------------
+// readDrummapEntry
+//---------------------------------------------------------
+
+static void readDrummapEntry(Xml& xml, DrumMap* dm)
+ {
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "name")
+ dm->name = xml.parse(QString("name"));
+ else if (tag == "vol")
+ dm->vol = (unsigned char)xml.parseInt();
+ else if (tag == "quant")
+ dm->quant = xml.parseInt();
+ else if (tag == "len")
+ dm->len = xml.parseInt();
+ else if (tag == "channel")
+ dm->channel = xml.parseInt();
+ else if (tag == "port")
+ dm->port = xml.parseInt();
+ else if (tag == "lv1")
+ dm->lv1 = xml.parseInt();
+ else if (tag == "lv2")
+ dm->lv2 = xml.parseInt();
+ else if (tag == "lv3")
+ dm->lv3 = xml.parseInt();
+ else if (tag == "lv4")
+ dm->lv4 = xml.parseInt();
+ else if (tag == "enote")
+ dm->enote = xml.parseInt();
+ else if (tag == "anote")
+ dm->anote = xml.parseInt();
+ else if (tag == "mute")
+ dm->mute = xml.parseInt();
+ else if (tag == "selected")
+ //; // dm->selected = xml.parseInt();
+ xml.skip(tag);
+ else
+ xml.unknown("DrumMapEntry");
+ break;
+ case Xml::Attribut:
+ if (tag == "idx") {
+ int idx = xml.s2().toInt() & 0x7f;
+ dm = &drumMap[idx];
+
+ }
+ break;
+ case Xml::TagEnd:
+ if (tag == "entry")
+ {
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// readDrummap
+//---------------------------------------------------------
+
+void readDrumMap(Xml& xml, bool external)
+ {
+ audio->msgIdle(true);
+ // Delete all port controller events.
+ //audio->msgChangeAllPortDrumCtrlEvents(false);
+ song->changeAllPortDrumCtrlEvents(false);
+
+ if (external) {
+ for (int i = 0; i < DRUM_MAPSIZE; ++i)
+ drumMap[i] = blankdm;
+ }
+ else {
+ for (int i = 0; i < DRUM_MAPSIZE; ++i)
+ drumMap[i] = idrumMap[i];
+ }
+ int i = 0;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ audio->msgIdle(false);
+ return;
+ case Xml::TagStart:
+ if (tag == "entry") {
+ if(i >= DRUM_MAPSIZE)
+ {
+ audio->msgIdle(false);
+ return;
+ }
+ readDrummapEntry(xml, external ? &drumMap[i] : 0);
+ ++i;
+ }
+ else if (tag == "comment")
+ xml.parse();
+ else
+ xml.unknown("DrumMap");
+ break;
+ case Xml::Attribut:
+ break;
+ case Xml::TagEnd:
+ if (tag == "drummap") {
+ memset(drumInmap, 0, sizeof(drumInmap));
+ memset(drumOutmap, 0, sizeof(drumOutmap));
+ for (int i = 0; i < DRUM_MAPSIZE; ++i) {
+ drumInmap[(unsigned int)(drumMap[i].enote)] = i;
+ drumOutmap[(unsigned int)(drumMap[i].anote)] = i;
+ }
+ // Add all port controller events.
+ //audio->msgChangeAllPortDrumCtrlEvents(true);
+ song->changeAllPortDrumCtrlEvents(true);
+
+ audio->msgIdle(false);
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ // Add all port controller events.
+ //audio->msgChangeAllPortDrumCtrlEvents(true);
+ song->changeAllPortDrumCtrlEvents(true);
+ audio->msgIdle(false);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/midiedit/drummap.h b/attic/muse2-oom/muse2/muse/midiedit/drummap.h
new file mode 100644
index 00000000..eb494c9c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/drummap.h
@@ -0,0 +1,47 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: drummap.h,v 1.3.2.3 2009/10/29 02:14:37 terminator356 Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __DRUMMAP_H__
+#define __DRUMMAP_H__
+
+class QString;
+
+class Xml;
+
+//---------------------------------------------------------
+// DrumMap
+//---------------------------------------------------------
+
+struct DrumMap {
+ QString name;
+ unsigned char vol; // playback volume, percent.
+ int quant;
+ int len; // len of event in ticks
+ int channel; // midi channel
+ int port; // midi port
+ char lv1, lv2, lv3, lv4; // velocities
+ char enote, anote; // input note - output note
+ bool mute;
+// bool selected;
+
+ //bool const operator==(const DrumMap& map) const;
+ bool operator==(const DrumMap& map) const;
+ };
+
+#define DRUM_MAPSIZE 128
+
+extern char drumOutmap[DRUM_MAPSIZE];
+extern char drumInmap[DRUM_MAPSIZE];
+extern DrumMap drumMap[DRUM_MAPSIZE];
+extern void initDrumMap();
+extern void writeDrumMap(int level, Xml& xml, bool external);
+extern void readDrumMap(Xml& xml, bool external);
+extern void resetGMDrumMap();
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/midiedit/ecanvas.cpp b/attic/muse2-oom/muse2/muse/midiedit/ecanvas.cpp
new file mode 100644
index 00000000..3a10e135
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/ecanvas.cpp
@@ -0,0 +1,541 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: ecanvas.cpp,v 1.8.2.6 2009/05/03 04:14:00 terminator356 Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <errno.h>
+#include <values.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+
+#include <QKeyEvent>
+#include <QDropEvent>
+#include <QEvent>
+#include <QMimeData>
+#include <QByteArray>
+#include <QDrag>
+
+#include "xml.h"
+#include "midieditor.h"
+#include "ecanvas.h"
+#include "song.h"
+#include "event.h"
+#include "shortcuts.h"
+#include "audio.h"
+
+//---------------------------------------------------------
+// EventCanvas
+//---------------------------------------------------------
+
+EventCanvas::EventCanvas(MidiEditor* pr, QWidget* parent, int sx,
+ int sy, const char* name)
+ : Canvas(parent, sx, sy, name)
+ {
+ editor = pr;
+ _steprec = false;
+ _midiin = false;
+ _playEvents = false;
+ curVelo = 70;
+
+ setBg(QColor(226,229,229));
+ setAcceptDrops(true);
+ setFocusPolicy(Qt::StrongFocus);
+ setMouseTracking(true);
+
+ curPart = (MidiPart*)(editor->parts()->begin()->second);
+ curPartId = curPart->sn();
+ }
+
+//---------------------------------------------------------
+// getCaption
+//---------------------------------------------------------
+
+QString EventCanvas::getCaption() const
+ {
+ int bar1, bar2, xx;
+ unsigned x;
+ ///sigmap.tickValues(curPart->tick(), &bar1, &xx, &x);
+ AL::sigmap.tickValues(curPart->tick(), &bar1, &xx, &x);
+ ///sigmap.tickValues(curPart->tick() + curPart->lenTick(), &bar2, &xx, &x);
+ AL::sigmap.tickValues(curPart->tick() + curPart->lenTick(), &bar2, &xx, &x);
+
+ return QString("MusE: Part <") + curPart->name()
+ + QString("> %1-%2").arg(bar1+1).arg(bar2+1);
+ }
+
+//---------------------------------------------------------
+// leaveEvent
+//---------------------------------------------------------
+
+void EventCanvas::leaveEvent(QEvent*)
+ {
+ emit pitchChanged(-1);
+ emit timeChanged(MAXINT);
+ }
+
+//---------------------------------------------------------
+// enterEvent
+//---------------------------------------------------------
+
+void EventCanvas::enterEvent(QEvent*)
+ {
+ emit enterCanvas();
+ }
+
+//---------------------------------------------------------
+// raster
+//---------------------------------------------------------
+
+QPoint EventCanvas::raster(const QPoint& p) const
+ {
+ int x = p.x();
+ if (x < 0)
+ x = 0;
+ x = editor->rasterVal(x);
+ int pitch = y2pitch(p.y());
+ int y = pitch2y(pitch);
+ return QPoint(x, y);
+ }
+
+//---------------------------------------------------------
+// startUndo
+//---------------------------------------------------------
+
+void EventCanvas::startUndo(DragType)
+ {
+ song->startUndo();
+ }
+
+//---------------------------------------------------------
+// endUndo
+//---------------------------------------------------------
+
+void EventCanvas::endUndo(DragType dtype, int flags)
+ {
+ song->endUndo(flags | ((dtype == MOVE_COPY || dtype == MOVE_CLONE)
+ ? SC_EVENT_INSERTED : SC_EVENT_MODIFIED));
+ }
+
+//---------------------------------------------------------
+// mouseMove
+//---------------------------------------------------------
+
+void EventCanvas::mouseMove(const QPoint& pos)
+ {
+ emit pitchChanged(y2pitch(pos.y()));
+ int x = pos.x();
+ emit timeChanged(editor->rasterVal(x));
+ }
+
+//---------------------------------------------------------
+// updateSelection
+//---------------------------------------------------------
+
+void EventCanvas::updateSelection()
+ {
+ song->update(SC_SELECTION);
+ }
+
+//---------------------------------------------------------
+// songChanged(type)
+//---------------------------------------------------------
+
+void EventCanvas::songChanged(int flags)
+ {
+ // Is it simply a midi controller value adjustment? Forget it.
+ if(flags == SC_MIDI_CONTROLLER)
+ return;
+
+ if (flags & ~SC_SELECTION) {
+ items.clear();
+ start_tick = MAXINT;
+ end_tick = 0;
+ curPart = 0;
+ for (iPart p = editor->parts()->begin(); p != editor->parts()->end(); ++p) {
+ MidiPart* part = (MidiPart*)(p->second);
+ if (part->sn() == curPartId)
+ curPart = part;
+ unsigned stick = part->tick();
+ unsigned len = part->lenTick();
+ unsigned etick = stick + len;
+ if (stick < start_tick)
+ start_tick = stick;
+ if (etick > end_tick)
+ end_tick = etick;
+
+ EventList* el = part->events();
+ for (iEvent i = el->begin(); i != el->end(); ++i) {
+ Event e = i->second;
+ // Added by T356. Do not add events which are either past, or extend past the end of the part.
+ //if(e.tick() > len)
+ if(e.endTick() > len)
+ break;
+
+ if (e.isNote()) {
+ addItem(part, e);
+ }
+ }
+ }
+ }
+
+ Event event;
+ MidiPart* part = 0;
+ int x = 0;
+ CItem* nevent = 0;
+
+ int n = 0; // count selections
+ for (iCItem k = items.begin(); k != items.end(); ++k) {
+ Event ev = k->second->event();
+ bool selected = ev.selected();
+ if (selected) {
+ k->second->setSelected(true);
+ ++n;
+ if (!nevent) {
+ nevent = k->second;
+ Event mi = nevent->event();
+ curVelo = mi.velo();
+ }
+ }
+ }
+ start_tick = song->roundDownBar(start_tick);
+ end_tick = song->roundUpBar(end_tick);
+
+ if (n == 1) {
+ x = nevent->x();
+ event = nevent->event();
+ part = (MidiPart*)nevent->part();
+ if (curPart != part) {
+ curPart = part;
+ curPartId = curPart->sn();
+ curPartChanged();
+ }
+ }
+ emit selectionChanged(x, event, part);
+ if (curPart == 0)
+ curPart = (MidiPart*)(editor->parts()->begin()->second);
+ redraw();
+ }
+
+//---------------------------------------------------------
+// selectAtTick
+//---------------------------------------------------------
+void EventCanvas::selectAtTick(unsigned int tick)
+ {
+ //Select note nearest tick, if none selected and there are any
+ if (!items.empty() && selectionSize() == 0) {
+ iCItem i = items.begin();
+ CItem* nearest = i->second;
+
+ while (i != items.end()) {
+ CItem* cur=i->second;
+ unsigned int curtk=abs(cur->x() + cur->part()->tick() - tick);
+ unsigned int neartk=abs(nearest->x() + nearest->part()->tick() - tick);
+
+ if (curtk < neartk) {
+ nearest=cur;
+ }
+
+ i++;
+ }
+
+ if (!nearest->isSelected()) {
+ selectItem(nearest, true);
+ songChanged(SC_SELECTION);
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// track
+//---------------------------------------------------------
+
+MidiTrack* EventCanvas::track() const
+ {
+ return ((MidiPart*)curPart)->track();
+ }
+
+
+//---------------------------------------------------------
+// keyPress
+//---------------------------------------------------------
+
+void EventCanvas::keyPress(QKeyEvent* event)
+ {
+ int key = event->key();
+ ///if (event->state() & Qt::ShiftButton)
+ if (((QInputEvent*)event)->modifiers() & Qt::ShiftModifier)
+ key += Qt::SHIFT;
+ ///if (event->state() & Qt::AltButton)
+ if (((QInputEvent*)event)->modifiers() & Qt::AltModifier)
+ key += Qt::ALT;
+ ///if (event->state() & Qt::ControlButton)
+ if (((QInputEvent*)event)->modifiers() & Qt::ControlModifier)
+ key+= Qt::CTRL;
+
+ //
+ // Shortcut for DrumEditor & PianoRoll
+ // Sets locators to selected events
+ //
+ if (key == shortcuts[SHRT_LOCATORS_TO_SELECTION].key) {
+ int tick_max = 0;
+ int tick_min = INT_MAX;
+ bool found = false;
+
+ for (iCItem i= items.begin(); i != items.end(); i++) {
+ if (!i->second->isSelected())
+ continue;
+
+ int tick = i->second->x();
+ int len = i->second->event().lenTick();
+ found = true;
+ if (tick + len > tick_max)
+ tick_max = tick + len;
+ if (tick < tick_min)
+ tick_min = tick;
+ }
+ if (found) {
+ Pos p1(tick_min, true);
+ Pos p2(tick_max, true);
+ song->setPos(1, p1);
+ song->setPos(2, p2);
+ }
+ }
+ // Select items by key (PianoRoll & DrumEditor)
+ else if (key == shortcuts[SHRT_SEL_RIGHT].key || key == shortcuts[SHRT_SEL_RIGHT_ADD].key) {
+ iCItem i, iRightmost;
+ CItem* rightmost = NULL;
+ //Get the rightmost selected note (if any)
+ for (i = items.begin(); i != items.end(); ++i) {
+ if (i->second->isSelected()) {
+ iRightmost = i; rightmost = i->second;
+ }
+ }
+ if (rightmost) {
+ iCItem temp = iRightmost; temp++;
+ //If so, deselect current note and select the one to the right
+ if (temp != items.end()) {
+ if (key != shortcuts[SHRT_SEL_RIGHT_ADD].key)
+ deselectAll();
+
+ iRightmost++;
+ iRightmost->second->setSelected(true);
+ updateSelection();
+ }
+ }
+ }
+ //Select items by key: (PianoRoll & DrumEditor)
+ else if (key == shortcuts[SHRT_SEL_LEFT].key || key == shortcuts[SHRT_SEL_LEFT_ADD].key) {
+ iCItem i, iLeftmost;
+ CItem* leftmost = NULL;
+ if (items.size() > 0 ) {
+ for (i = items.end(), i--; i != items.begin(); i--) {
+ if (i->second->isSelected()) {
+ iLeftmost = i; leftmost = i->second;
+ }
+ }
+ if (leftmost) {
+ if (iLeftmost != items.begin()) {
+ //Add item
+ if (key != shortcuts[SHRT_SEL_LEFT_ADD].key)
+ deselectAll();
+
+ iLeftmost--;
+ iLeftmost->second->setSelected(true);
+ updateSelection();
+ }
+ }
+ }
+ }
+ else if (key == shortcuts[SHRT_INC_PITCH].key) {
+ modifySelected(NoteInfo::VAL_PITCH, 1);
+ }
+ else if (key == shortcuts[SHRT_DEC_PITCH].key) {
+ modifySelected(NoteInfo::VAL_PITCH, -1);
+ }
+ else if (key == shortcuts[SHRT_INC_POS].key) {
+ // TODO: Check boundaries
+ modifySelected(NoteInfo::VAL_TIME, editor->raster());
+ }
+ else if (key == shortcuts[SHRT_DEC_POS].key) {
+ // TODO: Check boundaries
+ modifySelected(NoteInfo::VAL_TIME, 0 - editor->raster());
+ }
+
+ else if (key == shortcuts[SHRT_INCREASE_LEN].key) {
+ // TODO: Check boundaries
+ modifySelected(NoteInfo::VAL_LEN, editor->raster());
+ }
+ else if (key == shortcuts[SHRT_DECREASE_LEN].key) {
+ // TODO: Check boundaries
+ modifySelected(NoteInfo::VAL_LEN, 0 - editor->raster());
+ }
+
+ else
+ event->ignore();
+ }
+
+//---------------------------------------------------------
+// getTextDrag
+//---------------------------------------------------------
+
+//QDrag* EventCanvas::getTextDrag(QWidget* parent)
+QMimeData* EventCanvas::getTextDrag()
+ {
+ //---------------------------------------------------
+ // generate event list from selected events
+ //---------------------------------------------------
+
+ EventList el;
+ unsigned startTick = MAXINT;
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ if (!i->second->isSelected())
+ continue;
+ ///NEvent* ne = (NEvent*)(i->second);
+ CItem* ne = i->second;
+ Event e = ne->event();
+ if (startTick == MAXINT)
+ startTick = e.tick();
+ el.add(e);
+ }
+
+ //---------------------------------------------------
+ // write events as XML into tmp file
+ //---------------------------------------------------
+
+ FILE* tmp = tmpfile();
+ if (tmp == 0) {
+ fprintf(stderr, "EventCanvas::getTextDrag() fopen failed: %s\n",
+ strerror(errno));
+ return 0;
+ }
+ Xml xml(tmp);
+
+ int level = 0;
+ xml.tag(level++, "eventlist");
+ for (ciEvent e = el.begin(); e != el.end(); ++e)
+ e->second.write(level, xml, -startTick);
+ xml.etag(--level, "eventlist");
+
+ //---------------------------------------------------
+ // read tmp file into drag Object
+ //---------------------------------------------------
+
+ fflush(tmp);
+ struct stat f_stat;
+ if (fstat(fileno(tmp), &f_stat) == -1) {
+ fprintf(stderr, "PianoCanvas::copy() fstat failes:<%s>\n",
+ strerror(errno));
+ fclose(tmp);
+ return 0;
+ }
+ int n = f_stat.st_size;
+ char* fbuf = (char*)mmap(0, n+1, PROT_READ|PROT_WRITE,
+ MAP_PRIVATE, fileno(tmp), 0);
+ fbuf[n] = 0;
+
+ QByteArray data(fbuf);
+ QMimeData* md = new QMimeData();
+ //QDrag* drag = new QDrag(parent);
+
+ md->setData("text/x-muse-eventlist", data);
+ //drag->setMimeData(md);
+
+ munmap(fbuf, n);
+ fclose(tmp);
+
+ //return drag;
+ return md;
+ }
+
+//---------------------------------------------------------
+// pasteAt
+//---------------------------------------------------------
+
+void EventCanvas::pasteAt(const QString& pt, int pos)
+ {
+ QByteArray ba = pt.toLatin1();
+ const char* p = ba.constData();
+ Xml xml(p);
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "eventlist") {
+ song->startUndo();
+ EventList* el = new EventList();
+ el->read(xml, "eventlist", true);
+ int modified = SC_EVENT_INSERTED;
+ for (iEvent i = el->begin(); i != el->end(); ++i) {
+ Event e = i->second;
+ int tick = e.tick() + pos - curPart->tick();
+ if (tick<0) {
+ printf("ERROR: trying to add event before current part!\n");
+ song->endUndo(SC_EVENT_INSERTED);
+ delete el;
+ return;
+ }
+
+ e.setTick(tick);
+ int diff = e.endTick()-curPart->lenTick();
+ if (diff > 0) {// too short part? extend it
+ Part* newPart = curPart->clone();
+ newPart->setLenTick(newPart->lenTick()+diff);
+ // Indicate no undo, and do port controller values but not clone parts.
+ audio->msgChangePart(curPart, newPart, false, true, false);
+ modified=modified|SC_PART_MODIFIED;
+ curPart = newPart; // reassign
+ }
+ // Indicate no undo, and do not do port controller values and clone parts.
+ audio->msgAddEvent(e, curPart, false, false, false);
+ }
+ song->endUndo(modified);
+ delete el;
+ return;
+ }
+ else
+ xml.unknown("pasteAt");
+ break;
+ case Xml::Attribut:
+ case Xml::TagEnd:
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// dropEvent
+//---------------------------------------------------------
+
+void EventCanvas::viewDropEvent(QDropEvent* event)
+ {
+ QString text;
+ if (event->source() == this) {
+ printf("local DROP\n"); // REMOVE Tim
+ //event->acceptProposedAction();
+ //event->ignore(); // TODO CHECK Tim.
+ return;
+ }
+ if (event->mimeData()->hasFormat("text/x-muse-eventlist")) {
+ text = QString(event->mimeData()->data("text/x-muse-eventlist"));
+
+ int x = editor->rasterVal(event->pos().x());
+ if (x < 0)
+ x = 0;
+ pasteAt(text, x);
+ //event->accept(); // TODO
+ }
+ else {
+ printf("cannot decode drop\n");
+ //event->acceptProposedAction();
+ //event->ignore(); // TODO CHECK Tim.
+ }
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/midiedit/ecanvas.h b/attic/muse2-oom/muse2/muse/midiedit/ecanvas.h
new file mode 100644
index 00000000..461a717a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/ecanvas.h
@@ -0,0 +1,94 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: ecanvas.h,v 1.5.2.4 2009/02/02 21:38:00 terminator356 Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __ECANVAS_H__
+#define __ECANVAS_H__
+
+#include "canvas.h"
+#include "noteinfo.h"
+#include <QEvent>
+#include <QKeyEvent>
+
+class MidiPart;
+class MidiTrack;
+class MidiEditor;
+class Part;
+class QMimeData;
+class QDrag;
+class QString;
+class QDropEvent;
+
+struct PartToChange
+{
+ Part* npart;
+ int xdiff;
+};
+typedef std::map<Part*, PartToChange> PartsToChangeMap;
+typedef std::map<Part*, PartToChange>::iterator iPartToChange;
+
+//---------------------------------------------------------
+// EventCanvas
+//---------------------------------------------------------
+
+class EventCanvas : public Canvas {
+ Q_OBJECT
+ virtual void leaveEvent(QEvent*e);
+ virtual void enterEvent(QEvent*e);
+ // Removed by T356.
+ //virtual QPoint raster(const QPoint&) const;
+
+ virtual void startUndo(DragType);
+
+ virtual void endUndo(DragType, int flags = 0);
+ virtual void mouseMove(const QPoint&);
+
+ protected:
+ bool _playEvents;
+ MidiEditor* editor;
+ unsigned start_tick, end_tick;
+ int curVelo;
+ bool _steprec;
+ bool _midiin;
+
+ void updateSelection();
+ virtual void addItem(Part*, Event&) = 0;
+ // Added by T356.
+ virtual QPoint raster(const QPoint&) const;
+
+ public slots:
+ void redrawGrid() { redraw(); }
+ void setSteprec(bool f) { _steprec = f; }
+ void setMidiin(bool f) { _midiin = f; }
+
+ signals:
+ void pitchChanged(int); // current cursor position
+ void timeChanged(unsigned);
+ void selectionChanged(int, Event&, Part*);
+ void enterCanvas();
+
+ public:
+ EventCanvas(MidiEditor*, QWidget*, int, int, const char* name = 0);
+ MidiTrack* track() const;
+ unsigned start() const { return start_tick; }
+ unsigned end() const { return end_tick; }
+ bool midiin() const { return _midiin; }
+ bool steprec() const { return _steprec; }
+ QString getCaption() const;
+ void songChanged(int);
+ void range(int* s, int* e) const { *s = start_tick; *e = end_tick; }
+ void playEvents(bool flag) { _playEvents = flag; }
+ void selectAtTick(unsigned int tick);
+ //QDrag* getTextDrag(QWidget* parent);
+ QMimeData* getTextDrag();
+ void pasteAt(const QString& pt, int pos);
+ void viewDropEvent(QDropEvent* event);
+ virtual void modifySelected(NoteInfo::ValType, int) {}
+ virtual void keyPress(QKeyEvent*);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/midiedit/piano.cpp b/attic/muse2-oom/muse2/muse/midiedit/piano.cpp
new file mode 100644
index 00000000..6d42556c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/piano.cpp
@@ -0,0 +1,554 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: piano.cpp,v 1.3 2004/05/31 11:48:55 lunar_shuttle Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QMouseEvent>
+#include <QPainter>
+
+#include <stdio.h>
+
+#include "piano.h"
+
+static const char *oct_xpm[] = {
+// w h colors
+ "40 91 2 1",
+ ". c #dedede",
+ "# c #565656",
+ // x
+ "####################################### ",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#", // 10
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#", //------------------------
+ "#######################................#",
+ "########################...............#",
+ "########################...............#",
+ "####################################### ", // 7
+ "########################...............#",
+ "########################...............#",
+ "#######################................#", //------------------------
+ ".......................................#",
+ ".......................................#",
+ ".......................................#", // 6
+ ".......................................#",
+ ".......................................#",
+ ".......................................#", //------------------------
+ "#######################................#",
+ "########################...............#",
+ "########################...............#", // 7
+ "####################################### ",
+ "########################...............#",
+ "########################...............#",
+ "#######################................#", //------------------------
+ ".......................................#",
+ ".......................................#",
+ ".......................................#", // 6
+ ".......................................#",
+ ".......................................#",
+ ".......................................#", //------------------------
+ "#######################................#",
+ "########################...............#",
+ "########################...............#", // 7
+ "####################################### ",
+ "########################...............#",
+ "########################...............#",
+ "#######################................#", //------------------------
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#", // 10
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ "####################################### ", //----------------------
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#", // 9
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#", //------------------------
+ "#######################................#",
+ "########################...............#",
+ "########################...............#",
+ "####################################### ", // 7
+ "########################...............#",
+ "########################...............#",
+ "#######################................#", //------------------------
+ ".......................................#",
+ ".......................................#",
+ ".......................................#", // 6
+ ".......................................#",
+ ".......................................#",
+ ".......................................#", //--------------------------
+ "#######################................#",
+ "########################...............#",
+ "########################...............#", // 7
+ "####################################### ",
+ "########################...............#",
+ "########################...............#",
+ "#######################................#", //------------------------
+ ".......................................#",
+ "..........................###..........#",
+ ".........................#...#.........#",
+ ".........................#.............#",
+ ".........................#.............#",
+ ".........................#...#.........#", // 10
+ "..........................###..........#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ };
+
+static const char *mk1_xpmC1[] = {
+ "40 10 2 1",
+ ". c #dedede",
+ "# c #565656",
+ ".......................................#",
+ "..........................###.....#....#",
+ ".........................#...#...##....#",
+ ".........................#........#....#",
+ ".........................#........#....#",
+ ".........................#...#....#....#", // 10
+ "..........................###....###...#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ };
+static const char *mk1_xpmC2[] = {
+ "40 10 2 1",
+ ". c #dedede",
+ "# c #565656",
+ ".......................................#",
+ "..........................###....##....#",
+ ".........................#...#..#..#...#",
+ ".........................#........#....#",
+ ".........................#.......#.....#",
+ ".........................#...#..#......#", // 10
+ "..........................###...####...#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ };
+static const char *mk1_xpmC3[] = {
+ "40 10 2 1",
+ ". c #dedede",
+ "# c #565656",
+ ".......................................#",
+ "..........................###....##....#",
+ ".........................#...#..#..#...#",
+ ".........................#........#....#",
+ ".........................#.........#...#",
+ ".........................#...#..#..#...#", // 10
+ "..........................###....##....#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ };
+static const char *mk1_xpmC4[] = {
+ "40 10 2 1",
+ ". c #dedede",
+ "# c #565656",
+ ".......................................#",
+ "..........................###...#..#...#",
+ ".........................#...#..#..#...#",
+ ".........................#......####...#",
+ ".........................#.........#...#",
+ ".........................#...#.....#...#", // 10
+ "..........................###......#...#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ };
+static const char *mk1_xpmC5[] = {
+ "40 10 2 1",
+ ". c #dedede",
+ "# c #565656",
+ ".......................................#",
+ "..........................###...####...#",
+ ".........................#...#..#......#",
+ ".........................#......###....#",
+ ".........................#.........#...#",
+ ".........................#...#.....#...#", // 10
+ "..........................###...###....#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ };
+
+static const char *mk1_xpmC6[] = {
+ "40 10 2 1",
+ ". c #dedede",
+ "# c #565656",
+ ".......................................#",
+ "..........................###....###...#",
+ ".........................#...#..#......#",
+ ".........................#......###....#",
+ ".........................#......#..#...#",
+ ".........................#...#..#..#...#", // 10
+ "..........................###...###....#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ };
+
+static const char *mk1_xpmC7[] = {
+ "40 10 2 1",
+ ". c #dedede",
+ "# c #565656",
+ ".......................................#",
+ "..........................###...####...#",
+ ".........................#...#.....#...#",
+ ".........................#........#....#",
+ ".........................#.......#.....#",
+ ".........................#...#..#......#", // 10
+ "..........................###...#......#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ };
+static const char *mk1_xpmC8[] = {
+ "40 10 2 1",
+ ". c #dedede",
+ "# c #565656",
+ ".......................................#",
+ "..........................###....##....#",
+ ".........................#...#..#..#....#",
+ ".........................#.......##....#",
+ ".........................#......#..#...#",
+ ".........................#...#..#..#...#", // 10
+ "..........................###....##....#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ };
+
+static const char *mk1_xpm[] = {
+ "40 13 2 1",
+ ". c #2d95b7",
+ "# c none",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ "#######################................#",
+ "########################...............#",
+ "########################...............#",
+ "####################################### ",
+ };
+
+static const char *mk2_xpm[] = {
+ "40 13 2 1",
+ ". c #2d95b7",
+ "# c none",
+ "########################...............#",
+ "########################...............#",
+ "#######################................#", //------------------------
+ ".......................................#",
+ ".......................................#",
+ ".......................................#", // 6
+ ".......................................#",
+ ".......................................#",
+ ".......................................#", //--------------------------
+ "#######################................#",
+ "########################...............#",
+ "########################...............#", // 7
+ "####################################### ",
+ };
+
+static const char *mk3_xpm[] = {
+ "40 13 2 1",
+ ". c #2d95b7",
+ "# c none",
+ "########################...............#",
+ "########################...............#",
+ "#######################................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ ".......................................#",
+ "########################################",
+ };
+
+static const char *mk4_xpm[] = {
+ "40 13 2 1",
+ "# c #2d95b7",
+ ". c none",
+ "........................................",
+ "........................................",
+ "........................................",
+ "#######################.................",
+ "########################................",
+ "########################................",
+ "########################................",
+ "########################................",
+ "########################................",
+ "#######################.................",
+ "........................................",
+ "........................................",
+ "........................................",
+ };
+/*
+ 0 1 2 3 4 5 6 7 8 9 10
+ c-2 c-1 C0 C1 C2 C3 C4 C5 C6 C7 C8 - G8
+
+ Grid über Oktave:
+
+ +------------+ ------------------------------
+ 11 | |
+ | h | 7
+ +------+ |
+ 10 | a# +-----+ ..............................
+ +------+ a |
+ 9 | | 6
+ +------+ |
+ 8 | g# +-----+ ..............................
+ +------+ g |
+ 7 | | 5
+ +------+ |
+ 6 | f# +-----+ ..............................
+ +------+ f |
+ 5 | | 4
+ | |
+ +------------+ ------------------------------
+ 4 | |
+ | e | 3
+ +------+ |
+ 3 | d# +-----+ ..............................
+ +------+ d |
+ 2 | | 2
+ +------+ |
+ 1 | c# +-----+ ..............................
+ +------+ c |
+ | | 1
+ 0 | |
+ +------------+ ------------------------------
+ */
+
+//---------------------------------------------------------
+// Piano
+//---------------------------------------------------------
+
+Piano::Piano(QWidget* parent, int ymag)
+ : View(parent, 1, ymag)
+ {
+ setMouseTracking(true);
+ curPitch = -1;
+ octave = new QPixmap(oct_xpm);
+ c_keys[0] = new QPixmap(mk1_xpmC8);
+ c_keys[1] = new QPixmap(mk1_xpmC7);
+ c_keys[2] = new QPixmap(mk1_xpmC6);
+ c_keys[3] = new QPixmap(mk1_xpmC5);
+ c_keys[4] = new QPixmap(mk1_xpmC4);
+ c_keys[5] = new QPixmap(mk1_xpmC3);
+ c_keys[6] = new QPixmap(mk1_xpmC2);
+ c_keys[7] = new QPixmap(mk1_xpmC1);
+
+ mk1 = new QPixmap(mk1_xpm);
+ mk2 = new QPixmap(mk2_xpm);
+ mk3 = new QPixmap(mk3_xpm);
+ mk4 = new QPixmap(mk4_xpm);
+ keyDown = -1;
+ button = Qt::NoButton;
+ }
+
+//---------------------------------------------------------
+// draw
+//---------------------------------------------------------
+
+void Piano::draw(QPainter& p, const QRect& r)
+ {
+ QPoint offset(0, KH*2);
+ p.drawTiledPixmap(r, *octave, r.topLeft()+offset);
+
+ // draw C notes
+ for (int drawKey = 0; drawKey < 8;drawKey++) {
+ int octaveSize=91;
+
+ int drawY = octaveSize * drawKey + 81 - KH*2;
+ if (drawY > r.y() && drawY < r.y() + r.height()) {
+ //printf("drawing c %d at %d r.y %d r.x %d\n",drawKey, drawY, r.y(), r.x());
+ p.drawPixmap(0,drawY,*c_keys[drawKey]);
+ }
+ }
+ //p.drawTiledPixmap(r, *c1, r.topLeft()+offset + coffset);
+ //printf("drawText KH %d %d, x %d y %d\n",KH, curPitch, r.x(), r.y());
+ //p.drawText(r,Qt::AlignAuto,"A");
+ if (curPitch == -1)
+ return;
+ int y = pitch2y(curPitch);
+ QPixmap* pm;
+ switch(curPitch % 12) {
+ case 0:
+ case 5:
+ pm = mk3;
+ break;
+ case 2:
+ case 7:
+ case 9:
+ pm = mk2;
+ break;
+ case 4:
+ case 11:
+ pm = mk1;
+ break;
+ default:
+ pm = mk4;
+ break;
+ }
+ p.drawPixmap(0, y, *pm);
+ }
+
+//---------------------------------------------------------
+// pitch2y
+//---------------------------------------------------------
+
+int Piano::pitch2y(int pitch) const
+ {
+ int tt[] = {
+ 12, 19, 25, 32, 38, 51, 58, 64, 71, 77, 84, 90
+ };
+ int y = (75 * KH) - (tt[pitch%12] + (7 * KH) * (pitch/12));
+ if (y < 0)
+ y = 0;
+ return y;
+ }
+
+//---------------------------------------------------------
+// y2pitch
+//---------------------------------------------------------
+
+int Piano::y2pitch(int y) const
+ {
+ const int total = (10 * 7 + 5) * KH; // 75 Ganztonschritte
+ y = total - y;
+ int oct = (y / (7 * KH)) * 12;
+ char kt[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 1, 1, 1, 1, 1, 1, 1,
+ 2, 2, 2, 2, 2, 2,
+ 3, 3, 3, 3, 3, 3, 3,
+ 4, 4, 4, 4, 4, 4, 4, 4, 4,
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
+ 6, 6, 6, 6, 6, 6, 6,
+ 7, 7, 7, 7, 7, 7,
+ 8, 8, 8, 8, 8, 8, 8,
+ 9, 9, 9, 9, 9, 9,
+ 10, 10, 10, 10, 10, 10, 10,
+ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11
+ };
+ return kt[y % 91] + oct;
+ }
+
+//---------------------------------------------------------
+// leaveEvent
+//---------------------------------------------------------
+
+void Piano::leaveEvent(QEvent*)
+ {
+ if (keyDown != -1) {
+ emit keyReleased(keyDown, shift);
+ keyDown = -1;
+ }
+ emit pitchChanged(-1);
+ setPitch(-1);
+ }
+
+//---------------------------------------------------------
+// setPitch
+//---------------------------------------------------------
+
+void Piano::setPitch(int pitch)
+ {
+ if (curPitch == pitch)
+ return;
+ curPitch = pitch;
+ redraw();
+ }
+
+//---------------------------------------------------------
+// viewMouseMoveEvent
+//---------------------------------------------------------
+
+void Piano::viewMouseMoveEvent(QMouseEvent* event)
+ {
+ int pitch = y2pitch(event->y());
+ emit pitchChanged(pitch);
+ setPitch(pitch);
+
+ if (button != Qt::NoButton) {
+ int nk = y2pitch(event->y());
+ if (nk < 0 || nk > 127)
+ nk = -1;
+ if (nk != keyDown) {
+ if (keyDown != -1) {
+ emit keyReleased(keyDown, shift);
+ }
+ keyDown = nk;
+ if (keyDown != -1) {
+ int velocity = event->x()*127/40;
+ //emit keyPressed(keyDown, shift);
+ emit keyPressed(keyDown, velocity>127 ? 127 : velocity, shift);
+ }
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// viewMousePressEvent
+//---------------------------------------------------------
+
+void Piano::viewMousePressEvent(QMouseEvent* event)
+ {
+ button = event->button();
+ shift = event->modifiers() & Qt::ShiftModifier;
+ if (keyDown != -1) {
+ emit keyReleased(keyDown, shift);
+ keyDown = -1;
+ }
+ keyDown = y2pitch(event->y());
+ if (keyDown < 0 || keyDown > 127) {
+ keyDown = -1;
+ }
+ else {
+ int velocity = event->x()*127/40;
+ emit keyPressed(keyDown, velocity>127 ? 127 : velocity, shift); //emit keyPressed(keyDown, shift);
+ }
+ }
+
+//---------------------------------------------------------
+// viewMouseReleaseEvent
+//---------------------------------------------------------
+
+void Piano::viewMouseReleaseEvent(QMouseEvent* event)
+ {
+ button = Qt::NoButton;
+ shift = event->modifiers() & Qt::ShiftModifier;
+ if (keyDown != -1) {
+ emit keyReleased(keyDown, shift);
+ keyDown = -1;
+ }
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/midiedit/piano.h b/attic/muse2-oom/muse2/muse/midiedit/piano.h
new file mode 100644
index 00000000..35106d64
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/piano.h
@@ -0,0 +1,62 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: piano.h,v 1.2 2004/05/31 11:48:55 lunar_shuttle Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __PIANO_H__
+#define __PIANO_H__
+
+#include "view.h"
+
+class QEvent;
+class QMouseEvent;
+class QPainter;
+class QPixmap;
+
+#define KH 13
+
+//---------------------------------------------------------
+// Piano
+//---------------------------------------------------------
+
+class Piano : public View
+ {
+ int curPitch;
+ QPixmap* octave;
+ QPixmap* c_keys[10];
+ QPixmap* mk1;
+ QPixmap* mk2;
+ QPixmap* mk3;
+ QPixmap* mk4;
+ int keyDown;
+ bool shift;
+ int button;
+
+ Q_OBJECT
+ int y2pitch(int) const;
+ int pitch2y(int) const;
+ void viewMouseMoveEvent(QMouseEvent* event);
+ virtual void leaveEvent(QEvent*e);
+
+ virtual void viewMousePressEvent(QMouseEvent* event);
+ virtual void viewMouseReleaseEvent(QMouseEvent*);
+
+ protected:
+ virtual void draw(QPainter&, const QRect&);
+
+ signals:
+ void pitchChanged(int);
+ void keyPressed(int, int, bool);
+ void keyReleased(int, bool);
+
+ public slots:
+ void setPitch(int);
+
+ public:
+ Piano(QWidget*, int);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/midiedit/pianoroll.cpp b/attic/muse2-oom/muse2/muse/midiedit/pianoroll.cpp
new file mode 100644
index 00000000..d2dbfca5
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/pianoroll.cpp
@@ -0,0 +1,1501 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: pianoroll.cpp,v 1.25.2.15 2009/11/16 11:29:33 lunar_shuttle Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QLayout>
+#include <QSizeGrip>
+#include <QLabel>
+#include <QPushButton>
+#include <QToolButton>
+#include <QToolTip>
+#include <QMenu>
+#include <QSignalMapper>
+#include <QMenuBar>
+#include <QApplication>
+#include <QClipboard>
+#include <QDir>
+#include <QAction>
+#include <QKeySequence>
+#include <QKeyEvent>
+#include <QGridLayout>
+#include <QResizeEvent>
+#include <QCloseEvent>
+#include <QMimeData>
+#include <QScrollArea>
+
+#include <stdio.h>
+
+#include "xml.h"
+#include "mtscale.h"
+#include "pcscale.h"
+#include "prcanvas.h"
+#include "pianoroll.h"
+#include "scrollscale.h"
+#include "piano.h"
+#include "../ctrl/ctrledit.h"
+#include "splitter.h"
+#include "ttoolbar.h"
+#include "tb1.h"
+#include "utils.h"
+#include "globals.h"
+#include "gconfig.h"
+#include "icons.h"
+#include "audio.h"
+
+#include "cmd.h"
+#include "quantconfig.h"
+#include "shortcuts.h"
+
+#include "mtrackinfo.h"
+
+int PianoRoll::_quantInit = 96;
+int PianoRoll::_rasterInit = 96;
+int PianoRoll::_widthInit = 600;
+int PianoRoll::_heightInit = 400;
+int PianoRoll::_quantStrengthInit = 80; // 1 - 100%
+int PianoRoll::_quantLimitInit = 50; // tick value
+bool PianoRoll::_quantLenInit = false;
+int PianoRoll::_toInit = 0;
+int PianoRoll::colorModeInit = 0;
+
+static const int xscale = -10;
+static const int yscale = 1;
+static const int pianoWidth = 40;
+static int pianorollTools = PointerTool | PencilTool | RubberTool | DrawTool;
+
+
+//---------------------------------------------------------
+// PianoRoll
+//---------------------------------------------------------
+
+PianoRoll::PianoRoll(PartList* pl, QWidget* parent, const char* name, unsigned initPos)
+ : MidiEditor(_quantInit, _rasterInit, pl, parent, name)
+ {
+ deltaMode = false;
+ resize(_widthInit, _heightInit);
+ selPart = 0;
+ quantConfig = 0;
+ _playEvents = false;
+ _quantStrength = _quantStrengthInit;
+ _quantLimit = _quantLimitInit;
+ _quantLen = _quantLenInit;
+ _to = _toInit;
+ colorMode = colorModeInit;
+
+ QSignalMapper* mapper = new QSignalMapper(this);
+ QSignalMapper* colorMapper = new QSignalMapper(this);
+
+ //---------Menu----------------------------------
+
+ menuEdit = menuBar()->addMenu(tr("&Edit"));
+
+ menuEdit->addActions(undoRedo->actions());
+
+ menuEdit->addSeparator();
+
+ editCutAction = menuEdit->addAction(QIcon(*editcutIconSet), tr("C&ut"));
+ mapper->setMapping(editCutAction, PianoCanvas::CMD_CUT);
+ connect(editCutAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ editCopyAction = menuEdit->addAction(QIcon(*editcopyIconSet), tr("&Copy"));
+ mapper->setMapping(editCopyAction, PianoCanvas::CMD_COPY);
+ connect(editCopyAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ editPasteAction = menuEdit->addAction(QIcon(*editpasteIconSet), tr("&Paste"));
+ mapper->setMapping(editPasteAction, PianoCanvas::CMD_PASTE);
+ connect(editPasteAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ menuEdit->addSeparator();
+
+ editDelEventsAction = menuEdit->addAction(tr("Delete &Events"));
+ mapper->setMapping(editDelEventsAction, PianoCanvas::CMD_DEL);
+ connect(editDelEventsAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ menuEdit->addSeparator();
+
+ menuSelect = menuEdit->addMenu(QIcon(*selectIcon), tr("&Select"));
+
+ selectAllAction = menuSelect->addAction(QIcon(*select_allIcon), tr("Select &All"));
+ mapper->setMapping(selectAllAction, PianoCanvas::CMD_SELECT_ALL);
+ connect(selectAllAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ selectNoneAction = menuSelect->addAction(QIcon(*select_deselect_allIcon), tr("&Deselect All"));
+ mapper->setMapping(selectNoneAction, PianoCanvas::CMD_SELECT_NONE);
+ connect(selectNoneAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ selectInvertAction = menuSelect->addAction(QIcon(*select_invert_selectionIcon), tr("Invert &Selection"));
+ mapper->setMapping(selectInvertAction, PianoCanvas::CMD_SELECT_INVERT);
+ connect(selectInvertAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ menuSelect->addSeparator();
+
+ selectInsideLoopAction = menuSelect->addAction(QIcon(*select_inside_loopIcon), tr("&Inside Loop"));
+ mapper->setMapping(selectInsideLoopAction, PianoCanvas::CMD_SELECT_ILOOP);
+ connect(selectInsideLoopAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ selectOutsideLoopAction = menuSelect->addAction(QIcon(*select_outside_loopIcon), tr("&Outside Loop"));
+ mapper->setMapping(selectOutsideLoopAction, PianoCanvas::CMD_SELECT_OLOOP);
+ connect(selectOutsideLoopAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ menuSelect->addSeparator();
+
+ //selectPrevPartAction = select->addAction(tr("&Previous Part"));
+ selectPrevPartAction = menuSelect->addAction(QIcon(*select_all_parts_on_trackIcon), tr("&Previous Part"));
+ mapper->setMapping(selectPrevPartAction, PianoCanvas::CMD_SELECT_PREV_PART);
+ connect(selectPrevPartAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ //selNextPartAction = select->addAction(tr("&Next Part"));
+ selectNextPartAction = menuSelect->addAction(QIcon(*select_all_parts_on_trackIcon), tr("&Next Part"));
+ mapper->setMapping(selectNextPartAction, PianoCanvas::CMD_SELECT_NEXT_PART);
+ connect(selectNextPartAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ menuConfig = menuBar()->addMenu(tr("&Config"));
+
+ eventColor = menuConfig->addMenu(tr("&Event Color"));
+
+ QActionGroup* actgrp = new QActionGroup(this);
+ actgrp->setExclusive(true);
+
+ //evColorBlueAction = eventColor->addAction(tr("&Blue"));
+ evColorBlueAction = actgrp->addAction(tr("&Blue"));
+ evColorBlueAction->setCheckable(true);
+ colorMapper->setMapping(evColorBlueAction, 0);
+
+ //evColorPitchAction = eventColor->addAction(tr("&Pitch colors"));
+ evColorPitchAction = actgrp->addAction(tr("&Pitch colors"));
+ evColorPitchAction->setCheckable(true);
+ colorMapper->setMapping(evColorPitchAction, 1);
+
+ //evColorVelAction = eventColor->addAction(tr("&Velocity colors"));
+ evColorVelAction = actgrp->addAction(tr("&Velocity colors"));
+ evColorVelAction->setCheckable(true);
+ colorMapper->setMapping(evColorVelAction, 2);
+
+ connect(evColorBlueAction, SIGNAL(triggered()), colorMapper, SLOT(map()));
+ connect(evColorPitchAction, SIGNAL(triggered()), colorMapper, SLOT(map()));
+ connect(evColorVelAction, SIGNAL(triggered()), colorMapper, SLOT(map()));
+
+ eventColor->addActions(actgrp->actions());
+
+ connect(colorMapper, SIGNAL(mapped(int)), this, SLOT(eventColorModeChanged(int)));
+
+ menuFunctions = menuBar()->addMenu(tr("&Functions"));
+
+ menuFunctions->setTearOffEnabled(true);
+
+ funcOverQuantAction = menuFunctions->addAction(tr("Over Quantize"));
+ mapper->setMapping(funcOverQuantAction, PianoCanvas::CMD_OVER_QUANTIZE);
+ connect(funcOverQuantAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ funcNoteOnQuantAction = menuFunctions->addAction(tr("Note On Quantize"));
+ mapper->setMapping(funcNoteOnQuantAction, PianoCanvas::CMD_ON_QUANTIZE);
+ connect(funcNoteOnQuantAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ funcNoteOnOffQuantAction = menuFunctions->addAction(tr("Note On/Off Quantize"));
+ mapper->setMapping(funcNoteOnOffQuantAction, PianoCanvas::CMD_ONOFF_QUANTIZE);
+ connect(funcNoteOnOffQuantAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ funcIterQuantAction = menuFunctions->addAction(tr("Iterative Quantize"));
+ mapper->setMapping(funcIterQuantAction, PianoCanvas::CMD_ITERATIVE_QUANTIZE);
+ connect(funcIterQuantAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ menuFunctions->addSeparator();
+
+ funcConfigQuantAction = menuFunctions->addAction(tr("Config Quant..."));
+ connect(funcConfigQuantAction, SIGNAL(triggered()), this, SLOT(configQuant()));
+
+ menuFunctions->addSeparator();
+
+ funcGateTimeAction = menuFunctions->addAction(tr("Modify Gate Time"));
+ mapper->setMapping(funcGateTimeAction, PianoCanvas::CMD_MODIFY_GATE_TIME);
+ connect(funcGateTimeAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ funcModVelAction = menuFunctions->addAction(tr("Modify Velocity"));
+ mapper->setMapping(funcModVelAction, PianoCanvas::CMD_MODIFY_VELOCITY);
+ connect(funcModVelAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ funcCrescendoAction = menuFunctions->addAction(tr("Crescendo"));
+ mapper->setMapping(funcCrescendoAction, PianoCanvas::CMD_CRESCENDO);
+ funcCrescendoAction->setEnabled(false);
+ connect(funcCrescendoAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ funcTransposeAction = menuFunctions->addAction(tr("Transpose"));
+ mapper->setMapping(funcTransposeAction, PianoCanvas::CMD_TRANSPOSE);
+ funcTransposeAction->setEnabled(false);
+ connect(funcTransposeAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ funcThinOutAction = menuFunctions->addAction(tr("Thin Out"));
+ mapper->setMapping(funcThinOutAction, PianoCanvas::CMD_THIN_OUT);
+ funcThinOutAction->setEnabled(false);
+ connect(funcThinOutAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ funcEraseEventAction = menuFunctions->addAction(tr("Erase Event"));
+ mapper->setMapping(funcEraseEventAction, PianoCanvas::CMD_ERASE_EVENT);
+ funcEraseEventAction->setEnabled(false);
+ connect(funcEraseEventAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ funcNoteShiftAction = menuFunctions->addAction(tr("Note Shift"));
+ mapper->setMapping(funcNoteShiftAction, PianoCanvas::CMD_NOTE_SHIFT);
+ funcNoteShiftAction->setEnabled(false);
+ connect(funcNoteShiftAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ funcMoveClockAction = menuFunctions->addAction(tr("Move Clock"));
+ mapper->setMapping(funcMoveClockAction, PianoCanvas::CMD_MOVE_CLOCK);
+ funcMoveClockAction->setEnabled(false);
+ connect(funcMoveClockAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ funcCopyMeasureAction = menuFunctions->addAction(tr("Copy Measure"));
+ mapper->setMapping(funcCopyMeasureAction, PianoCanvas::CMD_COPY_MEASURE);
+ funcCopyMeasureAction->setEnabled(false);
+ connect(funcCopyMeasureAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ funcEraseMeasureAction = menuFunctions->addAction(tr("Erase Measure"));
+ mapper->setMapping(funcEraseMeasureAction, PianoCanvas::CMD_ERASE_MEASURE);
+ funcEraseMeasureAction->setEnabled(false);
+ connect(funcEraseMeasureAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ funcDelMeasureAction = menuFunctions->addAction(tr("Delete Measure"));
+ mapper->setMapping(funcDelMeasureAction, PianoCanvas::CMD_DELETE_MEASURE);
+ funcDelMeasureAction->setEnabled(false);
+ connect(funcDelMeasureAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ funcCreateMeasureAction = menuFunctions->addAction(tr("Create Measure"));
+ mapper->setMapping(funcCreateMeasureAction, PianoCanvas::CMD_CREATE_MEASURE);
+ funcCreateMeasureAction->setEnabled(false);
+ connect(funcCreateMeasureAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ funcSetFixedLenAction = menuFunctions->addAction(tr("Set Fixed Length"));
+ mapper->setMapping(funcSetFixedLenAction, PianoCanvas::CMD_FIXED_LEN);
+ connect(funcSetFixedLenAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ funcDelOverlapsAction = menuFunctions->addAction(tr("Delete Overlaps"));
+ mapper->setMapping(funcDelOverlapsAction, PianoCanvas::CMD_DELETE_OVERLAPS);
+ connect(funcDelOverlapsAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ menuPlugins = menuBar()->addMenu(tr("&Plugins"));
+ song->populateScriptMenu(menuPlugins, this);
+
+ connect(mapper, SIGNAL(mapped(int)), this, SLOT(cmd(int)));
+
+ //---------ToolBar----------------------------------
+ tools = addToolBar(tr("Pianoroll tools"));
+ tools->addActions(undoRedo->actions());
+ tools->addSeparator();
+ tools->setIconSize(QSize(22,22));
+
+ srec = new QToolButton();
+ srec->setToolTip(tr("Step Record"));
+ srec->setIcon(*steprecIcon);
+ srec->setCheckable(true);
+ //srec->setObjectName("StepRecord");
+ tools->addWidget(srec);
+
+ midiin = new QToolButton();
+ midiin->setToolTip(tr("Midi Input"));
+ midiin->setIcon(*midiinIcon);
+ midiin->setCheckable(true);
+ //tools->addWidget(midiin);
+
+ speaker = new QToolButton();
+ speaker->setToolTip(tr("Play Events"));
+ speaker->setIcon(*speakerIcon);
+ speaker->setCheckable(true);
+ tools->addWidget(speaker);
+
+ tools2 = new EditToolBar(this, pianorollTools);
+ tools2->setIconSize(QSize(22,22));
+ addToolBar(tools2);
+
+ QToolBar* panicToolbar = new QToolBar(tr("panic"));
+ panicToolbar->addAction(panicAction);
+ panicToolbar->setAllowedAreas(Qt::BottomToolBarArea);
+
+ //-------------------------------------------------------------
+ // Transport Bar
+ QToolBar* transport = new QToolBar(tr("transport"));
+ addToolBar(Qt::BottomToolBarArea, transport);
+ transport->addActions(transportAction->actions());
+ transport->setAllowedAreas(Qt::BottomToolBarArea);
+ transport->setIconSize(QSize(22,22));
+ addToolBar(Qt::BottomToolBarArea, panicToolbar);
+
+ //addToolBarBreak();
+ toolbar = new Toolbar1(this, _rasterInit, _quantInit);
+ addToolBar(toolbar);
+
+ //addToolBarBreak();
+ info = new NoteInfo(this);
+ addToolBar(Qt::BottomToolBarArea, info);
+ info->setAllowedAreas(Qt::BottomToolBarArea);
+
+ //---------------------------------------------------
+ // split
+ //---------------------------------------------------
+
+ splitter = new Splitter(Qt::Vertical, mainw, "splitter");
+ splitter->setHandleWidth(2);
+
+ hsplitter = new Splitter(Qt::Horizontal, mainw, "hsplitter");
+ hsplitter->setChildrenCollapsible(true);
+ hsplitter->setHandleWidth(2);
+
+ QPushButton* ctrl = new QPushButton(tr("ctrl"), mainw);
+ //QPushButton* ctrl = new QPushButton(tr("C"), mainw); // Tim.
+ ctrl->setObjectName("Ctrl");
+ ctrl->setFont(config.fonts[3]);
+ ctrl->setToolTip(tr("Add Controller View"));
+ hscroll = new ScrollScale(-25, -2, xscale, 20000, Qt::Horizontal, mainw);
+ ctrl->setFixedSize(pianoWidth, hscroll->sizeHint().height());
+ //ctrl->setFixedSize(pianoWidth / 2, hscroll->sizeHint().height()); // Tim.
+
+ // Tim.
+ /*
+ QPushButton* trackInfoButton = new QPushButton(tr("T"), mainw);
+ trackInfoButton->setObjectName("TrackInfo");
+ trackInfoButton->setFont(config.fonts[3]);
+ trackInfoButton->setToolTip(tr("Show track info"));
+ trackInfoButton->setFixedSize(pianoWidth / 2, hscroll->sizeHint().height());
+ */
+
+ QSizeGrip* corner = new QSizeGrip(mainw);
+
+ midiTrackInfo = new MidiTrackInfo(mainw);
+ midiTrackInfo->setObjectName("prTrackInfo");
+ int mtiw = 280;//midiTrackInfo->width(); // Save this.
+ midiTrackInfo->setMinimumWidth(100);
+ //midiTrackInfo->setMaximumWidth(300);
+ connect(hsplitter, SIGNAL(splitterMoved(int, int)), midiTrackInfo, SLOT(updateSize()));
+
+ //midiTrackInfo->setSizePolicy(QSizePolicy(/*QSizePolicy::Ignored*/QSizePolicy::Preferred, QSizePolicy::Expanding));
+ infoScroll = new QScrollArea;
+ infoScroll->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ infoScroll->setVerticalScrollBarPolicy(Qt::ScrollBarAsNeeded);
+ //infoScroll->setMaximumWidth(300);
+ infoScroll->setMinimumWidth(100);
+ //infoScroll->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Expanding));
+ infoScroll->setWidget(midiTrackInfo);
+ infoScroll->setWidgetResizable(true);
+ //infoScroll->setObjectName("trackInfoScroll");
+ //infoScroller->setAttribute(Qt::WA_NoBackground);
+ //infoScroll->setVisible(false);
+ //infoScroll->setEnabled(false);
+
+ //hsplitter->addWidget(midiTrackInfo);
+ hsplitter->addWidget(infoScroll); // Tim.
+ hsplitter->addWidget(splitter);
+
+ mainGrid->setRowStretch(0, 100);
+ mainGrid->setColumnStretch(1, 100);
+ mainGrid->addWidget(hsplitter, 0, 1, 1, 3);
+
+ // Original.
+ /*
+ mainGrid->setColumnStretch(1, 100);
+ mainGrid->addWidget(splitter, 0, 0, 1, 3);
+ mainGrid->addWidget(ctrl, 1, 0);
+ mainGrid->addWidget(hscroll, 1, 1);
+ mainGrid->addWidget(corner, 1, 2, Qt::AlignBottom|Qt::AlignRight);
+ */
+
+
+ // Tim.
+ /*
+ mainGrid->setColumnStretch(2, 100);
+ mainGrid->addWidget(splitter, 0, 0, 1, 4);
+ mainGrid->addWidget(trackInfoButton, 1, 0);
+ mainGrid->addWidget(ctrl, 1, 1);
+ mainGrid->addWidget(hscroll, 1, 2);
+ mainGrid->addWidget(corner, 1, 3, Qt::AlignBottom|Qt::AlignRight);
+ */
+
+ //mainGrid->addRowSpacing(1, hscroll->sizeHint().height());
+ //mainGrid->addItem(new QSpacerItem(0, hscroll->sizeHint().height()), 1, 0); // Orig + Tim.
+
+ QWidget* split1 = new QWidget(splitter);
+ split1->setObjectName("split1");
+ QGridLayout* gridS1 = new QGridLayout(split1);
+ gridS1->setContentsMargins(0, 0, 0, 0);
+ gridS1->setSpacing(0);
+ //Defined and configure your program change bar here.
+ //This may well be a copy of MTScale extended for our needs
+ pcbar = new PCScale(&_raster, split1, this, xscale);
+ pcbar->setAudio(audio);
+ //pcbar->setEditor(this);
+ time = new MTScale(&_raster, split1, xscale);
+ Piano* piano = new Piano(split1, yscale);
+ canvas = new PianoCanvas(this, split1, xscale, yscale);
+ vscroll = new ScrollScale(-3, 7, yscale, KH * 75, Qt::Vertical, split1);
+
+ //setFocusProxy(canvas); // Tim.
+
+ int offset = -(config.division/4);
+ canvas->setOrigin(offset, 0);
+ canvas->setCanvasTools(pianorollTools);
+ canvas->setFocus();
+ connect(canvas, SIGNAL(toolChanged(int)), tools2, SLOT(set(int)));
+ time->setOrigin(offset, 0);
+ pcbar->setOrigin(offset, 0);
+
+ gridS1->setRowStretch(2, 100);
+ gridS1->setColumnStretch(1, 100);
+ //gridS1->setColumnStretch(2, 100); // Tim.
+
+ gridS1->addWidget(pcbar, 0, 1, 1, 2);
+ gridS1->addWidget(time, 1, 1, 1, 2);
+ gridS1->addWidget(hLine(split1), 2, 0, 1, 3);
+ gridS1->addWidget(piano, 3, 0);
+ gridS1->addWidget(canvas, 3, 1);
+ gridS1->addWidget(vscroll, 3, 2);
+
+ // Tim.
+ /*
+ gridS1->addWidget(time, 0, 2, 1, 3);
+ gridS1->addWidget(hLine(split1), 1, 1, 1, 4);
+ //gridS1->addWidget(infoScroll, 2, 0);
+ gridS1->addWidget(infoScroll, 0, 0, 3, 1);
+ gridS1->addWidget(piano, 2, 1);
+ gridS1->addWidget(canvas, 2, 2);
+ gridS1->addWidget(vscroll, 2, 3);
+ */
+
+ ctrlLane = new Splitter(Qt::Vertical, splitter, "ctrllane");
+ QWidget* split2 = new QWidget(splitter);
+ split2->setMaximumHeight(hscroll->sizeHint().height());
+ split2->setMinimumHeight(hscroll->sizeHint().height());
+ QGridLayout* gridS2 = new QGridLayout(split2);
+ gridS2->setContentsMargins(0, 0, 0, 0);
+ gridS2->setSpacing(0);
+ gridS2->setRowStretch(0, 100);
+ gridS2->setColumnStretch(1, 100);
+ gridS2->addWidget(ctrl, 0, 0);
+ gridS2->addWidget(hscroll, 0, 1);
+ gridS2->addWidget(corner, 0, 2, Qt::AlignBottom|Qt::AlignRight);
+ //splitter->setCollapsible(0, true);
+
+ piano->setFixedWidth(pianoWidth);
+
+ // Tim.
+ QList<int> mops;
+ mops.append(mtiw); // 30 for possible scrollbar
+ mops.append(width() - mtiw);
+ hsplitter->setSizes(mops);
+ hsplitter->setStretchFactor(0, 0);
+ hsplitter->setStretchFactor(1, 15);
+
+ connect(tools2, SIGNAL(toolChanged(int)), canvas, SLOT(setTool(int)));
+
+ //connect(midiTrackInfo, SIGNAL(outputPortChanged(int)), list, SLOT(redraw()));
+ connect(ctrl, SIGNAL(clicked()), SLOT(addCtrl()));
+ //connect(trackInfoButton, SIGNAL(clicked()), SLOT(toggleTrackInfo())); Tim.
+ connect(info, SIGNAL(valueChanged(NoteInfo::ValType, int)), SLOT(noteinfoChanged(NoteInfo::ValType, int)));
+ connect(vscroll, SIGNAL(scrollChanged(int)), piano, SLOT(setYPos(int)));
+ connect(vscroll, SIGNAL(scrollChanged(int)), canvas, SLOT(setYPos(int)));
+ connect(vscroll, SIGNAL(scaleChanged(int)), canvas, SLOT(setYMag(int)));
+ connect(vscroll, SIGNAL(scaleChanged(int)), piano, SLOT(setYMag(int)));
+
+ connect(hscroll, SIGNAL(scrollChanged(int)), canvas, SLOT(setXPos(int)));
+ connect(hscroll, SIGNAL(scrollChanged(int)), time, SLOT(setXPos(int)));
+ connect(hscroll, SIGNAL(scrollChanged(int)), pcbar, SLOT(setXPos(int)));
+
+ connect(hscroll, SIGNAL(scaleChanged(int)), canvas, SLOT(setXMag(int)));
+ connect(hscroll, SIGNAL(scaleChanged(int)), time, SLOT(setXMag(int)));
+ connect(hscroll, SIGNAL(scaleChanged(int)), pcbar, SLOT(setXMag(int)));
+
+ connect(canvas, SIGNAL(newWidth(int)), SLOT(newCanvasWidth(int)));
+ connect(canvas, SIGNAL(pitchChanged(int)), piano, SLOT(setPitch(int)));
+ connect(canvas, SIGNAL(verticalScroll(unsigned)), vscroll, SLOT(setPos(unsigned)));
+ connect(canvas, SIGNAL(horizontalScroll(unsigned)),hscroll, SLOT(setPos(unsigned)));
+ connect(canvas, SIGNAL(horizontalScrollNoLimit(unsigned)),hscroll, SLOT(setPosNoLimit(unsigned)));
+ connect(canvas, SIGNAL(selectionChanged(int, Event&, Part*)), this,
+ SLOT(setSelection(int, Event&, Part*)));
+
+ connect(piano, SIGNAL(keyPressed(int, int, bool)), canvas, SLOT(pianoPressed(int, int, bool)));
+ connect(piano, SIGNAL(keyReleased(int, bool)), canvas, SLOT(pianoReleased(int, bool)));
+ connect(srec, SIGNAL(toggled(bool)), SLOT(setSteprec(bool)));
+ //connect(midiin, SIGNAL(toggled(bool)), canvas, SLOT(setMidiin(bool)));
+ connect(speaker, SIGNAL(toggled(bool)), SLOT(setSpeaker(bool)));
+ connect(canvas, SIGNAL(followEvent(int)), SLOT(follow(int)));
+
+ connect(hscroll, SIGNAL(scaleChanged(int)), SLOT(updateHScrollRange()));
+ piano->setYPos(KH * 30);
+ canvas->setYPos(KH * 30);
+ vscroll->setPos(KH * 30);
+ //setSelection(0, 0, 0); //Really necessary? Causes segfault when only 1 item selected, replaced by the following:
+ info->setEnabled(false);
+
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged1(int)));
+
+ setWindowTitle(canvas->getCaption());
+
+ updateHScrollRange();
+ // connect to toolbar
+ connect(canvas, SIGNAL(pitchChanged(int)), toolbar, SLOT(setPitch(int)));
+ connect(canvas, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
+ connect(piano, SIGNAL(pitchChanged(int)), toolbar, SLOT(setPitch(int)));
+ connect(time, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
+ connect(pcbar, SIGNAL(selectInstrument()), midiTrackInfo, SLOT(instrPopup()));
+ connect(pcbar, SIGNAL(addProgramChange()), midiTrackInfo, SLOT(progRecClicked()));
+ connect(toolbar, SIGNAL(quantChanged(int)), SLOT(setQuant(int)));
+ connect(toolbar, SIGNAL(rasterChanged(int)),SLOT(setRaster(int)));
+ connect(toolbar, SIGNAL(toChanged(int)), SLOT(setTo(int)));
+ connect(toolbar, SIGNAL(soloChanged(bool)), SLOT(soloChanged(bool)));
+
+ setFocusPolicy(Qt::StrongFocus);
+ setEventColorMode(colorMode);
+ canvas->setMidiin(true);
+ midiin->setChecked(true);
+ canvas->playEvents(true);
+ speaker->setChecked(true);
+
+ QClipboard* cb = QApplication::clipboard();
+ connect(cb, SIGNAL(dataChanged()), SLOT(clipboardChanged()));
+
+ clipboardChanged(); // enable/disable "Paste"
+ selectionChanged(); // enable/disable "Copy" & "Paste"
+ initShortcuts(); // initialize shortcuts
+
+ const Pos cpos=song->cPos();
+ canvas->setPos(0, cpos.tick(), true);
+ canvas->selectAtTick(cpos.tick());
+ //canvas->selectFirst();
+//
+ if(canvas->track())
+ {
+ updateTrackInfo();
+ toolbar->setSolo(canvas->track()->solo());
+ }
+
+ unsigned pos;
+ if(initPos >= MAXINT)
+ pos = song->cpos();
+ else
+ pos = initPos;
+ if(pos > MAXINT)
+ pos = MAXINT;
+
+ // At this point in time the range of the canvas hasn't
+ // been calculated right ?
+ // Also, why wanting to restore some initPos, what is initPos?
+ // To me, it seems to make a lot more sense to use the actual
+ // current song cpos.
+ // This is now done via the showEvent();
+
+// hscroll->setOffset((int)pos); // changed that to:
+}
+
+//---------------------------------------------------------
+// songChanged1
+//---------------------------------------------------------
+
+void PianoRoll::songChanged1(int bits)
+ {
+
+ if (bits & SC_SOLO)
+ {
+ toolbar->setSolo(canvas->track()->solo());
+ return;
+ }
+ songChanged(bits);
+ //trackInfo->songChanged(bits);
+ // We'll receive SC_SELECTION if a different part is selected.
+ if (bits & SC_SELECTION)
+ updateTrackInfo();
+ }
+
+//---------------------------------------------------------
+// configChanged
+//---------------------------------------------------------
+
+void PianoRoll::configChanged()
+ {
+ initShortcuts();
+ //trackInfo->updateTrackInfo();
+ }
+
+//---------------------------------------------------------
+// updateHScrollRange
+//---------------------------------------------------------
+
+void PianoRoll::updateHScrollRange()
+{
+ int s, e;
+ canvas->range(&s, &e);
+ // Show one more measure.
+ e += AL::sigmap.ticksMeasure(e);
+ // Show another quarter measure due to imprecise drawing at canvas end point.
+ e += AL::sigmap.ticksMeasure(e) / 4;
+ // Compensate for the fixed piano and vscroll widths.
+ e += canvas->rmapxDev(pianoWidth - vscroll->width());
+ int s1, e1;
+ hscroll->range(&s1, &e1);
+ if(s != s1 || e != e1)
+ hscroll->setRange(s, e);
+}
+
+void PianoRoll::updateTrackInfo()
+{
+ selected = curCanvasPart()->track();
+ if (selected->isMidiTrack()) {
+ midiTrackInfo->setTrack(selected);
+ ///midiTrackInfo->updateTrackInfo(-1);
+ }
+}
+
+//---------------------------------------------------------
+// follow
+//---------------------------------------------------------
+
+void PianoRoll::follow(int pos)
+ {
+ int s, e;
+ canvas->range(&s, &e);
+
+ if (pos < e && pos >= s)
+ hscroll->setOffset(pos);
+ if (pos < s)
+ hscroll->setOffset(s);
+ }
+
+//---------------------------------------------------------
+// setTime
+//---------------------------------------------------------
+
+void PianoRoll::setTime(unsigned tick)
+ {
+ toolbar->setTime(tick);
+ time->setPos(3, tick, false);
+ pcbar->setPos(3, tick, false);
+ }
+
+//---------------------------------------------------------
+// ~Pianoroll
+//---------------------------------------------------------
+
+PianoRoll::~PianoRoll()
+ {
+ // undoRedo->removeFrom(tools); // p4.0.6 Removed
+ }
+
+//---------------------------------------------------------
+// cmd
+// pulldown menu commands
+//---------------------------------------------------------
+
+void PianoRoll::cmd(int cmd)
+ {
+ ((PianoCanvas*)canvas)->cmd(cmd, _quantStrength, _quantLimit, _quantLen, _to);
+ }
+
+//---------------------------------------------------------
+// setSelection
+// update Info Line
+//---------------------------------------------------------
+
+void PianoRoll::setSelection(int tick, Event& e, Part* p)
+ {
+ int selections = canvas->selectionSize();
+
+ selEvent = e;
+ selPart = (MidiPart*)p;
+ selTick = tick;
+
+ if (selections > 1) {
+ info->setEnabled(true);
+ info->setDeltaMode(true);
+ if (!deltaMode) {
+ deltaMode = true;
+ info->setValues(0, 0, 0, 0, 0);
+ tickOffset = 0;
+ lenOffset = 0;
+ pitchOffset = 0;
+ veloOnOffset = 0;
+ veloOffOffset = 0;
+ }
+ }
+ else if (selections == 1) {
+ deltaMode = false;
+ info->setEnabled(true);
+ info->setDeltaMode(false);
+ info->setValues(tick,
+ selEvent.lenTick(),
+ selEvent.pitch(),
+ selEvent.velo(),
+ selEvent.veloOff());
+ }
+ else {
+ deltaMode = false;
+ info->setEnabled(false);
+ }
+ selectionChanged();
+ }
+
+//---------------------------------------------------------
+// edit currently selected Event
+//---------------------------------------------------------
+
+void PianoRoll::noteinfoChanged(NoteInfo::ValType type, int val)
+ {
+ int selections = canvas->selectionSize();
+
+ if (selections == 0) {
+ printf("noteinfoChanged while nothing selected\n");
+ }
+ else if (selections == 1) {
+ Event event = selEvent.clone();
+ switch(type) {
+ case NoteInfo::VAL_TIME:
+ event.setTick(val - selPart->tick());
+ break;
+ case NoteInfo::VAL_LEN:
+ event.setLenTick(val);
+ break;
+ case NoteInfo::VAL_VELON:
+ event.setVelo(val);
+ break;
+ case NoteInfo::VAL_VELOFF:
+ event.setVeloOff(val);
+ break;
+ case NoteInfo::VAL_PITCH:
+ event.setPitch(val);
+ break;
+ }
+ // Indicate do undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(selEvent, event, selPart);
+ audio->msgChangeEvent(selEvent, event, selPart, true, false, false);
+ }
+ else {
+ // multiple events are selected; treat noteinfo values
+ // as offsets to event values
+
+ int delta = 0;
+ switch (type) {
+ case NoteInfo::VAL_TIME:
+ delta = val - tickOffset;
+ tickOffset = val;
+ break;
+ case NoteInfo::VAL_LEN:
+ delta = val - lenOffset;
+ lenOffset = val;
+ break;
+ case NoteInfo::VAL_VELON:
+ delta = val - veloOnOffset;
+ veloOnOffset = val;
+ break;
+ case NoteInfo::VAL_VELOFF:
+ delta = val - veloOffOffset;
+ veloOffOffset = val;
+ break;
+ case NoteInfo::VAL_PITCH:
+ delta = val - pitchOffset;
+ pitchOffset = val;
+ break;
+ }
+ if (delta)
+ canvas->modifySelected(type, delta);
+ }
+ }
+
+//---------------------------------------------------------
+// addCtrl
+//---------------------------------------------------------
+
+CtrlEdit* PianoRoll::addCtrl()
+ {
+ ///CtrlEdit* ctrlEdit = new CtrlEdit(splitter, this, xscale, false, "pianoCtrlEdit");
+ CtrlEdit* ctrlEdit = new CtrlEdit(ctrlLane/*splitter*/, this, xscale, false, "pianoCtrlEdit"); // ccharrett
+ connect(tools2, SIGNAL(toolChanged(int)), ctrlEdit, SLOT(setTool(int)));
+ connect(hscroll, SIGNAL(scrollChanged(int)), ctrlEdit, SLOT(setXPos(int)));
+ connect(hscroll, SIGNAL(scaleChanged(int)), ctrlEdit, SLOT(setXMag(int)));
+ connect(ctrlEdit, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
+ connect(ctrlEdit, SIGNAL(destroyedCtrl(CtrlEdit*)), SLOT(removeCtrl(CtrlEdit*)));
+ connect(ctrlEdit, SIGNAL(yposChanged(int)), toolbar, SLOT(setInt(int)));
+
+ ctrlEdit->setTool(tools2->curTool());
+ ctrlEdit->setXPos(hscroll->pos());
+ ctrlEdit->setXMag(hscroll->getScaleValue());
+
+ ctrlEdit->show();
+ ctrlEditList.push_back(ctrlEdit);
+ return ctrlEdit;
+ }
+
+//---------------------------------------------------------
+// removeCtrl
+//---------------------------------------------------------
+
+void PianoRoll::removeCtrl(CtrlEdit* ctrl)
+ {
+ for (std::list<CtrlEdit*>::iterator i = ctrlEditList.begin();
+ i != ctrlEditList.end(); ++i) {
+ if (*i == ctrl) {
+ ctrlEditList.erase(i);
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void PianoRoll::closeEvent(QCloseEvent* e)
+ {
+ emit deleted((unsigned long)this);
+ e->accept();
+ }
+
+//---------------------------------------------------------
+// readConfiguration
+//---------------------------------------------------------
+
+void PianoRoll::readConfiguration(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ if (token == Xml::Error || token == Xml::End)
+ break;
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::TagStart:
+ if (tag == "quant")
+ _quantInit = xml.parseInt();
+ else if (tag == "raster")
+ _rasterInit = xml.parseInt();
+ else if (tag == "quantStrength")
+ _quantStrengthInit = xml.parseInt();
+ else if (tag == "quantLimit")
+ _quantLimitInit = xml.parseInt();
+ else if (tag == "quantLen")
+ _quantLenInit = xml.parseInt();
+ else if (tag == "to")
+ _toInit = xml.parseInt();
+ else if (tag == "colormode")
+ colorModeInit = xml.parseInt();
+ else if (tag == "width")
+ _widthInit = xml.parseInt();
+ else if (tag == "height")
+ _heightInit = xml.parseInt();
+ else
+ xml.unknown("PianoRoll");
+ break;
+ case Xml::TagEnd:
+ if (tag == "pianoroll")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// writeConfiguration
+//---------------------------------------------------------
+
+void PianoRoll::writeConfiguration(int level, Xml& xml)
+ {
+ xml.tag(level++, "pianoroll");
+ xml.intTag(level, "quant", _quantInit);
+ xml.intTag(level, "raster", _rasterInit);
+ xml.intTag(level, "quantStrength", _quantStrengthInit);
+ xml.intTag(level, "quantLimit", _quantLimitInit);
+ xml.intTag(level, "quantLen", _quantLenInit);
+ xml.intTag(level, "to", _toInit);
+ xml.intTag(level, "width", _widthInit);
+ xml.intTag(level, "height", _heightInit);
+ xml.intTag(level, "colormode", colorModeInit);
+ xml.etag(level, "pianoroll");
+ }
+
+//---------------------------------------------------------
+// soloChanged
+// signal from solo button
+//---------------------------------------------------------
+
+void PianoRoll::soloChanged(bool flag)
+ {
+ audio->msgSetSolo(canvas->track(), flag);
+ song->update(SC_SOLO);
+ }
+
+//---------------------------------------------------------
+// setRaster
+//---------------------------------------------------------
+
+void PianoRoll::setRaster(int val)
+ {
+ _rasterInit = val;
+ MidiEditor::setRaster(val);
+ canvas->redrawGrid();
+ canvas->setFocus(); // give back focus after kb input
+ }
+
+//---------------------------------------------------------
+// setQuant
+//---------------------------------------------------------
+
+void PianoRoll::setQuant(int val)
+ {
+ _quantInit = val;
+ MidiEditor::setQuant(val);
+ canvas->setFocus();
+ }
+
+//---------------------------------------------------------
+// writeStatus
+//---------------------------------------------------------
+
+void PianoRoll::writeStatus(int level, Xml& xml) const
+ {
+ writePartList(level, xml);
+ xml.tag(level++, "pianoroll");
+ MidiEditor::writeStatus(level, xml);
+ splitter->writeStatus(level, xml);
+ hsplitter->writeStatus(level, xml);
+
+ for (std::list<CtrlEdit*>::const_iterator i = ctrlEditList.begin();
+ i != ctrlEditList.end(); ++i) {
+ (*i)->writeStatus(level, xml);
+ }
+
+ xml.intTag(level, "steprec", canvas->steprec());
+ xml.intTag(level, "midiin", canvas->midiin());
+ xml.intTag(level, "tool", int(canvas->tool()));
+ xml.intTag(level, "quantStrength", _quantStrength);
+ xml.intTag(level, "quantLimit", _quantLimit);
+ xml.intTag(level, "quantLen", _quantLen);
+ xml.intTag(level, "playEvents", _playEvents);
+ xml.intTag(level, "xpos", hscroll->pos());
+ xml.intTag(level, "xmag", hscroll->mag());
+ xml.intTag(level, "ypos", vscroll->pos());
+ xml.intTag(level, "ymag", vscroll->mag());
+ xml.tag(level, "/pianoroll");
+ }
+
+//---------------------------------------------------------
+// readStatus
+//---------------------------------------------------------
+
+void PianoRoll::readStatus(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ if (token == Xml::Error || token == Xml::End)
+ break;
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::TagStart:
+ if (tag == "steprec") {
+ int val = xml.parseInt();
+ canvas->setSteprec(val);
+ srec->setChecked(val);
+ }
+ else if (tag == "midiin") {
+ int val = xml.parseInt();
+ canvas->setMidiin(val);
+ midiin->setChecked(val);
+ }
+ else if (tag == "tool") {
+ int tool = xml.parseInt();
+ canvas->setTool(tool);
+ tools2->set(tool);
+ }
+ else if (tag == "midieditor")
+ MidiEditor::readStatus(xml);
+ else if (tag == "ctrledit") {
+ CtrlEdit* ctrl = addCtrl();
+ ctrl->readStatus(xml);
+ }
+ else if (tag == splitter->objectName())
+ splitter->readStatus(xml);
+ else if (tag == hsplitter->objectName())
+ hsplitter->readStatus(xml);
+ else if (tag == "quantStrength")
+ _quantStrength = xml.parseInt();
+ else if (tag == "quantLimit")
+ _quantLimit = xml.parseInt();
+ else if (tag == "quantLen")
+ _quantLen = xml.parseInt();
+ else if (tag == "playEvents") {
+ _playEvents = xml.parseInt();
+ canvas->playEvents(_playEvents);
+ speaker->setChecked(_playEvents);
+ }
+ else if (tag == "xmag")
+ hscroll->setMag(xml.parseInt());
+ else if (tag == "xpos")
+ hscroll->setPos(xml.parseInt());
+ else if (tag == "ymag")
+ vscroll->setMag(xml.parseInt());
+ else if (tag == "ypos")
+ vscroll->setPos(xml.parseInt());
+ else
+ xml.unknown("PianoRoll");
+ break;
+ case Xml::TagEnd:
+ if (tag == "pianoroll") {
+ _quantInit = _quant;
+ _rasterInit = _raster;
+ toolbar->setRaster(_raster);
+ toolbar->setQuant(_quant);
+ canvas->redrawGrid();
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+static int rasterTable[] = {
+ //-9----8- 7 6 5 4 3(1/4) 2 1
+ 4, 8, 16, 32, 64, 128, 256, 512, 1024, // triple
+ 6, 12, 24, 48, 96, 192, 384, 768, 1536,
+ 9, 18, 36, 72, 144, 288, 576, 1152, 2304 // dot
+ };
+
+//---------------------------------------------------------
+// viewKeyPressEvent
+//---------------------------------------------------------
+
+void PianoRoll::keyPressEvent(QKeyEvent* event)
+ {
+ if (info->hasFocus()) {
+ event->ignore();
+ return;
+ }
+
+ int index;
+ int n = sizeof(rasterTable)/sizeof(*rasterTable);
+ for (index = 0; index < n; ++index)
+ if (rasterTable[index] == raster())
+ break;
+ if (index == n) {
+ index = 0;
+ // raster 1 is not in table
+ }
+ int off = (index / 9) * 9;
+ index = index % 9;
+
+ int val = 0;
+
+ PianoCanvas* pc = (PianoCanvas*)canvas;
+ int key = event->key();
+
+ //if (event->state() & Qt::ShiftButton)
+ if (((QInputEvent*)event)->modifiers() & Qt::ShiftModifier)
+ key += Qt::SHIFT;
+ //if (event->state() & Qt::AltButton)
+ if (((QInputEvent*)event)->modifiers() & Qt::AltModifier)
+ key += Qt::ALT;
+ //if (event->state() & Qt::ControlButton)
+ if (((QInputEvent*)event)->modifiers() & Qt::ControlModifier)
+ key+= Qt::CTRL;
+
+ if (key == Qt::Key_Escape) {
+ close();
+ return;
+ }
+ else if (key == shortcuts[SHRT_TOOL_POINTER].key) {
+ tools2->set(PointerTool);
+ return;
+ }
+ else if (key == shortcuts[SHRT_TOOL_PENCIL].key) {
+ tools2->set(PencilTool);
+ return;
+ }
+ else if (key == shortcuts[SHRT_TOOL_RUBBER].key) {
+ tools2->set(RubberTool);
+ return;
+ }
+ else if (key == shortcuts[SHRT_TOOL_LINEDRAW].key) {
+ tools2->set(DrawTool);
+ return;
+ }
+ else if (key == shortcuts[SHRT_POS_INC].key) {
+ pc->pianoCmd(CMD_RIGHT);
+ return;
+ }
+ else if (key == shortcuts[SHRT_POS_DEC].key) {
+ pc->pianoCmd(CMD_LEFT);
+ return;
+ }
+ else if (key == shortcuts[SHRT_POS_INC_NOSNAP].key) {
+ pc->pianoCmd(CMD_RIGHT_NOSNAP);
+ return;
+ }
+ else if (key == shortcuts[SHRT_POS_DEC_NOSNAP].key) {
+ pc->pianoCmd(CMD_LEFT_NOSNAP);
+ return;
+ }
+ else if (key == shortcuts[SHRT_INSERT_AT_LOCATION].key) {
+ pc->pianoCmd(CMD_INSERT);
+ return;
+ }
+ else if (key == Qt::Key_Delete) {
+ pc->pianoCmd(CMD_DELETE);
+ return;
+ }
+ else if (key == shortcuts[SHRT_ZOOM_IN].key) {
+ int mag = hscroll->mag();
+ int zoomlvl = ScrollScale::getQuickZoomLevel(mag);
+ if (zoomlvl < 23)
+ zoomlvl++;
+
+ int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl);
+ hscroll->setMag(newmag);
+ //printf("mag = %d zoomlvl = %d newmag = %d\n", mag, zoomlvl, newmag);
+ return;
+ }
+ else if (key == shortcuts[SHRT_ZOOM_OUT].key) {
+ int mag = hscroll->mag();
+ int zoomlvl = ScrollScale::getQuickZoomLevel(mag);
+ if (zoomlvl > 1)
+ zoomlvl--;
+
+ int newmag = ScrollScale::convertQuickZoomLevelToMag(zoomlvl);
+ hscroll->setMag(newmag);
+ //printf("mag = %d zoomlvl = %d newmag = %d\n", mag, zoomlvl, newmag);
+ return;
+ }
+ else if (key == shortcuts[SHRT_GOTO_CPOS].key) {
+ PartList* p = this->parts();
+ Part* first = p->begin()->second;
+ hscroll->setPos(song->cpos() - first->tick() );
+ return;
+ }
+ else if (key == shortcuts[SHRT_SCROLL_LEFT].key) {
+ int pos = hscroll->pos() - config.division;
+ if (pos < 0)
+ pos = 0;
+ hscroll->setPos(pos);
+ return;
+ }
+ else if (key == shortcuts[SHRT_SCROLL_RIGHT].key) {
+ int pos = hscroll->pos() + config.division;
+ hscroll->setPos(pos);
+ return;
+ }
+ else if (key == shortcuts[SHRT_SEL_INSTRUMENT].key) {
+ midiTrackInfo->instrPopup();
+ return;
+ }
+ else if (key == shortcuts[SHRT_ADD_PROGRAM].key) {
+ midiTrackInfo->insertMatrixEvent();//progRecClicked();
+ return;
+ }
+ else if (key == shortcuts[SHRT_DEL_PROGRAM].key) {
+ //printf("Delete KeyStroke recieved\n");
+ int x = song->cpos();
+ Track* track = song->findTrack(curCanvasPart());/*{{{*/
+ PartList* parts = track->parts();
+ for (iPart p = parts->begin(); p != parts->end(); ++p)
+ {
+ Part* mprt = p->second;
+ EventList* eventList = mprt->events();//m->second.events();
+ for(iEvent evt = eventList->begin(); evt != eventList->end(); ++evt)
+ {
+ //Get event type.
+ Event pcevt = evt->second;
+ //printf("Found events %d \n", pcevt.type());
+ if(!pcevt.isNote())
+ {
+ //printf("Found none Note events of type: %d with dataA: %d\n", pcevt.type(), pcevt.dataA());
+ if(pcevt.type() == Controller && pcevt.dataA() == CTRL_PROGRAM)
+ {
+ //printf("Found Program Change event type\n");
+ //printf("Pos x: %d\n", x);
+ int xp = pcevt.tick()+mprt->tick();
+ //printf("Event x: %d\n", xp);
+ if(xp >= x && xp <= (x+50))
+ {
+ //printf("Found Program Change to delete at: %d\n", x);
+ song->startUndo();
+ audio->msgDeleteEvent(evt->second, p->second, true, true, true);
+ song->endUndo(SC_EVENT_MODIFIED);
+ }
+ }
+ }
+ }
+ }/*}}}*/
+ //pcbar->deleteProgram();
+ return;
+ }
+ else if (key == shortcuts[SHRT_SET_QUANT_1].key)
+ val = rasterTable[8 + off];
+ else if (key == shortcuts[SHRT_SET_QUANT_2].key)
+ val = rasterTable[7 + off];
+ else if (key == shortcuts[SHRT_SET_QUANT_3].key)
+ val = rasterTable[6 + off];
+ else if (key == shortcuts[SHRT_SET_QUANT_4].key)
+ val = rasterTable[5 + off];
+ else if (key == shortcuts[SHRT_SET_QUANT_5].key)
+ val = rasterTable[4 + off];
+ else if (key == shortcuts[SHRT_SET_QUANT_6].key)
+ val = rasterTable[3 + off];
+ else if (key == shortcuts[SHRT_SET_QUANT_7].key)
+ val = rasterTable[2 + off];
+ else if (key == shortcuts[SHRT_TOGGLE_TRIOL].key)
+ val = rasterTable[index + ((off == 0) ? 9 : 0)];
+ else if (key == shortcuts[SHRT_EVENT_COLOR].key) {
+ if (colorMode == 0)
+ colorMode = 1;
+ else if (colorMode == 1)
+ colorMode = 2;
+ else
+ colorMode = 0;
+ setEventColorMode(colorMode);
+ return;
+ }
+ else if (key == shortcuts[SHRT_TOGGLE_PUNCT].key)
+ val = rasterTable[index + ((off == 18) ? 9 : 18)];
+
+ else if (key == shortcuts[SHRT_TOGGLE_PUNCT2].key) {//CDW
+ if ((off == 18) && (index > 2)) {
+ val = rasterTable[index + 9 - 1];
+ }
+ else if ((off == 9) && (index < 8)) {
+ val = rasterTable[index + 18 + 1];
+ }
+ else
+ return;
+ }
+ else { //Default:
+ event->ignore();
+ return;
+ }
+ setQuant(val);
+ setRaster(val);
+ toolbar->setQuant(_quant);
+ toolbar->setRaster(_raster);
+}
+
+//---------------------------------------------------------
+// configQuant
+//---------------------------------------------------------
+
+void PianoRoll::configQuant()
+ {
+ if (!quantConfig) {
+ quantConfig = new QuantConfig(_quantStrength, _quantLimit, _quantLen);
+ connect(quantConfig, SIGNAL(setQuantStrength(int)), SLOT(setQuantStrength(int)));
+ connect(quantConfig, SIGNAL(setQuantLimit(int)), SLOT(setQuantLimit(int)));
+ connect(quantConfig, SIGNAL(setQuantLen(bool)), SLOT(setQuantLen(bool)));
+ }
+ quantConfig->show();
+ }
+
+//---------------------------------------------------------
+// setSteprec
+//---------------------------------------------------------
+
+void PianoRoll::setSteprec(bool flag)
+{
+ canvas->setSteprec(flag);
+ //if (flag == false)
+ // midiin->setChecked(flag);
+}
+
+//---------------------------------------------------------
+// eventColorModeChanged
+//---------------------------------------------------------
+
+void PianoRoll::eventColorModeChanged(int mode)
+ {
+ colorMode = mode;
+ colorModeInit = colorMode;
+
+ ((PianoCanvas*)(canvas))->setColorMode(colorMode);
+ }
+
+//---------------------------------------------------------
+// setEventColorMode
+//---------------------------------------------------------
+
+void PianoRoll::setEventColorMode(int mode)
+ {
+ colorMode = mode;
+ colorModeInit = colorMode;
+
+ ///eventColor->setItemChecked(0, mode == 0);
+ ///eventColor->setItemChecked(1, mode == 1);
+ ///eventColor->setItemChecked(2, mode == 2);
+ evColorBlueAction->setChecked(mode == 0);
+ evColorPitchAction->setChecked(mode == 1);
+ evColorVelAction->setChecked(mode == 2);
+
+ ((PianoCanvas*)(canvas))->setColorMode(colorMode);
+ }
+
+//---------------------------------------------------------
+// clipboardChanged
+//---------------------------------------------------------
+
+void PianoRoll::clipboardChanged()
+ {
+ editPasteAction->setEnabled(QApplication::clipboard()->mimeData()->hasFormat(QString("text/x-muse-eventlist")));
+ }
+
+//---------------------------------------------------------
+// selectionChanged
+//---------------------------------------------------------
+
+void PianoRoll::selectionChanged()
+ {
+ bool flag = canvas->selectionSize() > 0;
+ editCutAction->setEnabled(flag);
+ editCopyAction->setEnabled(flag);
+ editDelEventsAction->setEnabled(flag);
+ }
+
+//---------------------------------------------------------
+// setSpeaker
+//---------------------------------------------------------
+
+void PianoRoll::setSpeaker(bool val)
+ {
+ _playEvents = val;
+ canvas->playEvents(_playEvents);
+ }
+
+//---------------------------------------------------------
+// resizeEvent
+//---------------------------------------------------------
+
+void PianoRoll::resizeEvent(QResizeEvent* ev)
+ {
+ QWidget::resizeEvent(ev);
+ _widthInit = ev->size().width();
+ _heightInit = ev->size().height();
+ }
+
+//---------------------------------------------------------
+// showEvent
+// Now that every gui element is created, including
+// the scroll bars, what about updating the scrollbars
+// so that the play cursor is in the center of the viewport?
+//---------------------------------------------------------
+
+void PianoRoll::showEvent(QShowEvent *)
+{
+ // maybe add a bool flag to follow: centered ?
+ // couldn't find a function that does that directly.
+ follow(song->cpos());
+ // now that the cursor is in the view, move the view
+ // half the canvas width so the cursor is centered.
+ hscroll->setPos(hscroll->pos() - (canvas->width()/2));
+}
+
+/*
+//---------------------------------------------------------
+// trackInfoScroll
+//---------------------------------------------------------
+
+void PianoRoll::trackInfoScroll(int y)
+ {
+ if (trackInfo->visibleWidget())
+ trackInfo->visibleWidget()->move(0, -y);
+ }
+*/
+
+//---------------------------------------------------------
+// initShortcuts
+//---------------------------------------------------------
+
+void PianoRoll::initShortcuts()
+ {
+ editCutAction->setShortcut(shortcuts[SHRT_CUT].key);
+ editCopyAction->setShortcut(shortcuts[SHRT_COPY].key);
+ editPasteAction->setShortcut(shortcuts[SHRT_PASTE].key);
+ editDelEventsAction->setShortcut(shortcuts[SHRT_DELETE].key);
+
+ selectAllAction->setShortcut(shortcuts[SHRT_SELECT_ALL].key);
+ selectNoneAction->setShortcut(shortcuts[SHRT_SELECT_NONE].key);
+ selectInvertAction->setShortcut(shortcuts[SHRT_SELECT_INVERT].key);
+ selectInsideLoopAction->setShortcut(shortcuts[SHRT_SELECT_ILOOP].key);
+ selectOutsideLoopAction->setShortcut(shortcuts[SHRT_SELECT_OLOOP].key);
+ selectPrevPartAction->setShortcut(shortcuts[SHRT_SELECT_PREV_PART].key);
+ selectNextPartAction->setShortcut(shortcuts[SHRT_SELECT_NEXT_PART].key);
+
+ eventColor->menuAction()->setShortcut(shortcuts[SHRT_EVENT_COLOR].key);
+ //evColorBlueAction->setShortcut(shortcuts[ ].key);
+ //evColorPitchAction->setShortcut(shortcuts[ ].key);
+ //evColorVelAction->setShortcut(shortcuts[ ].key);
+
+ funcOverQuantAction->setShortcut(shortcuts[SHRT_OVER_QUANTIZE].key);
+ funcNoteOnQuantAction->setShortcut(shortcuts[SHRT_ON_QUANTIZE].key);
+ funcNoteOnOffQuantAction->setShortcut(shortcuts[SHRT_ONOFF_QUANTIZE].key);
+ funcIterQuantAction->setShortcut(shortcuts[SHRT_ITERATIVE_QUANTIZE].key);
+
+ funcConfigQuantAction->setShortcut(shortcuts[SHRT_CONFIG_QUANT].key);
+
+ funcGateTimeAction->setShortcut(shortcuts[SHRT_MODIFY_GATE_TIME].key);
+ funcModVelAction->setShortcut(shortcuts[SHRT_MODIFY_VELOCITY].key);
+ funcCrescendoAction->setShortcut(shortcuts[SHRT_CRESCENDO].key);
+ funcTransposeAction->setShortcut(shortcuts[SHRT_TRANSPOSE].key);
+ funcThinOutAction->setShortcut(shortcuts[SHRT_THIN_OUT].key);
+ funcEraseEventAction->setShortcut(shortcuts[SHRT_ERASE_EVENT].key);
+ funcNoteShiftAction->setShortcut(shortcuts[SHRT_NOTE_SHIFT].key);
+ funcMoveClockAction->setShortcut(shortcuts[SHRT_MOVE_CLOCK].key);
+ funcCopyMeasureAction->setShortcut(shortcuts[SHRT_COPY_MEASURE].key);
+ funcEraseMeasureAction->setShortcut(shortcuts[SHRT_ERASE_MEASURE].key);
+ funcDelMeasureAction->setShortcut(shortcuts[SHRT_DELETE_MEASURE].key);
+ funcCreateMeasureAction->setShortcut(shortcuts[SHRT_CREATE_MEASURE].key);
+ funcSetFixedLenAction->setShortcut(shortcuts[SHRT_FIXED_LEN].key);
+ funcDelOverlapsAction->setShortcut(shortcuts[SHRT_DELETE_OVERLAPS].key);
+
+ }
+
+//---------------------------------------------------------
+// execDeliveredScript
+//---------------------------------------------------------
+void PianoRoll::execDeliveredScript(int id)
+{
+ //QString scriptfile = QString(INSTPREFIX) + SCRIPTSSUFFIX + deliveredScriptNames[id];
+ QString scriptfile = song->getScriptPath(id, true);
+ song->executeScript(scriptfile.toAscii().data(), parts(), quant(), true);
+}
+
+//---------------------------------------------------------
+// execUserScript
+//---------------------------------------------------------
+void PianoRoll::execUserScript(int id)
+{
+ QString scriptfile = song->getScriptPath(id, false);
+ song->executeScript(scriptfile.toAscii().data(), parts(), quant(), true);
+}
+
+//---------------------------------------------------------
+// newCanvasWidth
+//---------------------------------------------------------
+
+void PianoRoll::newCanvasWidth(int /*w*/)
+ {
+/*
+ int nw = w + (vscroll->width() - 18); // 18 is the fixed width of the CtlEdit VScale widget.
+ if(nw < 1)
+ nw = 1;
+
+ for (std::list<CtrlEdit*>::iterator i = ctrlEditList.begin();
+ i != ctrlEditList.end(); ++i) {
+ // Changed by Tim. p3.3.7
+ //(*i)->setCanvasWidth(w);
+ (*i)->setCanvasWidth(nw);
+ }
+
+ updateHScrollRange();
+*/
+ }
+
+//---------------------------------------------------------
+// toggleTrackInfo
+//---------------------------------------------------------
+
+void PianoRoll::toggleTrackInfo()
+{
+ bool vis = midiTrackInfo->isVisible();
+ infoScroll->setVisible(!vis);
+ infoScroll->setEnabled(!vis);
+}
diff --git a/attic/muse2-oom/muse2/muse/midiedit/pianoroll.h b/attic/muse2-oom/muse2/muse/midiedit/pianoroll.h
new file mode 100644
index 00000000..f7469ec6
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/pianoroll.h
@@ -0,0 +1,204 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: pianoroll.h,v 1.5.2.4 2009/11/16 11:29:33 lunar_shuttle Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __PIANOROLL_H__
+#define __PIANOROLL_H__
+
+#include <QCloseEvent>
+#include <QResizeEvent>
+#include <QLabel>
+#include <QKeyEvent>
+
+#include <values.h>
+#include "noteinfo.h"
+#include "cobject.h"
+#include "midieditor.h"
+#include "tools.h"
+#include "event.h"
+
+class MidiPart;
+class TimeLabel;
+class PitchLabel;
+class QLabel;
+class PianoCanvas;
+class MTScale;
+class PCScale;
+class Track;
+class QToolButton;
+class QToolBar;
+class QPushButton;
+class CtrlEdit;
+class Splitter;
+class PartList;
+class Toolbar1;
+class Xml;
+class QuantConfig;
+class ScrollScale;
+class Part;
+class SNode;
+class QMenu;
+class QAction;
+class QWidget;
+class QScrollBar;
+class MidiTrackInfo;
+class QScrollArea;
+
+//---------------------------------------------------------
+// PianoRoll
+//---------------------------------------------------------
+
+class PianoRoll : public MidiEditor {
+ Event selEvent;
+ MidiPart* selPart;
+ int selTick;
+
+ //enum { CMD_EVENT_COLOR, CMD_CONFIG_QUANT, CMD_LAST };
+ //int menu_ids[CMD_LAST];
+ //Q3PopupMenu *menuEdit, *menuFunctions, *menuSelect, *menuConfig, *menuPlugins;
+
+
+ QMenu *menuEdit, *menuFunctions, *menuSelect, *menuConfig, *eventColor, *menuPlugins;
+ MidiTrackInfo *midiTrackInfo;
+ Track* selected;
+ PCScale* pcbar;
+
+ QAction* editCutAction;
+ QAction* editCopyAction;
+ QAction* editPasteAction;
+ QAction* editDelEventsAction;
+
+ QAction* selectAllAction;
+ QAction* selectNoneAction;
+ QAction* selectInvertAction;
+ QAction* selectInsideLoopAction;
+ QAction* selectOutsideLoopAction;
+ QAction* selectPrevPartAction;
+ QAction* selectNextPartAction;
+
+ QAction* evColorBlueAction;
+ QAction* evColorPitchAction;
+ QAction* evColorVelAction;
+
+ QAction* funcOverQuantAction;
+ QAction* funcNoteOnQuantAction;
+ QAction* funcNoteOnOffQuantAction;
+ QAction* funcIterQuantAction;
+ QAction* funcConfigQuantAction;
+ QAction* funcGateTimeAction;
+ QAction* funcModVelAction;
+ QAction* funcCrescendoAction;
+ QAction* funcTransposeAction;
+ QAction* funcThinOutAction;
+ QAction* funcEraseEventAction;
+ QAction* funcNoteShiftAction;
+ QAction* funcMoveClockAction;
+ QAction* funcCopyMeasureAction;
+ QAction* funcEraseMeasureAction;
+ QAction* funcDelMeasureAction;
+ QAction* funcCreateMeasureAction;
+ QAction* funcSetFixedLenAction;
+ QAction* funcDelOverlapsAction;
+
+
+ int tickOffset;
+ int lenOffset;
+ int pitchOffset;
+ int veloOnOffset;
+ int veloOffOffset;
+ bool deltaMode;
+
+ NoteInfo* info;
+ QToolButton* srec;
+ QToolButton* midiin;
+
+ Toolbar1* toolbar;
+ Splitter* splitter;
+ Splitter* hsplitter;
+ Splitter* ctrlLane;
+
+ QToolButton* speaker;
+ QToolBar* tools;
+ EditToolBar* tools2;
+
+ int colorMode;
+
+ static int _quantInit, _rasterInit;
+ static int _widthInit, _heightInit;
+
+ static int _quantStrengthInit;
+ static int _quantLimitInit;
+ static bool _quantLenInit;
+ static int _toInit;
+ static int colorModeInit;
+
+ int _quantStrength;
+ int _quantLimit;
+ int _to;
+ bool _quantLen;
+ QuantConfig* quantConfig;
+ bool _playEvents;
+
+ //QScrollBar* infoScroll;
+ QScrollArea* infoScroll;
+
+ Q_OBJECT
+ void initShortcuts();
+ void setEventColorMode(int);
+ QWidget* genToolbar(QWidget* parent);
+ virtual void closeEvent(QCloseEvent*);
+ virtual void keyPressEvent(QKeyEvent*);
+ virtual void resizeEvent(QResizeEvent*);
+ virtual void showEvent(QShowEvent *);
+
+ private slots:
+ void setSelection(int, Event&, Part*);
+ void noteinfoChanged(NoteInfo::ValType, int);
+ //CtrlEdit* addCtrl();
+ void removeCtrl(CtrlEdit* ctrl);
+ void soloChanged(bool flag);
+ //void trackInfoScroll(int);
+ void setRaster(int);
+ void setQuant(int);
+ void configQuant();
+ void setQuantStrength(int val) { _quantStrength = val; }
+ void setQuantLimit(int val) { _quantLimit = val; }
+ void setQuantLen(bool val) { _quantLen = val; }
+ void cmd(int);
+ void setSteprec(bool);
+ void setTo(int val) { _to = val; }
+ void eventColorModeChanged(int);
+ void clipboardChanged(); // enable/disable "Paste"
+ void selectionChanged(); // enable/disable "Copy" & "Paste"
+ void setSpeaker(bool);
+ void setTime(unsigned);
+ void follow(int pos);
+ void songChanged1(int);
+ void configChanged();
+ void newCanvasWidth(int);
+ void toggleTrackInfo();
+ void updateTrackInfo();
+
+ signals:
+ void deleted(unsigned long);
+
+ public slots:
+ virtual void updateHScrollRange();
+ void execDeliveredScript(int id);
+ void execUserScript(int id);
+ CtrlEdit* addCtrl();
+
+ public:
+ PianoRoll(PartList*, QWidget* parent = 0, const char* name = 0, unsigned initPos = MAXINT);
+ ~PianoRoll();
+ virtual void readStatus(Xml&);
+ virtual void writeStatus(int, Xml&) const;
+ static void readConfiguration(Xml&);
+ static void writeConfiguration(int, Xml&);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/midiedit/prcanvas.cpp b/attic/muse2-oom/muse2/muse/midiedit/prcanvas.cpp
new file mode 100644
index 00000000..28d0d049
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/prcanvas.cpp
@@ -0,0 +1,1864 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: prcanvas.cpp,v 1.20.2.19 2009/11/16 11:29:33 lunar_shuttle Exp $
+// (C) Copyright 1999-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QApplication>
+#include <QClipboard>
+#include <QPainter>
+#include <QDrag>
+#include <QDragLeaveEvent>
+#include <QDragEnterEvent>
+#include <QDragMoveEvent>
+#include <QDropEvent>
+#include <QMouseEvent>
+
+#include <values.h>
+#include <stdio.h>
+#include <math.h>
+#include <errno.h>
+//#include <sys/stat.h>
+//#include <sys/types.h>
+//#include <sys/mman.h>
+//#include <fcntl.h>
+//#include <dirent.h>
+
+#include "xml.h"
+#include "prcanvas.h"
+#include "midiport.h"
+#include "event.h"
+#include "mpevent.h"
+#include "globals.h"
+#include "cmd.h"
+#include "gatetime.h"
+#include "velocity.h"
+#include "song.h"
+#include "audio.h"
+
+//---------------------------------------------------------
+// NEvent
+//---------------------------------------------------------
+
+NEvent::NEvent(Event& e, Part* p, int y) : CItem(e, p)
+ {
+ y = y - KH/4;
+ unsigned tick = e.tick() + p->tick();
+ setPos(QPoint(tick, y));
+ setBBox(QRect(tick, y, e.lenTick(), KH/2));
+ }
+
+//---------------------------------------------------------
+// addItem
+//---------------------------------------------------------
+
+void PianoCanvas::addItem(Part* part, Event& event)
+ {
+ if (signed(event.tick())<0) {
+ printf("ERROR: trying to add event before current part!\n");
+ return;
+ }
+
+ NEvent* ev = new NEvent(event, part, pitch2y(event.pitch()));
+ items.add(ev);
+
+ int diff = event.endTick()-part->lenTick();
+ if (diff > 0) {// too short part? extend it
+ //printf("addItem - this code should not be run!\n");
+ //Part* newPart = part->clone();
+ //newPart->setLenTick(newPart->lenTick()+diff);
+ //audio->msgChangePart(part, newPart,false);
+ //part = newPart;
+ part->setLenTick(part->lenTick()+diff);
+ }
+ }
+
+//---------------------------------------------------------
+// PianoCanvas
+//---------------------------------------------------------
+
+PianoCanvas::PianoCanvas(MidiEditor* pr, QWidget* parent, int sx, int sy)
+ : EventCanvas(pr, parent, sx, sy)
+ {
+ colorMode = 0;
+ cmdRange = 0; // all Events
+ playedPitch = -1;
+
+ songChanged(SC_TRACK_INSERTED);
+ connect(song, SIGNAL(midiNote(int, int)), SLOT(midiNote(int,int)));
+ }
+
+//---------------------------------------------------------
+// pitch2y
+//---------------------------------------------------------
+
+int PianoCanvas::pitch2y(int pitch) const
+ {
+ int tt[] = {
+ 5, 12, 19, 26, 33, 44, 51, 58, 64, 71, 78, 85
+ };
+ int y = (75 * KH) - (tt[pitch%12] + (7 * KH) * (pitch/12));
+ if (y < 0)
+ y = 0;
+ return y;
+ }
+
+//---------------------------------------------------------
+// y2pitch
+//---------------------------------------------------------
+
+int PianoCanvas::y2pitch(int y) const
+ {
+ const int total = (10 * 7 + 5) * KH; // 75 Ganztonschritte
+ y = total - y;
+ int oct = (y / (7 * KH)) * 12;
+ char kt[] = {
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, // 5
+ 1, 1, 1, 1, 1, 1, 1, // 13
+ 2, 2, 2, 2, 2, 2, // 19
+ 3, 3, 3, 3, 3, 3, 3, // 26
+ 4, 4, 4, 4, 4, 4, 4, 4, 4, // 34
+ 5, 5, 5, 5, 5, 5, 5, 5, 5, 5, // 43
+ 6, 6, 6, 6, 6, 6, 6, // 52
+ 7, 7, 7, 7, 7, 7, // 58
+ 8, 8, 8, 8, 8, 8, 8, // 65
+ 9, 9, 9, 9, 9, 9, // 71
+ 10, 10, 10, 10, 10, 10, 10, // 78
+ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11 // 87
+ };
+ return kt[y % 91] + oct;
+ }
+
+//---------------------------------------------------------
+// drawEvent
+// draws a note
+//---------------------------------------------------------
+
+void PianoCanvas::drawItem(QPainter& p, const CItem* item,
+ const QRect& rect)
+{
+ QRect r = item->bbox();
+ if(!virt())
+ r.moveCenter(map(item->pos()));
+ r = r.intersected(rect);
+ if(!r.isValid())
+ return;
+ p.setPen(Qt::black);
+ struct Triple
+ {
+ int r, g, b;
+ };
+
+ static Triple myColors /*Qt::color1*/[12] =
+ { // ddskrjp
+ { 0xff, 0x3d, 0x39 },
+ { 0x39, 0xff, 0x39 },
+ { 0x39, 0x3d, 0xff },
+ { 0xff, 0xff, 0x39 },
+ { 0xff, 0x3d, 0xff },
+ { 0x39, 0xff, 0xff },
+ { 0xff, 0x7e, 0x7a },
+ { 0x7a, 0x7e, 0xff },
+ { 0x7a, 0xff, 0x7a },
+ { 0xff, 0x7e, 0xbf },
+ { 0x7a, 0xbf, 0xff },
+ { 0xff, 0xbf, 0x7a }
+ };
+
+ QPen mainPen(Qt::black, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
+ p.setPen(mainPen);
+
+ QColor colMoving;
+ colMoving.setRgb(220, 220, 120, 127);
+
+ QPen movingPen(Qt::darkGray, 1, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
+
+ QColor colSelected;
+ colSelected.setRgb(243, 206, 105, 127);
+
+ NEvent* nevent = (NEvent*) item;
+ Event event = nevent->event();
+ if (nevent->part() != curPart)
+ {
+ if(item->isMoving())
+ {
+ p.setPen(movingPen);
+ p.setBrush(colMoving);
+ }
+ else if(item->isSelected())
+ {
+ p.setPen(mainPen);
+ p.setBrush(colSelected);
+ }
+ else
+ {
+ p.setPen(movingPen);
+ p.setBrush(QColor(192,192,192,127));
+ }
+ }
+ else {
+ if (item->isMoving())
+ {
+ p.setPen(movingPen);
+ p.setBrush(colMoving);
+ //p.setBrush(Qt::gray);
+ }
+ else if (item->isSelected())
+ {
+ p.setPen(mainPen);
+ p.setBrush(colSelected);
+ }
+ else
+ {
+ QColor color;
+ //color.setRgb(80, 102, 143);
+ color.setRgb(13,124,151,127);
+ switch(colorMode)
+ {
+ case 0:
+ break;
+ case 1: // pitch
+ {
+ Triple* c = &myColors/*Qt::color1*/[event.pitch() % 12];
+ color.setRgb(c->r, c->g, c->b, 127);
+ }
+ break;
+ case 2: // velocity
+ {
+ int velo = event.velo();
+ /*
+ if (velo < 64)
+ color.setRgb(velo*4, 0, 0xff);
+ else
+ color.setRgb(0xff, 0, (127-velo) * 4);
+ */
+ /*
+ if(velo <= 11)
+ color.setRgb(75,145,47);
+ else if(velo <= 22)
+ color.setRgb(56,145,79);
+ else if(velo <= 33)
+ color.setRgb(64,139,84);
+ else if(velo <= 44)
+ color.setRgb(60,137,99);
+ else if(velo <= 55)
+ color.setRgb(55,134,113);
+ else if(velo <= 66)
+ color.setRgb(51,132,127);
+ else if(velo <= 77)
+ color.setRgb(48,130,141);
+ else if(velo <= 88)
+ color.setRgb(57,121,144);
+ else if(velo <= 99)
+ color.setRgb(72,108,143);
+ else if(velo <= 110)
+ color.setRgb(86,96,142);
+ else if(velo <= 121)
+ color.setRgb(101,84,141);
+ else
+ color.setRgb(116,72,140);
+ */
+
+ if(velo <= 11)
+ color.setRgb(147,186,195,127);
+ else if(velo <= 22)
+ color.setRgb(119,169,181,127);
+ else if(velo <= 33)
+ color.setRgb(85,157,175,127);
+ else if(velo <= 44)
+ color.setRgb(58,152,176,127);
+ else if(velo <= 55)
+ color.setRgb(33,137,163,127);
+ else if(velo <= 66)
+ color.setRgb(30,136,162,127);
+ else if(velo <= 77)
+ color.setRgb(13,124,151,127);
+ else if(velo <= 88)
+ color.setRgb(0,110,138,127);
+ else if(velo <= 99)
+ color.setRgb(0,99,124,127);
+ else if(velo <= 110)
+ color.setRgb(0,77,96,127);
+ else if(velo <= 121)
+ color.setRgb(0,69,86,127);
+ else
+ color.setRgb(0,58,72,127);
+
+ }
+ break;
+ }
+ p.setBrush(color);
+ }
+ }
+ p.drawRect(r);
+}
+
+
+//---------------------------------------------------------
+// drawMoving
+// draws moving items
+//---------------------------------------------------------
+
+void PianoCanvas::drawMoving(QPainter& p, const CItem* item, const QRect& rect)
+ {
+ //if(((NEvent*)item)->part() != curPart)
+ // return;
+ //if(!item->isMoving())
+ // return;
+ QRect mr = QRect(item->mp().x(), item->mp().y() - item->height()/2, item->width(), item->height());
+ mr = mr.intersected(rect);
+ if(!mr.isValid())
+ return;
+ p.setPen(Qt::black);
+ p.setBrush(Qt::NoBrush);
+ p.drawRect(mr);
+ }
+
+//---------------------------------------------------------
+// viewMouseDoubleClickEvent
+//---------------------------------------------------------
+
+void PianoCanvas::viewMouseDoubleClickEvent(QMouseEvent* event)
+ {
+ if ((_tool != PointerTool) && (event->button() != Qt::LeftButton)) {
+ mousePress(event);
+ return;
+ }
+ }
+
+//---------------------------------------------------------
+// moveCanvasItems
+//---------------------------------------------------------
+
+void PianoCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtype, int* pflags)
+{
+ if(editor->parts()->empty())
+ return;
+
+ PartsToChangeMap parts2change;
+
+ int modified = 0;
+ for(iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip)
+ {
+ Part* part = ip->second;
+ if(!part)
+ continue;
+
+ int npartoffset = 0;
+ for(iCItem ici = items.begin(); ici != items.end(); ++ici)
+ {
+ CItem* ci = ici->second;
+ if(ci->part() != part)
+ continue;
+
+ int x = ci->pos().x() + dx;
+ int y = pitch2y(y2pitch(ci->pos().y()) + dp);
+ QPoint newpos = raster(QPoint(x, y));
+
+ // Test moving the item...
+ NEvent* nevent = (NEvent*) ci;
+ Event event = nevent->event();
+ x = newpos.x();
+ if(x < 0)
+ x = 0;
+ int ntick = editor->rasterVal(x) - part->tick();
+ if(ntick < 0)
+ ntick = 0;
+ int diff = ntick + event.lenTick() - part->lenTick();
+
+ // If moving the item would require a new part size...
+ if(diff > npartoffset)
+ npartoffset = diff;
+ }
+
+ if(npartoffset > 0)
+ {
+ // Create new part...
+ // if there are several events that are moved outside the part, it will be recreated for each
+ // so the part _in_ the event will not be valid, ask the authority.
+// Part* newPart = part->clone();
+ //Part* newPart = Canvas::part()->clone();
+
+// newPart->setLenTick(newPart->lenTick() + npartoffset);
+ //audio->msgChangePart(part, newPart,false);
+
+// modified = SC_PART_MODIFIED;
+
+ // BUG FIX: #1650953
+ // Added by T356.
+ // Fixes posted "select and drag past end of part - crashing" bug
+// for(iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip)
+// {
+// if(ip->second == part)
+// {
+// editor->parts()->erase(ip);
+// break;
+// }
+// }
+
+// editor->parts()->add(newPart);
+// audio->msgChangePart(part, newPart,false);
+
+ //if(parts2change.find(part) == parts2change.end())
+ // parts2change.insert(std::pair<Part*, Part*> (part, newPart));
+ iPartToChange ip2c = parts2change.find(part);
+ if(ip2c == parts2change.end())
+ {
+ PartToChange p2c = {0, npartoffset};
+ parts2change.insert(std::pair<Part*, PartToChange> (part, p2c));
+ }
+ else
+ ip2c->second.xdiff = npartoffset;
+
+ //part = newPart; // reassign
+ //item->setPart(part);
+ //item->setEvent(newEvent);
+ //curPart = part;
+ //curPartId = curPart->sn();
+
+ }
+ }
+
+ for(iPartToChange ip2c = parts2change.begin(); ip2c != parts2change.end(); ++ip2c)
+ {
+ Part* opart = ip2c->first;
+ int diff = ip2c->second.xdiff;
+
+ Part* newPart = opart->clone();
+
+ newPart->setLenTick(newPart->lenTick() + diff);
+
+ modified = SC_PART_MODIFIED;
+
+ // BUG FIX: #1650953
+ // Added by T356.
+ // Fixes posted "select and drag past end of part - crashing" bug
+ for(iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip)
+ {
+ if(ip->second == opart)
+ {
+ editor->parts()->erase(ip);
+ break;
+ }
+ }
+
+ editor->parts()->add(newPart);
+ // Indicate no undo, and do port controller values but not clone parts.
+ audio->msgChangePart(opart, newPart, false, true, false);
+
+ ip2c->second.npart = newPart;
+
+ }
+
+ iPartToChange icp = parts2change.find(curPart);
+ if(icp != parts2change.end())
+ {
+ curPart = icp->second.npart;
+ curPartId = curPart->sn();
+ }
+
+ std::vector< CItem* > doneList;
+ typedef std::vector< CItem* >::iterator iDoneList;
+
+ for(iCItem ici = items.begin(); ici != items.end(); ++ici)
+ {
+ CItem* ci = ici->second;
+
+ // If this item's part is in the parts2change list, change the item's part to the new part.
+ Part* pt = ci->part();
+ iPartToChange ip2c = parts2change.find(pt);
+ if(ip2c != parts2change.end())
+ ci->setPart(ip2c->second.npart);
+
+ int x = ci->pos().x();
+ int y = ci->pos().y();
+ int nx = x + dx;
+ int ny = pitch2y(y2pitch(y) + dp);
+ QPoint newpos = raster(QPoint(nx, ny));
+ selectItem(ci, true);
+
+ iDoneList idl;
+ for(idl = doneList.begin(); idl != doneList.end(); ++idl)
+ // This compares EventBase pointers to see if they're the same...
+ if((*idl)->event() == ci->event())
+ break;
+
+ // Do not process if the event has already been processed (meaning it's an event in a clone part)...
+ //if(moveItem(ci, newpos, dtype))
+ if(idl != doneList.end())
+ // Just move the canvas item.
+ ci->move(newpos);
+ else
+ {
+ // Currently moveItem always returns true.
+ if(moveItem(ci, newpos, dtype))
+ {
+ // Add the canvas item to the list of done items.
+ doneList.push_back(ci);
+ // Move the canvas item.
+ ci->move(newpos);
+ }
+ }
+
+ if(moving.size() == 1)
+ itemReleased(curItem, newpos);
+ if(dtype == MOVE_COPY || dtype == MOVE_CLONE)
+ selectItem(ci, false);
+ }
+
+ if(pflags)
+ *pflags = modified;
+}
+
+//---------------------------------------------------------
+// moveItem
+// called after moving an object
+//---------------------------------------------------------
+
+// Changed by T356.
+//bool PianoCanvas::moveItem(CItem* item, const QPoint& pos, DragType dtype, int* pflags)
+bool PianoCanvas::moveItem(CItem* item, const QPoint& pos, DragType dtype)
+ {
+ NEvent* nevent = (NEvent*) item;
+ Event event = nevent->event();
+ int npitch = y2pitch(pos.y());
+ Event newEvent = event.clone();
+ int x = pos.x();
+ if (x < 0)
+ x = 0;
+ if (event.pitch() != npitch && _playEvents) {
+ int port = track()->outPort();
+ int channel = track()->outChannel();
+ // release note:
+ MidiPlayEvent ev1(0, port, channel, 0x90, event.pitch() + track()->transposition, 0);
+ audio->msgPlayMidiEvent(&ev1);
+ MidiPlayEvent ev2(0, port, channel, 0x90, npitch + track()->transposition, event.velo());
+ audio->msgPlayMidiEvent(&ev2);
+ }
+
+ // Changed by T356.
+ Part* part = nevent->part(); //
+ //Part * part = Canvas::part(); // part can be dynamically recreated, ask the authority
+
+ newEvent.setPitch(npitch);
+ int ntick = editor->rasterVal(x) - part->tick();
+ if (ntick < 0)
+ ntick = 0;
+ newEvent.setTick(ntick);
+ newEvent.setLenTick(event.lenTick());
+
+ // Removed by T356.
+ /*
+ int modified=0;
+ //song->startUndo();
+ int diff = newEvent.endTick()-part->lenTick();
+ if (diff > 0){// too short part? extend it
+ // if there are several events that are moved outside the part, it will be recreated for each
+ // so the part _in_ the event will not be valid, ask the authority.
+ //Part* newPart = part->clone();
+ Part* newPart = Canvas::part()->clone();
+
+ newPart->setLenTick(newPart->lenTick()+diff);
+ audio->msgChangePart(Canvas::part(), newPart,false);
+
+ modified = SC_PART_MODIFIED;
+ part = newPart; // reassign
+
+ // BUG FIX: #1650953
+ // Added by T356.
+ // Fixes posted "select and drag past end of part - crashing" bug
+ for(iPart i = editor->parts()->begin(); i != editor->parts()->end(); ++i)
+ {
+ if(i->second == Canvas::part())
+ {
+ editor->parts()->erase(i);
+ break;
+ }
+ }
+ editor->parts()->add(part);
+ item->setPart(part);
+ item->setEvent(newEvent);
+ curPart = part;
+ curPartId = curPart->sn();
+
+ }
+ */
+
+ // Added by T356.
+ // msgAddEvent and msgChangeEvent (below) will set these, but set them here first?
+ //item->setPart(part);
+ item->setEvent(newEvent);
+
+ // Added by T356.
+ if(((int)newEvent.endTick() - (int)part->lenTick()) > 0)
+ printf("PianoCanvas::moveItem Error! New event end:%d exceeds length:%d of part:%s\n", newEvent.endTick(), part->lenTick(), part->name().toLatin1().constData());
+
+ if (dtype == MOVE_COPY || dtype == MOVE_CLONE)
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgAddEvent(newEvent, part, false);
+ audio->msgAddEvent(newEvent, part, false, false, false);
+ else
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(event, newEvent, part, false);
+ audio->msgChangeEvent(event, newEvent, part, false, false, false);
+ //song->endUndo(modified);
+
+ // Removed by T356.
+ //if(pflags)
+ // *pflags = modified;
+
+ return true;
+ }
+
+//---------------------------------------------------------
+// newItem(p, state)
+//---------------------------------------------------------
+
+CItem* PianoCanvas::newItem(const QPoint& p, int)
+ {
+ //printf("newItem point\n");
+ int pitch = y2pitch(p.y());
+ int tick = editor->rasterVal1(p.x());
+ int len = p.x() - tick;
+ tick -= curPart->tick();
+ if (tick < 0)
+ tick=0;
+ Event e = Event(Note);
+ e.setTick(tick);
+ e.setPitch(pitch);
+ e.setVelo(curVelo);
+ e.setLenTick(len);
+ return new NEvent(e, curPart, pitch2y(pitch));
+ }
+
+void PianoCanvas::newItem(CItem* item, bool noSnap)
+ {
+ //printf("newItem citem\n");
+ NEvent* nevent = (NEvent*) item;
+ Event event = nevent->event();
+ int x = item->x();
+ if (x<0)
+ x=0;
+ int w = item->width();
+
+ if (!noSnap) {
+ x = editor->rasterVal1(x); //round down
+ w = editor->rasterVal(x + w) - x;
+ if (w == 0)
+ w = editor->raster();
+ }
+ Part* part = nevent->part();
+ event.setTick(x - part->tick());
+ event.setLenTick(w);
+ event.setPitch(y2pitch(item->y()));
+
+ song->startUndo();
+ int modified=SC_EVENT_MODIFIED;
+ int diff = event.endTick()-part->lenTick();
+ if (diff > 0) {// too short part? extend it
+ //printf("extend Part!\n");
+ Part* newPart = part->clone();
+ newPart->setLenTick(newPart->lenTick()+diff);
+ // Indicate no undo, and do port controller values but not clone parts.
+ //audio->msgChangePart(part, newPart,false);
+ audio->msgChangePart(part, newPart, false, true, false);
+ modified=modified|SC_PART_MODIFIED;
+ part = newPart; // reassign
+ }
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgAddEvent(event, part,false);
+ audio->msgAddEvent(event, part, false, false, false);
+ song->endUndo(modified);
+ }
+
+//---------------------------------------------------------
+// resizeItem
+//---------------------------------------------------------
+
+void PianoCanvas::resizeItem(CItem* item, bool noSnap) // experimental changes to try dynamically extending parts
+ {
+ //printf("resizeItem!\n");
+ NEvent* nevent = (NEvent*) item;
+ Event event = nevent->event();
+ Event newEvent = event.clone();
+ int len;
+
+ Part* part = nevent->part();
+
+ if (noSnap)
+ len = nevent->width();
+ else {
+ //Part* part = nevent->part();
+ unsigned tick = event.tick() + part->tick();
+ len = editor->rasterVal(tick + nevent->width()) - tick;
+ if (len <= 0)
+ len = editor->raster();
+ }
+ song->startUndo();
+ int modified=SC_EVENT_MODIFIED;
+ //printf("event.tick()=%d len=%d part->lenTick()=%d\n",event.endTick(),len,part->lenTick());
+ int diff = event.tick()+len-part->lenTick();
+ if (diff > 0) {// too short part? extend it
+ //printf("extend Part!\n");
+ Part* newPart = part->clone();
+ newPart->setLenTick(newPart->lenTick()+diff);
+ // Indicate no undo, and do port controller values but not clone parts.
+ //audio->msgChangePart(part, newPart,false);
+ audio->msgChangePart(part, newPart, false, true, false);
+ modified=modified|SC_PART_MODIFIED;
+ part = newPart; // reassign
+ }
+
+ newEvent.setLenTick(len);
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(event, newEvent, nevent->part(),false);
+ audio->msgChangeEvent(event, newEvent, nevent->part(), false, false, false);
+ song->endUndo(modified);
+ }
+
+//---------------------------------------------------------
+// deleteItem
+//---------------------------------------------------------
+
+bool PianoCanvas::deleteItem(CItem* item)
+ {
+ NEvent* nevent = (NEvent*) item;
+ if (nevent->part() == curPart) {
+ Event ev = nevent->event();
+ // Indicate do undo, and do not do port controller values and clone parts.
+ //audio->msgDeleteEvent(ev, curPart);
+ audio->msgDeleteEvent(ev, curPart, true, false, false);
+ return true;
+ }
+ return false;
+ }
+
+//---------------------------------------------------------
+// pianoCmd
+//---------------------------------------------------------
+
+void PianoCanvas::pianoCmd(int cmd)
+ {
+ switch(cmd) {
+ case CMD_LEFT:
+ {
+ int spos = pos[0];
+ if(spos > 0)
+ {
+ spos -= 1; // Nudge by -1, then snap down with raster1.
+ spos = AL::sigmap.raster1(spos, editor->rasterStep(pos[0]));
+ }
+ if(spos < 0)
+ spos = 0;
+ Pos p(spos,true);
+ song->setPos(0, p, true, true, true);
+ }
+ break;
+ case CMD_RIGHT:
+ {
+ int spos = AL::sigmap.raster2(pos[0] + 1, editor->rasterStep(pos[0])); // Nudge by +1, then snap up with raster2.
+ Pos p(spos,true);
+ song->setPos(0, p, true, true, true);
+ }
+ break;
+ case CMD_LEFT_NOSNAP:
+ {
+ int spos = pos[0] - editor->rasterStep(pos[0]);
+ if (spos < 0)
+ spos = 0;
+ Pos p(spos,true);
+ song->setPos(0, p, true, true, true); //CDW
+ }
+ break;
+ case CMD_RIGHT_NOSNAP:
+ {
+ Pos p(pos[0] + editor->rasterStep(pos[0]), true);
+ //if (p > part->tick())
+ // p = part->tick();
+ song->setPos(0, p, true, true, true); //CDW
+ }
+ break;
+ case CMD_INSERT:
+ {
+ if (pos[0] < start() || pos[0] >= end())
+ break;
+ MidiPart* part = (MidiPart*)curPart;
+
+ if (part == 0)
+ break;
+ song->startUndo();
+ EventList* el = part->events();
+
+ std::list <Event> elist;
+ for (iEvent e = el->lower_bound(pos[0] - part->tick()); e != el->end(); ++e)
+ elist.push_back((Event)e->second);
+ for (std::list<Event>::iterator i = elist.begin(); i != elist.end(); ++i) {
+ Event event = *i;
+ Event newEvent = event.clone();
+ newEvent.setTick(event.tick() + editor->raster());// - part->tick());
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(event, newEvent, part, false);
+ audio->msgChangeEvent(event, newEvent, part, false, false, false);
+ }
+ song->endUndo(SC_EVENT_MODIFIED);
+ Pos p(editor->rasterVal(pos[0] + editor->rasterStep(pos[0])), true);
+ song->setPos(0, p, true, false, true);
+ }
+ return;
+ case CMD_DELETE:
+ if (pos[0] < start() || pos[0] >= end())
+ break;
+ {
+ MidiPart* part = (MidiPart*)curPart;
+ if (part == 0)
+ break;
+ song->startUndo();
+ EventList* el = part->events();
+
+ std::list<Event> elist;
+ for (iEvent e = el->lower_bound(pos[0]); e != el->end(); ++e)
+ elist.push_back((Event)e->second);
+ for (std::list<Event>::iterator i = elist.begin(); i != elist.end(); ++i) {
+ Event event = *i;
+ Event newEvent = event.clone();
+ newEvent.setTick(event.tick() - editor->raster() - part->tick());
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(event, newEvent, part, false);
+ audio->msgChangeEvent(event, newEvent, part, false, false, false);
+ }
+ song->endUndo(SC_EVENT_MODIFIED);
+ Pos p(editor->rasterVal(pos[0] - editor->rasterStep(pos[0])), true);
+ song->setPos(0, p, true, false, true);
+ }
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// pianoPressed
+//---------------------------------------------------------
+
+void PianoCanvas::pianoPressed(int pitch, int velocity, bool shift)
+ {
+ int port = track()->outPort();
+ int channel = track()->outChannel();
+ pitch += track()->transposition;
+
+ // play note:
+ //MidiPlayEvent e(0, port, channel, 0x90, pitch, 127);
+ MidiPlayEvent e(0, port, channel, 0x90, pitch, velocity);
+ audio->msgPlayMidiEvent(&e);
+
+ if (_steprec && pos[0] >= start_tick && pos[0] < end_tick) {
+ if (curPart == 0)
+ return;
+ int len = editor->raster();
+ unsigned tick = pos[0] - curPart->tick(); //CDW
+ if (shift)
+ tick -= editor->rasterStep(tick);
+ Event e(Note);
+ e.setTick(tick);
+ e.setPitch(pitch);
+ e.setVelo(127);
+ e.setLenTick(len);
+ // Indicate do undo, and do not do port controller values and clone parts.
+ //audio->msgAddEvent(e, curPart);
+ audio->msgAddEvent(e, curPart, true, false, false);
+ tick += editor->rasterStep(tick) + curPart->tick();
+ if (tick != song->cpos()) {
+ Pos p(tick, true);
+ song->setPos(0, p, true, false, true);
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// pianoReleased
+//---------------------------------------------------------
+
+void PianoCanvas::pianoReleased(int pitch, bool)
+ {
+ int port = track()->outPort();
+ int channel = track()->outChannel();
+ pitch += track()->transposition;
+
+ // release key:
+ MidiPlayEvent e(0, port, channel, 0x90, pitch, 0);
+ audio->msgPlayMidiEvent(&e);
+ }
+
+//---------------------------------------------------------
+// drawTickRaster
+//---------------------------------------------------------
+
+void drawTickRaster(QPainter& p, int x, int y, int w, int h, int raster)
+{
+
+ QColor colBeat;
+ colBeat.setRgb(210, 216, 219);
+ QColor colBar1;
+ colBar1.setRgb(82,85,87);
+ QColor colBar2;
+ colBar2.setRgb(150,160,167);
+
+
+ int bar1, bar2, beat;
+ unsigned tick;
+ AL::sigmap.tickValues(x, &bar1, &beat, &tick);
+ AL::sigmap.tickValues(x+w, &bar2, &beat, &tick);
+ ++bar2;
+ int y2 = y + h;
+ for (int bar = bar1; bar < bar2; ++bar) {
+ unsigned x = AL::sigmap.bar2tick(bar, 0, 0);
+ p.setPen(colBar1);
+ p.drawLine(x, y, x, y2);
+ int z, n;
+ AL::sigmap.timesig(x, z, n);
+ ///int q = p.xForm(QPoint(raster, 0)).x() - p.xForm(QPoint(0, 0)).x();
+ int q = p.combinedTransform().map(QPoint(raster, 0)).x() - p.combinedTransform().map(QPoint(0, 0)).x();
+ int qq = raster;
+ if (q < 8) // grid too dense
+ qq *= 2;
+ //switch (quant) {
+ // case 32:
+ // case 48:
+ // case 64:
+ // case 96:
+ // case 192: // 8tel
+ // case 128: // 8tel Triolen
+ // case 288:
+ p.setPen(colBeat);
+ if (raster>=4)
+ {
+ int xx = x + qq;
+ int xxx = AL::sigmap.bar2tick(bar, z, 0);
+ while (xx <= xxx) {
+ p.drawLine(xx, y, xx, y2);
+ xx += qq;
+ }
+ xx = xxx;
+ }
+ // break;
+ // default:
+ // break;
+ // }
+ p.setPen(colBar2);
+ for (int beat = 1; beat < z; beat++)
+ {
+ int xx = AL::sigmap.bar2tick(bar, beat, 0);
+ p.drawLine(xx, y, xx, y2);
+ }
+
+ }
+}
+
+//---------------------------------------------------------
+// draw
+//---------------------------------------------------------
+
+void PianoCanvas::drawCanvas(QPainter& p, const QRect& rect)
+ {
+ int x = rect.x();
+ int y = rect.y();
+ int w = rect.width();
+ int h = rect.height();
+
+ //---------------------------------------------------
+ // horizontal lines
+ //---------------------------------------------------
+
+ int yy = ((y-1) / KH) * KH + KH;
+ int key = 75 - (yy / KH);
+ for (; yy < y + h; yy += KH)
+ {
+ switch (key % 7)
+ {
+ case 0:
+ case 3:
+ p.setPen(QColor(213,220,213));
+ p.drawLine(x, yy, x + w, yy);
+ break;
+ default:
+ //p.setPen(lightGray);
+ //p.fillRect(x, yy-3, w, 6, QBrush(QColor(230,230,230)));
+ p.fillRect(x, yy-3, w, 6, QBrush(QColor(209,213,209)));
+ //p.drawLine(x, yy, x + w, yy);
+ break;
+ }
+ --key;
+ }
+
+ //---------------------------------------------------
+ // vertical lines
+ //---------------------------------------------------
+
+ drawTickRaster(p, x, y, w, h, editor->raster());
+}
+
+//---------------------------------------------------------
+// cmd
+// pulldown menu commands
+//---------------------------------------------------------
+
+void PianoCanvas::cmd(int cmd, int quantStrength,
+ int quantLimit, bool quantLen, int range)
+ {
+ cmdRange = range;
+ printf("PianoCanvas cmd called with command: %d\n\n", cmd);
+ switch (cmd) {
+ case CMD_CUT:
+ copy();
+ song->startUndo();
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ if (!(i->second->isSelected()))
+ continue;
+ NEvent* e = (NEvent*)(i->second);
+ Event ev = e->event();
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgDeleteEvent(ev, e->part(), false);
+ audio->msgDeleteEvent(ev, e->part(), false, false, false);
+ }
+ song->endUndo(SC_EVENT_REMOVED);
+ break;
+ case CMD_COPY:
+ copy();
+ break;
+ case CMD_PASTE:
+ paste();
+ break;
+ case CMD_DEL:
+ if (selectionSize()) {
+ song->startUndo();
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ if (!i->second->isSelected())
+ continue;
+ Event ev = i->second->event();
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgDeleteEvent(ev, i->second->part(), false);
+ audio->msgDeleteEvent(ev, i->second->part(), false, false, false);
+ }
+ song->endUndo(SC_EVENT_REMOVED);
+ }
+ return;
+ case CMD_OVER_QUANTIZE: // over quantize
+ quantize(100, 1, quantLen);
+ break;
+ case CMD_ON_QUANTIZE: // note on quantize
+ quantize(50, 1, false);
+ break;
+ case CMD_ONOFF_QUANTIZE: // note on/off quantize
+ quantize(50, 1, true);
+ break;
+ case CMD_ITERATIVE_QUANTIZE: // Iterative Quantize
+ quantize(quantStrength, quantLimit, quantLen);
+ break;
+ case CMD_SELECT_ALL: // select all
+ for (iCItem k = items.begin(); k != items.end(); ++k) {
+ if (!k->second->isSelected())
+ selectItem(k->second, true);
+ }
+ break;
+ case CMD_SELECT_NONE: // select none
+ deselectAll();
+ break;
+ case CMD_SELECT_INVERT: // invert selection
+ for (iCItem k = items.begin(); k != items.end(); ++k) {
+ selectItem(k->second, !k->second->isSelected());
+ }
+ break;
+ case CMD_SELECT_ILOOP: // select inside loop
+ for (iCItem k = items.begin(); k != items.end(); ++k) {
+ NEvent* nevent = (NEvent*)(k->second);
+ Part* part = nevent->part();
+ Event event = nevent->event();
+ unsigned tick = event.tick() + part->tick();
+ if (tick < song->lpos() || tick >= song->rpos())
+ selectItem(k->second, false);
+ else
+ selectItem(k->second, true);
+ }
+ break;
+ case CMD_SELECT_OLOOP: // select outside loop
+ for (iCItem k = items.begin(); k != items.end(); ++k) {
+ NEvent* nevent = (NEvent*)(k->second);
+ Part* part = nevent->part();
+ Event event = nevent->event();
+ unsigned tick = event.tick() + part->tick();
+ if (tick < song->lpos() || tick >= song->rpos())
+ selectItem(k->second, true);
+ else
+ selectItem(k->second, false);
+ }
+ break;
+ case CMD_SELECT_PREV_PART: // select previous part
+ {
+ Part* pt = editor->curCanvasPart();
+ Part* newpt = pt;
+ PartList* pl = editor->parts();
+ for(iPart ip = pl->begin(); ip != pl->end(); ++ip)
+ if(ip->second == pt)
+ {
+ if(ip == pl->begin())
+ ip = pl->end();
+ --ip;
+ newpt = ip->second;
+ break;
+ }
+ if(newpt != pt)
+ editor->setCurCanvasPart(newpt);
+ }
+ break;
+ case CMD_SELECT_NEXT_PART: // select next part
+ {
+ Part* pt = editor->curCanvasPart();
+ Part* newpt = pt;
+ PartList* pl = editor->parts();
+ for(iPart ip = pl->begin(); ip != pl->end(); ++ip)
+ if(ip->second == pt)
+ {
+ ++ip;
+ if(ip == pl->end())
+ ip = pl->begin();
+ newpt = ip->second;
+ break;
+ }
+ if(newpt != pt)
+ editor->setCurCanvasPart(newpt);
+ }
+ break;
+ case CMD_MODIFY_GATE_TIME:
+ {
+ GateTime w(this);
+ w.setRange(range);
+ if (!w.exec())
+ break;
+ int range = w.range(); // all, selected, looped, sel+loop
+ int rate = w.rateVal();
+ int offset = w.offsetVal();
+
+ song->startUndo();
+ for (iCItem k = items.begin(); k != items.end(); ++k) {
+ NEvent* nevent =(NEvent*)(k->second);
+ Event event = nevent->event();
+ if (event.type() != Note)
+ continue;
+ unsigned tick = event.tick();
+ bool selected = k->second->isSelected();
+ bool inLoop = (tick >= song->lpos()) && (tick < song->rpos());
+
+ if ((range == 0)
+ || (range == 1 && selected)
+ || (range == 2 && inLoop)
+ || (range == 3 && selected && inLoop)) {
+ unsigned int len = event.lenTick(); //prevent compiler warning: comparison singed/unsigned
+
+ len = rate ? (len * 100) / rate : 1;
+ len += offset;
+ if (len < 1)
+ len = 1;
+
+ if (event.lenTick() != len) {
+ Event newEvent = event.clone();
+ newEvent.setLenTick(len);
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(event, newEvent, nevent->part(), false);
+ audio->msgChangeEvent(event, newEvent, nevent->part(), false, false, false);
+ }
+ }
+ }
+ song->endUndo(SC_EVENT_MODIFIED);
+ }
+ break;
+
+ case CMD_MODIFY_VELOCITY:
+ {
+ Velocity w;
+ w.setRange(range);
+ if (!w.exec())
+ break;
+ int range = w.range(); // all, selected, looped, sel+loop
+ int rate = w.rateVal();
+ int offset = w.offsetVal();
+
+ song->startUndo();
+ for (iCItem k = items.begin(); k != items.end(); ++k) {
+ NEvent* nevent = (NEvent*)(k->second);
+ Event event = nevent->event();
+ if (event.type() != Note)
+ continue;
+ unsigned tick = event.tick();
+ bool selected = k->second->isSelected();
+ bool inLoop = (tick >= song->lpos()) && (tick < song->rpos());
+
+ if ((range == 0)
+ || (range == 1 && selected)
+ || (range == 2 && inLoop)
+ || (range == 3 && selected && inLoop)) {
+ int velo = event.velo();
+
+ //velo = rate ? (velo * 100) / rate : 64;
+ velo = (velo * rate) / 100;
+ velo += offset;
+
+ if (velo <= 0)
+ velo = 1;
+ if (velo > 127)
+ velo = 127;
+ if (event.velo() != velo) {
+ Event newEvent = event.clone();
+ newEvent.setVelo(velo);
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(event, newEvent, nevent->part(), false);
+ audio->msgChangeEvent(event, newEvent, nevent->part(), false, false, false);
+ }
+ }
+ }
+ song->endUndo(SC_EVENT_MODIFIED);
+ }
+ break;
+
+ case CMD_FIXED_LEN: //Set notes to the length specified in the drummap
+ if (!selectionSize())
+ break;
+ song->startUndo();
+ for (iCItem k = items.begin(); k != items.end(); ++k) {
+ if (k->second->isSelected()) {
+ NEvent* nevent = (NEvent*)(k->second);
+ Event event = nevent->event();
+ Event newEvent = event.clone();
+ newEvent.setLenTick(editor->raster());
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(event, newEvent, nevent->part() , false);
+ audio->msgChangeEvent(event, newEvent, nevent->part(), false, false, false);
+ }
+ }
+ song->endUndo(SC_EVENT_MODIFIED);
+ break;
+
+ case CMD_DELETE_OVERLAPS:
+ if (!selectionSize())
+ break;
+
+ song->startUndo();
+ for (iCItem k = items.begin(); k != items.end(); k++) {
+ if (k->second->isSelected() == false)
+ continue;
+
+ NEvent* e1 = (NEvent*) (k->second); // first note
+ NEvent* e2 = NULL; // ptr to next selected note (which will be checked for overlap)
+ Event ce1 = e1->event();
+ Event ce2;
+
+ if (ce1.type() != Note)
+ continue;
+
+ // Find next selected item on the same pitch
+ iCItem l = k; l++;
+ for (; l != items.end(); l++) {
+ if (l->second->isSelected() == false)
+ continue;
+
+ e2 = (NEvent*) l->second;
+ ce2 = e2->event();
+
+ // Same pitch?
+ if (ce1.dataA() == ce2.dataA())
+ break;
+
+ // If the note has the same len and place we treat it as a duplicate note and not a following note
+ // The best thing to do would probably be to delete the duplicate note, we just want to avoid
+ // matching against the same note
+ if ( ce1.tick() + e1->part()->tick() == ce2.tick() + e2->part()->tick()
+ && ce1.lenTick() + e1->part()->tick() == ce2.lenTick() + e2->part()->tick())
+ {
+ e2 = NULL; // this wasn't what we were looking for
+ continue;
+ }
+
+ }
+
+ if (e2 == NULL) // None found
+ break;
+
+ Part* part1 = e1->part();
+ Part* part2 = e2->part();
+ if (ce2.type() != Note)
+ continue;
+
+
+ unsigned event1pos = ce1.tick() + part1->tick();
+ unsigned event1end = event1pos + ce1.lenTick();
+ unsigned event2pos = ce2.tick() + part2->tick();
+
+ //printf("event1pos %u event1end %u event2pos %u\n", event1pos, event1end, event2pos);
+ if (event1end > event2pos) {
+ Event newEvent = ce1.clone();
+ unsigned newlen = ce1.lenTick() - (event1end - event2pos);
+ //printf("newlen: %u\n", newlen);
+ newEvent.setLenTick(newlen);
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(ce1, newEvent, e1->part(), false);
+ audio->msgChangeEvent(ce1, newEvent, e1->part(), false, false, false);
+ }
+ }
+ song->endUndo(SC_EVENT_MODIFIED);
+ break;
+
+
+ case CMD_CRESCENDO:
+ case CMD_TRANSPOSE:
+ case CMD_THIN_OUT:
+ case CMD_ERASE_EVENT:
+ case CMD_NOTE_SHIFT:
+ case CMD_MOVE_CLOCK:
+ case CMD_COPY_MEASURE:
+ case CMD_ERASE_MEASURE:
+ case CMD_DELETE_MEASURE:
+ case CMD_CREATE_MEASURE:
+ break;
+ default:
+// printf("unknown ecanvas cmd %d\n", cmd);
+ break;
+ }
+ updateSelection();
+ redraw();
+ }
+
+//---------------------------------------------------------
+// quantize
+//---------------------------------------------------------
+
+void PianoCanvas::quantize(int strength, int limit, bool quantLen)
+ {
+ song->startUndo();
+ for (iCItem k = items.begin(); k != items.end(); ++k) {
+ NEvent* nevent = (NEvent*)(k->second);
+ Event event = nevent->event();
+ Part* part = nevent->part();
+ if (event.type() != Note)
+ continue;
+
+ if ((cmdRange & CMD_RANGE_SELECTED) && !k->second->isSelected())
+ continue;
+
+ unsigned tick = event.tick() + part->tick();
+
+ if ((cmdRange & CMD_RANGE_LOOP)
+ && ((tick < song->lpos() || tick >= song->rpos())))
+ continue;
+
+ unsigned int len = event.lenTick(); //prevent compiler warning: comparison singed/unsigned
+ int tick2 = tick + len;
+
+ // quant start position
+ int diff = AL::sigmap.raster(tick, editor->quant()) - tick;
+ if (abs(diff) > limit)
+ tick += ((diff * strength) / 100);
+
+ // quant len
+ diff = AL::sigmap.raster(tick2, editor->quant()) - tick2;
+ if (quantLen && (abs(diff) > limit))
+ len += ((diff * strength) / 100);
+
+ // something changed?
+ if (((event.tick() + part->tick()) != tick) || (event.lenTick() != len)) {
+ Event newEvent = event.clone();
+ newEvent.setTick(tick - part->tick());
+ newEvent.setLenTick(len);
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(event, newEvent, part, false);
+ audio->msgChangeEvent(event, newEvent, part, false, false, false);
+ }
+ }
+ song->endUndo(SC_EVENT_MODIFIED);
+ }
+
+//---------------------------------------------------------
+// midiNote
+//---------------------------------------------------------
+
+void PianoCanvas::midiNote(int pitch, int velo)
+ {
+ if (_midiin && _steprec && curPart
+ && !audio->isPlaying() && velo && pos[0] >= start_tick
+ && pos[0] < end_tick
+ && !(globalKeyState & Qt::AltModifier)) {
+ unsigned int len = editor->quant();//prevent compiler warning: comparison singed/unsigned
+ unsigned tick = pos[0]; //CDW
+ unsigned starttick = tick;
+ if (globalKeyState & Qt::ShiftModifier)
+ tick -= editor->rasterStep(tick);
+
+ //
+ // extend len of last note?
+ //
+ EventList* events = curPart->events();
+ if (globalKeyState & Qt::ControlModifier) {
+ for (iEvent i = events->begin(); i != events->end(); ++i) {
+ Event ev = i->second;
+ if (!ev.isNote())
+ continue;
+ if (ev.pitch() == pitch && ((ev.tick() + ev.lenTick()) == /*(int)*/starttick)) {
+ Event e = ev.clone();
+ e.setLenTick(ev.lenTick() + editor->rasterStep(starttick));
+ // Indicate do undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(ev, e, curPart);
+ audio->msgChangeEvent(ev, e, curPart, true, false, false);
+ tick += editor->rasterStep(tick);
+ if (tick != song->cpos()) {
+ Pos p(tick, true);
+ song->setPos(0, p, true, false, true);
+ }
+ return;
+ }
+ }
+ }
+
+ //
+ // if we already entered the note, delete it
+ //
+ EventRange range = events->equal_range(tick);
+ for (iEvent i = range.first; i != range.second; ++i) {
+ Event ev = i->second;
+ if (ev.isNote() && ev.pitch() == pitch) {
+ // Indicate do undo, and do not do port controller values and clone parts.
+ //audio->msgDeleteEvent(ev, curPart);
+ audio->msgDeleteEvent(ev, curPart, true, false, false);
+ if (globalKeyState & Qt::ShiftModifier)
+ tick += editor->rasterStep(tick);
+ return;
+ }
+ }
+ Event e(Note);
+ e.setTick(tick - curPart->tick());
+ e.setPitch(pitch);
+ e.setVelo(velo);
+ e.setLenTick(len);
+ // Indicate do undo, and do not do port controller values and clone parts.
+ //audio->msgAddEvent(e, curPart);
+ audio->msgAddEvent(e, curPart, true, false, false);
+ tick += editor->rasterStep(tick);
+ if (tick != song->cpos()) {
+ Pos p(tick, true);
+ song->setPos(0, p, true, false, true);
+ }
+ }
+ }
+
+/*
+//---------------------------------------------------------
+// getTextDrag
+//---------------------------------------------------------
+
+Q3TextDrag* PianoCanvas::getTextDrag(QWidget* parent)
+ {
+ //---------------------------------------------------
+ // generate event list from selected events
+ //---------------------------------------------------
+
+ EventList el;
+ unsigned startTick = MAXINT;
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ if (!i->second->isSelected())
+ continue;
+ NEvent* ne = (NEvent*)(i->second);
+ Event e = ne->event();
+ if (startTick == MAXINT)
+ startTick = e.tick();
+ el.add(e);
+ }
+
+ //---------------------------------------------------
+ // write events as XML into tmp file
+ //---------------------------------------------------
+
+ FILE* tmp = tmpfile();
+ if (tmp == 0) {
+ fprintf(stderr, "PianoCanvas::copy() fopen failed: %s\n",
+ strerror(errno));
+ return 0;
+ }
+ Xml xml(tmp);
+
+ int level = 0;
+ xml.tag(level++, "eventlist");
+ for (ciEvent e = el.begin(); e != el.end(); ++e)
+ e->second.write(level, xml, -startTick);
+ xml.etag(--level, "eventlist");
+
+ //---------------------------------------------------
+ // read tmp file into QTextDrag Object
+ //---------------------------------------------------
+
+ fflush(tmp);
+ struct stat f_stat;
+ if (fstat(fileno(tmp), &f_stat) == -1) {
+ fprintf(stderr, "PianoCanvas::copy() fstat failes:<%s>\n",
+ strerror(errno));
+ fclose(tmp);
+ return 0;
+ }
+ int n = f_stat.st_size;
+ char* fbuf = (char*)mmap(0, n+1, PROT_READ|PROT_WRITE,
+ MAP_PRIVATE, fileno(tmp), 0);
+ fbuf[n] = 0;
+ Q3TextDrag* drag = new Q3TextDrag(QString(fbuf), parent);
+ drag->setSubtype("eventlist");
+ munmap(fbuf, n);
+ fclose(tmp);
+ return drag;
+ }
+*/
+
+//---------------------------------------------------------
+// copy
+// cut copy paste
+//---------------------------------------------------------
+
+void PianoCanvas::copy()
+ {
+ //QDrag* drag = getTextDrag();
+ QMimeData* drag = getTextDrag();
+
+ if (drag)
+ QApplication::clipboard()->setMimeData(drag, QClipboard::Clipboard);
+ }
+
+/*
+//---------------------------------------------------------
+// pasteAt
+//---------------------------------------------------------
+
+void PianoCanvas::pasteAt(const QString& pt, int pos)
+ {
+ QByteArray ba = pt.toLatin1();
+ const char* p = ba.constData();
+ Xml xml(p);
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "eventlist") {
+ song->startUndo();
+ EventList* el = new EventList();
+ el->read(xml, "eventlist", true);
+ int modified = SC_EVENT_INSERTED;
+ for (iEvent i = el->begin(); i != el->end(); ++i) {
+ Event e = i->second;
+ int tick = e.tick() + pos - curPart->tick();
+ if (tick<0) {
+ printf("ERROR: trying to add event before current part!\n");
+ song->endUndo(SC_EVENT_INSERTED);
+ delete el;
+ return;
+ }
+
+ e.setTick(tick);
+ int diff = e.endTick()-curPart->lenTick();
+ if (diff > 0) {// too short part? extend it
+ Part* newPart = curPart->clone();
+ newPart->setLenTick(newPart->lenTick()+diff);
+ // Indicate no undo, and do port controller values but not clone parts.
+ audio->msgChangePart(curPart, newPart, false, true, false);
+ modified=modified|SC_PART_MODIFIED;
+ curPart = newPart; // reassign
+ }
+ // Indicate no undo, and do not do port controller values and clone parts.
+ audio->msgAddEvent(e, curPart, false, false, false);
+ }
+ song->endUndo(modified);
+ delete el;
+ return;
+ }
+ else
+ xml.unknown("pasteAt");
+ break;
+ case Xml::Attribut:
+ case Xml::TagEnd:
+ default:
+ break;
+ }
+ }
+ }
+*/
+
+//---------------------------------------------------------
+// paste
+// paste events
+//---------------------------------------------------------
+
+void PianoCanvas::paste()
+ {
+/*
+ //Q3CString subtype("eventlist"); ddskrjo
+ QString subtype("eventlist");
+ QMimeSource* ms = QApplication::clipboard()->data(QClipboard::Clipboard);
+ QString pt;
+ if (!Q3TextDrag::decode(ms, pt, subtype)) {
+ printf("cannot paste: bad data type\n");
+ return;
+ }
+ pasteAt(pt, song->cpos());
+*/
+ QString stype("x-muse-eventlist");
+
+ //QString s = QApplication::clipboard()->text(stype, QClipboard::Selection);
+ QString s = QApplication::clipboard()->text(stype, QClipboard::Clipboard); // TODO CHECK Tim.
+
+ pasteAt(s, song->cpos());
+ }
+
+//---------------------------------------------------------
+// startDrag
+//---------------------------------------------------------
+
+void PianoCanvas::startDrag(CItem* /* item*/, bool copymode)
+ {
+ QMimeData* md = getTextDrag();
+ //QDrag* drag = getTextDrag();
+
+ if (md) {
+// QApplication::clipboard()->setData(drag, QClipboard::Clipboard); // This line NOT enabled in muse-1
+ //QApplication::clipboard()->setMimeData(md); // TODO CHECK Tim.
+ //QApplication::clipboard()->setMimeData(drag->mimeData()); //
+
+ // "Note that setMimeData() assigns ownership of the QMimeData object to the QDrag object.
+ // The QDrag must be constructed on the heap with a parent QWidget to ensure that Qt can
+ // clean up after the drag and drop operation has been completed. "
+ QDrag* drag = new QDrag(this);
+ drag->setMimeData(md);
+
+ if (copymode)
+ drag->exec(Qt::CopyAction);
+ else
+ drag->exec(Qt::MoveAction);
+ }
+ }
+
+//---------------------------------------------------------
+// dragEnterEvent
+//---------------------------------------------------------
+
+void PianoCanvas::dragEnterEvent(QDragEnterEvent* event)
+ {
+ ///event->accept(Q3TextDrag::canDecode(event));
+ event->acceptProposedAction(); // TODO CHECK Tim.
+ }
+
+//---------------------------------------------------------
+// dragMoveEvent
+//---------------------------------------------------------
+
+void PianoCanvas::dragMoveEvent(QDragMoveEvent*)
+ {
+ //printf("drag move %x\n", this);
+ //event->acceptProposedAction();
+ }
+
+//---------------------------------------------------------
+// dragLeaveEvent
+//---------------------------------------------------------
+
+void PianoCanvas::dragLeaveEvent(QDragLeaveEvent*)
+ {
+ //printf("drag leave\n");
+ //event->acceptProposedAction();
+ }
+
+/*
+//---------------------------------------------------------
+// dropEvent
+//---------------------------------------------------------
+
+void PianoCanvas::viewDropEvent(QDropEvent* event)
+ {
+ QString text;
+ if (event->source() == this) {
+ printf("local DROP\n"); // REMOVE Tim
+ //event->acceptProposedAction();
+ //event->ignore(); // TODO CHECK Tim.
+ return;
+ }
+ ///if (Q3TextDrag::decode(event, text)) {
+ //if (event->mimeData()->hasText()) {
+ if (event->mimeData()->hasFormat("text/x-muse-eventlist")) {
+
+ //text = event->mimeData()->text();
+ text = QString(event->mimeData()->data("text/x-muse-eventlist"));
+
+ int x = editor->rasterVal(event->pos().x());
+ if (x < 0)
+ x = 0;
+ pasteAt(text, x);
+ //event->accept(); // TODO
+ }
+ else {
+ printf("cannot decode drop\n");
+ //event->acceptProposedAction();
+ //event->ignore(); // TODO CHECK Tim.
+ }
+ }
+*/
+
+//---------------------------------------------------------
+// itemPressed
+//---------------------------------------------------------
+
+void PianoCanvas::itemPressed(const CItem* item)
+ {
+ if (!_playEvents)
+ return;
+
+ int port = track()->outPort();
+ int channel = track()->outChannel();
+ NEvent* nevent = (NEvent*) item;
+ Event event = nevent->event();
+ playedPitch = event.pitch() + track()->transposition;
+ int velo = event.velo();
+
+ // play note:
+ MidiPlayEvent e(0, port, channel, 0x90, playedPitch, velo);
+ audio->msgPlayMidiEvent(&e);
+ }
+
+//---------------------------------------------------------
+// itemReleased
+//---------------------------------------------------------
+
+void PianoCanvas::itemReleased(const CItem*, const QPoint&)
+ {
+ if (!_playEvents)
+ return;
+ int port = track()->outPort();
+ int channel = track()->outChannel();
+
+ // release note:
+ MidiPlayEvent ev(0, port, channel, 0x90, playedPitch, 0);
+ audio->msgPlayMidiEvent(&ev);
+ playedPitch = -1;
+ }
+
+//---------------------------------------------------------
+// itemMoved
+//---------------------------------------------------------
+
+void PianoCanvas::itemMoved(const CItem* item, const QPoint& pos)
+ {
+ int npitch = y2pitch(pos.y());
+ if ((playedPitch != -1) && (playedPitch != npitch)) {
+ int port = track()->outPort();
+ int channel = track()->outChannel();
+ NEvent* nevent = (NEvent*) item;
+ Event event = nevent->event();
+
+ // release note:
+ MidiPlayEvent ev1(0, port, channel, 0x90, playedPitch, 0);
+ audio->msgPlayMidiEvent(&ev1);
+ // play note:
+ MidiPlayEvent e2(0, port, channel, 0x90, npitch + track()->transposition, event.velo());
+ audio->msgPlayMidiEvent(&e2);
+ playedPitch = npitch + track()->transposition;
+ }
+ }
+
+//---------------------------------------------------------
+// curPartChanged
+//---------------------------------------------------------
+
+void PianoCanvas::curPartChanged()
+ {
+ editor->setWindowTitle(getCaption());
+ }
+
+//---------------------------------------------------------
+// modifySelected
+//---------------------------------------------------------
+
+void PianoCanvas::modifySelected(NoteInfo::ValType type, int delta)
+ {
+ audio->msgIdle(true);
+ song->startUndo();
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ if (!(i->second->isSelected()))
+ continue;
+ NEvent* e = (NEvent*)(i->second);
+ Event event = e->event();
+ if (event.type() != Note)
+ continue;
+
+ MidiPart* part = (MidiPart*)(e->part());
+ Event newEvent = event.clone();
+
+ switch (type) {
+ case NoteInfo::VAL_TIME:
+ {
+ int newTime = event.tick() + delta;
+ if (newTime < 0)
+ newTime = 0;
+ newEvent.setTick(newTime);
+ }
+ break;
+ case NoteInfo::VAL_LEN:
+ {
+ int len = event.lenTick() + delta;
+ if (len < 1)
+ len = 1;
+ newEvent.setLenTick(len);
+ }
+ break;
+ case NoteInfo::VAL_VELON:
+ {
+ int velo = event.velo() + delta;
+ if (velo > 127)
+ velo = 127;
+ else if (velo < 0)
+ velo = 0;
+ newEvent.setVelo(velo);
+ }
+ break;
+ case NoteInfo::VAL_VELOFF:
+ {
+ int velo = event.veloOff() + delta;
+ if (velo > 127)
+ velo = 127;
+ else if (velo < 0)
+ velo = 0;
+ newEvent.setVeloOff(velo);
+ }
+ break;
+ case NoteInfo::VAL_PITCH:
+ {
+ int pitch = event.pitch() + delta;
+ if (pitch > 127)
+ pitch = 127;
+ else if (pitch < 0)
+ pitch = 0;
+ newEvent.setPitch(pitch);
+ }
+ break;
+ }
+ song->changeEvent(event, newEvent, part);
+ // Indicate do not do port controller values and clone parts.
+ //song->undoOp(UndoOp::ModifyEvent, newEvent, event, part);
+ song->undoOp(UndoOp::ModifyEvent, newEvent, event, part, false, false);
+ }
+ song->endUndo(SC_EVENT_MODIFIED);
+ audio->msgIdle(false);
+ }
+
+//---------------------------------------------------------
+// resizeEvent
+//---------------------------------------------------------
+
+void PianoCanvas::resizeEvent(QResizeEvent* ev)
+ {
+ if (ev->size().width() != ev->oldSize().width())
+ emit newWidth(ev->size().width());
+ EventCanvas::resizeEvent(ev);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/midiedit/prcanvas.h b/attic/muse2-oom/muse2/muse/midiedit/prcanvas.h
new file mode 100644
index 00000000..81acf426
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/prcanvas.h
@@ -0,0 +1,110 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: prcanvas.h,v 1.5.2.6 2009/11/16 11:29:33 lunar_shuttle Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __PRCANVAS_H__
+#define __PRCANVAS_H__
+
+#include "ecanvas.h"
+#include "pianoroll.h"
+#include <QDragEnterEvent>
+#include <QDropEvent>
+#include <QMouseEvent>
+#include <QDragMoveEvent>
+#include <QDragLeaveEvent>
+
+#define KH 13
+
+//---------------------------------------------------------
+// NEvent
+// ''visual'' Note Event
+//---------------------------------------------------------
+
+class NEvent : public CItem {
+ public:
+ NEvent(Event& e, Part* p, int y);
+ };
+
+class ScrollScale;
+class PianoRoll;
+class QRect;
+
+//---------------------------------------------------------
+// PianoCanvas
+//---------------------------------------------------------
+
+class PianoCanvas : public EventCanvas {
+ int cmdRange;
+ int colorMode;
+ int playedPitch;
+
+ Q_OBJECT
+ virtual void viewMouseDoubleClickEvent(QMouseEvent*);
+ virtual void drawItem(QPainter&, const CItem*, const QRect&);
+ virtual void drawMoving(QPainter&, const CItem*, const QRect&);
+ virtual void moveCanvasItems(CItemList&, int, int, DragType, int*);
+ // Changed by T356.
+ //virtual bool moveItem(CItem*, const QPoint&, DragType, int*);
+ virtual bool moveItem(CItem*, const QPoint&, DragType);
+ virtual CItem* newItem(const QPoint&, int);
+ virtual void resizeItem(CItem*, bool noSnap);
+ virtual void newItem(CItem*, bool noSnap);
+ virtual bool deleteItem(CItem*);
+ virtual void startDrag(CItem* item, bool copymode);
+ virtual void dragEnterEvent(QDragEnterEvent* event);
+ virtual void dragMoveEvent(QDragMoveEvent*);
+ virtual void dragLeaveEvent(QDragLeaveEvent*);
+ virtual void addItem(Part*, Event&);
+
+ int y2pitch(int) const;
+ int pitch2y(int) const;
+ virtual void drawCanvas(QPainter&, const QRect&);
+ void quantize(int, int, bool);
+ void copy();
+ void paste();
+ virtual void itemPressed(const CItem*);
+ virtual void itemReleased(const CItem*, const QPoint&);
+ virtual void itemMoved(const CItem*, const QPoint&);
+ virtual void curPartChanged();
+ virtual void resizeEvent(QResizeEvent*);
+
+ private slots:
+ void midiNote(int pitch, int velo);
+
+ signals:
+ void quantChanged(int);
+ void rasterChanged(int);
+ void newWidth(int);
+
+ public slots:
+ void pianoCmd(int);
+ void pianoPressed(int pitch, int velocity, bool shift);
+ void pianoReleased(int pitch, bool);
+
+ public:
+ enum {
+ CMD_CUT, CMD_COPY, CMD_PASTE, CMD_DEL,
+ CMD_OVER_QUANTIZE, CMD_ON_QUANTIZE, CMD_ONOFF_QUANTIZE,
+ CMD_ITERATIVE_QUANTIZE,
+ CMD_SELECT_ALL, CMD_SELECT_NONE, CMD_SELECT_INVERT,
+ CMD_SELECT_ILOOP, CMD_SELECT_OLOOP, CMD_SELECT_PREV_PART, CMD_SELECT_NEXT_PART,
+ CMD_MODIFY_GATE_TIME, CMD_MODIFY_VELOCITY,
+ CMD_CRESCENDO, CMD_TRANSPOSE, CMD_THIN_OUT, CMD_ERASE_EVENT,
+ CMD_NOTE_SHIFT, CMD_MOVE_CLOCK, CMD_COPY_MEASURE,
+ CMD_ERASE_MEASURE, CMD_DELETE_MEASURE, CMD_CREATE_MEASURE,
+ CMD_FIXED_LEN, CMD_DELETE_OVERLAPS
+ };
+
+ PianoCanvas(MidiEditor*, QWidget*, int, int);
+ void cmd(int, int, int, bool, int);
+ void setColorMode(int mode) {
+ colorMode = mode;
+ redraw();
+ }
+ virtual void modifySelected(NoteInfo::ValType type, int delta);
+ };
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/midiedit/quantconfig.cpp b/attic/muse2-oom/muse2/muse/midiedit/quantconfig.cpp
new file mode 100644
index 00000000..2f413e6a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/quantconfig.cpp
@@ -0,0 +1,79 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: quantconfig.cpp,v 1.2 2004/04/24 14:58:52 wschweer Exp $
+//
+// (C) Copyright 1999/2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QCheckBox>
+#include <QGroupBox>
+#include <QLabel>
+#include <QSpinBox>
+#include <QVBoxLayout>
+
+#include "quantconfig.h"
+
+const char* wtStrengthTxt = QT_TRANSLATE_NOOP("@default", "sets amount of quantization:\n"
+ "0 - no quantization\n"
+ "100 - full quantization");
+const char* wtQLimitTxt = QT_TRANSLATE_NOOP("@default", "don't quantize notes above this tick limit");
+const char* wtQLenTxt = QT_TRANSLATE_NOOP("@default", "quantize also note len as default");
+
+//---------------------------------------------------------
+// QuantConfig
+//---------------------------------------------------------
+
+QuantConfig::QuantConfig(int s, int l, bool lenFlag)
+ : QDialog()
+ {
+ setWindowTitle(tr("MusE: Config Quantize"));
+ QVBoxLayout *mainlayout = new QVBoxLayout;
+
+ QGridLayout* layout = new QGridLayout;
+ QGroupBox* gb = new QGroupBox(tr("Config Quantize"));
+
+ QLabel* l1 = new QLabel(tr("Strength"));
+ layout->addWidget(l1, 0, 0);
+ QSpinBox* sb1 = new QSpinBox;
+ sb1->setMinimum(0);
+ sb1->setMaximum(100);
+ sb1->setSingleStep(1);
+ sb1->setSuffix(QString("%"));
+ sb1->setValue(s);
+ layout->addWidget(sb1, 0, 1);
+
+ QLabel* l2 = new QLabel(tr("Donīt Quantize"));
+ layout->addWidget(l2, 1, 0);
+ QSpinBox* sb2 = new QSpinBox;
+ sb2->setMinimum(0);
+ sb2->setMaximum(500);
+ sb2->setSingleStep(1);
+ sb2->setValue(l);
+ layout->addWidget(sb2, 1, 1);
+
+ QLabel* l3 = new QLabel(tr("Quant Len"));
+ layout->addWidget(l3, 2, 0);
+ QCheckBox* but = new QCheckBox;
+ but->setChecked(lenFlag);
+ layout->addWidget(but, 2, 1);
+
+ connect(sb1, SIGNAL(valueChanged(int)), SIGNAL(setQuantStrength(int)));
+ connect(sb2, SIGNAL(valueChanged(int)), SIGNAL(setQuantLimit(int)));
+ connect(but, SIGNAL(toggled(bool)), SIGNAL(setQuantLen(bool)));
+
+ gb->setLayout(layout);
+ mainlayout->addWidget(gb);
+ setLayout(mainlayout);
+
+ l1->setWhatsThis(tr(wtStrengthTxt));
+ l1->setToolTip(tr(wtStrengthTxt));
+ sb1->setWhatsThis(tr(wtStrengthTxt));
+ l2->setWhatsThis(tr(wtQLimitTxt));
+ l2->setToolTip(tr(wtQLimitTxt));
+ sb2->setWhatsThis(tr(wtQLimitTxt));
+ l3->setWhatsThis(tr(wtQLenTxt));
+ l3->setToolTip(tr(wtQLenTxt));
+ but->setWhatsThis(tr(wtQLenTxt));
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/midiedit/quantconfig.h b/attic/muse2-oom/muse2/muse/midiedit/quantconfig.h
new file mode 100644
index 00000000..4466cdf0
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiedit/quantconfig.h
@@ -0,0 +1,32 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: quantconfig.h,v 1.1.1.1 2003/10/27 18:52:23 wschweer Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __QCONFIG_H__
+#define __QCONFIG_H__
+
+#include <QDialog>
+
+//---------------------------------------------------------
+// QuantConfig
+//---------------------------------------------------------
+
+class QuantConfig : public QDialog {
+ Q_OBJECT
+
+ signals:
+ void setQuantStrength(int);
+ void setQuantLimit(int);
+ void setQuantLen(bool);
+
+ public:
+ QuantConfig(int, int, bool);
+ };
+
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/midieditor.cpp b/attic/muse2-oom/muse2/muse/midieditor.cpp
new file mode 100644
index 00000000..9191233d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midieditor.cpp
@@ -0,0 +1,243 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midieditor.cpp,v 1.2.2.2 2009/02/02 21:38:00 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "midieditor.h"
+#include "midiedit/ecanvas.h"
+#include "waveedit/waveview.h"
+#include "scrollscale.h"
+#include "mtscale.h"
+#include "xml.h"
+#include "part.h"
+#include "track.h"
+#include "song.h"
+
+#include <QRect>
+#include <QColor>
+#include <QGridLayout>
+
+//---------------------------------------------------------
+// MidiEditor
+//---------------------------------------------------------
+
+MidiEditor::MidiEditor(int q, int r, PartList* pl,
+ QWidget* parent, const char* name) : TopWin(parent, name)
+ {
+ setAttribute(Qt::WA_DeleteOnClose);
+ _pl = pl;
+ if (_pl)
+ for (iPart i = _pl->begin(); i != _pl->end(); ++i)
+ _parts.push_back(i->second->sn());
+ _quant = q;
+ _raster = r;
+ canvas = 0;
+ wview = 0;
+ _curDrumInstrument = -1;
+ mainw = new QWidget(this);
+
+ ///mainGrid = new QGridLayout(mainw);
+ mainGrid = new QGridLayout();
+ mainw->setLayout(mainGrid);
+
+ mainGrid->setContentsMargins(0, 0, 0, 0);
+ mainGrid->setSpacing(0);
+ setCentralWidget(mainw);
+ }
+
+//---------------------------------------------------------
+// genPartlist
+//---------------------------------------------------------
+
+void MidiEditor::genPartlist()
+ {
+ _pl->clear();
+ for (std::list<int>::iterator i = _parts.begin(); i != _parts.end(); ++i) {
+ TrackList* tl = song->tracks();
+ for (iTrack it = tl->begin(); it != tl->end(); ++it) {
+ PartList* pl = (*it)->parts();
+ iPart ip;
+ for (ip = pl->begin(); ip != pl->end(); ++ip) {
+ if (ip->second->sn() == *i) {
+ _pl->add(ip->second);
+ break;
+ }
+ }
+ if (ip != pl->end())
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// MidiEditor
+//---------------------------------------------------------
+
+MidiEditor::~MidiEditor()
+ {
+ if (_pl)
+ delete _pl;
+ }
+
+//---------------------------------------------------------
+// quantVal
+//---------------------------------------------------------
+
+int MidiEditor::quantVal(int v) const
+ {
+ int val = ((v+_quant/2)/_quant)*_quant;
+ if (val == 0)
+ val = _quant;
+ return val;
+ }
+
+//---------------------------------------------------------
+// readStatus
+//---------------------------------------------------------
+
+void MidiEditor::readStatus(Xml& xml)
+ {
+ if (_pl == 0)
+ _pl = new PartList;
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ QString tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "quant")
+ _quant = xml.parseInt();
+ else if (tag == "raster")
+ _raster = xml.parseInt();
+ else if (tag == "topwin")
+ TopWin::readStatus(xml);
+ else
+ xml.unknown("MidiEditor");
+ break;
+ case Xml::TagEnd:
+ if (tag == "midieditor")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// writePartList
+//---------------------------------------------------------
+
+void MidiEditor::writePartList(int level, Xml& xml) const
+ {
+ for (ciPart p = _pl->begin(); p != _pl->end(); ++p) {
+ Part* part = p->second;
+ Track* track = part->track();
+ int trkIdx = song->tracks()->index(track);
+ int partIdx = track->parts()->index(part);
+
+ if((trkIdx == -1) || (partIdx == -1))
+ printf("MidiEditor::writePartList error: trkIdx:%d partIdx:%d\n", trkIdx, partIdx);
+
+ xml.put(level, "<part>%d:%d</part>", trkIdx, partIdx);
+ }
+ }
+
+//---------------------------------------------------------
+// writeStatus
+//---------------------------------------------------------
+
+void MidiEditor::writeStatus(int level, Xml& xml) const
+ {
+ xml.tag(level++, "midieditor");
+ TopWin::writeStatus(level, xml);
+ xml.intTag(level, "quant", _quant);
+ xml.intTag(level, "raster", _raster);
+ xml.tag(level, "/midieditor");
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void MidiEditor::songChanged(int type)
+ {
+
+ if (type) {
+ if (type & (SC_PART_REMOVED | SC_PART_MODIFIED
+ | SC_PART_INSERTED | SC_TRACK_REMOVED)) {
+ genPartlist();
+ // close window if editor has no parts anymore
+ if (parts()->empty()) {
+ close();
+ return;
+ }
+ }
+ if (canvas)
+ canvas->songChanged(type);
+ else if (wview)
+ wview->songChanged(type);
+
+ if (type & (SC_PART_REMOVED | SC_PART_MODIFIED
+ | SC_PART_INSERTED | SC_TRACK_REMOVED)) {
+
+ updateHScrollRange();
+ if (canvas)
+ setWindowTitle(canvas->getCaption());
+ else if (wview)
+ setWindowTitle(wview->getCaption());
+ if (type & SC_SIG)
+ time->update();
+
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// setCurDrumInstrument
+//---------------------------------------------------------
+
+void MidiEditor::setCurDrumInstrument(int instr)
+ {
+ _curDrumInstrument = instr;
+ emit curDrumInstrumentChanged(_curDrumInstrument);
+ }
+
+//---------------------------------------------------------
+// curCanvasPart
+//---------------------------------------------------------
+
+Part* MidiEditor::curCanvasPart()
+{
+ if(canvas)
+ return canvas->part();
+ else
+ return 0;
+}
+
+//---------------------------------------------------------
+// curWavePart
+//---------------------------------------------------------
+
+WavePart* MidiEditor::curWavePart()
+{
+ if(wview)
+ return wview->part();
+ else
+ return 0;
+}
+
+//---------------------------------------------------------
+// setCurCanvasPart
+//---------------------------------------------------------
+
+void MidiEditor::setCurCanvasPart(Part* part)
+{
+ if(canvas)
+ canvas->setCurrentPart(part);
+}
+
diff --git a/attic/muse2-oom/muse2/muse/midieditor.h b/attic/muse2-oom/muse2/muse/midieditor.h
new file mode 100644
index 00000000..1f465c2d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midieditor.h
@@ -0,0 +1,89 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midieditor.h,v 1.3.2.2 2009/02/02 21:38:00 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MIDIEDITOR_H__
+#define __MIDIEDITOR_H__
+
+///#include "sig.h"
+#include "al/sig.h"
+#include "cobject.h"
+
+class QGridLayout;
+class QWidget;
+
+class PartList;
+class Xml;
+class EventCanvas;
+class ScrollScale;
+class CtrlEdit;
+class MTScale;
+class WaveView;
+class Part;
+class WavePart;
+
+//---------------------------------------------------------
+// MidiEditor
+//---------------------------------------------------------
+
+class MidiEditor : public TopWin {
+ Q_OBJECT
+
+ PartList* _pl;
+ std::list<int> _parts;
+ int _curDrumInstrument; // currently selected instrument if drum
+ // editor
+ protected:
+ ScrollScale* hscroll;
+ ScrollScale* vscroll;
+ MTScale* time;
+ EventCanvas* canvas;
+ WaveView* wview;
+
+ std::list<CtrlEdit*> ctrlEditList;
+ int _quant, _raster;
+ QGridLayout* mainGrid;
+ QWidget* mainw;
+ virtual void readStatus(Xml&);
+ virtual void writeStatus(int, Xml&) const;
+ void writePartList(int, Xml&) const;
+ void genPartlist();
+
+ public slots:
+ void songChanged(int type);
+ void setCurDrumInstrument(int instr);
+
+ virtual void updateHScrollRange() { };
+ signals:
+ void curDrumInstrumentChanged(int);
+
+ public:
+ MidiEditor(int, int, PartList*,
+ QWidget* parent = 0, const char* name = 0);
+ ~MidiEditor();
+
+ int quantVal(int v) const;
+ ///int rasterStep(unsigned tick) const { return sigmap.rasterStep(tick, _raster); }
+ ///unsigned rasterVal(unsigned v) const { return sigmap.raster(v, _raster); }
+ ///unsigned rasterVal1(unsigned v) const { return sigmap.raster1(v, _raster); }
+ ///unsigned rasterVal2(unsigned v) const { return sigmap.raster2(v, _raster); }
+ int rasterStep(unsigned tick) const { return AL::sigmap.rasterStep(tick, _raster); }
+ unsigned rasterVal(unsigned v) const { return AL::sigmap.raster(v, _raster); }
+ unsigned rasterVal1(unsigned v) const { return AL::sigmap.raster1(v, _raster); }
+ unsigned rasterVal2(unsigned v) const { return AL::sigmap.raster2(v, _raster); }
+ int quant() const { return _quant; }
+ void setQuant(int val) { _quant = val; }
+ int raster() const { return _raster; }
+ void setRaster(int val) { _raster = val; }
+ PartList* parts() { return _pl; }
+ int curDrumInstrument() const { return _curDrumInstrument; }
+ Part* curCanvasPart();
+ WavePart* curWavePart();
+ void setCurCanvasPart(Part*);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/midievent.cpp b/attic/muse2-oom/muse2/muse/midievent.cpp
new file mode 100644
index 00000000..ffeca3ff
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midievent.cpp
@@ -0,0 +1,176 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midievent.cpp,v 1.7.2.2 2009/05/24 21:43:44 terminator356 Exp $
+//
+// (C) Copyright 2000-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "event.h"
+#include "midievent.h"
+#include "xml.h"
+#include "mpevent.h"
+#include "midictrl.h"
+
+//---------------------------------------------------------
+// MidiEventBase
+//---------------------------------------------------------
+
+MidiEventBase::MidiEventBase(EventType t)
+ : EventBase(t)
+ {
+ a = 0;
+ b = 0;
+ c = 0;
+ }
+
+//---------------------------------------------------------
+// MidiEventBase::mid
+//---------------------------------------------------------
+
+EventBase* MidiEventBase::mid(unsigned b, unsigned e)
+ {
+ if (tick() < b || tick() >= e)
+ return 0;
+ return new MidiEventBase(*this);
+ }
+
+//---------------------------------------------------------
+// isNoteOff
+//---------------------------------------------------------
+
+bool MidiEventBase::isNoteOff() const
+ {
+ return (type() == Note && (velo() == 0));
+ }
+
+bool MidiEventBase::isNoteOff(const Event& e) const
+ {
+ return (e.isNoteOff() && (e.pitch() == a));
+ }
+
+void MidiEventBase::dump(int n) const
+ {
+ EventBase::dump(n);
+ const char* p;
+
+ switch(type()) {
+ case Note: p = "Note "; break;
+ case Controller: p = "Ctrl "; break;
+ case Sysex: p = "Sysex "; break;
+ case PAfter: p = "PAfter "; break;
+ case CAfter: p = "CAfter "; break;
+ case Meta: p = "Meta "; break;
+ default: p = "?? "; break;
+ }
+ for (int i = 0; i < (n+2); ++i)
+ putchar(' ');
+ printf("<%s> a:0x%x(%d) b:0x%x(%d) c:0x%x(%d)\n",
+ p, a, a, b, b, c, c);
+ }
+
+//---------------------------------------------------------
+// MidiEventBase::write
+//---------------------------------------------------------
+
+//void MidiEventBase::write(int level, Xml& xml, const Pos& offset) const
+void MidiEventBase::write(int level, Xml& xml, const Pos& offset, bool /*forcePath*/) const
+ {
+ xml.nput(level++, "<event tick=\"%d\"", tick() + offset.tick());
+ switch (type()) {
+ case Note:
+ xml.nput(" len=\"%d\"", lenTick());
+ break;
+ default:
+ xml.nput(" type=\"%d\"", type());
+ break;
+ }
+
+ // Changed by T356. BUG: *.med does not save meta event types - ID: 2879426
+ if (a)
+ xml.nput(" a=\"%d\"", a);
+ if (b)
+ xml.nput(" b=\"%d\"", b);
+ if (c)
+ xml.nput(" c=\"%d\"", c);
+
+ if (edata.dataLen) {
+ xml.nput(" datalen=\"%d\">\n", edata.dataLen);
+ xml.nput(level, "");
+ for (int i = 0; i < edata.dataLen; ++i)
+ xml.nput("%02x ", edata.data[i] & 0xff);
+ xml.nput("\n");
+ xml.tag(level, "/event");
+ }
+ else {
+ //if (a)
+ // xml.nput(" a=\"%d\"", a);
+ //if (b)
+ // xml.nput(" b=\"%d\"", b);
+ //if (c)
+ // xml.nput(" c=\"%d\"", c);
+ xml.nput(" />\n");
+ }
+ }
+
+//---------------------------------------------------------
+// MidiEventBase::read
+//---------------------------------------------------------
+
+void MidiEventBase::read(Xml& xml)
+ {
+ setType(Note);
+ a = 0;
+ b = 0;
+ c = 0;
+
+ int dataLen = 0;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ xml.unknown("Event");
+ break;
+ case Xml::Text:
+ {
+ QByteArray ba = tag.toLatin1();
+ const char*s = ba.constData();
+ edata.data = new unsigned char[dataLen];
+ edata.dataLen = dataLen;
+ unsigned char* d = edata.data;
+ for (int i = 0; i < dataLen; ++i) {
+ char* endp;
+ *d++ = strtol(s, &endp, 16);
+ s = endp;
+ }
+ }
+ break;
+ case Xml::Attribut:
+ if (tag == "tick")
+ setTick(xml.s2().toInt());
+ else if (tag == "type")
+ setType(EventType(xml.s2().toInt()));
+ else if (tag == "len")
+ setLenTick(xml.s2().toInt());
+ else if (tag == "a")
+ a = xml.s2().toInt();
+ else if (tag == "b")
+ b = xml.s2().toInt();
+ else if (tag == "c")
+ c = xml.s2().toInt();
+ else if (tag == "datalen")
+ dataLen = xml.s2().toInt();
+ break;
+ case Xml::TagEnd:
+ if (tag == "event")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/midievent.h b/attic/muse2-oom/muse2/muse/midievent.h
new file mode 100644
index 00000000..48217f57
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midievent.h
@@ -0,0 +1,62 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midievent.h,v 1.7.2.1 2009/05/24 21:43:44 terminator356 Exp $
+//
+// (C) Copyright 1999-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MIDI_EVENT_H__
+#define __MIDI_EVENT_H__
+
+#include "eventbase.h"
+
+//---------------------------------------------------------
+// MidiEventBase
+//---------------------------------------------------------
+
+class MidiEventBase : public EventBase {
+ int a, b, c; // pitch, velo-on, velo-off
+ EvData edata;
+
+ virtual EventBase* clone() { return new MidiEventBase(*this); }
+
+ public:
+ MidiEventBase(EventType t);
+ virtual ~MidiEventBase() {}
+
+ virtual bool isNote() const { return type() == Note; }
+ virtual bool isNoteOff() const;
+ virtual bool isNoteOff(const Event&) const;
+ virtual int pitch() const { return a; }
+ virtual int program() const { return a; }
+ virtual int cntrl() const { return a; }
+ virtual int dataA() const { return a; }
+ virtual void setA(int val) { a = val; }
+ virtual void setPitch(int v) { a = v; }
+
+ virtual int cntrlVal() const { return b; }
+ virtual int dataB() const { return b; }
+ virtual int velo() const { return b; }
+ virtual void setB(int val) { b = val; }
+ virtual void setVelo(int v) { b = v; }
+
+ virtual int veloOff() const { return c; }
+ virtual int dataC() const { return c; }
+ virtual void setC(int val) { c = val; }
+ virtual void setVeloOff(int v) { c = v; }
+
+ virtual const unsigned char* data() const { return edata.data; }
+ virtual int dataLen() const { return edata.dataLen; }
+ virtual void setData(const unsigned char* data, int len) { edata.setData(data, len); }
+ virtual const EvData eventData() const { return edata; }
+
+ virtual void dump(int n = 0) const;
+ virtual void read(Xml&);
+ //virtual void write(int, Xml&, const Pos& offset) const;
+ virtual void write(int, Xml&, const Pos& offset, bool forcePath = false) const;
+ virtual EventBase* mid(unsigned, unsigned);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/midifile.cpp b/attic/muse2-oom/muse2/muse/midifile.cpp
new file mode 100644
index 00000000..319152d7
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midifile.cpp
@@ -0,0 +1,678 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midifile.cpp,v 1.17 2004/06/18 08:36:43 wschweer Exp $
+//
+// (C) Copyright 1999-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <errno.h>
+#include <values.h>
+#include <assert.h>
+
+#include "song.h"
+#include "midi.h"
+#include "midifile.h"
+#include "drummap.h"
+#include "event.h"
+#include "globals.h"
+#include "midictrl.h"
+#include "marker/marker.h"
+#include "midiport.h"
+#include "midictrl.h"
+#include "mpevent.h"
+#include "gconfig.h"
+
+const char* errString[] = {
+ "no Error",
+ "unexpected EOF",
+ "read Error",
+ "write Error",
+ "bad midifile: 'MTrk' expected",
+ "bad midifile: 'MThd' expected",
+ "bad midi fileformat",
+ };
+
+enum ERROR {
+ MF_NO_ERROR,
+ MF_EOF,
+ MF_READ,
+ MF_WRITE,
+ MF_MTRK,
+ MF_MTHD,
+ MF_FORMAT,
+ };
+
+//---------------------------------------------------------
+// error
+//---------------------------------------------------------
+
+QString MidiFile::error()
+ {
+ return QString(errString[_error]);
+ }
+
+//---------------------------------------------------------
+// MidiFile
+//---------------------------------------------------------
+
+MidiFile::MidiFile(FILE* f)
+ {
+ fp = f;
+ curPos = 0;
+ _mtype = MT_UNKNOWN;
+ _error = MF_NO_ERROR;
+ _tracks = new MidiFileTrackList;
+ }
+
+MidiFile::~MidiFile()
+ {
+ delete _tracks;
+ }
+
+//---------------------------------------------------------
+// read
+// return true on error
+//---------------------------------------------------------
+
+bool MidiFile::read(void* p, size_t len)
+ {
+ for (;;) {
+ curPos += len;
+ size_t rv = fread(p, 1, len, fp);
+ if (rv == len)
+ return false;
+ if (feof(fp)) {
+ _error = MF_EOF;
+ return true;
+ }
+ _error = MF_READ;
+ return true;
+ }
+ return false;
+ }
+
+//---------------------------------------------------------
+// write
+// return true on error
+//---------------------------------------------------------
+
+bool MidiFile::write(const void* p, size_t len)
+ {
+ size_t rv = fwrite(p, 1, len, fp);
+ if (rv == len)
+ return false;
+ _error = MF_WRITE;
+ return true;
+ }
+
+//---------------------------------------------------------
+// writeShort
+// return true on error
+//---------------------------------------------------------
+
+bool MidiFile::writeShort(int i)
+ {
+ short format = BE_SHORT(i);
+ return write(&format, 2);
+ }
+
+//---------------------------------------------------------
+// writeLong
+// return true on error
+//---------------------------------------------------------
+
+bool MidiFile::writeLong(int i)
+ {
+ int format = BE_LONG(i);
+ return write(&format, 4);
+ }
+
+//---------------------------------------------------------
+// readShort
+//---------------------------------------------------------
+
+int MidiFile::readShort()
+ {
+ short format;
+ read(&format, 2);
+ return BE_SHORT(format);
+ }
+
+//---------------------------------------------------------
+// readLong
+// writeLong
+//---------------------------------------------------------
+
+int MidiFile::readLong()
+ {
+ int format;
+ read(&format, 4);
+ return BE_LONG(format);
+ }
+
+/*---------------------------------------------------------
+ * skip
+ * This is meant for skipping a few bytes in a
+ * file or fifo.
+ *---------------------------------------------------------*/
+
+bool MidiFile::skip(size_t len)
+ {
+ char tmp[len];
+ return read(tmp, len);
+ }
+
+/*---------------------------------------------------------
+ * getvl
+ * Read variable-length number (7 bits per byte, MSB first)
+ *---------------------------------------------------------*/
+
+int MidiFile::getvl()
+ {
+ int l = 0;
+ for (int i = 0; i < 16; i++) {
+ uchar c;
+ if (read(&c, 1))
+ return -1;
+ l += (c & 0x7f);
+ if (!(c & 0x80))
+ return l;
+ l <<= 7;
+ }
+ return -1;
+ }
+
+/*---------------------------------------------------------
+ * putvl
+ * Write variable-length number (7 bits per byte, MSB first)
+ *---------------------------------------------------------*/
+
+void MidiFile::putvl(unsigned val)
+ {
+ unsigned long buf = val & 0x7f;
+ while ((val >>= 7) > 0) {
+ buf <<= 8;
+ buf |= 0x80;
+ buf += (val & 0x7f);
+ }
+ for (;;) {
+ put(buf);
+ if (buf & 0x80)
+ buf >>= 8;
+ else
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// readTrack
+// return true on error
+//---------------------------------------------------------
+
+bool MidiFile::readTrack(MidiFileTrack* t)
+ {
+ MPEventList* el = &(t->events);
+ char tmp[4];
+ if (read(tmp, 4))
+ return true;
+ if (memcmp(tmp, "MTrk", 4)) {
+ _error = MF_MTRK;
+ return true;
+ }
+ int len = readLong(); // len
+ int endPos = curPos + len;
+ status = -1;
+ sstatus = -1; // running status, not reset scanning meta or sysex
+ click = 0;
+
+ int port = 0;
+ int channel = 0;
+
+ for (;;) {
+ MidiPlayEvent event;
+ lastport = -1;
+ lastchannel = -1;
+
+ int rv = readEvent(&event, t);
+ if (lastport != -1) {
+ port = lastport;
+ if (port >= MIDI_PORTS) {
+ printf("port %d >= %d, reset to 0\n", port, MIDI_PORTS);
+ port = 0;
+ }
+ }
+ if (lastchannel != -1) {
+ channel = lastchannel;
+ if (channel >= MIDI_CHANNELS) {
+ printf("channel %d >= %d, reset to 0\n", port, MIDI_CHANNELS);
+ channel = 0;
+ }
+ }
+ if (rv == 0)
+ break;
+ else if (rv == -1)
+ continue;
+ else if (rv == -2) // error
+ return true;
+
+ event.setPort(port);
+ if (event.type() == ME_SYSEX || event.type() == ME_META)
+ event.setChannel(channel);
+ else
+ channel = event.channel();
+ el->add(event);
+ }
+ int end = curPos;
+ if (end != endPos) {
+ printf("MidiFile::readTrack(): TRACKLEN does not fit %d+%d != %d, %d too much\n",
+ endPos-len, len, end, endPos-end);
+ if (end < endPos)
+ skip(endPos - end);
+ }
+ return false;
+ }
+
+//---------------------------------------------------------
+// readEvent
+// returns:
+// 0 End of track
+// -1 Event filtered
+// -2 Error
+//---------------------------------------------------------
+
+int MidiFile::readEvent(MidiPlayEvent* event, MidiFileTrack* t)
+ {
+ uchar me, type, a, b;
+
+ int nclick = getvl();
+ if (nclick == -1) {
+ printf("readEvent: error 1\n");
+ return 0;
+ }
+ click += nclick;
+ for (;;) {
+ if (read(&me, 1)) {
+ printf("readEvent: error 2\n");
+ return 0;
+ }
+ if (me >= 0xf8 && me <= 0xfe)
+ printf("Midi: Real Time Message 0x%02x??\n", me & 0xff);
+ else
+ break;
+ }
+
+ event->setTime(click);
+ int len;
+ unsigned char* buffer;
+
+ if ((me & 0xf0) == 0xf0) {
+ if (me == 0xf0 || me == 0xf7) {
+ //
+ // SYSEX
+ //
+ status = -1; // no running status
+ len = getvl();
+ if (len == -1) {
+ printf("readEvent: error 3\n");
+ return -2;
+ }
+ buffer = new unsigned char[len];
+ if (read(buffer, len)) {
+ printf("readEvent: error 4\n");
+ delete[] buffer;
+ return -2;
+ }
+ if (buffer[len-1] != 0xf7) {
+ printf("SYSEX endet nicht mit 0xf7!\n");
+ // Forstsetzung folgt?
+ }
+ else
+ --len; // don't count 0xf7
+ event->setType(ME_SYSEX);
+ event->setData(buffer, len);
+ if (((unsigned)len == gmOnMsgLen) && memcmp(buffer, gmOnMsg, gmOnMsgLen) == 0) {
+ setMType(MT_GM);
+ return -1;
+ }
+ if (((unsigned)len == gsOnMsgLen) && memcmp(buffer, gsOnMsg, gsOnMsgLen) == 0) {
+ setMType(MT_GS);
+ return -1;
+ }
+ if (((unsigned)len == xgOnMsgLen) && memcmp(buffer, xgOnMsg, xgOnMsgLen) == 0) {
+ setMType(MT_XG);
+ return -1;
+ }
+ if (buffer[0] == 0x41) { // Roland
+ if (mtype() != MT_UNKNOWN)
+ setMType(MT_GS);
+ }
+ else if (buffer[0] == 0x43) { // Yamaha
+ if (mtype() == MT_UNKNOWN || mtype() == MT_GM)
+ setMType(MT_XG);
+ int type = buffer[1] & 0xf0;
+ switch (type) {
+ case 0x00: // bulk dump
+ buffer[1] = 0;
+ break;
+ case 0x10:
+ if (buffer[1] != 0x10) {
+ buffer[1] = 0x10; // fix to Device 1
+ }
+ if (len == 7 && buffer[2] == 0x4c && buffer[3] == 0x08 && buffer[5] == 7) {
+ // part mode
+ // 0 - normal
+ // 1 - DRUM
+ // 2 - DRUM 1
+ // 3 - DRUM 2
+ // 4 - DRUM 3
+ // 5 - DRUM 4
+ printf("xg set part mode channel %d to %d\n", buffer[4]+1, buffer[6]);
+ if (buffer[6] != 0)
+ t->isDrumTrack = true;
+ }
+ break;
+ case 0x20:
+ printf("YAMAHA DUMP REQUEST\n");
+ return -1;
+ case 0x30:
+ printf("YAMAHA PARAMETER REQUEST\n");
+ return -1;
+ default:
+ printf("YAMAHA unknown SYSEX: data[2]=%02x\n", buffer[1]);
+ return -1;
+ }
+ }
+ return 3;
+ }
+ if (me == 0xff) {
+ //
+ // META
+ //
+ status = -1; // no running status
+ if (read(&type, 1)) { // read type
+ printf("readEvent: error 5\n");
+ return -2;
+ }
+ len = getvl(); // read len
+ if (len == -1) {
+ printf("readEvent: error 6\n");
+ return -2;
+ }
+ buffer = new unsigned char[len+1];
+ if (len) {
+ if (read(buffer, len)) {
+ printf("readEvent: error 7\n");
+ delete[] buffer;
+ return -2;
+ }
+ }
+ buffer[len] = 0;
+ switch(type) {
+ case 0x21: // switch port
+ lastport = buffer[0];
+ delete[] buffer;
+ return -1;
+ case 0x20: // switch channel
+ lastchannel = buffer[0];
+ delete[] buffer;
+ return -1;
+ case 0x2f: // End of Track
+ delete[] buffer;
+ return 0;
+ default:
+ event->setType(ME_META);
+ event->setData(buffer, len+1);
+ event->setA(type);
+ return 3;
+ }
+ }
+ else {
+ printf("Midi: unknown Message 0x%02x\n", me & 0xff);
+ return -1;
+ }
+ }
+
+ if (me & 0x80) { // status byte
+ status = me;
+ sstatus = status;
+ if (read(&a, 1)) {
+ printf("readEvent: error 9\n");
+ return -2;
+ }
+ a &= 0x7F;
+ }
+ else {
+ if (status == -1) {
+ printf("readEvent: no running status, read 0x%02x sstatus %x\n", me, sstatus);
+ if (sstatus == -1)
+ return -1;
+ status = sstatus;
+ }
+ a = me;
+ }
+ b = 0;
+ switch (status & 0xf0) {
+ case ME_NOTEOFF:
+ case ME_NOTEON:
+ case ME_POLYAFTER:
+ case ME_CONTROLLER:
+ case ME_PITCHBEND:
+ if (read(&b, 1)) {
+ printf("readEvent: error 15\n");
+ return -2;
+ }
+ event->setB(b & 0x80 ? 0 : b);
+ break;
+ case ME_PROGRAM:
+ case ME_AFTERTOUCH:
+ break;
+ default: // f1 f2 f3 f4 f5 f6 f7 f8 f9
+ printf("BAD STATUS 0x%02x, me 0x%02x\n", status, me);
+ return -2;
+ }
+ event->setA(a & 0x7f);
+ event->setType(status & 0xf0);
+ event->setChannel(status & 0xf);
+ if ((a & 0x80) || (b & 0x80)) {
+ printf("8'tes Bit in Daten(%02x %02x): tick %d read 0x%02x status:0x%02x\n",
+ a & 0xff, b & 0xff, click, me, status);
+ printf("readEvent: error 16\n");
+ if (b & 0x80) {
+ // Try to fix: interpret as channel byte
+ status = b & 0xf0;
+ sstatus = status;
+ return 3;
+ }
+ return -1;
+ }
+ if (event->type() == ME_PITCHBEND) {
+ int val = (event->dataB() << 7) + event->dataA();
+ val -= 8192;
+ event->setA(val);
+ }
+ return 3;
+ }
+
+//---------------------------------------------------------
+// writeTrack
+//---------------------------------------------------------
+
+bool MidiFile::writeTrack(const MidiFileTrack* t)
+ {
+ //FIXME: By T356 01/19/2010
+ // If saving as a compressed file (gz or bz2),
+ // the file is a pipe, and pipes can't seek !
+ // This results in a corrupted midi file.
+ // So exporting compressed midi has been disabled (elsewhere)
+ // for now...
+
+ const MPEventList* events = &(t->events);
+ write("MTrk", 4);
+ int lenpos = ftell(fp);
+ writeLong(0); // dummy len
+
+ status = -1;
+ int tick = 0;
+ for (iMPEvent i = events->begin(); i != events->end(); ++i) {
+ int ntick = i->time();
+ if (ntick < tick) {
+ printf("MidiFile::writeTrack: ntick %d < tick %d\n", ntick, tick);
+ ntick = tick;
+ }
+ putvl(((ntick - tick) * config.midiDivision + config.division/2)/config.division);
+ tick = ntick;
+ writeEvent(&(*i));
+ }
+
+ //---------------------------------------------------
+ // write "End Of Track" Meta
+ // write Track Len
+ //
+
+ putvl(0);
+ put(0xff); // Meta
+ put(0x2f); // EOT
+ putvl(0); // len 0
+ int endpos = ftell(fp);
+ fseek(fp, lenpos, SEEK_SET);
+ writeLong(endpos-lenpos-4); // tracklen
+ fseek(fp, endpos, SEEK_SET);
+ return false;
+ }
+
+//---------------------------------------------------------
+// writeEvent
+//---------------------------------------------------------
+
+void MidiFile::writeEvent(const MidiPlayEvent* event)
+ {
+ int c = event->channel();
+ int nstat = event->type();
+
+ // we dont save meta data into smf type 0 files:
+
+ if (config.smfFormat == 0 && nstat == ME_META)
+ return;
+
+ nstat |= c;
+ //
+ // running status; except for Sysex- and Meta Events
+ //
+ if (((nstat & 0xf0) != 0xf0) && (nstat != status)) {
+ status = nstat;
+ put(nstat);
+ }
+ switch (event->type()) {
+ case ME_NOTEOFF:
+ case ME_NOTEON:
+ case ME_POLYAFTER:
+ case ME_CONTROLLER:
+ case ME_PITCHBEND:
+ put(event->dataA());
+ put(event->dataB());
+ break;
+ case ME_PROGRAM: // Program Change
+ case ME_AFTERTOUCH: // Channel Aftertouch
+ put(event->dataA());
+ break;
+ case ME_SYSEX:
+ put(0xf0);
+ putvl(event->len() + 1); // including 0xf7
+ write(event->data(), event->len());
+ put(0xf7);
+ status = -1; // invalidate running status
+ break;
+ case ME_META:
+ put(0xff);
+ put(event->dataA());
+ putvl(event->len());
+ write(event->data(), event->len());
+ status = -1;
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// write
+// returns true on error
+//---------------------------------------------------------
+
+bool MidiFile::write()
+ {
+ write("MThd", 4);
+ writeLong(6); // header len
+ writeShort(config.smfFormat);
+ if (config.smfFormat == 0) {
+ writeShort(1);
+ MidiFileTrack dst;
+ for (iMidiFileTrack i = _tracks->begin(); i != _tracks->end(); ++i) {
+ MPEventList* sl = &((*i)->events);
+ for (iMPEvent ie = sl->begin(); ie != sl->end(); ++ie)
+ dst.events.add(*ie);
+ }
+ writeShort(1);
+ writeShort(_division);
+ writeTrack(&dst);
+ }
+ else {
+ writeShort(ntracks);
+
+ writeShort(_division);
+ for (ciMidiFileTrack i = _tracks->begin(); i != _tracks->end(); ++i)
+ writeTrack(*i);
+ }
+ return (ferror(fp) != 0);
+ }
+
+//---------------------------------------------------------
+// readMidi
+// returns true on error
+//---------------------------------------------------------
+
+bool MidiFile::read()
+ {
+ _error = MF_NO_ERROR;
+ int i;
+ char tmp[4];
+
+ if (read(tmp, 4))
+ return true;
+ int len = readLong();
+ if (memcmp(tmp, "MThd", 4) || len < 6) {
+ _error = MF_MTHD;
+ return true;
+ }
+ format = readShort();
+ ntracks = readShort();
+ _division = readShort();
+
+ if (_division < 0)
+ _division = (-(_division/256)) * (_division & 0xff);
+ if (len > 6)
+ skip(len-6); // skip excess bytes
+
+ switch (format) {
+ case 0:
+ {
+ MidiFileTrack* t = new MidiFileTrack;
+ _tracks->push_back(t);
+ if (readTrack(t))
+ return true;
+ }
+ break;
+ case 1:
+ for (i = 0; i < ntracks; i++) {
+ MidiFileTrack* t = new MidiFileTrack;
+ _tracks->push_back(t);
+ if (readTrack(t))
+ return true;
+ }
+ break;
+ default:
+ _error = MF_FORMAT;
+ return true;
+ }
+ return false;
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/midifile.h b/attic/muse2-oom/muse2/muse/midifile.h
new file mode 100644
index 00000000..da71a00a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midifile.h
@@ -0,0 +1,113 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midifile.h,v 1.3 2004/01/04 18:24:43 wschweer Exp $
+//
+// (C) Copyright 1999-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MIDIFILE_H__
+#define __MIDIFILE_H__
+
+#include <stdio.h>
+#include <list>
+
+#include "globaldefs.h"
+#include "mpevent.h"
+
+struct MPEventList;
+class MidiPlayEvent;
+
+//---------------------------------------------------------
+// MidiFileTrack
+//---------------------------------------------------------
+
+struct MidiFileTrack {
+ MPEventList events;
+ bool isDrumTrack;
+ MidiFileTrack() {
+ isDrumTrack = false;
+ }
+ };
+
+typedef std::list<MidiFileTrack*> MidiFileTrackList;
+typedef MidiFileTrackList::iterator iMidiFileTrack;
+typedef MidiFileTrackList::const_iterator ciMidiFileTrack;
+
+//---------------------------------------------------------
+// MidiFile
+//---------------------------------------------------------
+
+class MidiFile {
+ int _error;
+ int format; // smf file format
+ int ntracks; // number of midi tracks
+ int _division;
+ MType _mtype;
+ MidiFileTrackList* _tracks;
+
+ int status, click;
+ int sstatus;
+ int lastport, lastchannel;
+ FILE* fp;
+ int curPos;
+
+ bool read(void*, size_t);
+ bool write(const void*, size_t);
+ void put(unsigned char c) { write(&c, 1); }
+ bool skip(size_t);
+ int readShort();
+ bool writeShort(int);
+ int readLong();
+ bool writeLong(int);
+ int getvl();
+ void putvl(unsigned);
+
+ bool readTrack(MidiFileTrack*);
+ bool writeTrack(const MidiFileTrack*);
+
+ int readEvent(MidiPlayEvent*, MidiFileTrack*);
+ void writeEvent(const MidiPlayEvent*);
+
+ public:
+ MidiFile(FILE* f);
+ ~MidiFile();
+ bool read();
+ bool write();
+ QString error();
+ MidiFileTrackList* trackList() { return _tracks; }
+ int tracks() const { return ntracks; }
+ void setTrackList(MidiFileTrackList* tr, int n) {
+ _tracks = tr;
+ ntracks = n;
+ }
+ void setDivision(int d) { _division = d; }
+ int division() const { return _division; }
+ void setMType(MType t) { _mtype = t; }
+ MType mtype() const { return _mtype; }
+ };
+
+#define XCHG_SHORT(x) ((((x)&0xFF)<<8) | (((x)>>8)&0xFF))
+#ifdef __i486__
+#define XCHG_LONG(x) \
+ ({ int __value; \
+ asm ("bswap %1; movl %1,%0" : "=g" (__value) : "r" (x)); \
+ __value; })
+#else
+#define XCHG_LONG(x) ((((x)&0xFF)<<24) | \
+ (((x)&0xFF00)<<8) | \
+ (((x)&0xFF0000)>>8) | \
+ (((x)>>24)&0xFF))
+#endif
+
+#if __BYTE_ORDER == __LITTLE_ENDIAN
+#define BE_SHORT(x) XCHG_SHORT(x)
+#define BE_LONG(x) XCHG_LONG(x)
+#else
+#define BE_SHORT(x) x
+#define BE_LONG(x) x
+#endif
+
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/midiport.cpp b/attic/muse2-oom/muse2/muse/midiport.cpp
new file mode 100644
index 00000000..02fed8d1
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiport.cpp
@@ -0,0 +1,1033 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midiport.cpp,v 1.21.2.15 2009/12/07 20:11:51 terminator356 Exp $
+//
+// (C) Copyright 2000-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+//#include "config.h"
+
+#include <QMenu>
+
+#include "mididev.h"
+#include "midiport.h"
+#include "midictrl.h"
+#include "midi.h"
+#include "minstrument.h"
+//#include "instruments/minstrument.h" // p4.0.2
+#include "xml.h"
+#include "globals.h"
+#include "mpevent.h"
+#include "synth.h"
+#include "app.h"
+#include "song.h"
+
+//#ifdef DSSI_SUPPORT
+//#include "dssihost.h"
+//#endif
+
+MidiPort midiPorts[MIDI_PORTS];
+
+//---------------------------------------------------------
+// initMidiPorts
+//---------------------------------------------------------
+
+void initMidiPorts()
+ {
+ for (int i = 0; i < MIDI_PORTS; ++i) {
+ MidiPort* port = &midiPorts[i];
+ ///port->setInstrument(genericMidiInstrument);
+ port->setInstrument(registerMidiInstrument("GM")); // Changed by Tim.
+ port->syncInfo().setPort(i);
+ }
+ }
+
+//---------------------------------------------------------
+// MidiPort
+//---------------------------------------------------------
+
+MidiPort::MidiPort()
+ : _state("not configured")
+ {
+ _defaultInChannels = 0;
+ _defaultOutChannels = 0;
+ _device = 0;
+ _instrument = 0;
+ _controller = new MidiCtrlValListList();
+ _foundInSongFile = false;
+
+ //
+ // create minimum set of managed controllers
+ // to make midi mixer operational
+ //
+ for (int i = 0; i < MIDI_CHANNELS; ++i) {
+ addManagedController(i, CTRL_PROGRAM);
+ addManagedController(i, CTRL_VOLUME);
+ addManagedController(i, CTRL_PANPOT);
+ _automationType[i] = AUTO_READ;
+ }
+ }
+
+//---------------------------------------------------------
+// MidiPort
+//---------------------------------------------------------
+
+MidiPort::~MidiPort()
+ {
+ delete _controller;
+ }
+
+//---------------------------------------------------------
+// guiVisible
+//---------------------------------------------------------
+
+bool MidiPort::guiVisible() const
+ {
+ return _instrument ? _instrument->guiVisible() : false;
+ }
+
+//---------------------------------------------------------
+// hasGui
+//---------------------------------------------------------
+
+bool MidiPort::hasGui() const
+ {
+ return _instrument ? _instrument->hasGui() : false;
+ }
+
+//---------------------------------------------------------
+// setDevice
+//---------------------------------------------------------
+
+void MidiPort::setMidiDevice(MidiDevice* dev)
+ {
+ if (_device) {
+ if (_device->isSynti())
+ _instrument = genericMidiInstrument;
+ _device->setPort(-1);
+ _device->close();
+ }
+ if (dev) {
+ for (int i = 0; i < MIDI_PORTS; ++i) {
+ MidiPort* mp = &midiPorts[i];
+ if (mp->device() == dev) {
+ if(dev->isSynti())
+ mp->setInstrument(genericMidiInstrument);
+ // move device
+ _state = mp->state();
+ mp->clearDevice();
+ break;
+ }
+ }
+ _device = dev;
+ if (_device->isSynti()) {
+ SynthI* s = (SynthI*)_device;
+ _instrument = s;
+ }
+ _state = _device->open();
+ _device->setPort(portno());
+
+ // By T356. Send all instrument controller initial (default) values to all midi channels now,
+ // except where explicitly initialized in the song.
+ // By sending ALL instrument controller initial values, even if those controllers are NOT
+ // in the song, we can ensure better consistency between songs.
+ // For example: A song is loaded which has a 'reverb level' controller initial value of '100'.
+ // Then a song is loaded which has no such controller (hence no explicit initial value).
+ // The 'reverb level' controller would still be at '100', and could adversely affect the song,
+ // but if the instrument has an available initial value of say '0', it will be used instead.
+ //
+ //if(_instrument)
+ // p3.3.39 NOT for syntis! Use midiState an/or initParams for that.
+ if(_instrument && !_device->isSynti())
+ {
+ MidiControllerList* cl = _instrument->controller();
+ MidiController* mc;
+ for(ciMidiController imc = cl->begin(); imc != cl->end(); ++imc)
+ {
+ //mc = *imc;
+ mc = imc->second;
+ for(int chan = 0; chan < MIDI_CHANNELS; ++chan)
+ {
+ ciMidiCtrlValList i;
+ // Look for an initial value for this midi controller, on this midi channel, in the song...
+ for(i = _controller->begin(); i != _controller->end(); ++i)
+ {
+ int channel = i->first >> 24;
+ int cntrl = i->first & 0xffffff;
+ int val = i->second->hwVal();
+ if(channel == chan && cntrl == mc->num() && val != CTRL_VAL_UNKNOWN)
+ break;
+ }
+ // If no initial value was found for this midi controller, on this midi channel, in the song...
+ if(i == _controller->end())
+ {
+ // If the instrument's midi controller has an initial value, send it now.
+ if(mc->initVal() != CTRL_VAL_UNKNOWN)
+ {
+ int ctl = mc->num();
+
+///#ifdef DSSI_SUPPORT
+ // Exclude dssi synths from this, as some of them have hundreds of controls.
+ // Another difference is dssi synth devices (usually) have readable default port values,
+ // unlike a midi output port, which cannot be queried for a current or default value,
+ // so we blindly send values here. Also some dssi have a different default mechanism or
+ // storage systems for parameters, with complex GUIs with their own manipulation schemes.
+ // Another difference is dssi controls are best manipulated as ladspa controls -
+ // (they ARE ladspa controls). This is stuff I mainly put for midi ports and MESS...
+ // I DO allow midi control of those ladspa controls, so our midi controls shall be updated here...
+ // p3.3.39 Only non-syntis! Use midiState an/or initParams for that.
+ ///if(!_device->isSynti() || (dynamic_cast<DssiSynthIF*>(((SynthI*)_device)->sif()) == 0))
+ ///{
+///#endif
+ // Note the addition of bias!
+ _device->putEvent(MidiPlayEvent(0, portno(), chan,
+ ME_CONTROLLER, ctl, mc->initVal() + mc->bias()));
+///#ifdef DSSI_SUPPORT
+ ///}
+///#endif
+
+ // Set it once so the 'last HW value' is set, and control knobs are positioned at the value...
+ //setHwCtrlState(chan, ctl, mc->initVal() + mc->bias());
+ // Set it again so that control labels show 'off'...
+ //setHwCtrlState(chan, ctl, CTRL_VAL_UNKNOWN);
+ setHwCtrlStates(chan, ctl, CTRL_VAL_UNKNOWN, mc->initVal() + mc->bias());
+ }
+ }
+ }
+ }
+ }
+
+ // init HW controller state
+ // p3.3.39 NOT for syntis! Use midiState an/or initParams for that.
+ if(!_device->isSynti())
+ {
+ for (iMidiCtrlValList i = _controller->begin(); i != _controller->end(); ++i) {
+ int channel = i->first >> 24;
+ int cntrl = i->first & 0xffffff;
+ int val = i->second->hwVal();
+ if (val != CTRL_VAL_UNKNOWN) {
+
+
+///#ifdef DSSI_SUPPORT
+ // Not for dssi synths...
+ ///if(!_device->isSynti() || (dynamic_cast<DssiSynthIF*>(((SynthI*)_device)->sif()) == 0))
+ ///{
+///#endif
+ _device->putEvent(MidiPlayEvent(0, portno(), channel,
+ ME_CONTROLLER, cntrl, val));
+///#ifdef DSSI_SUPPORT
+ ///}
+///#endif
+
+ // Set it once so the 'last HW value' is set, and control knobs are positioned at the value...
+ setHwCtrlState(channel, cntrl, val);
+ // Set it again so that control labels show 'off'...
+ //setHwCtrlState(channel, cntrl, CTRL_VAL_UNKNOWN);
+ //setHwCtrlStates(channel, cntrl, CTRL_VAL_UNKNOWN, val);
+ }
+ }
+ }
+ }
+
+ else
+ clearDevice();
+ }
+
+//---------------------------------------------------------
+// clearDevice
+//---------------------------------------------------------
+
+void MidiPort::clearDevice()
+ {
+ _device = 0;
+ _state = "not configured";
+ }
+
+//---------------------------------------------------------
+// portno
+//---------------------------------------------------------
+
+int MidiPort::portno() const
+ {
+ for (int i = 0; i < MIDI_PORTS; ++i) {
+ if (&midiPorts[i] == this)
+ return i;
+ }
+ return -1;
+ }
+
+//---------------------------------------------------------
+// midiPortsPopup
+//---------------------------------------------------------
+
+//QPopupMenu* midiPortsPopup(QWidget* parent)
+QMenu* midiPortsPopup(QWidget* parent, int checkPort)
+ {
+ QMenu* p = new QMenu(parent);
+ for (int i = 0; i < MIDI_PORTS; ++i) {
+ MidiPort* port = &midiPorts[i];
+ QString name;
+ name.sprintf("%d:%s", port->portno()+1, port->portname().toLatin1().constData());
+ QAction *act = p->addAction(name);
+ act->setData(i);
+
+ if(i == checkPort)
+ act->setChecked(true);
+ }
+ return p;
+ }
+
+//---------------------------------------------------------
+// portname
+//---------------------------------------------------------
+
+const QString& MidiPort::portname() const
+ {
+ //static const QString none("<none>");
+ static const QString none(QT_TRANSLATE_NOOP("@default", "<none>"));
+ if (_device)
+ return _device->name();
+ else
+ return none;
+ }
+
+//---------------------------------------------------------
+// tryCtrlInitVal
+//---------------------------------------------------------
+
+void MidiPort::tryCtrlInitVal(int chan, int ctl, int val)
+{
+ if(_instrument)
+ {
+ MidiControllerList* cl = _instrument->controller();
+ //for(ciMidiController imc = cl->begin(); imc != cl->end(); ++imc)
+ ciMidiController imc = cl->find(ctl);
+ if(imc != cl->end())
+ {
+ //MidiController* mc = *imc;
+ MidiController* mc = imc->second;
+ //int cnum = mc->num();
+ //if(cnum == ctl)
+ //{
+ int initval = mc->initVal();
+
+ // Initialize from either the instrument controller's initial value, or the supplied value.
+ if(initval != CTRL_VAL_UNKNOWN)
+ {
+ if(_device)
+ {
+ //MidiPlayEvent ev(song->cpos(), portno(), chan, ME_CONTROLLER, ctl, initval + mc->bias());
+ MidiPlayEvent ev(0, portno(), chan, ME_CONTROLLER, ctl, initval + mc->bias());
+ _device->putEvent(ev);
+ }
+ // Set it once so the 'last HW value' is set, and control knobs are positioned at the value...
+ //setHwCtrlState(chan, ctl, initval + mc->bias());
+ // Set it again so that control labels show 'off'...
+ //setHwCtrlState(chan, ctl, CTRL_VAL_UNKNOWN);
+ setHwCtrlStates(chan, ctl, CTRL_VAL_UNKNOWN, initval + mc->bias());
+
+ return;
+ }
+ }
+ }
+
+ if(_device)
+ {
+ //MidiPlayEvent ev(song->cpos(), portno(), chan, ME_CONTROLLER, ctl, val);
+ MidiPlayEvent ev(0, portno(), chan, ME_CONTROLLER, ctl, val);
+ _device->putEvent(ev);
+ }
+ // Set it once so the 'last HW value' is set, and control knobs are positioned at the value...
+ //setHwCtrlState(chan, ctl, val);
+ // Set it again so that control labels show 'off'...
+ //setHwCtrlState(chan, ctl, CTRL_VAL_UNKNOWN);
+ setHwCtrlStates(chan, ctl, CTRL_VAL_UNKNOWN, val);
+}
+
+//---------------------------------------------------------
+// sendGmInitValues
+//---------------------------------------------------------
+
+void MidiPort::sendGmInitValues()
+{
+ for (int i = 0; i < MIDI_CHANNELS; ++i) {
+ // Changed by T356.
+ //setHwCtrlState(i, CTRL_PROGRAM, 0);
+ //setHwCtrlState(i, CTRL_PITCH, 0);
+ //setHwCtrlState(i, CTRL_VOLUME, 100);
+ //setHwCtrlState(i, CTRL_PANPOT, 64);
+ //setHwCtrlState(i, CTRL_REVERB_SEND, 40);
+ //setHwCtrlState(i, CTRL_CHORUS_SEND, 0);
+
+ // By T356. Initialize from instrument controller if it has an initial value, otherwise use the specified value.
+ // Tested: Ultimately, a track's controller stored values take priority by sending any 'zero time' value
+ // AFTER these GM/GS/XG init routines are called via initDevices().
+ tryCtrlInitVal(i, CTRL_PROGRAM, 0);
+ tryCtrlInitVal(i, CTRL_PITCH, 0);
+ tryCtrlInitVal(i, CTRL_VOLUME, 100);
+ tryCtrlInitVal(i, CTRL_PANPOT, 64);
+ tryCtrlInitVal(i, CTRL_REVERB_SEND, 40);
+ tryCtrlInitVal(i, CTRL_CHORUS_SEND, 0);
+ }
+}
+
+//---------------------------------------------------------
+// sendGsInitValues
+//---------------------------------------------------------
+
+void MidiPort::sendGsInitValues()
+{
+ sendGmInitValues();
+}
+
+//---------------------------------------------------------
+// sendXgInitValues
+//---------------------------------------------------------
+
+void MidiPort::sendXgInitValues()
+{
+ for (int i = 0; i < MIDI_CHANNELS; ++i) {
+ // Changed by T356.
+ //setHwCtrlState(i, CTRL_PROGRAM, 0);
+ //setHwCtrlState(i, CTRL_MODULATION, 0);
+ //setHwCtrlState(i, CTRL_PORTAMENTO_TIME, 0);
+ //setHwCtrlState(i, CTRL_VOLUME, 0x64);
+ //setHwCtrlState(i, CTRL_PANPOT, 0x40);
+ //setHwCtrlState(i, CTRL_EXPRESSION, 0x7f);
+ //setHwCtrlState(i, CTRL_SUSTAIN, 0x0);
+ //setHwCtrlState(i, CTRL_PORTAMENTO, 0x0);
+ //setHwCtrlState(i, CTRL_SOSTENUTO, 0x0);
+ //setHwCtrlState(i, CTRL_SOFT_PEDAL, 0x0);
+ //setHwCtrlState(i, CTRL_HARMONIC_CONTENT, 0x40);
+ //setHwCtrlState(i, CTRL_RELEASE_TIME, 0x40);
+ //setHwCtrlState(i, CTRL_ATTACK_TIME, 0x40);
+ //setHwCtrlState(i, CTRL_BRIGHTNESS, 0x40);
+ //setHwCtrlState(i, CTRL_REVERB_SEND, 0x28);
+ //setHwCtrlState(i, CTRL_CHORUS_SEND, 0x0);
+ //setHwCtrlState(i, CTRL_VARIATION_SEND, 0x0);
+
+ // By T356. Initialize from instrument controller if it has an initial value, otherwise use the specified value.
+ tryCtrlInitVal(i, CTRL_PROGRAM, 0);
+ tryCtrlInitVal(i, CTRL_MODULATION, 0);
+ tryCtrlInitVal(i, CTRL_PORTAMENTO_TIME, 0);
+ tryCtrlInitVal(i, CTRL_VOLUME, 0x64);
+ tryCtrlInitVal(i, CTRL_PANPOT, 0x40);
+ tryCtrlInitVal(i, CTRL_EXPRESSION, 0x7f);
+ tryCtrlInitVal(i, CTRL_SUSTAIN, 0x0);
+ tryCtrlInitVal(i, CTRL_PORTAMENTO, 0x0);
+ tryCtrlInitVal(i, CTRL_SOSTENUTO, 0x0);
+ tryCtrlInitVal(i, CTRL_SOFT_PEDAL, 0x0);
+ tryCtrlInitVal(i, CTRL_HARMONIC_CONTENT, 0x40);
+ tryCtrlInitVal(i, CTRL_RELEASE_TIME, 0x40);
+ tryCtrlInitVal(i, CTRL_ATTACK_TIME, 0x40);
+ tryCtrlInitVal(i, CTRL_BRIGHTNESS, 0x40);
+ tryCtrlInitVal(i, CTRL_REVERB_SEND, 0x28);
+ tryCtrlInitVal(i, CTRL_CHORUS_SEND, 0x0);
+ tryCtrlInitVal(i, CTRL_VARIATION_SEND, 0x0);
+ }
+}
+
+//---------------------------------------------------------
+// sendGmOn
+// send GM-On message to midi device and keep track
+// of device state
+//---------------------------------------------------------
+
+void MidiPort::sendGmOn()
+ {
+ sendSysex(gmOnMsg, gmOnMsgLen);
+ }
+
+//---------------------------------------------------------
+// sendGsOn
+// send Roland GS-On message to midi device and keep track
+// of device state
+//---------------------------------------------------------
+
+void MidiPort::sendGsOn()
+ {
+ //static unsigned char data2[] = { 0x41, 0x10, 0x42, 0x12, 0x40, 0x01, 0x33, 0x50, 0x3c };
+ //static unsigned char data3[] = { 0x41, 0x10, 0x42, 0x12, 0x40, 0x01, 0x34, 0x50, 0x3b };
+ //sendSysex(data2, sizeof(data2));
+ //sendSysex(data3, sizeof(data3));
+ sendSysex(gsOnMsg2, gsOnMsg2Len);
+ sendSysex(gsOnMsg3, gsOnMsg3Len);
+ }
+
+//---------------------------------------------------------
+// sendXgOn
+// send Yamaha XG-On message to midi device and keep track
+// of device state
+//---------------------------------------------------------
+
+void MidiPort::sendXgOn()
+ {
+ sendSysex(xgOnMsg, xgOnMsgLen);
+ }
+
+//---------------------------------------------------------
+// sendSysex
+// send SYSEX message to midi device
+//---------------------------------------------------------
+
+void MidiPort::sendSysex(const unsigned char* p, int n)
+ {
+ if (_device) {
+ MidiPlayEvent event(0, 0, ME_SYSEX, p, n);
+ _device->putEvent(event);
+ }
+ }
+
+//---------------------------------------------------------
+// sendMMCLocate
+//---------------------------------------------------------
+
+void MidiPort::sendMMCLocate(unsigned char ht, unsigned char m, unsigned char s, unsigned char f, unsigned char sf, int devid)
+{
+ unsigned char msg[mmcLocateMsgLen];
+ memcpy(msg, mmcLocateMsg, mmcLocateMsgLen);
+ if(devid != -1)
+ msg[1] = devid;
+ else
+ msg[1] = _syncInfo.idOut();
+ msg[6] = ht;
+ msg[7] = m;
+ msg[8] = s;
+ msg[9] = f;
+ msg[10] = sf;
+ sendSysex(msg, mmcLocateMsgLen);
+}
+
+//---------------------------------------------------------
+// sendMMCStop
+//---------------------------------------------------------
+
+void MidiPort::sendMMCStop(int devid)
+{
+ unsigned char msg[mmcStopMsgLen];
+ memcpy(msg, mmcStopMsg, mmcStopMsgLen);
+ if(devid != -1)
+ msg[1] = devid;
+ else
+ msg[1] = _syncInfo.idOut();
+ sendSysex(msg, mmcStopMsgLen);
+}
+
+//---------------------------------------------------------
+// sendMMCDeferredPlay
+//---------------------------------------------------------
+
+void MidiPort::sendMMCDeferredPlay(int devid)
+{
+ unsigned char msg[mmcDeferredPlayMsgLen];
+ memcpy(msg, mmcDeferredPlayMsg, mmcDeferredPlayMsgLen);
+ if(devid != -1)
+ msg[1] = devid;
+ else
+ msg[1] = _syncInfo.idOut();
+ sendSysex(msg, mmcDeferredPlayMsgLen);
+}
+
+//---------------------------------------------------------
+// sendStart
+//---------------------------------------------------------
+
+void MidiPort::sendStart()
+ {
+ if (_device) {
+ MidiPlayEvent event(0, 0, 0, ME_START, 0, 0);
+ _device->putEvent(event);
+ }
+ }
+
+//---------------------------------------------------------
+// sendStop
+//---------------------------------------------------------
+
+void MidiPort::sendStop()
+ {
+ if (_device) {
+ MidiPlayEvent event(0, 0, 0, ME_STOP, 0, 0);
+ _device->putEvent(event);
+ }
+ }
+
+//---------------------------------------------------------
+// sendClock
+//---------------------------------------------------------
+
+void MidiPort::sendClock()
+ {
+ if (_device) {
+ MidiPlayEvent event(0, 0, 0, ME_CLOCK, 0, 0);
+ _device->putEvent(event);
+ }
+ }
+
+//---------------------------------------------------------
+// sendContinue
+//---------------------------------------------------------
+
+void MidiPort::sendContinue()
+ {
+ if (_device) {
+ MidiPlayEvent event(0, 0, 0, ME_CONTINUE, 0, 0);
+ _device->putEvent(event);
+ }
+ }
+
+//---------------------------------------------------------
+// sendSongpos
+//---------------------------------------------------------
+
+void MidiPort::sendSongpos(int pos)
+ {
+ if (_device) {
+ MidiPlayEvent event(0, 0, 0, ME_SONGPOS, pos, 0);
+ _device->putEvent(event);
+ }
+ }
+
+//---------------------------------------------------------
+// addManagedController
+//---------------------------------------------------------
+
+MidiCtrlValList* MidiPort::addManagedController(int channel, int ctrl)
+ {
+ iMidiCtrlValList cl = _controller->find(channel, ctrl);
+ if (cl == _controller->end()) {
+ MidiCtrlValList* pvl = new MidiCtrlValList(ctrl);
+ _controller->add(channel, pvl);
+ return pvl;
+ }
+ else
+ return cl->second;
+ }
+
+//---------------------------------------------------------
+// limitValToInstrCtlRange
+//---------------------------------------------------------
+
+int MidiPort::limitValToInstrCtlRange(MidiController* mc, int val)
+{
+ if(!_instrument || !mc || val == CTRL_VAL_UNKNOWN)
+ return val;
+
+ //MidiController* mc = imc->second;
+ int mn = mc->minVal();
+ int mx = mc->maxVal();
+ int bias = mc->bias();
+
+ // Subtract controller bias from value.
+ val -= bias;
+
+ // Limit value to controller range.
+ if(val < mn)
+ val = mn;
+ else
+ if(val > mx)
+ val = mx;
+
+ // Re-add controller bias to value.
+ val += bias;
+
+ return val;
+}
+
+int MidiPort::limitValToInstrCtlRange(int ctl, int val)
+{
+ if(!_instrument || val == CTRL_VAL_UNKNOWN)
+ return val;
+
+ MidiControllerList* cl = _instrument->controller();
+
+ // Is it a drum controller?
+ MidiController *mc = drumController(ctl);
+ if(!mc)
+ {
+ // It's not a drum controller. Find it as a regular controller instead.
+ iMidiController imc = cl->find(ctl);
+ if(imc != cl->end())
+ mc = imc->second;
+ }
+
+ // If it's a valid controller, limit the value to the instrument controller range.
+ if(mc)
+ return limitValToInstrCtlRange(mc, val);
+
+ return val;
+}
+
+//---------------------------------------------------------
+// sendEvent
+// return true, if event cannot be delivered
+//---------------------------------------------------------
+
+bool MidiPort::sendEvent(const MidiPlayEvent& ev)
+ {
+ if (ev.type() == ME_CONTROLLER) {
+
+// printf("current sustain %d %d %d\n", hwCtrlState(ev.channel(),CTRL_SUSTAIN), CTRL_SUSTAIN, ev.dataA());
+
+ // Added by T356.
+ int da = ev.dataA();
+ int db = ev.dataB();
+ /*
+ // Is it a drum controller?
+ MidiController* mc = drumController(da);
+ if(mc)
+ {
+ DrumMap* dm = &drumMap[da & 0x7f];
+ int port = dm->port;
+ MidiPort* mp = &midiPorts[port];
+ // Is it NOT for this MidiPort?
+ if(mp && (mp != this))
+ {
+ // Redirect the event to the mapped port and channel...
+ da = (da & ~0xff) | (dm->anote & 0x7f);
+ db = mp->limitValToInstrCtlRange(da, db);
+ MidiPlayEvent nev(ev.time(), port, dm->channel, ME_CONTROLLER, da, db);
+ if(!mp->setHwCtrlState(ev.channel(), da, db))
+ return false;
+ if(!mp->device())
+ return true;
+ return mp->device()->putEvent(nev);
+ }
+ }
+ */
+ db = limitValToInstrCtlRange(da, db);
+
+
+ // Removed by T356.
+ //
+ // optimize controller settings
+ //
+ //if (hwCtrlState(ev.channel(), ev.dataA()) == ev.dataB()) {
+// printf("optimize ctrl %d %x val %d\n", ev.dataA(), ev.dataA(), ev.dataB());
+ // return false;
+ // }
+// printf("set HW Ctrl State ch:%d 0x%x 0x%x\n", ev.channel(), ev.dataA(), ev.dataB());
+ if(!setHwCtrlState(ev.channel(), da, db))
+ return false;
+ }
+ else
+ if (ev.type() == ME_PITCHBEND)
+ {
+ int da = limitValToInstrCtlRange(CTRL_PITCH, ev.dataA());
+ // Removed by T356.
+ //if (hwCtrlState(ev.channel(), CTRL_PITCH) == ev.dataA())
+ // return false;
+
+ if(!setHwCtrlState(ev.channel(), CTRL_PITCH, da))
+ return false;
+ }
+ else
+ if (ev.type() == ME_PROGRAM)
+ {
+ if(!setHwCtrlState(ev.channel(), CTRL_PROGRAM, ev.dataA()))
+ return false;
+ }
+
+
+ if (!_device)
+ return true;
+ return _device->putEvent(ev);
+ }
+
+//---------------------------------------------------------
+// lastValidHWCtrlState
+//---------------------------------------------------------
+
+int MidiPort::lastValidHWCtrlState(int ch, int ctrl) const
+{
+ ch &= 0xff;
+ iMidiCtrlValList cl = _controller->find(ch, ctrl);
+ if (cl == _controller->end()) {
+ return CTRL_VAL_UNKNOWN;
+ }
+ MidiCtrlValList* vl = cl->second;
+ return vl->lastValidHWVal();
+}
+
+//---------------------------------------------------------
+// hwCtrlState
+//---------------------------------------------------------
+
+int MidiPort::hwCtrlState(int ch, int ctrl) const
+ {
+ ch &= 0xff;
+ iMidiCtrlValList cl = _controller->find(ch, ctrl);
+ if (cl == _controller->end()) {
+ //if (debugMsg)
+ // printf("hwCtrlState: chan %d ctrl 0x%x not found\n", ch, ctrl);
+ return CTRL_VAL_UNKNOWN;
+ }
+ MidiCtrlValList* vl = cl->second;
+ return vl->hwVal();
+ }
+
+//---------------------------------------------------------
+// setHwCtrlState
+// Returns false if value is already equal, true if value is set.
+//---------------------------------------------------------
+
+bool MidiPort::setHwCtrlState(int ch, int ctrl, int val)
+ {
+ // Changed by T356.
+ //iMidiCtrlValList cl = _controller->find(ch, ctrl);
+ //if (cl == _controller->end()) {
+ // try to add new controller
+ // addManagedController(ch, ctrl);
+// muse->importController(ch, this, ctrl);
+ // cl = _controller->find(ch, ctrl);
+ // if (cl == _controller->end()) {
+ // if (debugMsg)
+ // printf("setHwCtrlState(%d,0x%x,0x%x): not found\n", ch, ctrl, val);
+ // return;
+ // }
+ // }
+ //MidiCtrlValList* vl = cl->second;
+// printf("setHwCtrlState ch %d ctrl %x val %x\n", ch, ctrl, val);
+
+ // By T356. This will create a new value list if necessary, otherwise it returns the existing list.
+ MidiCtrlValList* vl = addManagedController(ch, ctrl);
+
+ return vl->setHwVal(val);
+ }
+
+//---------------------------------------------------------
+// setHwCtrlStates
+// Sets current and last HW values.
+// Handy for forcing labels to show 'off' and knobs to show specific values
+// without having to send two messages.
+// Returns false if both values are already set, true if either value is changed.
+//---------------------------------------------------------
+
+bool MidiPort::setHwCtrlStates(int ch, int ctrl, int val, int lastval)
+ {
+ // This will create a new value list if necessary, otherwise it returns the existing list.
+ MidiCtrlValList* vl = addManagedController(ch, ctrl);
+
+ return vl->setHwVals(val, lastval);
+ }
+
+// Removed by T356.
+//---------------------------------------------------------
+// setCtrl
+// return true if new controller value added
+//---------------------------------------------------------
+
+//bool MidiPort::setCtrl(int ch, int tick, int ctrl, int val)
+// {
+// if (debugMsg)
+// printf("setCtrl(tick=%d val=%d)\n",tick,val);
+// iMidiCtrlValList cl = _controller->find(ch, ctrl);
+// if (cl == _controller->end()) {
+// if (debugMsg)
+// printf("setCtrl: controller 0x%x for channel %d not found\n", ctrl, ch);
+// return false;
+// }
+// return cl->second->add(tick, val);
+// }
+
+//---------------------------------------------------------
+// setControllerVal
+// This function sets a controller value,
+// creating the controller if necessary.
+// Returns true if a value was actually added or replaced.
+//---------------------------------------------------------
+
+bool MidiPort::setControllerVal(int ch, int tick, int ctrl, int val, Part* part)
+{
+ MidiCtrlValList* pvl;
+ iMidiCtrlValList cl = _controller->find(ch, ctrl);
+ if (cl == _controller->end())
+ {
+ pvl = new MidiCtrlValList(ctrl);
+ _controller->add(ch, pvl);
+ }
+ else
+ pvl = cl->second;
+
+ return pvl->addMCtlVal(tick, val, part);
+}
+
+//---------------------------------------------------------
+// getCtrl
+//---------------------------------------------------------
+
+int MidiPort::getCtrl(int ch, int tick, int ctrl) const
+ {
+ iMidiCtrlValList cl = _controller->find(ch, ctrl);
+ if (cl == _controller->end()) {
+ //if (debugMsg)
+ // printf("getCtrl: controller %d(0x%x) for channel %d not found size %zd\n",
+ // ctrl, ctrl, ch, _controller->size());
+ return CTRL_VAL_UNKNOWN;
+ }
+ return cl->second->value(tick);
+ }
+
+int MidiPort::getCtrl(int ch, int tick, int ctrl, Part* part) const
+ {
+ iMidiCtrlValList cl = _controller->find(ch, ctrl);
+ if (cl == _controller->end()) {
+ //if (debugMsg)
+ // printf("getCtrl: controller %d(0x%x) for channel %d not found size %zd\n",
+ // ctrl, ctrl, ch, _controller->size());
+ return CTRL_VAL_UNKNOWN;
+ }
+ return cl->second->value(tick, part);
+ }
+//---------------------------------------------------------
+// deleteController
+//---------------------------------------------------------
+
+void MidiPort::deleteController(int ch, int tick, int ctrl, Part* part)
+ {
+ iMidiCtrlValList cl = _controller->find(ch, ctrl);
+ if (cl == _controller->end()) {
+ if (debugMsg)
+ printf("deleteController: controller %d(0x%x) for channel %d not found size %zd\n",
+ ctrl, ctrl, ch, _controller->size());
+ return;
+ }
+
+ cl->second->delMCtlVal(tick, part);
+ }
+
+//---------------------------------------------------------
+// midiController
+//---------------------------------------------------------
+
+MidiController* MidiPort::midiController(int num) const
+ {
+ if (_instrument) {
+ MidiControllerList* mcl = _instrument->controller();
+ for (iMidiController i = mcl->begin(); i != mcl->end(); ++i) {
+ int cn = i->second->num();
+ if (cn == num)
+ return i->second;
+ // wildcard?
+ if (((cn & 0xff) == 0xff) && ((cn & ~0xff) == (num & ~0xff)))
+ return i->second;
+ }
+ }
+
+ for (iMidiController i = defaultMidiController.begin(); i != defaultMidiController.end(); ++i) {
+ int cn = i->second->num();
+ if (cn == num)
+ return i->second;
+ // wildcard?
+ if (((cn & 0xff) == 0xff) && ((cn & ~0xff) == (num & ~0xff)))
+ return i->second;
+ }
+
+
+ QString name = midiCtrlName(num);
+ int min = 0;
+ int max = 127;
+
+ MidiController::ControllerType t = midiControllerType(num);
+ switch (t) {
+ case MidiController::RPN:
+ case MidiController::NRPN:
+ case MidiController::Controller7:
+ max = 127;
+ break;
+ case MidiController::Controller14:
+ case MidiController::RPN14:
+ case MidiController::NRPN14:
+ max = 16383;
+ break;
+ case MidiController::Program:
+ max = 0xffffff;
+ break;
+ case MidiController::Pitch:
+ max = 8191;
+ min = -8192;
+ break;
+ case MidiController::Velo: // cannot happen
+ break;
+ }
+ MidiController* c = new MidiController(name, num, min, max, 0);
+ defaultMidiController.add(c);
+ return c;
+ }
+
+//---------------------------------------------------------
+// drumController
+// Returns instrument drum controller if ctl is a drum controller number.
+// Otherwise returns zero.
+//---------------------------------------------------------
+
+MidiController* MidiPort::drumController(int ctl)
+{
+ if(!_instrument)
+ return 0;
+
+ MidiControllerList* cl = _instrument->controller();
+
+ // If it's an RPN, NRPN, RPN14, or NRPN14 controller...
+ if(((ctl - CTRL_RPN_OFFSET >= 0) && (ctl - CTRL_RPN_OFFSET <= 0xffff)) ||
+ ((ctl - CTRL_NRPN_OFFSET >= 0) && (ctl - CTRL_NRPN_OFFSET <= 0xffff)) ||
+ ((ctl - CTRL_RPN14_OFFSET >= 0) && (ctl - CTRL_RPN14_OFFSET <= 0xffff)) ||
+ ((ctl - CTRL_NRPN14_OFFSET >= 0) && (ctl - CTRL_NRPN14_OFFSET <= 0xffff)))
+ {
+ // Does the instrument have a drum controller to match this controller's number?
+ iMidiController imc = cl->find(ctl | 0xff);
+ if(imc != cl->end())
+ // Yes, it's a drum controller. Return a pointer to it.
+ return imc->second;
+ }
+
+ return 0;
+}
+
+int MidiPort::nullSendValue()
+{
+ return _instrument ? _instrument->nullSendValue() : -1;
+}
+
+void MidiPort::setNullSendValue(int v)
+{
+ if(_instrument)
+ _instrument->setNullSendValue(v);
+}
+
+//---------------------------------------------------------
+// writeRouting // p3.3.50
+//---------------------------------------------------------
+
+void MidiPort::writeRouting(int level, Xml& xml) const
+{
+ // If this device is not actually in use by the song, do not write any routes.
+ // This prevents bogus routes from being saved and propagated in the med file.
+ if(!device())
+ return;
+
+ QString s;
+
+ for (ciRoute r = _outRoutes.begin(); r != _outRoutes.end(); ++r)
+ {
+ if(r->type == Route::TRACK_ROUTE && !r->name().isEmpty())
+ {
+ //xml.tag(level++, "Route");
+
+ s = QT_TRANSLATE_NOOP("@default", "Route");
+ if(r->channel != -1 && r->channel != 0)
+ s += QString(QT_TRANSLATE_NOOP("@default", " channelMask=\"%1\"")).arg(r->channel); // Use new channel mask.
+ xml.tag(level++, s.toLatin1().constData());
+
+ xml.tag(level, "source mport=\"%d\"/", portno());
+
+ s = QT_TRANSLATE_NOOP("@default", "dest");
+ s += QString(QT_TRANSLATE_NOOP("@default", " name=\"%1\"/")).arg(Xml::xmlString(r->name()));
+ xml.tag(level, s.toLatin1().constData());
+
+ xml.etag(level--, "Route");
+ }
+ }
+}
+
diff --git a/attic/muse2-oom/muse2/muse/midiport.h b/attic/muse2-oom/muse2/muse/midiport.h
new file mode 100644
index 00000000..7ee83cc9
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiport.h
@@ -0,0 +1,135 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midiport.h,v 1.9.2.6 2009/11/17 22:08:22 terminator356 Exp $
+//
+// (C) Copyright 1999-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MIDIPORT_H__
+#define __MIDIPORT_H__
+
+#include "globaldefs.h"
+#include "sync.h"
+#include "route.h"
+
+class MidiDevice;
+class MidiInstrument;
+class MidiCtrlValListList;
+class MidiPlayEvent;
+class MidiController;
+class MidiCtrlValList;
+class Part;
+//class MidiSyncInfo;
+
+//---------------------------------------------------------
+// MidiPort
+//---------------------------------------------------------
+
+class MidiPort {
+ MidiCtrlValListList* _controller;
+ MidiDevice* _device;
+ QString _state; // result of device open
+ MidiInstrument* _instrument;
+ AutomationType _automationType[MIDI_CHANNELS];
+ // Holds sync settings and detection monitors.
+ MidiSyncInfo _syncInfo;
+ // p3.3.50 Just a flag to say the port was found in the song file, even if it has no device right now.
+ bool _foundInSongFile;
+ // When creating a new midi track, add these global default channel routes to/from this port. Ignored if 0.
+ int _defaultInChannels; // These are bit-wise channel masks.
+ int _defaultOutChannels; //
+
+ RouteList _inRoutes, _outRoutes;
+
+ void clearDevice();
+
+ public:
+ MidiPort();
+ ~MidiPort();
+
+ //
+ // manipulate active midi controller
+ //
+ MidiCtrlValListList* controller() { return _controller; }
+ int getCtrl(int ch, int tick, int ctrl) const;
+ int getCtrl(int ch, int tick, int ctrl, Part* part) const;
+ // Removed by T356.
+ //bool setCtrl(int ch, int tick, int ctrl, int val);
+ bool setControllerVal(int ch, int tick, int ctrl, int val, Part* part);
+ // Can be CTRL_VAL_UNKNOWN until a valid state is set
+ int lastValidHWCtrlState(int ch, int ctrl) const;
+ int hwCtrlState(int ch, int ctrl) const;
+ bool setHwCtrlState(int ch, int ctrl, int val);
+ bool setHwCtrlStates(int ch, int ctrl, int val, int lastval);
+ void deleteController(int ch, int tick, int ctrl, Part* part);
+
+ bool guiVisible() const;
+ bool hasGui() const;
+
+ int portno() const;
+ bool foundInSongFile() const { return _foundInSongFile; }
+ void setFoundInSongFile(bool b) { _foundInSongFile = b; }
+
+ MidiDevice* device() const { return _device; }
+ const QString& state() const { return _state; }
+ void setState(const QString& s) { _state = s; }
+ void setMidiDevice(MidiDevice* dev);
+ const QString& portname() const;
+ MidiInstrument* instrument() const { return _instrument; }
+ void setInstrument(MidiInstrument* i) { _instrument = i; }
+ MidiController* midiController(int num) const;
+ MidiCtrlValList* addManagedController(int channel, int ctrl);
+ void tryCtrlInitVal(int chan, int ctl, int val);
+ int limitValToInstrCtlRange(int ctl, int val);
+ int limitValToInstrCtlRange(MidiController* mc, int val);
+ MidiController* drumController(int ctl);
+ int nullSendValue();
+ void setNullSendValue(int v);
+
+ int defaultInChannels() const { return _defaultInChannels; }
+ int defaultOutChannels() const { return _defaultOutChannels; }
+ void setDefaultInChannels(int c) { _defaultInChannels = c; }
+ void setDefaultOutChannels(int c) { _defaultOutChannels = c; }
+ RouteList* inRoutes() { return &_inRoutes; }
+ RouteList* outRoutes() { return &_outRoutes; }
+ bool noInRoute() const { return _inRoutes.empty(); }
+ bool noOutRoute() const { return _outRoutes.empty(); }
+ void writeRouting(int, Xml&) const;
+
+ // send events to midi device and keep track of
+ // device state:
+ void sendGmOn();
+ void sendGsOn();
+ void sendXgOn();
+ void sendGmInitValues();
+ void sendGsInitValues();
+ void sendXgInitValues();
+ void sendStart();
+ void sendStop();
+ void sendContinue();
+ void sendSongpos(int);
+ void sendClock();
+ void sendSysex(const unsigned char* p, int n);
+ void sendMMCLocate(unsigned char ht, unsigned char m,
+ unsigned char s, unsigned char f, unsigned char sf, int devid = -1);
+ void sendMMCStop(int devid = -1);
+ void sendMMCDeferredPlay(int devid = -1);
+
+ bool sendEvent(const MidiPlayEvent&);
+ AutomationType automationType(int channel) { return _automationType[channel]; }
+ void setAutomationType(int channel, AutomationType t) {
+ _automationType[channel] = t;
+ }
+ MidiSyncInfo& syncInfo() { return _syncInfo; }
+ };
+
+extern MidiPort midiPorts[MIDI_PORTS];
+extern void initMidiPorts();
+
+class QMenu;
+class QWidget;
+//extern QPopupMenu* midiPortsPopup(QWidget*);
+extern QMenu* midiPortsPopup(QWidget* parent = 0, int checkPort = -1);
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/midiseq.cpp b/attic/muse2-oom/muse2/muse/midiseq.cpp
new file mode 100644
index 00000000..8aabcbbb
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiseq.cpp
@@ -0,0 +1,766 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midiseq.cpp,v 1.30.2.21 2009/12/20 05:00:35 terminator356 Exp $
+//
+// high priority task for scheduling midi events
+//
+// (C) Copyright 2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QMessageBox>
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <sys/ioctl.h>
+#include <poll.h>
+#include <math.h>
+
+#include "globals.h"
+#include "midi.h"
+#include "midiseq.h"
+#include "midiport.h"
+#include "mididev.h"
+#include "midictrl.h"
+#include "audio.h"
+#include "driver/alsamidi.h"
+#include "driver/jackmidi.h"
+#include "sync.h"
+#include "synth.h"
+#include "song.h"
+#include "gconfig.h"
+
+MidiSeq* midiSeq;
+int MidiSeq::ticker = 0;
+volatile bool midiBusy=false;
+
+
+//---------------------------------------------------------
+// readMsg
+//---------------------------------------------------------
+
+static void readMsg(void* p, void*)
+ {
+
+ MidiSeq* at = (MidiSeq*)p;
+ at->readMsg();
+ }
+
+//---------------------------------------------------------
+// processMsg
+//---------------------------------------------------------
+
+void MidiSeq::processMsg(const ThreadMsg* m)
+ {
+ AudioMsg* msg = (AudioMsg*)m;
+ switch(msg->id) {
+ case MS_PROCESS:
+ audio->processMidi();
+ break;
+ case SEQM_SEEK:
+ processSeek();
+ break;
+ case MS_STOP:
+ processStop();
+ break;
+ case MS_SET_RTC:
+ doSetuid();
+ setRtcTicks();
+ undoSetuid();
+ break;
+ case MS_UPDATE_POLL_FD:
+ updatePollFd();
+ break;
+ case SEQM_ADD_TRACK:
+ song->insertTrack2(msg->track, msg->ival);
+ updatePollFd();
+ break;
+ case SEQM_REMOVE_TRACK:
+ song->cmdRemoveTrack(msg->track);
+ updatePollFd();
+ break;
+ case SEQM_CHANGE_TRACK:
+ song->changeTrack((Track*)(msg->p1), (Track*)(msg->p2));
+ updatePollFd();
+ break;
+ case SEQM_ADD_PART:
+ song->cmdAddPart((Part*)msg->p1);
+ break;
+ case SEQM_REMOVE_PART:
+ song->cmdRemovePart((Part*)msg->p1);
+ break;
+ case SEQM_CHANGE_PART:
+ //song->cmdChangePart((Part*)msg->p1, (Part*)msg->p2);
+ song->cmdChangePart((Part*)msg->p1, (Part*)msg->p2, msg->a, msg->b);
+ break;
+ case SEQM_SET_TRACK_OUT_CHAN:
+ {
+ MidiTrack* track = (MidiTrack*)(msg->p1);
+ track->setOutChanAndUpdate(msg->a);
+ }
+ break;
+ case SEQM_SET_TRACK_OUT_PORT:
+ {
+ MidiTrack* track = (MidiTrack*)(msg->p1);
+ track->setOutPortAndUpdate(msg->a);
+ }
+ break;
+ case SEQM_REMAP_PORT_DRUM_CTL_EVS:
+ song->remapPortDrumCtrlEvents(msg->ival, msg->a, msg->b, msg->c);
+ break;
+ case SEQM_CHANGE_ALL_PORT_DRUM_CTL_EVS:
+ song->changeAllPortDrumCtrlEvents((bool)msg->a, (bool)msg->b);
+ break;
+ case SEQM_SET_MIDI_DEVICE:
+ ((MidiPort*)(msg->p1))->setMidiDevice((MidiDevice*)(msg->p2));
+ updatePollFd();
+ break;
+ case SEQM_IDLE:
+ idle = msg->a;
+ break;
+ default:
+ printf("MidiSeq::processMsg() unknown id %d\n", msg->id);
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// processStop
+//---------------------------------------------------------
+
+void MidiSeq::processStop()
+ {
+ // p3.3.28
+ playStateExt = false; // not playing
+
+ //
+ // stop stuck notes
+ //
+ for (iMidiDevice id = midiDevices.begin(); id != midiDevices.end(); ++id) {
+ MidiDevice* md = *id;
+ if (md->midiPort() == -1)
+ continue;
+ MPEventList* pel = md->playEvents();
+ MPEventList* sel = md->stuckNotes();
+ pel->clear();
+ for (iMPEvent i = sel->begin(); i != sel->end(); ++i) {
+ MidiPlayEvent ev = *i;
+ ev.setTime(0);
+ pel->add(ev);
+ }
+ sel->clear();
+ md->setNextPlayEvent(pel->begin());
+ }
+ }
+
+//---------------------------------------------------------
+// processSeek
+//---------------------------------------------------------
+
+void MidiSeq::processSeek()
+ {
+ int pos = audio->tickPos();
+ if (pos == 0 && !song->record())
+ audio->initDevices();
+
+ //---------------------------------------------------
+ // set all controller
+ //---------------------------------------------------
+
+ for (iMidiDevice i = midiDevices.begin(); i != midiDevices.end(); ++i) {
+ MidiDevice* dev = *i;
+ int port = dev->midiPort();
+ if (port == -1)
+ continue;
+ MidiPort* mp = &midiPorts[port];
+ MidiCtrlValListList* cll = mp->controller();
+
+ MPEventList* el = dev->playEvents();
+
+ if (audio->isPlaying()) {
+ // stop all notes
+ el->clear();
+ MPEventList* sel = dev->stuckNotes();
+ for (iMPEvent i = sel->begin(); i != sel->end(); ++i) {
+ MidiPlayEvent ev = *i;
+ ev.setTime(0);
+ el->add(ev);
+ }
+ sel->clear();
+ }
+ else
+ el->erase(el->begin(), dev->nextPlayEvent());
+
+ for (iMidiCtrlValList ivl = cll->begin(); ivl != cll->end(); ++ivl) {
+ MidiCtrlValList* vl = ivl->second;
+ //int val = vl->value(pos);
+ //if (val != CTRL_VAL_UNKNOWN) {
+ // int channel = ivl->first >> 24;
+ // el->add(MidiPlayEvent(0, port, channel, ME_CONTROLLER, vl->num(), val));
+ // }
+ iMidiCtrlVal imcv = vl->iValue(pos);
+ if(imcv != vl->end())
+ {
+ Part* p = imcv->second.part;
+ unsigned t = (unsigned)imcv->first;
+ // Do not add values that are outside of the part.
+ if(p && t >= p->tick() && t < (p->tick() + p->lenTick()) )
+ el->add(MidiPlayEvent(0, port, ivl->first >> 24, ME_CONTROLLER, vl->num(), imcv->second.val));
+ }
+ }
+ dev->setNextPlayEvent(el->begin());
+ }
+ }
+
+//---------------------------------------------------------
+// MidiSeq
+//---------------------------------------------------------
+
+//MidiSeq::MidiSeq(int priority, const char* name)
+// : Thread(priority, name)
+MidiSeq::MidiSeq(const char* name)
+ : Thread(name)
+ {
+ // Changed by Tim. p3.3.17
+ //prio = priority;
+ prio = 0;
+
+ idle = false;
+ midiClock = 0;
+ mclock1 = 0.0;
+ mclock2 = 0.0;
+ songtick1 = songtick2 = 0;
+ lastTempo = 0;
+ storedtimediffs = 0;
+ playStateExt = false; // not playing
+ doSetuid();
+ timerFd=selectTimer();
+ undoSetuid();
+
+ }
+
+//---------------------------------------------------------
+// ~MidiSeq
+//---------------------------------------------------------
+
+MidiSeq::~MidiSeq()
+ {
+ delete timer;
+ }
+
+//---------------------------------------------------------
+// selectTimer()
+// select one of the supported timers to use during this run
+//---------------------------------------------------------
+
+signed int MidiSeq::selectTimer()
+ {
+ int tmrFd;
+
+ printf("Trying RTC timer...\n");
+ timer = new RtcTimer();
+ tmrFd = timer->initTimer();
+ if (tmrFd != -1) { // ok!
+ printf("got timer = %d\n", tmrFd);
+ return tmrFd;
+ }
+ delete timer;
+
+ printf("Trying ALSA timer...\n");
+ timer = new AlsaTimer();
+ tmrFd = timer->initTimer();
+ if ( tmrFd!= -1) { // ok!
+ printf("got timer = %d\n", tmrFd);
+ return tmrFd;
+ }
+ delete timer;
+ timer=NULL;
+ QMessageBox::critical( 0, /*tr*/(QString("Failed to start timer!")),
+ /*tr*/(QString("No functional timer was available.\n"
+ "RTC timer not available, check if /dev/rtc is available and readable by current user\n"
+ "Alsa timer not available, check if module snd_timer is available and /dev/snd/timer is available")));
+ printf("No functional timer available!!!\n");
+ exit(1);
+ }
+
+//---------------------------------------------------------
+// threadStart
+// called from loop()
+//---------------------------------------------------------
+
+void MidiSeq::threadStart(void*)
+ {
+ // Removed by Tim. p3.3.17
+ /*
+ struct sched_param rt_param;
+ memset(&rt_param, 0, sizeof(rt_param));
+ int prio_min = sched_get_priority_min(SCHED_FIFO);
+ int prio_max = sched_get_priority_max(SCHED_FIFO);
+
+ if (prio < prio_min) prio = prio_min;
+ else if (prio > prio_max) prio = prio_max;
+
+ rt_param.sched_priority = prio;
+ int rv = pthread_setschedparam(pthread_self(), SCHED_FIFO, &rt_param);
+ if (rv != 0)
+ perror("set realtime scheduler");
+ */
+
+ int policy;
+ if ((policy = sched_getscheduler (0)) < 0) {
+ printf("Cannot get current client scheduler: %s\n", strerror(errno));
+ }
+ if (policy != SCHED_FIFO)
+ printf("midi thread %d _NOT_ running SCHED_FIFO\n", getpid());
+ updatePollFd();
+ }
+
+//---------------------------------------------------------
+// alsaMidiRead
+//---------------------------------------------------------
+
+static void alsaMidiRead(void*, void*)
+ {
+ // calls itself midiDevice->recordEvent(MidiRecordEvent):
+ alsaProcessMidiInput();
+ }
+
+//---------------------------------------------------------
+// midiRead
+//---------------------------------------------------------
+
+static void midiRead(void*, void* d)
+ {
+ MidiDevice* dev = (MidiDevice*) d;
+ dev->processInput();
+ }
+
+//---------------------------------------------------------
+// synthIRead
+//---------------------------------------------------------
+
+#if 0
+static void synthIRead(void*, void* d)
+ {
+ SynthI* syn = (SynthI*) d;
+ syn->processInput();
+ }
+#endif
+
+//---------------------------------------------------------
+// midiWrite
+//---------------------------------------------------------
+
+static void midiWrite(void*, void* d)
+ {
+ MidiDevice* dev = (MidiDevice*) d;
+ dev->flush();
+ }
+
+//---------------------------------------------------------
+// updatePollFd
+//---------------------------------------------------------
+
+void MidiSeq::updatePollFd()
+ {
+ if (!isRunning())
+ return;
+
+ clearPollFd();
+ addPollFd(timerFd, POLLIN, midiTick, this, 0);
+
+ if (timerFd == -1) {
+ fprintf(stderr, "updatePollFd: no timer fd\n");
+ if (!debugMode)
+ exit(-1);
+ }
+
+ addPollFd(toThreadFdr, POLLIN, ::readMsg, this, 0);
+
+ //---------------------------------------------------
+ // midi ports
+ //---------------------------------------------------
+
+ for (iMidiDevice imd = midiDevices.begin(); imd != midiDevices.end(); ++imd) {
+ MidiDevice* dev = *imd;
+ int port = dev->midiPort();
+ const QString name = dev->name();
+ if (port == -1)
+ continue;
+ if ((dev->rwFlags() & 0x2) || (extSyncFlag.value()
+ //&& (rxSyncPort == port || rxSyncPort == -1))) {
+ //&& (dev->syncInfo().MCIn()))) {
+ && (midiPorts[port].syncInfo().MCIn()))) {
+ if(dev->selectRfd() < 0){
+ //fprintf(stderr, "WARNING: read-file-descriptor for {%s} is negative\n", name.toLatin1());
+ }
+ addPollFd(dev->selectRfd(), POLLIN, ::midiRead, this, dev);
+ }
+ if (dev->bytesToWrite()){
+ if(dev->selectWfd() < 0){
+ //fprintf(stderr, "WARNING: write-file-descriptor for {%s} is negative\n", name.toLatin1());
+ }
+ addPollFd(dev->selectWfd(), POLLOUT, ::midiWrite, this, dev);
+ }
+ }
+ // special handling for alsa midi:
+ // (one fd for all devices)
+ // this allows for processing of some alsa events
+ // even if no alsa driver is active (assigned to a port)
+ addPollFd(alsaSelectRfd(), POLLIN, ::alsaMidiRead, this, 0);
+ }
+
+//---------------------------------------------------------
+// threadStop
+// called from loop()
+//---------------------------------------------------------
+
+void MidiSeq::threadStop()
+ {
+ timer->stopTimer();
+ //timer.stopTimer();
+ }
+
+//---------------------------------------------------------
+// setRtcTicks
+// return true on success
+//---------------------------------------------------------
+
+bool MidiSeq::setRtcTicks()
+ {
+
+ //timer.setTimerFreq(config.rtcTicks);
+ //timer.startTimer();
+ timer->setTimerFreq(config.rtcTicks);
+ timer->startTimer();
+ realRtcTicks = config.rtcTicks;
+ return true;
+ }
+
+//---------------------------------------------------------
+// start
+// return true on error
+//---------------------------------------------------------
+
+//bool MidiSeq::start()
+void MidiSeq::start(int priority)
+ {
+ // Changed by Tim. p3.3.17
+
+ prio = priority;
+
+ //timerFd = -1;
+
+ doSetuid();
+ //timerFd = selectTimer();
+ //timerFd = timer.initTimer();
+ //printf("timerFd=%d\n",timerFd);
+ setRtcTicks();
+ undoSetuid();
+ //Thread::start();
+ Thread::start(priority);
+ //return false;
+ }
+
+//---------------------------------------------------------
+// processMidiClock
+//---------------------------------------------------------
+
+void MidiSeq::processMidiClock()
+ {
+// if (genMCSync) {
+// midiPorts[txSyncPort].sendClock();
+// }
+
+/* if (state == START_PLAY) {
+ // start play on sync
+ state = PLAY;
+ _midiTick = playTickPos;
+ midiClock = playTickPos;
+
+ int bar, beat, tick;
+ sigmap.tickValues(_midiTick, &bar, &beat, &tick);
+ midiClick = sigmap.bar2tick(bar, beat+1, 0);
+
+ double cpos = tempomap.tick2time(playTickPos);
+ samplePosStart = samplePos - lrint(cpos * sampleRate);
+ rtcTickStart = rtcTick - lrint(cpos * realRtcTicks);
+
+ endSlice = playTickPos;
+ recTick = playTickPos;
+ lastTickPos = playTickPos;
+
+ tempoSN = tempomap.tempoSN();
+
+ startRecordPos.setPosTick(playTickPos);
+ }
+*/
+// midiClock += config.division/24;
+ }
+
+//---------------------------------------------------------
+// midiTick
+//---------------------------------------------------------
+
+void MidiSeq::midiTick(void* p, void*)
+ {
+ MidiSeq* at = (MidiSeq*)p;
+ at->processTimerTick();
+ if (TIMER_DEBUG)
+ {
+ if(MidiSeq::ticker++ > 100)
+ {
+ printf("tick!\n");
+ MidiSeq::ticker=0;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// processTimerTick
+//---------------------------------------------------------
+
+void MidiSeq::processTimerTick()
+ {
+ // Disabled by Tim. p3.3.22
+// extern int watchMidi;
+// ++watchMidi; // make a simple watchdog happy
+
+ //---------------------------------------------------
+ // read elapsed rtc timer ticks
+ //---------------------------------------------------
+
+ // This is required otherwise it freezes.
+ unsigned long nn;
+ if (timerFd != -1) {
+ nn = timer->getTimerTicks();
+ //nn = timer.getTimerTicks();
+ nn >>= 8;
+ }
+
+ if (idle) {
+// printf("IDLE\n");
+ return;
+ }
+ if (midiBusy) {
+ // we hit audio: midiSeq->msgProcess
+ // miss this timer tick
+ return;
+ }
+
+ unsigned curFrame = audio->curFrame();
+
+ // Keep the sync detectors running...
+ // No, done in Song::beat(), (at the much slower heartbeat rate).
+ //
+ //for(int port = 0; port < MIDI_PORTS; ++port)
+ //{
+ // Must keep them running even if there's no device...
+ //if(midiPorts[port].device())
+ // midiPorts[port].syncInfo().setCurFrame(curFrame);
+ //}
+ //for(iMidiDevice imd = midiDevices.begin(); imd != midiDevices.end(); ++imd)
+ // (*imd)->syncInfo().setCurFrame(curFrame);
+
+ if (!extSyncFlag.value()) {
+ //int curTick = tempomap.frame2tick(curFrame);
+ // Copied from Tempomap.
+ //int curTick = lrint((double(curFrame)/double(sampleRate)) * tempomap.globalTempo() * config.division * 10000.0 / double(tempomap.tempo(song->cpos())));
+ //int curTick = lrint((double(curFrame)/double(sampleRate)) * tempomap.globalTempo() * 240000.0 / double(tempomap.tempo(song->cpos())));
+ int curTick = lrint((double(curFrame)/double(sampleRate)) * double(tempomap.globalTempo()) * double(config.division) * 10000.0 / double(tempomap.tempo(song->cpos())));
+ //int curTick = int((double(curFrame)/double(sampleRate)) * double(tempomap.globalTempo()) * double(config.division * 10000.0) / double(tempomap.tempo(song->cpos())));
+
+/* if ( midiClock > curTick + 100) // reinitialize
+ {
+ midiClock = curTick;
+ }
+ else if( curTick > midiClock + 100) // reinitialize
+ {
+ midiClock = curTick;
+ }*/
+
+ if(midiClock > curTick)
+ midiClock = curTick;
+
+ int div = config.division/24;
+ if(curTick >= midiClock + div) {
+ //if(curTick >= midiClock) {
+ //processMidiClock();
+ int perr = (curTick - midiClock) / div;
+ //int perr = curTick - midiClock;
+
+ bool used = false;
+
+ //if(genMCSync)
+ //{
+ //midiPorts[txSyncPort].sendClock();
+ for(int port = 0; port < MIDI_PORTS; ++port)
+ {
+ MidiPort* mp = &midiPorts[port];
+
+ // No device? Clock out not turned on?
+ //MidiDevice* dev = mp->device();
+ //if(!dev || !mp->syncInfo().MCOut())
+ if(!mp->device() || !mp->syncInfo().MCOut())
+ continue;
+
+ // Shall we check open flags?
+ //if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
+ //if(!(dev->openFlags() & 1))
+ // continue;
+
+ used = true;
+
+ mp->sendClock();
+ }
+
+ /*
+ for(iMidiDevice imd = midiDevices.begin(); imd != midiDevices.end(); ++imd)
+ {
+ MidiDevice* dev = *imd;
+
+ if(!dev->syncInfo().MCOut())
+ continue;
+
+ // Shall we check open flags?
+ //if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
+ //if(!(dev->openFlags() & 1))
+ // continue;
+
+ int port = dev->midiPort();
+ // Without this -1 check, interesting sync things can be done by the user without ever
+ // assigning any devices to ports !
+ //if(port < 0 || port > MIDI_PORTS)
+ if(port < -1 || port > MIDI_PORTS)
+ continue;
+
+ if(port == -1)
+ // Send straight to the device... Copied from MidiPort.
+ {
+ MidiPlayEvent event(0, 0, 0, ME_CLOCK, 0, 0);
+ dev->putEvent(event);
+ }
+ else
+ // Go through the port...
+ midiPorts[port].sendClock();
+ }
+ */
+
+ if(debugMsg && used && perr > 1)
+ printf("Dropped %d midi out clock(s). curTick:%d midiClock:%d div:%d\n", perr, curTick, midiClock, div);
+ //}
+
+ // Keeping in mind how (receiving end) Phase Locked Loops (usually) operate...
+ // Increment as if we had caught the timer exactly on the mark, even if the timer
+ // has passed beyond the mark, or even beyond 2 * div.
+ // If we missed some chances to send clock, resume the count where it would have been,
+ // had we not missed chances.
+ // We can't do anything about missed chances except send right away, and make up
+ // for gained time by losing time in the next count...
+ // In other words, use equalization periods to counter gained/lost time, so that
+ // ultimately, over time, the receiver remains in phase, despite any short dropouts / phase glitches.
+ // (midiClock only increments by div units).
+ //
+ // Tested: With midi thread set to high priority, very few clock dropouts ocurred (P4 1.6Ghz).
+ // But target device tick drifts out of phase with muse tick slowly over time, say 20 bars or so.
+ // May need more tweaking, possibly use round with/instead of lrint (above), and/or
+ // do not use equalization periods - set midiClock to fractions of div.
+ // Tested: With RTC resolution at 1024, stability was actually better than with 8192!
+ // It stayed in sync more than 64 bars...
+ //
+ //
+ // Using equalization periods...
+ midiClock += (perr * div);
+ //midiClock += perr;
+ //
+ // No equalization periods... TODO:
+ //midiClock += (perr * div);
+ }
+ }
+
+// if (genMTCSync) {
+ // printf("Midi Time Code Sync generation not impl.\n");
+// }
+
+ // p3.3.25
+ int tickpos = audio->tickPos();
+ bool extsync = extSyncFlag.value();
+ //
+ // play all events upto curFrame
+ //
+ for (iMidiDevice id = midiDevices.begin(); id != midiDevices.end(); ++id) {
+ MidiDevice* md = *id;
+ // Is it a Jack midi device? p3.3.36
+ //MidiJackDevice* mjd = dynamic_cast<MidiJackDevice*>(md);
+ //if(mjd)
+ if(md->deviceType() == MidiDevice::JACK_MIDI)
+ continue;
+ if(md->isSynti()) // syntis are handled by audio thread
+ continue;
+ int port = md->midiPort();
+ MidiPort* mp = port != -1 ? &midiPorts[port] : 0;
+ MPEventList* el = md->playEvents();
+ if (el->empty())
+ continue;
+ iMPEvent i = md->nextPlayEvent();
+ for (; i != el->end(); ++i) {
+ // p3.3.25
+ // If syncing to external midi sync, we cannot use the tempo map.
+ // Therefore we cannot get sub-tick resolution. Just use ticks instead of frames.
+ //if (i->time() > curFrame) {
+ if (i->time() > (extsync ? tickpos : curFrame)) {
+ //printf(" curT %d frame %d\n", i->time(), curFrame);
+ break; // skip this event
+ }
+
+ if (mp) {
+ if (mp->sendEvent(*i))
+ break;
+ }
+ else {
+ if (md->putEvent(*i))
+ break;
+ }
+ }
+ md->setNextPlayEvent(i);
+ }
+ }
+
+//---------------------------------------------------------
+// msgMsg
+//---------------------------------------------------------
+
+void MidiSeq::msgMsg(int id)
+ {
+ AudioMsg msg;
+ msg.id = id;
+ Thread::sendMsg(&msg);
+ }
+
+//---------------------------------------------------------
+// msgSetMidiDevice
+// to avoid timeouts in the RT-thread, setMidiDevice
+// is done in GUI context after setting the midi thread
+// into idle mode
+//---------------------------------------------------------
+
+void MidiSeq::msgSetMidiDevice(MidiPort* port, MidiDevice* device)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_IDLE;
+ msg.a = true;
+ Thread::sendMsg(&msg);
+
+ port->setMidiDevice(device);
+
+ msg.id = SEQM_IDLE;
+ msg.a = false;
+ Thread::sendMsg(&msg);
+ }
+
+void MidiSeq::msgProcess() { msgMsg(MS_PROCESS); }
+void MidiSeq::msgSeek() { msgMsg(SEQM_SEEK); }
+void MidiSeq::msgStop() { msgMsg(MS_STOP); }
+void MidiSeq::msgSetRtc() { msgMsg(MS_SET_RTC); }
+void MidiSeq::msgUpdatePollFd() { msgMsg(MS_UPDATE_POLL_FD); }
+
diff --git a/attic/muse2-oom/muse2/muse/midiseq.h b/attic/muse2-oom/muse2/muse/midiseq.h
new file mode 100644
index 00000000..a11820fe
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/midiseq.h
@@ -0,0 +1,102 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midiseq.h,v 1.6.2.11 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MIDISEQ_H__
+#define __MIDISEQ_H__
+
+#include "thread.h"
+#include "mpevent.h"
+#include "driver/alsatimer.h"
+#include "driver/rtctimer.h"
+
+class MPEventList;
+class SynthI;
+class MTC;
+class MidiPort;
+class MidiDevice;
+
+//---------------------------------------------------------
+// MidiSeq
+//---------------------------------------------------------
+
+class MidiSeq : public Thread {
+ int realRtcTicks;
+ int timerFd;
+ int idle;
+ int prio; // realtime priority
+ int midiClock;
+ static int ticker;
+
+/* Testing */
+ bool playStateExt; // used for keeping play state in sync functions
+ int recTick; // ext sync tick position
+// int lastTickPos; // position of last sync tick
+ // run values:
+// unsigned _midiTick;
+ double mclock1, mclock2;
+ double songtick1, songtick2;
+ int recTick1, recTick2;
+ int lastTempo;
+ double timediff[24];
+ int storedtimediffs;
+
+ void alignAllTicks(int frameOverride = 0);
+/* Testing */
+
+ Timer *timer;
+
+ signed int selectTimer();
+ bool setRtcTicks();
+ static void midiTick(void* p, void*);
+ void processTimerTick();
+ void processSeek();
+ void processStop();
+ void processMidiClock();
+ virtual void processMsg(const ThreadMsg*);
+ void updatePollFd();
+
+ void mtcSyncMsg(const MTC&, int, bool);
+ //void mtcInputFull(const unsigned char* p, int n);
+ //void nonRealtimeSystemSysex(const unsigned char* p, int n);
+
+ public:
+ //MidiSeq(int prio, const char* name);
+ MidiSeq(const char* name);
+
+ ~MidiSeq();
+
+ //bool start();
+ virtual void start(int);
+
+ virtual void threadStop();
+ virtual void threadStart(void*);
+
+ void realtimeSystemInput(int, int);
+ void mtcInputQuarter(int, unsigned char);
+ void setSongPosition(int, int);
+ // void eventReceived(MidiRecordEvent& event);
+ //void mmcInput(const unsigned char* p, int n);
+ void mmcInput(int, const unsigned char*, int);
+ void mtcInputFull(int, const unsigned char*, int);
+ void nonRealtimeSystemSysex(int, const unsigned char*, int);
+
+ void msgMsg(int id);
+ void msgProcess();
+ void msgSeek();
+ void msgStop();
+ void msgSetRtc();
+ void msgUpdatePollFd();
+ void msgAddSynthI(SynthI* synth);
+ void msgRemoveSynthI(SynthI* synth);
+ void msgSetMidiDevice(MidiPort*, MidiDevice*);
+ };
+
+extern MidiSeq* midiSeq;
+extern volatile bool midiBusy;
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/miditransform.cpp b/attic/muse2-oom/muse2/muse/miditransform.cpp
new file mode 100644
index 00000000..1c73b7c2
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/miditransform.cpp
@@ -0,0 +1,1743 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: miditransform.cpp,v 1.8.2.3 2009/05/24 21:43:44 terminator356 Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <list>
+
+
+#include <QDialog>
+#include <QListWidgetItem>
+
+#include "helper.h"
+#include "spinboxFP.h"
+#include "event.h"
+#include "miditransform.h"
+#include "track.h"
+#include "song.h"
+#include "xml.h"
+#include "globals.h"
+#include "comboQuant.h"
+//#include "pitchedit.h"
+#include "audio.h"
+#include "gconfig.h"
+#include "midictrl.h"
+
+//
+// Order of events:
+// Note, Poly Pressure, Control, AfterTouch, Pitch Bend, NRPN, RPN
+//
+#define MIDITRANSFORM_NOTE 0
+#define MIDITRANSFORM_POLY 1
+#define MIDITRANSFORM_CTRL 2
+#define MIDITRANSFORM_ATOUCH 3
+#define MIDITRANSFORM_PITCHBEND 4
+#define MIDITRANSFORM_NRPN 5
+#define MIDITRANSFORM_RPN 6
+
+
+static int eventTypeTable[] = {
+ MIDITRANSFORM_NOTE, MIDITRANSFORM_POLY, MIDITRANSFORM_CTRL, MIDITRANSFORM_ATOUCH,
+ MIDITRANSFORM_PITCHBEND, MIDITRANSFORM_NRPN, MIDITRANSFORM_RPN
+ };
+
+static int procVal2Map[] = { 0, 1, 2, 3, 4, 5, 6, 7, 10, 11 };
+
+//---------------------------------------------------------
+// MidiTransformation
+//---------------------------------------------------------
+
+class MidiTransformation {
+ public:
+ QString name;
+ QString comment;
+
+ ValOp selEventOp;
+ EventType selType;
+
+ ValOp selVal1;
+ int selVal1a, selVal1b;
+ ValOp selVal2;
+ int selVal2a, selVal2b;
+ ValOp selLen;
+ int selLenA, selLenB;
+ ValOp selRange;
+ int selRangeA, selRangeB;
+
+ TransformOperator procEvent;
+ EventType eventType;
+ TransformOperator procVal1;
+ int procVal1a, procVal1b;
+ TransformOperator procVal2;
+ int procVal2a, procVal2b;
+ TransformOperator procLen;
+ int procLenA;
+ TransformOperator procPos;
+ int procPosA;
+
+ TransformFunction funcOp;
+ int quantVal;
+ bool selectedTracks;
+ bool insideLoop;
+
+ MidiTransformation(const QString& s) {
+ name = s;
+ selEventOp = All;
+ selType = Note;
+ selVal1 = Ignore;
+ selVal1a = 0;
+ selVal1b = 0;
+ selVal2 = Ignore;
+ selVal2a = 0;
+ selVal2b = 0;
+ selLen = Ignore;
+ selLenA = 0;
+ selLenB = 0;
+ selRange = Ignore;
+ selRangeA = 0;
+ selRangeB = 0;
+ procEvent = Keep;
+ eventType = Note;
+ procVal1 = Keep;
+ procVal1a = 0;
+ procVal1b = 0;
+ procVal2 = Keep;
+ procVal2a = 0;
+ procVal2b = 0;
+ procLen = Keep;
+ procLenA = 0;
+ procPos = Keep;
+ procPosA = 0;
+ funcOp = Select;
+ quantVal = config.division;
+ selectedTracks = false;
+ insideLoop = false;
+ }
+ void write(int level, Xml& xml);
+ };
+
+class MidiTransformPrivate {
+ public:
+ MidiTransformation* cmt;
+ int cindex; // current index in preset list
+ };
+
+typedef std::list<MidiTransformation* > MidiTransformationList;
+typedef std::list<MidiTransformation* >::iterator iMidiTransformation;
+typedef std::list<MidiTransformation* >::const_iterator ciMidiTransformation;
+
+static MidiTransformationList mtlist;
+
+//---------------------------------------------------------
+// MidiTransformDialog
+// Widgets:
+// presetList nameEntry commentEntry
+// selEventOp selType
+// selVal1Op selVal1a selVal1b
+// selVal2Op selVal2a selVal2b
+// selLenOp selLenA selLenB
+// selRangeOp selBarA selBarB
+//
+// procEventOp procType
+// procVal1Op procVal1a procVal1b
+// procVal2Op procVal2a procVal2b
+// procLenOp procLenA
+// procPosOp procPosA
+// funcOp funcQuantVal
+// processAll selectedTracks insideLoop
+// buttonNew buttonDelete buttonApply buttonOk
+//---------------------------------------------------------
+
+MidiTransformerDialog::MidiTransformerDialog(QDialog* parent, Qt::WFlags fl)
+ : QDialog(parent, fl)
+ {
+ setupUi(this);
+ data = new MidiTransformPrivate;
+ data->cmt = 0;
+ data->cindex = -1;
+ connect(buttonApply, SIGNAL(clicked()), SLOT(apply()));
+ connect(buttonNew, SIGNAL(clicked()), SLOT(presetNew()));
+ connect(buttonDelete, SIGNAL(clicked()), SLOT(presetDelete()));
+ connect(selEventOp, SIGNAL(activated(int)), SLOT(selEventOpSel(int)));
+ connect(selType, SIGNAL(activated(int)), SLOT(selTypeSel(int)));
+ connect(selVal1Op, SIGNAL(activated(int)), SLOT(selVal1OpSel(int)));
+ connect(selVal2Op, SIGNAL(activated(int)), SLOT(selVal2OpSel(int)));
+ connect(selLenOp, SIGNAL(activated(int)), SLOT(selLenOpSel(int)));
+ connect(selRangeOp, SIGNAL(activated(int)), SLOT(selRangeOpSel(int)));
+ connect(procEventOp, SIGNAL(activated(int)), SLOT(procEventOpSel(int)));
+ connect(procType, SIGNAL(activated(int)), SLOT(procEventTypeSel(int)));
+ connect(procVal1Op, SIGNAL(activated(int)), SLOT(procVal1OpSel(int)));
+ connect(procVal2Op, SIGNAL(activated(int)), SLOT(procVal2OpSel(int)));
+ connect(procLenOp, SIGNAL(activated(int)), SLOT(procLenOpSel(int)));
+ connect(procPosOp, SIGNAL(activated(int)), SLOT(procPosOpSel(int)));
+ connect(funcOp, SIGNAL(activated(int)), SLOT(funcOpSel(int)));
+ connect(funcQuantVal, SIGNAL(valueChanged(int)), SLOT(funcQuantValSel(int)));
+ connect(presetList, SIGNAL(itemClicked(QListWidgetItem*)),
+ SLOT(presetChanged(QListWidgetItem*)));
+ connect(nameEntry, SIGNAL(textChanged(const QString&)),
+ SLOT(nameChanged(const QString&)));
+ connect(commentEntry, SIGNAL(textChanged()), SLOT(commentChanged()));
+
+ connect(selVal1a, SIGNAL(valueChanged(int)), SLOT(selVal1aChanged(int)));
+ connect(selVal1b, SIGNAL(valueChanged(int)), SLOT(selVal1bChanged(int)));
+ connect(selVal2a, SIGNAL(valueChanged(int)), SLOT(selVal2aChanged(int)));
+ connect(selVal2b, SIGNAL(valueChanged(int)), SLOT(selVal2bChanged(int)));
+ connect(selLenA, SIGNAL(valueChanged(int)), SLOT(selLenAChanged(int)));
+ connect(selLenB, SIGNAL(valueChanged(int)), SLOT(selLenBChanged(int)));
+ connect(selBarA, SIGNAL(valueChanged(int)), SLOT(selBarAChanged(int)));
+ connect(selBarB, SIGNAL(valueChanged(int)), SLOT(selBarBChanged(int)));
+ connect(procVal1a, SIGNAL(valueChanged(int)), SLOT(procVal1aChanged(int)));
+ connect(procVal1b, SIGNAL(valueChanged(int)), SLOT(procVal1bChanged(int)));
+ connect(procVal2a, SIGNAL(valueChanged(int)), SLOT(procVal2aChanged(int)));
+ connect(procVal2b, SIGNAL(valueChanged(int)), SLOT(procVal2bChanged(int)));
+ connect(procLenA, SIGNAL(valueChanged(int)), SLOT(procLenAChanged(int)));
+ connect(procPosA, SIGNAL(valueChanged(int)), SLOT(procPosAChanged(int)));
+
+ connect(processAll, SIGNAL(toggled(bool)), SLOT(processAllChanged(bool)));
+ connect(selectedTracks, SIGNAL(toggled(bool)), SLOT(selectedTracksChanged(bool)));
+ connect(insideLoop, SIGNAL(toggled(bool)), SLOT(insideLoopChanged(bool)));
+
+ //---------------------------------------------------
+ // populate preset list
+ //---------------------------------------------------
+
+ updatePresetList();
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+ }
+
+//---------------------------------------------------------
+// ~MidiTransformDialog
+//---------------------------------------------------------
+
+MidiTransformerDialog::~MidiTransformerDialog()
+ {
+ delete data;
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::songChanged(int flags)
+{
+ // Whenever a song is loaded, flags is -1. Since transforms are part of configuration,
+ // use SC_CONFIG here, to filter unwanted song change events.
+ if(flags & SC_CONFIG)
+ updatePresetList();
+}
+
+//---------------------------------------------------------
+// updatePresetList
+//---------------------------------------------------------
+
+void MidiTransformerDialog::updatePresetList()
+{
+ data->cmt = 0;
+ data->cindex = 0;
+ presetList->clear();
+ for (iMidiTransformation i = mtlist.begin(); i != mtlist.end(); ++i) {
+ presetList->addItem((*i)->name);
+ if (data->cmt == 0)
+ data->cmt = *i;
+ }
+ if (data->cmt == 0) {
+ data->cmt = new MidiTransformation(tr("New"));
+ mtlist.push_back(data->cmt);
+ presetList->addItem(tr("New"));
+ presetList->setCurrentItem(0);
+ }
+
+ //data->cindex = 0;
+ //presetList->setCurrentItem(0);
+
+}
+
+//---------------------------------------------------------
+// writeMidiTransforms
+//---------------------------------------------------------
+
+void writeMidiTransforms(int level, Xml& xml)
+ {
+ for (iMidiTransformation i = mtlist.begin(); i != mtlist.end(); ++i) {
+ (*i)->write(level, xml);
+ }
+ }
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+void MidiTransformation::write(int level, Xml& xml)
+ {
+ xml.tag(level++, "midiTransform");
+ xml.strTag(level, "name", name);
+ xml.strTag(level, "comment", comment);
+ xml.intTag(level, "function", int(funcOp));
+ xml.intTag(level, "selectedTracks", selectedTracks);
+ xml.intTag(level, "insideLoop", insideLoop);
+ if (funcOp == Quantize) {
+ xml.intTag(level, "quantVal", quantVal);
+ }
+ if (funcOp == Transform || funcOp == Insert) {
+ if (procEvent != Keep) {
+ xml.intTag(level, "procEventOp", int(procEvent));
+ xml.intTag(level, "eventType", int(eventType));
+ }
+ if (procVal1 != Keep) {
+ xml.intTag(level, "procVal1Op", int(procVal1));
+ xml.intTag(level, "procVal1a", procVal1a);
+ xml.intTag(level, "procVal1b", procVal1b);
+ }
+ if (procVal2 != Keep) {
+ xml.intTag(level, "procVal2Op", int(procVal2));
+ xml.intTag(level, "procVal2a", procVal2a);
+ xml.intTag(level, "procVal2b", procVal2b);
+ }
+ if (procLen != Keep) {
+ xml.intTag(level, "procLenOp", int(procLen));
+ xml.intTag(level, "procLen", procLenA);
+ }
+ if (procPos != Keep) {
+ xml.intTag(level, "procPosOp", int(procPos));
+ xml.intTag(level, "procPos", procPosA);
+ }
+ }
+ if (selEventOp != Ignore) {
+ xml.intTag(level, "selEventOp", int(selEventOp));
+ xml.intTag(level, "selEventType", int(selType));
+ }
+ if (selVal1 != Ignore) {
+ xml.intTag(level, "selVal1Op", int(selVal1));
+ xml.intTag(level, "selVal1a", selVal1a);
+ xml.intTag(level, "selVal1b", selVal1b);
+ }
+ if (selVal2 != Ignore) {
+ xml.intTag(level, "selVal2Op", int(selVal2));
+ xml.intTag(level, "selVal2a", selVal2a);
+ xml.intTag(level, "selVal2b", selVal2b);
+ }
+ if (selLen != Ignore) {
+ xml.intTag(level, "selLenOp", int(selLen));
+ xml.intTag(level, "selLenA", selLenA);
+ xml.intTag(level, "selLenB", selLenB);
+ }
+ if (selRange != Ignore) {
+ xml.intTag(level, "selRangeOp", int(selRange));
+ xml.intTag(level, "selRangeA", selRangeA);
+ xml.intTag(level, "selRangeB", selRangeB);
+ }
+ xml.etag(level, "midiTransform");
+ }
+
+//---------------------------------------------------------
+// readMidiTransform
+//---------------------------------------------------------
+
+void readMidiTransform(Xml& xml)
+ {
+ MidiTransformation trans(QWidget::tr("new"));
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "name")
+ trans.name = xml.parse1();
+ else if (tag == "comment")
+ trans.comment = xml.parse1();
+ else if (tag == "function")
+ trans.funcOp = TransformFunction(xml.parseInt());
+ else if (tag == "selectedTracks")
+ trans.selectedTracks = xml.parseInt();
+ else if (tag == "insideLoop")
+ trans.insideLoop = xml.parseInt();
+ else if (tag == "quantVal")
+ trans.quantVal = xml.parseInt();
+ else if (tag == "procEventOp")
+ trans.procEvent = TransformOperator(xml.parseInt());
+ else if (tag == "eventType")
+ trans.eventType = EventType(xml.parseInt());
+ else if (tag == "procVal1Op")
+ trans.procVal1 = TransformOperator(xml.parseInt());
+ else if (tag == "procVal1a")
+ trans.procVal1a = xml.parseInt();
+ else if (tag == "procVal1b")
+ trans.procVal1b = xml.parseInt();
+ else if (tag == "procVal2Op")
+ trans.procVal2 = TransformOperator(xml.parseInt());
+ else if (tag == "procVal2a")
+ trans.procVal2a = xml.parseInt();
+ else if (tag == "procVal2b")
+ trans.procVal2b = xml.parseInt();
+ else if (tag == "procLenOp")
+ trans.procLen = TransformOperator(xml.parseInt());
+ else if (tag == "procLen")
+ trans.procLenA = xml.parseInt();
+ else if (tag == "procPosOp")
+ trans.procPos = TransformOperator(xml.parseInt());
+ else if (tag == "procPos")
+ trans.procPosA = xml.parseInt();
+ else if (tag == "selEventOp")
+ trans.selEventOp = ValOp(xml.parseInt());
+ else if (tag == "selEventType")
+ trans.selType = EventType(xml.parseInt());
+ else if (tag == "selVal1Op")
+ trans.selVal1 = ValOp(xml.parseInt());
+ else if (tag == "selVal1a")
+ trans.selVal1a = xml.parseInt();
+ else if (tag == "selVal1b")
+ trans.selVal1b = xml.parseInt();
+ else if (tag == "selVal2Op")
+ trans.selVal2 = ValOp(xml.parseInt());
+ else if (tag == "selVal2a")
+ trans.selVal2a = xml.parseInt();
+ else if (tag == "selVal2b")
+ trans.selVal2b = xml.parseInt();
+ else if (tag == "selLenOp")
+ trans.selLen = ValOp(xml.parseInt());
+ else if (tag == "selLenA")
+ trans.selLenA = xml.parseInt();
+ else if (tag == "selLenB")
+ trans.selLenB = xml.parseInt();
+ else if (tag == "selRangeOp")
+ trans.selRange = ValOp(xml.parseInt());
+ else if (tag == "selRangeA")
+ trans.selRangeA = xml.parseInt();
+ else if (tag == "selRangeB")
+ trans.selRangeB = xml.parseInt();
+ else
+ xml.unknown("midiTransform");
+ break;
+ case Xml::TagEnd:
+ if (xml.s1() == "midiTransform") {
+ // By T356. A previous bug caused some .med files to grow very large
+ // with duplicate transforms. Here we can eliminate those duplicates.
+ for(iMidiTransformation i = mtlist.begin(); i != mtlist.end(); ++i)
+ {
+ if((*i)->name == trans.name)
+ return;
+ }
+
+ MidiTransformation* t = new MidiTransformation(trans);
+ mtlist.push_back(t);
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// clearMidiTransforms
+//---------------------------------------------------------
+
+void clearMidiTransforms()
+{
+ for (iMidiTransformation i = mtlist.begin(); i != mtlist.end(); ++i)
+ {
+ MidiTransformation* t = *i;
+ if(t)
+ delete t;
+ }
+ mtlist.clear();
+}
+
+//---------------------------------------------------------
+// accept
+//---------------------------------------------------------
+
+void MidiTransformerDialog::accept()
+ {
+ apply();
+ reject();
+ }
+
+//---------------------------------------------------------
+// transformEvent
+// subfunction of processEvent()
+//---------------------------------------------------------
+
+void MidiTransformerDialog::transformEvent(Event& event, MidiPart* part,
+ MidiPart* newPart)
+ {
+ MidiTransformation* cmt = data->cmt;
+ Event newEvent = event.clone();
+
+ if (cmt->procEvent != Keep)
+ newEvent.setType(cmt->eventType);
+
+ //---------------------------------------------------
+ // transform value A
+ //---------------------------------------------------
+
+ int val = newEvent.dataA();
+ switch (cmt->procVal1) {
+ case Keep:
+ break;
+ case Plus:
+ val += cmt->procVal1a;
+ break;
+ case Minus:
+ val -= cmt->procVal1a;
+ break;
+ case Multiply:
+ val = int(val * (cmt->procVal1a/100.0) + .5);
+ break;
+ case Divide:
+ val = int(val / (cmt->procVal1a/100.0) + .5);
+ break;
+ case Fix:
+ val = cmt->procVal1a;
+ break;
+ case Value:
+ val = cmt->procVal2a;
+ break;
+ case Invert:
+ val = 128 - val;
+ break;
+ case ScaleMap:
+ printf("scale map not implemented\n");
+ break;
+ case Flip:
+ val = cmt->procVal1a - val;
+ break;
+ case Dynamic: // "crescendo"
+ val = (((cmt->procVal2b-cmt->procVal2a)
+ * (newEvent.tick() - song->lpos()))
+ / (song->rpos() - song->lpos())) + cmt->procVal2a;
+ break;
+ case Random:
+ {
+ int range = cmt->procVal1b - cmt->procVal1a;
+ if (range > 0)
+ val = (rand() % range) + cmt->procVal1a;
+ else if (range < 0)
+ val = (rand() % -range) + cmt->procVal1b;
+ else
+ val = cmt->procVal1a;
+ }
+ break;
+ }
+ if (val < 0)
+ val = 0;
+ if (val > 127)
+ val = 127;
+ newEvent.setA(val);
+
+ //---------------------------------------------------
+ // transform value B
+ //---------------------------------------------------
+
+ val = newEvent.dataB();
+ switch (cmt->procVal2) {
+ case Plus:
+ val += cmt->procVal2a;
+ break;
+ case Minus:
+ val -= cmt->procVal2a;
+ break;
+ case Multiply:
+ val = int(val * (cmt->procVal2a/100.0) + .5);
+ break;
+ case Divide:
+ val = int(val / (cmt->procVal2a/100.0) + .5);
+ break;
+ case Fix:
+ val = cmt->procVal2a;
+ break;
+ case Value:
+ val = cmt->procVal1a;
+ break;
+ case Invert:
+ val = 128 - val;
+ break;
+ case Dynamic:
+ val = (((cmt->procVal2b-cmt->procVal2a)
+ * (newEvent.tick() - song->lpos()))
+ / (song->rpos() - song->lpos())) + cmt->procVal2a;
+ break;
+ case Random:
+ {
+ int range = cmt->procVal2b - cmt->procVal2a;
+ if (range > 0)
+ val = (rand() % range) + cmt->procVal2a;
+ else if (range < 0)
+ val = (rand() % -range) + cmt->procVal2b;
+ else
+ val = cmt->procVal1a;
+ }
+ break;
+ case ScaleMap:
+ case Keep:
+ case Flip:
+ break;
+ }
+ if (val < 0)
+ val = 0;
+ if (val > 127)
+ val = 127;
+ newEvent.setB(val);
+
+ //---------------------------------------------------
+ // transform len
+ //---------------------------------------------------
+
+ int len = newEvent.lenTick();
+ switch (cmt->procLen) {
+ case Plus:
+ len += cmt->procLenA;
+ break;
+ case Minus:
+ len -= cmt->procLenA;
+ break;
+ case Multiply:
+ len = int(val * (cmt->procLenA/100.0) + .5);
+ break;
+ case Divide:
+ len = int(val / (cmt->procLenA/100.0) + .5);
+ break;
+ case Fix:
+ len = cmt->procLenA;
+ break;
+ case Invert:
+ case ScaleMap:
+ case Dynamic:
+ case Random:
+ case Keep:
+ case Flip:
+ case Value:
+ break;
+ }
+ if (len < 0)
+ len = 0;
+ newEvent.setLenTick(len);
+
+ //---------------------------------------------------
+ // transform pos
+ //---------------------------------------------------
+
+ int pos = newEvent.tick();
+ switch (cmt->procPos) {
+ case Plus:
+ pos += cmt->procPosA;
+ break;
+ case Minus:
+ pos -= cmt->procPosA;
+ break;
+ case Multiply:
+ pos = int(val * (cmt->procPosA/100.0) + .5);
+ break;
+ case Divide:
+ pos = int(val / (cmt->procPosA/100.0) + .5);
+ break;
+ case Fix:
+ case Invert:
+ case ScaleMap:
+ case Dynamic:
+ case Random:
+ case Keep:
+ case Flip:
+ case Value:
+ break;
+ }
+ if (pos < 0)
+ pos = 0;
+ newEvent.setTick(pos);
+
+ Event dummy;
+ switch(data->cmt->funcOp) {
+ case Transform:
+ // Indicate do clone parts.
+ removePortCtrlEvents(event, part, true);
+ song->changeEvent(event, newEvent, part);
+ // Indicate do clone parts.
+ addPortCtrlEvents(newEvent, part, true);
+ // Indicate do port controller values and clone parts.
+ //song->undoOp(UndoOp::ModifyEvent, newEvent, event, part);
+ song->undoOp(UndoOp::ModifyEvent, newEvent, event, part, true, true);
+ song->addUpdateFlags(SC_EVENT_MODIFIED);
+ break;
+ case Insert:
+ // Indicate do port controller values and clone parts.
+ //song->undoOp(UndoOp::AddEvent, dummy, newEvent, part);
+ song->undoOp(UndoOp::AddEvent, dummy, newEvent, part, true, true);
+ song->addEvent(newEvent, part);
+ // Indicate do clone parts.
+ addPortCtrlEvents(newEvent, part, true);
+ song->addUpdateFlags(SC_EVENT_INSERTED);
+ break;
+ case Extract:
+ // Indicate do port controller values and clone parts.
+ //song->undoOp(UndoOp::DeleteEvent, dummy, event, part);
+ song->undoOp(UndoOp::DeleteEvent, dummy, event, part, true, true);
+ // Indicate do clone parts.
+ removePortCtrlEvents(event, part, true);
+ song->deleteEvent(event, part);
+ song->addUpdateFlags(SC_EVENT_REMOVED);
+ case Copy:
+ newPart->addEvent(newEvent);
+ break;
+ default:
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// processEvent
+//---------------------------------------------------------
+
+void MidiTransformerDialog::processEvent(Event& event, MidiPart* part, MidiPart* newPart)
+ {
+ switch(data->cmt->funcOp) {
+ case Select:
+ break;
+ case Quantize:
+ {
+ int tick = event.tick();
+ int rt = AL::sigmap.raster(tick, data->cmt->quantVal) - tick;
+ if (tick != rt) {
+ // Indicate do clone parts.
+ removePortCtrlEvents(event, part, true);
+ Event newEvent = event.clone();
+ newEvent.setTick(rt);
+ song->changeEvent(event, newEvent, part);
+ // Indicate do clone parts.
+ addPortCtrlEvents(newEvent, part, true);
+ // Indicate do port controller values and clone parts.
+ //song->undoOp(UndoOp::ModifyEvent, newEvent, event, part);
+ song->undoOp(UndoOp::ModifyEvent, newEvent, event, part, true, true);
+ song->addUpdateFlags(SC_EVENT_MODIFIED);
+ }
+ }
+ break;
+ case Delete:
+ {
+ Event ev;
+ // Indicate do port controller values and clone parts.
+ //song->undoOp(UndoOp::DeleteEvent, ev, event, part, true, true);
+ song->undoOp(UndoOp::DeleteEvent, ev, event, part, true, true);
+ // Indicate do clone parts.
+ removePortCtrlEvents(event, part, true);
+ song->deleteEvent(event, part);
+ song->addUpdateFlags(SC_EVENT_REMOVED);
+ }
+ break;
+ case Transform:
+ case Insert:
+ case Copy:
+ case Extract:
+ transformEvent(event, part, newPart);
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// isSelected
+// apply Select filter
+// return true if event is selected
+//---------------------------------------------------------
+
+bool MidiTransformerDialog::isSelected(Event& event, MidiPart*)
+ {
+ MidiTransformation* cmt = data->cmt;
+
+ switch (cmt->selEventOp) {
+ case Equal:
+ if (!typesMatch(event, cmt->selType)) {
+ return false;
+ }
+ break;
+ case Unequal:
+ if (typesMatch(event, cmt->selType))
+ return false;
+ break;
+ default:
+ break;
+ }
+ switch (cmt->selVal1) {
+ case Ignore:
+ break;
+ case Equal:
+ if (event.dataA() != cmt->selVal1a)
+ return false;
+ break;
+ case Unequal:
+ if (event.dataA() == cmt->selVal1a)
+ return false;
+ break;
+ case Higher:
+ if (event.dataA() <= cmt->selVal1a)
+ return false;
+ break;
+ case Lower:
+ if (event.dataA() >= cmt->selVal1a)
+ return false;
+ break;
+ case Inside:
+ if ((event.dataA() < cmt->selVal1a)
+ || (event.dataA() >= cmt->selVal1b))
+ return false;
+ break;
+ case Outside:
+ if ((event.dataA() >= cmt->selVal1a)
+ && (event.dataA() < cmt->selVal1b))
+ return false;
+ break;
+ }
+ switch (cmt->selVal2) {
+ case Ignore:
+ break;
+ case Equal:
+ if (event.dataB() != cmt->selVal2a)
+ return false;
+ break;
+ case Unequal:
+ if (event.dataB() == cmt->selVal2a)
+ return false;
+ break;
+ case Higher:
+ if (event.dataB() <= cmt->selVal2a)
+ return false;
+ break;
+ case Lower:
+ if (event.dataB() >= cmt->selVal2a)
+ return false;
+ break;
+ case Inside:
+ if ((event.dataB() < cmt->selVal2a)
+ || (event.dataB() >= cmt->selVal2b))
+ return false;
+ break;
+ case Outside:
+ if ((event.dataB() >= cmt->selVal2a)
+ && (event.dataB() < cmt->selVal2b))
+ return false;
+ break;
+ }
+ int len = event.lenTick();
+ switch (cmt->selLen) {
+ case Ignore:
+ break;
+ case Equal:
+ if (len != cmt->selLenA)
+ return false;
+ break;
+ case Unequal:
+ if (len == cmt->selLenA)
+ return false;
+ break;
+ case Higher:
+ if (len <= cmt->selLenA)
+ return false;
+ break;
+ case Lower:
+ if (len >= cmt->selLenA)
+ return false;
+ break;
+ case Inside:
+ if ((len < cmt->selLenA) || (len >= cmt->selLenB))
+ return false;
+ break;
+ case Outside:
+ if ((len >= cmt->selLenA) && (len < cmt->selLenB))
+ return false;
+ break;
+ }
+ int bar, beat;
+ unsigned tick;
+ AL::sigmap.tickValues(event.tick(), &bar, &beat, &tick);
+ int beat1 = cmt->selRangeA / 1000;
+ unsigned tick1 = cmt->selRangeA % 1000;
+ int beat2 = cmt->selRangeB / 1000;
+ unsigned tick2 = cmt->selRangeB % 1000;
+ switch (cmt->selRange) {
+ case Ignore:
+ break;
+ case Equal:
+ if (beat != beat1 || tick != tick1)
+ return false;
+ break;
+ case Unequal:
+ if (beat == beat1 && tick == tick1)
+ return false;
+ break;
+ case Higher:
+ if (beat <= beat1)
+ return false;
+ if (beat == beat1 && tick <= tick1)
+ return false;
+ break;
+ case Lower:
+ if (beat >= beat1)
+ return false;
+ if (beat == beat1 && tick >= tick1)
+ return false;
+ break;
+ case Inside:
+ if ((beat < beat1) || (beat >= beat2))
+ return false;
+ if (beat == beat1 && tick < tick1)
+ return false;
+ if (beat == beat2 && tick >= tick2)
+ return false;
+ break;
+ case Outside:
+ if ((beat >= beat1) || (beat < beat2))
+ return false;
+ if (beat == beat1 && tick >= tick1)
+ return false;
+ if (beat == beat2 && tick < tick2)
+ return false;
+ break;
+ }
+ return true;
+ }
+
+//---------------------------------------------------------
+// apply
+//---------------------------------------------------------
+
+void MidiTransformerDialog::apply()
+ {
+ int flags = 0;
+ song->startUndo();
+ audio->msgIdle(true);
+ bool copyExtract = (data->cmt->funcOp == Copy)
+ || (data->cmt->funcOp == Extract);
+
+ std::vector< EventList* > doneList;
+ typedef std::vector< EventList* >::iterator iDoneList;
+ iDoneList idl;
+
+ MidiTrackList* tracks = song->midis();
+ MidiTrackList tl;
+ for (iMidiTrack t = tracks->begin(); t != tracks->end(); ++t) {
+ if (data->cmt->selectedTracks && !(*t)->selected())
+ continue;
+ MidiTrack* newTrack = 0;
+ PartList *pl = (*t)->parts();
+ if (copyExtract) {
+ // check wether we must generate a new track
+ for (iPart p = pl->begin(); p != pl->end(); ++p) {
+ MidiPart* part = (MidiPart *) p->second;
+ EventList* el = part->events();
+ // Check if the event list has already been done. Skip repeated clones.
+ for(idl = doneList.begin(); idl != doneList.end(); ++idl)
+ if(*idl == el)
+ break;
+ if(idl != doneList.end())
+ break;
+ doneList.push_back(el);
+
+ for (iEvent i = el->begin(); i != el->end(); ++i) {
+ Event event = i->second;
+ unsigned tick = event.tick();
+ if (data->cmt->insideLoop && (tick < song->lpos() || tick >= song->rpos()))
+ continue;
+ if (isSelected(event, part)) {
+ newTrack = new MidiTrack();
+ tl.push_back(newTrack);
+ break;
+ }
+ }
+ if (newTrack)
+ break;
+ }
+ }
+
+ for (iPart p = pl->begin(); p != pl->end(); ++p) {
+ MidiPart* part = (MidiPart *) p->second;
+ MidiPart* newPart = 0;
+ EventList* el = part->events();
+ // Check if the event list has already been done. Skip repeated clones.
+ for(idl = doneList.begin(); idl != doneList.end(); ++idl)
+ if(*idl == el)
+ break;
+ if(idl != doneList.end())
+ break;
+ doneList.push_back(el);
+
+ if (copyExtract) {
+ // check wether we must generate a new part
+ for (iEvent i = el->begin(); i != el->end(); ++i) {
+ Event event = i->second;
+ unsigned tick = event.tick();
+ if (data->cmt->insideLoop && (tick < song->lpos() || tick >= song->rpos()))
+ continue;
+ if (isSelected(event, part)) {
+ newPart = new MidiPart(newTrack);
+ newPart->setName(part->name());
+ newPart->setColorIndex(part->colorIndex());
+ newPart->setTick(part->tick());
+ newPart->setLenTick(part->lenTick());
+ song->addPart(newPart);
+ flags |= SC_PART_INSERTED;
+ break;
+ }
+ }
+ }
+ EventList pel;
+ for (iEvent i = el->begin(); i != el->end(); ++i) {
+ Event event = i->second;
+ unsigned tick = event.tick();
+ if (data->cmt->insideLoop && (tick < song->lpos() || tick >= song->rpos()))
+ continue;
+ int flag = isSelected(event, part);
+ if (data->cmt->funcOp == Select)
+ event.setSelected(flag);
+ else if (flag)
+ pel.add(event);
+ }
+ for (iEvent i = pel.begin(); i != pel.end(); ++i) {
+ Event event = i->second;
+ processEvent(event, part, newPart);
+ }
+ }
+ }
+ if (!tl.empty()) {
+ flags |= SC_TRACK_INSERTED;
+ for (iTrack t = tl.begin(); t != tl.end(); ++t) {
+ song->insertTrack0(*t, -1);
+ }
+ }
+
+ switch(data->cmt->funcOp) {
+ case Select:
+ flags |= SC_SELECTION;
+ break;
+ case Quantize:
+ flags |= SC_EVENT_MODIFIED;
+ break;
+ case Delete:
+ flags |= SC_EVENT_REMOVED;
+ break;
+ case Transform:
+ flags |= SC_EVENT_MODIFIED;
+ break;
+ case Insert:
+ flags |= SC_EVENT_INSERTED;
+ break;
+ case Copy:
+ flags |= SC_EVENT_INSERTED;
+ case Extract:
+ break;
+ }
+ audio->msgIdle(false);
+ song->endUndo(flags);
+ }
+
+//---------------------------------------------------------
+// setValOp
+//---------------------------------------------------------
+
+void MidiTransformerDialog::setValOp(QWidget* a, QWidget* b, ValOp op)
+ {
+ switch (op) {
+ case Ignore:
+ a->setEnabled(false);
+ b->setEnabled(false);
+ break;
+ case Equal:
+ case Unequal:
+ case Higher:
+ case Lower:
+ a->setEnabled(true);
+ b->setEnabled(false);
+ break;
+ case Inside:
+ case Outside:
+ a->setEnabled(true);
+ b->setEnabled(true);
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// selEventOpSel
+//---------------------------------------------------------
+
+void MidiTransformerDialog::selEventOpSel(int val)
+ {
+ selType->setEnabled(val != All);
+ data->cmt->selEventOp = ValOp(val);
+ selVal1aChanged(data->cmt->selVal1a);
+ selVal1bChanged(data->cmt->selVal1b);
+ }
+
+//---------------------------------------------------------
+// selTypeSel
+//---------------------------------------------------------
+
+void MidiTransformerDialog::selTypeSel(int val)
+ {
+ data->cmt->selType = EventType(eventTypeTable[val]);
+ selVal1aChanged(data->cmt->selVal1a);
+ selVal1bChanged(data->cmt->selVal1b);
+ }
+
+//---------------------------------------------------------
+// selVal1OpSel
+//---------------------------------------------------------
+
+void MidiTransformerDialog::selVal1OpSel(int val)
+ {
+ setValOp(selVal1a, selVal1b, ValOp(val));
+ data->cmt->selVal1 = ValOp(val);
+ }
+
+//---------------------------------------------------------
+// selVal2OpSel
+//---------------------------------------------------------
+
+void MidiTransformerDialog::selVal2OpSel(int val)
+ {
+ setValOp(selVal2a, selVal2b, ValOp(val));
+ data->cmt->selVal2 = ValOp(val);
+ }
+
+//---------------------------------------------------------
+// selLenOpSel
+//---------------------------------------------------------
+
+void MidiTransformerDialog::selLenOpSel(int val)
+ {
+ setValOp(selLenA, selLenB, ValOp(val));
+ data->cmt->selLen = ValOp(val);
+ }
+
+//---------------------------------------------------------
+// selRangeOpSel
+//---------------------------------------------------------
+
+void MidiTransformerDialog::selRangeOpSel(int val)
+ {
+ setValOp(selBarA, selBarB, ValOp(val));
+ data->cmt->selRange = ValOp(val);
+ }
+
+//---------------------------------------------------------
+// procEventOpSel
+//---------------------------------------------------------
+
+void MidiTransformerDialog::procEventOpSel(int val)
+ {
+ TransformOperator op = val == 0 ? Keep : Fix;
+ procType->setEnabled(op == Fix);
+ data->cmt->procEvent = op;
+
+ procVal1aChanged(data->cmt->procVal1a);
+ procVal1bChanged(data->cmt->procVal1b);
+ }
+
+//---------------------------------------------------------
+// procEventTypeSel
+//---------------------------------------------------------
+
+void MidiTransformerDialog::procEventTypeSel(int val)
+ {
+ data->cmt->eventType = EventType(eventTypeTable[val]);
+ procVal1aChanged(data->cmt->procVal1a);
+ procVal1bChanged(data->cmt->procVal1b);
+ }
+
+//---------------------------------------------------------
+// procVal1OpSel
+//---------------------------------------------------------
+
+void MidiTransformerDialog::procVal1OpSel(int val)
+ {
+ data->cmt->procVal1 = TransformOperator(val);
+ switch(TransformOperator(val)) {
+ case Keep:
+ case Invert:
+ procVal1a->setEnabled(false);
+ procVal1b->setEnabled(false);
+ break;
+ case Multiply:
+ case Divide:
+ procVal1a->setEnabled(true);
+ procVal1a->setDecimals(2);
+ procVal1b->setEnabled(false);
+ break;
+ case Plus:
+ case Minus:
+ case Fix:
+ case Value:
+ case Flip:
+ procVal1a->setDecimals(0);
+ procVal1a->setEnabled(true);
+ procVal1b->setEnabled(false);
+ break;
+ case Random:
+ case ScaleMap:
+ case Dynamic:
+ procVal1a->setDecimals(0);
+ procVal1a->setEnabled(true);
+ procVal1b->setEnabled(true);
+ break;
+ }
+ procVal1aChanged(data->cmt->procVal1a);
+ procVal1bChanged(data->cmt->procVal1b);
+ }
+
+//---------------------------------------------------------
+// procVal2OpSel
+//---------------------------------------------------------
+
+void MidiTransformerDialog::procVal2OpSel(int val)
+ {
+ TransformOperator op = TransformOperator(procVal2Map[val]);
+ data->cmt->procVal2 = op;
+
+ switch (op) {
+ case Keep:
+ case Invert:
+ procVal2a->setEnabled(false);
+ procVal2b->setEnabled(false);
+ break;
+ case Multiply:
+ case Divide:
+ procVal2a->setEnabled(true);
+ procVal2a->setDecimals(2);
+ procVal2b->setEnabled(false);
+ break;
+ case Plus:
+ case Minus:
+ case Fix:
+ case Value:
+ procVal2a->setDecimals(0);
+ procVal2a->setEnabled(true);
+ procVal2b->setEnabled(false);
+ break;
+ case Random:
+ case Dynamic:
+ procVal2a->setDecimals(0);
+ procVal2a->setEnabled(true);
+ procVal2b->setEnabled(true);
+ break;
+ default:
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// procLenOpSel
+//---------------------------------------------------------
+
+void MidiTransformerDialog::procLenOpSel(int val)
+ {
+ TransformOperator op = TransformOperator(val);
+ data->cmt->procLen = op;
+
+ switch (op) {
+ case Keep:
+ case Invert:
+ procLenA->setEnabled(false);
+ break;
+ case Plus:
+ case Minus:
+ case Fix:
+ procLenA->setDecimals(0);
+ procLenA->setEnabled(true);
+ break;
+ case Multiply:
+ case Divide:
+ procLenA->setDecimals(2);
+ procLenA->setEnabled(true);
+ break;
+ default:
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// procPosOpSel
+//---------------------------------------------------------
+
+void MidiTransformerDialog::procPosOpSel(int val)
+ {
+ TransformOperator op = TransformOperator(val);
+ data->cmt->procPos = op;
+
+ switch (op) {
+ case Keep:
+ case Invert:
+ procPosA->setEnabled(false);
+ break;
+ case Multiply:
+ case Divide:
+ procPosA->setDecimals(2);
+ procPosA->setEnabled(true);
+ break;
+ case Plus:
+ case Minus:
+ procPosA->setDecimals(0);
+ procPosA->setEnabled(true);
+ break;
+ default:
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// funcOpSel
+//---------------------------------------------------------
+
+void MidiTransformerDialog::funcOpSel(int val)
+ {
+ funcQuantVal->setEnabled(val == Quantize);
+ bool isFuncOp = val == Transform || val == Insert;
+
+ procEventOp->setEnabled(isFuncOp);
+ procType->setEnabled(isFuncOp);
+ procVal1Op->setEnabled(isFuncOp);
+ procVal1a->setEnabled(isFuncOp);
+ procVal1b->setEnabled(isFuncOp);
+ procVal2Op->setEnabled(isFuncOp);
+ procVal2a->setEnabled(isFuncOp);
+ procVal2b->setEnabled(isFuncOp);
+ procLenOp->setEnabled(isFuncOp);
+ procLenA->setEnabled(isFuncOp);
+ procPosOp->setEnabled(isFuncOp);
+ procPosA->setEnabled(isFuncOp);
+ if (isFuncOp) {
+ procEventOpSel(data->cmt->procEvent);
+ procVal1OpSel(data->cmt->procVal1);
+ procVal2OpSel(data->cmt->procVal2);
+ procLenOpSel(data->cmt->procLen);
+ procPosOpSel(data->cmt->procPos);
+ }
+ data->cmt->funcOp = TransformFunction(val);
+ }
+
+//---------------------------------------------------------
+// presetNew
+//---------------------------------------------------------
+
+void MidiTransformerDialog::presetNew()
+ {
+ QString name;
+ for (int i = 0;; ++i) {
+ name.sprintf("New-%d", i);
+ iMidiTransformation imt;
+ for (imt = mtlist.begin(); imt != mtlist.end(); ++imt) {
+ if (name == (*imt)->name)
+ break;
+ }
+ if (imt == mtlist.end())
+ break;
+ }
+ MidiTransformation* mt = new MidiTransformation(name);
+ QListWidgetItem* lbi = new QListWidgetItem(name);
+ presetList->addItem(lbi);
+ mtlist.push_back(mt);
+ presetList->setCurrentItem(lbi);
+ presetChanged(lbi);
+ }
+
+//---------------------------------------------------------
+// presetDelete
+//---------------------------------------------------------
+
+void MidiTransformerDialog::presetDelete()
+ {
+ if (data->cindex != -1) {
+ iMidiTransformation mt = mtlist.begin();
+ for (int i = 0; i < data->cindex; ++i, ++mt) {
+ mtlist.erase(mt);
+ presetList->setCurrentItem(presetList->item(data->cindex - 1));
+ presetList->takeItem(data->cindex);
+ presetChanged(presetList->item(data->cindex - 1));
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// presetChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::presetChanged(QListWidgetItem* item)
+ {
+ data->cindex = presetList->row(item);
+ iMidiTransformation i;
+ for (i = mtlist.begin(); i != mtlist.end(); ++i) {
+ if (item->text() == (*i)->name) {
+ data->cmt = *i;
+ break;
+ }
+ }
+ if (i == mtlist.end()) {
+ printf("MidiTransformerDialog::presetChanged: not found\n");
+ return;
+ }
+ nameEntry->setText(data->cmt->name);
+ commentEntry->setText(data->cmt->comment);
+
+ selEventOp->setCurrentIndex(data->cmt->selEventOp);
+ selEventOpSel(data->cmt->selEventOp);
+
+ for (unsigned i = 0; i < sizeof(eventTypeTable)/sizeof(*eventTypeTable); ++i) {
+ if (eventTypeTable[i] == data->cmt->selType) {
+ selType->setCurrentIndex(i);
+ break;
+ }
+ }
+
+ selVal1Op->setCurrentIndex(data->cmt->selVal1);
+ selVal1OpSel(data->cmt->selVal1);
+
+ selVal2Op->setCurrentIndex(data->cmt->selVal2);
+ selVal2OpSel(data->cmt->selVal2);
+
+ selLenOp->setCurrentIndex(data->cmt->selLen);
+ selLenOpSel(data->cmt->selLen);
+
+ selRangeOp->setCurrentIndex(data->cmt->selRange);
+ selRangeOpSel(data->cmt->selRange);
+
+ funcOp->setCurrentIndex(data->cmt->funcOp);
+ funcOpSel(data->cmt->funcOp);
+
+ // TransformOperator procEvent: Keep, Fix
+ procEventOp->setCurrentIndex(data->cmt->procEvent == Fix);
+
+ procEventOpSel(data->cmt->procEvent);
+
+ procVal1Op->setCurrentIndex(data->cmt->procVal1);
+ procVal1OpSel(data->cmt->procVal1);
+
+ for (unsigned i = 0; i < sizeof(procVal2Map)/sizeof(*procVal2Map); ++i) {
+ if (procVal2Map[i] == data->cmt->procVal2) {
+ procVal2Op->setCurrentIndex(i);
+ break;
+ }
+ }
+ procLenOp->setCurrentIndex(data->cmt->procLen);
+ procLenOpSel(data->cmt->procLen);
+
+ procPosOp->setCurrentIndex(data->cmt->procPos);
+ procPosOpSel(data->cmt->procPos);
+
+ selVal1aChanged(data->cmt->selVal1a);
+ selVal1bChanged(data->cmt->selVal1b);
+ selVal2a->setValue(data->cmt->selVal2a);
+ selVal2b->setValue(data->cmt->selVal2b);
+ selLenA->setValue(data->cmt->selLenA);
+ selLenB->setValue(data->cmt->selLenB);
+ selBarA->setValue(data->cmt->selRangeA);
+ selBarB->setValue(data->cmt->selRangeB);
+ procVal1a->setValue(data->cmt->procVal1a);
+ procVal1b->setValue(data->cmt->procVal1b);
+ procVal2a->setValue(data->cmt->procVal2a);
+ procVal2b->setValue(data->cmt->procVal2b);
+ procLenA->setValue(data->cmt->procLenA);
+ procPosA->setValue(data->cmt->procPosA);
+ funcQuantVal->setValue(data->cmt->quantVal);
+
+ selectedTracks->setChecked(data->cmt->selectedTracks);
+ selectedTracksChanged(data->cmt->selectedTracks);
+ insideLoop->setChecked(data->cmt->insideLoop);
+ insideLoopChanged(data->cmt->insideLoop);
+ }
+
+//---------------------------------------------------------
+// nameChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::nameChanged(const QString& s)
+ {
+ data->cmt->name = s;
+ QListWidgetItem* item = presetList->item(data->cindex);
+ if (s != item->text()) {
+ disconnect(presetList, SIGNAL(highlighted(QListWidgetItem*)),
+ this, SLOT(presetChanged(QListWidgetItem*)));
+ presetList->insertItem(data->cindex, s);
+ presetList->takeItem(data->cindex);
+ presetList->setCurrentItem(presetList->item(data->cindex));
+ connect(presetList, SIGNAL(highlighted(QListWidgetItem*)),
+ SLOT(presetChanged(QListWidgetItem*)));
+ }
+ }
+
+//---------------------------------------------------------
+// commentChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::commentChanged()
+ {
+ data->cmt->comment = commentEntry->toPlainText();
+ }
+
+//-----------------------------op----------------------------
+// selVal1aChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::selVal1aChanged(int val)
+ {
+ data->cmt->selVal1a = val;
+ if ((data->cmt->selEventOp != All)
+ && (data->cmt->selType == Note)) {
+ selVal1a->setSuffix(" - " + pitch2string(val));
+ }
+ else
+ {
+ if(!selVal1a->suffix().isEmpty())
+ selVal1a->setSuffix(QString(""));
+ }
+ }
+
+//---------------------------------------------------------
+// selVal1bChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::selVal1bChanged(int val)
+ {
+ data->cmt->selVal1b = val;
+ if ((data->cmt->selEventOp != All)
+ && (data->cmt->selType == Note)) {
+ selVal1b->setSuffix(" - " + pitch2string(val));
+ }
+ else
+ {
+ if(!selVal1b->suffix().isEmpty())
+ selVal1b->setSuffix(QString(""));
+ }
+ }
+
+//---------------------------------------------------------
+// selVal2aChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::selVal2aChanged(int val)
+ {
+ data->cmt->selVal2a = val;
+ }
+
+//---------------------------------------------------------
+// selVal2bChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::selVal2bChanged(int val)
+ {
+ data->cmt->selVal2b = val;
+ }
+
+//---------------------------------------------------------
+// selLenAChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::selLenAChanged(int val)
+ {
+ data->cmt->selLenA = val;
+ }
+
+//---------------------------------------------------------
+// selLenBChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::selLenBChanged(int val)
+ {
+ data->cmt->selLenB = val;
+ }
+
+//---------------------------------------------------------
+// selBarAChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::selBarAChanged(int val)
+ {
+ data->cmt->selRangeA = val;
+ }
+
+//---------------------------------------------------------
+// selBarBChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::selBarBChanged(int val)
+ {
+ data->cmt->selRangeB = val;
+ }
+
+//---------------------------------------------------------
+// procVal1aChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::procVal1aChanged(int val)
+ {
+ data->cmt->procVal1a = val;
+
+ if((data->cmt->procEvent == Keep && data->cmt->selType == MIDITRANSFORM_NOTE) &&
+ (data->cmt->procVal1 == Fix || data->cmt->procVal1 == ScaleMap || data->cmt->procVal1 == Dynamic ||
+ data->cmt->procVal1 == Random || data->cmt->procVal1 == Flip))
+ {
+ procVal1a->setSuffix(" - " + pitch2string(val));
+ }
+ else
+ {
+ if(!procVal1a->suffix().isEmpty())
+ procVal1a->setSuffix(QString(""));
+ }
+
+ }
+
+//---------------------------------------------------------
+// procVal1bChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::procVal1bChanged(int val)
+ {
+ data->cmt->procVal1b = val;
+
+ if((data->cmt->procEvent == Keep && data->cmt->selType == MIDITRANSFORM_NOTE) &&
+ (data->cmt->procVal1 == Fix || data->cmt->procVal1 == ScaleMap || data->cmt->procVal1 == Dynamic ||
+ data->cmt->procVal1 == Random || data->cmt->procVal1 == Flip))
+ {
+ procVal1b->setSuffix(" - " + pitch2string(val));
+ }
+ else
+ {
+ if(!procVal1b->suffix().isEmpty())
+ procVal1b->setSuffix(QString(""));
+ }
+ }
+
+//---------------------------------------------------------
+// procVal2aChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::procVal2aChanged(int val)
+ {
+ data->cmt->procVal2a = val;
+ }
+
+//---------------------------------------------------------
+// procVal2bChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::procVal2bChanged(int val)
+ {
+ data->cmt->procVal2b = val;
+ }
+
+//---------------------------------------------------------
+// procLenAChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::procLenAChanged(int val)
+ {
+ data->cmt->procLenA = val;
+ }
+
+//---------------------------------------------------------
+// procPosAChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::procPosAChanged(int val)
+ {
+ data->cmt->procPosA = val;
+ }
+
+//---------------------------------------------------------
+// funcQuantValSel
+//---------------------------------------------------------
+
+void MidiTransformerDialog::funcQuantValSel(int val)
+ {
+ data->cmt->quantVal = val;
+ }
+
+//---------------------------------------------------------
+// processAllChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::processAllChanged(bool val)
+ {
+ if (val == true) {
+ selectedTracks->setChecked(false);
+ insideLoop->setChecked(false);
+ data->cmt->selectedTracks = false;
+ data->cmt->insideLoop = false;
+ }
+ }
+
+//---------------------------------------------------------
+// selectedTracksChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::selectedTracksChanged(bool val)
+ {
+ data->cmt->selectedTracks = val;
+ processAll->setChecked(!val && !data->cmt->insideLoop);
+ }
+
+//---------------------------------------------------------
+// insideLoopChanged
+//---------------------------------------------------------
+
+void MidiTransformerDialog::insideLoopChanged(bool val)
+ {
+ data->cmt->insideLoop = val;
+ processAll->setChecked(!data->cmt->selectedTracks && !val);
+ }
+
+
+
+/*!
+ \fn MidiTransformerDialog::typesMatch(MidiEvent e, unsigned t)
+ */
+bool MidiTransformerDialog::typesMatch(Event& e, unsigned selType)
+ {
+ bool matched = false;
+ switch (selType)
+ {
+ case MIDITRANSFORM_NOTE:
+ matched = (e.type() == Note);
+ break;
+ case MIDITRANSFORM_POLY:
+ matched = (e.type() == PAfter);
+ break;
+ case MIDITRANSFORM_CTRL:
+ matched = (e.type() == Controller);
+ break;
+ case MIDITRANSFORM_ATOUCH:
+ matched = (e.type() == CAfter);
+ break;
+ case MIDITRANSFORM_PITCHBEND:
+ {
+ if (e.type() == Controller) {
+ MidiController::ControllerType c = midiControllerType(e.dataA());
+ matched = (c == MidiController::Pitch);
+ }
+ break;
+ }
+ case MIDITRANSFORM_NRPN:
+ {
+ if (e.type() == Controller) {
+ MidiController::ControllerType c = midiControllerType(e.dataA());
+ matched = (c == MidiController::NRPN);
+ }
+ }
+ case MIDITRANSFORM_RPN:
+ {
+ if (e.type() == Controller) {
+ MidiController::ControllerType c = midiControllerType(e.dataA());
+ matched = (c == MidiController::RPN);
+ }
+ }
+ default:
+ fprintf(stderr, "Error matching type in MidiTransformerDialog: unknown eventtype!\n");
+ break;
+ }
+ //printf("Event type=%d, selType =%d matched=%d\n", e.type(), selType, matched);
+ return matched;
+ }
diff --git a/attic/muse2-oom/muse2/muse/miditransform.h b/attic/muse2-oom/muse2/muse/miditransform.h
new file mode 100644
index 00000000..4cf444bd
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/miditransform.h
@@ -0,0 +1,105 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: miditransform.h,v 1.2.2.2 2009/02/02 21:38:00 terminator356 Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MIDITRANSFORM_H__
+#define __MIDITRANSFORM_H__
+
+#include "ui_transformbase.h"
+
+class QListWidgetItem;
+class QDialog;
+class MidiTransformation;
+class MidiTransformPrivate;
+class Event;
+class MidiPart;
+class Xml;
+
+enum ValOp {
+ All=0, Ignore=0, Equal=1, Unequal=2, Higher=3, Lower=4,
+ Inside=5, Outside=6
+ };
+
+enum TransformFunction {
+ Select, Quantize, Delete, Transform, Insert, Copy, Extract
+ };
+
+enum TransformOperator {
+ Keep, Plus, Minus, Multiply, Divide, Fix, Value, Invert,
+ ScaleMap, Flip, Dynamic, Random
+ };
+
+//---------------------------------------------------------
+// MidiTransformDialog
+//---------------------------------------------------------
+
+class MidiTransformerDialog : public QDialog, public Ui::MidiTransformDialogBase {
+ Q_OBJECT
+ MidiTransformPrivate* data;
+
+ virtual void accept();
+// virtual void reject();
+ void setValOp(QWidget* a, QWidget* b, ValOp op);
+ void processEvent(Event&, MidiPart*, MidiPart*);
+ bool isSelected(Event&, MidiPart*);
+ void transformEvent(Event&, MidiPart*, MidiPart*);
+ bool typesMatch(Event& e, unsigned selType);
+
+ void updatePresetList();
+
+ private slots:
+ void apply();
+ void presetNew();
+ void presetDelete();
+
+ void selEventOpSel(int);
+ void selTypeSel(int);
+ void selVal1OpSel(int);
+ void selVal2OpSel(int);
+ void selLenOpSel(int);
+ void selRangeOpSel(int);
+ void procEventOpSel(int);
+ void procEventTypeSel(int);
+ void procVal1OpSel(int);
+ void procVal2OpSel(int);
+ void procLenOpSel(int);
+ void procPosOpSel(int);
+ void funcOpSel(int);
+ void presetChanged(QListWidgetItem*);
+ void nameChanged(const QString&);
+ void commentChanged();
+ void selVal1aChanged(int);
+ void selVal1bChanged(int);
+ void selVal2aChanged(int);
+ void selVal2bChanged(int);
+ void selLenAChanged(int);
+ void selLenBChanged(int);
+ void selBarAChanged(int);
+ void selBarBChanged(int);
+ void procVal1aChanged(int);
+ void procVal1bChanged(int);
+ void procVal2aChanged(int);
+ void procVal2bChanged(int);
+ void procLenAChanged(int);
+ void procPosAChanged(int);
+ void funcQuantValSel(int);
+ void processAllChanged(bool);
+ void selectedTracksChanged(bool);
+ void insideLoopChanged(bool);
+
+ public slots:
+ void songChanged(int);
+
+ public:
+ MidiTransformerDialog(QDialog* parent = 0, Qt::WFlags fl = 0);
+ ~MidiTransformerDialog();
+ };
+
+extern void writeMidiTransforms(int level, Xml& xml);
+extern void readMidiTransform(Xml&);
+extern void clearMidiTransforms();
+#endif
diff --git a/attic/muse2-oom/muse2/muse/mixer/CMakeLists.txt b/attic/muse2-oom/muse2/muse/mixer/CMakeLists.txt
new file mode 100644
index 00000000..62a4ed11
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/CMakeLists.txt
@@ -0,0 +1,101 @@
+#=============================================================================
+# MusE
+# Linux Music Editor
+# $Id:$
+#
+# Copyright (C) 2002-2006 by Werner Schweer and others
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#=============================================================================
+
+##
+## Expand Qt macros in source files
+##
+QT4_WRAP_CPP ( mixer_mocs
+ amixer.h
+ astrip.h
+ auxknob.h
+ meter.h
+ mstrip.h
+ panknob.h
+ rack.h
+ routedialog.h
+ strip.h
+ )
+
+##
+## UI files
+##
+file (GLOB mixer_ui_files
+ routedialogbase.ui
+ )
+QT4_WRAP_UI ( mixer_uis ${mixer_ui_files} )
+
+##
+## List of source files to compile
+##
+file (GLOB mixer_source_files
+ amixer.cpp
+ astrip.cpp
+ auxknob.cpp
+ meter.cpp
+ mstrip.cpp
+ panknob.cpp
+ rack.cpp
+ routedialog.cpp
+ strip.cpp
+ )
+
+##
+## Define target
+##
+add_library ( mixer SHARED
+ ${mixer_source_files}
+ ${mixer_mocs}
+ ${mixer_uis}
+ )
+
+##
+## Append to the list of translations
+##
+set (FILES_TO_TRANSLATE
+ ${FILES_TO_TRANSLATE}
+ ${mixer_source_files}
+ ${mixer_ui_files}
+ CACHE INTERNAL ""
+ )
+
+##
+## Compilation flags and target name
+##
+set_target_properties ( mixer
+ PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h -fPIC"
+ OUTPUT_NAME muse_mixer
+ )
+
+##
+## Linkage
+##
+target_link_libraries ( mixer
+ ${QT_LIBRARIES}
+ widgets
+ )
+
+##
+## Install location
+##
+install(TARGETS mixer
+ DESTINATION ${MusE_MODULES_DIR}
+ )
+
+
diff --git a/attic/muse2-oom/muse2/muse/mixer/amixer.cpp b/attic/muse2-oom/muse2/muse/mixer/amixer.cpp
new file mode 100644
index 00000000..7b7d9c93
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/amixer.cpp
@@ -0,0 +1,732 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: amixer.cpp,v 1.49.2.5 2009/11/16 01:55:55 terminator356 Exp $
+//
+// (C) Copyright 2000-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <list>
+#include <cmath>
+
+#include <QApplication>
+#include <QMenuBar>
+#include <QResizeEvent>
+#include <QPaintEvent>
+#include <QHBoxLayout>
+#include <QCloseEvent>
+#include <QMenu>
+#include <QActionGroup>
+#include <QAction>
+
+#include "app.h"
+#include "icons.h"
+#include "amixer.h"
+#include "song.h"
+
+#include "astrip.h"
+#include "mstrip.h"
+
+#include "gconfig.h"
+#include "xml.h"
+
+extern QActionGroup* populateAddTrack(QMenu* addTrack);
+
+#define __WIDTH_COMPENSATION 4
+
+//typedef std::list<Strip*> StripList;
+//static StripList stripList;
+
+
+/*
+Nov 16, 2010: After making the strips variable width, we need a way to
+ set the maximum size of the main window.
+
+// See help Qt4 "Window Geometry"
+// "On X11, a window does not have a frame until the window manager decorates it.
+// This happens asynchronously at some point in time after calling QWidget::show()
+// and the first paint event the window receives, or it does not happen at all.
+// " ...you cannot make any safe assumption about the decoration frame your window will get."
+// "X11 provides no standard or easy way to get the frame geometry once the window is decorated.
+// Qt solves this problem with nifty heuristics and clever code that works on a wide range of
+// window managers that exist today..."
+//
+
+Sequence of events when mixer is opened, and then when a strip is added:
+
+ViewWidget::event type:68 // Mixer opened:
+Event is QEvent::ChildAdded
+ViewWidget::event type:18
+ViewWidget::event type:27
+ViewWidget::event type:131
+ScrollArea::viewportEvent type:68
+Event is QEvent::ChildAdded
+ViewWidget::event type:21
+ViewWidget::event type:75
+ViewWidget::event type:70
+ScrollArea::viewportEvent type:69
+Event is QEvent::ChildPolished
+child width:100 frame width:100
+ViewWidget::event type:26
+ViewWidget::event type:68
+Event is QEvent::ChildAdded
+ViewWidget::event type:69
+Event is QEvent::ChildPolished
+child width:100 frame width:100 // Size is not correct yet
+AudioMixerApp::updateMixer other
+ScrollArea::viewportEvent type:75
+ScrollArea::viewportEvent type:70
+ScrollArea::viewportEvent type:13
+ScrollArea::viewportEvent type:14
+ViewWidget::event type:70
+ViewWidget::event type:13
+ViewWidget::event type:14
+ViewWidget::event type:17
+ScrollArea::viewportEvent type:17
+ScrollArea::viewportEvent type:26
+ViewWidget::event type:67
+ScrollArea::viewportEvent type:67
+ViewWidget::event type:67
+ScrollArea::viewportEvent type:14
+ViewWidget::event type:14
+ScrollArea::viewportEvent type:74
+ViewWidget::event type:74
+ViewWidget::event type:76
+ScrollArea::viewportEvent type:76 // Layout request:
+Event is QEvent::LayoutRequest
+AudioMixerApp::setSizing width:75 frame width:2
+ScrollArea::viewportEvent type:14
+ViewWidget::event type:14
+ViewWidget::event type:12 // Paint event:
+ViewWidget::paintEvent // By this time the size is correct.
+ScrollArea::viewportEvent type:24 // But to avoid having to do the resizing
+ViewWidget::event type:24 // in every paint event, do it just after
+ScrollArea::viewportEvent type:14 // the layout request, as shown above.
+ViewWidget::event type:14 // Hopefully that is a good time to do it.
+ViewWidget::event type:12
+ViewWidget::paintEvent
+ScrollArea::viewportEvent type:25
+ViewWidget::event type:25
+
+ViewWidget::event type:68 // Strip is added:
+Event is QEvent::ChildAdded
+ViewWidget::event type:69
+Event is QEvent::ChildPolished
+child width:100 frame width:100 // Size not correct yet.
+ViewWidget::event type:70
+AudioMixerApp::updateMixer other
+ViewWidget::event type:67
+ViewWidget::event type:76
+ScrollArea::viewportEvent type:76
+ViewWidget::event type:14
+Event is QEvent::LayoutRequest
+AudioMixerApp::setSizing width:75 frame width:2
+AudioMixerApp::setSizing width:75 frame width:2
+ViewWidget::event type:12 // Size is correct by now.
+ViewWidget::paintEvent
+*/
+
+bool ScrollArea::viewportEvent(QEvent* event)
+{
+ // Let it do the layout now, before we emit.
+ QScrollArea::viewportEvent(event);
+
+ if(event->type() == QEvent::LayoutRequest)
+ emit layoutRequest();
+
+ return false;
+}
+
+//---------------------------------------------------------
+// AudioMixer
+//
+// inputs | synthis | tracks | groups | master
+//---------------------------------------------------------
+
+AudioMixerApp::AudioMixerApp(QWidget* parent, MixerConfig* c)
+ : QMainWindow(parent)
+ {
+ cfg = c;
+ oldAuxsSize = 0;
+ routingDialog = 0;
+ setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding)); // TESTING Tim
+ setWindowTitle(cfg->name);
+ setWindowIcon(*museIcon);
+
+ QMenu* menuConfig = menuBar()->addMenu(tr("&Create"));
+ populateAddTrack(menuConfig);
+
+ QMenu* menuView = menuBar()->addMenu(tr("&View"));
+ routingId = menuView->addAction(tr("Routing"), this, SLOT(toggleRouteDialog()));
+ routingId->setCheckable(true);
+
+ menuView->addSeparator();
+
+ QActionGroup* actionItems = new QActionGroup(this);
+ actionItems->setExclusive(false);
+
+ showMidiTracksId = new QAction(tr("Show Midi Tracks"), actionItems);
+ showDrumTracksId = new QAction(tr("Show Drum Tracks"), actionItems);
+ showWaveTracksId = new QAction(tr("Show Wave Tracks"), actionItems);
+
+ QAction *separator = new QAction(this);
+ separator->setSeparator(true);
+ actionItems->addAction(separator);
+
+ showInputTracksId = new QAction(tr("Show Inputs"), actionItems);
+ showOutputTracksId = new QAction(tr("Show Outputs"), actionItems);
+ showGroupTracksId = new QAction(tr("Show Groups"), actionItems);
+ showAuxTracksId = new QAction(tr("Show Auxs"), actionItems);
+ showSyntiTracksId = new QAction(tr("Show Synthesizers"), actionItems);
+
+ showMidiTracksId->setCheckable(true);
+ showDrumTracksId->setCheckable(true);
+ showWaveTracksId->setCheckable(true);
+ showInputTracksId->setCheckable(true);
+ showOutputTracksId->setCheckable(true);
+ showGroupTracksId->setCheckable(true);
+ showAuxTracksId->setCheckable(true);
+ showSyntiTracksId->setCheckable(true);
+
+ //connect(menuView, SIGNAL(triggered(QAction*)), SLOT(showTracksChanged(QAction*)));
+ //connect(actionItems, SIGNAL(selected(QAction*)), this, SLOT(showTracksChanged(QAction*)));
+ connect(showMidiTracksId, SIGNAL(triggered(bool)), SLOT(showMidiTracksChanged(bool)));
+ connect(showDrumTracksId, SIGNAL(triggered(bool)), SLOT(showDrumTracksChanged(bool)));
+ connect(showWaveTracksId, SIGNAL(triggered(bool)), SLOT(showWaveTracksChanged(bool)));
+ connect(showInputTracksId, SIGNAL(triggered(bool)), SLOT(showInputTracksChanged(bool)));
+ connect(showOutputTracksId, SIGNAL(triggered(bool)), SLOT(showOutputTracksChanged(bool)));
+ connect(showGroupTracksId, SIGNAL(triggered(bool)), SLOT(showGroupTracksChanged(bool)));
+ connect(showAuxTracksId, SIGNAL(triggered(bool)), SLOT(showAuxTracksChanged(bool)));
+ connect(showSyntiTracksId, SIGNAL(triggered(bool)), SLOT(showSyntiTracksChanged(bool)));
+
+ menuView->addActions(actionItems->actions());
+
+ ///view = new QScrollArea();
+ view = new ScrollArea();
+ view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setCentralWidget(view);
+
+ central = new QWidget(view);
+ central->setObjectName("MixerCenter");
+ layout = new QHBoxLayout();
+ central->setLayout(layout);
+ layout->setSpacing(0);
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->setSpacing(0);
+ view->setWidget(central);
+ view->setWidgetResizable(true);
+
+ connect(view, SIGNAL(layoutRequest()), SLOT(setSizing()));
+ ///connect(this, SIGNAL(layoutRequest()), SLOT(setSizing()));
+
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+ connect(muse, SIGNAL(configChanged()), SLOT(configChanged()));
+ song->update(); // calls update mixer
+ }
+
+/*
+bool AudioMixerApp::event(QEvent* event)
+{
+ printf("AudioMixerApp::event type:%d\n", event->type()); // REMOVE Tim.
+
+ // Let it do the layout now, before we emit.
+ QMainWindow::event(event);
+
+ if(event->type() == QEvent::LayoutRequest)
+ emit layoutRequest();
+
+ return false;
+}
+*/
+
+void AudioMixerApp::setSizing()
+{
+ int w = 0;
+ StripList::iterator si = stripList.begin();
+ for (; si != stripList.end(); ++si)
+ {
+ //w += (*si)->frameGeometry().width();
+ //Strip* s = *si;
+ //printf("AudioMixerApp::setSizing width:%d frame width:%d\n", s->width(), s->frameWidth()); // REMOVE Tim
+ //w += s->width() + 2 * (s->frameWidth() + s->lineWidth() + s->midLineWidth());
+ //w += s->width() + 2 * s->frameWidth();
+ w += (*si)->width();
+ }
+
+ //w += 2* style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
+ // FIXME: When mixer first opened, frameSize is not correct yet, done after main window shown.
+ w += frameSize().width() - width();
+
+ if(w < 40)
+ w = 40;
+ setMaximumWidth(w);
+ if(stripList.size() <= 6)
+ view->setMinimumWidth(w);
+}
+
+//---------------------------------------------------------
+// addStrip
+//---------------------------------------------------------
+
+void AudioMixerApp::addStrip(Track* t, int idx)
+ {
+ StripList::iterator si = stripList.begin();
+ for (int i = 0; i < idx; ++i) {
+ if (si != stripList.end())
+ ++si;
+ }
+ if (si != stripList.end() && (*si)->getTrack() == t)
+ return;
+
+ std::list<Strip*>::iterator nsi = si;
+ ++nsi;
+ if (si != stripList.end()
+ && nsi != stripList.end()
+ && (*nsi)->getTrack() == t) {
+ layout->removeWidget(*si);
+ delete *si;
+ stripList.erase(si);
+ }
+ else {
+ Strip* strip;
+ if (t->isMidiTrack())
+ {
+ strip = new MidiStrip(central, (MidiTrack*)t);
+ }
+ else
+ {
+ strip = new AudioStrip(central, (AudioTrack*)t);
+ }
+ switch(t->type()) {/*{{{*/
+ case Track::AUDIO_OUTPUT:
+ strip->setObjectName("MixerAudioOutStrip");
+ break;
+ case Track::AUDIO_GROUP:
+ strip->setObjectName("MixerAudioGroupStrip");
+ break;
+ case Track::AUDIO_AUX:
+ strip->setObjectName("MixerAuxStrip");
+ break;
+ case Track::WAVE:
+ strip->setObjectName("MixerWaveStrip");
+ break;
+ case Track::AUDIO_INPUT:
+ strip->setObjectName("MixerAudioInStrip");
+ break;
+ case Track::AUDIO_SOFTSYNTH:
+ strip->setObjectName("MixerSynthStrip");
+ break;
+ case Track::MIDI:
+ case Track::DRUM:
+ {
+ strip->setObjectName("MidiTrackStrip");
+ }
+ break;
+ }/*}}}*/
+ layout->insertWidget(idx, strip);
+ stripList.insert(si, strip);
+ strip->show();
+ }
+ }
+
+//---------------------------------------------------------
+// clear
+//---------------------------------------------------------
+
+void AudioMixerApp::clear()
+ {
+ StripList::iterator si = stripList.begin();
+ for (; si != stripList.end(); ++si) {
+ layout->removeWidget(*si);
+ delete *si;
+ }
+ stripList.clear();
+ oldAuxsSize = -1;
+ }
+
+//---------------------------------------------------------
+// updateMixer
+//---------------------------------------------------------
+
+void AudioMixerApp::updateMixer(UpdateAction action)
+ {
+ //printf("AudioMixerApp::updateMixer action:%d\n", action);
+
+ //name = cfg->name;
+ //setCaption(name);
+ setWindowTitle(cfg->name);
+
+ showMidiTracksId->setChecked(cfg->showMidiTracks);
+ showDrumTracksId->setChecked(cfg->showDrumTracks);
+ showInputTracksId->setChecked(cfg->showInputTracks);
+ showOutputTracksId->setChecked(cfg->showOutputTracks);
+ showWaveTracksId->setChecked(cfg->showWaveTracks);
+ showGroupTracksId->setChecked(cfg->showGroupTracks);
+ showAuxTracksId->setChecked(cfg->showAuxTracks);
+ showSyntiTracksId->setChecked(cfg->showSyntiTracks);
+
+ int auxsSize = song->auxs()->size();
+ if ((action == UPDATE_ALL) || (auxsSize != oldAuxsSize)) {
+ clear();
+ oldAuxsSize = auxsSize;
+ }
+ else if (action == STRIP_REMOVED)
+ {
+ StripList::iterator si = stripList.begin();
+ for (; si != stripList.end();) {
+ Track* track = (*si)->getTrack();
+ TrackList* tl = song->tracks();
+ iTrack it;
+ for (it = tl->begin(); it != tl->end(); ++it) {
+ if (*it == track)
+ break;
+ }
+ StripList::iterator ssi = si;
+ ++si;
+ if (it != tl->end())
+ continue;
+ layout->removeWidget(*ssi);
+ delete *ssi;
+ stripList.erase(ssi);
+ }
+
+ //printf("AudioMixerApp::updateMixer STRIP_REMOVED\n"); // REMOVE Tim
+
+ //setMaximumWidth(STRIP_WIDTH * stripList.size() + __WIDTH_COMPENSATION);
+/// int w = computeWidth();
+/// setMaximumWidth(w);
+/// if (stripList.size() < 8)
+ // view->setMinimumWidth(stripList.size() * STRIP_WIDTH + __WIDTH_COMPENSATION);
+/// view->setMinimumWidth(w);
+
+ return;
+ }
+ // Added by Tim. p3.3.7
+ else if (action == UPDATE_MIDI)
+ {
+ int i = 0;
+ int idx = -1;
+ StripList::iterator si = stripList.begin();
+ for (; si != stripList.end(); ++i)
+ {
+ Track* track = (*si)->getTrack();
+ if(!track->isMidiTrack())
+ {
+ ++si;
+ continue;
+ }
+
+ if(idx == -1)
+ idx = i;
+
+ StripList::iterator ssi = si;
+ ++si;
+ layout->removeWidget(*ssi);
+ delete *ssi;
+ stripList.erase(ssi);
+ }
+
+ if(idx == -1)
+ idx = 0;
+
+ //---------------------------------------------------
+ // generate Midi channel/port Strips
+ //---------------------------------------------------
+
+ MidiTrackList* mtl = song->midis();
+ for (iMidiTrack i = mtl->begin(); i != mtl->end(); ++i)
+ {
+ MidiTrack* mt = *i;
+ if((mt->type() == Track::MIDI && cfg->showMidiTracks) || (mt->type() == Track::DRUM && cfg->showDrumTracks))
+ addStrip(*i, idx++);
+ }
+
+ //printf("AudioMixerApp::updateMixer UPDATE_MIDI\n"); // REMOVE Tim
+
+ //setMaximumWidth(STRIP_WIDTH * stripList.size() + __WIDTH_COMPENSATION);
+/// int w = computeWidth();
+/// setMaximumWidth(w);
+/// if (stripList.size() < 8)
+ // view->setMinimumWidth(stripList.size() * STRIP_WIDTH + __WIDTH_COMPENSATION);
+/// view->setMinimumWidth(w);
+ return;
+ }
+
+ int idx = 0;
+ //---------------------------------------------------
+ // generate Input Strips
+ //---------------------------------------------------
+
+ if(cfg->showInputTracks)
+ {
+ InputList* itl = song->inputs();
+ for (iAudioInput i = itl->begin(); i != itl->end(); ++i)
+ addStrip(*i, idx++);
+ }
+
+ //---------------------------------------------------
+ // Synthesizer Strips
+ //---------------------------------------------------
+
+ if(cfg->showSyntiTracks)
+ {
+ SynthIList* sl = song->syntis();
+ for (iSynthI i = sl->begin(); i != sl->end(); ++i)
+ addStrip(*i, idx++);
+ }
+
+ //---------------------------------------------------
+ // generate Wave Track Strips
+ //---------------------------------------------------
+
+ if(cfg->showWaveTracks)
+ {
+ WaveTrackList* wtl = song->waves();
+ for (iWaveTrack i = wtl->begin(); i != wtl->end(); ++i)
+ addStrip(*i, idx++);
+ }
+
+ //---------------------------------------------------
+ // generate Midi channel/port Strips
+ //---------------------------------------------------
+
+ MidiTrackList* mtl = song->midis();
+ for (iMidiTrack i = mtl->begin(); i != mtl->end(); ++i)
+ {
+ MidiTrack* mt = *i;
+ if((mt->type() == Track::MIDI && cfg->showMidiTracks) || (mt->type() == Track::DRUM && cfg->showDrumTracks))
+ addStrip(*i, idx++);
+ }
+
+ //---------------------------------------------------
+ // Groups
+ //---------------------------------------------------
+
+ if(cfg->showGroupTracks)
+ {
+ GroupList* gtl = song->groups();
+ for (iAudioGroup i = gtl->begin(); i != gtl->end(); ++i)
+ addStrip(*i, idx++);
+ }
+
+ //---------------------------------------------------
+ // Aux
+ //---------------------------------------------------
+
+ if(cfg->showAuxTracks)
+ {
+ AuxList* al = song->auxs();
+ for (iAudioAux i = al->begin(); i != al->end(); ++i)
+ addStrip(*i, idx++);
+ }
+
+ //---------------------------------------------------
+ // Master
+ //---------------------------------------------------
+
+ if(cfg->showOutputTracks)
+ {
+ OutputList* otl = song->outputs();
+ for (iAudioOutput i = otl->begin(); i != otl->end(); ++i)
+ addStrip(*i, idx++);
+ }
+
+ //printf("AudioMixerApp::updateMixer other\n"); // REMOVE Tim
+
+ //setMaximumWidth(STRIP_WIDTH * idx + __WIDTH_COMPENSATION);
+/// int w = computeWidth();
+/// setMaximumWidth(w);
+/// if (idx < 8)
+ // view->setMinimumWidth(idx * STRIP_WIDTH + __WIDTH_COMPENSATION);
+/// view->setMinimumWidth(w);
+ }
+
+//---------------------------------------------------------
+// configChanged
+//---------------------------------------------------------
+
+void AudioMixerApp::configChanged()
+{
+ songChanged(SC_CONFIG);
+}
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void AudioMixerApp::songChanged(int flags)
+ {
+ // Is it simply a midi controller value adjustment? Forget it.
+ if(flags == SC_MIDI_CONTROLLER)
+ return;
+
+ UpdateAction action = NO_UPDATE;
+ if (flags == -1)
+ action = UPDATE_ALL;
+ else if (flags & SC_TRACK_REMOVED)
+ action = STRIP_REMOVED;
+ else if (flags & SC_TRACK_INSERTED)
+ action = STRIP_INSERTED;
+ else if (flags & SC_MIDI_TRACK_PROP)
+ action = UPDATE_MIDI;
+ if (action != NO_UPDATE)
+ updateMixer(action);
+ if (action != UPDATE_ALL) {
+ StripList::iterator si = stripList.begin();
+ for (; si != stripList.end(); ++si) {
+ (*si)->songChanged(flags);
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void AudioMixerApp::closeEvent(QCloseEvent* e)
+ {
+ emit closed();
+ e->accept();
+ }
+
+//---------------------------------------------------------
+// toggleRouteDialog
+//---------------------------------------------------------
+
+void AudioMixerApp::toggleRouteDialog()
+ {
+ showRouteDialog(routingId->isChecked());
+ }
+
+//---------------------------------------------------------
+// showRouteDialog
+//---------------------------------------------------------
+
+void AudioMixerApp::showRouteDialog(bool on)
+ {
+ if (on && routingDialog == 0) {
+ routingDialog = new RouteDialog(this);
+ connect(routingDialog, SIGNAL(closed()), SLOT(routingDialogClosed()));
+ }
+ if (routingDialog)
+ routingDialog->setVisible(on);
+ //menuView->setItemChecked(routingId, on);
+ routingId->setChecked(on);
+ }
+
+//---------------------------------------------------------
+// routingDialogClosed
+//---------------------------------------------------------
+
+void AudioMixerApp::routingDialogClosed()
+ {
+ routingId->setChecked(false);
+ }
+
+//---------------------------------------------------------
+// showTracksChanged
+//---------------------------------------------------------
+
+/*
+void AudioMixerApp::showTracksChanged(QAction* id)
+ {
+ bool val = id->isOn();
+ if (id == showMidiTracksId)
+ cfg->showMidiTracks = val;
+ else if (id == showDrumTracksId)
+ cfg->showDrumTracks = val;
+ else if (id == showInputTracksId)
+ cfg->showInputTracks = val;
+ else if (id == showOutputTracksId)
+ cfg->showOutputTracks = val;
+ else if (id == showWaveTracksId)
+ cfg->showWaveTracks = val;
+ else if (id == showGroupTracksId)
+ cfg->showGroupTracks = val;
+ else if (id == showAuxTracksId)
+ cfg->showAuxTracks = val;
+ else if (id == showSyntiTracksId)
+ cfg->showSyntiTracks = val;
+ updateMixer(UPDATE_ALL);
+ }
+*/
+
+void AudioMixerApp::showMidiTracksChanged(bool v)
+{
+ cfg->showMidiTracks = v;
+ updateMixer(UPDATE_ALL);
+}
+
+void AudioMixerApp::showDrumTracksChanged(bool v)
+{
+ cfg->showDrumTracks = v;
+ updateMixer(UPDATE_ALL);
+}
+
+void AudioMixerApp::showWaveTracksChanged(bool v)
+{
+ cfg->showWaveTracks = v;
+ updateMixer(UPDATE_ALL);
+}
+
+void AudioMixerApp::showInputTracksChanged(bool v)
+{
+ cfg->showInputTracks = v;
+ updateMixer(UPDATE_ALL);
+}
+
+void AudioMixerApp::showOutputTracksChanged(bool v)
+{
+ cfg->showOutputTracks = v;
+ updateMixer(UPDATE_ALL);
+}
+
+void AudioMixerApp::showGroupTracksChanged(bool v)
+{
+ cfg->showGroupTracks = v;
+ updateMixer(UPDATE_ALL);
+}
+
+void AudioMixerApp::showAuxTracksChanged(bool v)
+{
+ cfg->showAuxTracks = v;
+ updateMixer(UPDATE_ALL);
+}
+
+void AudioMixerApp::showSyntiTracksChanged(bool v)
+{
+ cfg->showSyntiTracks = v;
+ updateMixer(UPDATE_ALL);
+}
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+//void AudioMixerApp::write(Xml& xml, const char* name)
+void AudioMixerApp::write(int level, Xml& xml)
+//void AudioMixerApp::write(int level, Xml& xml, const char* name)
+ {
+ //xml.stag(QString(name));
+ //xml.tag(level++, name.toLatin1());
+ xml.tag(level++, "Mixer");
+
+ xml.strTag(level, "name", cfg->name);
+
+ //xml.tag("geometry", geometry());
+ xml.qrectTag(level, "geometry", geometry());
+
+ xml.intTag(level, "showMidiTracks", cfg->showMidiTracks);
+ xml.intTag(level, "showDrumTracks", cfg->showDrumTracks);
+ xml.intTag(level, "showInputTracks", cfg->showInputTracks);
+ xml.intTag(level, "showOutputTracks", cfg->showOutputTracks);
+ xml.intTag(level, "showWaveTracks", cfg->showWaveTracks);
+ xml.intTag(level, "showGroupTracks", cfg->showGroupTracks);
+ xml.intTag(level, "showAuxTracks", cfg->showAuxTracks);
+ xml.intTag(level, "showSyntiTracks", cfg->showSyntiTracks);
+
+ //xml.etag(name);
+ //xml.etag(level, name.toLatin1());
+ xml.etag(level, "Mixer");
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/mixer/amixer.h b/attic/muse2-oom/muse2/muse/mixer/amixer.h
new file mode 100644
index 00000000..f8e365c3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/amixer.h
@@ -0,0 +1,132 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: amixer.h,v 1.27.2.2 2009/10/18 06:13:00 terminator356 Exp $
+//
+// (C) Copyright 2000-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __AMIXER_H__
+#define __AMIXER_H__
+
+#include <QScrollArea>
+
+#include "cobject.h"
+#include "synth.h"
+#include "node.h"
+#include "routedialog.h"
+
+class QHBoxLayout;
+class QLabel;
+class QMenu;
+class QToolButton;
+class QWidget;
+
+class Xml;
+class AudioTrack;
+class Meter;
+class Track;
+class Slider;
+class Knob;
+class DoubleLabel;
+class ComboBox;
+class RouteDialog;
+class Strip;
+
+struct MixerConfig;
+
+#define EFX_HEIGHT 16
+
+typedef std::list<Strip*> StripList;
+
+//---------------------------------------------------------
+// ScrollArea
+//---------------------------------------------------------
+
+class ScrollArea : public QScrollArea
+{
+ Q_OBJECT
+
+ signals:
+ void layoutRequest();
+
+ protected:
+ virtual bool viewportEvent(QEvent* event);
+
+ public:
+ ScrollArea(QWidget* parent = 0) : QScrollArea(parent) { }
+};
+
+//---------------------------------------------------------
+// AudioMixerApp
+//---------------------------------------------------------
+
+class AudioMixerApp : public QMainWindow {
+ //QString name;
+ MixerConfig* cfg;
+ StripList stripList;
+ QScrollArea* view;
+ QWidget* central;
+ QHBoxLayout* lbox;
+ //Strip* master;
+ QHBoxLayout* layout;
+ QMenu* menuView;
+ RouteDialog* routingDialog;
+ QAction* routingId;
+ int oldAuxsSize;
+
+ QAction* showMidiTracksId;
+ QAction* showDrumTracksId;
+ QAction* showInputTracksId;
+ QAction* showOutputTracksId;
+ QAction* showWaveTracksId;
+ QAction* showGroupTracksId;
+ QAction* showAuxTracksId;
+ QAction* showSyntiTracksId;
+
+ Q_OBJECT
+
+ virtual void closeEvent(QCloseEvent*);
+ void addStrip(Track*, int);
+ void showRouteDialog(bool);
+
+ enum UpdateAction {
+ NO_UPDATE, UPDATE_ALL, UPDATE_MIDI, STRIP_INSERTED, STRIP_REMOVED
+ };
+ void updateMixer(UpdateAction);
+
+ signals:
+ void closed();
+ //void layoutRequest();
+
+ private slots:
+ void songChanged(int);
+ //void configChanged() { songChanged(-1); }
+ void configChanged();
+ void setSizing();
+ void toggleRouteDialog();
+ void routingDialogClosed();
+ //void showTracksChanged(QAction*);
+ void showMidiTracksChanged(bool);
+ void showDrumTracksChanged(bool);
+ void showWaveTracksChanged(bool);
+ void showInputTracksChanged(bool);
+ void showOutputTracksChanged(bool);
+ void showGroupTracksChanged(bool);
+ void showAuxTracksChanged(bool);
+ void showSyntiTracksChanged(bool);
+
+ //protected:
+ // virtual bool event(QEvent* event);
+
+ public:
+ //AudioMixerApp(QWidget* parent);
+ AudioMixerApp(QWidget* parent, MixerConfig* c);
+ //void write(Xml&, const char* name);
+ //void write(int level, Xml& xml, const char* name);
+ void write(int level, Xml& xml);
+ void clear();
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/mixer/astrip.cpp b/attic/muse2-oom/muse2/muse/mixer/astrip.cpp
new file mode 100644
index 00000000..58e75f67
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/astrip.cpp
@@ -0,0 +1,1996 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: astrip.cpp,v 1.23.2.17 2009/11/16 01:55:55 terminator356 Exp $
+//
+// (C) Copyright 2000-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <fastlog.h>
+
+#include <QLayout>
+#include <QApplication>
+//#include <QDialog>
+#include <QToolButton>
+#include <QLabel>
+#include <QComboBox>
+#include <QToolTip>
+#include <QTimer>
+//#include <QPopupMenu>
+#include <QCursor>
+#include <QPainter>
+#include <QString>
+#include <QPoint>
+#include <QEvent>
+#include <QWidget>
+#include <QVariant>
+#include <QAction>
+#include <QGridLayout>
+
+#include "app.h"
+#include "globals.h"
+#include "audio.h"
+#include "driver/audiodev.h"
+#include "song.h"
+#include "slider.h"
+#include "knob.h"
+#include "combobox.h"
+#include "meter.h"
+#include "astrip.h"
+#include "track.h"
+#include "synth.h"
+//#include "route.h"
+#include "doublelabel.h"
+#include "rack.h"
+#include "node.h"
+#include "amixer.h"
+#include "icons.h"
+#include "gconfig.h"
+#include "ttoolbutton.h"
+#include "menutitleitem.h"
+#include "popupmenu.h"
+
+//---------------------------------------------------------
+// MenuTitleItem
+//---------------------------------------------------------
+
+MenuTitleItem::MenuTitleItem(const QString& ss, QWidget* parent)
+ : QWidgetAction(parent)
+ {
+ s = ss;
+ // Don't allow to click on it.
+ setEnabled(false);
+ // Just to be safe, set to -1 instead of default 0.
+ setData(-1);
+ }
+
+QWidget* MenuTitleItem::createWidget(QWidget *parent)
+{
+ QLabel* l = new QLabel(s, parent);
+ l->setAlignment(Qt::AlignCenter);
+ return l;
+}
+
+/*
+//---------------------------------------------------------
+// minimumSizeHint
+//---------------------------------------------------------
+
+QSize AudioStrip::minimumSizeHint () const
+{
+ // We force the width of the size hint to be what we want
+ //return QWidget::minimumSizeHint();
+ ///return QSize(66,QWidget::minimumSizeHint().height());
+}
+
+//---------------------------------------------------------
+// sizeHint
+//---------------------------------------------------------
+
+QSize AudioStrip::sizeHint () const
+{
+ // We force the width of the size hint to be what we want
+ //return QWidget::minimumSizeHint();
+ //return QSize(66,QWidget::minimumSizeHint().height());
+ return minimumSizeHint();
+}
+*/
+
+//---------------------------------------------------------
+// heartBeat
+//---------------------------------------------------------
+
+void AudioStrip::heartBeat()
+ {
+ for (int ch = 0; ch < track->channels(); ++ch) {
+ if (meter[ch]) {
+ //int meterVal = track->meter(ch);
+ //int peak = track->peak(ch);
+ //meter[ch]->setVal(meterVal, peak, false);
+ meter[ch]->setVal(track->meter(ch), track->peak(ch), false);
+ }
+ }
+ Strip::heartBeat();
+ updateVolume();
+ updatePan();
+ }
+
+//---------------------------------------------------------
+// configChanged
+//---------------------------------------------------------
+
+void AudioStrip::configChanged()
+{
+ songChanged(SC_CONFIG);
+}
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void AudioStrip::songChanged(int val)
+ {
+ // Is it simply a midi controller value adjustment? Forget it.
+ if (val == SC_MIDI_CONTROLLER)
+ return;
+
+ AudioTrack* src = (AudioTrack*)track;
+
+ // Do channels before config...
+ if (val & SC_CHANNELS)
+ updateChannels();
+
+ // p3.3.47
+ // Update the routing popup menu if anything relevant changed.
+ if (val & (SC_ROUTE | SC_CHANNELS | SC_CONFIG))
+ {
+ //updateRouteMenus();
+ muse->updateRouteMenus(track, this); // p3.3.50 Use this handy shared routine.
+ }
+
+ // Catch when label font, or configuration min slider and meter values change.
+ if (val & SC_CONFIG)
+ {
+ // Added by Tim. p3.3.9
+
+ // Set the strip label's font.
+ //label->setFont(config.fonts[1]);
+ setLabelFont();
+
+ // Adjust minimum volume slider and label values.
+ slider->setRange(config.minSlider-0.1, 10.0);
+ sl->setRange(config.minSlider, 10.0);
+
+ // Adjust minimum aux knob and label values.
+ int n = auxKnob.size();
+ for (int idx = 0; idx < n; ++idx)
+ {
+ auxKnob[idx]->blockSignals(true);
+ auxLabel[idx]->blockSignals(true);
+ auxKnob[idx]->setRange(config.minSlider-0.1, 10.0);
+ auxLabel[idx]->setRange(config.minSlider, 10.1);
+ auxKnob[idx]->blockSignals(false);
+ auxLabel[idx]->blockSignals(false);
+ }
+
+ // Adjust minimum meter values.
+ for(int c = 0; c < channel; ++c)
+ meter[c]->setRange(config.minMeter, 10.0);
+ }
+
+ if (mute && (val & SC_MUTE)) { // mute && off
+ mute->blockSignals(true);
+ mute->setChecked(src->mute());
+ mute->blockSignals(false);
+ updateOffState();
+ }
+ if (solo && (val & SC_SOLO)) {
+ if((bool)track->internalSolo())
+ {
+ if(!useSoloIconSet2)
+ {
+ solo->setIcon(*soloIconSet2);
+ solo->setIconSize(soloIconOn->size());
+ useSoloIconSet2 = true;
+ }
+ }
+ else if(useSoloIconSet2)
+ {
+ solo->setIcon(*soloIconSet1);
+ solo->setIconSize(soloblksqIconOn->size());
+ useSoloIconSet2 = false;
+ }
+
+ solo->blockSignals(true);
+ solo->setChecked(track->solo());
+ solo->blockSignals(false);
+ }
+ if (val & SC_RECFLAG)
+ setRecordFlag(track->recordFlag());
+ if (val & SC_TRACK_MODIFIED)
+ {
+ setLabelText();
+ // Added by Tim. p3.3.9
+ setLabelFont();
+
+ }
+ //if (val & SC_CHANNELS)
+ // updateChannels();
+ if (val & SC_ROUTE) {
+ if (pre) {
+ pre->blockSignals(true);
+ pre->setChecked(src->prefader());
+ pre->blockSignals(false);
+ }
+ }
+ if (val & SC_AUX) {
+ int n = auxKnob.size();
+ for (int idx = 0; idx < n; ++idx) {
+ double val = fast_log10(src->auxSend(idx)) * 20.0;
+ auxKnob[idx]->blockSignals(true);
+ auxLabel[idx]->blockSignals(true);
+ auxKnob[idx]->setValue(val);
+ auxLabel[idx]->setValue(val);
+ auxKnob[idx]->blockSignals(false);
+ auxLabel[idx]->blockSignals(false);
+ }
+ }
+ if (autoType && (val & SC_AUTOMATION)) {
+ autoType->blockSignals(true);
+ autoType->setCurrentItem(track->automationType());
+ if(track->automationType() == AUTO_TOUCH || track->automationType() == AUTO_WRITE)
+ {
+ //autoType->setPaletteBackgroundColor(Qt::red);
+ QPalette palette;
+ palette.setColor(autoType->backgroundRole(), QColor(Qt::red));
+ autoType->setPalette(palette);
+ }
+ else
+ {
+ //autoType->setPaletteBackgroundColor(qApp->palette().active().background());
+ QPalette palette;
+ palette.setColor(autoType->backgroundRole(), qApp->palette().color(QPalette::Active, QPalette::Background));
+ autoType->setPalette(palette);
+ }
+
+ autoType->blockSignals(false);
+ }
+ }
+
+//---------------------------------------------------------
+// updateVolume
+//---------------------------------------------------------
+
+void AudioStrip::updateVolume()
+{
+ double vol = ((AudioTrack*)track)->volume();
+ if (vol != volume)
+ {
+ //printf("AudioStrip::updateVolume setting slider and label\n");
+
+ slider->blockSignals(true);
+ sl->blockSignals(true);
+ double val = fast_log10(vol) * 20.0;
+ slider->setValue(val);
+ sl->setValue(val);
+ sl->blockSignals(false);
+ slider->blockSignals(false);
+ volume = vol;
+ }
+}
+
+//---------------------------------------------------------
+// updatePan
+//---------------------------------------------------------
+
+void AudioStrip::updatePan()
+{
+ double v = ((AudioTrack*)track)->pan();
+ if (v != panVal)
+ {
+ //printf("AudioStrip::updatePan setting slider and label\n");
+
+ pan->blockSignals(true);
+ panl->blockSignals(true);
+ pan->setValue(v);
+ panl->setValue(v);
+ panl->blockSignals(false);
+ pan->blockSignals(false);
+ panVal = v;
+ }
+}
+
+//---------------------------------------------------------
+// offToggled
+//---------------------------------------------------------
+
+void AudioStrip::offToggled(bool val)
+ {
+ track->setOff(val);
+ song->update(SC_MUTE);
+ }
+
+//---------------------------------------------------------
+// updateOffState
+//---------------------------------------------------------
+
+void AudioStrip::updateOffState()
+ {
+ bool val = !track->off();
+ slider->setEnabled(val);
+ sl->setEnabled(val);
+ pan->setEnabled(val);
+ panl->setEnabled(val);
+ if (track->type() != Track::AUDIO_SOFTSYNTH)
+ stereo->setEnabled(val);
+ label->setEnabled(val);
+
+ int n = auxKnob.size();
+ for (int i = 0; i < n; ++i)
+ {
+ auxKnob[i]->setEnabled(val);
+ auxLabel[i]->setEnabled(val);
+ }
+
+ if (pre)
+ pre->setEnabled(val);
+ if (record)
+ record->setEnabled(val);
+ if (solo)
+ solo->setEnabled(val);
+ if (mute)
+ mute->setEnabled(val);
+ if (autoType)
+ autoType->setEnabled(val);
+ if (iR)
+ iR->setEnabled(val);
+ if (oR)
+ oR->setEnabled(val);
+ if (off) {
+ off->blockSignals(true);
+ off->setChecked(track->off());
+ off->blockSignals(false);
+ }
+ }
+
+//---------------------------------------------------------
+// preToggled
+//---------------------------------------------------------
+
+void AudioStrip::preToggled(bool val)
+ {
+ audio->msgSetPrefader((AudioTrack*)track, val);
+ resetPeaks();
+ song->update(SC_ROUTE);
+ }
+
+//---------------------------------------------------------
+// stereoToggled
+//---------------------------------------------------------
+
+void AudioStrip::stereoToggled(bool val)
+ {
+ int oc = track->channels();
+ int nc = val ? 2 : 1;
+// stereo->setIcon(nc == 2 ? *stereoIcon : *monoIcon);
+ if (oc == nc)
+ return;
+ audio->msgSetChannels((AudioTrack*)track, nc);
+ song->update(SC_CHANNELS);
+ }
+
+//---------------------------------------------------------
+// auxChanged
+//---------------------------------------------------------
+
+void AudioStrip::auxChanged(double val, int idx)
+ {
+ double vol;
+ if (val <= config.minSlider) {
+ vol = 0.0;
+ val -= 1.0; // display special value "off"
+ }
+ else
+ vol = pow(10.0, val/20.0);
+ audio->msgSetAux((AudioTrack*)track, idx, vol);
+ song->update(SC_AUX);
+ }
+
+//---------------------------------------------------------
+// auxLabelChanged
+//---------------------------------------------------------
+
+void AudioStrip::auxLabelChanged(double val, unsigned int idx)
+ {
+ if(idx >= auxKnob.size())
+ return;
+ auxKnob[idx]->setValue(val);
+ }
+
+//---------------------------------------------------------
+// volumeChanged
+//---------------------------------------------------------
+
+void AudioStrip::volumeChanged(double val)
+ {
+ AutomationType at = ((AudioTrack*)track)->automationType();
+ if(at == AUTO_WRITE || (audio->isPlaying() && at == AUTO_TOUCH))
+ track->enableVolumeController(false);
+
+ double vol;
+ if (val <= config.minSlider) {
+ vol = 0.0;
+ val -= 1.0; // display special value "off"
+ }
+ else
+ vol = pow(10.0, val/20.0);
+ volume = vol;
+ audio->msgSetVolume((AudioTrack*)track, vol);
+ ((AudioTrack*)track)->recordAutomation(AC_VOLUME, vol);
+ }
+
+//---------------------------------------------------------
+// volumePressed
+//---------------------------------------------------------
+
+void AudioStrip::volumePressed()
+ {
+ AutomationType at = ((AudioTrack*)track)->automationType();
+ if(at == AUTO_WRITE || (at == AUTO_READ || at == AUTO_TOUCH))
+ track->enableVolumeController(false);
+
+ double val = slider->value();
+ double vol;
+ if (val <= config.minSlider) {
+ vol = 0.0;
+ //val -= 1.0; // display special value "off"
+ }
+ else
+ vol = pow(10.0, val/20.0);
+ volume = vol;
+ audio->msgSetVolume((AudioTrack*)track, volume);
+ ((AudioTrack*)track)->startAutoRecord(AC_VOLUME, volume);
+ }
+
+//---------------------------------------------------------
+// volumeReleased
+//---------------------------------------------------------
+
+void AudioStrip::volumeReleased()
+ {
+ if(track->automationType() != AUTO_WRITE)
+ track->enableVolumeController(true);
+
+ ((AudioTrack*)track)->stopAutoRecord(AC_VOLUME, volume);
+ }
+
+//---------------------------------------------------------
+// volumeRightClicked
+//---------------------------------------------------------
+void AudioStrip::volumeRightClicked(const QPoint &p)
+{
+ song->execAutomationCtlPopup((AudioTrack*)track, p, AC_VOLUME);
+}
+
+//---------------------------------------------------------
+// volLabelChanged
+//---------------------------------------------------------
+
+void AudioStrip::volLabelChanged(double val)
+ {
+ AutomationType at = ((AudioTrack*)track)->automationType();
+ if(at == AUTO_WRITE || (audio->isPlaying() && at == AUTO_TOUCH))
+ track->enableVolumeController(false);
+
+ double vol;
+ if (val <= config.minSlider) {
+ vol = 0.0;
+ val -= 1.0; // display special value "off"
+ }
+ else
+ vol = pow(10.0, val/20.0);
+ volume = vol;
+ slider->setValue(val);
+ audio->msgSetVolume((AudioTrack*)track, vol);
+ ((AudioTrack*)track)->startAutoRecord(AC_VOLUME, vol);
+ }
+
+//---------------------------------------------------------
+// panChanged
+//---------------------------------------------------------
+
+void AudioStrip::panChanged(double val)
+ {
+ AutomationType at = ((AudioTrack*)track)->automationType();
+ if(at == AUTO_WRITE || (audio->isPlaying() && at == AUTO_TOUCH))
+ track->enablePanController(false);
+
+ panVal = val;
+ audio->msgSetPan(((AudioTrack*)track), val);
+ ((AudioTrack*)track)->recordAutomation(AC_PAN, val);
+ }
+
+//---------------------------------------------------------
+// panPressed
+//---------------------------------------------------------
+
+void AudioStrip::panPressed()
+ {
+ AutomationType at = ((AudioTrack*)track)->automationType();
+ if(at == AUTO_WRITE || (at == AUTO_READ || at == AUTO_TOUCH))
+ track->enablePanController(false);
+
+ panVal = pan->value();
+ audio->msgSetPan(((AudioTrack*)track), panVal);
+ ((AudioTrack*)track)->startAutoRecord(AC_PAN, panVal);
+ }
+
+//---------------------------------------------------------
+// panReleased
+//---------------------------------------------------------
+
+void AudioStrip::panReleased()
+ {
+ if(track->automationType() != AUTO_WRITE)
+ track->enablePanController(true);
+ ((AudioTrack*)track)->stopAutoRecord(AC_PAN, panVal);
+ }
+
+//---------------------------------------------------------
+// panRightClicked
+//---------------------------------------------------------
+void AudioStrip::panRightClicked(const QPoint &p)
+{
+ song->execAutomationCtlPopup((AudioTrack*)track, p, AC_PAN);
+}
+
+//---------------------------------------------------------
+// panLabelChanged
+//---------------------------------------------------------
+
+void AudioStrip::panLabelChanged(double val)
+ {
+ AutomationType at = ((AudioTrack*)track)->automationType();
+ if(at == AUTO_WRITE || (audio->isPlaying() && at == AUTO_TOUCH))
+ track->enablePanController(false);
+
+ panVal = val;
+ pan->setValue(val);
+ audio->msgSetPan((AudioTrack*)track, val);
+ ((AudioTrack*)track)->startAutoRecord(AC_PAN, val);
+ }
+
+//---------------------------------------------------------
+// updateChannels
+//---------------------------------------------------------
+
+void AudioStrip::updateChannels()
+ {
+ AudioTrack* t = (AudioTrack*)track;
+ int c = t->channels();
+ //printf("AudioStrip::updateChannels track channels:%d current channels:%d\n", c, channel);
+
+ if (c > channel) {
+ for (int cc = channel; cc < c; ++cc) {
+ meter[cc] = new Meter(this);
+ //meter[cc]->setRange(config.minSlider, 10.0);
+ meter[cc]->setRange(config.minMeter, 10.0);
+ meter[cc]->setFixedWidth(15);
+ connect(meter[cc], SIGNAL(mousePress()), this, SLOT(resetPeaks()));
+ sliderGrid->addWidget(meter[cc], 0, cc+1, Qt::AlignHCenter);
+ sliderGrid->setColumnStretch(cc, 50);
+ meter[cc]->show();
+ }
+ }
+ else if (c < channel) {
+ for (int cc = channel-1; cc >= c; --cc) {
+ delete meter[cc];
+ meter[cc] = 0;
+ }
+ }
+ channel = c;
+ stereo->blockSignals(true);
+ stereo->setChecked(channel == 2);
+ stereo->blockSignals(false);
+ }
+
+//---------------------------------------------------------
+// addKnob
+// type = 0 - panorama
+// 1 - aux send
+//---------------------------------------------------------
+
+Knob* AudioStrip::addKnob(int type, int id, DoubleLabel** dlabel)
+ {
+ Knob* knob = new Knob(this);
+ knob->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ if (type == 0)
+ knob->setRange(-1.0, +1.0);
+ else
+ knob->setRange(config.minSlider-0.1, 10.0);
+ knob->setBackgroundRole(QPalette::Mid);
+
+ if (type == 0)
+ {
+ knob->setToolTip(tr("panorama"));
+ knob->setKnobImage(":/images/knob.png");
+ }
+ else
+ {
+ knob->setKnobImage(":/images/knob_aux.png");
+ knob->setToolTip(tr("aux send level"));
+ }
+
+ DoubleLabel* pl;
+ if (type == 0)
+ pl = new DoubleLabel(0, -1.0, +1.0, this);
+ else
+ pl = new DoubleLabel(0.0, config.minSlider, 10.1, this);
+
+ if (dlabel)
+ *dlabel = pl;
+ pl->setSlider(knob);
+ pl->setFont(config.fonts[1]);
+ pl->setBackgroundRole(QPalette::Mid);
+ pl->setFrame(true);
+ if (type == 0)
+ pl->setPrecision(2);
+ else {
+ pl->setPrecision(0);
+ }
+ pl->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+
+ QString label;
+ if (type == 0)
+ label = tr("Pan");
+ else
+ label.sprintf("Aux%d", id+1);
+
+ QLabel* plb = new QLabel(label, this);
+ plb->setFont(config.fonts[1]);
+ plb->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ plb->setAlignment(Qt::AlignCenter);
+
+ grid->addWidget(plb, _curGridRow, 0);
+ grid->addWidget(pl, _curGridRow+1, 0);
+ grid->addWidget(knob, _curGridRow, 1, 2, 1);
+ //grid->addWidget(plb, _curGridRow, 0, Qt::AlignCenter);
+ //grid->addWidget(pl, _curGridRow+1, 0, Qt::AlignCenter);
+ //grid->addWidget(knob, _curGridRow, 1, 2, 1, Qt::AlignCenter);
+ _curGridRow += 2;
+
+ connect(knob, SIGNAL(valueChanged(double,int)), pl, SLOT(setValue(double)));
+ //connect(pl, SIGNAL(valueChanged(double, int)), SLOT(panChanged(double)));
+
+ if (type == 0) {
+ connect(pl, SIGNAL(valueChanged(double, int)), SLOT(panLabelChanged(double)));
+ connect(knob, SIGNAL(sliderMoved(double,int)), SLOT(panChanged(double)));
+ connect(knob, SIGNAL(sliderPressed(int)), SLOT(panPressed()));
+ connect(knob, SIGNAL(sliderReleased(int)), SLOT(panReleased()));
+ connect(knob, SIGNAL(sliderRightClicked(const QPoint &, int)), SLOT(panRightClicked(const QPoint &)));
+ }
+ else {
+ knob->setId(id);
+
+ connect(pl, SIGNAL(valueChanged(double, int)), knob, SLOT(setValue(double)));
+ // Not used yet. Switch if/when necessary.
+ //connect(pl, SIGNAL(valueChanged(double, int)), SLOT(auxLabelChanged(double, int)));
+
+ connect(knob, SIGNAL(sliderMoved(double, int)), SLOT(auxChanged(double, int)));
+ }
+ return knob;
+ }
+
+//---------------------------------------------------------
+// AudioStrip
+//---------------------------------------------------------
+
+AudioStrip::~AudioStrip()
+ {
+ }
+
+
+//---------------------------------------------------------
+// AudioStrip
+// create mixer strip
+//---------------------------------------------------------
+
+AudioStrip::AudioStrip(QWidget* parent, AudioTrack* at)
+ : Strip(parent, at)
+ {
+
+ volume = -1.0;
+ panVal = 0;
+
+ record = 0;
+ off = 0;
+
+ AudioTrack* t = (AudioTrack*)track;
+ channel = at->channels();
+ ///setMinimumWidth(STRIP_WIDTH);
+ //grid->setVerticalSpacing(4);
+
+ int ch = 0;
+ for (; ch < channel; ++ch)
+ meter[ch] = new Meter(this);
+ for (; ch < MAX_CHANNELS; ++ch)
+ meter[ch] = 0;
+
+ //---------------------------------------------------
+ // plugin rack
+ //---------------------------------------------------
+
+ rack = new EffectRack(this, t);
+ rack->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum);
+ grid->addWidget(rack, _curGridRow++, 0, 1, 2);
+
+ //---------------------------------------------------
+ // mono/stereo pre/post
+ //---------------------------------------------------
+
+ stereo = new QToolButton();
+ stereo->setFont(config.fonts[1]);
+ QIcon stereoSet;
+ stereoSet.addPixmap(*monoIcon, QIcon::Normal, QIcon::Off);
+ stereoSet.addPixmap(*stereoIcon, QIcon::Normal, QIcon::On);
+ stereo->setIcon(stereoSet);
+ stereo->setIconSize(monoIcon->size());
+
+ stereo->setCheckable(true);
+ stereo->setObjectName("btnStereo");
+ stereo->setToolTip(tr("1/2 channel"));
+ stereo->setChecked(channel == 2);
+ stereo->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ connect(stereo, SIGNAL(clicked(bool)), SLOT(stereoToggled(bool)));
+
+ // disable mono/stereo for Synthesizer-Plugins
+ if (t->type() == Track::AUDIO_SOFTSYNTH)
+ stereo->setEnabled(false);
+
+ pre = new QToolButton();
+ pre->setFont(config.fonts[1]);
+ pre->setCheckable(true);
+ //pre->setText(tr("Pre"));
+ QIcon preSet;
+ preSet.addPixmap(*preIcon, QIcon::Normal, QIcon::Off);
+ preSet.addPixmap(*preIconOn, QIcon::Normal, QIcon::On);
+ //preSet.addPixmap(*muteIcon, QIcon::Active, QIcon::On);
+ pre->setIcon(preSet);
+ pre->setObjectName("btnPre");
+ pre->setIconSize(preIcon->size());
+ pre->setToolTip(tr("pre fader - post fader"));
+ pre->setChecked(t->prefader());
+ pre->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ connect(pre, SIGNAL(clicked(bool)), SLOT(preToggled(bool)));
+ //pre->setAttribute(Qt::WA_Hover);
+
+ grid->addItem(new QSpacerItem(0, 4), _curGridRow++, 0);
+ grid->addWidget(stereo, _curGridRow, 0);
+ grid->addWidget(pre, _curGridRow++, 1);
+
+ //---------------------------------------------------
+ // aux send
+ //---------------------------------------------------
+
+ int auxsSize = song->auxs()->size();
+ if (t->hasAuxSend()) {
+ grid->addItem(new QSpacerItem(0, 4), _curGridRow++, 0);
+ for (int idx = 0; idx < auxsSize; ++idx) {
+ DoubleLabel* al;
+ Knob* ak = addKnob(1, idx, &al);
+ auxKnob.push_back(ak);
+ auxLabel.push_back(al);
+ double val = fast_log10(t->auxSend(idx))*20.0;
+ ak->setValue(val);
+ al->setValue(val);
+ }
+ }
+ else {
+ ///if (auxsSize)
+ //layout->addSpacing((STRIP_WIDTH/2 + 2) * auxsSize);
+ ///grid->addSpacing((STRIP_WIDTH/2 + 2) * auxsSize); // ???
+ }
+
+ grid->addItem(new QSpacerItem(0, 10), _curGridRow++, 0);
+ //---------------------------------------------------
+ // slider, label, meter
+ //---------------------------------------------------
+
+ sliderGrid = new QGridLayout();
+ sliderGrid->setRowStretch(0, 100);
+ sliderGrid->setContentsMargins(0, 0, 8, 0);
+ sliderGrid->setSpacing(0);
+
+ slider = new Slider(this, "vol", Qt::Vertical, Slider::None, Slider::BgSlot);
+ slider->setCursorHoming(true);
+ slider->setRange(config.minSlider-0.1, 10.0);
+ slider->setFixedWidth(20);
+ slider->setFont(config.fonts[1]);
+ slider->setValue(fast_log10(t->volume())*20.0);
+
+ sliderGrid->addWidget(slider, 0, 0, Qt::AlignHCenter);
+
+ for (int i = 0; i < channel; ++i) {
+ //meter[i]->setRange(config.minSlider, 10.0);
+ meter[i]->setRange(config.minMeter, 10.0);
+ meter[i]->setFixedWidth(15);
+ connect(meter[i], SIGNAL(mousePress()), this, SLOT(resetPeaks()));
+ connect(meter[i], SIGNAL(meterClipped()), this, SLOT(playbackClipped()));
+ sliderGrid->addWidget(meter[i], 0, i+1);// , Qt::AlignHCenter);
+ sliderGrid->setColumnStretch(i, 50);
+ }
+ grid->addLayout(sliderGrid, _curGridRow++, 0, 1, 2);
+
+ sl = new DoubleLabel(0.0, config.minSlider, 10.0, this);
+ sl->setSlider(slider);
+ sl->setFont(config.fonts[1]);
+ sl->setBackgroundRole(QPalette::Mid);
+ sl->setSuffix(tr("dB"));
+ sl->setFrame(true);
+ sl->setPrecision(0);
+ sl->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum));
+ sl->setValue(fast_log10(t->volume()) * 20.0);
+ slDefaultStyle = sl->styleSheet();
+
+ connect(sl, SIGNAL(valueChanged(double,int)), SLOT(volLabelChanged(double)));
+ //connect(sl, SIGNAL(valueChanged(double,int)), SLOT(volumeChanged(double)));
+ connect(slider, SIGNAL(valueChanged(double,int)), sl, SLOT(setValue(double)));
+ connect(slider, SIGNAL(sliderMoved(double,int)), SLOT(volumeChanged(double)));
+ connect(slider, SIGNAL(sliderPressed(int)), SLOT(volumePressed()));
+ connect(slider, SIGNAL(sliderReleased(int)), SLOT(volumeReleased()));
+ connect(slider, SIGNAL(sliderRightClicked(const QPoint &, int)), SLOT(volumeRightClicked(const QPoint &)));
+ grid->addItem(new QSpacerItem(0, 6), _curGridRow++, 0);
+ grid->addWidget(sl, _curGridRow++, 0, 1, 2, Qt::AlignCenter);
+ grid->addItem(new QSpacerItem(0, 8), _curGridRow++, 0);
+
+ //---------------------------------------------------
+ // pan, balance
+ //---------------------------------------------------
+
+ pan = addKnob(0, 0, &panl);
+ pan->setValue(t->pan());
+
+ //---------------------------------------------------
+ // mute, solo, record
+ //---------------------------------------------------
+
+ record = new TransparentToolButton(this);
+ if (track->canRecord())
+ {
+ record->setCheckable(true);
+ record->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ record->setBackgroundRole(QPalette::Mid);
+ QIcon iconSet;
+ iconSet.addPixmap(*record_on_Icon, QIcon::Normal, QIcon::On);
+ iconSet.addPixmap(*record_off_Icon, QIcon::Normal, QIcon::Off);
+ record->setIcon(iconSet);
+ record->setIconSize(record_on_Icon->size());
+ record->setToolTip(tr("record"));
+ record->setObjectName("btnRecord");
+ record->setChecked(t->recordFlag());
+ connect(record, SIGNAL(clicked(bool)), SLOT(recordToggled(bool)));
+ grid->addItem(new QSpacerItem(0, 2), _curGridRow++, 0);
+ }
+ else
+ {
+ record->setCheckable(false);
+ record->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ record->setBackgroundRole(QPalette::Mid);
+ QIcon iconSet;
+ iconSet.addPixmap(*blankRecord, QIcon::Normal, QIcon::On);
+ record->setIcon(iconSet);
+ record->setObjectName("btnRecord");
+ record->setIconSize(record_on_Icon->size());
+ grid->addItem(new QSpacerItem(0, 2), _curGridRow++, 0);
+
+ }
+
+ grid->addItem(new QSpacerItem(0, 8), _curGridRow++, 0);
+
+ Track::TrackType type = t->type();
+
+ mute = new QToolButton();
+ QIcon muteSet;
+ muteSet.addPixmap(*muteIconOn, QIcon::Normal, QIcon::Off);
+ muteSet.addPixmap(*muteIconOff, QIcon::Normal, QIcon::On);
+ mute->setIcon(muteSet);
+ mute->setIconSize(muteIconOn->size());
+ mute->setCheckable(true);
+ mute->setToolTip(tr("mute"));
+ mute->setObjectName("btnMute");
+ mute->setChecked(t->mute());
+ mute->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ connect(mute, SIGNAL(clicked(bool)), SLOT(muteToggled(bool)));
+
+ solo = new QToolButton();
+
+ if((bool)t->internalSolo())
+ {
+ solo->setIcon(*soloIconSet2);
+ solo->setIconSize(soloIconOn->size());
+ useSoloIconSet2 = true;
+ }
+ else
+ {
+ solo->setIcon(*soloIconSet1);
+ solo->setIconSize(soloblksqIconOn->size());
+ useSoloIconSet2 = false;
+ }
+
+ solo->setCheckable(true);
+ solo->setChecked(t->solo());
+ solo->setObjectName("btnSolo");
+ solo->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ connect(solo, SIGNAL(clicked(bool)), SLOT(soloToggled(bool)));
+ if (type == Track::AUDIO_OUTPUT) {
+ record->setToolTip(tr("record downmix"));
+ //solo->setToolTip(tr("solo mode (monitor)"));
+ solo->setToolTip(tr("solo mode"));
+ }
+ else {
+ //solo->setToolTip(tr("pre fader listening"));
+ solo->setToolTip(tr("solo mode"));
+ }
+
+ off = new TransparentToolButton(this);
+ QIcon iconSet;
+ iconSet.addPixmap(*exit1Icon, QIcon::Normal, QIcon::On);
+ iconSet.addPixmap(*exitIcon, QIcon::Normal, QIcon::Off);
+ off->setIcon(iconSet);
+ off->setObjectName("btnExit");
+ off->setIconSize(exit1Icon->size());
+ off->setBackgroundRole(QPalette::Mid);
+ off->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ off->setCheckable(true);
+ off->setToolTip(tr("off"));
+ off->setChecked(t->off());
+ connect(off, SIGNAL(clicked(bool)), SLOT(offToggled(bool)));
+
+ grid->addWidget(off, _curGridRow, 0);
+ if (record)
+ grid->addWidget(record, _curGridRow, 1);
+ ++_curGridRow;
+ grid->addWidget(mute, _curGridRow, 0);
+ grid->addWidget(solo, _curGridRow++, 1);
+
+ //---------------------------------------------------
+ // routing
+ //---------------------------------------------------
+
+ if (type != Track::AUDIO_AUX) {
+ iR = new QToolButton();
+ iR->setFont(config.fonts[1]);
+ iR->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ //iR->setText(tr("iR"));
+ iR->setIcon(*mixerIn);
+ iR->setObjectName("btnIns");
+ iR->setIconSize(mixerIn->size());
+ iR->setCheckable(false);
+ iR->setToolTip(tr("input routing"));
+ grid->addWidget(iR, _curGridRow, 0);
+ connect(iR, SIGNAL(pressed()), SLOT(iRoutePressed()));
+ }
+
+ oR = new QToolButton();
+ oR->setFont(config.fonts[1]);
+ oR->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ //oR->setText(tr("oR"));
+ oR->setIcon(*mixerOut);
+ oR->setObjectName("btnOuts");
+ oR->setIconSize(mixerOut->size());
+ oR->setCheckable(false);
+ oR->setToolTip(tr("output routing"));
+ grid->addWidget(oR, _curGridRow++, 1);
+ connect(oR, SIGNAL(pressed()), SLOT(oRoutePressed()));
+
+ grid->addItem(new QSpacerItem(0, 5), _curGridRow++, 0);
+ //---------------------------------------------------
+ // automation type
+ //---------------------------------------------------
+
+ autoType = new ComboBox(this);
+ autoType->setFont(config.fonts[1]);
+ autoType->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ autoType->setAlignment(Qt::AlignCenter);
+
+ autoType->insertItem(tr("Off"), AUTO_OFF);
+ autoType->insertItem(tr("Read"), AUTO_READ);
+ autoType->insertItem(tr("Touch"), AUTO_TOUCH);
+ autoType->insertItem(tr("Write"), AUTO_WRITE);
+ autoType->setCurrentItem(t->automationType());
+ // FIXME: TODO: Convert ComboBox to QT4
+ //autoType->insertItem(AUTO_OFF, tr("Off"));
+ //autoType->insertItem(AUTO_READ, tr("Read"));
+ //autoType->insertItem(AUTO_TOUCH, tr("Touch"));
+ //autoType->insertItem(AUTO_WRITE, tr("Write"));
+ //autoType->setCurrentIndex(t->automationType());
+
+ if(t->automationType() == AUTO_TOUCH || t->automationType() == AUTO_WRITE)
+ {
+ // FIXME:
+ //autoType->setPaletteBackgroundColor(Qt::red);
+ QPalette palette;
+ palette.setColor(autoType->backgroundRole(), QColor(Qt::red));
+ autoType->setPalette(palette);
+ }
+ else
+ {
+ // FIXME:
+ //autoType->setPaletteBackgroundColor(qApp->palette().active().background());
+ QPalette palette;
+ palette.setColor(autoType->backgroundRole(), qApp->palette().color(QPalette::Active, QPalette::Background));
+ autoType->setPalette(palette);
+ }
+ autoType->setToolTip(tr("automation type"));
+ connect(autoType, SIGNAL(activated(int,int)), SLOT(setAutomationType(int,int)));
+ grid->addWidget(autoType, _curGridRow++, 0, 1, 2);
+ grid->addItem(new QSpacerItem(0, 5), _curGridRow++, 0);
+ QLabel* toprack = new QLabel();
+ toprack->setPixmap(QPixmap(":/images/bottom_rack.png"));
+ grid->addWidget(toprack, _curGridRow++, 0, 1, 2);
+
+ if (off) {
+ off->blockSignals(true);
+ updateOffState(); // init state
+ off->blockSignals(false);
+ }
+ connect(heartBeatTimer, SIGNAL(timeout()), SLOT(heartBeat()));
+ }
+
+//---------------------------------------------------------
+// addMenuItem
+//---------------------------------------------------------
+
+static int addMenuItem(AudioTrack* track, Track* route_track, PopupMenu* lb, int id, RouteMenuMap& mm, int channel, int channels, bool isOutput)
+{
+ // totalInChannels is only used by syntis.
+ int toch = ((AudioTrack*)track)->totalOutChannels();
+ // If track channels = 1, it must be a mono synth. And synti channels cannot be changed by user.
+ if(track->channels() == 1)
+ toch = 1;
+
+ // Don't add the last stray mono route if the track is stereo.
+ //if(route_track->channels() > 1 && (channel+1 == chans))
+ // return id;
+
+ RouteList* rl = isOutput ? track->outRoutes() : track->inRoutes();
+
+ QAction* act;
+
+ QString s(route_track->name());
+
+ act = lb->addAction(s);
+ act->setData(id);
+ act->setCheckable(true);
+
+ int ach = channel;
+ int bch = -1;
+
+ Route r(route_track, isOutput ? ach : bch, channels);
+
+ r.remoteChannel = isOutput ? bch : ach;
+
+ mm.insert( pRouteMenuMap(id, r) );
+
+ for(iRoute ir = rl->begin(); ir != rl->end(); ++ir)
+ {
+ if(ir->type == Route::TRACK_ROUTE && ir->track == route_track && ir->remoteChannel == r.remoteChannel)
+ {
+ int tcompch = r.channel;
+ if(tcompch == -1)
+ tcompch = 0;
+ int tcompchs = r.channels;
+ if(tcompchs == -1)
+ tcompchs = isOutput ? track->channels() : route_track->channels();
+
+ int compch = ir->channel;
+ if(compch == -1)
+ compch = 0;
+ int compchs = ir->channels;
+ if(compchs == -1)
+ compchs = isOutput ? track->channels() : ir->track->channels();
+
+ if(compch == tcompch && compchs == tcompchs)
+ {
+ act->setChecked(true);
+ break;
+ }
+ }
+ }
+ return ++id;
+}
+
+//---------------------------------------------------------
+// addAuxPorts
+//---------------------------------------------------------
+
+static int addAuxPorts(AudioTrack* t, PopupMenu* lb, int id, RouteMenuMap& mm, int channel, int channels, bool isOutput)
+ {
+ AuxList* al = song->auxs();
+ for (iAudioAux i = al->begin(); i != al->end(); ++i) {
+ Track* track = *i;
+ if (t == track)
+ continue;
+ id = addMenuItem(t, track, lb, id, mm, channel, channels, isOutput);
+ }
+ return id;
+ }
+
+//---------------------------------------------------------
+// addInPorts
+//---------------------------------------------------------
+
+static int addInPorts(AudioTrack* t, PopupMenu* lb, int id, RouteMenuMap& mm, int channel, int channels, bool isOutput)
+ {
+ InputList* al = song->inputs();
+ for (iAudioInput i = al->begin(); i != al->end(); ++i) {
+ Track* track = *i;
+ if (t == track)
+ continue;
+ id = addMenuItem(t, track, lb, id, mm, channel, channels, isOutput);
+ }
+ return id;
+ }
+
+//---------------------------------------------------------
+// addOutPorts
+//---------------------------------------------------------
+
+static int addOutPorts(AudioTrack* t, PopupMenu* lb, int id, RouteMenuMap& mm, int channel, int channels, bool isOutput)
+ {
+ OutputList* al = song->outputs();
+ for (iAudioOutput i = al->begin(); i != al->end(); ++i) {
+ Track* track = *i;
+ if (t == track)
+ continue;
+ id = addMenuItem(t, track, lb, id, mm, channel, channels, isOutput);
+ }
+ return id;
+ }
+
+//---------------------------------------------------------
+// addGroupPorts
+//---------------------------------------------------------
+
+static int addGroupPorts(AudioTrack* t, PopupMenu* lb, int id, RouteMenuMap& mm, int channel, int channels, bool isOutput)
+ {
+ GroupList* al = song->groups();
+ for (iAudioGroup i = al->begin(); i != al->end(); ++i) {
+ Track* track = *i;
+ if (t == track)
+ continue;
+ id = addMenuItem(t, track, lb, id, mm, channel, channels, isOutput);
+ }
+ return id;
+ }
+
+//---------------------------------------------------------
+// addWavePorts
+//---------------------------------------------------------
+
+static int addWavePorts(AudioTrack* t, PopupMenu* lb, int id, RouteMenuMap& mm, int channel, int channels, bool isOutput)
+ {
+ WaveTrackList* al = song->waves();
+ for (iWaveTrack i = al->begin(); i != al->end(); ++i) {
+ Track* track = *i;
+ if (t == track)
+ continue;
+ id = addMenuItem(t, track, lb, id, mm, channel, channels, isOutput);
+ }
+ return id;
+ }
+
+//---------------------------------------------------------
+// addSyntiPorts
+//---------------------------------------------------------
+
+static int addSyntiPorts(AudioTrack* t, PopupMenu* lb, int id,
+ RouteMenuMap& mm, int channel, int channels, bool isOutput)
+{
+ RouteList* rl = isOutput ? t->outRoutes() : t->inRoutes();
+
+ QAction* act;
+
+ SynthIList* al = song->syntis();
+ for (iSynthI i = al->begin(); i != al->end(); ++i)
+ {
+ Track* track = *i;
+ if (t == track)
+ continue;
+ int toch = ((AudioTrack*)track)->totalOutChannels();
+ // If track channels = 1, it must be a mono synth. And synti channels cannot be changed by user.
+ if(track->channels() == 1)
+ toch = 1;
+
+ // totalInChannels is only used by syntis.
+ int chans = (!isOutput || track->type() != Track::AUDIO_SOFTSYNTH) ? toch : ((AudioTrack*)track)->totalInChannels();
+
+ int tchans = (channels != -1) ? channels: t->channels();
+ if(tchans == 2)
+ {
+ // Ignore odd numbered left-over mono channel.
+ //chans = chans & ~1;
+ //if(chans != 0)
+ chans -= 1;
+ }
+
+ if(chans > 0)
+ {
+ PopupMenu* chpup = new PopupMenu(lb);
+ chpup->setTitle(track->name());
+ for(int ch = 0; ch < chans; ++ch)
+ {
+ char buffer[128];
+ if(tchans == 2)
+ snprintf(buffer, 128, "%s %d,%d", chpup->tr("Channel").toLatin1().constData(), ch+1, ch+2);
+ else
+ snprintf(buffer, 128, "%s %d", chpup->tr("Channel").toLatin1().constData(), ch+1);
+ act = chpup->addAction(QString(buffer));
+ act->setData(id);
+ act->setCheckable(true);
+
+ int ach = (channel == -1) ? ch : channel;
+ int bch = (channel == -1) ? -1 : ch;
+
+ Route rt(track, (t->type() != Track::AUDIO_SOFTSYNTH || isOutput) ? ach : bch, tchans);
+ //Route rt(track, ch);
+ //rt.remoteChannel = -1;
+ rt.remoteChannel = (t->type() != Track::AUDIO_SOFTSYNTH || isOutput) ? bch : ach;
+
+ mm.insert( pRouteMenuMap(id, rt) );
+
+ for(iRoute ir = rl->begin(); ir != rl->end(); ++ir)
+ {
+ if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->remoteChannel == rt.remoteChannel)
+ {
+ int tcompch = rt.channel;
+ if(tcompch == -1)
+ tcompch = 0;
+ int tcompchs = rt.channels;
+ if(tcompchs == -1)
+ tcompchs = isOutput ? t->channels() : track->channels();
+
+ int compch = ir->channel;
+ if(compch == -1)
+ compch = 0;
+ int compchs = ir->channels;
+ if(compchs == -1)
+ compchs = isOutput ? t->channels() : ir->track->channels();
+
+ if(compch == tcompch && compchs == tcompchs)
+ {
+ act->setChecked(true);
+ break;
+ }
+ }
+ }
+ ++id;
+ }
+
+ lb->addMenu(chpup);
+ }
+ }
+ return id;
+}
+
+//---------------------------------------------------------
+// addMultiChannelOutPorts
+//---------------------------------------------------------
+
+static int addMultiChannelPorts(AudioTrack* t, PopupMenu* pup, int id, RouteMenuMap& mm, bool isOutput)
+{
+ int toch = t->totalOutChannels();
+ // If track channels = 1, it must be a mono synth. And synti channels cannot be changed by user.
+ if(t->channels() == 1)
+ toch = 1;
+
+ // Number of allocated buffers is always MAX_CHANNELS or more, even if _totalOutChannels is less.
+ // totalInChannels is only used by syntis.
+ int chans = (isOutput || t->type() != Track::AUDIO_SOFTSYNTH) ? toch : t->totalInChannels();
+
+ if(chans > 1)
+ pup->addAction(new MenuTitleItem("<Mono>", pup));
+
+ //
+ // If it's more than one channel, create a sub-menu. If it's just one channel, don't bother with a sub-menu...
+ //
+
+ PopupMenu* chpup = pup;
+
+ for(int ch = 0; ch < chans; ++ch)
+ {
+ // If more than one channel, create the sub-menu.
+ if(chans > 1)
+ chpup = new PopupMenu(pup);
+
+ if(isOutput)
+ {
+ switch(t->type())
+ {
+
+ case Track::AUDIO_INPUT:
+ id = addWavePorts(t, chpup, id, mm, ch, 1, isOutput);
+ case Track::WAVE:
+ case Track::AUDIO_GROUP:
+ case Track::AUDIO_SOFTSYNTH:
+ id = addOutPorts(t, chpup, id, mm, ch, 1, isOutput);
+ id = addGroupPorts(t, chpup, id, mm, ch, 1, isOutput);
+ id = addSyntiPorts(t, chpup, id, mm, ch, 1, isOutput);
+ break;
+ case Track::AUDIO_AUX:
+ id = addOutPorts(t, chpup, id, mm, ch, 1, isOutput);
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ switch(t->type())
+ {
+
+ case Track::AUDIO_OUTPUT:
+ id = addWavePorts(t, chpup, id, mm, ch, 1, isOutput);
+ id = addInPorts(t, chpup, id, mm, ch, 1, isOutput);
+ id = addGroupPorts(t, chpup, id, mm, ch, 1, isOutput);
+ id = addAuxPorts(t, chpup, id, mm, ch, 1, isOutput);
+ id = addSyntiPorts(t, chpup, id, mm, ch, 1, isOutput);
+ break;
+ case Track::WAVE:
+ id = addInPorts(t, chpup, id, mm, ch, 1, isOutput);
+ break;
+ case Track::AUDIO_SOFTSYNTH:
+ case Track::AUDIO_GROUP:
+ id = addWavePorts(t, chpup, id, mm, ch, 1, isOutput);
+ id = addInPorts(t, chpup, id, mm, ch, 1, isOutput);
+ id = addGroupPorts(t, chpup, id, mm, ch, 1, isOutput);
+ id = addSyntiPorts(t, chpup, id, mm, ch, 1, isOutput);
+ break;
+ default:
+ break;
+ }
+ }
+
+ // If more than one channel, add the created sub-menu.
+ if(chans > 1)
+ {
+ char buffer[128];
+ snprintf(buffer, 128, "%s %d", pup->tr("Channel").toLatin1().constData(), ch+1);
+ chpup->setTitle(QString(buffer));
+ pup->addMenu(chpup);
+ }
+ }
+
+ // For stereo listing, ignore odd numbered left-over channels.
+ chans -= 1;
+ if(chans > 0)
+ {
+ // Ignore odd numbered left-over channels.
+ //int schans = (chans & ~1) - 1;
+
+ pup->addSeparator();
+ pup->addAction(new MenuTitleItem("<Stereo>", pup));
+
+ //
+ // If it's more than two channels, create a sub-menu. If it's just two channels, don't bother with a sub-menu...
+ //
+
+ chpup = pup;
+ if(chans <= 2)
+ // Just do one iteration.
+ chans = 1;
+
+ for(int ch = 0; ch < chans; ++ch)
+ {
+ // If more than two channels, create the sub-menu.
+ if(chans > 2)
+ chpup = new PopupMenu(pup);
+
+ if(isOutput)
+ {
+ switch(t->type())
+ {
+ case Track::AUDIO_INPUT:
+ id = addWavePorts(t, chpup, id, mm, ch, 2, isOutput);
+ case Track::WAVE:
+ case Track::AUDIO_GROUP:
+ case Track::AUDIO_SOFTSYNTH:
+ id = addOutPorts(t, chpup, id, mm, ch, 2, isOutput);
+ id = addGroupPorts(t, chpup, id, mm, ch, 2, isOutput);
+ id = addSyntiPorts(t, chpup, id, mm, ch, 2, isOutput);
+ break;
+ case Track::AUDIO_AUX:
+ id = addOutPorts(t, chpup, id, mm, ch, 2, isOutput);
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ switch(t->type())
+ {
+ case Track::AUDIO_OUTPUT:
+ id = addWavePorts(t, chpup, id, mm, ch, 2, isOutput);
+ id = addInPorts(t, chpup, id, mm, ch, 2, isOutput);
+ id = addGroupPorts(t, chpup, id, mm, ch, 2, isOutput);
+ id = addAuxPorts(t, chpup, id, mm, ch, 2, isOutput);
+ id = addSyntiPorts(t, chpup, id, mm, ch, 2, isOutput);
+ break;
+ case Track::WAVE:
+ id = addInPorts(t, chpup, id, mm, ch, 2, isOutput);
+ break;
+ case Track::AUDIO_SOFTSYNTH:
+ case Track::AUDIO_GROUP:
+ id = addWavePorts(t, chpup, id, mm, ch, 2, isOutput);
+ id = addInPorts(t, chpup, id, mm, ch, 2, isOutput);
+ id = addGroupPorts(t, chpup, id, mm, ch, 2, isOutput);
+ id = addSyntiPorts(t, chpup, id, mm, ch, 2, isOutput);
+ break;
+ default:
+ break;
+ }
+ }
+
+ // If more than two channels, add the created sub-menu.
+ if(chans > 2)
+ {
+ char buffer[128];
+ snprintf(buffer, 128, "%s %d,%d", pup->tr("Channel").toLatin1().constData(), ch+1, ch+2);
+ chpup->setTitle(QString(buffer));
+ pup->addMenu(chpup);
+ }
+ }
+ }
+
+ return id;
+}
+
+//---------------------------------------------------------
+// nonSyntiTrackAddSyntis
+//---------------------------------------------------------
+
+static int nonSyntiTrackAddSyntis(AudioTrack* t, PopupMenu* lb, int id, RouteMenuMap& mm, bool isOutput)
+{
+ RouteList* rl = isOutput ? t->outRoutes() : t->inRoutes();
+
+ QAction* act;
+ SynthIList* al = song->syntis();
+ for (iSynthI i = al->begin(); i != al->end(); ++i)
+ {
+ Track* track = *i;
+ if (t == track)
+ continue;
+
+ int toch = ((AudioTrack*)track)->totalOutChannels();
+ // If track channels = 1, it must be a mono synth. And synti channels cannot be changed by user.
+ if(track->channels() == 1)
+ toch = 1;
+
+ // totalInChannels is only used by syntis.
+ int chans = (!isOutput || track->type() != Track::AUDIO_SOFTSYNTH) ? toch : ((AudioTrack*)track)->totalInChannels();
+
+ //int schans = synti->channels();
+ //if(schans < chans)
+ // chans = schans;
+// int tchans = (channels != -1) ? channels: t->channels();
+// if(tchans == 2)
+// {
+ // Ignore odd numbered left-over mono channel.
+ //chans = chans & ~1;
+ //if(chans != 0)
+// chans -= 1;
+// }
+ //int tchans = (channels != -1) ? channels: t->channels();
+
+ if(chans > 0)
+ {
+ PopupMenu* chpup = new PopupMenu(lb);
+ chpup->setTitle(track->name());
+ if(chans > 1)
+ chpup->addAction(new MenuTitleItem("<Mono>", chpup));
+
+ for(int ch = 0; ch < chans; ++ch)
+ {
+ char buffer[128];
+ snprintf(buffer, 128, "%s %d", chpup->tr("Channel").toLatin1().constData(), ch+1);
+ act = chpup->addAction(QString(buffer));
+ act->setData(id);
+ act->setCheckable(true);
+
+ int ach = ch;
+ int bch = -1;
+
+ Route rt(track, isOutput ? bch : ach, 1);
+
+ rt.remoteChannel = isOutput ? ach : bch;
+
+ mm.insert( pRouteMenuMap(id, rt) );
+
+ for(iRoute ir = rl->begin(); ir != rl->end(); ++ir)
+ {
+ if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->remoteChannel == rt.remoteChannel)
+ {
+ int tcompch = rt.channel;
+ if(tcompch == -1)
+ tcompch = 0;
+ int tcompchs = rt.channels;
+ if(tcompchs == -1)
+ tcompchs = isOutput ? t->channels() : track->channels();
+
+ int compch = ir->channel;
+ if(compch == -1)
+ compch = 0;
+ int compchs = ir->channels;
+ if(compchs == -1)
+ compchs = isOutput ? t->channels() : ir->track->channels();
+
+ if(compch == tcompch && compchs == tcompchs)
+ {
+ act->setChecked(true);
+ break;
+ }
+ }
+ }
+ ++id;
+ }
+
+ chans -= 1;
+ if(chans > 0)
+ {
+ // Ignore odd numbered left-over channels.
+ //int schans = (chans & ~1) - 1;
+
+ chpup->addSeparator();
+ chpup->addAction(new MenuTitleItem("<Stereo>", chpup));
+
+ for(int ch = 0; ch < chans; ++ch)
+ {
+ char buffer[128];
+ snprintf(buffer, 128, "%s %d,%d", chpup->tr("Channel").toLatin1().constData(), ch+1, ch+2);
+ act = chpup->addAction(QString(buffer));
+ act->setData(id);
+ act->setCheckable(true);
+
+ int ach = ch;
+ int bch = -1;
+
+ Route rt(track, isOutput ? bch : ach, 2);
+
+ rt.remoteChannel = isOutput ? ach : bch;
+
+ mm.insert( pRouteMenuMap(id, rt) );
+
+ for(iRoute ir = rl->begin(); ir != rl->end(); ++ir)
+ {
+ if(ir->type == Route::TRACK_ROUTE && ir->track == track && ir->remoteChannel == rt.remoteChannel)
+ {
+ int tcompch = rt.channel;
+ if(tcompch == -1)
+ tcompch = 0;
+ int tcompchs = rt.channels;
+ if(tcompchs == -1)
+ tcompchs = isOutput ? t->channels() : track->channels();
+
+ int compch = ir->channel;
+ if(compch == -1)
+ compch = 0;
+ int compchs = ir->channels;
+ if(compchs == -1)
+ compchs = isOutput ? t->channels() : ir->track->channels();
+
+ if(compch == tcompch && compchs == tcompchs)
+ {
+ act->setChecked(true);
+ break;
+ }
+ }
+ }
+ ++id;
+ }
+ }
+
+ lb->addMenu(chpup);
+ }
+ }
+ return id;
+}
+
+//---------------------------------------------------------
+// iRoutePressed
+//---------------------------------------------------------
+
+void AudioStrip::iRoutePressed()
+ {
+ //if(track->isMidiTrack() || (track->type() == Track::AUDIO_AUX) || (track->type() == Track::AUDIO_SOFTSYNTH))
+ if(!track || track->isMidiTrack() || track->type() == Track::AUDIO_AUX)
+ {
+ gRoutingPopupMenuMaster = 0;
+ return;
+ }
+
+ QPoint ppt = QCursor::pos();
+
+ PopupMenu* pup = muse->getRoutingPopupMenu();
+ pup->disconnect();
+
+
+ AudioTrack* t = (AudioTrack*)track;
+ RouteList* irl = t->inRoutes();
+
+ QAction* act = 0;
+ int gid = 0;
+ int id = 0;
+
+ pup->clear();
+ gRoutingMenuMap.clear();
+ gid = 0;
+
+ switch(track->type())
+ {
+ case Track::AUDIO_INPUT:
+ {
+ for(int i = 0; i < channel; ++i)
+ {
+ char buffer[128];
+ snprintf(buffer, 128, "%s %d", tr("Channel").toLatin1().constData(), i+1);
+ MenuTitleItem* titel = new MenuTitleItem(QString(buffer), pup);
+ pup->addAction(titel);
+
+ if(!checkAudioDevice())
+ {
+ gRoutingPopupMenuMaster = 0;
+ pup->clear();
+ gRoutingMenuMap.clear();
+ iR->setDown(false);
+ return;
+ }
+ std::list<QString> ol = audioDevice->outputPorts();
+
+ if(ol.size() >= 75 && ol.size() <= 125)
+ {
+ pup->setStyleSheet("font-size:8pt");
+ }
+ else if(ol.size() >= 126)
+ {
+ pup->setStyleSheet("font-size:6pt; font-family:'fixed'; ");
+ }
+
+ for(std::list<QString>::iterator ip = ol.begin(); ip != ol.end(); ++ip)
+ {
+ id = gid * 16 + i;
+ act = pup->addAction(*ip);
+ act->setData(id);
+ act->setCheckable(true);
+
+ Route dst(*ip, true, i, Route::JACK_ROUTE);
+ gRoutingMenuMap.insert( pRouteMenuMap(id, dst) );
+ ++gid;
+ for(iRoute ir = irl->begin(); ir != irl->end(); ++ir)
+ {
+ if(*ir == dst)
+ {
+ act->setChecked(true);
+ break;
+ }
+ }
+ }
+ if(i+1 != channel)
+ pup->addSeparator();
+ }
+ }
+ break;
+ //case Track::AUDIO_OUTPUT:
+ //case Track::WAVE:
+ //case Track::AUDIO_GROUP:
+
+ case Track::AUDIO_OUTPUT:
+ gid = addWavePorts( t, pup, gid, gRoutingMenuMap, -1, -1, false);
+ gid = addInPorts( t, pup, gid, gRoutingMenuMap, -1, -1, false);
+ gid = addGroupPorts(t, pup, gid, gRoutingMenuMap, -1, -1, false);
+ gid = addAuxPorts( t, pup, gid, gRoutingMenuMap, -1, -1, false);
+ gid = nonSyntiTrackAddSyntis(t, pup, gid, gRoutingMenuMap, false);
+ break;
+ case Track::WAVE:
+ gid = addInPorts( t, pup, gid, gRoutingMenuMap, -1, -1, false);
+ break;
+ case Track::AUDIO_GROUP:
+ gid = addWavePorts( t, pup, gid, gRoutingMenuMap, -1, -1, false);
+ gid = addInPorts( t, pup, gid, gRoutingMenuMap, -1, -1, false);
+ gid = addGroupPorts(t, pup, gid, gRoutingMenuMap, -1, -1, false);
+ gid = nonSyntiTrackAddSyntis(t, pup, gid, gRoutingMenuMap, false);
+ break;
+
+ case Track::AUDIO_SOFTSYNTH:
+ gid = addMultiChannelPorts(t, pup, gid, gRoutingMenuMap, false);
+ break;
+ default:
+ gRoutingPopupMenuMaster = 0;
+ pup->clear();
+ gRoutingMenuMap.clear();
+ iR->setDown(false);
+ return;
+ }
+
+ if(pup->actions().isEmpty())
+ {
+ gRoutingPopupMenuMaster = 0;
+ gRoutingMenuMap.clear();
+ iR->setDown(false);
+ return;
+ }
+
+ gIsOutRoutingPopupMenu = false;
+ gRoutingPopupMenuMaster = this;
+ connect(pup, SIGNAL(triggered(QAction*)), SLOT(routingPopupMenuActivated(QAction*)));
+ connect(pup, SIGNAL(aboutToHide()), muse, SLOT(routingPopupMenuAboutToHide()));
+ pup->popup(ppt);
+ iR->setDown(false);
+ }
+
+//---------------------------------------------------------
+// routingPopupMenuActivated
+//---------------------------------------------------------
+
+void AudioStrip::routingPopupMenuActivated(QAction* act)
+{
+ if(!track || gRoutingPopupMenuMaster != this || track->isMidiTrack())
+ return;
+
+ PopupMenu* pup = muse->getRoutingPopupMenu();
+
+ if(pup->actions().isEmpty())
+ return;
+
+ AudioTrack* t = (AudioTrack*)track;
+ RouteList* rl = gIsOutRoutingPopupMenu ? t->outRoutes() : t->inRoutes();
+
+ int n = act->data().toInt();
+ if (n == -1)
+ return;
+
+ if(gIsOutRoutingPopupMenu)
+ {
+ if(track->type() == Track::AUDIO_OUTPUT)
+ {
+
+ int chan = n & 0xf;
+
+ Route srcRoute(t, chan);
+ Route dstRoute(act->text(), true, -1, Route::JACK_ROUTE);
+ dstRoute.channel = chan;
+
+ // check if route src->dst exists:
+ iRoute irl = rl->begin();
+ for (; irl != rl->end(); ++irl) {
+ if (*irl == dstRoute)
+ break;
+ }
+ if (irl != rl->end()) {
+ // disconnect if route exists
+ audio->msgRemoveRoute(srcRoute, dstRoute);
+ }
+ else {
+ // connect if route does not exist
+ audio->msgAddRoute(srcRoute, dstRoute);
+ }
+ audio->msgUpdateSoloStates();
+ song->update(SC_ROUTE);
+ return;
+ }
+
+ iRouteMenuMap imm = gRoutingMenuMap.find(n);
+ if(imm == gRoutingMenuMap.end())
+ return;
+
+ Route srcRoute(t, imm->second.channel, imm->second.channels);
+ srcRoute.remoteChannel = imm->second.remoteChannel;
+
+ Route &dstRoute = imm->second;
+
+ // check if route src->dst exists:
+ iRoute irl = rl->begin();
+ for (; irl != rl->end(); ++irl) {
+ if (*irl == dstRoute)
+ break;
+ }
+ if (irl != rl->end()) {
+ // disconnect if route exists
+ audio->msgRemoveRoute(srcRoute, dstRoute);
+ }
+ else {
+ // connect if route does not exist
+ audio->msgAddRoute(srcRoute, dstRoute);
+ }
+ audio->msgUpdateSoloStates();
+ song->update(SC_ROUTE);
+ }
+ else
+ {
+ if(track->type() == Track::AUDIO_INPUT)
+ {
+ int chan = n & 0xf;
+
+ Route srcRoute(act->text(), false, -1, Route::JACK_ROUTE);
+ Route dstRoute(t, chan);
+
+ srcRoute.channel = chan;
+
+ iRoute irl = rl->begin();
+ for(; irl != rl->end(); ++irl)
+ {
+ if(*irl == srcRoute)
+ break;
+ }
+ if(irl != rl->end())
+ // disconnect
+ audio->msgRemoveRoute(srcRoute, dstRoute);
+ else
+ // connect
+ audio->msgAddRoute(srcRoute, dstRoute);
+
+ audio->msgUpdateSoloStates();
+ song->update(SC_ROUTE);
+ return;
+ }
+
+ iRouteMenuMap imm = gRoutingMenuMap.find(n);
+ if(imm == gRoutingMenuMap.end())
+ return;
+
+ Route &srcRoute = imm->second;
+
+ Route dstRoute(t, imm->second.channel, imm->second.channels);
+ dstRoute.remoteChannel = imm->second.remoteChannel;
+
+ iRoute irl = rl->begin();
+ for (; irl != rl->end(); ++irl) {
+ if (*irl == srcRoute)
+ break;
+ }
+ if (irl != rl->end()) {
+ // disconnect
+ audio->msgRemoveRoute(srcRoute, dstRoute);
+ }
+ else {
+ // connect
+ audio->msgAddRoute(srcRoute, dstRoute);
+ }
+ audio->msgUpdateSoloStates();
+ song->update(SC_ROUTE);
+ }
+}
+
+//---------------------------------------------------------
+// oRoutePressed
+//---------------------------------------------------------
+
+void AudioStrip::oRoutePressed()
+{
+ if(!track || track->isMidiTrack())
+ {
+ gRoutingPopupMenuMaster = 0;
+ return;
+ }
+
+ QPoint ppt = QCursor::pos();
+
+ PopupMenu* pup = muse->getRoutingPopupMenu();
+ pup->disconnect();
+
+ AudioTrack* t = (AudioTrack*)track;
+ RouteList* orl = t->outRoutes();
+
+ QAction* act = 0;
+ int gid = 0;
+ int id = 0;
+
+ pup->clear();
+ gRoutingMenuMap.clear();
+ gid = 0;
+
+ switch(track->type())
+ {
+ case Track::AUDIO_OUTPUT:
+ {
+ for(int i = 0; i < channel; ++i)
+ {
+ char buffer[128];
+ snprintf(buffer, 128, "%s %d", tr("Channel").toLatin1().constData(), i+1);
+ MenuTitleItem* titel = new MenuTitleItem(QString(buffer), pup);
+ pup->addAction(titel);
+
+ if(!checkAudioDevice())
+ {
+ gRoutingPopupMenuMaster = 0;
+ pup->clear();
+ gRoutingMenuMap.clear();
+ oR->setDown(false);
+ return;
+ }
+ std::list<QString> ol = audioDevice->inputPorts();
+ for(std::list<QString>::iterator ip = ol.begin(); ip != ol.end(); ++ip)
+ {
+ id = gid * 16 + i;
+ act = pup->addAction(*ip);
+ act->setData(id);
+ act->setCheckable(true);
+
+ Route dst(*ip, true, i, Route::JACK_ROUTE);
+ gRoutingMenuMap.insert( pRouteMenuMap(id, dst) );
+ ++gid;
+ for(iRoute ir = orl->begin(); ir != orl->end(); ++ir)
+ {
+ if(*ir == dst)
+ {
+ act->setChecked(true);
+ break;
+ }
+ }
+ }
+ if(i+1 != channel)
+ pup->addSeparator();
+ }
+ }
+ break;
+ //case Track::AUDIO_INPUT:
+ //case Track::WAVE:
+ //case Track::AUDIO_GROUP:
+
+ case Track::AUDIO_SOFTSYNTH:
+ gid = addMultiChannelPorts(t, pup, gid, gRoutingMenuMap, true);
+ break;
+
+ case Track::AUDIO_INPUT:
+ gid = addWavePorts( t, pup, gid, gRoutingMenuMap, -1, -1, true);
+ case Track::WAVE:
+ case Track::AUDIO_GROUP:
+ case Track::AUDIO_AUX:
+ //case Track::AUDIO_SOFTSYNTH:
+ gid = addOutPorts( t, pup, gid, gRoutingMenuMap, -1, -1, true);
+ gid = addGroupPorts( t, pup, gid, gRoutingMenuMap, -1, -1, true);
+ gid = nonSyntiTrackAddSyntis(t, pup, gid, gRoutingMenuMap, true);
+ break;
+ //case Track::AUDIO_AUX:
+ // gid = addOutPorts( t, pup, gid, gRoutingMenuMap, -1, -1, true);
+ //break;
+
+ default:
+ gRoutingPopupMenuMaster = 0;
+ pup->clear();
+ gRoutingMenuMap.clear();
+ oR->setDown(false);
+ return;
+ }
+
+ if(pup->actions().isEmpty())
+ {
+ gRoutingPopupMenuMaster = 0;
+ gRoutingMenuMap.clear();
+ oR->setDown(false);
+ return;
+ }
+
+ gIsOutRoutingPopupMenu = true;
+ gRoutingPopupMenuMaster = this;
+ connect(pup, SIGNAL(triggered(QAction*)), SLOT(routingPopupMenuActivated(QAction*)));
+ connect(pup, SIGNAL(aboutToHide()), muse, SLOT(routingPopupMenuAboutToHide()));
+ pup->popup(ppt);
+ oR->setDown(false);
+}
+
+void AudioStrip::playbackClipped()
+{
+ sl->setStyleSheet("DoubleLabel { padding-left: 2px; border: 1px solid #9d9d9d; border-image: none; background-color: black; color: #ba0000; font-weight: normal;}");
+}
+
+//---------------------------------------------------------
+// resetPeaks
+//---------------------------------------------------------
+
+void AudioStrip::resetPeaks()
+{
+ track->resetPeaks();
+ sl->setStyleSheet(slDefaultStyle);
+}
+
diff --git a/attic/muse2-oom/muse2/muse/mixer/astrip.h b/attic/muse2-oom/muse2/muse/mixer/astrip.h
new file mode 100644
index 00000000..1526c847
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/astrip.h
@@ -0,0 +1,105 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: astrip.h,v 1.8.2.6 2009/11/14 03:37:48 terminator356 Exp $
+//
+// (C) Copyright 2000-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __ASTRIP_H__
+#define __ASTRIP_H__
+
+#include <vector>
+
+#include "strip.h"
+#include "route.h"
+
+class Slider;
+class Knob;
+//class QDialog;
+class QToolButton;
+//class QAction;
+//class QPopupMenu;
+class PopupMenu;
+class QButton;
+class TransparentToolButton;
+class AudioTrack;
+class DoubleLabel;
+class EffectRack;
+
+//---------------------------------------------------------
+// AudioStrip
+//---------------------------------------------------------
+
+class AudioStrip : public Strip {
+ Q_OBJECT
+
+ int channel;
+ Slider* slider;
+ DoubleLabel* sl;
+ EffectRack* rack;
+
+ Knob* pan;
+ DoubleLabel* panl;
+
+ std::vector<Knob*> auxKnob;
+ std::vector<DoubleLabel*> auxLabel;
+
+ QToolButton* stereo;
+ QToolButton* pre;
+ TransparentToolButton* off;
+
+ double volume;
+ double panVal;
+
+ QString slDefaultStyle;
+
+ //QToolButton* iR;
+ //QToolButton* oR;
+
+ Knob* addKnob(int, int, DoubleLabel**);
+
+ void updateOffState();
+ void updateVolume();
+ void updatePan();
+ void updateChannels();
+ //void updateRouteMenus();
+
+ private slots:
+ void stereoToggled(bool);
+ void preToggled(bool);
+ void offToggled(bool);
+ void iRoutePressed();
+ void oRoutePressed();
+ void routingPopupMenuActivated(QAction*);
+ void auxChanged(double, int);
+ void volumeChanged(double);
+ void volumePressed();
+ void volumeReleased();
+ void panChanged(double);
+ void panPressed();
+ void panReleased();
+ void volLabelChanged(double);
+ void panLabelChanged(double);
+ void auxLabelChanged(double, unsigned int);
+ void volumeRightClicked(const QPoint &);
+ void panRightClicked(const QPoint &);
+ void playbackClipped();
+ void resetPeaks();
+
+ protected slots:
+ virtual void heartBeat();
+
+ public slots:
+ virtual void configChanged();
+ virtual void songChanged(int);
+
+ public:
+ AudioStrip(QWidget* parent, AudioTrack*);
+ ~AudioStrip();
+ ///virtual QSize minimumSizeHint () const;
+ //virtual QSize sizeHint () const;
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/mixer/auxknob.cpp b/attic/muse2-oom/muse2/muse/mixer/auxknob.cpp
new file mode 100644
index 00000000..a64f3929
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/auxknob.cpp
@@ -0,0 +1,40 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: auxknob.cpp,v 1.7 2004/07/11 16:26:46 wschweer Exp $
+//
+// (C) Copyright 2000-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <cmath>
+#include "auxknob.h"
+#include "gconfig.h"
+
+//---------------------------------------------------------
+// Aux
+//---------------------------------------------------------
+
+AuxKnob::AuxKnob(QWidget* parent, int i)
+ : Knob(parent, "aux")
+ {
+ idx = i;
+ setRange(config.minSlider-0.1, 10.0);
+ connect(this, SIGNAL(valueChanged(double,int)), SLOT(valueChanged(double)));
+ }
+
+//---------------------------------------------------------
+// panChanged
+//---------------------------------------------------------
+
+void AuxKnob::valueChanged(double val)
+ {
+ double vol;
+ if (val <= config.minSlider) {
+ vol = 0.0;
+ val -= 1.0; // display special value "off"
+ }
+ else
+ vol = pow(10.0, val/20.0);
+ emit auxChanged(idx, vol);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/mixer/auxknob.h b/attic/muse2-oom/muse2/muse/mixer/auxknob.h
new file mode 100644
index 00000000..c2b8ec7a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/auxknob.h
@@ -0,0 +1,33 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: auxknob.h,v 1.3 2003/11/08 15:10:18 wschweer Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __AUXKNOB_H__
+#define __AUXKNOB_H__
+
+#include "knob.h"
+
+//---------------------------------------------------------
+// AuxKnob
+//---------------------------------------------------------
+
+class AuxKnob : public Knob {
+ Q_OBJECT
+ int idx;
+
+ private slots:
+ void valueChanged(double v);
+
+ signals:
+ void auxChanged(int, double);
+
+ public:
+ AuxKnob(QWidget* parent, int idx);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/mixer/meter.cpp b/attic/muse2-oom/muse2/muse/mixer/meter.cpp
new file mode 100644
index 00000000..ea1ae3c3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/meter.cpp
@@ -0,0 +1,298 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: meter.cpp,v 1.4.2.2 2009/05/03 04:14:00 terminator356 Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <cmath>
+
+#include <QMouseEvent>
+#include <QPainter>
+#include <QResizeEvent>
+
+#include "meter.h"
+#include "gconfig.h"
+#include "fastlog.h"
+
+//---------------------------------------------------------
+// Meter
+//---------------------------------------------------------
+
+Meter::Meter(QWidget* parent, MeterType type)
+ : QFrame(parent) //Qt::WNoAutoErase
+{
+ setBackgroundRole(QPalette::NoRole);
+ setAttribute(Qt::WA_NoSystemBackground);
+ setAttribute(Qt::WA_StaticContents);
+ // This is absolutely required for speed! Otherwise painfully slow because we get
+ // full rect paint events even on small scrolls! See help on QPainter::scroll().
+ setAttribute(Qt::WA_OpaquePaintEvent);
+
+ mtype = type;
+ overflow = false;
+ val = 0.0;
+ maxVal = 0.0;
+ minScale = mtype == DBMeter ? config.minMeter : 0.0; // min value in dB or int
+ maxScale = mtype == DBMeter ? 10.0 : 127.0;
+ yellowScale = -10;
+ redScale = 0;
+ setLineWidth(0);
+ setMidLineWidth(0);
+ green = QColor(49,175,197);
+ yellow = QColor(156,85,115);
+ red = QColor(197,49,87);
+ bgColor = QColor(0,12,16);
+}
+
+//---------------------------------------------------------
+// setVal
+//---------------------------------------------------------
+
+void Meter::setVal(double v, double max, bool ovl)
+ {
+ overflow = ovl;
+ bool ud = false;
+
+ if(mtype == DBMeter)
+ {
+ double minScaleLin = pow(10.0, minScale/20.0);
+ if((v >= minScaleLin && val != v) || val >= minScaleLin)
+ {
+ val = v;
+ ud = true;
+ }
+ }
+ else
+ {
+ if(val != v)
+ {
+ val = v;
+ ud = true;
+ }
+ }
+
+ if(maxVal != max)
+ {
+ maxVal = max;
+ ud = true;
+ }
+
+ if(ud)
+ update();
+ }
+//---------------------------------------------------------
+// resetPeaks
+// reset peak and overflow indicator
+//---------------------------------------------------------
+
+void Meter::resetPeaks()
+ {
+ maxVal = val;
+ overflow = val > 0.0;
+ update();
+ }
+
+//---------------------------------------------------------
+// setRange
+//---------------------------------------------------------
+
+void Meter::setRange(double min, double max)
+ {
+ minScale = min;
+ maxScale = max;
+ update();
+ }
+
+//---------------------------------------------------------
+// paintEvent
+//---------------------------------------------------------
+
+void Meter::paintEvent(QPaintEvent* /*ev*/)
+ {
+ // TODO: Could make better use of event rectangle, for speed.
+
+ QPainter p(this);
+
+ double range = maxScale - minScale;
+
+ int fw = frameWidth();
+ int w = width() - 2*fw;
+ int h = height() - 2*fw;
+ int yv;
+
+ if(mtype == DBMeter)
+ yv = val == 0 ? h : int(((maxScale - (fast_log10(val) * 20.0)) * h)/range);
+ else
+ yv = val == 0 ? h : int(((maxScale - val) * h)/range);
+
+ if(yv > h) yv = h;
+
+ // Draw the red, green, and yellow sections.
+ drawVU(p, w, h, yv);
+
+ // Draw the peak white line.
+ int ymax;
+ if(mtype == DBMeter)
+ ymax = maxVal == 0 ? 0 : int(((maxScale - (fast_log10(maxVal) * 20.0)) * h)/range);
+ else
+ ymax = maxVal == 0 ? 0 : int(((maxScale - maxVal) * h)/range);
+
+ int y1 = int((maxScale - redScale) * h / range);
+ int y2 = int((maxScale - yellowScale) * h / range);
+ int y3 = int((maxScale - yellowScale) * h / range);
+ int y4 = int((maxScale - -15) * h / range);
+ int y5 = int((maxScale - -20) * h / range);
+ int y6 = int((maxScale - -25) * h / range);
+ int y7 = int((maxScale - -30) * h / range);
+ int y8 = int((maxScale - -35) * h / range);
+ int y9 = int((maxScale - -40) * h / range);
+ int y10 = int((maxScale - -45) * h / range);
+ int y11 = int((maxScale - -50) * h / range);
+ int y12 = int((maxScale - -55) * h / range);
+ int y13 = int((maxScale - -5) * h / range);
+ int y14 = int((maxScale - 5) * h / range);
+ QPen myPen = QPen(green, 5, Qt::SolidLine, Qt::RoundCap );
+ if(ymax == 0)
+ {
+ myPen.setColor(bgColor);
+ }
+ else if(ymax <= y1)
+ {
+ myPen.setColor(red);
+ }
+ else if(ymax <= y2 && ymax > y1)
+ {
+ myPen.setColor(yellow);
+ }
+ p.setPen(myPen);//floating vu levels
+ p.drawLine(5, ymax, w-6, ymax);
+
+ myPen.setWidth(1);
+ myPen.setColor(QColor(63,74,80));
+ p.setPen(myPen);//0 db
+ p.drawLine(3, y1, w-4, y1);
+ //myPen.setColor(QColor(122,122,122));
+ p.setPen(myPen);//-10 db
+ p.drawLine(3, y2, w-4, y2);
+ p.drawLine(3, y2, w-4, y2);
+ p.drawLine(6, y3, w-8, y3);
+ p.drawLine(6, y4, w-8, y4);
+ p.drawLine(6, y5, w-8, y5);
+ p.drawLine(6, y6, w-8, y6);
+ p.drawLine(6, y7, w-8, y7);
+ p.drawLine(6, y8, w-8, y8);
+ p.drawLine(6, y9, w-8, y9);
+ p.drawLine(6, y10, w-8, y10);
+ p.drawLine(6, y11, w-8, y11);
+ p.drawLine(6, y12, w-8, y12);
+ p.drawLine(6, y13, w-8, y13);
+ p.drawLine(6, y14, w-8, y14);
+}
+
+//---------------------------------------------------------
+// drawVU
+//---------------------------------------------------------
+
+void Meter::drawVU(QPainter& p, int w, int h, int yv)
+{
+ /*if(mtype == DBMeter)
+ {*/
+ double range = maxScale - minScale;
+ int y1 = int((maxScale - redScale) * h / range);
+ int y2 = int((maxScale - yellowScale) * h / range);
+ QLinearGradient vuGrad(QPointF(0, 0), QPointF(0, h));
+ vuGrad.setColorAt(1, green);
+ //vuGrad.setColorAt(0.3, yellow);
+ vuGrad.setColorAt(0, red);
+ QPen myPen = QPen();
+ //myPen.setCapStyle(Qt::RoundCap);
+ myPen.setStyle(Qt::DashLine);
+ myPen.setBrush(QBrush(vuGrad));
+ //myPen.setWidth(w-8);
+ myPen.setWidth(1);
+ p.setPen(myPen);
+ //QBrush brush(vuGrad);
+ //brush.setPen(myPen);
+ //p.setBrush(brush);
+ //p.fillRect(4, yv, w-8, h, brush);
+
+ p.fillRect(0, 0, w, h, QBrush(bgColor)); // dark red
+ p.drawLine(4, 0, 4, h);
+ p.drawLine(5, 0, 5, h);
+ p.drawLine(6, 0, 6, h);
+ p.drawLine(7, 0, 7, h);
+ p.drawLine(8, 0, 8, h);
+ p.drawLine(9, 0, 9, h);
+ p.drawLine(10, 0, 10, h);
+ p.fillRect(0, 0, w, yv, QBrush(bgColor)); // dark red
+ if(yv == 0)
+ {
+ emit meterClipped();
+ }
+
+ /* if(yv < y1)
+ {
+ // Red section:
+ p.fillRect(0, 0, w, yv, QBrush(bgColor)); // dark red
+ p.fillRect(0, yv, w, y1-yv, QBrush(0xff0000)); // light red
+
+ // Yellow section:
+ p.fillRect(0, y1, w, y2-y1, QBrush(0xffff00)); // light yellow
+
+ // Green section:
+ p.fillRect(0, y2, w, h-y2, QBrush(0x00ff00)); // light green
+
+ }
+ else
+ if(yv < y2)
+ {
+ // Red section:
+ p.fillRect(0, 0, w, y1, QBrush(bgColor)); // dark red
+
+ // Yellow section:
+ p.fillRect(0, yv, w, y2-yv, QBrush(0xffff00)); // light yellow
+
+ // Green section:
+ p.fillRect(0, y2, w, h-y2, QBrush(0x00ff00)); // light green
+ }
+ else
+ //if(yv <= y3)
+ {
+ // Red section:
+ p.fillRect(0, 0, w, y1, QBrush(bgColor)); // dark red
+
+ // Yellow section:
+ p.fillRect(0, y1, w, y2-y1, QBrush(bgColor)); // dark yellow
+
+ // Green section:
+ p.fillRect(0, yv, w, h-yv, QBrush(0x00ff00)); // light green
+ }
+ }
+ else
+ {
+ p.fillRect(0, 0, w, yv, QBrush(bgColor)); // dark green
+ p.fillRect(0, yv, w, h-yv, QBrush(0x00ff00)); // light green
+ }*/
+}
+
+//---------------------------------------------------------
+// resizeEvent
+//---------------------------------------------------------
+
+void Meter::resizeEvent(QResizeEvent* /*ev*/)
+{
+
+}
+
+//---------------------------------------------------------
+// mousePressEvent
+//---------------------------------------------------------
+
+void Meter::mousePressEvent(QMouseEvent*)
+{
+ emit mousePress();
+}
+
diff --git a/attic/muse2-oom/muse2/muse/mixer/meter.h b/attic/muse2-oom/muse2/muse/mixer/meter.h
new file mode 100644
index 00000000..a32bd602
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/meter.h
@@ -0,0 +1,53 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: meter.h,v 1.1.1.1.2.2 2009/05/03 04:14:00 terminator356 Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __METER_H__
+#define __METER_H__
+
+#include <QFrame>
+
+class QResizeEvent;
+class QMouseEvent;
+class QPainter;
+
+class Meter : public QFrame {
+ public:
+ enum MeterType {DBMeter, LinMeter};
+ private:
+ MeterType mtype;
+ bool overflow;
+ double val;
+ double maxVal;
+ double minScale, maxScale;
+ int yellowScale, redScale;
+ QColor green;
+ QColor red;
+ QColor yellow;
+ QColor bgColor;
+
+ void drawVU(QPainter& p, int, int, int);
+
+ Q_OBJECT
+ void paintEvent(QPaintEvent*);
+ virtual void resizeEvent(QResizeEvent*);
+ virtual void mousePressEvent(QMouseEvent*);
+
+ public slots:
+ void resetPeaks();
+ void setVal(double, double, bool);
+
+ signals:
+ void mousePress();
+ void meterClipped();
+
+ public:
+ Meter(QWidget* parent, MeterType type = DBMeter);
+ void setRange(double min, double max);
+ };
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/mixer/mstrip.cpp b/attic/muse2-oom/muse2/muse/mixer/mstrip.cpp
new file mode 100644
index 00000000..6f938fda
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/mstrip.cpp
@@ -0,0 +1,1087 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mstrip.cpp,v 1.9.2.13 2009/11/14 03:37:48 terminator356 Exp $
+//
+// (C) Copyright 2000-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <fastlog.h>
+
+#include <QLayout>
+#include <QAction>
+#include <QApplication>
+//#include <QDialog>
+#include <QToolButton>
+#include <QLabel>
+#include <QComboBox>
+#include <QToolTip>
+#include <QTimer>
+//#include <QPopupMenu>
+#include <QCursor>
+#include <QGridLayout>
+
+#include <math.h>
+#include "app.h"
+#include "midi.h"
+#include "midictrl.h"
+#include "mstrip.h"
+#include "midiport.h"
+#include "globals.h"
+#include "audio.h"
+#include "song.h"
+#include "slider.h"
+#include "knob.h"
+#include "combobox.h"
+#include "meter.h"
+#include "track.h"
+#include "doublelabel.h"
+#include "rack.h"
+#include "node.h"
+#include "amixer.h"
+#include "icons.h"
+#include "gconfig.h"
+#include "ttoolbutton.h"
+//#include "utils.h"
+#include "popupmenu.h"
+
+enum { KNOB_PAN, KNOB_VAR_SEND, KNOB_REV_SEND, KNOB_CHO_SEND };
+
+//---------------------------------------------------------
+// addKnob
+//---------------------------------------------------------
+
+void MidiStrip::addKnob(int idx, const QString& tt, const QString& label,
+ const char* slot, bool enabled)
+ {
+ int ctl = CTRL_PANPOT, mn, mx, v;
+ int chan = ((MidiTrack*)track)->outChannel();
+ QString img;
+ switch(idx)
+ {
+ case KNOB_PAN:
+ // ctl = CTRL_PANPOT;
+ img = QString(":images/knob.png");
+ break;
+ case KNOB_VAR_SEND:
+ ctl = CTRL_VARIATION_SEND;
+ img = QString(":images/knob_aux.png");
+ break;
+ case KNOB_REV_SEND:
+ ctl = CTRL_REVERB_SEND;
+ img = QString(":images/knob_aux.png");
+ break;
+ case KNOB_CHO_SEND:
+ ctl = CTRL_CHORUS_SEND;
+ img = QString(":images/knob_aux.png");
+ break;
+ }
+ MidiPort* mp = &midiPorts[((MidiTrack*)track)->outPort()];
+ MidiController* mc = mp->midiController(ctl);
+ mn = mc->minVal();
+ mx = mc->maxVal();
+
+ Knob* knob = new Knob(this);
+ knob->setRange(double(mn), double(mx), 1.0);
+ knob->setId(ctl);
+ knob->setKnobImage(img);
+
+ controller[idx].knob = knob;
+ knob->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ knob->setBackgroundRole(QPalette::Mid);
+ knob->setToolTip(tt);
+ knob->setEnabled(enabled);
+
+ DoubleLabel* dl = new DoubleLabel(0.0, double(mn), double(mx), this);
+ dl->setId(idx);
+ dl->setSpecialText(tr("off"));
+ dl->setToolTip(tr("double click on/off"));
+ controller[idx].dl = dl;
+ dl->setFont(config.fonts[1]);
+ dl->setBackgroundRole(QPalette::Mid);
+ dl->setFrame(true);
+ dl->setPrecision(0);
+ dl->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ dl->setEnabled(enabled);
+
+ double dlv;
+ v = mp->hwCtrlState(chan, ctl);
+ if(v == CTRL_VAL_UNKNOWN)
+ {
+ //v = mc->initVal();
+ //if(v == CTRL_VAL_UNKNOWN)
+ // v = 0;
+// v = mn - 1;
+ int lastv = mp->lastValidHWCtrlState(chan, ctl);
+ if(lastv == CTRL_VAL_UNKNOWN)
+ {
+ if(mc->initVal() == CTRL_VAL_UNKNOWN)
+ v = 0;
+ else
+ v = mc->initVal();
+ }
+ else
+ v = lastv - mc->bias();
+ //dlv = mn - 1;
+ dlv = dl->off() - 1.0;
+ }
+ else
+ {
+ // Auto bias...
+ v -= mc->bias();
+ dlv = double(v);
+ }
+
+ knob->setValue(double(v));
+ dl->setValue(dlv);
+ //}
+ //else
+ // knob->setRange(0.0, 127.0);
+
+ QLabel* lb = new QLabel(label, this);
+ controller[idx].lb = lb;
+ lb->setFont(config.fonts[1]);
+ lb->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ lb->setAlignment(Qt::AlignCenter);
+ lb->setEnabled(enabled);
+
+ grid->addWidget(lb, _curGridRow, 0);
+ grid->addWidget(dl, _curGridRow+1, 0);
+ grid->addWidget(knob, _curGridRow, 1, 2, 1);
+ _curGridRow += 2;
+
+ connect(knob, SIGNAL(sliderMoved(double,int)), slot);
+ connect(knob, SIGNAL(sliderRightClicked(const QPoint &, int)), SLOT(controlRightClicked(const QPoint &, int)));
+ connect(dl, SIGNAL(valueChanged(double, int)), slot);
+ connect(dl, SIGNAL(doubleClicked(int)), SLOT(labelDoubleClicked(int)));
+ }
+
+//---------------------------------------------------------
+// MidiStrip
+//---------------------------------------------------------
+
+MidiStrip::MidiStrip(QWidget* parent, MidiTrack* t)
+ : Strip(parent, t)
+ {
+ inHeartBeat = true;
+
+ // Clear so the meters don't start off by showing stale values.
+ t->setActivity(0);
+ t->setLastActivity(0);
+
+ volume = CTRL_VAL_UNKNOWN;
+ pan = CTRL_VAL_UNKNOWN;
+ variSend = CTRL_VAL_UNKNOWN;
+ chorusSend = CTRL_VAL_UNKNOWN;
+ reverbSend = CTRL_VAL_UNKNOWN;
+
+ grid->addItem(new QSpacerItem(0, 10), _curGridRow++, 0);
+ addKnob(KNOB_VAR_SEND, tr("VariationSend"), tr("Var"), SLOT(setVariSend(double)), false);
+ addKnob(KNOB_REV_SEND, tr("ReverbSend"), tr("Rev"), SLOT(setReverbSend(double)), false);
+ addKnob(KNOB_CHO_SEND, tr("ChorusSend"), tr("Cho"), SLOT(setChorusSend(double)), false);
+ grid->addItem(new QSpacerItem(0, 5), _curGridRow++, 0);
+ ///int auxsSize = song->auxs()->size();
+ ///if (auxsSize)
+ //layout->addSpacing((STRIP_WIDTH/2 + 1) * auxsSize);
+ ///grid->addSpacing((STRIP_WIDTH/2 + 1) * auxsSize); // ??
+
+ //---------------------------------------------------
+ // slider, label, meter
+ //---------------------------------------------------
+
+ MidiPort* mp = &midiPorts[t->outPort()];
+ MidiController* mc = mp->midiController(CTRL_VOLUME);
+ int chan = t->outChannel();
+ int mn = mc->minVal();
+ int mx = mc->maxVal();
+
+ slider = new Slider(this, "vol", Qt::Vertical, Slider::None,
+ Slider::BgSlot);
+ slider->setCursorHoming(true);
+ slider->setRange(double(mn), double(mx), 1.0);
+ slider->setFixedWidth(20);
+ slider->setFont(config.fonts[1]);
+ slider->setId(CTRL_VOLUME);
+
+ meter[0] = new Meter(this, Meter::LinMeter);
+ meter[0]->setRange(0, 127.0);
+ meter[0]->setFixedWidth(15);
+ connect(meter[0], SIGNAL(mousePress()), this, SLOT(resetPeaks()));
+
+ grid->addItem(new QSpacerItem(0, 10), _curGridRow++, 0);
+ sliderGrid = new QGridLayout();
+ sliderGrid->setRowStretch(0, 100);
+ sliderGrid->addWidget(slider, 0, 0, Qt::AlignRight);
+ sliderGrid->addWidget(meter[0], 0, 1, Qt::AlignLeft);
+ grid->addLayout(sliderGrid, _curGridRow++, 0, 1, 2);
+
+ sl = new DoubleLabel(0.0, -98.0, 0.0, this);
+ sl->setFont(config.fonts[1]);
+ sl->setBackgroundRole(QPalette::Mid);
+ sl->setSpecialText(tr("off"));
+ sl->setSuffix(tr("dB"));
+ sl->setToolTip(tr("double click on/off"));
+ sl->setFrame(true);
+ sl->setPrecision(0);
+ sl->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum));
+ // Set the label's slider 'buddy'.
+ sl->setSlider(slider);
+
+ double dlv;
+ int v = mp->hwCtrlState(chan, CTRL_VOLUME);
+ if(v == CTRL_VAL_UNKNOWN)
+ {
+ int lastv = mp->lastValidHWCtrlState(chan, CTRL_VOLUME);
+ if(lastv == CTRL_VAL_UNKNOWN)
+ {
+ if(mc->initVal() == CTRL_VAL_UNKNOWN)
+ v = 0;
+ else
+ v = mc->initVal();
+ }
+ else
+ v = lastv - mc->bias();
+ dlv = sl->off() - 1.0;
+ }
+ else
+ {
+ if(v == 0)
+ dlv = sl->minValue() - 0.5 * (sl->minValue() - sl->off());
+ else
+ {
+ dlv = -fast_log10(float(127*127)/float(v*v))*20.0;
+ if(dlv > sl->maxValue())
+ dlv = sl->maxValue();
+ }
+ // Auto bias...
+ v -= mc->bias();
+ }
+ slider->setValue(double(v));
+ sl->setValue(dlv);
+
+
+// connect(sl, SIGNAL(valueChanged(double,int)), slider, SLOT(setValue(double)));
+// connect(slider, SIGNAL(valueChanged(double,int)), sl, SLOT(setValue(double)));
+ connect(slider, SIGNAL(sliderMoved(double,int)), SLOT(setVolume(double)));
+ connect(slider, SIGNAL(sliderRightClicked(const QPoint &, int)), SLOT(controlRightClicked(const QPoint &, int)));
+ connect(sl, SIGNAL(valueChanged(double, int)), SLOT(volLabelChanged(double)));
+ connect(sl, SIGNAL(doubleClicked(int)), SLOT(labelDoubleClicked(int)));
+
+ grid->addItem(new QSpacerItem(0, 5), _curGridRow++, 0);
+ grid->addWidget(sl, _curGridRow++, 0, 1, 2, Qt::AlignCenter);
+ grid->addItem(new QSpacerItem(0, 10), _curGridRow++, 0);
+
+ //---------------------------------------------------
+ // pan, balance
+ //---------------------------------------------------
+
+ addKnob(KNOB_PAN, tr("Pan/Balance"), tr("Pan"), SLOT(setPan(double)), true);
+
+ grid->addItem(new QSpacerItem(0, 9), _curGridRow++, 0);
+ updateControls();
+
+ //---------------------------------------------------
+ // mute, solo
+ // or
+ // record, mixdownfile
+ //---------------------------------------------------
+
+ record = new TransparentToolButton(this);
+ record->setBackgroundRole(QPalette::Mid);
+ record->setCheckable(true);
+ record->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+
+ QIcon iconSet;
+ iconSet.addPixmap(*record_on_Icon, QIcon::Normal, QIcon::On);
+ iconSet.addPixmap(*record_off_Icon, QIcon::Normal, QIcon::Off);
+ record->setIcon(iconSet);
+ record->setIconSize(record_on_Icon->size());
+ record->setToolTip(tr("record"));
+ record->setObjectName("btnRecord");
+ record->setChecked(track->recordFlag());
+ connect(record, SIGNAL(clicked(bool)), SLOT(recordToggled(bool)));
+
+ mute = new QToolButton();
+ QIcon muteSet;
+ muteSet.addPixmap(*muteIconOn, QIcon::Normal, QIcon::Off);
+ muteSet.addPixmap(*muteIconOff, QIcon::Normal, QIcon::On);
+ mute->setIcon(muteSet);
+ mute->setIconSize(muteIconOn->size());
+ mute->setCheckable(true);
+ mute->setToolTip(tr("mute"));
+ mute->setObjectName("btnMute");
+ mute->setChecked(track->mute());
+ mute->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ connect(mute, SIGNAL(clicked(bool)), SLOT(muteToggled(bool)));
+
+ solo = new QToolButton();
+
+ if((bool)t->internalSolo())
+ {
+ solo->setIcon(*soloIconSet2);
+ solo->setIconSize(soloIconOn->size());
+ useSoloIconSet2 = true;
+ }
+ else
+ {
+ solo->setIcon(*soloIconSet1);
+ solo->setIconSize(soloblksqIconOn->size());
+ useSoloIconSet2 = false;
+ }
+
+ //solo->setToolTip(tr("pre fader listening"));
+ solo->setToolTip(tr("solo mode"));
+ solo->setCheckable(true);
+ solo->setObjectName("btnSolo");
+ solo->setChecked(t->solo());
+ solo->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ connect(solo, SIGNAL(clicked(bool)), SLOT(soloToggled(bool)));
+
+ /*
+ // Changed by Tim. p3.3.21
+ //QToolTip::add(record, tr("record"));
+ //smBox1->addStretch(100);
+ //smBox1->addWidget(record);
+ QLabel* dev_ch_label = new QLabel();
+ ///dev_ch_label->setMinimumWidth(STRIP_WIDTH/2);
+
+ // Special here: Must make label same size as the 'exit' button would be IF this were an audio strip...
+ // (The 'exit1' icon is BIGGER than the 'record on' icon.)
+ TransparentToolButton* off = new TransparentToolButton(this);
+ QIcon iconOff;
+ iconOff.addPixmap(*exit1Icon, QIcon::Normal, QIcon::On);
+ iconOff.addPixmap(*exitIcon, QIcon::Normal, QIcon::Off);
+ off->setIcon(iconOff);
+ off->setIconSize(exit1Icon->size());
+ dev_ch_label->setMinimumHeight(off->height());
+ delete off;
+
+ //dev_ch_label->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum));
+ ///dev_ch_label->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum));
+ dev_ch_label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ dev_ch_label->setAlignment(Qt::AlignCenter);
+ int port = t->outPort();
+ int channel = t->outChannel();
+ QString dcs;
+ dcs.sprintf("%d-%d", port + 1, channel + 1);
+ dev_ch_label->setText(dcs);
+ //dev_ch_label->setBackgroundColor(QColor(0, 160, 255)); // Med blue
+ //dev_ch_label->setFont(config.fonts[6]);
+ dev_ch_label->setFont(config.fonts[1]);
+ // Dealing with a horizontally constrained label. Ignore vertical. Use a minimum readable point size.
+ //autoAdjustFontSize(dev_ch_label, dev_ch_label->text(), false, true, config.fonts[6].pointSize(), 5);
+ QToolTip::add(dev_ch_label, tr("output port and channel"));
+ */
+
+ off = new TransparentToolButton(this);
+ QIcon iconOff;
+ iconOff.addPixmap(*exit1Icon, QIcon::Normal, QIcon::On);
+ iconOff.addPixmap(*exitIcon, QIcon::Normal, QIcon::Off);
+ off->setIcon(iconOff);
+ off->setIconSize(exit1Icon->size());
+ off->setBackgroundRole(QPalette::Mid);
+ off->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ off->setCheckable(true);
+ off->setToolTip(tr("off"));
+ off->setObjectName("btnExit");
+ off->setChecked(t->off());
+ connect(off, SIGNAL(clicked(bool)), SLOT(offToggled(bool)));
+
+ grid->addWidget(off, _curGridRow, 0);
+ grid->addWidget(record, _curGridRow++, 1);
+ grid->addWidget(mute, _curGridRow, 0);
+ grid->addWidget(solo, _curGridRow++, 1);
+
+ //---------------------------------------------------
+ // routing
+ //---------------------------------------------------
+
+ iR = new QToolButton();
+ iR->setFont(config.fonts[1]);
+ iR->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ //iR->setText(tr("iR"));
+ iR->setIcon(*mixerIn);
+ iR->setIconSize(mixerIn->size());
+ iR->setCheckable(false);
+ iR->setToolTip(tr("input routing"));
+ iR->setObjectName("btnIns");
+ grid->addWidget(iR, _curGridRow, 0);
+ connect(iR, SIGNAL(pressed()), SLOT(iRoutePressed()));
+ oR = new QToolButton();
+ oR->setFont(config.fonts[1]);
+ oR->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ //oR->setText(tr("oR"));
+ oR->setIcon(*mixerOut);
+ oR->setIconSize(mixerIn->size());
+ oR->setCheckable(false);
+ oR->setObjectName("btnOuts");
+ // TODO: Works OK, but disabled for now, until we figure out what to do about multiple out routes and display values...
+ oR->setEnabled(false);
+ oR->setToolTip(tr("output routing"));
+ grid->addWidget(oR, _curGridRow++, 1);
+ connect(oR, SIGNAL(pressed()), SLOT(oRoutePressed()));
+
+ grid->addItem(new QSpacerItem(0, 5), _curGridRow++, 0);
+ //---------------------------------------------------
+ // automation mode
+ //---------------------------------------------------
+
+ autoType = new ComboBox(this);
+ autoType->setFont(config.fonts[1]);
+ autoType->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
+ autoType->setAlignment(Qt::AlignCenter);
+ autoType->setEnabled(false);
+
+ // Removed by T356.
+ // Disabled for now. There is no midi automation mechanism yet...
+ //autoType->insertItem(tr("Off"), AUTO_OFF);
+ //autoType->insertItem(tr("Read"), AUTO_READ);
+ //autoType->insertItem(tr("Touch"), AUTO_TOUCH);
+ //autoType->insertItem(tr("Write"), AUTO_WRITE);
+ //autoType->setCurrentItem(t->automationType());
+ // TODO: Convert ComboBox to QT4
+ //autoType->insertItem(AUTO_OFF, tr("Off"));
+ //autoType->insertItem(AUTO_READ, tr("Read"));
+ //autoType->insertItem(AUTO_TOUCH, tr("Touch"));
+ //autoType->insertItem(AUTO_WRITE, tr("Write"));
+ //autoType->setCurrentIndex(t->automationType());
+ //autoType->setToolTip(tr("automation type"));
+
+ //connect(autoType, SIGNAL(activated(int,int)), SLOT(setAutomationType(int,int)));
+ grid->addWidget(autoType, _curGridRow++, 0, 1, 2);
+ grid->addItem(new QSpacerItem(0, 5), _curGridRow++, 0);
+ QLabel* toprack = new QLabel();
+ toprack->setPixmap(QPixmap(":/images/bottom_rack.png"));
+ grid->addWidget(toprack, _curGridRow++, 0, 1, 2);
+ connect(heartBeatTimer, SIGNAL(timeout()), SLOT(heartBeat()));
+ inHeartBeat = false;
+ }
+
+//---------------------------------------------------------
+// updateOffState
+//---------------------------------------------------------
+
+void MidiStrip::updateOffState()
+ {
+ bool val = !track->off();
+ slider->setEnabled(val);
+ sl->setEnabled(val);
+ controller[KNOB_PAN].knob->setEnabled(val);
+ controller[KNOB_PAN].dl->setEnabled(val);
+ label->setEnabled(val);
+
+ if (record)
+ record->setEnabled(val);
+ if (solo)
+ solo->setEnabled(val);
+ if (mute)
+ mute->setEnabled(val);
+ if (autoType)
+ autoType->setEnabled(val);
+ if (iR)
+ iR->setEnabled(val);
+ // TODO: Disabled for now.
+ //if (oR)
+ // oR->setEnabled(val);
+ if (off) {
+ off->blockSignals(true);
+ off->setChecked(track->off());
+ off->blockSignals(false);
+ }
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void MidiStrip::songChanged(int val)
+ {
+ if (mute && (val & SC_MUTE)) { // mute && off
+ mute->blockSignals(true);
+ mute->setChecked(track->isMute());
+ updateOffState();
+ mute->blockSignals(false);
+ }
+ if (solo && (val & SC_SOLO))
+ {
+ if((bool)track->internalSolo())
+ {
+ if(!useSoloIconSet2)
+ {
+ solo->setIcon(*soloIconSet2);
+ solo->setIconSize(soloIconOn->size());
+ useSoloIconSet2 = true;
+ }
+ }
+ else if(useSoloIconSet2)
+ {
+ solo->setIcon(*soloIconSet1);
+ solo->setIconSize(soloblksqIconOn->size());
+ useSoloIconSet2 = false;
+ }
+ solo->blockSignals(true);
+ solo->setChecked(track->solo());
+ solo->blockSignals(false);
+ }
+
+ if (val & SC_RECFLAG)
+ setRecordFlag(track->recordFlag());
+ if (val & SC_TRACK_MODIFIED)
+ {
+ setLabelText();
+ // Added by Tim. p3.3.9
+ setLabelFont();
+
+ }
+ // Added by Tim. p3.3.9
+
+ // Catch when label font changes.
+ if (val & SC_CONFIG)
+ {
+ // Set the strip label's font.
+ //label->setFont(config.fonts[1]);
+ setLabelFont();
+ }
+
+ // p3.3.47 Update the routing popup menu if anything relevant changes.
+ //if(gRoutingPopupMenuMaster == this && track && (val & (SC_ROUTE | SC_CHANNELS | SC_CONFIG)))
+ if(val & (SC_ROUTE | SC_CHANNELS | SC_CONFIG)) // p3.3.50
+ // Use this handy shared routine.
+ //muse->updateRouteMenus(track);
+ muse->updateRouteMenus(track, this); // p3.3.50
+ }
+
+//---------------------------------------------------------
+// controlRightClicked
+//---------------------------------------------------------
+
+void MidiStrip::controlRightClicked(const QPoint &p, int id)
+{
+ song->execMidiAutomationCtlPopup((MidiTrack*)track, 0, p, id);
+}
+
+//---------------------------------------------------------
+// labelDoubleClicked
+//---------------------------------------------------------
+
+void MidiStrip::labelDoubleClicked(int idx)
+{
+ //int mn, mx, v;
+ //int num = CTRL_VOLUME;
+ int num;
+ switch(idx)
+ {
+ case KNOB_PAN:
+ num = CTRL_PANPOT;
+ break;
+ case KNOB_VAR_SEND:
+ num = CTRL_VARIATION_SEND;
+ break;
+ case KNOB_REV_SEND:
+ num = CTRL_REVERB_SEND;
+ break;
+ case KNOB_CHO_SEND:
+ num = CTRL_CHORUS_SEND;
+ break;
+ //case -1:
+ default:
+ num = CTRL_VOLUME;
+ break;
+ }
+ int outport = ((MidiTrack*)track)->outPort();
+ int chan = ((MidiTrack*)track)->outChannel();
+ MidiPort* mp = &midiPorts[outport];
+ MidiController* mc = mp->midiController(num);
+
+ int lastv = mp->lastValidHWCtrlState(chan, num);
+ int curv = mp->hwCtrlState(chan, num);
+
+ if(curv == CTRL_VAL_UNKNOWN)
+ {
+ // If no value has ever been set yet, use the current knob value
+ // (or the controller's initial value?) to 'turn on' the controller.
+ if(lastv == CTRL_VAL_UNKNOWN)
+ {
+ //int kiv = _ctrl->initVal());
+ int kiv;
+ if(idx == -1)
+ kiv = lrint(slider->value());
+ else
+ kiv = lrint(controller[idx].knob->value());
+ if(kiv < mc->minVal())
+ kiv = mc->minVal();
+ if(kiv > mc->maxVal())
+ kiv = mc->maxVal();
+ kiv += mc->bias();
+
+ //MidiPlayEvent ev(song->cpos(), outport, chan, ME_CONTROLLER, num, kiv);
+ MidiPlayEvent ev(0, outport, chan, ME_CONTROLLER, num, kiv);
+ audio->msgPlayMidiEvent(&ev);
+ }
+ else
+ {
+ //MidiPlayEvent ev(song->cpos(), outport, chan, ME_CONTROLLER, num, lastv);
+ MidiPlayEvent ev(0, outport, chan, ME_CONTROLLER, num, lastv);
+ audio->msgPlayMidiEvent(&ev);
+ }
+ }
+ else
+ {
+ if(mp->hwCtrlState(chan, num) != CTRL_VAL_UNKNOWN)
+ audio->msgSetHwCtrlState(mp, chan, num, CTRL_VAL_UNKNOWN);
+ }
+ song->update(SC_MIDI_CONTROLLER);
+}
+
+
+//---------------------------------------------------------
+// offToggled
+//---------------------------------------------------------
+
+void MidiStrip::offToggled(bool val)
+ {
+ track->setOff(val);
+ song->update(SC_MUTE);
+ }
+
+/*
+//---------------------------------------------------------
+// routeClicked
+//---------------------------------------------------------
+
+void MidiStrip::routeClicked()
+ {
+ }
+*/
+
+//---------------------------------------------------------
+// heartBeat
+//---------------------------------------------------------
+
+void MidiStrip::heartBeat()
+ {
+ inHeartBeat = true;
+
+ int act = track->activity();
+ double dact = double(act) * (slider->value() / 127.0);
+
+ if((int)dact > track->lastActivity())
+ track->setLastActivity((int)dact);
+
+ if(meter[0])
+ //meter[0]->setVal(int(double(act) * (slider->value() / 127.0)), 0, false);
+ meter[0]->setVal(dact, track->lastActivity(), false);
+
+ // Gives reasonable decay with gui update set to 20/sec.
+ if(act)
+ track->setActivity((int)((double)act * 0.8));
+
+ Strip::heartBeat();
+ updateControls();
+
+ inHeartBeat = false;
+ }
+
+//---------------------------------------------------------
+// updateControls
+//---------------------------------------------------------
+
+void MidiStrip::updateControls()
+ {
+ bool en;
+ int channel = ((MidiTrack*)track)->outChannel();
+ MidiPort* mp = &midiPorts[((MidiTrack*)track)->outPort()];
+ MidiCtrlValListList* mc = mp->controller();
+ ciMidiCtrlValList icl;
+
+ MidiController* ctrl = mp->midiController(CTRL_VOLUME);
+ int nvolume = mp->hwCtrlState(channel, CTRL_VOLUME);
+ if(nvolume == CTRL_VAL_UNKNOWN)
+ {
+ //if(nvolume != volume)
+ //{
+ // DoubleLabel ignores the value if already set...
+ sl->setValue(sl->off() - 1.0);
+ //volume = nvolume;
+ //}
+ volume = CTRL_VAL_UNKNOWN;
+ nvolume = mp->lastValidHWCtrlState(channel, CTRL_VOLUME);
+ //if(nvolume != volume)
+ if(nvolume != CTRL_VAL_UNKNOWN)
+ {
+ nvolume -= ctrl->bias();
+ //slider->blockSignals(true);
+ if(double(nvolume) != slider->value())
+ {
+ //printf("MidiStrip::updateControls setting volume slider\n");
+
+ slider->setValue(double(nvolume));
+ }
+ }
+ }
+ else
+ {
+ int ivol = nvolume;
+ nvolume -= ctrl->bias();
+ if(nvolume != volume) {
+ //printf("MidiStrip::updateControls setting volume slider\n");
+
+ //slider->blockSignals(true);
+ slider->setValue(double(nvolume));
+ //sl->setValue(double(nvolume));
+ if(ivol == 0)
+ {
+ //printf("MidiStrip::updateControls setting volume slider label\n");
+
+ sl->setValue(sl->minValue() - 0.5 * (sl->minValue() - sl->off()));
+ }
+ else
+ {
+ double v = -fast_log10(float(127*127)/float(ivol*ivol))*20.0;
+ if(v > sl->maxValue())
+ {
+ //printf("MidiStrip::updateControls setting volume slider label\n");
+
+ sl->setValue(sl->maxValue());
+ }
+ else
+ {
+ //printf("MidiStrip::updateControls setting volume slider label\n");
+
+ sl->setValue(v);
+ }
+ }
+ //slider->blockSignals(false);
+ volume = nvolume;
+ }
+ }
+
+
+ KNOB* gcon = &controller[KNOB_PAN];
+ ctrl = mp->midiController(CTRL_PANPOT);
+ int npan = mp->hwCtrlState(channel, CTRL_PANPOT);
+ if(npan == CTRL_VAL_UNKNOWN)
+ {
+ // DoubleLabel ignores the value if already set...
+ //if(npan != pan)
+ //{
+ gcon->dl->setValue(gcon->dl->off() - 1.0);
+ //pan = npan;
+ //}
+ pan = CTRL_VAL_UNKNOWN;
+ npan = mp->lastValidHWCtrlState(channel, CTRL_PANPOT);
+ if(npan != CTRL_VAL_UNKNOWN)
+ {
+ npan -= ctrl->bias();
+ if(double(npan) != gcon->knob->value())
+ {
+ //printf("MidiStrip::updateControls setting pan knob\n");
+
+ gcon->knob->setValue(double(npan));
+ }
+ }
+ }
+ else
+ {
+ npan -= ctrl->bias();
+ if(npan != pan)
+ {
+ //printf("MidiStrip::updateControls setting pan label and knob\n");
+
+ //controller[KNOB_PAN].knob->blockSignals(true);
+ gcon->knob->setValue(double(npan));
+ gcon->dl->setValue(double(npan));
+ //controller[KNOB_PAN].knob->blockSignals(false);
+ pan = npan;
+ }
+ }
+
+
+ icl = mc->find(channel, CTRL_VARIATION_SEND);
+ en = icl != mc->end();
+
+ gcon = &controller[KNOB_VAR_SEND];
+ if(gcon->knob->isEnabled() != en)
+ gcon->knob->setEnabled(en);
+ if(gcon->lb->isEnabled() != en)
+ gcon->lb->setEnabled(en);
+ if(gcon->dl->isEnabled() != en)
+ gcon->dl->setEnabled(en);
+
+ if(en)
+ {
+ ctrl = mp->midiController(CTRL_VARIATION_SEND);
+ int nvariSend = icl->second->hwVal();
+ if(nvariSend == CTRL_VAL_UNKNOWN)
+ {
+ // DoubleLabel ignores the value if already set...
+ //if(nvariSend != variSend)
+ //{
+ gcon->dl->setValue(gcon->dl->off() - 1.0);
+ //variSend = nvariSend;
+ //}
+ variSend = CTRL_VAL_UNKNOWN;
+ nvariSend = mp->lastValidHWCtrlState(channel, CTRL_VARIATION_SEND);
+ if(nvariSend != CTRL_VAL_UNKNOWN)
+ {
+ nvariSend -= ctrl->bias();
+ if(double(nvariSend) != gcon->knob->value())
+ {
+ gcon->knob->setValue(double(nvariSend));
+ }
+ }
+ }
+ else
+ {
+ nvariSend -= ctrl->bias();
+ if(nvariSend != variSend)
+ {
+ //controller[KNOB_VAR_SEND].knob->blockSignals(true);
+ gcon->knob->setValue(double(nvariSend));
+ gcon->dl->setValue(double(nvariSend));
+ //controller[KNOB_VAR_SEND].knob->blockSignals(false);
+ variSend = nvariSend;
+ }
+ }
+ }
+
+ icl = mc->find(channel, CTRL_REVERB_SEND);
+ en = icl != mc->end();
+
+ gcon = &controller[KNOB_REV_SEND];
+ if(gcon->knob->isEnabled() != en)
+ gcon->knob->setEnabled(en);
+ if(gcon->lb->isEnabled() != en)
+ gcon->lb->setEnabled(en);
+ if(gcon->dl->isEnabled() != en)
+ gcon->dl->setEnabled(en);
+
+ if(en)
+ {
+ ctrl = mp->midiController(CTRL_REVERB_SEND);
+ int nreverbSend = icl->second->hwVal();
+ if(nreverbSend == CTRL_VAL_UNKNOWN)
+ {
+ // DoubleLabel ignores the value if already set...
+ //if(nreverbSend != reverbSend)
+ //{
+ gcon->dl->setValue(gcon->dl->off() - 1.0);
+ //reverbSend = nreverbSend;
+ //}
+ reverbSend = CTRL_VAL_UNKNOWN;
+ nreverbSend = mp->lastValidHWCtrlState(channel, CTRL_REVERB_SEND);
+ if(nreverbSend != CTRL_VAL_UNKNOWN)
+ {
+ nreverbSend -= ctrl->bias();
+ if(double(nreverbSend) != gcon->knob->value())
+ {
+ gcon->knob->setValue(double(nreverbSend));
+ }
+ }
+ }
+ else
+ {
+ nreverbSend -= ctrl->bias();
+ if(nreverbSend != reverbSend)
+ {
+ //controller[KNOB_REV_SEND].knob->blockSignals(true);
+ gcon->knob->setValue(double(nreverbSend));
+ gcon->dl->setValue(double(nreverbSend));
+ //controller[KNOB_REV_SEND].knob->blockSignals(false);
+ reverbSend = nreverbSend;
+ }
+ }
+ }
+
+ icl = mc->find(channel, CTRL_CHORUS_SEND);
+ en = icl != mc->end();
+
+ gcon = &controller[KNOB_CHO_SEND];
+ if(gcon->knob->isEnabled() != en)
+ gcon->knob->setEnabled(en);
+ if(gcon->lb->isEnabled() != en)
+ gcon->lb->setEnabled(en);
+ if(gcon->dl->isEnabled() != en)
+ gcon->dl->setEnabled(en);
+
+ if(en)
+ {
+ ctrl = mp->midiController(CTRL_CHORUS_SEND);
+ int nchorusSend = icl->second->hwVal();
+ if(nchorusSend == CTRL_VAL_UNKNOWN)
+ {
+ // DoubleLabel ignores the value if already set...
+ //if(nchorusSend != chorusSend)
+ //{
+ gcon->dl->setValue(gcon->dl->off() - 1.0);
+ //chorusSend = nchorusSend;
+ //}
+ chorusSend = CTRL_VAL_UNKNOWN;
+ nchorusSend = mp->lastValidHWCtrlState(channel, CTRL_CHORUS_SEND);
+ if(nchorusSend != CTRL_VAL_UNKNOWN)
+ {
+ nchorusSend -= ctrl->bias();
+ if(double(nchorusSend) != gcon->knob->value())
+ {
+ gcon->knob->setValue(double(nchorusSend));
+ }
+ }
+ }
+ else
+ {
+ nchorusSend -= ctrl->bias();
+ if(nchorusSend != chorusSend)
+ {
+ gcon->knob->setValue(double(nchorusSend));
+ gcon->dl->setValue(double(nchorusSend));
+ chorusSend = nchorusSend;
+ }
+ }
+ }
+ }
+//---------------------------------------------------------
+// ctrlChanged
+//---------------------------------------------------------
+
+void MidiStrip::ctrlChanged(int num, int val)
+ {
+ if (inHeartBeat)
+ return;
+
+ MidiTrack* t = (MidiTrack*) track;
+ int port = t->outPort();
+
+ int chan = t->outChannel();
+ MidiPort* mp = &midiPorts[port];
+ MidiController* mctl = mp->midiController(num);
+ if((val < mctl->minVal()) || (val > mctl->maxVal()))
+ {
+ if(mp->hwCtrlState(chan, num) != CTRL_VAL_UNKNOWN)
+ audio->msgSetHwCtrlState(mp, chan, num, CTRL_VAL_UNKNOWN);
+ }
+ else
+ {
+ val += mctl->bias();
+
+ int tick = song->cpos();
+
+ MidiPlayEvent ev(tick, port, chan, ME_CONTROLLER, num, val);
+
+ audio->msgPlayMidiEvent(&ev);
+ }
+ song->update(SC_MIDI_CONTROLLER);
+ }
+
+//---------------------------------------------------------
+// volLabelChanged
+//---------------------------------------------------------
+
+void MidiStrip::volLabelChanged(double val)
+ {
+ val = sqrt( float(127*127) / pow(10.0, -val/20.0) );
+
+ ctrlChanged(CTRL_VOLUME, lrint(val));
+
+ }
+
+//---------------------------------------------------------
+// setVolume
+//---------------------------------------------------------
+
+void MidiStrip::setVolume(double val)
+ {
+
+// printf("Vol %d\n", lrint(val));
+ ctrlChanged(CTRL_VOLUME, lrint(val));
+ }
+
+//---------------------------------------------------------
+// setPan
+//---------------------------------------------------------
+
+void MidiStrip::setPan(double val)
+ {
+
+ ctrlChanged(CTRL_PANPOT, lrint(val));
+ }
+
+//---------------------------------------------------------
+// setVariSend
+//---------------------------------------------------------
+
+void MidiStrip::setVariSend(double val)
+ {
+ ctrlChanged(CTRL_VARIATION_SEND, lrint(val));
+ }
+
+//---------------------------------------------------------
+// setChorusSend
+//---------------------------------------------------------
+
+void MidiStrip::setChorusSend(double val)
+ {
+ ctrlChanged(CTRL_CHORUS_SEND, lrint(val));
+ }
+
+//---------------------------------------------------------
+// setReverbSend
+//---------------------------------------------------------
+
+void MidiStrip::setReverbSend(double val)
+ {
+ ctrlChanged(CTRL_REVERB_SEND, lrint(val));
+ }
+
+//---------------------------------------------------------
+// routingPopupMenuActivated
+//---------------------------------------------------------
+
+void MidiStrip::routingPopupMenuActivated(QAction* act)
+{
+ if(gRoutingPopupMenuMaster != this || !track || !track->isMidiTrack())
+ return;
+
+ muse->routingPopupMenuActivated(track, act->data().toInt());
+}
+
+//---------------------------------------------------------
+// iRoutePressed
+//---------------------------------------------------------
+
+void MidiStrip::iRoutePressed()
+{
+ if(!track || !track->isMidiTrack())
+ return;
+
+ PopupMenu* pup = muse->prepareRoutingPopupMenu(track, false);
+ if(!pup)
+ return;
+
+ gRoutingPopupMenuMaster = this;
+ connect(pup, SIGNAL(triggered(QAction*)), SLOT(routingPopupMenuActivated(QAction*)));
+ connect(pup, SIGNAL(aboutToHide()), muse, SLOT(routingPopupMenuAboutToHide()));
+ pup->popup(QCursor::pos());
+ iR->setDown(false);
+}
+
+//---------------------------------------------------------
+// oRoutePressed
+//---------------------------------------------------------
+
+void MidiStrip::oRoutePressed()
+{
+ if(!track || !track->isMidiTrack())
+ return;
+
+ PopupMenu* pup = muse->prepareRoutingPopupMenu(track, true);
+ if(!pup)
+ return;
+
+ gRoutingPopupMenuMaster = this;
+ connect(pup, SIGNAL(triggered(QAction*)), SLOT(routingPopupMenuActivated(QAction*)));
+ connect(pup, SIGNAL(aboutToHide()), muse, SLOT(routingPopupMenuAboutToHide()));
+ pup->popup(QCursor::pos());
+ oR->setDown(false);
+}
+
+
diff --git a/attic/muse2-oom/muse2/muse/mixer/mstrip.h b/attic/muse2-oom/muse2/muse/mixer/mstrip.h
new file mode 100644
index 00000000..920cca99
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/mstrip.h
@@ -0,0 +1,86 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mstrip.h,v 1.4.2.4 2009/10/25 19:26:29 lunar_shuttle Exp $
+//
+// (C) Copyright 2000-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MSTRIP_H__
+#define __MSTRIP_H__
+
+#include "strip.h"
+#include <QLabel>
+
+class Slider;
+class DoubleLabel;
+class QDialog;
+class Knob;
+class QString;
+class MidiTrack;
+class QLabel;
+class QAction;
+class TransparentToolButton;
+
+//---------------------------------------------------------
+// MidiStrip
+//---------------------------------------------------------
+
+class MidiStrip : public Strip {
+ Q_OBJECT
+
+ Slider* slider;
+ DoubleLabel* sl;
+ TransparentToolButton* off;
+ //QToolButton* route;
+ //QToolButton* iR;
+ //QToolButton* oR;
+
+ struct KNOB {
+ Knob* knob;
+ DoubleLabel* dl;
+ QLabel* lb;
+ } controller[4]; // pan variation reverb chorus
+
+ int volume;
+ int variSend;
+ int reverbSend;
+ int chorusSend;
+ int pan;
+ bool inHeartBeat;
+
+ void addKnob(int idx, const QString&, const QString&, const char*, bool);
+ void ctrlChanged(int num, int val);
+ void updateControls();
+ void updateOffState();
+
+ private slots:
+ //void routeClicked();
+ void offToggled(bool);
+ void iRoutePressed();
+ void oRoutePressed();
+ void routingPopupMenuActivated(QAction*);
+ void setVolume(double);
+ void setPan(double);
+ void setChorusSend(double);
+ void setVariSend(double);
+ void setReverbSend(double);
+ void labelDoubleClicked(int);
+ void volLabelChanged(double);
+ void controlRightClicked(const QPoint&, int);
+
+ protected slots:
+ virtual void heartBeat();
+
+ public slots:
+ virtual void songChanged(int);
+
+ public:
+ MidiStrip(QWidget* parent, MidiTrack*);
+ };
+
+
+#endif
+
+
+
diff --git a/attic/muse2-oom/muse2/muse/mixer/panknob.cpp b/attic/muse2-oom/muse2/muse/mixer/panknob.cpp
new file mode 100644
index 00000000..065c1bd1
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/panknob.cpp
@@ -0,0 +1,32 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: panknob.cpp,v 1.5 2004/01/23 08:41:38 wschweer Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "../audio.h"
+#include "panknob.h"
+
+//---------------------------------------------------------
+// PanKnob
+//---------------------------------------------------------
+
+PanKnob::PanKnob(QWidget* parent, AudioTrack* s)
+ : Knob(parent, "pan")
+ {
+ src = s;
+ connect(this, SIGNAL(valueChanged(double,int)), SLOT(valueChanged(double)));
+ }
+
+//---------------------------------------------------------
+// panChanged
+//---------------------------------------------------------
+
+void PanKnob::valueChanged(double val)
+ {
+ audio->msgSetPan(src, val);
+ }
+
+
diff --git a/attic/muse2-oom/muse2/muse/mixer/panknob.h b/attic/muse2-oom/muse2/muse/mixer/panknob.h
new file mode 100644
index 00000000..92c41b03
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/panknob.h
@@ -0,0 +1,32 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: panknob.h,v 1.3 2003/11/08 15:10:18 wschweer Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __PANKNOB_H__
+#define __PANKNOB_H__
+
+#include "knob.h"
+
+class AudioTrack;
+
+//---------------------------------------------------------
+// PanKnob
+//---------------------------------------------------------
+
+class PanKnob : public Knob {
+ Q_OBJECT
+ AudioTrack* src;
+
+ private slots:
+ void valueChanged(double);
+
+ public:
+ PanKnob(QWidget* parent, AudioTrack*);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/mixer/rack.cpp b/attic/muse2-oom/muse2/muse/mixer/rack.cpp
new file mode 100644
index 00000000..ab2e890a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/rack.cpp
@@ -0,0 +1,588 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: rack.cpp,v 1.7.2.7 2007/01/27 14:52:43 spamatica Exp $
+//
+// (C) Copyright 2000-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QByteArray>
+#include <QDrag>
+#include <QDragEnterEvent>
+#include <QDropEvent>
+#include <QMenu>
+#include <QMessageBox>
+#include <QMimeData>
+#include <QMouseEvent>
+#include <QPainter>
+#include <QPalette>
+#include <QUrl>
+
+#include <errno.h>
+
+#include "xml.h"
+#include "rack.h"
+#include "song.h"
+#include "audio.h"
+#include "icons.h"
+#include "gconfig.h"
+#include "plugin.h"
+#include "filedialog.h"
+
+//---------------------------------------------------------
+// class RackSlot
+//---------------------------------------------------------
+
+class RackSlot : public QListWidgetItem {
+ int idx;
+ AudioTrack* node;
+
+ public:
+ RackSlot(QListWidget* lb, AudioTrack* t, int i);
+ ~RackSlot();
+ void setBackgroundColor(const QBrush& brush) {setBackground(brush);};
+ };
+
+RackSlot::~RackSlot()
+ {
+ node = 0;
+ }
+
+//---------------------------------------------------------
+// RackSlot
+//---------------------------------------------------------
+
+RackSlot::RackSlot(QListWidget* b, AudioTrack* t, int i)
+ : QListWidgetItem(b)
+ {
+ node = t;
+ idx = i;
+ setSizeHint(QSize(10,17));
+ }
+
+//---------------------------------------------------------
+// EffectRack
+//---------------------------------------------------------
+
+EffectRack::EffectRack(QWidget* parent, AudioTrack* t)
+ : QListWidget(parent)
+ {
+ setObjectName("Rack");
+ setAttribute(Qt::WA_DeleteOnClose);
+ track = t;
+ setFont(config.fonts[1]);
+
+ setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
+ setSelectionMode(QAbstractItemView::SingleSelection);
+ setMaximumHeight(19 * PipelineDepth);
+ for (int i = 0; i < PipelineDepth; ++i)
+ new RackSlot(this, track, i);
+ updateContents();
+
+ connect(this, SIGNAL(itemDoubleClicked(QListWidgetItem*)),
+ this, SLOT(doubleClicked(QListWidgetItem*)));
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+
+ setSpacing(0);
+ //QPalette qpal;
+ //qpal.setColor(QPalette::Base, QColor(palette().midlight().color()));
+ //setPalette(qpal);
+
+ setAcceptDrops(true);
+ }
+
+void EffectRack::updateContents()
+ {
+ for (int i = 0; i < PipelineDepth; ++i) {
+ QString name = track->efxPipe()->name(i);
+ item(i)->setText(name);
+ //item(i)->setBackground(track->efxPipe()->isOn(i) ? palette().mid() : palette().dark());
+ item(i)->setToolTip(name == QString("empty") ? tr("effect rack") : name );
+ }
+ }
+
+//---------------------------------------------------------
+// EffectRack
+//---------------------------------------------------------
+
+EffectRack::~EffectRack()
+ {
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void EffectRack::songChanged(int typ)
+ {
+ if (typ & (SC_ROUTE | SC_RACK)) {
+ updateContents();
+ }
+ }
+
+//---------------------------------------------------------
+// minimumSizeHint
+//---------------------------------------------------------
+
+QSize EffectRack::minimumSizeHint() const
+ {
+ return QSize(10, 19 * PipelineDepth);
+ }
+
+//---------------------------------------------------------
+// SizeHint
+//---------------------------------------------------------
+
+QSize EffectRack::sizeHint() const
+ {
+ return minimumSizeHint();
+ }
+
+
+void EffectRack::choosePlugin(QListWidgetItem* it, bool replace)
+ {
+ Plugin* plugin = PluginDialog::getPlugin(this);
+ if (plugin) {
+ PluginI* plugi = new PluginI();
+ if (plugi->initPluginInstance(plugin, track->channels())) {
+ printf("cannot instantiate plugin <%s>\n",
+ plugin->name().toLatin1().constData());
+ delete plugi;
+ return;
+ }
+ int idx = row(it);
+ if (replace)
+ audio->msgAddPlugin(track, idx, 0);
+ audio->msgAddPlugin(track, idx, plugi);
+ updateContents();
+ }
+ }
+
+//---------------------------------------------------------
+// menuRequested
+//---------------------------------------------------------
+
+void EffectRack::menuRequested(QListWidgetItem* it)
+ {
+ if (it == 0 || track == 0)
+ return;
+ RackSlot* curitem = (RackSlot*)it;
+ int idx = row(curitem);
+ QString name;
+ bool mute;
+ Pipeline* pipe = track->efxPipe();
+ if (pipe) {
+ name = pipe->name(idx);
+ mute = pipe->isOn(idx);
+ }
+
+ //enum { NEW, CHANGE, UP, DOWN, REMOVE, BYPASS, SHOW, SAVE };
+ enum { NEW, CHANGE, UP, DOWN, REMOVE, BYPASS, SHOW, SHOW_NATIVE, SAVE };
+ QMenu* menu = new QMenu;
+ QAction* newAction = menu->addAction(tr("new"));
+ QAction* changeAction = menu->addAction(tr("change"));
+ QAction* upAction = menu->addAction(QIcon(*upIcon), tr("move up"));//, UP, UP);
+ QAction* downAction = menu->addAction(QIcon(*downIcon), tr("move down"));//, DOWN, DOWN);
+ QAction* removeAction = menu->addAction(tr("remove"));//, REMOVE, REMOVE);
+ QAction* bypassAction = menu->addAction(tr("bypass"));//, BYPASS, BYPASS);
+ QAction* showGuiAction = menu->addAction(tr("show gui"));//, SHOW, SHOW);
+ QAction* showNativeGuiAction = menu->addAction(tr("show native gui"));//, SHOW_NATIVE, SHOW_NATIVE);
+ QAction* saveAction = menu->addAction(tr("save preset"));
+
+ newAction->setData(NEW);
+ changeAction->setData(CHANGE);
+ upAction->setData(UP);
+ downAction->setData(DOWN);
+ removeAction->setData(REMOVE);
+ bypassAction->setData(BYPASS);
+ showGuiAction->setData(SHOW);
+ showNativeGuiAction->setData(SHOW_NATIVE);
+ saveAction->setData(SAVE);
+
+ bypassAction->setCheckable(true);
+ showGuiAction->setCheckable(true);
+ showNativeGuiAction->setCheckable(true);
+
+ bypassAction->setChecked(!pipe->isOn(idx));
+ showGuiAction->setChecked(pipe->guiVisible(idx));
+ showNativeGuiAction->setChecked(pipe->nativeGuiVisible(idx));
+
+ if (pipe->empty(idx)) {
+ menu->removeAction(changeAction);
+ menu->removeAction(saveAction);
+ upAction->setEnabled(false);
+ downAction->setEnabled(false);
+ removeAction->setEnabled(false);
+ bypassAction->setEnabled(false);
+ showGuiAction->setEnabled(false);
+ showNativeGuiAction->setEnabled(false);
+ }
+ else {
+ menu->removeAction(newAction);
+ if (idx == 0)
+ upAction->setEnabled(true);
+ if (idx == (PipelineDepth-1))
+ downAction->setEnabled(false);
+ if(!pipe->isDssiPlugin(idx))
+ showNativeGuiAction->setEnabled(false);
+ }
+
+ #ifndef OSC_SUPPORT
+ showNativeGuiAction->setEnabled(false);
+ #endif
+
+ QPoint pt = QCursor::pos();
+ QAction* act = menu->exec(pt, 0);
+
+ //delete menu;
+ if (!act)
+ {
+ delete menu;
+ return;
+ }
+
+ int sel = act->data().toInt();
+ delete menu;
+
+ switch(sel) {
+ case NEW:
+ {
+ choosePlugin(it);
+ break;
+ }
+ case CHANGE:
+ {
+ choosePlugin(it, true);
+ break;
+ }
+ case REMOVE:
+ audio->msgAddPlugin(track, idx, 0);
+ break;
+ case BYPASS:
+ {
+ bool flag = !pipe->isOn(idx);
+ pipe->setOn(idx, flag);
+ break;
+ }
+ case SHOW:
+ {
+ bool flag = !pipe->guiVisible(idx);
+ pipe->showGui(idx, flag);
+ break;
+ }
+ case SHOW_NATIVE:
+ {
+ bool flag = !pipe->nativeGuiVisible(idx);
+ pipe->showNativeGui(idx, flag);
+ break;
+ }
+ case UP:
+ if (idx > 0) {
+ setCurrentItem(item(idx-1));
+ pipe->move(idx, true);
+ }
+ break;
+ case DOWN:
+ if (idx < (PipelineDepth-1)) {
+ setCurrentItem(item(idx+1));
+ pipe->move(idx, false);
+ }
+ break;
+ case SAVE:
+ savePreset(idx);
+ break;
+ }
+ updateContents();
+ song->update(SC_RACK);
+ }
+
+//---------------------------------------------------------
+// doubleClicked
+// toggle gui
+//---------------------------------------------------------
+
+void EffectRack::doubleClicked(QListWidgetItem* it)
+ {
+ if (it == 0 || track == 0)
+ return;
+
+ RackSlot* item = (RackSlot*)it;
+ int idx = row(item);
+ Pipeline* pipe = track->efxPipe();
+
+ if (pipe->name(idx) == QString("empty")) {
+ choosePlugin(it);
+ return;
+ }
+ if (pipe) {
+ bool flag = !pipe->guiVisible(idx);
+ pipe->showGui(idx, flag);
+ }
+ }
+
+void EffectRack::savePreset(int idx)
+ {
+ //QString name = getSaveFileName(QString(""), plug_file_pattern, this,
+ QString name = getSaveFileName(QString(""), preset_file_save_pattern, this,
+ tr("MusE: Save Preset"));
+
+ if(name.isEmpty())
+ return;
+
+ //FILE* presetFp = fopen(name.ascii(),"w+");
+ bool popenFlag;
+ FILE* presetFp = fileOpen(this, name, QString(".pre"), "w", popenFlag, false, true);
+ if (presetFp == 0) {
+ //fprintf(stderr, "EffectRack::savePreset() fopen failed: %s\n",
+ // strerror(errno));
+ return;
+ }
+ Xml xml(presetFp);
+ Pipeline* pipe = track->efxPipe();
+ if (pipe) {
+ if ((*pipe)[idx] != NULL) {
+ xml.header();
+ xml.tag(0, "muse version=\"1.0\"");
+ (*pipe)[idx]->writeConfiguration(1, xml);
+ xml.tag(0, "/muse");
+ }
+ else {
+ printf("no plugin!\n");
+ //fclose(presetFp);
+ if (popenFlag)
+ pclose(presetFp);
+ else
+ fclose(presetFp);
+ return;
+ }
+ }
+ else {
+ printf("no pipe!\n");
+ //fclose(presetFp);
+ if (popenFlag)
+ pclose(presetFp);
+ else
+ fclose(presetFp);
+ return;
+ }
+ //fclose(presetFp);
+ if (popenFlag)
+ pclose(presetFp);
+ else
+ fclose(presetFp);
+ }
+
+void EffectRack::startDrag(int idx)
+ {
+ FILE* tmp = tmpfile();
+ if (tmp == 0) {
+ fprintf(stderr, "EffectRack::startDrag fopen failed: %s\n",
+ strerror(errno));
+ return;
+ }
+ Xml xml(tmp);
+ Pipeline* pipe = track->efxPipe();
+ if (pipe) {
+ if ((*pipe)[idx] != NULL) {
+ xml.header();
+ xml.tag(0, "muse version=\"1.0\"");
+ (*pipe)[idx]->writeConfiguration(1, xml);
+ xml.tag(0, "/muse");
+ }
+ else {
+ //printf("no plugin!\n");
+ return;
+ }
+ }
+ else {
+ //printf("no pipe!\n");
+ return;
+ }
+
+ QString xmlconf;
+ xml.dump(xmlconf);
+
+ QByteArray data(xmlconf.toLatin1().constData());
+ QMimeData* md = new QMimeData();
+
+ md->setData("text/x-muse-plugin", data);
+
+ QDrag* drag = new QDrag(this);
+ drag->setMimeData(md);
+
+ drag->exec(Qt::CopyAction);
+ }
+
+Qt::DropActions EffectRack::supportedDropActions () const
+ {
+ return Qt::CopyAction;
+ }
+
+QStringList EffectRack::mimeTypes() const
+ {
+ return QStringList("text/x-muse-plugin");
+ }
+
+void EffectRack::dropEvent(QDropEvent *event)
+ {
+ QString text;
+ QListWidgetItem *i = itemAt( event->pos() );
+ if (!i)
+ return;
+ int idx = row(i);
+
+ Pipeline* pipe = track->efxPipe();
+ if (pipe)
+ {
+ if ((*pipe)[idx] != NULL) {
+ QWidget *sw = event->source();
+ if(sw)
+ {
+ if(strcmp(sw->metaObject()->className(), "EffectRack") == 0)
+ {
+ EffectRack *ser = (EffectRack*)sw;
+ Pipeline* spipe = ser->getTrack()->efxPipe();
+ if(!spipe)
+ return;
+
+ QListWidgetItem *i = ser->itemAt(ser->getDragPos());
+ int idx0 = ser->row(i);
+ if (!(*spipe)[idx0] ||
+ (idx == idx0 && (ser == this || ser->getTrack()->name() == track->name())))
+ return;
+ }
+ }
+ if(QMessageBox::question(this, tr("Replace effect"),tr("Do you really want to replace the effect %1?").arg(pipe->name(idx)),
+ QMessageBox::Yes | QMessageBox::No, QMessageBox::Yes) == QMessageBox::Yes)
+ {
+ audio->msgAddPlugin(track, idx, 0);
+ song->update(SC_RACK);
+ }
+ else {
+ return;
+ }
+ }
+
+ if(event->mimeData()->hasFormat("text/x-muse-plugin"))
+ {
+ QString outxml;
+ Xml xml(event->mimeData()->data("text/x-muse-plugin").data());
+ initPlugin(xml, idx);
+ }
+ else
+ if (event->mimeData()->hasUrls())
+ {
+ // Multiple urls not supported here. Grab the first one.
+ text = event->mimeData()->urls()[0].path();
+
+ if (text.endsWith(".pre", Qt::CaseInsensitive) ||
+ text.endsWith(".pre.gz", Qt::CaseInsensitive) ||
+ text.endsWith(".pre.bz2", Qt::CaseInsensitive))
+ {
+ //bool popenFlag = false;
+ bool popenFlag;
+ FILE* fp = fileOpen(this, text, ".pre", "r", popenFlag, false, false);
+ if (fp)
+ {
+ Xml xml(fp);
+ initPlugin(xml, idx);
+
+ // Added by T356.
+ if (popenFlag)
+ pclose(fp);
+ else
+ fclose(fp);
+ }
+ }
+ }
+ }
+ }
+
+void EffectRack::dragEnterEvent(QDragEnterEvent *event)
+ {
+ ///event->accept(Q3TextDrag::canDecode(event));
+ event->acceptProposedAction(); // TODO CHECK Tim.
+ }
+
+void EffectRack::mousePressEvent(QMouseEvent *event)
+ {
+ if(event->button() & Qt::LeftButton) {
+ dragPos = event->pos();
+ }
+ else if(event->button() & Qt::RightButton) {
+ menuRequested(itemAt(event->pos()));
+ return;
+ }
+ else if(event->button() & Qt::MidButton) {
+ int idx = row(itemAt(event->pos()));
+ bool flag = !track->efxPipe()->isOn(idx);
+ track->efxPipe()->setOn(idx, flag);
+ updateContents();
+ }
+
+ QListWidget::mousePressEvent(event);
+ }
+
+void EffectRack::mouseMoveEvent(QMouseEvent *event)
+ {
+ if (event->buttons() & Qt::LeftButton) {
+ Pipeline* pipe = track->efxPipe();
+ if(!pipe)
+ return;
+
+ QListWidgetItem *i = itemAt(dragPos);
+ int idx0 = row(i);
+ if (!(*pipe)[idx0])
+ return;
+
+ int distance = (dragPos-event->pos()).manhattanLength();
+ if (distance > QApplication::startDragDistance()) {
+ QListWidgetItem *i = itemAt( event->pos() );
+ int idx = row(i);
+ startDrag(idx);
+ }
+ }
+ QListWidget::mouseMoveEvent(event);
+ }
+
+
+void EffectRack::initPlugin(Xml xml, int idx)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ QString tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "plugin") {
+ PluginI* plugi = new PluginI();
+ if (plugi->readConfiguration(xml, false)) {
+ printf("cannot instantiate plugin\n");
+ delete plugi;
+ }
+ else {
+ //printf("instantiated!\n");
+ audio->msgAddPlugin(track, idx, plugi);
+ song->update(SC_RACK);
+ return;
+ }
+ }
+ else if (tag =="muse")
+ break;
+ else
+ xml.unknown("EffectRack");
+ break;
+ case Xml::Attribut:
+ break;
+ case Xml::TagEnd:
+ if (tag == "muse")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/mixer/rack.h b/attic/muse2-oom/muse2/muse/mixer/rack.h
new file mode 100644
index 00000000..33c846bd
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/rack.h
@@ -0,0 +1,63 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: rack.h,v 1.5.2.3 2006/09/24 19:32:31 terminator356 Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __RACK_H__
+#define __RACK_H__
+
+#include <QListWidget>
+
+class QDragEnterEvent;
+class QDragLeaveEvent;
+class QDropEvent;
+class QMouseEvent;
+
+class AudioTrack;
+class Xml;
+
+//---------------------------------------------------------
+// EffectRack
+//---------------------------------------------------------
+
+class EffectRack : public QListWidget {
+ AudioTrack* track;
+ Q_OBJECT
+
+ virtual QSize minimumSizeHint() const;
+ virtual QSize sizeHint() const;
+
+ void startDrag(int idx);
+ void initPlugin(Xml xml, int idx);
+ QPoint dragPos;
+ void savePreset(int idx);
+ void choosePlugin(QListWidgetItem* item, bool replace = false);
+
+ private slots:
+ void menuRequested(QListWidgetItem*);
+ void doubleClicked(QListWidgetItem*);
+ void songChanged(int);
+ void updateContents();
+
+ protected:
+ void dropEvent(QDropEvent *event);
+ void dragEnterEvent(QDragEnterEvent *event);
+ void mousePressEvent(QMouseEvent *event);
+ void mouseMoveEvent(QMouseEvent *event);
+
+ QStringList mimeTypes() const;
+ Qt::DropActions supportedDropActions () const;
+
+ public:
+ EffectRack(QWidget*, AudioTrack* t);
+ ~EffectRack();
+
+ AudioTrack* getTrack() { return track; }
+ QPoint getDragPos() { return dragPos; }
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/mixer/routedialog.cpp b/attic/muse2-oom/muse2/muse/mixer/routedialog.cpp
new file mode 100644
index 00000000..29ff8946
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/routedialog.cpp
@@ -0,0 +1,186 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: routedialog.cpp,v 1.5.2.2 2007/01/04 00:35:17 terminator356 Exp $
+//
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QCloseEvent>
+#include <QDialog>
+#include <QListWidgetItem>
+#include <QTreeWidgetItem>
+
+#include "routedialog.h"
+#include "track.h"
+#include "song.h"
+#include "audio.h"
+#include "driver/jackaudio.h"
+
+//---------------------------------------------------------
+// RouteDialog
+//---------------------------------------------------------
+
+RouteDialog::RouteDialog(QWidget* parent)
+ : QDialog(parent)
+ {
+ setupUi(this);
+ connect(routeList, SIGNAL(itemSelectionChanged()), SLOT(routeSelectionChanged()));
+ connect(newSrcList, SIGNAL(itemSelectionChanged()), SLOT(srcSelectionChanged()));
+ connect(newDstList, SIGNAL(itemSelectionChanged()), SLOT(dstSelectionChanged()));
+ connect(removeButton, SIGNAL(clicked()), SLOT(removeRoute()));
+ connect(connectButton, SIGNAL(clicked()), SLOT(addRoute()));
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+ routingChanged();
+ }
+
+//---------------------------------------------------------
+// routingChanged
+//---------------------------------------------------------
+
+void RouteDialog::routingChanged()
+ {
+ //---------------------------------------------------
+ // populate lists
+ //---------------------------------------------------
+
+ routeList->clear();
+ newSrcList->clear();
+ newDstList->clear();
+
+ TrackList* tl = song->tracks();
+ for (ciTrack i = tl->begin(); i != tl->end(); ++i) {
+ if ((*i)->isMidiTrack())
+ continue;
+ // p3.3.38
+ //WaveTrack* track = (WaveTrack*)(*i);
+ AudioTrack* track = (AudioTrack*)(*i);
+ if (track->type() == Track::AUDIO_INPUT) {
+ for (int channel = 0; channel < track->channels(); ++channel)
+ newDstList->addItem(Route(track, channel).name());
+ const RouteList* rl = track->inRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r) {
+ //Route dst(track->name(), true, r->channel);
+ Route dst(track->name(), true, r->channel, Route::TRACK_ROUTE);
+ new QTreeWidgetItem(routeList, QStringList() << r->name() << dst.name());
+ }
+ }
+ else if (track->type() != Track::AUDIO_AUX)
+ newDstList->addItem(Route(track, -1).name());
+ if (track->type() == Track::AUDIO_OUTPUT) {
+ for (int channel = 0; channel < track->channels(); ++channel) {
+ Route r(track, channel);
+ newSrcList->addItem(r.name());
+ }
+ }
+ else
+ newSrcList->addItem(Route(track, -1).name());
+
+ const RouteList* rl = track->outRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r) {
+ QString src(track->name());
+ if (track->type() == Track::AUDIO_OUTPUT) {
+ Route s(src, false, r->channel);
+ src = s.name();
+ }
+ new QTreeWidgetItem(routeList, QStringList() << src << r->name());
+ }
+ }
+ if (!checkAudioDevice()) return;
+ std::list<QString> sl = audioDevice->outputPorts();
+ for (std::list<QString>::iterator i = sl.begin(); i != sl.end(); ++i)
+ newSrcList->addItem(*i);
+ sl = audioDevice->inputPorts();
+ for (std::list<QString>::iterator i = sl.begin(); i != sl.end(); ++i)
+ newDstList->addItem(*i);
+ routeSelectionChanged(); // init remove button
+ srcSelectionChanged(); // init select button
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void RouteDialog::songChanged(int v)
+ {
+ if (v & (SC_TRACK_INSERTED | SC_TRACK_REMOVED | SC_ROUTE)) {
+ routingChanged();
+ }
+ }
+
+//---------------------------------------------------------
+// routeSelectionChanged
+//---------------------------------------------------------
+
+void RouteDialog::routeSelectionChanged()
+ {
+ QTreeWidgetItem* item = routeList->currentItem();
+ removeButton->setEnabled(item != 0);
+ }
+
+//---------------------------------------------------------
+// removeRoute
+//---------------------------------------------------------
+
+void RouteDialog::removeRoute()
+ {
+ QTreeWidgetItem* item = routeList->currentItem();
+ if (item == 0)
+ return;
+ audio->msgRemoveRoute(Route(item->text(0), false, -1), Route(item->text(1), true, -1));
+ audio->msgUpdateSoloStates();
+ song->update(SC_SOLO);
+ delete item;
+ }
+
+//---------------------------------------------------------
+// addRoute
+//---------------------------------------------------------
+
+void RouteDialog::addRoute()
+ {
+ QListWidgetItem* srcItem = newSrcList->currentItem();
+ QListWidgetItem* dstItem = newDstList->currentItem();
+ if (srcItem == 0 || dstItem == 0)
+ return;
+ audio->msgAddRoute(Route(srcItem->text(), false, -1), Route(dstItem->text(), true, -1));
+ audio->msgUpdateSoloStates();
+ song->update(SC_SOLO);
+ new QTreeWidgetItem(routeList, QStringList() << srcItem->text() << dstItem->text());
+ }
+
+//---------------------------------------------------------
+// srcSelectionChanged
+//---------------------------------------------------------
+
+void RouteDialog::srcSelectionChanged()
+ {
+ QListWidgetItem* srcItem = newSrcList->currentItem();
+ QListWidgetItem* dstItem = newDstList->currentItem();
+ connectButton->setEnabled((srcItem != 0)
+ && (dstItem != 0)
+ && checkRoute(srcItem->text(), dstItem->text()));
+ }
+
+//---------------------------------------------------------
+// dstSelectionChanged
+//---------------------------------------------------------
+
+void RouteDialog::dstSelectionChanged()
+ {
+ QListWidgetItem* dstItem = newDstList->currentItem();
+ QListWidgetItem* srcItem = newSrcList->currentItem();
+ connectButton->setEnabled((srcItem != 0)
+ && (dstItem != 0)
+ && checkRoute(srcItem->text(), dstItem->text()));
+ }
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void RouteDialog::closeEvent(QCloseEvent* e)
+ {
+ emit closed();
+ e->accept();
+ }
diff --git a/attic/muse2-oom/muse2/muse/mixer/routedialog.h b/attic/muse2-oom/muse2/muse/mixer/routedialog.h
new file mode 100644
index 00000000..39bbce2c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/routedialog.h
@@ -0,0 +1,44 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: routedialog.h,v 1.2 2004/01/31 17:31:49 wschweer Exp $
+//
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __ROUTEDIALOG_H__
+#define __ROUTEDIALOG_H__
+
+#include "ui_routedialogbase.h"
+
+class QCloseEvent;
+class QDialog;
+
+//---------------------------------------------------------
+// RouteDialog
+//---------------------------------------------------------
+
+class RouteDialog : public QDialog, public Ui::RouteDialogBase {
+ Q_OBJECT
+
+ virtual void closeEvent(QCloseEvent*);
+ void routingChanged();
+
+ private slots:
+ void routeSelectionChanged();
+ void removeRoute();
+ void addRoute();
+ void srcSelectionChanged();
+ void dstSelectionChanged();
+ void songChanged(int);
+
+ signals:
+ void closed();
+
+ public:
+ RouteDialog(QWidget* parent=0);
+ };
+
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/mixer/routedialogbase.ui b/attic/muse2-oom/muse2/muse/mixer/routedialogbase.ui
new file mode 100644
index 00000000..54a9f45c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/routedialogbase.ui
@@ -0,0 +1,174 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>RouteDialogBase</class>
+ <widget class="QDialog" name="RouteDialogBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>316</width>
+ <height>383</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Routing</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>4</number>
+ </property>
+ <property name="margin">
+ <number>4</number>
+ </property>
+ <item>
+ <widget class="QGroupBox" name="groupBox4">
+ <property name="title">
+ <string>Add Route</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>4</number>
+ </property>
+ <property name="margin">
+ <number>4</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QGroupBox" name="groupBox2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Source:</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="margin">
+ <number>2</number>
+ </property>
+ <item>
+ <widget class="QListWidget" name="newSrcList"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Destination:</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>0</number>
+ </property>
+ <property name="margin">
+ <number>2</number>
+ </property>
+ <item>
+ <widget class="QListWidget" name="newDstList"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QToolButton" name="connectButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>connect source to destination</string>
+ </property>
+ <property name="text">
+ <string>Connect</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox1">
+ <property name="title">
+ <string>Current Routes</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>4</number>
+ </property>
+ <property name="margin">
+ <number>4</number>
+ </property>
+ <item>
+ <widget class="QTreeWidget" name="routeList">
+ <column>
+ <property name="text">
+ <string>Source</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Destination</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="removeButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>remove selected route</string>
+ </property>
+ <property name="text">
+ <string>Remove</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/mixer/strip.cpp b/attic/muse2-oom/muse2/muse/mixer/strip.cpp
new file mode 100644
index 00000000..58e6b7ec
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/strip.cpp
@@ -0,0 +1,298 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: strip.cpp,v 1.6.2.5 2009/11/14 03:37:48 terminator356 Exp $
+//
+// (C) Copyright 2000-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QToolButton>
+#include <QLabel>
+#include <QLayout>
+#include <QPalette>
+#include <QColor>
+#include <QVBoxLayout>
+#include <QFrame>
+
+#include "globals.h"
+#include "gconfig.h"
+#include "app.h"
+#include "audio.h"
+#include "song.h"
+#include "track.h"
+#include "strip.h"
+#include "meter.h"
+#include "utils.h"
+
+//---------------------------------------------------------
+// setRecordFlag
+//---------------------------------------------------------
+
+void Strip::setRecordFlag(bool flag)
+ {
+ if (record) {
+ record->blockSignals(true);
+ record->setChecked(flag);
+ record->blockSignals(false);
+ }
+ }
+
+//---------------------------------------------------------
+// resetPeaks
+//---------------------------------------------------------
+
+void Strip::resetPeaks()
+ {
+ track->resetPeaks();
+ }
+
+//---------------------------------------------------------
+// recordToggled
+//---------------------------------------------------------
+
+void Strip::recordToggled(bool val)
+ {
+ if (track->type() == Track::AUDIO_OUTPUT) {
+ if (val && track->recordFlag() == false) {
+ muse->bounceToFile((AudioOutput*)track);
+ }
+ audio->msgSetRecord((AudioOutput*)track, val);
+ if (!((AudioOutput*)track)->recFile())
+ record->setChecked(false);
+ return;
+ }
+ song->setRecordFlag(track, val);
+ }
+//---------------------------------------------------------
+// heartBeat
+//---------------------------------------------------------
+
+void Strip::heartBeat()
+ {
+ }
+
+//---------------------------------------------------------
+// setLabelFont
+//---------------------------------------------------------
+// Added by Tim. p3.3.9
+
+void Strip::setLabelFont()
+{
+ return;
+ // Use the new font #6 I created just for these labels (so far).
+ // Set the label's font.
+ label->setFont(config.fonts[6]);
+ // Dealing with a horizontally constrained label. Ignore vertical. Use a minimum readable point size.
+ autoAdjustFontSize(label, label->text(), false, true, config.fonts[6].pointSize(), 5);
+}
+
+//---------------------------------------------------------
+// setLabelText
+//---------------------------------------------------------
+
+void Strip::setLabelText()
+{
+ // QColor c;
+ // switch(track->type()) {
+ // case Track::AUDIO_OUTPUT:
+ // c = Qt::green;
+ // break;
+ // case Track::AUDIO_GROUP:
+ // c = Qt::yellow;
+ // break;
+ // case Track::AUDIO_AUX:
+ // c = QColor(120, 255, 255); // Light blue
+ // break;
+ // case Track::WAVE:
+ // c = Qt::magenta;
+ // break;
+ // case Track::AUDIO_INPUT:
+ // c = Qt::red;
+ // break;
+ // case Track::AUDIO_SOFTSYNTH:
+ // c = QColor(255, 130, 0); // Med orange
+ // break;
+ // case Track::MIDI:
+ // case Track::DRUM:
+ // {
+ // c = QColor(0, 160, 255); // Med blue
+ // }
+ // break;
+ // default:
+ // return;
+ // }
+
+ QString trackName = track->name();
+ if(track->name().length() > 8)
+ trackName = track->name().mid(0,7) + "..";
+
+ label->setText(trackName);
+ label->setToolTip(track->name());
+ //QPalette palette;
+ //palette.setColor(label->backgroundRole(), c);
+ //label->setPalette(palette);
+ //label->setStyleSheet(QString("background-color: ") + c.name());
+}
+
+//---------------------------------------------------------
+// muteToggled
+//---------------------------------------------------------
+
+void Strip::muteToggled(bool val)
+ {
+ track->setMute(val);
+ song->update(SC_MUTE);
+ }
+
+//---------------------------------------------------------
+// soloToggled
+//---------------------------------------------------------
+
+void Strip::soloToggled(bool val)
+ {
+ audio->msgSetSolo(track, val);
+ song->update(SC_SOLO);
+ }
+
+//---------------------------------------------------------
+// Strip
+// create mixer strip
+//---------------------------------------------------------
+
+Strip::Strip(QWidget* parent, Track* t)
+ : QFrame(parent)
+ {
+ _curGridRow = 0;
+ setAttribute(Qt::WA_DeleteOnClose);
+ iR = 0;
+ oR = 0;
+
+ setBackgroundRole(QPalette::Mid);
+ setFrameStyle(Panel | Raised);
+ setLineWidth(2);
+
+ // NOTE: Workaround for freakin' improper disabled button text colour (at least with Oxygen colours).
+ // Just set the parent palette.
+ QPalette pal(palette());
+ pal.setColor(QPalette::Disabled, QPalette::ButtonText,
+ pal.color(QPalette::Disabled, QPalette::WindowText));
+ setPalette(pal);
+
+ useSoloIconSet2 = false;
+
+ track = t;
+ meter[0] = 0;
+ meter[1] = 0;
+ //setFixedWidth(STRIP_WIDTH);
+ //setMinimumWidth(STRIP_WIDTH); // TESTING Tim.
+ //setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Expanding)); // TESTING Tim.
+ setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding)); // TESTING Tim.
+
+ rackgrid = new QVBoxLayout();
+ rackgrid->setContentsMargins(0, 0, 0, 0);
+ rackgrid->setSpacing(0);
+
+ grid = new QGridLayout();
+ grid->setContentsMargins(0, 0, 0, 0);
+ grid->setSpacing(0);
+ setLayout(grid);
+
+ //---------------------------------------------
+ // label
+ //---------------------------------------------
+
+ //label = new QLabel(this);
+ // NOTE: This was required, otherwise the strip labels have no colour in the mixer only - track info OK !
+ // Not sure why...
+ label = new QLabel(this);
+ switch(track->type()) {
+ case Track::AUDIO_OUTPUT:
+ label->setObjectName("MixerAudioOutLabel");
+ break;
+ case Track::AUDIO_GROUP:
+ label->setObjectName("MixerAudioGroupLabel");
+ break;
+ case Track::AUDIO_AUX:
+ label->setObjectName("MixerAuxLabel");
+ break;
+ case Track::WAVE:
+ label->setObjectName("MixerWaveLabel");
+ break;
+ case Track::AUDIO_INPUT:
+ label->setObjectName("MixerAudioInLabel");
+ break;
+ case Track::AUDIO_SOFTSYNTH:
+ label->setObjectName("MixerSynthLabel");
+ break;
+ case Track::MIDI:
+ case Track::DRUM:
+ {
+ label->setObjectName("MidiTrackLabel");
+ }
+ break;
+ }
+
+ // Moved by Tim. p3.3.9
+ //setLabelText();
+ //label->setFont(config.fonts[1]);
+
+ //printf("Strip::Strip w:%d frw:%d layoutmarg:%d lx:%d ly:%d lw:%d lh:%d\n", STRIP_WIDTH, frameWidth(), layout->margin(), label->x(), label->y(), label->width(), label->height());
+
+ // Tested: The label's width is 100. It does not become STRIP_WIDTH - 2*layout->margin
+ // until the mixer is shown in MusE::showMixer.
+ // Therefore 'fake' set the size of the label now.
+ // Added by Tim. p3.3.9
+ //label->setGeometry(label->x(), label->y(), STRIP_WIDTH - 2*frameWidth() - 2*layout->margin(), label->height());
+ label->setGeometry(label->x(), label->y(), STRIP_WIDTH - 2*grid->margin(), label->height());
+
+ label->setTextFormat(Qt::PlainText);
+
+ // Unfortunately for the mixer labels, QLabel doesn't support the BreakAnywhere flag.
+ // Changed by Tim. p3.3.9
+ //label->setAlignment(AlignCenter);
+ //label->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed));
+ // MusE-2 Tested: TextWrapAnywhere actually works, but in fact it takes precedence
+ // over word wrap, so I found it is not really desirable. Maybe with a user setting...
+ //label->setAlignment(Qt::AlignCenter | Qt::TextWordWrap | Qt::TextWrapAnywhere);
+ // changed by Orcan: We can't use Qt::TextWordWrap in alignment in Qt4.
+ label->setAlignment(Qt::AlignCenter);
+ label->setWordWrap(false);
+ label->setAutoFillBackground(true);
+ label->setLineWidth(2);
+ label->setFrameStyle(Sunken | StyledPanel);
+
+ //label->setSizePolicy(QSizePolicy(QSizePolicy::Preferred, QSizePolicy::Minimum));
+ label->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum));
+
+ // Added by Tim. p3.3.9
+ setLabelText();
+ //setLabelFont();
+
+ //Add you top image here
+ QLabel* toprack = new QLabel();
+ toprack->setPixmap(QPixmap(":/images/top_rack.png"));
+ grid->addWidget(toprack, _curGridRow++, 0, 1, 2);
+ //layout->addWidget(label);
+ grid->addWidget(label, _curGridRow++, 0, 1, 2);
+ //rackgrid->addLayout(grid);
+ //rackgrid->addWidget(toprack);
+ }
+
+//---------------------------------------------------------
+// Strip
+//---------------------------------------------------------
+
+Strip::~Strip()
+ {
+ }
+
+//---------------------------------------------------------
+// setAutomationType
+//---------------------------------------------------------
+
+void Strip::setAutomationType(int t,int)
+ {
+ track->setAutomationType(AutomationType(t));
+ song->update(SC_AUTOMATION);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/mixer/strip.h b/attic/muse2-oom/muse2/muse/mixer/strip.h
new file mode 100644
index 00000000..ee6a0f9d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mixer/strip.h
@@ -0,0 +1,79 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: strip.h,v 1.3.2.2 2009/11/14 03:37:48 terminator356 Exp $
+//
+// (C) Copyright 2000-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __STRIP_H__
+#define __STRIP_H__
+
+#include <QFrame>
+#include <QIcon>
+#include <QVBoxLayout>
+#include <QGridLayout>
+#include <QLabel>
+
+#include "globaldefs.h"
+//#include "route.h"
+
+class Track;
+class QLabel;
+class QVBoxLayout;
+class Meter;
+class QToolButton;
+class QGridLayout;
+class ComboBox;
+
+static const int STRIP_WIDTH = 65;
+
+//---------------------------------------------------------
+// Strip
+//---------------------------------------------------------
+
+class Strip : public QFrame {
+ Q_OBJECT
+
+ protected:
+ Track* track;
+ QLabel* label;
+ //QVBoxLayout* layout;
+ QGridLayout* grid;
+ QVBoxLayout* rackgrid;
+ int _curGridRow;
+ Meter* meter[MAX_CHANNELS];
+ bool useSoloIconSet2;
+
+ QToolButton* record;
+ QToolButton* solo;
+ QToolButton* mute;
+ QToolButton* iR; // Input routing button
+ QToolButton* oR; // Output routing button
+ QGridLayout* sliderGrid;
+ ComboBox* autoType;
+ void setLabelText();
+
+ private slots:
+ void recordToggled(bool);
+ void soloToggled(bool);
+ void muteToggled(bool);
+
+ protected slots:
+ virtual void heartBeat();
+ void setAutomationType(int t,int);
+
+ public slots:
+ void resetPeaks();
+ virtual void songChanged(int) = 0;
+
+ public:
+ Strip(QWidget* parent, Track* t);
+ ~Strip();
+ void setRecordFlag(bool flag);
+ Track* getTrack() const { return track; }
+ void setLabelFont();
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/mpevent.cpp b/attic/muse2-oom/muse2/muse/mpevent.cpp
new file mode 100644
index 00000000..9988c12b
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mpevent.cpp
@@ -0,0 +1,160 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mpevent.cpp,v 1.6.2.2 2009/11/25 09:09:43 terminator356 Exp $
+//
+// (C) Copyright 2002-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "mpevent.h"
+
+#include "helper.h"
+#include "event.h"
+#include "midictrl.h"
+#include "midiport.h"
+#include "muse/midi.h"
+
+//---------------------------------------------------------
+// MEvent
+//---------------------------------------------------------
+
+MEvent::MEvent(unsigned t, int port, int tpe, const unsigned char* data, int len)
+ {
+ _time = t;
+ _port = port;
+ edata.setData(data, len);
+ _type = tpe;
+ _loopNum = 0;
+ }
+
+MEvent::MEvent(unsigned tick, int port, int channel, const Event& e)
+ {
+ setChannel(channel);
+ setTime(tick);
+ setPort(port);
+ setLoopNum(0);
+ switch(e.type()) {
+ case Note:
+ setType(ME_NOTEON);
+ setA(e.dataA());
+ setB(e.dataB());
+ break;
+ case Controller:
+ setType(ME_CONTROLLER);
+ setA(e.dataA()); // controller number
+ setB(e.dataB()); // controller value
+ break;
+ case PAfter:
+ setType(ME_POLYAFTER);
+ setA(e.dataA());
+ setB(e.dataB());
+ break;
+ case CAfter:
+ setType(ME_AFTERTOUCH);
+ setA(e.dataA());
+ setB(0);
+ break;
+ case Sysex:
+ setType(ME_SYSEX);
+ setData(e.eventData());
+ break;
+ default:
+ printf("MEvent::MEvent(): event type %d not implemented\n",
+ type());
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// dump
+//---------------------------------------------------------
+
+void MEvent::dump() const
+ {
+ printf("time:%d port:%d chan:%d ", _time, _port, _channel+1);
+ if (_type == 0x90) { // NoteOn
+ QString s = pitch2string(_a);
+ printf("NoteOn %s(0x%x) %d\n", s.toLatin1().constData(), _a, _b);
+ }
+ else if (_type == 0xf0) {
+ printf("SysEx len %d 0x%0x ...\n", len(), data()[0]);
+ }
+ else
+ printf("type:0x%02x a=%d b=%d\n", _type, _a, _b);
+ }
+
+//---------------------------------------------------------
+// operator <
+//---------------------------------------------------------
+
+bool MEvent::operator<(const MEvent& e) const
+ {
+ if (time() != e.time())
+ return time() < e.time();
+ if (port() != e.port())
+ return port() < e.port();
+
+ // play note off events first to prevent overlapping
+ // notes
+
+ if (channel() == e.channel())
+ return type() == ME_NOTEOFF
+ || (type() == ME_NOTEON && dataB() == 0);
+
+ int map[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15 };
+ return map[channel()] < map[e.channel()];
+ }
+
+
+//---------------------------------------------------------
+// put
+// return true on fifo overflow
+//---------------------------------------------------------
+
+bool MidiFifo::put(const MidiPlayEvent& event)
+ {
+ if (size < MIDI_FIFO_SIZE) {
+ fifo[wIndex] = event;
+ wIndex = (wIndex + 1) % MIDI_FIFO_SIZE;
+ // q_atomic_increment(&size);
+ ++size;
+ return false;
+ }
+ return true;
+ }
+
+//---------------------------------------------------------
+// get
+//---------------------------------------------------------
+
+MidiPlayEvent MidiFifo::get()
+ {
+ MidiPlayEvent event(fifo[rIndex]);
+ rIndex = (rIndex + 1) % MIDI_FIFO_SIZE;
+ // q_atomic_decrement(&size);
+ --size;
+ return event;
+ }
+
+//---------------------------------------------------------
+// peek
+//---------------------------------------------------------
+
+const MidiPlayEvent& MidiFifo::peek(int n)
+ {
+ int idx = (rIndex + n) % MIDI_FIFO_SIZE;
+ return fifo[idx];
+ }
+
+//---------------------------------------------------------
+// remove
+//---------------------------------------------------------
+
+void MidiFifo::remove()
+ {
+ rIndex = (rIndex + 1) % MIDI_FIFO_SIZE;
+ // q_atomic_decrement(&size);
+ --size;
+ }
+
+
diff --git a/attic/muse2-oom/muse2/muse/mpevent.h b/attic/muse2-oom/muse2/muse/mpevent.h
new file mode 100644
index 00000000..6df7b0c0
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mpevent.h
@@ -0,0 +1,183 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mpevent.h,v 1.8.2.5 2009/11/25 09:09:43 terminator356 Exp $
+//
+// (C) Copyright 1999-2002 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MPEVENT_H__
+#define __MPEVENT_H__
+
+#include <set>
+#include <list>
+#include "evdata.h"
+#include "memory.h"
+
+#define MIDI_FIFO_SIZE 512
+
+class Event;
+class EvData;
+
+//---------------------------------------------------------
+// MEvent
+// baseclass for MidiPlayEvent and MidiRecordEvent
+//---------------------------------------------------------
+
+//---------------------------------------------------------
+// MEvent
+//---------------------------------------------------------
+
+class MEvent {
+ unsigned _time;
+ EvData edata;
+ unsigned char _port, _channel, _type;
+ int _a, _b;
+ int _loopNum; // The loop count when the note was recorded.
+
+ public:
+ MEvent() { _loopNum = 0; }
+ MEvent(unsigned tm, int p, int c, int t, int a, int b)
+ : _time(tm), _port(p), _channel(c & 0xf), _type(t), _a(a), _b(b) { _loopNum = 0; }
+ MEvent(unsigned t, int p, int type, const unsigned char* data, int len);
+ MEvent(unsigned t, int p, int tpe, EvData d) : _time(t), edata(d), _port(p), _type(tpe) { _loopNum = 0; }
+ MEvent(unsigned t, int port, int channel, const Event& e);
+
+ ~MEvent() {}
+
+ MEvent& operator=(const MEvent& ed) {
+ _time = ed._time;
+ edata = ed.edata;
+ _port = ed._port;
+ _channel = ed._channel;
+ _type = ed._type;
+ _a = ed._a;
+ _b = ed._b;
+ _loopNum = ed._loopNum;
+ return *this;
+ }
+
+ int port() const { return _port; }
+ int channel() const { return _channel; }
+ int type() const { return _type; }
+ int dataA() const { return _a; }
+ int dataB() const { return _b; }
+ unsigned time() const { return _time; }
+ int loopNum() const { return _loopNum; }
+
+ void setPort(int val) { _port = val; }
+ void setChannel(int val) { _channel = val; }
+ void setType(int val) { _type = val; }
+ void setA(int val) { _a = val; }
+ void setB(int val) { _b = val; }
+ void setTime(unsigned val) { _time = val; }
+ void setLoopNum(int n) { _loopNum = n; }
+
+ const EvData& eventData() const { return edata; }
+ unsigned char* data() const { return edata.data; }
+ int len() const { return edata.dataLen; }
+ void setData(const EvData& e) { edata = e; }
+ void setData(const unsigned char* p, int len) { edata.setData(p, len); }
+ void dump() const;
+ bool isNote() const { return _type == 0x90; }
+ bool isNoteOff() const { return (_type == 0x80)||(_type == 0x90 && _b == 0); }
+ bool operator<(const MEvent&) const;
+ };
+
+//---------------------------------------------------------
+// MidiRecordEvent
+// allocated and deleted in midiseq thread context
+//---------------------------------------------------------
+
+class MidiPlayEvent;
+
+class MidiRecordEvent : public MEvent {
+ public:
+ MidiRecordEvent() : MEvent() {}
+ MidiRecordEvent(const MEvent& e) : MEvent(e) {}
+ MidiRecordEvent(unsigned tm, int p, int c, int t, int a, int b)
+ : MEvent(tm, p, c, t, a, b) {}
+ MidiRecordEvent(unsigned t, int p, int tpe, const unsigned char* data, int len)
+ : MEvent(t, p, tpe, data, len) {}
+ MidiRecordEvent(unsigned t, int p, int type, EvData data)
+ : MEvent(t, p, type, data) {}
+ ~MidiRecordEvent() {}
+ };
+
+//---------------------------------------------------------
+// MidiPlayEvent
+// allocated and deleted in audio thread context
+//---------------------------------------------------------
+
+class MidiPlayEvent : public MEvent {
+ public:
+ MidiPlayEvent() : MEvent() {}
+ MidiPlayEvent(const MEvent& e) : MEvent(e) {}
+ MidiPlayEvent(unsigned tm, int p, int c, int t, int a, int b)
+ : MEvent(tm, p, c, t, a, b) {}
+ MidiPlayEvent(unsigned t, int p, int type, const unsigned char* data, int len)
+ : MEvent(t, p, type, data, len) {}
+ MidiPlayEvent(unsigned t, int p, int type, EvData data)
+ : MEvent(t, p, type, data) {}
+ MidiPlayEvent(unsigned t, int port, int channel, const Event& e)
+ : MEvent(t, port, channel, e) {}
+ ~MidiPlayEvent() {}
+ };
+
+//---------------------------------------------------------
+// MPEventList
+// memory allocation in audio thread domain
+//---------------------------------------------------------
+
+typedef std::multiset<MidiPlayEvent, std::less<MidiPlayEvent>, audioRTalloc<MidiPlayEvent> > MPEL;
+
+struct MPEventList : public MPEL {
+ void add(const MidiPlayEvent& ev) { MPEL::insert(ev); }
+ };
+
+typedef MPEventList::iterator iMPEvent;
+typedef MPEventList::const_iterator ciMPEvent;
+
+/*
+//---------------------------------------------------------
+// MREventList
+// memory allocation in midi thread domain
+//---------------------------------------------------------
+
+// Changed by Tim. p3.3.8
+
+// audioRTalloc? Surely this must have been a mistake?
+//typedef std::list<MidiRecordEvent, audioRTalloc<MidiRecordEvent> > MREL;
+typedef std::list<MidiRecordEvent, midiRTalloc<MidiRecordEvent> > MREL;
+
+struct MREventList : public MREL {
+ void add(const MidiRecordEvent& ev) { MREL::push_back(ev); }
+ };
+
+typedef MREventList::iterator iMREvent;
+typedef MREventList::const_iterator ciMREvent;
+*/
+
+//---------------------------------------------------------
+// MidiFifo
+//---------------------------------------------------------
+
+class MidiFifo {
+ MidiPlayEvent fifo[MIDI_FIFO_SIZE];
+ volatile int size;
+ int wIndex;
+ int rIndex;
+
+ public:
+ MidiFifo() { clear(); }
+ bool put(const MidiPlayEvent& event); // returns true on fifo overflow
+ MidiPlayEvent get();
+ const MidiPlayEvent& peek(int n = 0);
+ void remove();
+ bool isEmpty() const { return size == 0; }
+ void clear() { size = 0, wIndex = 0, rIndex = 0; }
+ int getSize() const { return size; }
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/mplugins/.cvsignore b/attic/muse2-oom/muse2/muse/mplugins/.cvsignore
new file mode 100644
index 00000000..66e962c6
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mplugins/.cvsignore
@@ -0,0 +1,2 @@
+mrconfigbase.h
+midifilter.h
diff --git a/attic/muse2-oom/muse2/muse/mplugins/CMakeLists.txt b/attic/muse2-oom/muse2/muse/mplugins/CMakeLists.txt
new file mode 100644
index 00000000..a6db14f6
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mplugins/CMakeLists.txt
@@ -0,0 +1,109 @@
+#=============================================================================
+# MusE
+# Linux Music Editor
+# $Id:$
+#
+# Copyright (C) 2002-2006 by Werner Schweer and others
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#=============================================================================
+
+##
+## Expand Qt macros in source files
+##
+if ( ENABLE_EXPERIMENTAL )
+ QT4_WRAP_UI ( mplugins_experimental_uis rhythmbase.ui)
+ set ( experimental_hdrs rhythm.h )
+ set ( experimental_srcs
+ rhythm.cpp
+ ${mplugins_experimental_uis}
+ )
+endif ( ENABLE_EXPERIMENTAL )
+QT4_WRAP_CPP ( mplugins_mocs
+ midifilterimpl.h
+ midiitransform.h
+ mittranspose.h
+ mrconfig.h
+ ${experimental_hdrs}
+ )
+
+##
+## UI files
+##
+file (GLOB mplugins_ui_files
+ midifilter.ui
+ mrconfigbase.ui
+ )
+QT4_WRAP_UI ( mplugins_uis ${mplugins_ui_files} )
+
+##
+## List of source files to compile
+##
+file (GLOB mplugins_source_files
+ midifilterimpl.cpp
+ midiitransform.cpp
+ mitplugin.cpp
+ mittranspose.cpp
+ mrconfig.cpp
+ random.cpp
+ )
+
+##
+## Define target
+##
+add_library ( mplugins SHARED
+ ${mplugins_source_files}
+ ${mplugins_mocs}
+ ${mplugins_uis}
+ ${experimental_srcs}
+ )
+
+##
+## Append to the list of translations
+##
+set (FILES_TO_TRANSLATE
+ ${FILES_TO_TRANSLATE}
+ ${mplugins_source_files}
+ ${mplugins_ui_files}
+ CACHE INTERNAL ""
+ )
+
+##
+## Compilation flags and target name
+##
+# - tell cmake to name target transform.so instead of
+# libtransform.so
+# - use precompiled header files
+#
+set_target_properties ( mplugins
+ # PROPERTIES PREFIX ""
+ PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h -fPIC"
+ OUTPUT_NAME muse_mplugins
+ )
+
+##
+## Linkage
+##
+target_link_libraries( mplugins
+ # midiplugin
+ ${QT_LIBRARIES}
+ widgets
+ )
+
+##
+## Install location
+##
+install(TARGETS mplugins
+ DESTINATION ${MusE_MODULES_DIR}
+ )
+
diff --git a/attic/muse2-oom/muse2/muse/mplugins/midifilter.ui b/attic/muse2-oom/muse2/muse/mplugins/midifilter.ui
new file mode 100644
index 00000000..529f893a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mplugins/midifilter.ui
@@ -0,0 +1,730 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MidiFilterConfigBase</class>
+ <widget class="QDialog" name="MidiFilterConfigBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>348</width>
+ <height>431</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Midi Input Filter</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QGroupBox" name="GroupBoxx">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Record Filter</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QCheckBox" name="rf1">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Note On</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="rf2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Poly Pressure</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="rf3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Controller</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="rf4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Program Change</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="rf5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>After Touch</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="rf6">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Pitch Bend</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="rf7">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Sysex</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QGroupBox" name="GroupBox2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Thru Filter</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QCheckBox" name="tf1">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Note On</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="tf2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Poly Pressure</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="tf3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Controller</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="tf4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Program Change</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="tf5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>After Touch</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="tf6">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Pitch Bend</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="tf7">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Sysex</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QGroupBox" name="GroupBox4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Controller Filter</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="CtrlComboBox" name="cb1" native="true"/>
+ </item>
+ <item>
+ <widget class="CtrlComboBox" name="cb2" native="true"/>
+ </item>
+ <item>
+ <widget class="CtrlComboBox" name="cb3" native="true"/>
+ </item>
+ <item>
+ <widget class="CtrlComboBox" name="cb4" native="true"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QGroupBox" name="ButtonGroup1">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Channel Filter</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>3</number>
+ </property>
+ <item row="3" column="1">
+ <widget class="QPushButton" name="cf14">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>14</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QPushButton" name="cf10">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>10</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QPushButton" name="cf6">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>6</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QPushButton" name="cf12">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>12</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QPushButton" name="cf4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>4</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QPushButton" name="cf2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>2</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QPushButton" name="cf9">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>9</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QPushButton" name="cf8">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>8</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QPushButton" name="cf3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>3</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QPushButton" name="cf13">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>13</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QPushButton" name="cf15">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>15</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="3">
+ <widget class="QPushButton" name="cf16">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>16</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QPushButton" name="cf7">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>7</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QPushButton" name="cf11">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>11</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QPushButton" name="cf5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>5</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QPushButton" name="cf1">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>30</width>
+ <height>32767</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>1</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <customwidgets>
+ <customwidget>
+ <class>CtrlComboBox</class>
+ <extends>QWidget</extends>
+ <header location="global">ctrlcombo.h</header>
+ </customwidget>
+ </customwidgets>
+ <tabstops>
+ <tabstop>rf1</tabstop>
+ <tabstop>rf2</tabstop>
+ <tabstop>rf3</tabstop>
+ <tabstop>rf4</tabstop>
+ <tabstop>rf5</tabstop>
+ <tabstop>rf6</tabstop>
+ <tabstop>rf7</tabstop>
+ <tabstop>tf1</tabstop>
+ <tabstop>tf2</tabstop>
+ <tabstop>tf3</tabstop>
+ <tabstop>tf4</tabstop>
+ <tabstop>tf5</tabstop>
+ <tabstop>tf6</tabstop>
+ <tabstop>tf7</tabstop>
+ <tabstop>cf1</tabstop>
+ <tabstop>cf2</tabstop>
+ <tabstop>cf3</tabstop>
+ <tabstop>cf4</tabstop>
+ <tabstop>cf5</tabstop>
+ <tabstop>cf6</tabstop>
+ <tabstop>cf7</tabstop>
+ <tabstop>cf8</tabstop>
+ <tabstop>cf9</tabstop>
+ <tabstop>cf10</tabstop>
+ <tabstop>cf11</tabstop>
+ <tabstop>cf12</tabstop>
+ <tabstop>cf13</tabstop>
+ <tabstop>cf14</tabstop>
+ <tabstop>cf15</tabstop>
+ <tabstop>cf16</tabstop>
+ </tabstops>
+ <includes>
+ <include location="local">ctrlcombo.h</include>
+ </includes>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/mplugins/midifilterimpl.cpp b/attic/muse2-oom/muse2/muse/mplugins/midifilterimpl.cpp
new file mode 100644
index 00000000..196ce97c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mplugins/midifilterimpl.cpp
@@ -0,0 +1,130 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midifilterimpl.cpp,v 1.1.1.1 2003/10/27 18:52:49 wschweer Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "midifilterimpl.h"
+#include "ctrlcombo.h"
+
+#include <QDialog>
+#include <QCloseEvent>
+
+//---------------------------------------------------------
+// setCtrl
+//---------------------------------------------------------
+
+void MidiFilterConfig::setCtrl1(int n)
+ {
+ midiFilterCtrl1 = n-1;
+ }
+void MidiFilterConfig::setCtrl2(int n)
+ {
+ midiFilterCtrl2 = n-1;
+ }
+void MidiFilterConfig::setCtrl3(int n)
+ {
+ midiFilterCtrl3 = n-1;
+ }
+void MidiFilterConfig::setCtrl4(int n)
+ {
+ midiFilterCtrl4 = n-1;
+ }
+
+
+//---------------------------------------------------------
+// MidiFilterConfig
+//---------------------------------------------------------
+
+MidiFilterConfig::MidiFilterConfig(QDialog* parent)
+ : QDialog(parent)
+ {
+ setupUi(this);
+ cb1->setCurrentIndex(midiFilterCtrl1);
+ cb2->setCurrentIndex(midiFilterCtrl2);
+ cb3->setCurrentIndex(midiFilterCtrl3);
+ cb4->setCurrentIndex(midiFilterCtrl4);
+
+ rf1->setChecked(midiRecordType & 1);
+ rf2->setChecked(midiRecordType & 2);
+ rf3->setChecked(midiRecordType & 4);
+ rf4->setChecked(midiRecordType & 8);
+ rf5->setChecked(midiRecordType & 16);
+ rf6->setChecked(midiRecordType & 32);
+ rf7->setChecked(midiRecordType & 64);
+ connect(rf1, SIGNAL(toggled(bool)), SLOT(recordChanged1(bool)));
+ connect(rf2, SIGNAL(toggled(bool)), SLOT(recordChanged2(bool)));
+ connect(rf3, SIGNAL(toggled(bool)), SLOT(recordChanged3(bool)));
+ connect(rf4, SIGNAL(toggled(bool)), SLOT(recordChanged4(bool)));
+ connect(rf5, SIGNAL(toggled(bool)), SLOT(recordChanged5(bool)));
+ connect(rf6, SIGNAL(toggled(bool)), SLOT(recordChanged6(bool)));
+ connect(rf7, SIGNAL(toggled(bool)), SLOT(recordChanged7(bool)));
+
+ tf1->setChecked(midiThruType & 1);
+ tf2->setChecked(midiThruType & 2);
+ tf3->setChecked(midiThruType & 4);
+ tf4->setChecked(midiThruType & 8);
+ tf5->setChecked(midiThruType & 16);
+ tf6->setChecked(midiThruType & 32);
+ tf7->setChecked(midiThruType & 64);
+ connect(tf1, SIGNAL(toggled(bool)), SLOT(thruChanged1(bool)));
+ connect(tf2, SIGNAL(toggled(bool)), SLOT(thruChanged2(bool)));
+ connect(tf3, SIGNAL(toggled(bool)), SLOT(thruChanged3(bool)));
+ connect(tf4, SIGNAL(toggled(bool)), SLOT(thruChanged4(bool)));
+ connect(tf5, SIGNAL(toggled(bool)), SLOT(thruChanged5(bool)));
+ connect(tf6, SIGNAL(toggled(bool)), SLOT(thruChanged6(bool)));
+ connect(tf7, SIGNAL(toggled(bool)), SLOT(thruChanged7(bool)));
+
+ cf1->setChecked(midiInputChannel & 1);
+ cf2->setChecked(midiInputChannel & 2);
+ cf3->setChecked(midiInputChannel & 4);
+ cf4->setChecked(midiInputChannel & 8);
+ cf5->setChecked(midiInputChannel & 0x10);
+ cf6->setChecked(midiInputChannel & 0x20);
+ cf7->setChecked(midiInputChannel & 0x40);
+ cf8->setChecked(midiInputChannel & 0x80);
+ cf9->setChecked(midiInputChannel & 0x100);
+ cf10->setChecked(midiInputChannel & 0x200);
+ cf11->setChecked(midiInputChannel & 0x400);
+ cf12->setChecked(midiInputChannel & 0x800);
+ cf13->setChecked(midiInputChannel & 0x1000);
+ cf14->setChecked(midiInputChannel & 0x2000);
+ cf15->setChecked(midiInputChannel & 0x4000);
+ cf16->setChecked(midiInputChannel & 0x8000);
+
+ connect(cb1, SIGNAL(activated(int)), SLOT(setCtrl1(int)));
+ connect(cb2, SIGNAL(activated(int)), SLOT(setCtrl2(int)));
+ connect(cb3, SIGNAL(activated(int)), SLOT(setCtrl3(int)));
+ connect(cb4, SIGNAL(activated(int)), SLOT(setCtrl4(int)));
+
+ connect(cf1, SIGNAL(toggled(bool)), SLOT(channelChanged1(bool)));
+ connect(cf2, SIGNAL(toggled(bool)), SLOT(channelChanged2(bool)));
+ connect(cf3, SIGNAL(toggled(bool)), SLOT(channelChanged3(bool)));
+ connect(cf4, SIGNAL(toggled(bool)), SLOT(channelChanged4(bool)));
+ connect(cf5, SIGNAL(toggled(bool)), SLOT(channelChanged5(bool)));
+ connect(cf6, SIGNAL(toggled(bool)), SLOT(channelChanged6(bool)));
+ connect(cf7, SIGNAL(toggled(bool)), SLOT(channelChanged7(bool)));
+ connect(cf8, SIGNAL(toggled(bool)), SLOT(channelChanged8(bool)));
+ connect(cf9, SIGNAL(toggled(bool)), SLOT(channelChanged9(bool)));
+ connect(cf10, SIGNAL(toggled(bool)), SLOT(channelChanged10(bool)));
+ connect(cf11, SIGNAL(toggled(bool)), SLOT(channelChanged11(bool)));
+ connect(cf12, SIGNAL(toggled(bool)), SLOT(channelChanged12(bool)));
+ connect(cf13, SIGNAL(toggled(bool)), SLOT(channelChanged13(bool)));
+ connect(cf14, SIGNAL(toggled(bool)), SLOT(channelChanged14(bool)));
+ connect(cf15, SIGNAL(toggled(bool)), SLOT(channelChanged15(bool)));
+ connect(cf16, SIGNAL(toggled(bool)), SLOT(channelChanged16(bool)));
+ }
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void MidiFilterConfig::closeEvent(QCloseEvent* ev)
+ {
+ emit hideWindow();
+ QWidget::closeEvent(ev);
+ }
+
+
diff --git a/attic/muse2-oom/muse2/muse/mplugins/midifilterimpl.h b/attic/muse2-oom/muse2/muse/mplugins/midifilterimpl.h
new file mode 100644
index 00000000..bbda7757
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mplugins/midifilterimpl.h
@@ -0,0 +1,92 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midifilterimpl.h,v 1.1.1.1 2003/10/27 18:52:40 wschweer Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MIDIFILTERIMP_H__
+#define __MIDIFILTERIMP_H__
+
+#include "globals.h"
+#include "ui_midifilter.h"
+
+class QCloseEvent;
+
+//---------------------------------------------------------
+// MidiFilterConfig
+//---------------------------------------------------------
+
+class MidiFilterConfig : public QDialog, public Ui::MidiFilterConfigBase {
+ Q_OBJECT
+
+ void rChanged(bool f, int val) {
+ if (f)
+ midiRecordType |= val;
+ else
+ midiRecordType &= ~val;
+ }
+ void tChanged(bool f, int val) {
+ if (f)
+ midiThruType |= val;
+ else
+ midiThruType &= ~val;
+ }
+ void chChanged(bool f, int val) {
+ if (f)
+ midiInputChannel |= val;
+ else
+ midiInputChannel &= ~val;
+ }
+ virtual void closeEvent(QCloseEvent*);
+
+ signals:
+ void hideWindow();
+
+ private slots:
+ void channelChanged1(bool f) { chChanged(f, 0x01); }
+ void channelChanged2(bool f) { chChanged(f, 0x02); }
+ void channelChanged3(bool f) { chChanged(f, 0x04); }
+ void channelChanged4(bool f) { chChanged(f, 0x08); }
+ void channelChanged5(bool f) { chChanged(f, 0x10); }
+ void channelChanged6(bool f) { chChanged(f, 0x20); }
+ void channelChanged7(bool f) { chChanged(f, 0x40); }
+ void channelChanged8(bool f) { chChanged(f, 0x80); }
+ void channelChanged9(bool f) { chChanged(f, 0x100); }
+ void channelChanged10(bool f) { chChanged(f, 0x200); }
+ void channelChanged11(bool f) { chChanged(f, 0x400); }
+ void channelChanged12(bool f) { chChanged(f, 0x800); }
+ void channelChanged13(bool f) { chChanged(f, 0x1000); }
+ void channelChanged14(bool f) { chChanged(f, 0x2000); }
+ void channelChanged15(bool f) { chChanged(f, 0x4000); }
+ void channelChanged16(bool f) { chChanged(f, 0x8000); }
+
+ void recordChanged1(bool f) { rChanged(f, 1); }
+ void recordChanged2(bool f) { rChanged(f, 2); }
+ void recordChanged3(bool f) { rChanged(f, 4); }
+ void recordChanged4(bool f) { rChanged(f, 8); }
+ void recordChanged5(bool f) { rChanged(f, 16); }
+ void recordChanged6(bool f) { rChanged(f, 32); }
+ void recordChanged7(bool f) { rChanged(f, 64); }
+
+ void thruChanged1(bool f) { tChanged(f, 1); }
+ void thruChanged2(bool f) { tChanged(f, 2); }
+ void thruChanged3(bool f) { tChanged(f, 4); }
+ void thruChanged4(bool f) { tChanged(f, 8); }
+ void thruChanged5(bool f) { tChanged(f, 16); }
+ void thruChanged6(bool f) { tChanged(f, 32); }
+ void thruChanged7(bool f) { tChanged(f, 64); }
+
+ void setCtrl1(int);
+ void setCtrl2(int);
+ void setCtrl3(int);
+ void setCtrl4(int);
+
+ public:
+ MidiFilterConfig(QDialog* parent=0);
+ };
+
+#endif
+
+
diff --git a/attic/muse2-oom/muse2/muse/mplugins/midiitransform.cpp b/attic/muse2-oom/muse2/muse/mplugins/midiitransform.cpp
new file mode 100644
index 00000000..6ab584d3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mplugins/midiitransform.cpp
@@ -0,0 +1,1722 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midiitransform.cpp,v 1.2.2.2 2009/05/24 21:43:44 terminator356 Exp $
+//
+// (C) Copyright 2001-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <list>
+#include <QCloseEvent>
+
+#include <QButtonGroup>
+#include <QDialog>
+#include <QListWidgetItem>
+
+#include "spinboxFP.h"
+#include "midi.h"
+#include "midictrl.h"
+#include "event.h"
+#include "mpevent.h"
+#include "midiitransform.h"
+#include "track.h"
+#include "song.h"
+#include "xml.h"
+#include "globals.h"
+#include "gconfig.h"
+//#include "comboQuant.h"
+//#include "pitchedit.h"
+#include "helper.h"
+
+#define MIDITRANSFORM_NOTE 0
+#define MIDITRANSFORM_POLY 1
+#define MIDITRANSFORM_CTRL 2
+#define MIDITRANSFORM_ATOUCH 3
+#define MIDITRANSFORM_PITCHBEND 4
+#define MIDITRANSFORM_NRPN 5
+#define MIDITRANSFORM_RPN 6
+
+static int selTypeTable[] = {
+ MIDITRANSFORM_NOTE, MIDITRANSFORM_POLY, MIDITRANSFORM_CTRL, MIDITRANSFORM_ATOUCH,
+ MIDITRANSFORM_PITCHBEND, MIDITRANSFORM_NRPN, MIDITRANSFORM_RPN
+ };
+
+static int procTypeTable[] = {
+ MIDITRANSFORM_POLY, MIDITRANSFORM_CTRL, MIDITRANSFORM_ATOUCH,
+ MIDITRANSFORM_PITCHBEND, MIDITRANSFORM_NRPN, MIDITRANSFORM_RPN
+ };
+
+static int procVal2Map[] = { 0, 1, 2, 3, 4, 5, 6, 7, 10, 11 };
+
+struct TDict {
+ TransformFunction id;
+ const QString text;
+ TDict(TransformFunction f, const QString& s) : id(f), text(s) {}
+ };
+
+static const TDict oplist[] = {
+ TDict(Transform, QString("Transform")),
+ TDict(Delete, QString("Filter"))
+ };
+
+//---------------------------------------------------------
+// MidiInputTransform
+//---------------------------------------------------------
+
+class MidiInputTransformation {
+ public:
+ QString name;
+ QString comment;
+
+ ValOp selEventOp;
+ int selType;
+
+ ValOp selVal1;
+ int selVal1a, selVal1b;
+ ValOp selVal2;
+ int selVal2a, selVal2b;
+ ValOp selPort;
+ int selPorta, selPortb;
+ ValOp selChannel;
+ int selChannela, selChannelb;
+
+ InputTransformProcEventOp procEvent;
+ int eventType;
+
+ TransformOperator procVal1;
+ int procVal1a, procVal1b;
+ TransformOperator procVal2;
+ int procVal2a, procVal2b;
+ TransformOperator procPort;
+ int procPorta, procPortb;
+ TransformOperator procChannel;
+ int procChannela, procChannelb;
+
+ TransformFunction funcOp;
+ int quantVal;
+
+ MidiInputTransformation(const QString& s) {
+ name = s;
+ selEventOp = All;
+ selType = MIDITRANSFORM_NOTE;
+ selVal1 = Ignore;
+ selVal1a = 0;
+ selVal1b = 0;
+ selVal2 = Ignore;
+ selVal2a = 0;
+ selVal2b = 0;
+ procEvent = KeepType;
+ eventType = MIDITRANSFORM_POLY;
+ procVal1 = Keep;
+ procVal1a = 0;
+ procVal1b = 0;
+ procVal2 = Keep;
+ procVal2a = 0;
+ procVal2b = 0;
+ funcOp = Transform;
+ quantVal = config.division;
+ selPort = Ignore;
+ selChannel = Ignore;
+ selChannela = 0;
+ selChannelb = 0;
+ procPort = Keep;
+ procChannel = Keep;
+ procPorta = 0;
+ procPortb = 0;
+ procChannela = 0;
+ procChannelb = 0;
+ }
+ void write(int level, Xml& xml) const;
+ int apply(MidiRecordEvent& ev) const;
+ bool typesMatch(MidiRecordEvent& e, int selType) const;
+ };
+
+typedef std::list<MidiInputTransformation*> MidiInputTransformationList;
+typedef std::list<MidiInputTransformation*>::iterator iMidiInputTransformation;
+typedef std::list<MidiInputTransformation*>::const_iterator ciMidiInputTransformation;
+
+// this is the list of defined transformations:
+static MidiInputTransformationList mtlist;
+
+// list of modules to apply:
+
+struct ITransModul {
+ bool valid;
+ MidiInputTransformation* transform;
+ };
+
+const int MIDI_INPUT_TRANSFORMATIONS = 4;
+static ITransModul modules[MIDI_INPUT_TRANSFORMATIONS];
+
+//---------------------------------------------------------
+// applyMidiInputTransformation
+// return false if event should be dropped
+// (filter)
+//---------------------------------------------------------
+
+bool applyMidiInputTransformation(MidiRecordEvent& event)
+ {
+ for (int i = 0; i < 4; ++i) {
+ if (modules[i].valid && modules[i].transform) {
+ int rv = modules[i].transform->apply(event);
+ if (rv == 1)
+ {
+ if(debugMsg)
+ printf("drop input event\n");
+ }
+ if (rv)
+ return rv != 1;
+ }
+ }
+ return true;
+ }
+
+//---------------------------------------------------------
+// filterValOp
+//---------------------------------------------------------
+
+static bool filterValOp(ValOp op, int val, int val1, int val2)
+ {
+ switch (op) {
+ case Ignore:
+ break;
+ case Equal:
+ if (val != val1)
+ return true;
+ break;
+ case Unequal:
+ if (val == val1)
+ return true;
+ break;
+ case Higher:
+ if (val <= val1)
+ return true;
+ break;
+ case Lower:
+ if (val >= val1)
+ return true;
+ break;
+ case Inside:
+ if ((val < val1) || (val >= val2))
+ return true;
+ break;
+ case Outside:
+ if ((val >= val1) && (val < val2))
+ return true;
+ break;
+ }
+ return false;
+ }
+
+//---------------------------------------------------------
+// apply
+// apply Select filter
+// return 0 - not applied
+// 1 - drop event
+// 2 - event changed
+//---------------------------------------------------------
+
+int MidiInputTransformation::apply(MidiRecordEvent& event) const
+ {
+ int t = event.type();
+
+ switch (selEventOp) {
+ case Equal:
+ switch(t) {
+ case ME_NOTEON:
+ case ME_NOTEOFF:
+ if (selType != MIDITRANSFORM_NOTE)
+ return 0;
+ break;
+ default:
+ if(!typesMatch(event, selType))
+ return 0;
+ break;
+ }
+ break;
+ case Unequal:
+ switch(event.type()) {
+ case ME_NOTEON:
+ case ME_NOTEOFF:
+ if (selType == MIDITRANSFORM_NOTE)
+ return 0;
+ break;
+ default:
+ if(typesMatch(event, selType))
+ return 0;
+ break;
+ }
+ break;
+ default:
+ break;
+ }
+ if (filterValOp(selVal1, event.dataA(), selVal1a, selVal1b))
+ return 0;
+ if (filterValOp(selVal2, event.dataB(), selVal2a, selVal2b))
+ return 0;
+ if (filterValOp(selPort, event.port(), selPorta, selPortb))
+ return 0;
+ if (filterValOp(selChannel, event.channel(), selChannela, selChannelb))
+ return 0;
+
+ if (funcOp == Delete)
+ return 1; // discard event
+
+ // transform event
+//printf("transform\n");
+ if (procEvent != KeepType)
+ {
+ switch(eventType)
+ {
+ case MIDITRANSFORM_POLY:
+ event.setType(ME_POLYAFTER);
+ break;
+ case MIDITRANSFORM_CTRL:
+ event.setType(ME_CONTROLLER);
+ break;
+ case MIDITRANSFORM_ATOUCH:
+ event.setType(ME_AFTERTOUCH);
+ break;
+ case MIDITRANSFORM_PITCHBEND:
+ {
+ event.setType(ME_PITCHBEND);
+ }
+ break;
+ case MIDITRANSFORM_NRPN:
+ {
+ event.setA(MidiController::NRPN);
+ event.setType(ME_CONTROLLER);
+ }
+ break;
+ case MIDITRANSFORM_RPN:
+ {
+ event.setA(MidiController::RPN);
+ event.setType(ME_CONTROLLER);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+ //---------------------------------------------------
+ // transform value A
+ //---------------------------------------------------
+
+ int val = event.dataA();
+ switch (procVal1) {
+ case Keep:
+ break;
+ case Plus:
+ val += procVal1a;
+ break;
+ case Minus:
+ val -= procVal1a;
+ break;
+ case Multiply:
+ val = int(val * (procVal1a/100.0) + .5);
+ break;
+ case Divide:
+ val = int(val / (procVal1a/100.0) + .5);
+ break;
+ case Fix:
+ val = procVal1a;
+ break;
+ case Value:
+ val = procVal2a;
+ break;
+ case Invert:
+ val = 127 - val;
+ break;
+ case ScaleMap:
+ printf("scale map not implemented\n");
+ break;
+ case Flip:
+ val = procVal1a - val;
+ break;
+ case Dynamic: // "crescendo"
+ printf("transform not implemented\n");
+ break;
+ case Random:
+ {
+ int range = procVal1b - procVal1a;
+ if (range > 0)
+ val = (rand() % range) + procVal1a;
+ else if (range < 0)
+ val = (rand() % -range) + procVal1b;
+ else
+ val = procVal1a;
+ }
+ break;
+ }
+ if (val < 0)
+ val = 0;
+ if (val > 127)
+ val = 127;
+ event.setA(val);
+
+ //---------------------------------------------------
+ // transform value B
+ //---------------------------------------------------
+
+ val = event.dataB();
+ switch (procVal2) {
+ case Plus:
+ val += procVal2a;
+ break;
+ case Minus:
+ val -= procVal2a;
+ break;
+ case Multiply:
+ val = int(val * (procVal2a/100.0) + .5);
+ break;
+ case Divide:
+ val = int(val / (procVal2a/100.0) + .5);
+ break;
+ case Fix:
+ val = procVal2a;
+ break;
+ case Value:
+ val = procVal1a;
+ break;
+ case Invert:
+ val = 127 - val;
+ break;
+ case Dynamic:
+ printf("transform not implemented\n");
+ break;
+ case Random:
+ {
+ int range = procVal2b - procVal2a;
+ if (range > 0)
+ val = (rand() % range) + procVal2a;
+ else if (range < 0)
+ val = (rand() % -range) + procVal2b;
+ else
+ val = procVal2a;
+ }
+ break;
+ case ScaleMap:
+ case Keep:
+ case Flip:
+ break;
+ }
+ if (val < 0)
+ val = 0;
+ if (val > 127)
+ val = 127;
+ event.setB(val);
+
+ //---------------------------------------------------
+ // transform port
+ //---------------------------------------------------
+
+ val = event.port();
+ switch (procPort) {
+ case Plus:
+ val += procPorta;
+ break;
+ case Minus:
+ val -= procPorta;
+ break;
+ case Multiply:
+ val = int(val * (procPorta/100.0) + .5);
+ break;
+ case Divide:
+ val = int(val / (procPorta/100.0) + .5);
+ break;
+ case Fix:
+ val = procPorta;
+ break;
+ case Value:
+ val = procPorta;
+ break;
+ case Invert:
+ val = 15 - val;
+ break;
+ case Dynamic:
+ printf("transform not implemented\n");
+ break;
+ case Random:
+ {
+ int range = procPortb - procPorta;
+ if (range > 0)
+ val = (rand() % range) + procPorta;
+ else if (range < 0)
+ val = (rand() % -range) + procPortb;
+ else
+ val = procPorta;
+ }
+ break;
+ case ScaleMap:
+ case Keep:
+ case Flip:
+ break;
+ }
+ if (val < 0)
+ val = 0;
+ if (val > 15)
+ val = 15;
+ event.setPort(val);
+
+ //---------------------------------------------------
+ // transform channel
+ //---------------------------------------------------
+
+ val = event.channel();
+ switch (procChannel) {
+ case Plus:
+ val += procChannela;
+ break;
+ case Minus:
+ val -= procChannela;
+ break;
+ case Multiply:
+ val = int(val * (procChannela/100.0) + .5);
+ break;
+ case Divide:
+ val = int(val / (procChannela/100.0) + .5);
+ break;
+ case Fix:
+ val = procChannela;
+ break;
+ case Value:
+ val = procChannela;
+ break;
+ case Invert:
+ val = 16 - val;
+ break;
+ case Dynamic:
+ printf("transform not implemented\n");
+ break;
+ case Random:
+ {
+ int range = procChannelb - procChannela;
+ if (range > 0)
+ val = (rand() % range) + procChannela;
+ else if (range < 0)
+ val = (rand() % -range) + procChannelb;
+ else
+ val = procChannela;
+ }
+ break;
+ case ScaleMap:
+ case Keep:
+ case Flip:
+ break;
+ }
+ if (val < 0)
+ val = 0;
+ if (val > 15)
+ val = 15;
+ event.setChannel(val);
+
+ return 2;
+ }
+
+//---------------------------------------------------------
+// typesMatch
+//---------------------------------------------------------
+
+bool MidiInputTransformation::typesMatch(MidiRecordEvent& e, int selType) const
+ {
+ bool matched = false;
+ int t = e.type();
+ switch (selType)
+ {
+ case MIDITRANSFORM_NOTE:
+ matched = ((t == ME_NOTEON) || (t == ME_NOTEOFF));
+ break;
+ case MIDITRANSFORM_POLY:
+ matched = (t == ME_POLYAFTER);
+ break;
+ case MIDITRANSFORM_CTRL:
+ matched = (t == ME_CONTROLLER);
+ break;
+ case MIDITRANSFORM_ATOUCH:
+ matched = (t == ME_AFTERTOUCH);
+ break;
+ case MIDITRANSFORM_PITCHBEND:
+ {
+ //if (t == ME_CONTROLLER) {
+ // MidiController::ControllerType c = midiControllerType(e.dataA());
+ // matched = (c == MidiController::Pitch);
+ matched = (t = ME_PITCHBEND);
+ }
+ break;
+ case MIDITRANSFORM_NRPN:
+ {
+ if (t == ME_CONTROLLER) {
+ MidiController::ControllerType c = midiControllerType(e.dataA());
+ matched = (c == MidiController::NRPN);
+ }
+ }
+ break;
+ case MIDITRANSFORM_RPN:
+ {
+ if (t == ME_CONTROLLER) {
+ MidiController::ControllerType c = midiControllerType(e.dataA());
+ matched = (c == MidiController::RPN);
+ }
+ }
+ break;
+ default:
+ fprintf(stderr, "Error matching type in MidiTransformerDialog: unknown eventtype!\n");
+ break;
+ }
+ //printf("Event type=%d, selType =%d matched=%d\n", e.type(), selType, matched);
+ return matched;
+ }
+
+//---------------------------------------------------------
+// MidiInputTransformDialog
+// Widgets:
+// presetList nameEntry commentEntry
+// selEventOp selType
+// selVal1Op selVal1a selVal1b
+// selVal2Op selVal2a selVal2b
+//
+// procEventOp procType
+// procVal1Op procVal1a procVal1b
+// procVal2Op procVal2a procVal2b
+// funcOp funcQuantVal
+// buttonNew buttonDelete
+//
+// modulGroup
+// modul1select modul1enable
+// modul2select modul2enable
+// modul3select modul3enable
+// modul4select modul4enable
+//
+// selPortOp selPortVala selPortValb
+// selChannelOp selChannelVala selChannelValb
+//
+// procPortOp procPortVala procPortValb
+// procChannelOp procChannelVala procChannelValb
+//---------------------------------------------------------
+
+MidiInputTransformDialog::MidiInputTransformDialog(QDialog* parent, Qt::WFlags fl)
+ : QDialog(parent, fl)
+ {
+ setupUi(this);
+ cindex = 0;
+ cmodul = 0;
+ cmt = 0;
+
+ modulGroup = new QButtonGroup;
+ modulGroup->addButton(modul1select,0);
+ modulGroup->addButton(modul2select,1);
+ modulGroup->addButton(modul3select,2);
+ modulGroup->addButton(modul4select,3);
+
+ for (unsigned i = 0; i < sizeof(oplist)/sizeof(*oplist); ++i)
+ funcOp->insertItem(i, oplist[i].text);
+
+ connect(buttonNew, SIGNAL(clicked()), SLOT(presetNew()));
+ connect(buttonDelete, SIGNAL(clicked()), SLOT(presetDelete()));
+ connect(selEventOp, SIGNAL(activated(int)), SLOT(selEventOpSel(int)));
+ connect(selType, SIGNAL(activated(int)), SLOT(selTypeSel(int)));
+ connect(selVal1Op, SIGNAL(activated(int)), SLOT(selVal1OpSel(int)));
+ connect(selVal2Op, SIGNAL(activated(int)), SLOT(selVal2OpSel(int)));
+ connect(procEventOp, SIGNAL(activated(int)), SLOT(procEventOpSel(int)));
+ connect(procType, SIGNAL(activated(int)), SLOT(procEventTypeSel(int)));
+ connect(procVal1Op, SIGNAL(activated(int)), SLOT(procVal1OpSel(int)));
+ connect(procVal2Op, SIGNAL(activated(int)), SLOT(procVal2OpSel(int)));
+ connect(funcOp, SIGNAL(activated(int)), SLOT(funcOpSel(int)));
+ connect(presetList, SIGNAL(itemActivated(QListWidgetItem*)),
+ SLOT(presetChanged(QListWidgetItem*)));
+ connect(nameEntry, SIGNAL(textChanged(const QString&)),
+ SLOT(nameChanged(const QString&)));
+ connect(commentEntry, SIGNAL(textChanged()), SLOT(commentChanged()));
+
+ connect(selVal1a, SIGNAL(valueChanged(int)), SLOT(selVal1aChanged(int)));
+ connect(selVal1b, SIGNAL(valueChanged(int)), SLOT(selVal1bChanged(int)));
+ connect(selVal2a, SIGNAL(valueChanged(int)), SLOT(selVal2aChanged(int)));
+ connect(selVal2b, SIGNAL(valueChanged(int)), SLOT(selVal2bChanged(int)));
+ connect(procVal1a, SIGNAL(valueChanged(int)), SLOT(procVal1aChanged(int)));
+ connect(procVal1b, SIGNAL(valueChanged(int)), SLOT(procVal1bChanged(int)));
+ connect(procVal2a, SIGNAL(valueChanged(int)), SLOT(procVal2aChanged(int)));
+ connect(procVal2b, SIGNAL(valueChanged(int)), SLOT(procVal2bChanged(int)));
+
+ connect(modul1enable, SIGNAL(toggled(bool)), SLOT(modul1enableChanged(bool)));
+ connect(modul2enable, SIGNAL(toggled(bool)), SLOT(modul2enableChanged(bool)));
+ connect(modul3enable, SIGNAL(toggled(bool)), SLOT(modul3enableChanged(bool)));
+ connect(modul4enable, SIGNAL(toggled(bool)), SLOT(modul4enableChanged(bool)));
+ connect(modulGroup, SIGNAL(buttonClicked(int)), SLOT(changeModul(int)));
+
+ connect(selPortOp, SIGNAL(activated(int)), SLOT(selPortOpSel(int)));
+ connect(selPortVala, SIGNAL(valueChanged(int)), SLOT(selPortValaChanged(int)));
+ connect(selPortValb, SIGNAL(valueChanged(int)), SLOT(selPortValbChanged(int)));
+
+ connect(selChannelOp, SIGNAL(activated(int)), SLOT(selChannelOpSel(int)));
+ connect(selChannelVala, SIGNAL(valueChanged(int)), SLOT(selChannelValaChanged(int)));
+ connect(selChannelValb, SIGNAL(valueChanged(int)), SLOT(selChannelValbChanged(int)));
+
+ connect(procPortOp, SIGNAL(activated(int)), SLOT(procPortOpSel(int)));
+ connect(procPortVala, SIGNAL(valueChanged(int)), SLOT(procPortValaChanged(int)));
+ connect(procPortValb, SIGNAL(valueChanged(int)), SLOT(procPortValbChanged(int)));
+
+ connect(procChannelOp, SIGNAL(activated(int)), SLOT(procChannelOpSel(int)));
+ connect(procChannelVala, SIGNAL(valueChanged(int)), SLOT(procChannelValaChanged(int)));
+ connect(procChannelValb, SIGNAL(valueChanged(int)), SLOT(procChannelValbChanged(int)));
+
+ //---------------------------------------------------
+ // populate preset list
+ //---------------------------------------------------
+
+ updatePresetList();
+ presetList->setCurrentItem(presetList->item(0));
+ presetChanged(presetList->item(0));
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::songChanged(int flags)
+{
+ // Whenever a song is loaded, flags is -1. Since transforms are part of configuration,
+ // use SC_CONFIG here, to filter unwanted song change events.
+ if(flags & SC_CONFIG)
+ updatePresetList();
+}
+
+//---------------------------------------------------------
+// updatePresetList
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::updatePresetList()
+{
+ cmt = 0;
+ presetList->clear();
+
+ modul1select->setChecked(true);
+ for (iMidiInputTransformation i = mtlist.begin(); i != mtlist.end(); ++i) {
+ presetList->addItem((*i)->name);
+ if (cmt == 0)
+ cmt = *i;
+ }
+ if (cmt == 0) {
+ // create default "New" preset
+ cmt = new MidiInputTransformation(tr("New"));
+ mtlist.push_back(cmt);
+ presetList->addItem(tr("New"));
+ presetList->setCurrentItem(0);
+ }
+ changeModul(0);
+
+ modul1enable->setChecked(modules[0].valid);
+ modul2enable->setChecked(modules[1].valid);
+ modul3enable->setChecked(modules[2].valid);
+ modul4enable->setChecked(modules[3].valid);
+}
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::closeEvent(QCloseEvent* ev)
+ {
+ emit hideWindow();
+ QWidget::closeEvent(ev);
+ }
+
+//---------------------------------------------------------
+// writeMidiTransforms
+//---------------------------------------------------------
+
+void writeMidiInputTransforms(int level, Xml& xml)
+ {
+ for (iMidiInputTransformation i = mtlist.begin(); i != mtlist.end(); ++i) {
+ (*i)->write(level, xml);
+ }
+ }
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+void MidiInputTransformation::write(int level, Xml& xml) const
+ {
+ xml.tag(level++, "midiInputTransform");
+ xml.strTag(level, "name", name);
+ xml.strTag(level, "comment", comment);
+ xml.intTag(level, "function", int(funcOp));
+
+ // apply this transformation?
+ for (int i = 0; i < MIDI_INPUT_TRANSFORMATIONS; ++i) {
+ if (modules[i].transform == this) {
+ xml.intTag(level, "apply", int(modules[i].valid));
+ break;
+ }
+ }
+ if (funcOp == Quantize) {
+ xml.intTag(level, "quantVal", quantVal);
+ }
+ if (funcOp == Transform || funcOp == Insert) {
+ if (procEvent != KeepType) {
+ xml.intTag(level, "procEventOp", int(procEvent));
+ xml.intTag(level, "eventType", int(eventType));
+ }
+ if (procVal1 != Keep) {
+ xml.intTag(level, "procVal1Op", int(procVal1));
+ xml.intTag(level, "procVal1a", procVal1a);
+ xml.intTag(level, "procVal1b", procVal1b);
+ }
+ if (procVal2 != Keep) {
+ xml.intTag(level, "procVal2Op", int(procVal2));
+ xml.intTag(level, "procVal2a", procVal2a);
+ xml.intTag(level, "procVal2b", procVal2b);
+ }
+ if (procPort != Keep) {
+ xml.intTag(level, "procPortOp", int(procPort));
+ xml.intTag(level, "procPorta", procPorta);
+ xml.intTag(level, "procPortb", procPortb);
+ }
+ if (procChannel != Keep) {
+ xml.intTag(level, "procChannelOp", int(procChannel));
+ xml.intTag(level, "procChannela", procChannela);
+ xml.intTag(level, "procChannelb", procChannelb);
+ }
+ }
+ if (selEventOp != Ignore) {
+ xml.intTag(level, "selEventOp", int(selEventOp));
+ xml.intTag(level, "selEventType", int(selType));
+ }
+ if (selVal1 != Ignore) {
+ xml.intTag(level, "selVal1Op", int(selVal1));
+ xml.intTag(level, "selVal1a", selVal1a);
+ xml.intTag(level, "selVal1b", selVal1b);
+ }
+ if (selVal2 != Ignore) {
+ xml.intTag(level, "selVal2Op", int(selVal2));
+ xml.intTag(level, "selVal2a", selVal2a);
+ xml.intTag(level, "selVal2b", selVal2b);
+ }
+ if (selPort != Ignore) {
+ xml.intTag(level, "selPortOp", int(selPort));
+ xml.intTag(level, "selPorta", selPorta);
+ xml.intTag(level, "selPortb", selPortb);
+ }
+ if (selChannel != Ignore) {
+ xml.intTag(level, "selChannelOp", int(selChannel));
+ xml.intTag(level, "selChannela", selChannela);
+ xml.intTag(level, "selChannelb", selChannelb);
+ }
+ xml.etag(level, "midiInputTransform");
+ }
+
+//---------------------------------------------------------
+// readMidiTransform
+//---------------------------------------------------------
+
+void readMidiInputTransform(Xml& xml)
+ {
+ MidiInputTransformation trans(QString("new"));
+ int apply = -1;
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "name")
+ trans.name = xml.parse1();
+ else if (tag == "comment")
+ trans.comment = xml.parse1();
+ else if (tag == "function")
+ trans.funcOp = TransformFunction(xml.parseInt());
+ else if (tag == "quantVal")
+ trans.quantVal = xml.parseInt();
+ else if (tag == "procEventOp")
+ trans.procEvent = InputTransformProcEventOp(xml.parseInt());
+ else if (tag == "eventType")
+ trans.eventType = xml.parseInt();
+ else if (tag == "procVal1Op")
+ trans.procVal1 = TransformOperator(xml.parseInt());
+ else if (tag == "procVal1a")
+ trans.procVal1a = xml.parseInt();
+ else if (tag == "procVal1b")
+ trans.procVal1b = xml.parseInt();
+ else if (tag == "procVal2Op")
+ trans.procVal2 = TransformOperator(xml.parseInt());
+ else if (tag == "procVal2a")
+ trans.procVal2a = xml.parseInt();
+ else if (tag == "procVal2b")
+ trans.procVal2b = xml.parseInt();
+ else if (tag == "selEventOp")
+ trans.selEventOp = ValOp(xml.parseInt());
+ else if (tag == "selEventType")
+ trans.selType = xml.parseInt();
+ else if (tag == "selVal1Op")
+ trans.selVal1 = ValOp(xml.parseInt());
+ else if (tag == "selVal1a")
+ trans.selVal1a = xml.parseInt();
+ else if (tag == "selVal1b")
+ trans.selVal1b = xml.parseInt();
+ else if (tag == "selVal2Op")
+ trans.selVal2 = ValOp(xml.parseInt());
+ else if (tag == "selVal2a")
+ trans.selVal2a = xml.parseInt();
+ else if (tag == "selVal2b")
+ trans.selVal2b = xml.parseInt();
+
+ else if (tag == "procPortOp")
+ trans.procPort = TransformOperator(xml.parseInt());
+ else if (tag == "procPorta")
+ trans.procPorta = xml.parseInt();
+ else if (tag == "procPortb")
+ trans.procPortb = xml.parseInt();
+ else if (tag == "procChannelOp")
+ trans.procChannel = TransformOperator(xml.parseInt());
+ else if (tag == "procChannela")
+ trans.procChannela = xml.parseInt();
+ else if (tag == "procChannelb")
+ trans.procChannelb = xml.parseInt();
+
+ else if (tag == "selPortOp")
+ trans.selPort = ValOp(xml.parseInt());
+ else if (tag == "selPorta")
+ trans.selPorta = xml.parseInt();
+ else if (tag == "selPortb")
+ trans.selPortb = xml.parseInt();
+ else if (tag == "selChannelOp")
+ trans.selChannel = ValOp(xml.parseInt());
+ else if (tag == "selChannela")
+ trans.selChannela = xml.parseInt();
+ else if (tag == "selChannelb")
+ trans.selChannelb = xml.parseInt();
+
+ else if (tag == "apply")
+ apply = xml.parseInt();
+ else
+ xml.unknown("midiInputTransform");
+ break;
+ case Xml::TagEnd:
+ if (xml.s1() == "midiInputTransform") {
+// printf("midi Input transform <%s> apply %d\n",
+// trans.name.toLatin1().constData(), apply);
+
+ // By T356. A previous bug caused some .med files to grow very large
+ // with duplicate transforms. Here we can eliminate those duplicates.
+ for(iMidiInputTransformation i = mtlist.begin(); i != mtlist.end(); ++i)
+ {
+ if((*i)->name == trans.name)
+ {
+ return;
+ }
+ }
+
+ MidiInputTransformation* t = new MidiInputTransformation(trans);
+ // search free slot in modules
+ if (apply != -1) {
+ for (int i = 0; i < MIDI_INPUT_TRANSFORMATIONS; ++i) {
+ if (modules[i].transform == 0) {
+ modules[i].transform = t;
+ modules[i].valid = apply;
+ break;
+ }
+ }
+ }
+ mtlist.push_back(t);
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// clearMidiInputTransforms
+//---------------------------------------------------------
+
+void clearMidiInputTransforms()
+{
+ for (int i = 0; i < MIDI_INPUT_TRANSFORMATIONS; ++i)
+ {
+ modules[i].transform = 0;
+ modules[i].valid = false;
+ }
+ for (iMidiInputTransformation i = mtlist.begin(); i != mtlist.end(); ++i)
+ {
+ MidiInputTransformation* t = *i;
+ if(t)
+ delete t;
+ }
+ mtlist.clear();
+}
+
+//---------------------------------------------------------
+// accept
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::accept()
+ {
+ reject();
+ }
+
+//---------------------------------------------------------
+// reject
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::reject()
+ {
+ close();
+ }
+
+//---------------------------------------------------------
+// setValOp
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::setValOp(QWidget* a, QWidget* b, ValOp op)
+ {
+ switch (op) {
+ case Ignore:
+ a->setEnabled(false);
+ b->setEnabled(false);
+ break;
+ case Equal:
+ case Unequal:
+ case Higher:
+ case Lower:
+ a->setEnabled(true);
+ b->setEnabled(false);
+ break;
+ case Inside:
+ case Outside:
+ a->setEnabled(true);
+ b->setEnabled(true);
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// selEventOpSel
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::selEventOpSel(int val)
+ {
+ selType->setEnabled(val != All);
+ cmt->selEventOp = ValOp(val);
+ selVal1aChanged(cmt->selVal1a);
+ selVal1bChanged(cmt->selVal1b);
+ }
+
+//---------------------------------------------------------
+// selTypeSel
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::selTypeSel(int val)
+ {
+ cmt->selType = selTypeTable[val];
+ selVal1aChanged(cmt->selVal1a);
+ selVal1bChanged(cmt->selVal1b);
+ }
+
+//---------------------------------------------------------
+// selVal1OpSel
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::selVal1OpSel(int val)
+ {
+ setValOp(selVal1a, selVal1b, ValOp(val));
+ cmt->selVal1 = ValOp(val);
+ }
+
+//---------------------------------------------------------
+// selVal2OpSel
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::selVal2OpSel(int val)
+ {
+ setValOp(selVal2a, selVal2b, ValOp(val));
+ cmt->selVal2 = ValOp(val);
+ }
+
+//---------------------------------------------------------
+// procEventOpSel
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::procEventOpSel(int val)
+ {
+ InputTransformProcEventOp op = val == 0 ? KeepType : FixType;
+ procType->setEnabled(op == FixType);
+ cmt->procEvent = op;
+
+ procVal1aChanged(cmt->procVal1a);
+ procVal1bChanged(cmt->procVal1b);
+ }
+
+//---------------------------------------------------------
+// procEventTypeSel
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::procEventTypeSel(int val)
+ {
+ cmt->eventType = procTypeTable[val];
+ procVal1aChanged(cmt->procVal1a);
+ procVal1bChanged(cmt->procVal1b);
+ }
+
+//---------------------------------------------------------
+// procVal1OpSel
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::procVal1OpSel(int val)
+ {
+ cmt->procVal1 = TransformOperator(val);
+ switch(TransformOperator(val)) {
+ case Keep:
+ case Invert:
+ procVal1a->setEnabled(false);
+ procVal1b->setEnabled(false);
+ break;
+ case Multiply:
+ case Divide:
+ procVal1a->setEnabled(true);
+ procVal1a->setDecimals(2);
+ procVal1b->setEnabled(false);
+ break;
+ case Plus:
+ case Minus:
+ case Fix:
+ case Value:
+ case Flip:
+ procVal1a->setDecimals(0);
+ procVal1a->setEnabled(true);
+ procVal1b->setEnabled(false);
+ break;
+ case Random:
+ case ScaleMap:
+ case Dynamic:
+ procVal1a->setDecimals(0);
+ procVal1a->setEnabled(true);
+ procVal1b->setEnabled(true);
+ break;
+ }
+ procVal1aChanged(cmt->procVal1a);
+ procVal1bChanged(cmt->procVal1b);
+ }
+
+//---------------------------------------------------------
+// procVal2OpSel
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::procVal2OpSel(int val)
+ {
+ TransformOperator op = TransformOperator(procVal2Map[val]);
+ cmt->procVal2 = op;
+
+ switch (op) {
+ case Keep:
+ case Invert:
+ procVal2a->setEnabled(false);
+ procVal2b->setEnabled(false);
+ break;
+ case Multiply:
+ case Divide:
+ procVal2a->setEnabled(true);
+ procVal2a->setDecimals(2);
+ procVal2b->setEnabled(false);
+ break;
+ case Plus:
+ case Minus:
+ case Fix:
+ case Value:
+ procVal2a->setDecimals(0);
+ procVal2a->setEnabled(true);
+ procVal2b->setEnabled(false);
+ break;
+ case Random:
+ case Dynamic:
+ procVal2a->setDecimals(0);
+ procVal2a->setEnabled(true);
+ procVal2b->setEnabled(true);
+ break;
+ default:
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// funcOpSel
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::funcOpSel(int val)
+ {
+ TransformFunction op = oplist[val].id;
+
+ bool isFuncOp(op == Transform);
+
+ procEventOp->setEnabled(isFuncOp);
+ procType->setEnabled(isFuncOp);
+ procVal1Op->setEnabled(isFuncOp);
+ procVal1a->setEnabled(isFuncOp);
+ procVal1b->setEnabled(isFuncOp);
+ procVal2Op->setEnabled(isFuncOp);
+ procVal2a->setEnabled(isFuncOp);
+ procVal2b->setEnabled(isFuncOp);
+ procPortOp->setEnabled(isFuncOp);
+ procPortVala->setEnabled(isFuncOp);
+ procPortValb->setEnabled(isFuncOp);
+ procChannelOp->setEnabled(isFuncOp);
+ procChannelVala->setEnabled(isFuncOp);
+ procChannelValb->setEnabled(isFuncOp);
+ if (isFuncOp) {
+ procEventOpSel(cmt->procEvent);
+ procVal1OpSel(cmt->procVal1);
+ procVal2OpSel(cmt->procVal2);
+ procPortOpSel(cmt->procPort);
+ procChannelOpSel(cmt->procChannel);
+ }
+ cmt->funcOp = op;
+ }
+
+//---------------------------------------------------------
+// presetNew
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::presetNew()
+ {
+ QString name;
+ for (int i = 0;; ++i) {
+ name.sprintf("New-%d", i);
+ iMidiInputTransformation imt;
+ for (imt = mtlist.begin(); imt != mtlist.end(); ++imt) {
+ if (name == (*imt)->name)
+ break;
+ }
+ if (imt == mtlist.end())
+ break;
+ }
+ MidiInputTransformation* mt = new MidiInputTransformation(name);
+ QListWidgetItem* lbi = new QListWidgetItem(name);
+ presetList->addItem(lbi);
+ mtlist.push_back(mt);
+ presetList->setCurrentItem(lbi);
+ presetChanged(lbi);
+ }
+
+//---------------------------------------------------------
+// presetDelete
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::presetDelete()
+ {
+ if (cindex != -1) {
+ iMidiInputTransformation mt = mtlist.begin();
+ for (int i = 0; i < cindex; ++i, ++mt) {
+ mtlist.erase(mt);
+ presetList->setCurrentItem(presetList->item(cindex - 1));
+ presetList->takeItem(cindex);
+ presetChanged(presetList->item(cindex - 1));
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// nameChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::nameChanged(const QString& s)
+ {
+ cmt->name = s;
+ QListWidgetItem* item = presetList->item(cindex);
+ if (s != item->text()) {
+ disconnect(presetList, SIGNAL(itemActivated(QListWidgetItem*)),
+ this, SLOT(presetChanged(QListWidgetItem*)));
+ presetList->insertItem(cindex, s);
+ presetList->takeItem(cindex+1);
+ presetList->setCurrentItem(presetList->item(cindex));
+ connect(presetList, SIGNAL(itemActivated(QListWidgetItem*)),
+ SLOT(presetChanged(QListWidgetItem*)));
+ }
+ }
+
+//---------------------------------------------------------
+// commentChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::commentChanged()
+ {
+ cmt->comment = commentEntry->toPlainText();
+ }
+
+//---------------------------------------------------------
+// selVal1aChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::selVal1aChanged(int val)
+ {
+ cmt->selVal1a = val;
+ if ((cmt->selEventOp != All)
+ && (cmt->selType == MIDITRANSFORM_NOTE)) {
+ selVal1a->setSuffix(" - " + pitch2string(val));
+ }
+ else
+ {
+ if(!selVal1a->suffix().isEmpty())
+ selVal1a->setSuffix(QString(""));
+ }
+ }
+
+//---------------------------------------------------------
+// selVal1bChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::selVal1bChanged(int val)
+ {
+ cmt->selVal1b = val;
+ if ((cmt->selEventOp != All)
+ && (cmt->selType == MIDITRANSFORM_NOTE)) {
+ selVal1b->setSuffix(" - " + pitch2string(val));
+ }
+ else
+ {
+ if(!selVal1b->suffix().isEmpty())
+ selVal1b->setSuffix(QString(""));
+ }
+ }
+
+//---------------------------------------------------------
+// selVal2aChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::selVal2aChanged(int val)
+ {
+ cmt->selVal2a = val;
+ }
+
+//---------------------------------------------------------
+// selVal2bChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::selVal2bChanged(int val)
+ {
+ cmt->selVal2b = val;
+ }
+
+//---------------------------------------------------------
+// procVal1aChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::procVal1aChanged(int val)
+ {
+ cmt->procVal1a = val;
+
+ if((cmt->procEvent == KeepType && cmt->selType == MIDITRANSFORM_NOTE) &&
+ (cmt->procVal1 == Fix || cmt->procVal1 == ScaleMap || cmt->procVal1 == Dynamic ||
+ cmt->procVal1 == Random || cmt->procVal1 == Flip))
+ {
+ procVal1a->setSuffix(" - " + pitch2string(val));
+ }
+ else
+ {
+ if(!procVal1a->suffix().isEmpty())
+ procVal1a->setSuffix(QString(""));
+ }
+ }
+
+//---------------------------------------------------------
+// procVal1bChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::procVal1bChanged(int val)
+ {
+ cmt->procVal1b = val;
+
+ if((cmt->procEvent == KeepType && cmt->selType == MIDITRANSFORM_NOTE) &&
+ (cmt->procVal1 == Fix || cmt->procVal1 == ScaleMap || cmt->procVal1 == Dynamic ||
+ cmt->procVal1 == Random || cmt->procVal1 == Flip))
+ {
+ procVal1b->setSuffix(" - " + pitch2string(val));
+ }
+ else
+ {
+ if(!procVal1b->suffix().isEmpty())
+ procVal1b->setSuffix(QString(""));
+ }
+ }
+
+//---------------------------------------------------------
+// procVal2aChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::procVal2aChanged(int val)
+ {
+ cmt->procVal2a = val;
+ }
+
+//---------------------------------------------------------
+// procVal2bChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::procVal2bChanged(int val)
+ {
+ cmt->procVal2b = val;
+ }
+
+//---------------------------------------------------------
+// modul1enableChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::modul1enableChanged(bool val)
+ {
+ modules[0].valid = val;
+ }
+
+//---------------------------------------------------------
+// modul2enableChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::modul2enableChanged(bool val)
+ {
+ modules[1].valid = val;
+ }
+
+//---------------------------------------------------------
+// modul3enableChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::modul3enableChanged(bool val)
+ {
+ modules[2].valid = val;
+ }
+
+//---------------------------------------------------------
+// modul4enableChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::modul4enableChanged(bool val)
+ {
+ modules[3].valid = val;
+ }
+
+//---------------------------------------------------------
+// selPortOpSel
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::selPortOpSel(int val)
+ {
+ setValOp(selPortVala, selPortValb, ValOp(val));
+ cmt->selPort = ValOp(val);
+ }
+
+//---------------------------------------------------------
+// selPortValaChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::selPortValaChanged(int val)
+ {
+ cmt->selPorta = val;
+ }
+
+//---------------------------------------------------------
+// selPortValbChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::selPortValbChanged(int val)
+ {
+ cmt->selPortb = val;
+ }
+
+//---------------------------------------------------------
+// selChannelOpSel
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::selChannelOpSel(int val)
+ {
+ setValOp(selChannelVala, selChannelValb, ValOp(val));
+ cmt->selChannel = ValOp(val);
+ }
+
+//---------------------------------------------------------
+// selChannelValaChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::selChannelValaChanged(int val)
+ {
+ cmt->selChannela = val;
+ }
+
+//---------------------------------------------------------
+// selChannelValbChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::selChannelValbChanged(int val)
+ {
+ cmt->selChannelb = val;
+ }
+
+//---------------------------------------------------------
+// procPortOpSel
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::procPortOpSel(int val)
+ {
+ cmt->procPort = TransformOperator(val);
+ switch(TransformOperator(val)) {
+ case Keep:
+ case Invert:
+ procPortVala->setEnabled(false);
+ procPortValb->setEnabled(false);
+ break;
+ case Multiply:
+ case Divide:
+ procPortVala->setEnabled(true);
+ procPortVala->setDecimals(2);
+ procPortValb->setEnabled(false);
+ break;
+ case Plus:
+ case Minus:
+ case Fix:
+ case Value:
+ case Flip:
+ procPortVala->setDecimals(0);
+ procPortVala->setEnabled(true);
+ procPortValb->setEnabled(false);
+ break;
+ case Random:
+ case ScaleMap:
+ case Dynamic:
+ procPortVala->setDecimals(0);
+ procPortVala->setEnabled(true);
+ procPortValb->setEnabled(true);
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// procPortValaChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::procPortValaChanged(int val)
+ {
+ cmt->procPorta = val;
+ }
+
+//---------------------------------------------------------
+// procPortValbChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::procPortValbChanged(int val)
+ {
+ cmt->procPortb = val;
+ }
+
+//---------------------------------------------------------
+// procChannelOpSel
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::procChannelOpSel(int val)
+ {
+ cmt->procChannel = TransformOperator(val);
+ switch(TransformOperator(val)) {
+ case Keep:
+ case Invert:
+ procChannelVala->setEnabled(false);
+ procChannelValb->setEnabled(false);
+ break;
+ case Multiply:
+ case Divide:
+ procChannelVala->setEnabled(true);
+ procChannelVala->setDecimals(2);
+ procChannelValb->setEnabled(false);
+ break;
+ case Plus:
+ case Minus:
+ case Fix:
+ case Value:
+ case Flip:
+ procChannelVala->setDecimals(0);
+ procChannelVala->setEnabled(true);
+ procChannelValb->setEnabled(false);
+ break;
+ case Random:
+ case ScaleMap:
+ case Dynamic:
+ procChannelVala->setDecimals(0);
+ procChannelVala->setEnabled(true);
+ procChannelValb->setEnabled(true);
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// procChannelValaChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::procChannelValaChanged(int val)
+ {
+ cmt->procChannela = val;
+ }
+
+//---------------------------------------------------------
+// procChannelValbChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::procChannelValbChanged(int val)
+ {
+ cmt->procChannelb = val;
+ }
+
+//---------------------------------------------------------
+// changeModul
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::changeModul(int k)
+ {
+//printf("change modul %d\n", k);
+
+ cmodul = k; // current modul
+
+ if (modules[k].transform == 0) {
+ //printf("transform %d ist null\n", k);
+ modules[k].transform = cmt;
+ }
+ else {
+ //---------------------------------------------
+ // search transformation in list
+ //---------------------------------------------
+
+ int idx = 0;
+ iMidiInputTransformation i;
+ for (i = mtlist.begin(); i != mtlist.end(); ++i, ++idx) {
+ if (*i == modules[k].transform) {
+ presetList->setCurrentItem(presetList->item(idx));
+ break;
+ }
+ }
+ if (i == mtlist.end())
+ printf("change to unknown transformation!\n");
+ }
+ }
+
+//---------------------------------------------------------
+// presetChanged
+//---------------------------------------------------------
+
+void MidiInputTransformDialog::presetChanged(QListWidgetItem* item)
+ {
+ cindex = presetList->row(item);
+
+ //---------------------------------------------------
+ // search transformation in list and set
+ // cmt
+ //---------------------------------------------------
+
+ iMidiInputTransformation i;
+ for (i = mtlist.begin(); i != mtlist.end(); ++i) {
+ if (item->text() == (*i)->name) {
+ if(debugMsg)
+ printf("found %s\n", (*i)->name.toLatin1().constData());
+ cmt = *i;
+ if (cmodul != -1) {
+ modules[cmodul].transform = *i;
+ }
+ break;
+ }
+ }
+ if (i == mtlist.end()) {
+ printf("MidiInputTransformDialog::presetChanged: not found\n");
+ return;
+ }
+ nameEntry->setText(cmt->name);
+ commentEntry->setText(cmt->comment);
+
+ selEventOp->setCurrentIndex(cmt->selEventOp);
+ selEventOpSel(cmt->selEventOp);
+
+ for (unsigned i = 0; i < sizeof(selTypeTable)/sizeof(*selTypeTable); ++i) {
+ if (selTypeTable[i] == cmt->selType) {
+ selType->setCurrentIndex(i);
+ break;
+ }
+ }
+
+ selVal1Op->setCurrentIndex(cmt->selVal1);
+ selVal1OpSel(cmt->selVal1);
+
+ selVal2Op->setCurrentIndex(cmt->selVal2);
+ selVal2OpSel(cmt->selVal2);
+
+ selPortOp->setCurrentIndex(cmt->selPort);
+ selPortOpSel(cmt->selPort);
+
+ selChannelOp->setCurrentIndex(cmt->selChannel);
+ selChannelOpSel(cmt->selChannel);
+
+ {
+ unsigned i;
+ for (i = 0; i < sizeof(oplist)/sizeof(*oplist); ++i) {
+ if (oplist[i].id == cmt->funcOp) {
+ funcOp->setCurrentIndex(i);
+ break;
+ }
+ }
+ if (i == sizeof(oplist)/sizeof(*oplist))
+ printf("internal error: bad OpCode\n");
+ funcOpSel(i);
+ }
+
+ for (unsigned i = 0; i < sizeof(procTypeTable)/sizeof(*procTypeTable); ++i) {
+ if (procTypeTable[i] == cmt->eventType) {
+ procType->setCurrentIndex(i);
+ break;
+ }
+ }
+
+ procEventOp->setCurrentIndex(cmt->procEvent);
+ procEventOpSel(cmt->procEvent);
+
+ procVal1Op->setCurrentIndex(cmt->procVal1);
+ procVal1OpSel(cmt->procVal1);
+
+ for (unsigned i = 0; i < sizeof(procVal2Map)/sizeof(*procVal2Map); ++i) {
+ if (procVal2Map[i] == cmt->procVal2) {
+ procVal2Op->setCurrentIndex(i);
+ break;
+ }
+ }
+
+ selVal1a->setValue(cmt->selVal1a);
+ selVal1b->setValue(cmt->selVal1b);
+ selVal1aChanged(cmt->selVal1a);
+ selVal1bChanged(cmt->selVal1b);
+
+ selVal2a->setValue(cmt->selVal2a);
+ selVal2b->setValue(cmt->selVal2b);
+
+ selPortVala->setValue(cmt->selPorta);
+ selPortValb->setValue(cmt->selPortb);
+
+ selChannelVala->setValue(cmt->selChannela);
+ selChannelValb->setValue(cmt->selChannelb);
+
+ procVal1a->setValue(cmt->procVal1a);
+ procVal1b->setValue(cmt->procVal1b);
+
+ procVal2a->setValue(cmt->procVal2a);
+ procVal2b->setValue(cmt->procVal2b);
+
+ procPortVala->setValue(cmt->procPorta);
+ procPortValb->setValue(cmt->procPortb);
+
+ procChannelVala->setValue(cmt->procChannela);
+ procChannelValb->setValue(cmt->procChannelb);
+
+ procPortOp->setCurrentIndex(cmt->procPort);
+ procPortOpSel(cmt->procPort);
+
+ procChannelOp->setCurrentIndex(cmt->procChannel);
+ procChannelOpSel(cmt->procChannel);
+
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/mplugins/midiitransform.h b/attic/muse2-oom/muse2/muse/mplugins/midiitransform.h
new file mode 100644
index 00000000..b9288319
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mplugins/midiitransform.h
@@ -0,0 +1,102 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midiitransform.h,v 1.1.1.1.2.1 2009/02/02 21:38:01 terminator356 Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MIDIITRANSFORM_H__
+#define __MIDIITRANSFORM_H__
+
+#include "ui_itransformbase.h"
+
+#include <QCloseEvent>
+
+class QButtonGroup;
+class MidiTransformation;
+class MidiInputTransformation;
+class MidiRecordEvent;
+class MidiPart;
+class Xml;
+
+#include "miditransform.h"
+
+enum InputTransformProcEventOp { KeepType, FixType };
+
+//---------------------------------------------------------
+// MidiInputTransform
+//---------------------------------------------------------
+
+class MidiInputTransformDialog : public QDialog, public Ui::MidiInputTransformDialogBase {
+ Q_OBJECT
+ MidiInputTransformation* cmt;
+ int cindex; // current index in preset list
+ int cmodul; // current index in modules list
+
+ virtual void accept();
+ virtual void reject();
+ void setValOp(QWidget* a, QWidget* b, ValOp op);
+ virtual void closeEvent(QCloseEvent*);
+
+ void updatePresetList();
+ QButtonGroup* modulGroup;
+
+ signals:
+ void hideWindow();
+
+ private slots:
+ void presetNew();
+ void presetDelete();
+
+ void changeModul(int k);
+ void selEventOpSel(int);
+ void selTypeSel(int);
+ void selVal1OpSel(int);
+ void selVal2OpSel(int);
+ void procEventOpSel(int);
+ void procEventTypeSel(int);
+ void procVal1OpSel(int);
+ void procVal2OpSel(int);
+ void funcOpSel(int);
+ void presetChanged(QListWidgetItem*);
+ void nameChanged(const QString&);
+ void commentChanged();
+ void selVal1aChanged(int);
+ void selVal1bChanged(int);
+ void selVal2aChanged(int);
+ void selVal2bChanged(int);
+ void procVal1aChanged(int);
+ void procVal1bChanged(int);
+ void procVal2aChanged(int);
+ void procVal2bChanged(int);
+ void modul1enableChanged(bool);
+ void modul2enableChanged(bool);
+ void modul3enableChanged(bool);
+ void modul4enableChanged(bool);
+
+ void selPortOpSel(int);
+ void selPortValaChanged(int);
+ void selPortValbChanged(int);
+ void selChannelOpSel(int);
+ void selChannelValaChanged(int);
+ void selChannelValbChanged(int);
+ void procPortOpSel(int);
+ void procPortValaChanged(int);
+ void procPortValbChanged(int);
+ void procChannelOpSel(int);
+ void procChannelValaChanged(int);
+ void procChannelValbChanged(int);
+
+ public slots:
+ void songChanged(int);
+
+ public:
+ MidiInputTransformDialog(QDialog* parent = 0, Qt::WFlags fl = 0);
+ };
+
+extern void writeMidiInputTransforms(int level, Xml& xml);
+extern void readMidiInputTransform(Xml&);
+extern bool applyMidiInputTransformation(MidiRecordEvent& event);
+extern void clearMidiInputTransforms();
+#endif
diff --git a/attic/muse2-oom/muse2/muse/mplugins/mitplugin.cpp b/attic/muse2-oom/muse2/muse/mplugins/mitplugin.cpp
new file mode 100644
index 00000000..e1a4e656
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mplugins/mitplugin.cpp
@@ -0,0 +1,156 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mitplugin.cpp,v 1.1.1.1 2003/10/27 18:52:40 wschweer Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "mitplugin.h"
+#include "app.h"
+#include "event.h"
+#include "xml.h"
+
+#include "midiitransform.h"
+#include "mittranspose.h"
+#include "midifilterimpl.h"
+#include "mrconfig.h"
+
+#ifdef BUILD_EXPERIMENTAL
+#include "rhythm.h"
+#endif
+
+MITPluginList mitPlugins;
+
+//---------------------------------------------------------
+// startMidiInputPlugin
+//---------------------------------------------------------
+
+void MusE::startMidiInputPlugin(int id)
+ {
+ bool flag = false;
+ QWidget* w = 0;
+ QAction* act;
+ if (id == 0) {
+ if (!mitPluginTranspose) {
+ mitPluginTranspose = new MITPluginTranspose();
+ mitPlugins.push_back(mitPluginTranspose);
+ connect(mitPluginTranspose, SIGNAL(hideWindow()),
+ SLOT(hideMitPluginTranspose()));
+ }
+ w = mitPluginTranspose;
+ act = midiTrpAction;
+ }
+ else if (id == 1) {
+ if (!midiInputTransform) {
+ midiInputTransform = new MidiInputTransformDialog();
+ connect(midiInputTransform, SIGNAL(hideWindow()),
+ SLOT(hideMidiInputTransform()));
+ }
+ w = midiInputTransform;
+ act = midiInputTrfAction;
+ }
+ else if (id == 2) {
+ if (!midiFilterConfig) {
+ midiFilterConfig = new MidiFilterConfig();
+ connect(midiFilterConfig, SIGNAL(hideWindow()),
+ SLOT(hideMidiFilterConfig()));
+ }
+ w = midiFilterConfig;
+ act = midiInputFilterAction;
+ }
+ else if (id == 3) {
+ if (!midiRemoteConfig) {
+ midiRemoteConfig = new MRConfig();
+ connect(midiRemoteConfig, SIGNAL(hideWindow()),
+ SLOT(hideMidiRemoteConfig()));
+ }
+ w = midiRemoteConfig;
+ act = midiRemoteAction;
+ }
+#ifdef BUILD_EXPERIMENTAL
+ else if (id == 4) {
+ if (!midiRhythmGenerator) {
+ midiRhythmGenerator = new RhythmGen();
+ connect(midiRhythmGenerator, SIGNAL(hideWindow()),
+ SLOT(hideMidiRhythmGenerator()));
+ }
+ w = midiRhythmGenerator;
+ act = midiRhythmAction;
+ }
+#endif
+ if (w) {
+ flag = !w->isVisible();
+ if (flag)
+ w->show();
+ else
+ w->hide();
+ }
+ act->setChecked(flag);
+ }
+
+void MusE::hideMitPluginTranspose()
+ {
+ midiTrpAction->setChecked(false);
+ }
+void MusE::hideMidiInputTransform()
+ {
+ midiInputTrfAction->setChecked(false);
+ }
+void MusE::hideMidiFilterConfig()
+ {
+ midiInputFilterAction->setChecked(false);
+ }
+void MusE::hideMidiRemoteConfig()
+ {
+ midiRemoteAction->setChecked(false);
+ }
+#ifdef BUILD_EXPERIMENTAL
+void MusE::hideMidiRhythmGenerator()
+ {
+ midiRhythmAction->setChecked(false);
+ }
+#endif
+
+//---------------------------------------------------------
+// processMidiInputTransformPlugins
+//---------------------------------------------------------
+
+void processMidiInputTransformPlugins(MEvent& event)
+ {
+ for (iMITPlugin i = mitPlugins.begin(); i != mitPlugins.end(); ++i)
+ (*i)->process(event);
+ }
+
+//---------------------------------------------------------
+// startMidiTransformer
+//---------------------------------------------------------
+
+void MusE::startMidiTransformer()
+ {
+ if (midiTransformerDialog == 0)
+ midiTransformerDialog = new MidiTransformerDialog;
+ midiTransformerDialog->show();
+ }
+
+//---------------------------------------------------------
+// writeStatusMidiInputTransformPlugins
+//---------------------------------------------------------
+
+void writeStatusMidiInputTransformPlugins(int level, Xml& xml)
+ {
+ for (iMITPlugin i = mitPlugins.begin(); i != mitPlugins.end(); ++i) {
+ xml.tag(level++, "mplugin name=\"%d\"");
+ (*i)->writeStatus(level, xml);
+ xml.etag(level, "mplugin");
+ }
+ }
+
+//---------------------------------------------------------
+// readStatusMidiInputTransformPlugin
+//---------------------------------------------------------
+
+void readStatusMidiInputTransformPlugin(Xml&)
+ {
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/mplugins/mitplugin.h b/attic/muse2-oom/muse2/muse/mplugins/mitplugin.h
new file mode 100644
index 00000000..a7ab3729
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mplugins/mitplugin.h
@@ -0,0 +1,39 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mitplugin.h,v 1.1.1.1.2.1 2007/01/27 14:52:43 spamatica Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MITPLUGIN_H__
+#define __MITPLUGIN_H__
+
+#include <list>
+
+class MEvent;
+class Xml;
+
+//---------------------------------------------------------
+// MITPlugin
+// midi input transform plugin
+//---------------------------------------------------------
+
+class MITPlugin {
+ public:
+ virtual ~MITPlugin(){}
+ virtual void process(MEvent& event) = 0;
+ virtual void readStatus(Xml&) {}
+ virtual void writeStatus(int, Xml&) const {}
+ };
+
+typedef std::list<MITPlugin*> MITPluginList;
+typedef MITPluginList::iterator iMITPlugin;
+
+extern MITPluginList mitPlugins;
+extern void processMidiInputTransformPlugins(MEvent&);
+extern void writeStatusMidiInputTransformPlugins(int, Xml&);
+extern void readStatusMidiInputTransformPlugin(Xml&);
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/mplugins/mittranspose.cpp b/attic/muse2-oom/muse2/muse/mplugins/mittranspose.cpp
new file mode 100644
index 00000000..4aeaf046
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mplugins/mittranspose.cpp
@@ -0,0 +1,178 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mittranspose.cpp,v 1.2.2.1 2009/05/03 04:14:00 terminator356 Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QCloseEvent>
+#include <QTimer>
+
+#include "mittranspose.h"
+#include "song.h"
+#include "mpevent.h"
+#include "pitchedit.h"
+#include "xml.h"
+#include "globals.h"
+
+MITPluginTranspose* mitPluginTranspose;
+
+//---------------------------------------------------------
+// MITPluginTranspose
+//---------------------------------------------------------
+
+MITPluginTranspose::MITPluginTranspose(QWidget* parent, Qt::WFlags fl)
+ : QWidget(parent, fl)
+ {
+ setupUi(this);
+ on = false;
+ transpose = 0;
+ trigger = 24;
+ transposeChangedFlag = false;
+ triggerKeySpinBox->setValue(trigger);
+
+ onToggled(false);
+ connect(onCheckBox, SIGNAL(toggled(bool)), SLOT(onToggled(bool)));
+ connect(triggerKeySpinBox, SIGNAL(valueChanged(int)),
+ SLOT(triggerKeyChanged(int)));
+ connect(heartBeatTimer, SIGNAL(timeout()), SLOT(noteReceived()));
+ }
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void MITPluginTranspose::closeEvent(QCloseEvent* ev)
+ {
+ emit hideWindow();
+ QWidget::closeEvent(ev);
+ }
+
+//---------------------------------------------------------
+// noteReceived
+//---------------------------------------------------------
+
+void MITPluginTranspose::noteReceived()
+ {
+ if (transposeChangedFlag)
+ {
+ // Added by Tim. p3.3.6
+ //printf("MITPluginTranspose::noteReceived\n");
+
+ transposeChanged();
+ }
+ }
+
+//---------------------------------------------------------
+// triggerKeyChanged
+//---------------------------------------------------------
+
+void MITPluginTranspose::triggerKeyChanged(int val)
+ {
+ trigger = val;
+ }
+
+//---------------------------------------------------------
+// transposeChanged
+//---------------------------------------------------------
+
+void MITPluginTranspose::transposeChanged()
+ {
+ QString s;
+ s.sprintf("%c%d", transpose >= 0 ? '-' : ' ', transpose);
+ transposeLabel->setText(s);
+ transposeChangedFlag = false;
+ }
+
+//---------------------------------------------------------
+// onToggled
+//---------------------------------------------------------
+
+void MITPluginTranspose::onToggled(bool f)
+ {
+ on = f;
+ if (!on) {
+ transpose = 0;
+ transposeChanged();
+ keyOnList.clear();
+ }
+ transposeLabel->setEnabled(on);
+ triggerKeySpinBox->setEnabled(on);
+ }
+
+//---------------------------------------------------------
+// process
+//---------------------------------------------------------
+
+void MITPluginTranspose::process(MEvent& ev)
+ {
+ if (!on || (ev.type() != 0x90))
+ return;
+ int pitch = ev.dataA();
+ if (pitch >= trigger && pitch < (trigger+12)) {
+ // process control keys
+ int diff = transpose - (pitch-trigger);
+ transpose -= diff;
+ transposeChangedFlag = true;
+ return;
+ }
+ if (ev.dataB() == 0) {
+ // Note Off
+ for (iKeyOn i = keyOnList.begin(); i != keyOnList.end(); ++i) {
+ if (i->pitch == pitch && i->channel == ev.channel()
+ && i->port == ev.port()) {
+ pitch += i->transpose;
+ keyOnList.erase(i);
+ break;
+ }
+ }
+ }
+ else {
+ // Note On
+ keyOnList.push_back(KeyOn(pitch, ev.channel(), ev.port(), transpose));
+ pitch += transpose;
+ }
+ ev.setA(pitch);
+ }
+
+//---------------------------------------------------------
+// readStatus
+//---------------------------------------------------------
+
+void MITPluginTranspose::readStatus(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::Text:
+ if (tag == "on")
+ on = xml.parseInt();
+ else if (tag == "trigger")
+ trigger = xml.parseInt();
+ else
+ xml.unknown("TransposePlugin");
+ break;
+ case Xml::TagEnd:
+ if (xml.s1() == "mplugin")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// writeStatus
+//---------------------------------------------------------
+
+void MITPluginTranspose::writeStatus(int level, Xml& xml) const
+ {
+ xml.intTag(level, "on", on);
+ xml.intTag(level, "trigger", trigger);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/mplugins/mittranspose.h b/attic/muse2-oom/muse2/muse/mplugins/mittranspose.h
new file mode 100644
index 00000000..fcbc96e3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mplugins/mittranspose.h
@@ -0,0 +1,70 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mittranspose.h,v 1.1.1.1 2003/10/27 18:52:40 wschweer Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MITTRANSPOSE_H__
+#define __MITTRANSPOSE_H__
+
+#include "mitplugin.h"
+#include "ui_mittransposebase.h"
+#include <list>
+
+class QCloseEvent;
+
+struct KeyOn {
+ unsigned char pitch;
+ unsigned char channel;
+ unsigned char port;
+ char transpose;
+ KeyOn(int a, int b, int c, int d) {
+ pitch = a;
+ transpose = d;
+ channel = b;
+ port = c;
+ }
+ };
+
+typedef std::list<KeyOn > KeyOnList;
+typedef KeyOnList::iterator iKeyOn;
+
+class Xml;
+
+//---------------------------------------------------------
+// MITPluginTranspose
+//---------------------------------------------------------
+
+class MITPluginTranspose : public QWidget, public Ui::MITTransposeBase, public MITPlugin {
+ Q_OBJECT
+
+ KeyOnList keyOnList;
+ int transpose; // current pitch offset
+ int trigger;
+ bool on;
+ bool transposeChangedFlag;
+
+ void transposeChanged();
+ virtual void closeEvent(QCloseEvent*);
+
+ signals:
+ void hideWindow();
+
+ private slots:
+ void onToggled(bool);
+ void triggerKeyChanged(int);
+ void noteReceived();
+
+ public:
+ MITPluginTranspose(QWidget* parent = 0, Qt::WFlags fl = 0);
+ virtual void process(MEvent&);
+ virtual void readStatus(Xml&);
+ virtual void writeStatus(int, Xml&) const;
+ };
+
+extern MITPluginTranspose* mitPluginTranspose;
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/mplugins/mrconfig.cpp b/attic/muse2-oom/muse2/muse/mplugins/mrconfig.cpp
new file mode 100644
index 00000000..f64384af
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mplugins/mrconfig.cpp
@@ -0,0 +1,71 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mrconfig.cpp,v 1.1.1.1 2003/10/27 18:52:43 wschweer Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "pitchedit.h"
+#include "mrconfig.h"
+#include "globals.h"
+
+#include <QCloseEvent>
+
+//---------------------------------------------------------
+// MRConfig
+// Midi Remote Control Config
+//---------------------------------------------------------
+
+MRConfig::MRConfig(QWidget* parent, Qt::WFlags fl)
+ : QWidget(parent, fl)
+ {
+ setupUi(this);
+ b1->setChecked(rcEnable);
+ sb1->setValue(rcStopNote);
+ sb2->setValue(rcRecordNote);
+ sb3->setValue(rcGotoLeftMarkNote);
+ sb4->setValue(rcPlayNote);
+
+ connect(b1, SIGNAL(toggled(bool)), SLOT(setRcEnable(bool)));
+ connect(sb1, SIGNAL(valueChanged(int)), SLOT(setRcStopNote(int)));
+ connect(sb2, SIGNAL(valueChanged(int)), SLOT(setRcRecordNote(int)));
+ connect(sb3, SIGNAL(valueChanged(int)), SLOT(setRcGotoLeftMarkNote(int)));
+ connect(sb4, SIGNAL(valueChanged(int)), SLOT(setRcPlayNote(int)));
+ }
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void MRConfig::closeEvent(QCloseEvent* ev)
+ {
+ emit hideWindow();
+ QWidget::closeEvent(ev);
+ }
+
+void MRConfig::setRcEnable(bool f)
+ {
+ rcEnable = f;
+ }
+
+void MRConfig::setRcStopNote(int val)
+ {
+ rcStopNote = val;
+ }
+
+void MRConfig::setRcRecordNote(int val)
+ {
+ rcRecordNote = val;
+ }
+
+void MRConfig::setRcGotoLeftMarkNote(int val)
+ {
+ rcGotoLeftMarkNote = val;
+ }
+
+void MRConfig::setRcPlayNote(int val)
+ {
+ rcPlayNote = val;
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/mplugins/mrconfig.h b/attic/muse2-oom/muse2/muse/mplugins/mrconfig.h
new file mode 100644
index 00000000..e829c15c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mplugins/mrconfig.h
@@ -0,0 +1,41 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mrconfig.h,v 1.1.1.1 2003/10/27 18:52:43 wschweer Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MRCONFIG_H__
+#define __MRCONFIG_H__
+
+#include "ui_mrconfigbase.h"
+
+class QCloseEvent;
+class QWidget;
+
+//---------------------------------------------------------
+// MRConfig
+//---------------------------------------------------------
+
+class MRConfig : public QWidget, public Ui::MRConfigBase {
+ Q_OBJECT
+
+ virtual void closeEvent(QCloseEvent*);
+
+ signals:
+ void hideWindow();
+
+ private slots:
+ void setRcEnable(bool);
+ void setRcStopNote(int);
+ void setRcRecordNote(int);
+ void setRcGotoLeftMarkNote(int);
+ void setRcPlayNote(int);
+
+ public:
+ MRConfig(QWidget* parent=0, Qt::WFlags fl = 0);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/mplugins/mrconfigbase.ui b/attic/muse2-oom/muse2/muse/mplugins/mrconfigbase.ui
new file mode 100644
index 00000000..ed04c334
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mplugins/mrconfigbase.ui
@@ -0,0 +1,191 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MRConfigBase</class>
+ <widget class="QWidget" name="MRConfigBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>298</width>
+ <height>249</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Midi Input Plugin: Remote Control</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QGroupBox" name="GroupBox2">
+ <property name="title">
+ <string>Activate</string>
+ </property>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QCheckBox" name="b1">
+ <property name="text">
+ <string>On</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="GroupBox1">
+ <property name="title">
+ <string>Actions</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="TextLabel1">
+ <property name="text">
+ <string>Stop</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="TextLabel2">
+ <property name="text">
+ <string>Record</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="TextLabel3">
+ <property name="text">
+ <string>Goto Left Mark</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="TextLabel4">
+ <property name="text">
+ <string>Play</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="PitchEdit" name="sb1" native="true"/>
+ </item>
+ <item row="1" column="1">
+ <widget class="PitchEdit" name="sb2" native="true"/>
+ </item>
+ <item row="2" column="1">
+ <widget class="PitchEdit" name="sb3" native="true"/>
+ </item>
+ <item row="3" column="1">
+ <widget class="PitchEdit" name="sb4" native="true"/>
+ </item>
+ <item row="0" column="2">
+ <spacer name="Spacer1">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="2">
+ <spacer name="Spacer2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="2" column="2">
+ <spacer name="Spacer3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="3" column="2">
+ <spacer name="Spacer4">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <customwidgets>
+ <customwidget>
+ <class>PitchEdit</class>
+ <extends>QWidget</extends>
+ <header>pitchedit.h</header>
+ </customwidget>
+ </customwidgets>
+ <includes>
+ <include location="local">pitchedit.h</include>
+ </includes>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/mplugins/random.cpp b/attic/muse2-oom/muse2/muse/mplugins/random.cpp
new file mode 100644
index 00000000..5360d6b8
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mplugins/random.cpp
@@ -0,0 +1,758 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: random.cpp,v 1.1.1.1 2003/10/27 18:52:39 wschweer Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//
+// This code is an adaption of the random rhythm generator taken
+// from "The JAZZ++ Midi Sequencer"
+// Copyright (C) 1994-2000 Andreas Voss and Per Sigmond, all
+// rights reserved.
+// Distributed under the GNU General Public License
+//=========================================================
+
+#if 0
+#include "random.h"
+#include "util.h"
+#include <assert.h>
+
+
+#if USE_ACG
+ACG rnd(0, 55);
+#else
+#include <stdlib.h>
+double tRandomGenerator::asDouble()
+{
+ return double(rand()) / double(RAND_MAX);
+}
+tRandomGenerator rnd;
+#endif
+
+
+// Array of probabilities
+
+tRndArray::tRndArray(int nn, int mmin, int mmax)
+{
+ int i;
+ n = nn;
+ for (i = 0; i < n; i++)
+ array[i] = mmin;
+ min = mmin;
+ max = mmax;
+ nul = min > 0 ? min : 0;
+}
+
+
+void tRndArray::SetMinMax(int mi, int ma)
+{
+ min = mi;
+ max = ma;
+ nul = min > 0 ? min : 0;
+ for (int i = 0; i < array.GetSize(); i++)
+ {
+ if (array[i] < min)
+ array[i] = min;
+ else if (array[i] > max)
+ array[i] = max;
+ }
+}
+
+tRndArray::~tRndArray()
+{
+}
+
+#ifdef FOR_MSW
+double tRndArray::operator[](double f)
+#else
+double tRndArray::operator[](double f) const
+#endif
+{
+ int i = (int)f;
+ if (i < 0)
+ i = 0;
+ else if (i >= n - 2)
+ i = n - 2;
+ tMapper map(i, i+1, array[i], array[i+1]);
+ return map(f);
+}
+
+
+tRndArray & tRndArray::operator = (const tRndArray &o)
+{
+ if (this == &o)
+ return *this;
+
+ array = o.array;
+ n = o.n;
+ min = o.min;
+ max = o.max;
+ nul = o.nul;
+ return *this;
+}
+
+
+tRndArray::tRndArray(const tRndArray &o)
+ : array(o.array)
+{
+ n = o.n;
+ min = o.min;
+ max = o.max;
+ nul = o.nul;
+}
+
+
+int tRndArray::Random()
+{
+ return Random(rnd.asDouble());
+}
+
+int tRndArray::Random(double rndval)
+{
+ double sum, dec;
+ int i;
+
+ assert(n > 0);
+
+ sum = 0.0;
+ for (i = 0; i < n; i++)
+ {
+ assert(array[i] >= 0);
+ sum += array[i];
+ }
+ if (sum <= 0)
+ return 0;
+
+ dec = sum * rndval * 0.99999;
+ assert(dec < sum);
+
+ i = 0;
+ while (dec >= 0.0)
+ {
+ dec -= array[i];
+ i++;
+ }
+ i--;
+
+ assert(i >= 0 && i < n);
+ return i;
+}
+
+
+int tRndArray::Interval(int seed)
+{
+ if (seed < 0) // initial ?
+ seed = int(rnd.asDouble() * n);
+ int delta = Random();
+ if (rnd.asDouble() < 0.5)
+ delta = -delta;
+ seed = (seed + n + delta) % n;
+ return seed;
+}
+
+int tRndArray::Random(int i)
+{
+ return rnd.asDouble() * (max - min) < array[i];
+}
+
+
+void tRndArray::SetUnion(tRndArray &o, int fuzz)
+{
+ for (int i = 0; i < n; i++)
+ {
+ int val = array[i];
+ if (o.array[i] > val)
+ val = o.array[i];
+ array[i] = Fuzz(fuzz, array[i], val);
+ }
+}
+
+
+void tRndArray::SetIntersection(tRndArray &o, int fuzz)
+{
+ for (int i = 0; i < n; i++)
+ {
+ int val = array[i];
+ if (o.array[i] < val)
+ val = o.array[i];
+ array[i] = Fuzz(fuzz, array[i], val);
+ }
+}
+
+
+void tRndArray::SetDifference(tRndArray &o, int fuzz)
+{
+ tRndArray tmp(o);
+ tmp.SetInverse(tmp.Max());
+ SetIntersection(tmp, fuzz);
+}
+
+
+void tRndArray::SetInverse(int fuzz)
+{
+ for (int i = 0; i < n; i++)
+ array[i] = Fuzz(fuzz, array[i], min + max - array[i]);
+}
+
+
+int tRndArray::Fuzz(int fuz, int v1, int v2) const
+{
+ // interpolate between v1 and v2
+ return (fuz - min) * v2 / (max - min) + (max - fuz) * v1 / (max - min);
+}
+
+
+void tRndArray::Clear()
+{
+ for (int i = 0; i < n; i++)
+ array[i] = min;
+}
+
+
+ostream & operator << (ostream &os, tRndArray const &a)
+{
+ int i;
+
+ os << a.n << " " << a.min << " " << a.max << endl;
+ for (i = 0; i < a.n; i++)
+ os << a.array[i] << " ";
+ os << endl;
+ return os;
+}
+
+
+istream & operator >> (istream &is, tRndArray &a)
+{
+ int i;
+ is >> a.n >> a.min >> a.max;
+ for (i = 0; i < a.n; i++)
+ is >> a.array[i];
+ return is;
+}
+
+
+// --------------------------------- tArrayEdit -------------------------------------
+
+// length of tickmark line
+#define TICK_LINE 0
+
+tArrayEdit::tArrayEdit(wxFrame *frame, tRndArray &ar, long xx, long yy, long ww, long hh, int sty)
+ : wxCanvas(frame, xx, yy, ww, hh),
+ array(ar),
+ n(ar.n),
+ min(ar.min),
+ max(ar.max),
+ nul(ar.nul)
+{
+ draw_bars = 0;
+ enabled = 1;
+ dragging = 0;
+ index = -1;
+ label = 0;
+ style_bits = sty;
+
+ xmin = 0;
+ xmax = n;
+
+ x = 0; // draw to topleft corner of canvas
+ y = 0;
+ w = ww;
+ h = hh;
+
+ float tw, th;
+ wxDC *dc = GetDC();
+ dc->SetFont(wxSMALL_FONT);
+ dc->GetTextExtent("123", &tw, &th);
+ if (style_bits & ARED_XTICKS)
+ {
+ // leave space for bottomline
+ h -= (int)th;
+ }
+
+ if (style_bits & (ARED_MINMAX | ARED_YTICKS))
+ {
+ // leave space to display min / max
+ x = (int)(tw + TICK_LINE);
+ w -= (int)(tw + TICK_LINE);
+ }
+
+ ynul = y + h - h * (nul - min) / (max - min);
+}
+
+
+void tArrayEdit::OnSize(int ww, int hh)
+{
+ w = ww;
+ h = hh;
+ wxCanvas::OnSize(w, h);
+ float tw, th;
+ GetDC()->GetTextExtent("123", &tw, &th);
+ if (style_bits & ARED_XTICKS)
+ h -= (int)th;
+ if (style_bits & (ARED_MINMAX | ARED_YTICKS))
+ {
+ x = (int)(tw + TICK_LINE);
+ w -= (int)(tw + TICK_LINE);
+ }
+ ynul = y + h - h * (nul - min) / (max - min);
+}
+
+tArrayEdit::~tArrayEdit()
+{
+ delete [] label;
+}
+
+void tArrayEdit::DrawBar(int i, int Qt::black)
+{
+ wxDC *dc = GetDC();
+
+ if (style_bits & ARED_LINES)
+ {
+ if (!Qt::black)
+ dc->SetPen(wxWHITE_PEN);
+
+ tMapper xmap(0, n, 0, w);
+ tMapper ymap(min, max, h, 0);
+
+ float x1 = (float)xmap(i + 0.5);
+ float y1 = (float)ymap(array[i]);
+ if (i > 0)
+ {
+ // draw line to prev position
+ float x0 = (float)xmap(i - 0.5);
+ float y0 = (float)ymap(array[i-1]);
+ dc->DrawLine(x0, y0, x1, y1);
+ }
+ if (i < n-1)
+ {
+ // draw line to next position
+ float x2 = (float)xmap(i + 1.5);
+ float y2 = (float)ymap(array[i+1]);
+ dc->DrawLine(x1, y1, x2, y2);
+ }
+
+ if (!Qt::black)
+ dc->SetPen(wxBLACK_PEN);
+ return;
+ }
+
+ int gap = 0;
+ if (style_bits & ARED_GAP)
+ {
+ gap = w / n / 6;
+ if (!gap && w / n > 3)
+ gap = 1;
+ }
+ long xbar, ybar, wbar, hbar;
+
+ wbar = w / n - 2 * gap;
+ xbar = x + i * w / n + gap;
+ hbar = h * (array[i] - nul) / (max - min);
+
+ if (style_bits & ARED_BLOCKS)
+ {
+ /*
+ ybar = ynul - hbar;
+ if (hbar < 0)
+ hbar = -hbar;
+ hbar = (hbar < 2) ? hbar : 2;
+ */
+ int hblk = 12;
+
+ ybar = ynul - hbar - hblk/2;
+ hbar = hblk;
+ if (ybar < y) {
+ int d = y - ybar;
+ ybar += d;
+ hbar -= d;
+ }
+ if (ybar + hbar > y + h) {
+ int d = (ybar + hbar) - (y + h);
+ hbar -= d;
+ }
+ if (hbar < 2)
+ hbar = 2;
+ }
+ else
+
+ if (hbar < 0)
+ {
+ ybar = ynul;
+ hbar = -hbar;
+ }
+ else
+ ybar = ynul - hbar;
+
+ if (ybar == y)
+ ++ybar, --hbar;
+
+ if (!Qt::black)
+ {
+ dc->SetBrush(wxWHITE_BRUSH);
+ dc->SetPen(wxWHITE_PEN);
+ }
+ if (wbar && hbar)
+ dc->DrawRectangle(xbar, ybar, wbar, hbar);
+ if (!Qt::black)
+ {
+ dc->SetBrush(wxBLACK_BRUSH);
+ dc->SetPen(wxBLACK_PEN);
+ }
+}
+
+const char *tArrayEdit::GetXText(int xval)
+{
+ static char buf[8];
+ sprintf(buf, "%d", xval);
+ return buf;
+}
+
+const char *tArrayEdit::GetYText(int yval)
+{
+ static char buf[8];
+ sprintf(buf, "%d", yval);
+ return buf;
+}
+
+void tArrayEdit::DrawXTicks()
+{
+ float tw, th;
+
+ if (!(style_bits & ARED_XTICKS))
+ return;
+
+ wxDC *dc = GetDC();
+ dc->SetFont(wxSMALL_FONT);
+
+ // compute tickmark x-distance
+ dc->GetTextExtent("-123", &tw, &th);
+ int max_labels = (int)(w / (tw + tw/2));
+ if (max_labels > 0)
+ {
+ int step = (xmax - xmin + 1) / max_labels;
+ if (step <= 0)
+ step = 1;
+ for (int val = xmin; val <= xmax; val += step)
+ {
+ const char *buf = GetXText(val);
+ //sprintf(buf, "%d", val);
+ dc->GetTextExtent((char *)buf, &tw, &th);
+ float yy = y + h;
+ float xx = x + w * (val - xmin) / (xmax - xmin + 1);
+ xx -= tw/2; // center text
+ xx += 0.5 * w / n; // middle of bar
+ dc->DrawText(buf, xx, yy);
+ //dc->DrawLine(x - TICK_LINE, yy, x, yy);
+ }
+ }
+
+ dc->SetFont(wxNORMAL_FONT);
+}
+
+
+void tArrayEdit::DrawYTicks()
+{
+ wxDC *dc = GetDC();
+ dc->SetFont(wxSMALL_FONT);
+
+ if (style_bits & ARED_YTICKS)
+ {
+ // compute tickmark y-distance
+ float tw, th;
+ dc->GetTextExtent("-123", &tw, &th);
+ int max_labels = (int)(h / (th + th/2));
+ if (max_labels > 0)
+ {
+ int step = (max - min) / max_labels;
+ if (step <= 0)
+ step = 1;
+ for (int val = min; val < max; val += step)
+ {
+ const char *buf = GetYText(val);
+ //sprintf(buf, "%d", val);
+ dc->GetTextExtent((char *)buf, &tw, &th);
+ float yy = y + h - h * (val - min) / (max - min) - th/2;
+ dc->DrawText(buf, x - tw - TICK_LINE, yy);
+ //dc->DrawLine(x - TICK_LINE, yy, x, yy);
+ }
+ }
+ }
+
+ else if (style_bits & ARED_MINMAX)
+ {
+ // min/max
+ float tw, th;
+ char buf[20];
+ sprintf(buf, "%d", max);
+ dc->GetTextExtent(buf, &tw, &th);
+ dc->DrawText(buf, x - tw, y);
+ sprintf(buf, "%d", min);
+ dc->GetTextExtent(buf, &tw, &th);
+ dc->DrawText(buf, x - tw, y + h - th);
+
+ }
+
+ dc->SetFont(wxNORMAL_FONT);
+
+}
+
+void tArrayEdit::DrawLabel()
+{
+ wxDC *dc = GetDC();
+ dc->SetFont(wxSMALL_FONT);
+ if (label)
+ dc->DrawText(label, x + 5, y + 2);
+ dc->SetFont(wxNORMAL_FONT);
+}
+
+
+
+void tArrayEdit::OnPaint()
+{
+ int i;
+ wxDC *dc = GetDC();
+
+ // surrounding rectangle
+ dc->Clear();
+ if (enabled)
+ dc->SetBrush(wxWHITE_BRUSH);
+ else
+ dc->SetBrush(wxGREY_BRUSH);
+ dc->SetPen(wxBLACK_PEN);
+ if (w && h)
+ dc->DrawRectangle(x, y, w, h);
+
+ // sliders
+ dc->SetBrush(wxBLACK_BRUSH);
+ for (i = 0; i < n; i++)
+ DrawBar(i, 1);
+
+ DrawXTicks();
+ DrawLabel();
+ DrawYTicks();
+ DrawNull();
+ if (draw_bars)
+ draw_bars->DrawBars();
+}
+
+
+
+void tArrayEdit::DrawNull()
+{
+ wxDC *dc = GetDC();
+ dc->SetPen(wxCYAN_PEN);
+ // draw y-null line
+ if (min < nul && nul < max)
+ dc->DrawLine(x, ynul, x+w, ynul);
+ // draw x-null line
+ if (xmin < 0 && 0 < xmax)
+ {
+ float x0 = w * (0 - xmin) / (xmax - xmin);
+ dc->DrawLine(x0, y, x0, y + h);
+ }
+ dc->SetPen(wxBLACK_PEN);
+}
+
+
+
+void tArrayEdit::SetXMinMax(int xmi, int xma)
+{
+ xmin = xmi;
+ xmax = xma;
+}
+
+int tArrayEdit::Index(wxMouseEvent &e)
+{
+ float ex, ey;
+ e.Position(&ex, &ey);
+ int i = (int)( ((short)ex - x) * n / w);
+ i = i < 0 ? 0 : i;
+ i = i >= n ? n-1 : i;
+ return i;
+}
+
+int tArrayEdit::Dragging(wxMouseEvent &e)
+{
+ if (!dragging)
+ return 0;
+
+ if (index < 0)
+ index = Index(e);
+
+ int val = nul;
+ if (e.LeftIsDown())
+ {
+ float ex, ey;
+ e.Position(&ex, &ey);
+ // $blk$ val = (int)( (y + h - (short)ey) * (max - min) / h + min);
+ val = (int)( (double)(y + h - ey) * (max - min) / h + min + 0.5);
+ val = val > max ? max : val;
+ val = val < min ? min : val;
+ }
+
+#if 0
+ {
+ // in msw ex,ey are 65536 for negative values!
+ wxDC *dc = GetDC();
+ char buf[500];
+ sprintf(buf, "x %4.0f, y %4.0f, sh %d", ex, ey, e.ShiftDown());
+ dc->DrawText(buf, 50, 50);
+ }
+#endif
+
+ if (e.ShiftDown())
+ {
+ int k;
+ for (k = 0; k < n; k++)
+ {
+ DrawBar(k, 0);
+ array[k] = val;
+ DrawBar(k, 1);
+ }
+ }
+ else if (e.ControlDown())
+ {
+ DrawBar(index, 0);
+ array[index] = val;
+ DrawBar(index, 1);
+ }
+ else
+ {
+ int i = Index(e);
+ int k = i;
+ if (i < index)
+ for (; i <= index; i++)
+ {
+ DrawBar(i, 0);
+ array[i] = val;
+ DrawBar(i, 1);
+ }
+ else
+ for (; i >= index; i--)
+ {
+ DrawBar(i, 0);
+ array[i] = val;
+ DrawBar(i, 1);
+ }
+ index = k;
+ }
+
+ return 0;
+}
+
+int tArrayEdit::ButtonDown(wxMouseEvent &e)
+{
+#ifdef wx_msw
+ CaptureMouse();
+#endif
+ dragging = 1;
+ index = Index(e);
+ Dragging(e);
+ return 0;
+}
+
+int tArrayEdit::ButtonUp(wxMouseEvent &e)
+{
+#ifdef wx_msw
+ ReleaseMouse();
+#endif
+ dragging = 0;
+ index = -1;
+ DrawLabel();
+ DrawNull();
+ return 0;
+}
+
+
+void tArrayEdit::OnEvent(wxMouseEvent &e)
+{
+ if (!enabled)
+ return;
+ if (e.ButtonDown())
+ ButtonDown(e);
+ else if (e.Dragging())
+ Dragging(e);
+ else if (e.ButtonUp())
+ ButtonUp(e);
+}
+
+void tArrayEdit::Enable(int e)
+{
+ enabled = e;
+}
+
+void tArrayEdit::SetLabel(char const *llabel)
+{
+ delete label;
+ label = copystring(llabel);
+}
+
+void tArrayEdit::SetYMinMax(int mi, int ma)
+{
+ array.SetMinMax(mi, ma);
+ ynul = y + h - h * (nul - min) / (max - min);
+}
+
+void tArrayEdit::DrawBarLine (long xx)
+{
+ wxDC *dc = GetDC ();
+ // fprintf(stderr,"x: %ld, xx: %ld\n",x,xx);
+ if (xx > x && xx + 1 < x + w)
+ {
+ dc->SetPen (wxLIGHT_GREY_PEN);
+ dc->DrawLine (xx, y + 1, xx, y + h - 2);
+ dc->SetPen (wxBLACK_PEN);
+ }
+}
+
+
+
+tRhyArrayEdit::tRhyArrayEdit(wxFrame *parent, tRndArray &array, long xx, long yy, long ww, long hh, int sty)
+ : tArrayEdit(parent, array, xx, yy, ww, hh, sty)
+{
+ steps_per_count = 4;
+ count_per_bar = 4;
+ n_bars = 4;
+}
+
+void tRhyArrayEdit::SetMeter(int s, int c, int b)
+{
+ steps_per_count = s;
+ count_per_bar = c;
+ n_bars = b;
+ array.Resize(s * c * b);
+ SetXMinMax(1, s * c * b);
+}
+
+
+void tRhyArrayEdit::DrawXTicks()
+{
+ if (!(style_bits & ARED_RHYTHM))
+ {
+ tArrayEdit::DrawXTicks();
+ return;
+ }
+
+ char buf[20];
+ float tw, th;
+
+ wxDC *dc = GetDC();
+ dc->SetFont(wxSMALL_FONT);
+
+ // tick marks
+ assert(steps_per_count && count_per_bar && n_bars);
+ int i;
+ for (i = 0; i < n; i += steps_per_count)
+ {
+ int mark = (i / steps_per_count) % count_per_bar + 1;
+ sprintf(buf, "%d", mark);
+ float yy = y + h;
+ float xx = x + (i + 0.5) * w / n;
+ dc->GetTextExtent(buf, &tw, &th);
+ xx -= tw/2.0;
+ dc->DrawText(buf, xx, yy);
+ }
+ dc->SetFont(wxNORMAL_FONT);
+}
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/mplugins/random.h b/attic/muse2-oom/muse2/muse/mplugins/random.h
new file mode 100644
index 00000000..2c9dfe5b
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mplugins/random.h
@@ -0,0 +1,192 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: random.h,v 1.1.1.1 2003/10/27 18:52:43 wschweer Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//
+// This code is an adaption of the random rhythm generator taken
+// from "The JAZZ++ Midi Sequencer"
+// Copyright (C) 1994-2000 Andreas Voss and Per Sigmond, all
+// rights reserved.
+// Distributed under the GNU General Public License
+//=========================================================
+
+#if 0
+#ifndef random_h
+#define random_h
+
+#ifndef wx_wxh
+#include "wx.h"
+#endif
+
+#ifndef _FSTREAM_H
+#include <fstream.h>
+#endif
+
+#ifndef dynarray_h
+#include "dynarray.h"
+#endif
+
+// gcc > 2.7.2 does not have ACG anymore?
+#define USE_ACG 0
+
+#if USE_ACG
+#include <ACG.h> // random generator from libg++
+extern ACG rnd;
+
+#else
+
+class tRandomGenerator
+{
+ public:
+ double asDouble();
+};
+extern tRandomGenerator rnd;
+
+#endif
+
+
+#undef min
+#undef max
+
+
+// array of probabilities
+
+class tRndArray
+{
+ friend class tArrayEdit;
+ protected:
+ tIntArray array;
+ int n; // number of elements in array
+ int nul, min, max;
+
+ public:
+ int Null() { return nul; }
+ void SetNull(int n) { nul = n; }
+ tRndArray(int n, int min, int max);
+ tRndArray & operator = (const tRndArray &);
+ tRndArray(tRndArray const &);
+
+ virtual ~tRndArray();
+ int &operator[] (int i) { return array[i]; }
+ int operator[] (int i) const { return array[i]; }
+#ifdef FOR_MSW
+ double operator[](double f);
+ float operator[](float f) {
+#else
+ double operator[](double f) const;
+ float operator[](float f) const {
+#endif
+ return (float)operator[]((double)f);
+ }
+ int Size() const { return n; }
+ int Min() const { return min; }
+ int Max() const { return max; }
+ void SetMinMax(int min, int max);
+ void Resize(int nn) { n = nn; }
+
+ friend ostream & operator << (ostream &, tRndArray const &);
+ friend istream & operator >> (istream &, tRndArray &);
+
+ int Random(); // returns index 0..n-1 (arrayvalues -> empiric distribution)
+ int Random(double rndval); // returns index 0..n-1 (arrayvalues -> empiric distribution)
+ int Random(int i); // return 0/1
+ int Interval(int seed);
+
+ void SetUnion(tRndArray &o, int fuzz);
+ void SetDifference(tRndArray &o, int fuzz);
+ void SetIntersection(tRndArray &o, int fuzz);
+ void SetInverse(int fuzz);
+ int Fuzz(int fuzz, int v1, int v2) const;
+ void Clear();
+};
+
+
+#define ARED_GAP 1
+#define ARED_XTICKS 2
+#define ARED_YTICKS 4
+#define ARED_MINMAX 8
+#define ARED_RHYTHM 16
+#define ARED_BLOCKS 32
+#define ARED_LINES 64
+
+
+class tArrayEditDrawBars {
+ public:
+ virtual void DrawBars() = 0;
+};
+
+
+class tArrayEdit : public wxCanvas
+{
+protected:
+ // paint position
+ long x, y, w, h, ynul;
+ void DrawBar(int i, int Qt::black);
+
+ int dragging; // Dragging-Event valid
+ int index; // ctrl down: drag this one
+
+ tRndArray &array;
+ int &n, &min, &max, &nul; // shorthand for array.n, array.min, ...
+ char *label;
+ tArrayEditDrawBars *draw_bars;
+
+ // array size is mapped to this range for x-tick marks
+ int xmin, xmax;
+
+ virtual void DrawXTicks();
+ virtual void DrawYTicks();
+ virtual void DrawLabel();
+ virtual void DrawNull();
+ int Index(wxMouseEvent &e);
+
+ int enabled;
+ int style_bits;
+
+ virtual const char *GetXText(int xval); // Text for x-tickmarks
+ virtual const char *GetYText(int yval); // Text for y-tickmarks
+
+
+public:
+ tArrayEdit(wxFrame *parent, tRndArray &array, long xx, long yy, long ww, long hh, int style_bits = (ARED_GAP | ARED_XTICKS));
+ virtual ~tArrayEdit();
+
+ virtual void OnPaint();
+ virtual void OnSize(int ww, int hh);
+ virtual void OnEvent(wxMouseEvent &e);
+ virtual int Dragging(wxMouseEvent &);
+ virtual int ButtonDown(wxMouseEvent &);
+ virtual int ButtonUp(wxMouseEvent &);
+
+ virtual void SetLabel(char const *llabel);
+ void Enable(int enable = 1);
+ void SetStyle(int style) { style_bits = style; }
+ // min and max value in array (both values inclusive)
+ void SetYMinMax(int min, int max);
+ // for display x-axis only, does not resize the array (both values inclusive)
+ void SetXMinMax(int xmin, int xmax);
+ void DrawBarLine (long xx);
+ void SetDrawBars(tArrayEditDrawBars *x) { draw_bars = x; }
+ void Init() {}
+};
+
+
+
+class tRhyArrayEdit : public tArrayEdit
+{
+ int steps_per_count;
+ int count_per_bar;
+ int n_bars;
+ protected:
+ virtual void DrawXTicks();
+ public:
+ tRhyArrayEdit(wxFrame *parent, tRndArray &array, long xx, long yy, long ww, long hh, int style_bits = (ARED_GAP | ARED_XTICKS | ARED_RHYTHM));
+ void SetMeter(int steps_per_count, int count_per_bar, int n_bars);
+};
+
+
+#endif
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/mplugins/rhythm.cpp b/attic/muse2-oom/muse2/muse/mplugins/rhythm.cpp
new file mode 100644
index 00000000..0fe2ba16
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mplugins/rhythm.cpp
@@ -0,0 +1,514 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: rhythm.cpp,v 1.1.1.1 2003/10/27 18:52:49 wschweer Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//
+// This code is an adaption of the random rhythm generator taken
+// from "The JAZZ++ Midi Sequencer"
+// Copyright (C) 1994-2000 Andreas Voss and Per Sigmond, all
+// rights reserved.
+// Distributed under the GNU General Public License
+//=========================================================
+
+#include "rhythm.h"
+
+//---------------------------------------------------------
+// RhythmGen
+//---------------------------------------------------------
+
+RhythmGen::RhythmGen(QWidget* parent, Qt::WFlags fo)
+ : QMainWindow(parent, fo)
+ {
+ setupUi(this);
+ }
+RhythmGen::~RhythmGen()
+ {
+ }
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void RhythmGen::closeEvent(QCloseEvent* ev)
+ {
+ emit hideWindow();
+ QWidget::closeEvent(ev);
+ }
+
+
+
+#if 0
+/****************************************************************************
+** Form implementation generated from reading ui file 'rhythm.ui'
+**
+** Created: Tue Feb 26 13:43:04 2002
+** by: The User Interface Compiler (uic)
+**
+** WARNING! All changes made in this file will be lost!
+****************************************************************************/
+#include "rhythm.h"
+
+#include <QCloseEvent>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+#include <QVariant>
+#include <QCheckBox>
+#include <QFrame>
+#include <QLabel>
+#include <QLCDNumber>
+#include <QPushButton>
+#include <QSlider>
+#include <QToolButton>
+#include <QLayout>
+#include <QToolTip>
+#include <QImage>
+#include <QPixmap>
+
+static const char* const image0_data[] = {
+"16 16 56 1",
+". c None",
+"F c #000000",
+"L c #000101",
+"E c #010304",
+"C c #06101d",
+"j c #071728",
+"w c #07182a",
+"1 c #071c2c",
+"0 c #081c2d",
+"e c #081e31",
+"a c #0a121f",
+"Z c #0a1929",
+"Q c #0a263b",
+"T c #0a273b",
+"z c #0e97bf",
+"s c #0ea0c5",
+"K c #0f5d7e",
+"B c #105375",
+"G c #114760",
+"N c #1197b9",
+"x c #124c6d",
+"# c #124d6f",
+"u c #1290b5",
+"v c #135476",
+"h c #1390b4",
+"Y c #14839f",
+"b c #155474",
+"i c #155678",
+"o c #155a7a",
+"J c #159abc",
+"d c #17587a",
+"V c #178eac",
+"f c #194a6a",
+"r c #19b3ce",
+"k c #1b4b6a",
+"p c #1b4f6f",
+"A c #1ca2c3",
+"D c #20374f",
+"P c #2294b1",
+"I c #22bad1",
+"S c #2a98b3",
+"U c #2cc7d5",
+"n c #3cd7e1",
+"O c #43d5de",
+"t c #48dfe9",
+"X c #58acc5",
+"m c #59c3da",
+"q c #71d1e0",
+"W c #80c2db",
+"c c #819eba",
+"H c #9ddeee",
+"M c #cdebf6",
+"g c #ddeff8",
+"y c #e2f0f9",
+"R c #fdfafd",
+"l c #fdfcfd",
+"................",
+"................",
+".......#a.......",
+"......bcde......",
+".....fcghij.....",
+"....kclmnhoj....",
+"...pclqrstuvw...",
+"..xcymrzzsnABC..",
+".BDEFGHzIJKLFFF.",
+".....BMNOPQ.....",
+".....BRNOST.....",
+".....BMNUVT.....",
+".....BWXIYF.....",
+".....BZ01FF.....",
+"................",
+"................"};
+
+static const char* const image1_data[] = {
+"16 16 50 1",
+". c None",
+"E c #010001",
+"O c #03060c",
+"U c #050b12",
+"u c #05151e",
+"S c #060f19",
+"m c #06141d",
+"q c #06141f",
+"h c #071620",
+"D c #0b293e",
+"c c #0d324c",
+"v c #0d3652",
+"A c #0e5775",
+"J c #0e8fb6",
+"x c #0e94b9",
+"r c #0e97bf",
+"Q c #0e9ec3",
+"n c #0eadcb",
+"R c #0fa0c4",
+"N c #106589",
+"V c #10698f",
+"B c #114560",
+"# c #124d6f",
+"z c #1299bb",
+"C c #144059",
+"T c #14a5c9",
+"K c #15c1da",
+"b c #18425f",
+"y c #1bbad1",
+"M c #1ca2c3",
+"t c #1f95b2",
+"a c #254a64",
+"p c #2695b1",
+"l c #2b91ae",
+"F c #337f9e",
+"o c #40d1db",
+"s c #46dbe6",
+"L c #48dfe9",
+"I c #54bdd7",
+"j c #5fc0d8",
+"g c #64a3bd",
+"k c #8fcce2",
+"d c #a0cbdf",
+"H c #a7dcec",
+"w c #bfdfee",
+"f c #d3e5f0",
+"G c #dfeff8",
+"i c #e0f1fb",
+"e c #eff3fc",
+"P c #ffffff",
+"................",
+"................",
+".....###abc.....",
+".....#defgh.....",
+".....#ijklm.....",
+".....#enopq.....",
+".....airstu.....",
+".v##aawxyzABCDE.",
+"..vFGHIJrKLMNO..",
+"...vFPQrRLMNS...",
+"....vFPTLMNU....",
+".....vFGMNU.....",
+"......vVNS......",
+".......vO.......",
+"................",
+"................"};
+
+
+/*
+ * Constructs a RhythmGenerator which is a child of 'parent', with the
+ * name 'name' and widget flags set to 'f'.
+ *
+ * The dialog will by default be modeless, unless you set 'modal' to
+ * TRUE to construct a modal dialog.
+ */
+RhythmGenerator::RhythmGenerator( QWidget* parent, const char* name, bool modal, Qt::WFlags fl )
+ : QDialog( parent, name, modal, fl )
+{
+ QPixmap image0( ( const char** ) image0_data );
+ QPixmap image1( ( const char** ) image1_data );
+ if ( !name )
+ setName( "RhythmGenerator" );
+ resize( 500, 777 );
+ setCaption( trUtf8( "Form3" ) );
+ RhythmGeneratorLayout = new Q3VBoxLayout( this, 11, 6, "RhythmGeneratorLayout");
+
+ Frame6 = new QFrame( this);
+ Frame6->setFrameShape( QFrame::StyledPanel );
+ Frame6->setFrameShadow( QFrame::Raised );
+ Frame6Layout = new Q3VBoxLayout( Frame6, 11, 6, "Frame6Layout");
+
+ TextLabel1 = new QLabel( Frame6, "TextLabel1" );
+ QFont TextLabel1_font( TextLabel1->font() );
+ TextLabel1_font.setBold( TRUE );
+ TextLabel1_font.setUnderline( TRUE );
+ TextLabel1->setFont( TextLabel1_font );
+ TextLabel1->setText( trUtf8( "Instrument Settings:" ) );
+ Frame6Layout->addWidget( TextLabel1 );
+
+ Layout17 = new Q3HBoxLayout( 0, 0, 15, "Layout17");
+
+ Layout16 = new Q3VBoxLayout( 0, 0, 6, "Layout16");
+
+ InstrumentListLabel = new QLabel( Frame6, "InstrumentListLabel" );
+ InstrumentListLabel->setText( trUtf8( "Instrument" ) );
+ Layout16->addWidget( InstrumentListLabel );
+
+ InstrumentList = new Q3ListBox( Frame6, "InstrumentList" );
+ InstrumentList->insertItem( trUtf8( "Hi-Hat" ) );
+ InstrumentList->setMinimumSize( QSize( 150, 70 ) );
+ Layout16->addWidget( InstrumentList );
+
+ Layout11 = new Q3HBoxLayout( 0, 0, 2, "Layout11");
+
+ InstrumentUp = new QToolButton( Frame6, "InstrumentUp" );
+ InstrumentUp->setMinimumSize( QSize( 40, 20 ) );
+ InstrumentUp->setText( trUtf8( "" ) );
+ InstrumentUp->setPixmap( image0 );
+ Layout11->addWidget( InstrumentUp );
+
+ InstrumentDown = new QToolButton( Frame6, "InstrumentDown" );
+ InstrumentDown->setMinimumSize( QSize( 40, 20 ) );
+ InstrumentDown->setText( trUtf8( "" ) );
+ InstrumentDown->setPixmap( image1 );
+ Layout11->addWidget( InstrumentDown );
+
+ InstrumentAdd = new QToolButton( Frame6, "InstrumentAdd" );
+ InstrumentAdd->setMinimumSize( QSize( 40, 20 ) );
+ InstrumentAdd->setText( trUtf8( "add" ) );
+ Layout11->addWidget( InstrumentAdd );
+
+ InstrumentDel = new QToolButton( Frame6, "InstrumentDel" );
+ InstrumentDel->setMinimumSize( QSize( 40, 20 ) );
+ InstrumentDel->setText( trUtf8( "delete" ) );
+ Layout11->addWidget( InstrumentDel );
+ Layout16->addLayout( Layout11 );
+ Layout17->addLayout( Layout16 );
+
+ Layout20 = new Q3VBoxLayout( 0, 0, 6, "Layout20");
+
+ StepsLabel = new QLabel( Frame6, "StepsLabel" );
+ StepsLabel->setText( trUtf8( "steps/count" ) );
+ Layout20->addWidget( StepsLabel );
+
+ StepsLayout = new Q3HBoxLayout( 0, 0, 6, "StepsLayout");
+
+ StepsSlider = new QSlider( Frame6, "StepsSlider" );
+ StepsSlider->setMaxValue( 16 );
+ StepsSlider->setValue( 4 );
+ StepsSlider->setOrientation( Qt::Horizontal );
+ StepsLayout->addWidget( StepsSlider );
+
+ StepsNumber = new QLCDNumber( Frame6, "StepsNumber" );
+ StepsNumber->setPaletteBackgroundColor( QColor( 212, 212, 192 ) );
+ StepsNumber->setLineWidth( 1 );
+ StepsNumber->setNumDigits( 2 );
+ StepsNumber->setSegmentStyle( QLCDNumber::Flat );
+ StepsNumber->setProperty( "value", 4 );
+ StepsLayout->addWidget( StepsNumber );
+ Layout20->addLayout( StepsLayout );
+
+ CountLabel = new QLabel( Frame6, "CountLabel" );
+ CountLabel->setText( trUtf8( "count/bar" ) );
+ Layout20->addWidget( CountLabel );
+
+ CountLayout = new Q3HBoxLayout( 0, 0, 6, "CountLayout");
+
+ CountSlider = new QSlider( Frame6, "CountSlider" );
+ CountSlider->setMaxValue( 16 );
+ CountSlider->setValue( 4 );
+ CountSlider->setOrientation( Qt::Horizontal );
+ CountLayout->addWidget( CountSlider );
+
+ CountNumber = new QLCDNumber( Frame6, "CountNumber" );
+ CountNumber->setPaletteBackgroundColor( QColor( 212, 212, 192 ) );
+ CountNumber->setNumDigits( 2 );
+ CountNumber->setSegmentStyle( QLCDNumber::Flat );
+ CountNumber->setProperty( "value", 4 );
+ CountLayout->addWidget( CountNumber );
+ Layout20->addLayout( CountLayout );
+
+ BarsLabel = new QLabel( Frame6, "BarsLabel" );
+ BarsLabel->setText( trUtf8( "# bars" ) );
+ Layout20->addWidget( BarsLabel );
+
+ BarsLayout = new Q3HBoxLayout( 0, 0, 6, "BarsLayout");
+
+ BarsSlider = new QSlider( Frame6, "BarsSlider" );
+ BarsSlider->setMaxValue( 16 );
+ BarsSlider->setValue( 1 );
+ BarsSlider->setOrientation( Qt::Horizontal );
+ BarsLayout->addWidget( BarsSlider );
+
+ BarsNumber = new QLCDNumber( Frame6, "BarsNumber" );
+ BarsNumber->setPaletteBackgroundColor( QColor( 212, 212, 192 ) );
+ BarsNumber->setNumDigits( 2 );
+ BarsNumber->setSegmentStyle( QLCDNumber::Flat );
+ BarsNumber->setProperty( "value", 1 );
+ BarsLayout->addWidget( BarsNumber );
+ Layout20->addLayout( BarsLayout );
+ Layout17->addLayout( Layout20 );
+ Frame6Layout->addLayout( Layout17 );
+ RhythmGeneratorLayout->addWidget( Frame6 );
+
+ Layout27 = new Q3HBoxLayout( 0, 0, 15, "Layout27");
+
+ Frame5 = new QFrame( this );
+ Frame5->setFrameShape( QFrame::StyledPanel );
+ Frame5->setFrameShadow( QFrame::Raised );
+ Frame5Layout = new Q3VBoxLayout( Frame5, 11, 6, "Frame5Layout");
+
+ TextLabel2 = new QLabel( Frame5, "TextLabel2" );
+ QFont TextLabel2_font( TextLabel2->font() );
+ TextLabel2_font.setBold( TRUE );
+ TextLabel2_font.setUnderline( TRUE );
+ TextLabel2->setFont( TextLabel2_font );
+ TextLabel2->setText( trUtf8( "Group Settings:" ) );
+ Frame5Layout->addWidget( TextLabel2 );
+
+ Layout20_2 = new Q3HBoxLayout( 0, 0, 15, "Layout20_2");
+
+ GroupListLayout = new Q3VBoxLayout( 0, 0, 6, "GroupListLayout");
+
+ GroupListLabel = new QLabel( Frame5, "GroupListLabel" );
+ GroupListLabel->setText( trUtf8( "Group" ) );
+ GroupListLayout->addWidget( GroupListLabel );
+
+ GroupList = new Q3ListBox( Frame5, "GroupList" );
+ GroupList->insertItem( trUtf8( "Group 1" ) );
+ GroupList->insertItem( trUtf8( "Group 2" ) );
+ GroupList->insertItem( trUtf8( "Group 3" ) );
+ GroupList->insertItem( trUtf8( "Group 4" ) );
+ GroupList->insertItem( trUtf8( "Group 5" ) );
+ GroupList->setMinimumSize( QSize( 150, 90 ) );
+ GroupListLayout->addWidget( GroupList );
+ Layout20_2->addLayout( GroupListLayout );
+
+ Layout19 = new Q3VBoxLayout( 0, 0, 6, "Layout19");
+
+ ContribLabel = new QLabel( Frame5, "ContribLabel" );
+ ContribLabel->setText( trUtf8( "contrib" ) );
+ Layout19->addWidget( ContribLabel );
+
+ ContribLayout = new Q3HBoxLayout( 0, 0, 6, "ContribLayout");
+
+ ContribSlider = new QSlider( Frame5, "ContribSlider" );
+ ContribSlider->setMinimumSize( QSize( 100, 0 ) );
+ ContribSlider->setMaxValue( 100 );
+ ContribSlider->setOrientation( Qt::Horizontal );
+ ContribLayout->addWidget( ContribSlider );
+
+ ContribNumber = new QLCDNumber( Frame5, "ContribNumber" );
+ ContribNumber->setPaletteBackgroundColor( QColor( 212, 212, 192 ) );
+ ContribNumber->setNumDigits( 3 );
+ ContribNumber->setSegmentStyle( QLCDNumber::Flat );
+ ContribLayout->addWidget( ContribNumber );
+ Layout19->addLayout( ContribLayout );
+
+ ListenLabel = new QLabel( Frame5, "ListenLabel" );
+ ListenLabel->setText( trUtf8( "listen" ) );
+ Layout19->addWidget( ListenLabel );
+
+ ListenLayout = new Q3HBoxLayout( 0, 0, 6, "ListenLayout");
+
+ ListenSlider = new QSlider( Frame5, "ListenSlider" );
+ ListenSlider->setMinimumSize( QSize( 100, 0 ) );
+ ListenSlider->setMinValue( -99 );
+ ListenSlider->setMaxValue( 100 );
+ ListenSlider->setOrientation( Qt::Horizontal );
+ ListenLayout->addWidget( ListenSlider );
+
+ ListenNumber = new QLCDNumber( Frame5, "ListenNumber" );
+ ListenNumber->setPaletteBackgroundColor( QColor( 212, 212, 192 ) );
+ ListenNumber->setNumDigits( 3 );
+ ListenNumber->setSegmentStyle( QLCDNumber::Flat );
+ ListenLayout->addWidget( ListenNumber );
+ Layout19->addLayout( ListenLayout );
+ Layout20_2->addLayout( Layout19 );
+ Frame5Layout->addLayout( Layout20_2 );
+
+ RandomizeCheck = new QCheckBox( Frame5, "RandomizeCheck" );
+ RandomizeCheck->setText( trUtf8( "Randomize" ) );
+ Frame5Layout->addWidget( RandomizeCheck );
+ Layout27->addWidget( Frame5 );
+
+ Frame5_2 = new QFrame( this );
+ Frame5_2->setFrameShape( QFrame::StyledPanel );
+ Frame5_2->setFrameShadow( QFrame::Raised );
+ Frame5_2Layout = new Q3VBoxLayout( Frame5_2, 11, 6, "Frame5_2Layout");
+
+ TextLabel3 = new QLabel( Frame5_2, "TextLabel3" );
+ QFont TextLabel3_font( TextLabel3->font() );
+ TextLabel3_font.setBold( TRUE );
+ TextLabel3_font.setUnderline( TRUE );
+ TextLabel3->setFont( TextLabel3_font );
+ TextLabel3->setText( trUtf8( "Rhythm Style:" ) );
+ Frame5_2Layout->addWidget( TextLabel3 );
+
+ Layout21 = new Q3VBoxLayout( 0, 0, 2, "Layout21");
+
+ ToolButton7 = new QToolButton( Frame5_2, "ToolButton7" );
+ ToolButton7->setText( trUtf8( "Clear" ) );
+ Layout21->addWidget( ToolButton7 );
+
+ ToolButton8 = new QToolButton( Frame5_2, "ToolButton8" );
+ ToolButton8->setText( trUtf8( "Open..." ) );
+ Layout21->addWidget( ToolButton8 );
+
+ ToolButton9 = new QToolButton( Frame5_2, "ToolButton9" );
+ ToolButton9->setText( trUtf8( "Save" ) );
+ Layout21->addWidget( ToolButton9 );
+
+ ToolButton10 = new QToolButton( Frame5_2, "ToolButton10" );
+ ToolButton10->setText( trUtf8( "Save as..." ) );
+ Layout21->addWidget( ToolButton10 );
+ Frame5_2Layout->addLayout( Layout21 );
+
+ Layout22 = new Q3VBoxLayout( 0, 0, 2, "Layout22");
+
+ ToolButton5 = new QToolButton( Frame5_2, "ToolButton5" );
+ ToolButton5->setText( trUtf8( "Generate" ) );
+ Layout22->addWidget( ToolButton5 );
+
+ ToolButton6 = new QToolButton( Frame5_2, "ToolButton6" );
+ ToolButton6->setText( trUtf8( "Close" ) );
+ Layout22->addWidget( ToolButton6 );
+ Frame5_2Layout->addLayout( Layout22 );
+ Layout27->addWidget( Frame5_2 );
+ RhythmGeneratorLayout->addLayout( Layout27 );
+
+ Layout29 = new Q3HBoxLayout( 0, 0, 6, "Layout29");
+
+ Frame6_2 = new QFrame( this );
+ Frame6_2->setMinimumSize( QSize( 200, 150 ) );
+ Frame6_2->setFrameShape( QFrame::StyledPanel );
+ Frame6_2->setFrameShadow( QFrame::Raised );
+ Layout29->addWidget( Frame6_2 );
+
+ Frame7 = new QFrame( this );
+ Frame7->setMinimumSize( QSize( 200, 150 ) );
+ Frame7->setFrameShape( QFrame::StyledPanel );
+ Frame7->setFrameShadow( QFrame::Raised );
+ Layout29->addWidget( Frame7 );
+ RhythmGeneratorLayout->addLayout( Layout29 );
+
+ Frame8 = new QFrame( this );
+ Frame8->setMinimumSize( QSize( 400, 150 ) );
+ Frame8->setFrameShape( QFrame::StyledPanel );
+ Frame8->setFrameShadow( QFrame::Raised );
+ RhythmGeneratorLayout->addWidget( Frame8 );
+
+ // signals and slots connections
+ connect( StepsSlider, SIGNAL( valueChanged(int) ), StepsNumber, SLOT( display(int) ) );
+ connect( CountSlider, SIGNAL( valueChanged(int) ), CountNumber, SLOT( display(int) ) );
+ connect( BarsSlider, SIGNAL( valueChanged(int) ), BarsNumber, SLOT( display(int) ) );
+ connect( ContribSlider, SIGNAL( valueChanged(int) ), ContribNumber, SLOT( display(int) ) );
+ connect( ListenSlider, SIGNAL( valueChanged(int) ), ListenNumber, SLOT( display(int) ) );
+ connect( InstrumentDel, SIGNAL( pressed() ), InstrumentList, SLOT( clearSelection() ) );
+}
+
+/*
+ * Destroys the object and frees any allocated resources
+ */
+RhythmGenerator::~RhythmGenerator()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/mplugins/rhythm.h b/attic/muse2-oom/muse2/muse/mplugins/rhythm.h
new file mode 100644
index 00000000..eb8d00dd
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mplugins/rhythm.h
@@ -0,0 +1,198 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: rhythm.h,v 1.1.1.1 2003/10/27 18:52:44 wschweer Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//
+// This code is an adaption of the random rhythm generator taken
+// from "The JAZZ++ Midi Sequencer"
+// Copyright (C) 1994-2000 Andreas Voss and Per Sigmond, all
+// rights reserved.
+// Distributed under the GNU General Public License
+//=========================================================
+
+#ifndef __RHYTHM_H__
+#define __RHYTHM_H__
+
+#include "ui_rhythmbase.h"
+
+#include <QMainWindow>
+
+class QCloseEvent;
+
+class tTrack;
+class tEventWin;
+class tSong;
+class tBarInfo;
+
+#define MAX_GROUPS 5
+#define MAX_KEYS 20
+
+class Xml;
+
+#if 0
+//---------------------------------------------------------
+// tRhyGroup
+//---------------------------------------------------------
+
+struct tRhyGroup {
+ int contrib;
+ int listen;
+
+ tRhyGroup() {
+ listen = 0;
+ contrib = 0;
+ }
+// void write(int, Xml&);
+// void read(Xml&);
+ };
+
+//---------------------------------------------------------
+// tRhyGroups
+//---------------------------------------------------------
+
+struct tRhyGroups {
+ tRhyGroup g[MAX_GROUPS];
+ tRhyGroup& operator [] (int i) { return g[i]; }
+
+// void write(int, Xml&);
+// void read(Xml&);
+ };
+
+//---------------------------------------------------------
+// tRhythm
+//---------------------------------------------------------
+
+class tRhythm
+ {
+ friend class tRhythmWin;
+
+ char* label;
+
+// tRndArray rhythm;
+// tRndArray length;
+// tRndArray veloc;
+
+ int steps_per_count;
+ int count_per_bar;
+ int n_bars;
+ int keys[MAX_KEYS];
+ int n_keys;
+ int mode;
+ int parm;
+
+ int randomize;
+ tRhyGroups groups;
+// tRndArray history;
+
+ // set by GenInit()
+ long start_clock;
+ long next_clock;
+
+// void GenGroup(tRndArray& out, int grp, tBarInfo &bi, tRhythm *rhy[], int n_rhy);
+ int Clock2i(long clock, tBarInfo &bi) const;
+ int ClocksPerStep(tBarInfo &bi) const;
+
+ public:
+ tRhythm(int key);
+ tRhythm(const tRhythm &o);
+ tRhythm & operator= (const tRhythm &o);
+ virtual ~tRhythm();
+
+ char const * GetLabel() { return label; }
+ void SetLabel(char const *);
+
+ void Generate(tTrack *track, long fr_clock, long to_clock, long ticks_per_bar);
+ void Generate(tTrack *track, tBarInfo &bi, tRhythm *rhy[], int n_rhy);
+ void GenInit(long start_clock);
+ void GenerateEvent(tTrack *track, long clock, short vel, short len);
+
+ void write(int, Xml&);
+ void read(Xml&);
+ };
+#endif
+
+//---------------------------------------------------------
+// RhythmGen
+//---------------------------------------------------------
+
+class RhythmGen : public QMainWindow, public Ui::RhythmBase
+ {
+ Q_OBJECT
+#if 0
+ wxPanel *inst_panel;
+ wxText *label;
+ wxSlider *steps_per_count;
+ wxSlider *count_per_bar;
+ wxSlider *n_bars;
+ wxListBox *instrument_list;
+ wxCheckBox *rand_checkbox;
+
+ wxPanel *group_panel;
+ wxListBox *group_list;
+ wxSlider *group_contrib;
+ wxSlider *group_listen;
+ int act_group;
+
+ tArrayEdit *length_edit;
+ tArrayEdit *veloc_edit;
+ tRhyArrayEdit *rhythm_edit;
+
+ enum { MAX_INSTRUMENTS = 20 };
+ tRhythm *instruments[MAX_INSTRUMENTS];
+ int n_instruments;
+ int act_instrument; // -1 if none
+
+ // this one is edited and copied from/to instruments[i]
+ tRhythm edit;
+
+ // ignore Updates while creating the window (motif)
+ Bool in_create;
+
+ // callbacks
+ static void ItemCallback(wxItem& item, wxCommandEvent& event);
+ static void SelectInstr(wxListBox& list, wxCommandEvent& event);
+ static void SelectGroup(wxListBox& list, wxCommandEvent& event);
+ static void Add(wxButton &but, wxCommandEvent& event);
+ static void Del(wxButton &but, wxCommandEvent& event);
+ static void Generate(wxButton &but, wxCommandEvent& event);
+ static void Help();
+
+ void Instrument2Win(int i = -1); // instrument[act_instrument] -> win
+ void Win2Instrument(int i = -1); // win -> instrument[act_instrument]
+ void AddInstrumentDlg();
+ void AddInstrument(tRhythm *r);
+ void DelInstrument();
+
+ tEventWin *event_win;
+ tSong *song;
+
+ void RndEnable();
+
+ char *default_filename;
+ int has_changed;
+ wxToolBar *tool_bar;
+ float tb_width, tb_height;
+
+ void UpInstrument();
+ void DownInstrument();
+ void InitInstrumentList();
+#endif
+ virtual void closeEvent(QCloseEvent*);
+
+ signals:
+ void hideWindow();
+
+ public:
+// virtual void OnMenuCommand(int id);
+// virtual void OnSize(int w, int h);
+ RhythmGen(QWidget* parent = 0, Qt::WFlags fo = Qt::Window);
+ virtual ~RhythmGen();
+// void OnPaint();
+// void GenRhythm();
+// bool OnClose();
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/mplugins/rhythmbase.ui b/attic/muse2-oom/muse2/muse/mplugins/rhythmbase.ui
new file mode 100644
index 00000000..21373690
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mplugins/rhythmbase.ui
@@ -0,0 +1,1095 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>RhythmBase</class>
+ <widget class="QMainWindow" name="RhythmBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>465</width>
+ <height>605</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Random Rhythm Generator</string>
+ </property>
+ <widget class="QWidget" name="widget">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>59</y>
+ <width>465</width>
+ <height>546</height>
+ </rect>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>6</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="1" column="0">
+ <widget class="QGroupBox" name="GroupBox1">
+ <property name="title">
+ <string>Instrument Properties</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="1" column="2">
+ <widget class="QLabel" name="TextLabel2_3_2">
+ <property name="text">
+ <string>counts/bar</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLabel" name="TextLabel3_2">
+ <property name="text">
+ <string>steps/count</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QLabel" name="TextLabel1_2_2">
+ <property name="text">
+ <string># bars</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="lineInstrument_2">
+ <property name="text">
+ <string>test</string>
+ </property>
+ <property name="dragEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="5">
+ <widget class="QSpinBox" name="spinboxContrib_2">
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <widget class="QLabel" name="labelContrib_2">
+ <property name="text">
+ <string>contrib</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <widget class="QCheckBox" name="checkRandomize_2">
+ <property name="text">
+ <string>randomize</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ <property name="tristate">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="comboGroupSel_2">
+ <item>
+ <property name="text">
+ <string/>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Group 1</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Group 2</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Group 3</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Group 4</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Group 5</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QSpinBox" name="spinBoxSteps_2">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>16</number>
+ </property>
+ <property name="value">
+ <number>4</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QSpinBox" name="spinboxBars_2">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>16</number>
+ </property>
+ <property name="value">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="4">
+ <widget class="QLabel" name="labelListen_2">
+ <property name="text">
+ <string>listen</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="TextLabel1_4">
+ <property name="text">
+ <string>Instrument</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QSpinBox" name="spinboxCounts_2">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>16</number>
+ </property>
+ <property name="value">
+ <number>4</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="5">
+ <widget class="QSpinBox" name="spinboxListen_2">
+ <property name="minimum">
+ <number>-100</number>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="value">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="TextLabel1_3_2">
+ <property name="text">
+ <string>Group</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="buttonNew_2">
+ <property name="toolTip">
+ <string>create new entry</string>
+ </property>
+ <property name="whatsThis">
+ <string>pressing the New button you create a new entry
+in the MusE list of defined controllers</string>
+ </property>
+ <property name="text">
+ <string>&amp;New</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonDelete_2">
+ <property name="toolTip">
+ <string>delete selected entry</string>
+ </property>
+ <property name="text">
+ <string>&amp;Delete</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="Spacer1_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonUp_2">
+ <property name="text">
+ <string>Up</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonDown_2">
+ <property name="text">
+ <string>Down</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QTreeWidget" name="viewInstrument">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>150</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>32767</width>
+ <height>150</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>list of defined controllers</string>
+ </property>
+ <property name="whatsThis">
+ <string>This is the MusE list of defined controllers.</string>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Sunken</enum>
+ </property>
+ <column>
+ <property name="text">
+ <string>Instrument </string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Group</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>steps/count </string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>counts/bar</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string># bars</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>contrib</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>listen</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QSplitter" name="Splitter3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <widget class="QSplitter" name="Splitter2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <widget class="QFrame" name="Frame3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>50</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ </widget>
+ <widget class="QFrame" name="Frame4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>50</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ </widget>
+ </widget>
+ <widget class="QFrame" name="Frame5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>150</height>
+ </size>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <widget class="QLabel" name="textLabel1">
+ <property name="geometry">
+ <rect>
+ <x>64</x>
+ <y>26</y>
+ <width>250</width>
+ <height>90</height>
+ </rect>
+ </property>
+ <property name="text">
+ <string>&lt;b&gt;Notice!&lt;/b&gt;&lt;br&gt;
+Random Rhythm Generator is not enabled yet!</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </widget>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QToolBar" name="toolBar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>111</width>
+ <height>38</height>
+ </rect>
+ </property>
+ <property name="label">
+ <string>Tools</string>
+ </property>
+ <addaction name="fileNewAction"/>
+ <addaction name="fileOpenAction"/>
+ <addaction name="fileSaveAction"/>
+ </widget>
+ <widget class="QMenuBar" name="menubar">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>465</width>
+ <height>21</height>
+ </rect>
+ </property>
+ <widget class="QMenu" name="fileMenu">
+ <property name="title">
+ <string>&amp;File</string>
+ </property>
+ <addaction name="fileNewAction"/>
+ <addaction name="fileOpenAction"/>
+ <addaction name="fileSaveAction"/>
+ <addaction name="fileSaveAsAction"/>
+ <addaction name="separator"/>
+ <addaction name="filePrintAction"/>
+ <addaction name="separator"/>
+ <addaction name="fileExitAction"/>
+ </widget>
+ <widget class="QMenu" name="editMenu">
+ <property name="title">
+ <string>&amp;Edit</string>
+ </property>
+ <addaction name="editUndoAction"/>
+ <addaction name="editRedoAction"/>
+ <addaction name="separator"/>
+ <addaction name="editCutAction"/>
+ <addaction name="editCopyAction"/>
+ <addaction name="editPasteAction"/>
+ <addaction name="separator"/>
+ <addaction name="editFindAction"/>
+ </widget>
+ <widget class="QMenu" name="helpMenu">
+ <property name="title">
+ <string>&amp;Help</string>
+ </property>
+ <addaction name="helpContentsAction"/>
+ <addaction name="helpIndexAction"/>
+ <addaction name="separator"/>
+ <addaction name="helpAboutAction"/>
+ </widget>
+ <addaction name="fileMenu"/>
+ <addaction name="editMenu"/>
+ <addaction name="helpMenu"/>
+ </widget>
+ <action name="fileNewAction">
+ <property name="icon">
+ <iconset>
+ <normaloff>image0</normaloff>image0</iconset>
+ </property>
+ <property name="text">
+ <string>&amp;New</string>
+ </property>
+ <property name="iconText">
+ <string>New</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+N</string>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>fileNewAction</cstring>
+ </property>
+ </action>
+ <action name="fileOpenAction">
+ <property name="icon">
+ <iconset>
+ <normaloff>image1</normaloff>image1</iconset>
+ </property>
+ <property name="text">
+ <string>&amp;Open...</string>
+ </property>
+ <property name="iconText">
+ <string>Open</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+O</string>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>fileOpenAction</cstring>
+ </property>
+ </action>
+ <action name="fileSaveAction">
+ <property name="icon">
+ <iconset>
+ <normaloff>image2</normaloff>image2</iconset>
+ </property>
+ <property name="text">
+ <string>&amp;Save</string>
+ </property>
+ <property name="iconText">
+ <string>Save</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+S</string>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>fileSaveAction</cstring>
+ </property>
+ </action>
+ <action name="fileSaveAsAction">
+ <property name="text">
+ <string>Save &amp;As...</string>
+ </property>
+ <property name="iconText">
+ <string>Save As</string>
+ </property>
+ <property name="shortcut">
+ <string/>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>fileSaveAsAction</cstring>
+ </property>
+ </action>
+ <action name="filePrintAction">
+ <property name="icon">
+ <iconset>
+ <normaloff>image3</normaloff>image3</iconset>
+ </property>
+ <property name="text">
+ <string>&amp;Print...</string>
+ </property>
+ <property name="iconText">
+ <string>Print</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+P</string>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>filePrintAction</cstring>
+ </property>
+ </action>
+ <action name="fileExitAction">
+ <property name="text">
+ <string>E&amp;xit</string>
+ </property>
+ <property name="iconText">
+ <string>Exit</string>
+ </property>
+ <property name="shortcut">
+ <string/>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>fileExitAction</cstring>
+ </property>
+ </action>
+ <action name="editUndoAction">
+ <property name="icon">
+ <iconset>
+ <normaloff>image4</normaloff>image4</iconset>
+ </property>
+ <property name="text">
+ <string>&amp;Undo</string>
+ </property>
+ <property name="iconText">
+ <string>Undo</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+Z</string>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>editUndoAction</cstring>
+ </property>
+ </action>
+ <action name="editRedoAction">
+ <property name="icon">
+ <iconset>
+ <normaloff>image5</normaloff>image5</iconset>
+ </property>
+ <property name="text">
+ <string>&amp;Redo</string>
+ </property>
+ <property name="iconText">
+ <string>Redo</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+Y</string>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>editRedoAction</cstring>
+ </property>
+ </action>
+ <action name="editCutAction">
+ <property name="icon">
+ <iconset>
+ <normaloff>image6</normaloff>image6</iconset>
+ </property>
+ <property name="text">
+ <string>&amp;Cut</string>
+ </property>
+ <property name="iconText">
+ <string>Cut</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+X</string>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>editCutAction</cstring>
+ </property>
+ </action>
+ <action name="editCopyAction">
+ <property name="icon">
+ <iconset>
+ <normaloff>image7</normaloff>image7</iconset>
+ </property>
+ <property name="text">
+ <string>C&amp;opy</string>
+ </property>
+ <property name="iconText">
+ <string>Copy</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+C</string>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>editCopyAction</cstring>
+ </property>
+ </action>
+ <action name="editPasteAction">
+ <property name="icon">
+ <iconset>
+ <normaloff>image8</normaloff>image8</iconset>
+ </property>
+ <property name="text">
+ <string>&amp;Paste</string>
+ </property>
+ <property name="iconText">
+ <string>Paste</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+V</string>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>editPasteAction</cstring>
+ </property>
+ </action>
+ <action name="editFindAction">
+ <property name="icon">
+ <iconset>
+ <normaloff>image9</normaloff>image9</iconset>
+ </property>
+ <property name="text">
+ <string>&amp;Find...</string>
+ </property>
+ <property name="iconText">
+ <string>Find</string>
+ </property>
+ <property name="shortcut">
+ <string>Ctrl+F</string>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>editFindAction</cstring>
+ </property>
+ </action>
+ <action name="helpContentsAction">
+ <property name="text">
+ <string>&amp;Contents...</string>
+ </property>
+ <property name="iconText">
+ <string>Contents</string>
+ </property>
+ <property name="shortcut">
+ <string/>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>helpContentsAction</cstring>
+ </property>
+ </action>
+ <action name="helpIndexAction">
+ <property name="text">
+ <string>&amp;Index...</string>
+ </property>
+ <property name="iconText">
+ <string>Index</string>
+ </property>
+ <property name="shortcut">
+ <string/>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>helpIndexAction</cstring>
+ </property>
+ </action>
+ <action name="helpAboutAction">
+ <property name="text">
+ <string>&amp;About...</string>
+ </property>
+ <property name="iconText">
+ <string>About</string>
+ </property>
+ <property name="shortcut">
+ <string/>
+ </property>
+ <property name="name" stdset="0">
+ <cstring>helpAboutAction</cstring>
+ </property>
+ </action>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>fileNewAction</sender>
+ <signal>activated()</signal>
+ <receiver>RhythmBase</receiver>
+ <slot>fileNew()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>fileOpenAction</sender>
+ <signal>activated()</signal>
+ <receiver>RhythmBase</receiver>
+ <slot>fileOpen()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>fileSaveAction</sender>
+ <signal>activated()</signal>
+ <receiver>RhythmBase</receiver>
+ <slot>fileSave()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>fileSaveAsAction</sender>
+ <signal>activated()</signal>
+ <receiver>RhythmBase</receiver>
+ <slot>fileSaveAs()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>filePrintAction</sender>
+ <signal>activated()</signal>
+ <receiver>RhythmBase</receiver>
+ <slot>filePrint()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>fileExitAction</sender>
+ <signal>activated()</signal>
+ <receiver>RhythmBase</receiver>
+ <slot>fileExit()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>editUndoAction</sender>
+ <signal>activated()</signal>
+ <receiver>RhythmBase</receiver>
+ <slot>editUndo()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>editRedoAction</sender>
+ <signal>activated()</signal>
+ <receiver>RhythmBase</receiver>
+ <slot>editRedo()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>editCutAction</sender>
+ <signal>activated()</signal>
+ <receiver>RhythmBase</receiver>
+ <slot>editCut()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>editCopyAction</sender>
+ <signal>activated()</signal>
+ <receiver>RhythmBase</receiver>
+ <slot>editCopy()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>editPasteAction</sender>
+ <signal>activated()</signal>
+ <receiver>RhythmBase</receiver>
+ <slot>editPaste()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>editFindAction</sender>
+ <signal>activated()</signal>
+ <receiver>RhythmBase</receiver>
+ <slot>editFind()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>helpIndexAction</sender>
+ <signal>activated()</signal>
+ <receiver>RhythmBase</receiver>
+ <slot>helpIndex()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>helpContentsAction</sender>
+ <signal>activated()</signal>
+ <receiver>RhythmBase</receiver>
+ <slot>helpContents()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>helpAboutAction</sender>
+ <signal>activated()</signal>
+ <receiver>RhythmBase</receiver>
+ <slot>helpAbout()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>-1</x>
+ <y>-1</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/mtc.cpp b/attic/muse2-oom/muse2/muse/mtc.cpp
new file mode 100644
index 00000000..647d6359
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mtc.cpp
@@ -0,0 +1,130 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mtc.cpp,v 1.1.1.1 2003/10/27 18:51:48 wschweer Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "mtc.h"
+#include <stdio.h>
+
+extern int mtcType;
+
+//---------------------------------------------------------
+// MTC::time
+// converts MTC Time to seconds according to
+// global mtcType
+//---------------------------------------------------------
+
+double MTC::time(int type) const
+ {
+ double time = _h * 3600 + _m * 60 + _s;
+ double ft = 0.0;
+ if(type == -1)
+ type = mtcType;
+ switch (type) {
+ case 0: // 24 frames sec
+ ft = 1.0/24.0;
+ break;
+ case 1: // 25
+ ft = 0.04;
+ break;
+ case 2: // 30 drop frame TODO
+ case 3: // 30 non drop frame
+ default:
+ ft = 1.0/30.0;
+ break;
+ }
+ return time + ft *_f + 0.01 * ft * _sf;
+ }
+
+//---------------------------------------------------------
+// MTC
+//---------------------------------------------------------
+
+MTC::MTC(double t, int type)
+ {
+ _h = int(t/3600);
+ t -= _h * 3600;
+ _m = int(t/60);
+ t -= _m * 60;
+ _s = int(t);
+ t -= _s;
+ double ft = 1.0/24.0;
+ if(type == -1)
+ type = mtcType;
+ switch (type) {
+ case 0: // 24 frames sec
+ ft = 1.0/24.0;
+ break;
+ case 1: // 25
+ ft = 0.04;
+ break;
+ case 2: // 30 drop frame
+ case 3: // 30 non drop frame
+ default:
+ ft = 1.0/30.0;
+ break;
+ }
+ double frames = t / ft;
+ _f = int(frames);
+ frames -= _f;
+ _sf = int(frames * 100);
+ }
+
+//---------------------------------------------------------
+// incQuarter
+// increment MTC time one quarter frame time
+//---------------------------------------------------------
+
+void MTC::incQuarter(int type)
+ {
+ int frames = 24;
+ if(type == -1)
+ type = mtcType;
+ switch (type) {
+ case 0:
+ frames = 24;
+ break;
+ case 1:
+ frames = 25;
+ break;
+ case 2:
+ case 3:
+ default:
+ frames = 30;
+ break;
+ }
+ _sf += 25;
+ if (_sf >= 100) {
+ ++_f;
+ _sf -= 100;
+ }
+ if (_f == frames) {
+ ++_s;
+ _f = 0;
+ }
+ if (_s == 60) {
+ ++_m;
+ _s = 0;
+ }
+ if (_m == 60) {
+ ++_h;
+ _m = 0;
+ }
+ if (_h == 24) {
+ _h = 0;
+ }
+ }
+
+//---------------------------------------------------------
+// print
+//---------------------------------------------------------
+
+void MTC::print() const
+ {
+ printf("%02d:%02d:%02d:%02d:%02d", _h, _m, _s, _f, _sf);
+ }
+
+
diff --git a/attic/muse2-oom/muse2/muse/mtc.h b/attic/muse2-oom/muse2/muse/mtc.h
new file mode 100644
index 00000000..ae2bb01e
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/mtc.h
@@ -0,0 +1,56 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mtc.h,v 1.1.1.1 2003/10/27 18:51:25 wschweer Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MTC_H__
+#define __MTC_H__
+
+//---------------------------------------------------------
+// MTC
+//---------------------------------------------------------
+
+class MTC {
+ unsigned char _h, _m, _s, _f, _sf;
+
+ public:
+ MTC(int h, int m, int s, int f, int sf=0) {
+ _h = h;
+ _m = m;
+ _s = s;
+ _f = f;
+ _sf = sf;
+ }
+ MTC() {
+ _h = _m = _s = _f = _sf = 0;
+ }
+ MTC(double, int type = -1);
+ void set(int h, int m, int s, int f, int sf=0) {
+ _h = h;
+ _m = m;
+ _s = s;
+ _f = f;
+ _sf = sf;
+ }
+ void incQuarter(int type = -1);
+ void setH(int val) { _h = val; }
+ void setM(int val) { _m = val; }
+ void setS(int val) { _s = val; }
+ void setF(int val) { _f = val; }
+ void setSf(int val) { _sf = val; }
+
+ int h() const { return _h; }
+ int m() const { return _m; }
+ int s() const { return _s; }
+ int f() const { return _f; }
+ int sf() const { return _sf; }
+ double time(int type = -1) const;
+ void print() const;
+ };
+
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/muse.log b/attic/muse2-oom/muse2/muse/muse.log
new file mode 100644
index 00000000..887f40d5
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/muse.log
@@ -0,0 +1,1875 @@
+
+*** Beginning merge of project muse
+
+User: ws
+Date: Mon, 11 Aug 2003 15:03:52 +0200
+Common version: 0.2
+Selected version: 0.4
+Working version: 0.2(w)
+
+*** Action on file `m4/alsa.m4'
+No prompt for file `m4/alsa.m4'
+
+*** Action on file `m4/docbook.m4'
+No prompt for file `m4/docbook.m4'
+
+*** Action on file `m4/Makefile.am'
+No prompt for file `m4/Makefile.am'
+
+*** Action on file `m4/aclocal-include.m4'
+No prompt for file `m4/aclocal-include.m4'
+
+*** Action on file `m4/qt.m4'
+No prompt for file `m4/qt.m4'
+
+*** Action on file [symlink:COPYING]
+No prompt for file [symlink:COPYING]
+
+*** Action on file [symlink:INSTALL]
+No prompt for file [symlink:INSTALL]
+
+*** Action on file [symlink:depcomp]
+No prompt for file [symlink:depcomp]
+
+*** Action on file [symlink:mkinstalldirs]
+No prompt for file [symlink:mkinstalldirs]
+
+*** Action on file [symlink:missing]
+No prompt for file [symlink:missing]
+
+*** Action on file [symlink:config.sub]
+No prompt for file [symlink:config.sub]
+
+*** Action on file [symlink:install-sh]
+No prompt for file [symlink:install-sh]
+
+*** Action on file [symlink:config.guess]
+No prompt for file [symlink:config.guess]
+
+*** Action on file [symlink:ltmain.sh]
+No prompt for file [symlink:ltmain.sh]
+
+*** Action on file `configure.ac'
+No prompt for file `configure.ac'
+
+*** Action on file `Doxyfile.in'
+No prompt for file `Doxyfile.in'
+
+*** Action on file `common.am'
+No prompt for file `common.am'
+
+*** Action on file `aclocal.m4'
+No prompt for file `aclocal.m4'
+
+*** Action on file `ChangeLog'
+No prompt for file `ChangeLog'
+
+*** Action on file `README.ladspaguis'
+No prompt for file `README.ladspaguis'
+
+*** Action on file `README.instruments'
+No prompt for file `README.instruments'
+
+*** Action on file `README.translate'
+No prompt for file `README.translate'
+
+*** Action on file `README'
+No prompt for file `README'
+
+*** Action on file `README.de'
+No prompt for file `README.de'
+
+*** Action on file `AUTHORS'
+No prompt for file `AUTHORS'
+
+*** Action on file `README.shortcuts'
+No prompt for file `README.shortcuts'
+
+*** Action on file `README.CVS'
+No prompt for file `README.CVS'
+
+*** Action on file `NEWS'
+No prompt for file `NEWS'
+
+*** Action on file `README.softsynth'
+No prompt for file `README.softsynth'
+
+*** Action on file `SECURITY'
+No prompt for file `SECURITY'
+
+*** Action on file `.cvsignore'
+No prompt for file `.cvsignore'
+
+*** Action on file `Makefile.am'
+No prompt for file `Makefile.am'
+
+*** Action on file `pos.h'
+No prompt for file `pos.h'
+
+*** Action on file `mtc.h'
+No prompt for file `mtc.h'
+
+*** Action on file `cfprint.cpp'
+No prompt for file `cfprint.cpp'
+
+*** Action on file `key.h'
+No prompt for file `key.h'
+
+*** Action on file `app.h'
+No prompt for file `app.h'
+
+*** Action on file `song.cpp'
+No prompt for file `song.cpp'
+
+*** Action on file `key.cpp'
+No prompt for file `key.cpp'
+
+*** Action on file `memory.cpp'
+No prompt for file `memory.cpp'
+
+*** Action on file `midiport.h'
+No prompt for file `midiport.h'
+
+*** Action on file `xml.cpp'
+No prompt for file `xml.cpp'
+
+*** Action on file `undo.cpp'
+No prompt for file `undo.cpp'
+
+*** Action on file `debug.h'
+No prompt for file `debug.h'
+
+*** Action on file `app.cpp'
+No prompt for file `app.cpp'
+
+*** Action on file `thread.h'
+No prompt for file `thread.h'
+
+*** Action on file `icons.h'
+No prompt for file `icons.h'
+
+*** Action on file `midithread.cpp'
+Copied working file `midithread.cpp' to `obsolete/midithread.cpp.v0'
+Merge file `midithread.cpp' by rule 2
+
+*** Action on file `device.h'
+No prompt for file `device.h'
+
+*** Action on file `icons.cpp'
+No prompt for file `icons.cpp'
+
+*** Action on file `wave.h'
+No prompt for file `wave.h'
+
+*** Action on file `ladspa.h'
+No prompt for file `ladspa.h'
+
+*** Action on file `undo.h'
+No prompt for file `undo.h'
+
+*** Action on file `sync.h'
+No prompt for file `sync.h'
+
+*** Action on file `song.h'
+No prompt for file `song.h'
+
+*** Action on file `value.cpp'
+No prompt for file `value.cpp'
+
+*** Action on file `midiport.cpp'
+No prompt for file `midiport.cpp'
+
+*** Action on file `givertcap.c'
+No prompt for file `givertcap.c'
+
+*** Action on file `value.h'
+No prompt for file `value.h'
+
+*** Action on file `part.h'
+No prompt for file `part.h'
+
+*** Action on file `node.h'
+No prompt for file `node.h'
+
+*** Action on file `cobject.cpp'
+No prompt for file `cobject.cpp'
+
+*** Action on file `midithread.h'
+No prompt for file `midithread.h'
+
+*** Action on file `tempo.cpp'
+No prompt for file `tempo.cpp'
+
+*** Action on file `memory.h'
+Copied working file `memory.h' to `obsolete/memory.h.v0'
+Merge file `memory.h' by rule 2, conflicts created
+
+*** Action on file `help.cpp'
+No prompt for file `help.cpp'
+
+*** Action on file `audiomix.h'
+No prompt for file `audiomix.h'
+
+*** Action on file `thread.cpp'
+No prompt for file `thread.cpp'
+
+*** Action on file `mrecord.cpp'
+No prompt for file `mrecord.cpp'
+
+*** Action on file `globals.cpp'
+No prompt for file `globals.cpp'
+
+*** Action on file `pos.cpp'
+No prompt for file `pos.cpp'
+
+*** Action on file `track.cpp'
+No prompt for file `track.cpp'
+
+*** Action on file `midictrl.h'
+No prompt for file `midictrl.h'
+
+*** Action on file `node.cpp'
+No prompt for file `node.cpp'
+
+*** Action on file `audiomix.cpp'
+No prompt for file `audiomix.cpp'
+
+*** Action on file `transport.h'
+No prompt for file `transport.h'
+
+*** Action on file `transpose.h'
+No prompt for file `transpose.h'
+
+*** Action on file `seqmsg.cpp'
+No prompt for file `seqmsg.cpp'
+
+*** Action on file `audionode.h'
+No prompt for file `audionode.h'
+
+*** Action on file `audio.h'
+No prompt for file `audio.h'
+
+*** Action on file `grepmidi.cpp'
+No prompt for file `grepmidi.cpp'
+
+*** Action on file `globals.h'
+No prompt for file `globals.h'
+
+*** Action on file `midieditor.cpp'
+No prompt for file `midieditor.cpp'
+
+*** Action on file `wave.cpp'
+No prompt for file `wave.cpp'
+
+*** Action on file `midi.h'
+No prompt for file `midi.h'
+
+*** Action on file `mess.h'
+No prompt for file `mess.h'
+
+*** Action on file `sync.cpp'
+No prompt for file `sync.cpp'
+
+*** Action on file `config.h.in'
+No prompt for file `config.h.in'
+
+*** Action on file `track.h'
+No prompt for file `track.h'
+
+*** Action on file `mtc.cpp'
+No prompt for file `mtc.cpp'
+
+*** Action on file `minstrument.h'
+No prompt for file `minstrument.h'
+
+*** Action on file `cobject.h'
+No prompt for file `cobject.h'
+
+*** Action on file `synth.h'
+No prompt for file `synth.h'
+
+*** Action on file `songfile.cpp'
+No prompt for file `songfile.cpp'
+
+*** Action on file `midictrl.cpp'
+No prompt for file `midictrl.cpp'
+
+*** Action on file `mpevent.h'
+No prompt for file `mpevent.h'
+
+*** Action on file `font.h'
+No prompt for file `font.h'
+
+*** Action on file `conf.cpp'
+No prompt for file `conf.cpp'
+
+*** Action on file `conf.h'
+No prompt for file `conf.h'
+
+*** Action on file `event.cpp'
+No prompt for file `event.cpp'
+
+*** Action on file `midi.cpp'
+No prompt for file `midi.cpp'
+
+*** Action on file `event.h'
+No prompt for file `event.h'
+
+*** Action on file `audioprefetch.h'
+No prompt for file `audioprefetch.h'
+
+*** Action on file `mpevent.cpp'
+No prompt for file `mpevent.cpp'
+
+*** Action on file `appearance.cpp'
+No prompt for file `appearance.cpp'
+
+*** Action on file `autogen.sh'
+No prompt for file `autogen.sh'
+
+*** Action on file `tempo.h'
+No prompt for file `tempo.h'
+
+*** Action on file `muse.pro'
+No prompt for file `muse.pro'
+
+*** Action on file `part.cpp'
+No prompt for file `part.cpp'
+
+*** Action on file `make.inc'
+No prompt for file `make.inc'
+
+*** Action on file `confmport.h'
+No prompt for file `confmport.h'
+
+*** Action on file `audio.cpp'
+No prompt for file `audio.cpp'
+
+*** Action on file `confmport.cpp'
+No prompt for file `confmport.cpp'
+
+*** Action on file `cfprint.h'
+No prompt for file `cfprint.h'
+
+*** Action on file `sig.cpp'
+No prompt for file `sig.cpp'
+
+*** Action on file `font.cpp'
+No prompt for file `font.cpp'
+
+*** Action on file `midieditor.h'
+No prompt for file `midieditor.h'
+
+*** Action on file `appearance.h'
+No prompt for file `appearance.h'
+
+*** Action on file `globaldefs.h'
+No prompt for file `globaldefs.h'
+
+*** Action on file `seq.cpp'
+No prompt for file `seq.cpp'
+
+*** Action on file `miditransform.cpp'
+No prompt for file `miditransform.cpp'
+
+*** Action on file `miditransform.h'
+No prompt for file `miditransform.h'
+
+*** Action on file `minstrument.cpp'
+Copied working file `minstrument.cpp' to `obsolete/minstrument.cpp.v0'
+Merge file `minstrument.cpp' by rule 2
+
+*** Action on file `audioprefetch.cpp'
+No prompt for file `audioprefetch.cpp'
+
+*** Action on file `transport.cpp'
+No prompt for file `transport.cpp'
+
+*** Action on file `transpose.cpp'
+No prompt for file `transpose.cpp'
+
+*** Action on file `xml.h'
+No prompt for file `xml.h'
+
+*** Action on file `sig.h'
+No prompt for file `sig.h'
+
+*** Action on file `seq.h'
+No prompt for file `seq.h'
+
+*** Action on file `demos/Makefile.am'
+No prompt for file `demos/Makefile.am'
+
+*** Action on file `demos/rasen.med'
+No prompt for file `demos/rasen.med'
+
+*** Action on file `widgets/.cvsignore'
+No prompt for file `widgets/.cvsignore'
+
+*** Action on file `widgets/mmath.cpp'
+No prompt for file `widgets/mmath.cpp'
+
+*** Action on file `widgets/dimap.cpp'
+No prompt for file `widgets/dimap.cpp'
+
+*** Action on file `widgets/utils.cpp'
+No prompt for file `widgets/utils.cpp'
+
+*** Action on file `widgets/sclif.cpp'
+No prompt for file `widgets/sclif.cpp'
+
+*** Action on file `widgets/filedialog.cpp'
+No prompt for file `widgets/filedialog.cpp'
+
+*** Action on file `widgets/citem.h'
+No prompt for file `widgets/citem.h'
+
+*** Action on file `widgets/bigtime.cpp'
+No prompt for file `widgets/bigtime.cpp'
+
+*** Action on file `widgets/view.cpp'
+No prompt for file `widgets/view.cpp'
+
+*** Action on file `widgets/scldraw.h'
+No prompt for file `widgets/scldraw.h'
+
+*** Action on file `widgets/sliderbase.h'
+No prompt for file `widgets/sliderbase.h'
+
+*** Action on file `widgets/hitscale.cpp'
+No prompt for file `widgets/hitscale.cpp'
+
+*** Action on file `widgets/itransformbase.ui'
+No prompt for file `widgets/itransformbase.ui'
+
+*** Action on file `widgets/header.cpp'
+No prompt for file `widgets/header.cpp'
+
+*** Action on file `widgets/tempolabel.h'
+No prompt for file `widgets/tempolabel.h'
+
+*** Action on file `widgets/velocity.cpp'
+No prompt for file `widgets/velocity.cpp'
+
+*** Action on file `widgets/midirawbase.ui'
+No prompt for file `widgets/midirawbase.ui'
+
+*** Action on file `widgets/drange.cpp'
+No prompt for file `widgets/drange.cpp'
+
+*** Action on file `widgets/header.h'
+No prompt for file `widgets/header.h'
+
+*** Action on file `widgets/mlabel.h'
+No prompt for file `widgets/mlabel.h'
+
+*** Action on file `widgets/spinboxFP.cpp'
+No prompt for file `widgets/spinboxFP.cpp'
+
+*** Action on file `widgets/mlabel.cpp'
+No prompt for file `widgets/mlabel.cpp'
+
+*** Action on file `widgets/metronome.cpp'
+No prompt for file `widgets/metronome.cpp'
+
+*** Action on file `widgets/ctrlcombo.cw'
+No prompt for file `widgets/ctrlcombo.cw'
+
+*** Action on file `widgets/sigedit.h'
+No prompt for file `widgets/sigedit.h'
+
+*** Action on file `widgets/intlabel.h'
+No prompt for file `widgets/intlabel.h'
+
+*** Action on file `widgets/comment.cpp'
+No prompt for file `widgets/comment.cpp'
+
+*** Action on file `widgets/ctrlcombo.cpp'
+No prompt for file `widgets/ctrlcombo.cpp'
+
+*** Action on file `widgets/mixdowndialog.cpp'
+No prompt for file `widgets/mixdowndialog.cpp'
+
+*** Action on file `widgets/fontsel.cpp'
+No prompt for file `widgets/fontsel.cpp'
+
+*** Action on file `widgets/hitscale.h'
+No prompt for file `widgets/hitscale.h'
+
+*** Action on file `widgets/posedit.cpp'
+No prompt for file `widgets/posedit.cpp'
+
+*** Action on file `widgets/audioconfbase.ui'
+No prompt for file `widgets/audioconfbase.ui'
+
+*** Action on file `widgets/utils.h'
+No prompt for file `widgets/utils.h'
+
+*** Action on file `widgets/splitter.cpp'
+No prompt for file `widgets/splitter.cpp'
+
+*** Action on file `widgets/editctrl7dialogbase.ui'
+No prompt for file `widgets/editctrl7dialogbase.ui'
+
+*** Action on file `widgets/doublelabel.h'
+No prompt for file `widgets/doublelabel.h'
+
+*** Action on file `widgets/noteinfo.h'
+No prompt for file `widgets/noteinfo.h'
+
+*** Action on file `widgets/sigscale.h'
+No prompt for file `widgets/sigscale.h'
+
+*** Action on file `widgets/canvas.cpp'
+No prompt for file `widgets/canvas.cpp'
+
+*** Action on file `widgets/view.h'
+No prompt for file `widgets/view.h'
+
+*** Action on file `widgets/audioconf.h'
+No prompt for file `widgets/audioconf.h'
+
+*** Action on file `widgets/ccontrolbase.ui'
+No prompt for file `widgets/ccontrolbase.ui'
+
+*** Action on file `widgets/transposebase.ui'
+No prompt for file `widgets/transposebase.ui'
+
+*** Action on file `widgets/spinboxFP.h'
+No prompt for file `widgets/spinboxFP.h'
+
+*** Action on file `widgets/mtscale.h'
+No prompt for file `widgets/mtscale.h'
+
+*** Action on file `widgets/nentry.cpp'
+No prompt for file `widgets/nentry.cpp'
+
+*** Action on file `widgets/siglabel.h'
+No prompt for file `widgets/siglabel.h'
+
+*** Action on file `widgets/transformbase.ui'
+No prompt for file `widgets/transformbase.ui'
+
+*** Action on file `widgets/mittransposebase.ui'
+No prompt for file `widgets/mittransposebase.ui'
+
+*** Action on file `widgets/dentry.h'
+No prompt for file `widgets/dentry.h'
+
+*** Action on file `widgets/slider.h'
+No prompt for file `widgets/slider.h'
+
+*** Action on file `widgets/wtscale.cpp'
+No prompt for file `widgets/wtscale.cpp'
+
+*** Action on file `widgets/action.h'
+No prompt for file `widgets/action.h'
+
+*** Action on file `widgets/nentry.h'
+No prompt for file `widgets/nentry.h'
+
+*** Action on file `widgets/ttoolbar.h'
+No prompt for file `widgets/ttoolbar.h'
+
+*** Action on file `widgets/comboQuant.cpp'
+No prompt for file `widgets/comboQuant.cpp'
+
+*** Action on file `widgets/midisyncimpl.h'
+No prompt for file `widgets/midisyncimpl.h'
+
+*** Action on file `widgets/sliderbase.cpp'
+No prompt for file `widgets/sliderbase.cpp'
+
+*** Action on file `widgets/genset.cpp'
+No prompt for file `widgets/genset.cpp'
+
+*** Action on file `widgets/velocity.h'
+No prompt for file `widgets/velocity.h'
+
+*** Action on file `widgets/poslabel.h'
+No prompt for file `widgets/poslabel.h'
+
+*** Action on file `widgets/knob.h'
+No prompt for file `widgets/knob.h'
+
+*** Action on file `widgets/cliplisteditorbase.ui'
+No prompt for file `widgets/cliplisteditorbase.ui'
+
+*** Action on file `widgets/splitter.h'
+No prompt for file `widgets/splitter.h'
+
+*** Action on file `widgets/sigedit.cpp'
+No prompt for file `widgets/sigedit.cpp'
+
+*** Action on file `widgets/audioconf.cpp'
+No prompt for file `widgets/audioconf.cpp'
+
+*** Action on file `widgets/swidget.h'
+No prompt for file `widgets/swidget.h'
+
+*** Action on file `widgets/tools.h'
+No prompt for file `widgets/tools.h'
+
+*** Action on file `widgets/pitchlabel.h'
+No prompt for file `widgets/pitchlabel.h'
+
+*** Action on file `widgets/Makefile.am'
+No prompt for file `widgets/Makefile.am'
+
+*** Action on file `widgets/moc_ttoolbar.cpp'
+No prompt for file `widgets/moc_ttoolbar.cpp'
+
+*** Action on file `widgets/intlabel.cpp'
+No prompt for file `widgets/intlabel.cpp'
+
+*** Action on file `widgets/citem.cpp'
+No prompt for file `widgets/citem.cpp'
+
+*** Action on file `widgets/canvas.h'
+No prompt for file `widgets/canvas.h'
+
+*** Action on file `widgets/doublelabel.cpp'
+No prompt for file `widgets/doublelabel.cpp'
+
+*** Action on file `widgets/slider.cpp'
+No prompt for file `widgets/slider.cpp'
+
+*** Action on file `widgets/mmath.h'
+No prompt for file `widgets/mmath.h'
+
+*** Action on file `widgets/wtscale.h'
+No prompt for file `widgets/wtscale.h'
+
+*** Action on file `widgets/genset.h'
+No prompt for file `widgets/genset.h'
+
+*** Action on file `widgets/posedit.h'
+No prompt for file `widgets/posedit.h'
+
+*** Action on file `widgets/velocitybase.ui'
+No prompt for file `widgets/velocitybase.ui'
+
+*** Action on file `widgets/ttoolbar.cpp'
+No prompt for file `widgets/ttoolbar.cpp'
+
+*** Action on file `widgets/scrollscale.cpp'
+No prompt for file `widgets/scrollscale.cpp'
+
+*** Action on file `widgets/mtscale.cpp'
+No prompt for file `widgets/mtscale.cpp'
+
+*** Action on file `widgets/noteinfo.cpp'
+No prompt for file `widgets/noteinfo.cpp'
+
+*** Action on file `widgets/lcombo.cpp'
+No prompt for file `widgets/lcombo.cpp'
+
+*** Action on file `widgets/appearancebase.ui'
+No prompt for file `widgets/appearancebase.ui'
+
+*** Action on file `widgets/vscale.h'
+No prompt for file `widgets/vscale.h'
+
+*** Action on file `widgets/scldiv.h'
+No prompt for file `widgets/scldiv.h'
+
+*** Action on file `widgets/drange.h'
+No prompt for file `widgets/drange.h'
+
+*** Action on file `widgets/midisync.ui'
+No prompt for file `widgets/midisync.ui'
+
+*** Action on file `widgets/wtrackinfobase.ui'
+No prompt for file `widgets/wtrackinfobase.ui'
+
+*** Action on file `widgets/vscale.cpp'
+No prompt for file `widgets/vscale.cpp'
+
+*** Action on file `widgets/editsysexdialogbase.ui'
+No prompt for file `widgets/editsysexdialogbase.ui'
+
+*** Action on file `widgets/gatetimebase.ui'
+No prompt for file `widgets/gatetimebase.ui'
+
+*** Action on file `widgets/editmetadialogbase.ui'
+No prompt for file `widgets/editmetadialogbase.ui'
+
+*** Action on file `widgets/sigscale.cpp'
+No prompt for file `widgets/sigscale.cpp'
+
+*** Action on file `widgets/mtrackinfobase.ui'
+No prompt for file `widgets/mtrackinfobase.ui'
+
+*** Action on file `widgets/metronome.h'
+No prompt for file `widgets/metronome.h'
+
+*** Action on file `widgets/gatetime.cpp'
+No prompt for file `widgets/gatetime.cpp'
+
+*** Action on file `widgets/tb1.cpp'
+No prompt for file `widgets/tb1.cpp'
+
+*** Action on file `widgets/gensetbase.ui'
+No prompt for file `widgets/gensetbase.ui'
+
+*** Action on file `widgets/scldraw.cpp'
+No prompt for file `widgets/scldraw.cpp'
+
+*** Action on file `widgets/bigtime.h'
+No prompt for file `widgets/bigtime.h'
+
+*** Action on file `widgets/poslabel.cpp'
+No prompt for file `widgets/poslabel.cpp'
+
+*** Action on file `widgets/metronomebase.ui'
+No prompt for file `widgets/metronomebase.ui'
+
+*** Action on file `widgets/scrollscale.h'
+No prompt for file `widgets/scrollscale.h'
+
+*** Action on file `widgets/fdialogbuttons.ui'
+No prompt for file `widgets/fdialogbuttons.ui'
+
+*** Action on file `widgets/sclif.h'
+No prompt for file `widgets/sclif.h'
+
+*** Action on file `widgets/tools.cpp'
+No prompt for file `widgets/tools.cpp'
+
+*** Action on file `widgets/filedialog.h'
+No prompt for file `widgets/filedialog.h'
+
+*** Action on file `widgets/pitchlabel.cpp'
+No prompt for file `widgets/pitchlabel.cpp'
+
+*** Action on file `widgets/scldiv.cpp'
+No prompt for file `widgets/scldiv.cpp'
+
+*** Action on file `widgets/musewidgetsplug.cpp'
+No prompt for file `widgets/musewidgetsplug.cpp'
+
+*** Action on file `widgets/midisyncimpl.cpp'
+No prompt for file `widgets/midisyncimpl.cpp'
+
+*** Action on file `widgets/commentbase.ui'
+No prompt for file `widgets/commentbase.ui'
+
+*** Action on file `widgets/dentry.cpp'
+No prompt for file `widgets/dentry.cpp'
+
+*** Action on file `widgets/comment.h'
+No prompt for file `widgets/comment.h'
+
+*** Action on file `widgets/ctrlcombo.h'
+No prompt for file `widgets/ctrlcombo.h'
+
+*** Action on file `widgets/comboQuant.h'
+No prompt for file `widgets/comboQuant.h'
+
+*** Action on file `widgets/gatetime.h'
+No prompt for file `widgets/gatetime.h'
+
+*** Action on file `widgets/tb1.h'
+No prompt for file `widgets/tb1.h'
+
+*** Action on file `widgets/editnotedialogbase.ui'
+No prompt for file `widgets/editnotedialogbase.ui'
+
+*** Action on file `widgets/pitchedit.h'
+No prompt for file `widgets/pitchedit.h'
+
+*** Action on file `widgets/lcombo.h'
+No prompt for file `widgets/lcombo.h'
+
+*** Action on file `widgets/fontsel.h'
+No prompt for file `widgets/fontsel.h'
+
+*** Action on file `widgets/tempolabel.cpp'
+No prompt for file `widgets/tempolabel.cpp'
+
+*** Action on file `widgets/knob.cpp'
+No prompt for file `widgets/knob.cpp'
+
+*** Action on file `widgets/dimap.h'
+No prompt for file `widgets/dimap.h'
+
+*** Action on file `widgets/pitchedit.cpp'
+No prompt for file `widgets/pitchedit.cpp'
+
+*** Action on file `widgets/siglabel.cpp'
+No prompt for file `widgets/siglabel.cpp'
+
+*** Action on file `widgets/mixdowndialog.h'
+No prompt for file `widgets/mixdowndialog.h'
+
+*** Action on file `widgets/mixdowndialogbase.ui'
+No prompt for file `widgets/mixdowndialogbase.ui'
+
+*** Action on file `widgets/synthconfigbase.ui'
+No prompt for file `widgets/synthconfigbase.ui'
+
+*** Action on file `widgets/swidget.cpp'
+No prompt for file `widgets/swidget.cpp'
+
+*** Action on file `widgets/section.h'
+No prompt for file `widgets/section.h'
+
+*** Action on file `arranger/pcanvas.h'
+No prompt for file `arranger/pcanvas.h'
+
+*** Action on file `arranger/alayout.h'
+No prompt for file `arranger/alayout.h'
+
+*** Action on file `arranger/tlist.cpp'
+No prompt for file `arranger/tlist.cpp'
+
+*** Action on file `arranger/arranger.h'
+No prompt for file `arranger/arranger.h'
+
+*** Action on file `arranger/alayout.cpp'
+No prompt for file `arranger/alayout.cpp'
+
+*** Action on file `arranger/Makefile.am'
+No prompt for file `arranger/Makefile.am'
+
+*** Action on file `arranger/tlist.h'
+No prompt for file `arranger/tlist.h'
+
+*** Action on file `arranger/pcanvas.cpp'
+No prompt for file `arranger/pcanvas.cpp'
+
+*** Action on file `arranger/arranger.cpp'
+No prompt for file `arranger/arranger.cpp'
+
+*** Action on file `mplugins/Makefile.am'
+No prompt for file `mplugins/Makefile.am'
+
+*** Action on file `mplugins/.cvsignore'
+No prompt for file `mplugins/.cvsignore'
+
+*** Action on file `mplugins/midifilterimpl.cpp'
+No prompt for file `mplugins/midifilterimpl.cpp'
+
+*** Action on file `mplugins/rhythm.cpp'
+No prompt for file `mplugins/rhythm.cpp'
+
+*** Action on file `mplugins/rhythmbase.ui'
+No prompt for file `mplugins/rhythmbase.ui'
+
+*** Action on file `mplugins/midifilter.ui'
+No prompt for file `mplugins/midifilter.ui'
+
+*** Action on file `mplugins/mitplugin.h'
+No prompt for file `mplugins/mitplugin.h'
+
+*** Action on file `mplugins/rhythm.h'
+No prompt for file `mplugins/rhythm.h'
+
+*** Action on file `mplugins/midiitransform.h'
+No prompt for file `mplugins/midiitransform.h'
+
+*** Action on file `mplugins/mittranspose.cpp'
+No prompt for file `mplugins/mittranspose.cpp'
+
+*** Action on file `mplugins/mrconfigbase.ui'
+No prompt for file `mplugins/mrconfigbase.ui'
+
+*** Action on file `mplugins/mrconfig.cpp'
+No prompt for file `mplugins/mrconfig.cpp'
+
+*** Action on file `mplugins/mrconfig.h'
+No prompt for file `mplugins/mrconfig.h'
+
+*** Action on file `mplugins/random.h'
+No prompt for file `mplugins/random.h'
+
+*** Action on file `mplugins/midiitransform.cpp'
+No prompt for file `mplugins/midiitransform.cpp'
+
+*** Action on file `mplugins/mittranspose.h'
+No prompt for file `mplugins/mittranspose.h'
+
+*** Action on file `mplugins/mitplugin.cpp'
+No prompt for file `mplugins/mitplugin.cpp'
+
+*** Action on file `mplugins/midifilterimpl.h'
+No prompt for file `mplugins/midifilterimpl.h'
+
+*** Action on file `mplugins/random.cpp'
+No prompt for file `mplugins/random.cpp'
+
+*** Action on file `waveedit/Makefile.am'
+No prompt for file `waveedit/Makefile.am'
+
+*** Action on file `waveedit/waveview.h'
+No prompt for file `waveedit/waveview.h'
+
+*** Action on file `waveedit/waveedit.cpp'
+No prompt for file `waveedit/waveedit.cpp'
+
+*** Action on file `waveedit/waveedit.h'
+No prompt for file `waveedit/waveedit.h'
+
+*** Action on file `waveedit/waveview.cpp'
+No prompt for file `waveedit/waveview.cpp'
+
+*** Action on file `master/masteredit.cpp'
+No prompt for file `master/masteredit.cpp'
+
+*** Action on file `master/lmaster.cpp'
+No prompt for file `master/lmaster.cpp'
+
+*** Action on file `master/tscale.cpp'
+No prompt for file `master/tscale.cpp'
+
+*** Action on file `master/Makefile.am'
+No prompt for file `master/Makefile.am'
+
+*** Action on file `master/master.h'
+No prompt for file `master/master.h'
+
+*** Action on file `master/masteredit.h'
+No prompt for file `master/masteredit.h'
+
+*** Action on file `master/lmaster.h'
+No prompt for file `master/lmaster.h'
+
+*** Action on file `master/tscale.h'
+No prompt for file `master/tscale.h'
+
+*** Action on file `master/master.cpp'
+No prompt for file `master/master.cpp'
+
+*** Action on file `marker/Makefile.am'
+No prompt for file `marker/Makefile.am'
+
+*** Action on file `marker/marker.h'
+No prompt for file `marker/marker.h'
+
+*** Action on file `marker/markerview.cpp'
+No prompt for file `marker/markerview.cpp'
+
+*** Action on file `marker/markerview.h'
+No prompt for file `marker/markerview.h'
+
+*** Action on file `marker/marker.cpp'
+No prompt for file `marker/marker.cpp'
+
+*** Action on file `driver/audiodev.h'
+No prompt for file `driver/audiodev.h'
+
+*** Action on file `driver/midiserial.h'
+No prompt for file `driver/midiserial.h'
+
+*** Action on file `driver/mididev.h'
+No prompt for file `driver/mididev.h'
+
+*** Action on file `driver/mididev.cpp'
+No prompt for file `driver/mididev.cpp'
+
+*** Action on file `driver/midirawin.h'
+No prompt for file `driver/midirawin.h'
+
+*** Action on file `driver/midirawdev.h'
+No prompt for file `driver/midirawdev.h'
+
+*** Action on file `driver/alsamidi.cpp'
+No prompt for file `driver/alsamidi.cpp'
+
+*** Action on file `driver/alsamidi.h'
+No prompt for file `driver/alsamidi.h'
+
+*** Action on file `driver/Makefile.am'
+No prompt for file `driver/Makefile.am'
+
+*** Action on file `driver/jack.cpp'
+No prompt for file `driver/jack.cpp'
+
+*** Action on file `driver/midirawin.cpp'
+No prompt for file `driver/midirawin.cpp'
+
+*** Action on file `driver/alsaaudio.h'
+No prompt for file `driver/alsaaudio.h'
+
+*** Action on file `driver/midiserial.cpp'
+No prompt for file `driver/midiserial.cpp'
+
+*** Action on file `driver/alsaaudio.cpp'
+No prompt for file `driver/alsaaudio.cpp'
+
+*** Action on file `driver/midirawdev.cpp'
+No prompt for file `driver/midirawdev.cpp'
+
+*** Action on file `driver/jackaudio.h'
+No prompt for file `driver/jackaudio.h'
+
+*** Action on file `driver/mess.cpp'
+No prompt for file `driver/mess.cpp'
+
+*** Action on file `midiedit/drummap.cpp'
+No prompt for file `midiedit/drummap.cpp'
+
+*** Action on file `midiedit/dcanvas.h'
+No prompt for file `midiedit/dcanvas.h'
+
+*** Action on file `midiedit/piano.h'
+No prompt for file `midiedit/piano.h'
+
+*** Action on file `midiedit/drummap.h'
+No prompt for file `midiedit/drummap.h'
+
+*** Action on file `midiedit/drumedit.h'
+No prompt for file `midiedit/drumedit.h'
+
+*** Action on file `midiedit/prcanvas.cpp'
+No prompt for file `midiedit/prcanvas.cpp'
+
+*** Action on file `midiedit/dcanvas.cpp'
+No prompt for file `midiedit/dcanvas.cpp'
+
+*** Action on file `midiedit/Makefile.am'
+No prompt for file `midiedit/Makefile.am'
+
+*** Action on file `midiedit/dlist.cpp'
+No prompt for file `midiedit/dlist.cpp'
+
+*** Action on file `midiedit/pianoroll.cpp'
+No prompt for file `midiedit/pianoroll.cpp'
+
+*** Action on file `midiedit/ecanvas.h'
+No prompt for file `midiedit/ecanvas.h'
+
+*** Action on file `midiedit/quantconfig.h'
+No prompt for file `midiedit/quantconfig.h'
+
+*** Action on file `midiedit/quantconfig.cpp'
+No prompt for file `midiedit/quantconfig.cpp'
+
+*** Action on file `midiedit/ecanvas.cpp'
+No prompt for file `midiedit/ecanvas.cpp'
+
+*** Action on file `midiedit/piano.cpp'
+No prompt for file `midiedit/piano.cpp'
+
+*** Action on file `midiedit/prcanvas.h'
+No prompt for file `midiedit/prcanvas.h'
+
+*** Action on file `midiedit/drumedit.cpp'
+No prompt for file `midiedit/drumedit.cpp'
+
+*** Action on file `midiedit/dlist.h'
+No prompt for file `midiedit/dlist.h'
+
+*** Action on file `midiedit/cmd.h'
+No prompt for file `midiedit/cmd.h'
+
+*** Action on file `midiedit/pianoroll.h'
+No prompt for file `midiedit/pianoroll.h'
+
+*** Action on file `patchbay/Makefile.am'
+No prompt for file `patchbay/Makefile.am'
+
+*** Action on file `patchbay/patchbay.cpp'
+No prompt for file `patchbay/patchbay.cpp'
+
+*** Action on file `patchbay/patchbaybase.ui'
+No prompt for file `patchbay/patchbaybase.ui'
+
+*** Action on file `patchbay/patchbay.h'
+No prompt for file `patchbay/patchbay.h'
+
+*** Action on file `synti/synth.cpp'
+No prompt for file `synti/synth.cpp'
+
+*** Action on file `synti/synthconfig.h'
+No prompt for file `synti/synthconfig.h'
+
+*** Action on file `synti/Makefile.am'
+No prompt for file `synti/Makefile.am'
+
+*** Action on file `synti/synti-install.am'
+No prompt for file `synti/synti-install.am'
+
+*** Action on file `synti/synthconfig.cpp'
+No prompt for file `synti/synthconfig.cpp'
+
+*** Action on file `synti/organ/.cvsignore'
+No prompt for file `synti/organ/.cvsignore'
+
+*** Action on file `synti/organ/organ.cpp'
+No prompt for file `synti/organ/organ.cpp'
+
+*** Action on file `synti/organ/organ.h'
+No prompt for file `synti/organ/organ.h'
+
+*** Action on file `synti/organ/organguibase.ui'
+No prompt for file `synti/organ/organguibase.ui'
+
+*** Action on file `synti/organ/Makefile.am'
+No prompt for file `synti/organ/Makefile.am'
+
+*** Action on file `synti/organ/organgui.h'
+No prompt for file `synti/organ/organgui.h'
+
+*** Action on file `synti/organ/fdialogbuttons.ui'
+No prompt for file `synti/organ/fdialogbuttons.ui'
+
+*** Action on file `synti/organ/organgui.cpp'
+No prompt for file `synti/organ/organgui.cpp'
+
+*** Action on file `synti/fluid/fluidgui.cpp'
+No prompt for file `synti/fluid/fluidgui.cpp'
+
+*** Action on file `synti/fluid/fluidguibase.ui'
+No prompt for file `synti/fluid/fluidguibase.ui'
+
+*** Action on file `synti/fluid/synth.cpp'
+No prompt for file `synti/fluid/synth.cpp'
+
+*** Action on file `synti/fluid/Makefile.am'
+No prompt for file `synti/fluid/Makefile.am'
+
+*** Action on file `synti/fluid/synth.h'
+No prompt for file `synti/fluid/synth.h'
+
+*** Action on file `synti/fluid/fluid.cpp'
+No prompt for file `synti/fluid/fluid.cpp'
+
+*** Action on file `synti/fluid/fluidgui.h'
+No prompt for file `synti/fluid/fluidgui.h'
+
+*** Action on file `synti/fluidsynth/fluidsynthgui.h'
+No prompt for file `synti/fluidsynth/fluidsynthgui.h'
+
+*** Action on file `synti/fluidsynth/fluidsynti.h'
+No prompt for file `synti/fluidsynth/fluidsynti.h'
+
+*** Action on file `synti/fluidsynth/fluidsynti.cpp'
+No prompt for file `synti/fluidsynth/fluidsynti.cpp'
+
+*** Action on file `synti/fluidsynth/fluidsynthguibase.ui'
+No prompt for file `synti/fluidsynth/fluidsynthguibase.ui'
+
+*** Action on file `synti/fluidsynth/Makefile.am'
+No prompt for file `synti/fluidsynth/Makefile.am'
+
+*** Action on file `synti/fluidsynth/fluidsynthgui.cpp'
+No prompt for file `synti/fluidsynth/fluidsynthgui.cpp'
+
+*** Action on file `synti/fluidsynth/TODO'
+No prompt for file `synti/fluidsynth/TODO'
+
+*** Action on file `synti/vam/vamgui.cpp'
+No prompt for file `synti/vam/vamgui.cpp'
+
+*** Action on file `synti/vam/COPYING'
+No prompt for file `synti/vam/COPYING'
+
+*** Action on file `synti/vam/ChangeLog'
+No prompt for file `synti/vam/ChangeLog'
+
+*** Action on file `synti/vam/vamgui.h'
+No prompt for file `synti/vam/vamgui.h'
+
+*** Action on file `synti/vam/vam.cpp'
+No prompt for file `synti/vam/vam.cpp'
+
+*** Action on file `synti/vam/Makefile.am'
+No prompt for file `synti/vam/Makefile.am'
+
+*** Action on file `synti/vam/fdialogbuttons.ui'
+No prompt for file `synti/vam/fdialogbuttons.ui'
+
+*** Action on file `synti/vam/README'
+No prompt for file `synti/vam/README'
+
+*** Action on file `synti/vam/vam.h'
+No prompt for file `synti/vam/vam.h'
+
+*** Action on file `synti/vam/vamguibase.ui'
+No prompt for file `synti/vam/vamguibase.ui'
+
+*** Action on file `synti/vam/TODO'
+No prompt for file `synti/vam/TODO'
+
+*** Action on file `synti/s1/s1.cpp'
+No prompt for file `synti/s1/s1.cpp'
+
+*** Action on file `synti/s1/Makefile.am'
+No prompt for file `synti/s1/Makefile.am'
+
+*** Action on file `share/Makefile.am'
+No prompt for file `share/Makefile.am'
+
+*** Action on file `share/plugins/1050.ui'
+No prompt for file `share/plugins/1050.ui'
+
+*** Action on file `share/plugins/Makefile.am'
+No prompt for file `share/plugins/Makefile.am'
+
+*** Action on file `share/instruments/Yamaha-P50m.idf'
+No prompt for file `share/instruments/Yamaha-P50m.idf'
+
+*** Action on file `share/instruments/ns5r.idf'
+No prompt for file `share/instruments/ns5r.idf'
+
+*** Action on file `share/instruments/Roland-XP30.idf'
+No prompt for file `share/instruments/Roland-XP30.idf'
+
+*** Action on file `share/instruments/MC303.idf'
+No prompt for file `share/instruments/MC303.idf'
+
+*** Action on file `share/instruments/Makefile.am'
+No prompt for file `share/instruments/Makefile.am'
+
+*** Action on file `share/instruments/gm.idf'
+No prompt for file `share/instruments/gm.idf'
+
+*** Action on file `share/instruments/Yamaha-S90.idf'
+No prompt for file `share/instruments/Yamaha-S90.idf'
+
+*** Action on file `share/instruments/AlesisQS6.idf'
+No prompt for file `share/instruments/AlesisQS6.idf'
+
+*** Action on file `share/drummaps/Makefile.am'
+No prompt for file `share/drummaps/Makefile.am'
+
+*** Action on file `share/drummaps/sc88-pc1.map'
+No prompt for file `share/drummaps/sc88-pc1.map'
+
+*** Action on file `share/locale/Makefile.am'
+No prompt for file `share/locale/Makefile.am'
+
+*** Action on file `share/locale/muse_sv_SE.ts'
+No prompt for file `share/locale/muse_sv_SE.ts'
+
+*** Action on file `share/locale/muse_ru.ts'
+No prompt for file `share/locale/muse_ru.ts'
+
+*** Action on file `share/locale/muse_fr.ts'
+No prompt for file `share/locale/muse_fr.ts'
+
+*** Action on file `share/locale/muse_es.ts'
+No prompt for file `share/locale/muse_es.ts'
+
+*** Action on file `share/locale/muse_de.ts'
+No prompt for file `share/locale/muse_de.ts'
+
+*** Action on file `share/locale/muse_sv_SE.qm'
+No prompt for file `share/locale/muse_sv_SE.qm'
+
+*** Action on file `share/locale/muse_ru.qm'
+No prompt for file `share/locale/muse_ru.qm'
+
+*** Action on file `share/locale/muse_fr.qm'
+No prompt for file `share/locale/muse_fr.qm'
+
+*** Action on file `share/locale/muse_es.qm'
+No prompt for file `share/locale/muse_es.qm'
+
+*** Action on file `share/locale/muse_de.qm'
+No prompt for file `share/locale/muse_de.qm'
+
+*** Action on file `share/wallpapers/paper1.jpg'
+No prompt for file `share/wallpapers/paper1.jpg'
+
+*** Action on file `share/wallpapers/Makefile.am'
+No prompt for file `share/wallpapers/Makefile.am'
+
+*** Action on file `share/wallpapers/gray_rock.gif'
+No prompt for file `share/wallpapers/gray_rock.gif'
+
+*** Action on file `share/wallpapers/gray.gif'
+No prompt for file `share/wallpapers/gray.gif'
+
+*** Action on file `share/wallpapers/gray_stucco.gif'
+No prompt for file `share/wallpapers/gray_stucco.gif'
+
+*** Action on file `share/wallpapers/stone1.gif'
+No prompt for file `share/wallpapers/stone1.gif'
+
+*** Action on file `share/html/invocation.html'
+No prompt for file `share/html/invocation.html'
+
+*** Action on file `share/html/left_pane.jpg'
+No prompt for file `share/html/left_pane.jpg'
+
+*** Action on file `share/html/styles.css'
+No prompt for file `share/html/styles.css'
+
+*** Action on file `share/html/button_bar.jpg'
+No prompt for file `share/html/button_bar.jpg'
+
+*** Action on file `share/html/COPYING.html'
+No prompt for file `share/html/COPYING.html'
+
+*** Action on file `share/html/main_window.jpg'
+No prompt for file `share/html/main_window.jpg'
+
+*** Action on file `share/html/toc_.txt'
+No prompt for file `share/html/toc_.txt'
+
+*** Action on file `share/html/Makefile.am'
+No prompt for file `share/html/Makefile.am'
+
+*** Action on file `share/html/track_info.jpg'
+No prompt for file `share/html/track_info.jpg'
+
+*** Action on file `share/html/getting_started.html'
+No prompt for file `share/html/getting_started.html'
+
+*** Action on file `share/html/index.html'
+No prompt for file `share/html/index.html'
+
+*** Action on file `share/html/window_ref.html'
+No prompt for file `share/html/window_ref.html'
+
+*** Action on file `share/html/installation.html'
+No prompt for file `share/html/installation.html'
+
+*** Action on file `share/html/main_window_track_info.jpg'
+No prompt for file `share/html/main_window_track_info.jpg'
+
+*** Action on file `share/html/right_pane.jpg'
+No prompt for file `share/html/right_pane.jpg'
+
+*** Action on file `score/Makefile.am'
+No prompt for file `score/Makefile.am'
+
+*** Action on file `score/ncanvas.cpp'
+No prompt for file `score/ncanvas.cpp'
+
+*** Action on file `score/print.cpp'
+No prompt for file `score/print.cpp'
+
+*** Action on file `score/print.h'
+No prompt for file `score/print.h'
+
+*** Action on file `score/layout.h'
+No prompt for file `score/layout.h'
+
+*** Action on file `score/items.h'
+No prompt for file `score/items.h'
+
+*** Action on file `score/papersize.cpp'
+No prompt for file `score/papersize.cpp'
+
+*** Action on file `score/symbols.cpp'
+No prompt for file `score/symbols.cpp'
+
+*** Action on file `score/layout.cpp'
+No prompt for file `score/layout.cpp'
+
+*** Action on file `score/glyphs.cpp'
+No prompt for file `score/glyphs.cpp'
+
+*** Action on file `score/papersize.h'
+No prompt for file `score/papersize.h'
+
+*** Action on file `score/palettes.h'
+No prompt for file `score/palettes.h'
+
+*** Action on file `score/glyphs.h'
+No prompt for file `score/glyphs.h'
+
+*** Action on file `score/ncanvas.h'
+No prompt for file `score/ncanvas.h'
+
+*** Action on file `score/score.doc'
+No prompt for file `score/score.doc'
+
+*** Action on file `score/score.cpp'
+No prompt for file `score/score.cpp'
+
+*** Action on file `score/items.cpp'
+No prompt for file `score/items.cpp'
+
+*** Action on file `score/sconfig.h'
+No prompt for file `score/sconfig.h'
+
+*** Action on file `score/symbols.h'
+No prompt for file `score/symbols.h'
+
+*** Action on file `score/font.cpp'
+No prompt for file `score/font.cpp'
+
+*** Action on file `score/sconfig.cpp'
+No prompt for file `score/sconfig.cpp'
+
+*** Action on file `score/score.h'
+No prompt for file `score/score.h'
+
+*** Action on file `score/palettes.cpp'
+No prompt for file `score/palettes.cpp'
+
+*** Action on file `score/quant.cpp'
+No prompt for file `score/quant.cpp'
+
+*** Action on file `score/quant.h'
+No prompt for file `score/quant.h'
+
+*** Action on file `score/note.cpp'
+No prompt for file `score/note.cpp'
+
+*** Action on file `mixer/Makefile.am'
+No prompt for file `mixer/Makefile.am'
+
+*** Action on file `mixer/amixer.h'
+No prompt for file `mixer/amixer.h'
+
+*** Action on file `mixer/meter.cpp'
+No prompt for file `mixer/meter.cpp'
+
+*** Action on file `mixer/mixer.cpp'
+No prompt for file `mixer/mixer.cpp'
+
+*** Action on file `mixer/routecombo.cpp'
+No prompt for file `mixer/routecombo.cpp'
+
+*** Action on file `mixer/volslider.h'
+No prompt for file `mixer/volslider.h'
+
+*** Action on file `mixer/rack.h'
+No prompt for file `mixer/rack.h'
+
+*** Action on file `mixer/mixer.h'
+No prompt for file `mixer/mixer.h'
+
+*** Action on file `mixer/panknob.h'
+No prompt for file `mixer/panknob.h'
+
+*** Action on file `mixer/panknob.cpp'
+No prompt for file `mixer/panknob.cpp'
+
+*** Action on file `mixer/amixer.cpp'
+No prompt for file `mixer/amixer.cpp'
+
+*** Action on file `mixer/meter.h'
+No prompt for file `mixer/meter.h'
+
+*** Action on file `mixer/rack.cpp'
+No prompt for file `mixer/rack.cpp'
+
+*** Action on file `mixer/routecombo.h'
+No prompt for file `mixer/routecombo.h'
+
+*** Action on file `mixer/audionodebutton.h'
+No prompt for file `mixer/audionodebutton.h'
+
+*** Action on file `mixer/dot.xpm'
+No prompt for file `mixer/dot.xpm'
+
+*** Action on file `mixer/volslider.cpp'
+No prompt for file `mixer/volslider.cpp'
+
+*** Action on file `mixer/audionodebutton.cpp'
+No prompt for file `mixer/audionodebutton.cpp'
+
+*** Action on file `liste/editevent.cpp'
+No prompt for file `liste/editevent.cpp'
+
+*** Action on file `liste/editevent.h'
+No prompt for file `liste/editevent.h'
+
+*** Action on file `liste/Makefile.am'
+No prompt for file `liste/Makefile.am'
+
+*** Action on file `liste/listedit.h'
+No prompt for file `liste/listedit.h'
+
+*** Action on file `liste/listedit.cpp'
+No prompt for file `liste/listedit.cpp'
+
+*** Action on file `ctrl/Makefile.am'
+No prompt for file `ctrl/Makefile.am'
+
+*** Action on file `ctrl/ctrlcanvas.cpp'
+No prompt for file `ctrl/ctrlcanvas.cpp'
+
+*** Action on file `ctrl/ctrlpanel.h'
+No prompt for file `ctrl/ctrlpanel.h'
+
+*** Action on file `ctrl/ctrlcanvas.h'
+No prompt for file `ctrl/ctrlcanvas.h'
+
+*** Action on file `ctrl/ctrledit.h'
+No prompt for file `ctrl/ctrledit.h'
+
+*** Action on file `ctrl/ctrledit.cpp'
+No prompt for file `ctrl/ctrledit.cpp'
+
+*** Action on file `ctrl/ctrlpanel.cpp'
+No prompt for file `ctrl/ctrlpanel.cpp'
+
+*** Action on file `xpm/darkreddot.xpm'
+No prompt for file `xpm/darkreddot.xpm'
+
+*** Action on file `xpm/editmuteS.xpm'
+No prompt for file `xpm/editmuteS.xpm'
+
+*** Action on file `xpm/midiin.xpm'
+No prompt for file `xpm/midiin.xpm'
+
+*** Action on file `xpm/editpasteS.xpm'
+No prompt for file `xpm/editpasteS.xpm'
+
+*** Action on file `xpm/pitch.xpm'
+No prompt for file `xpm/pitch.xpm'
+
+*** Action on file `xpm/italic.xpm'
+No prompt for file `xpm/italic.xpm'
+
+*** Action on file `xpm/redo.xpm'
+No prompt for file `xpm/redo.xpm'
+
+*** Action on file `xpm/filesaveS.xpm'
+No prompt for file `xpm/filesaveS.xpm'
+
+*** Action on file `xpm/scoreS.xpm'
+No prompt for file `xpm/scoreS.xpm'
+
+*** Action on file `xpm/exit.xpm'
+No prompt for file `xpm/exit.xpm'
+
+*** Action on file `xpm/rmark.xpm'
+No prompt for file `xpm/rmark.xpm'
+
+*** Action on file `xpm/frewind.xpm'
+No prompt for file `xpm/frewind.xpm'
+
+*** Action on file `xpm/stop.xpm'
+No prompt for file `xpm/stop.xpm'
+
+*** Action on file `xpm/graydot.xpm'
+No prompt for file `xpm/graydot.xpm'
+
+*** Action on file `xpm/loop.xpm'
+No prompt for file `xpm/loop.xpm'
+
+*** Action on file `xpm/steprec.xpm'
+No prompt for file `xpm/steprec.xpm'
+
+*** Action on file `xpm/recordoffbutton.xpm'
+No prompt for file `xpm/recordoffbutton.xpm'
+
+*** Action on file `xpm/filenewS.xpm'
+No prompt for file `xpm/filenewS.xpm'
+
+*** Action on file `xpm/bold.xpm'
+No prompt for file `xpm/bold.xpm'
+
+*** Action on file `xpm/fileopen.xpm'
+No prompt for file `xpm/fileopen.xpm'
+
+*** Action on file `xpm/editpaste.xpm'
+No prompt for file `xpm/editpaste.xpm'
+
+*** Action on file `xpm/speaker.xpm'
+No prompt for file `xpm/speaker.xpm'
+
+*** Action on file `xpm/delete.xpm'
+No prompt for file `xpm/delete.xpm'
+
+*** Action on file `xpm/pianoS.xpm'
+No prompt for file `xpm/pianoS.xpm'
+
+*** Action on file `xpm/start.xpm'
+No prompt for file `xpm/start.xpm'
+
+*** Action on file `xpm/punchin.xpm'
+No prompt for file `xpm/punchin.xpm'
+
+*** Action on file `xpm/fileprint.xpm'
+No prompt for file `xpm/fileprint.xpm'
+
+*** Action on file `xpm/editcopy.xpm'
+No prompt for file `xpm/editcopy.xpm'
+
+*** Action on file `xpm/play.xpm'
+No prompt for file `xpm/play.xpm'
+
+*** Action on file `xpm/filesaveasS.xpm'
+No prompt for file `xpm/filesaveasS.xpm'
+
+*** Action on file `xpm/stick.xpm'
+No prompt for file `xpm/stick.xpm'
+
+*** Action on file `xpm/fforward.xpm'
+No prompt for file `xpm/fforward.xpm'
+
+*** Action on file `xpm/lock.xpm'
+No prompt for file `xpm/lock.xpm'
+
+*** Action on file `xpm/back.xpm'
+No prompt for file `xpm/back.xpm'
+
+*** Action on file `xpm/up.xpm'
+No prompt for file `xpm/up.xpm'
+
+*** Action on file `xpm/cafter.xpm'
+No prompt for file `xpm/cafter.xpm'
+
+*** Action on file `xpm/recordonbutton.xpm'
+No prompt for file `xpm/recordonbutton.xpm'
+
+*** Action on file `xpm/flag.xpm'
+No prompt for file `xpm/flag.xpm'
+
+*** Action on file `xpm/off.xpm'
+No prompt for file `xpm/off.xpm'
+
+*** Action on file `xpm/editcutS.xpm'
+No prompt for file `xpm/editcutS.xpm'
+
+*** Action on file `xpm/editmute.xpm'
+No prompt for file `xpm/editmute.xpm'
+
+*** Action on file `xpm/pencil.xpm'
+No prompt for file `xpm/pencil.xpm'
+
+*** Action on file `xpm/pointer.xpm'
+No prompt for file `xpm/pointer.xpm'
+
+*** Action on file `xpm/wave.xpm'
+No prompt for file `xpm/wave.xpm'
+
+*** Action on file `xpm/undoS.xpm'
+No prompt for file `xpm/undoS.xpm'
+
+*** Action on file `xpm/loop1.xpm'
+No prompt for file `xpm/loop1.xpm'
+
+*** Action on file `xpm/score.xpm'
+No prompt for file `xpm/score.xpm'
+
+*** Action on file `xpm/glue.xpm'
+No prompt for file `xpm/glue.xpm'
+
+*** Action on file `xpm/Makefile.am'
+No prompt for file `xpm/Makefile.am'
+
+*** Action on file `xpm/gv.xpm'
+No prompt for file `xpm/gv.xpm'
+
+*** Action on file `xpm/redoS.xpm'
+No prompt for file `xpm/redoS.xpm'
+
+*** Action on file `xpm/toc.xpm'
+No prompt for file `xpm/toc.xpm'
+
+*** Action on file `xpm/greendot.xpm'
+No prompt for file `xpm/greendot.xpm'
+
+*** Action on file `xpm/configure.xpm'
+No prompt for file `xpm/configure.xpm'
+
+*** Action on file `xpm/forward.xpm'
+No prompt for file `xpm/forward.xpm'
+
+*** Action on file `xpm/underlined.xpm'
+No prompt for file `xpm/underlined.xpm'
+
+*** Action on file `xpm/home.xpm'
+No prompt for file `xpm/home.xpm'
+
+*** Action on file `xpm/record1.xpm'
+No prompt for file `xpm/record1.xpm'
+
+*** Action on file `xpm/lmark.xpm'
+No prompt for file `xpm/lmark.xpm'
+
+*** Action on file `xpm/record.xpm'
+No prompt for file `xpm/record.xpm'
+
+*** Action on file `xpm/mute.xpm'
+No prompt for file `xpm/mute.xpm'
+
+*** Action on file `xpm/darkgreendot.xpm'
+No prompt for file `xpm/darkgreendot.xpm'
+
+*** Action on file `xpm/find.xpm'
+No prompt for file `xpm/find.xpm'
+
+*** Action on file `xpm/reddot.xpm'
+No prompt for file `xpm/reddot.xpm'
+
+*** Action on file `xpm/punchout.xpm'
+No prompt for file `xpm/punchout.xpm'
+
+*** Action on file `xpm/panic.xpm'
+No prompt for file `xpm/panic.xpm'
+
+*** Action on file `xpm/fileprintS.xpm'
+No prompt for file `xpm/fileprintS.xpm'
+
+*** Action on file `xpm/draw.xpm'
+No prompt for file `xpm/draw.xpm'
+
+*** Action on file `xpm/filesave.xpm'
+No prompt for file `xpm/filesave.xpm'
+
+*** Action on file `xpm/filenew.xpm'
+No prompt for file `xpm/filenew.xpm'
+
+*** Action on file `xpm/piano.xpm'
+No prompt for file `xpm/piano.xpm'
+
+*** Action on file `xpm/solobutton.xpm'
+No prompt for file `xpm/solobutton.xpm'
+
+*** Action on file `xpm/punchin1.xpm'
+No prompt for file `xpm/punchin1.xpm'
+
+*** Action on file `xpm/idea.xpm'
+No prompt for file `xpm/idea.xpm'
+
+*** Action on file `xpm/editcut.xpm'
+No prompt for file `xpm/editcut.xpm'
+
+*** Action on file `xpm/editcopyS.xpm'
+No prompt for file `xpm/editcopyS.xpm'
+
+*** Action on file `xpm/cmark.xpm'
+No prompt for file `xpm/cmark.xpm'
+
+*** Action on file `xpm/fileopenS.xpm'
+No prompt for file `xpm/fileopenS.xpm'
+
+*** Action on file `xpm/ctrl.xpm'
+No prompt for file `xpm/ctrl.xpm'
+
+*** Action on file `xpm/note1.xpm'
+No prompt for file `xpm/note1.xpm'
+
+*** Action on file `xpm/context_help.xpm'
+No prompt for file `xpm/context_help.xpm'
+
+*** Action on file `xpm/exitS.xpm'
+No prompt for file `xpm/exitS.xpm'
+
+*** Action on file `xpm/flagS.xpm'
+No prompt for file `xpm/flagS.xpm'
+
+*** Action on file `xpm/iiwusynth.xpm'
+No prompt for file `xpm/iiwusynth.xpm'
+
+*** Action on file `xpm/sysex.xpm'
+No prompt for file `xpm/sysex.xpm'
+
+*** Action on file `xpm/down.xpm'
+No prompt for file `xpm/down.xpm'
+
+*** Action on file `xpm/dot.xpm'
+No prompt for file `xpm/dot.xpm'
+
+*** Action on file `xpm/quant.xpm'
+No prompt for file `xpm/quant.xpm'
+
+*** Action on file `xpm/doth.xpm'
+No prompt for file `xpm/doth.xpm'
+
+*** Action on file `xpm/punchout1.xpm'
+No prompt for file `xpm/punchout1.xpm'
+
+*** Action on file `xpm/cut.xpm'
+No prompt for file `xpm/cut.xpm'
+
+*** Action on file `xpm/note.xpm'
+No prompt for file `xpm/note.xpm'
+
+*** Action on file `xpm/buttondown.xpm'
+No prompt for file `xpm/buttondown.xpm'
+
+*** Action on file `xpm/dot1.xpm'
+No prompt for file `xpm/dot1.xpm'
+
+*** Action on file `xpm/meta.xpm'
+No prompt for file `xpm/meta.xpm'
+
+*** Action on file `xpm/undo.xpm'
+No prompt for file `xpm/undo.xpm'
+
+*** Action on file `xpm/master.xpm'
+No prompt for file `xpm/master.xpm'
+
+*** Action on file `xpm/bluedot.xpm'
+No prompt for file `xpm/bluedot.xpm'
+
+*** Action on file `xpm/newmutebutton.xpm'
+No prompt for file `xpm/newmutebutton.xpm'
+
+*** Action on file `xpm/pafter.xpm'
+No prompt for file `xpm/pafter.xpm'
+
+*** Action on file `lib/plugins/Makefile.am'
+No prompt for file `lib/plugins/Makefile.am'
+
+*** Action on file `lib/synthi/Makefile.am'
+No prompt for file `lib/synthi/Makefile.am'
+
+*** Action on file `lib/Makefile.am'
+No prompt for file `lib/Makefile.am'
+
+*** Action on file `cliplist/cliplist.cpp'
+No prompt for file `cliplist/cliplist.cpp'
+
+*** Action on file `cliplist/Makefile.am'
+No prompt for file `cliplist/Makefile.am'
+
+*** Action on file `cliplist/cliplist.h'
+No prompt for file `cliplist/cliplist.h'
+
+*** Action on file `doc/midieditfunctions.png'
+No prompt for file `doc/midieditfunctions.png'
+
+*** Action on file `doc/Makefile.am'
+No prompt for file `doc/Makefile.am'
+
+*** Action on file `doc/muse.sgm'
+No prompt for file `doc/muse.sgm'
+
+*** Action on file `plugins/Makefile.am'
+No prompt for file `plugins/Makefile.am'
+
+*** Action on file `plugins/plugin.h'
+No prompt for file `plugins/plugin.h'
+
+*** Action on file `plugins/plugin.cpp'
+No prompt for file `plugins/plugin.cpp'
+
+*** Action on file `plugins/plugins-install.am'
+No prompt for file `plugins/plugins-install.am'
+
+*** Action on file `plugins/freeverb/denormals.h'
+No prompt for file `plugins/freeverb/denormals.h'
+
+*** Action on file `plugins/freeverb/tuning.h'
+No prompt for file `plugins/freeverb/tuning.h'
+
+*** Action on file `plugins/freeverb/readme.txt'
+No prompt for file `plugins/freeverb/readme.txt'
+
+*** Action on file `plugins/freeverb/revmodel.h'
+No prompt for file `plugins/freeverb/revmodel.h'
+
+*** Action on file `plugins/freeverb/Makefile.am'
+No prompt for file `plugins/freeverb/Makefile.am'
+
+*** Action on file `plugins/freeverb/comb.h'
+No prompt for file `plugins/freeverb/comb.h'
+
+*** Action on file `plugins/freeverb/freeverb.cpp'
+No prompt for file `plugins/freeverb/freeverb.cpp'
+
+*** Action on file `plugins/freeverb/allpass.h'
+No prompt for file `plugins/freeverb/allpass.h'
+
+*** Action on file `plugins/freeverb/revmodel.cpp'
+No prompt for file `plugins/freeverb/revmodel.cpp'
+
+*** Action on file `midictrledit.h'
+No prompt for file `midictrledit.h'
+
+
+*** Merge complete
+
diff --git a/attic/muse2-oom/muse2/muse/muse.pro b/attic/muse2-oom/muse2/muse/muse.pro
new file mode 100644
index 00000000..b9c235c9
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/muse.pro
@@ -0,0 +1,371 @@
+HEADERS = \
+ ./ctrl/ctrledit.h \
+ ./ctrl/ctrlcanvas.h \
+ ./ctrl/ctrlpanel.h \
+ ./debug.h \
+ ./midiport.h \
+ ./app.h \
+ ./eventbase.h \
+ ./key.h \
+ ./liste/listedit.h \
+ ./liste/editevent.h \
+ ./mixer/mstrip.h \
+ ./mixer/auxknob.h \
+ ./mixer/meter.h \
+ ./mixer/panknob.h \
+ ./mixer/strip.h \
+ ./mixer/rack.h \
+ ./mixer/routedialog.h \
+ ./mixer/amixer.h \
+ ./mixer/astrip.h \
+ ./mtc.h \
+ ./pos.h \
+ ./sig.h \
+ ./xml.h \
+ ./miditransform.h \
+ ./route.h \
+ ./globaldefs.h \
+ ./appearance.h \
+ ./midievent.h \
+ ./midieditor.h \
+ ./confmport.h \
+ ./patchbay/patchbay.h \
+ ./tempo.h \
+ ./audioprefetch.h \
+ ./event.h \
+ ./waveevent.h \
+ ./midiedit/pianoroll.h \
+ ./midiedit/cmd.h \
+ ./midiedit/dlist.h \
+ ./midiedit/prcanvas.h \
+ ./midiedit/quantconfig.h \
+ ./midiedit/ecanvas.h \
+ ./midiedit/drumedit.h \
+ ./midiedit/drummap.h \
+ ./midiedit/piano.h \
+ ./midiedit/dcanvas.h \
+ ./conf.h \
+ ./ctrl.h \
+ ./driver/jackaudio.h \
+ ./driver/alsamidi.h \
+ ./driver/audiodev.h \
+ ./fastlog.h \
+ ./mpevent.h \
+ ./synth.h \
+ ./cobject.h \
+ ./track.h \
+ ./evdata.h \
+ ./marker/markerview.h \
+ ./marker/marker.h \
+ ./master/tscale.h \
+ ./master/lmaster.h \
+ ./master/masteredit.h \
+ ./master/master.h \
+ ./gconfig.h \
+ ./midi.h \
+ ./waveedit/waveedit.h \
+ ./waveedit/waveview.h \
+ ./mplugins/midifilterimpl.h \
+ ./mplugins/mittranspose.h \
+ ./mplugins/random.h \
+ ./mplugins/mrconfig.h \
+ ./mplugins/midiitransform.h \
+ ./mplugins/rhythm.h \
+ ./mplugins/mitplugin.h \
+ ./node.h \
+ ./part.h \
+ ./value.h \
+ ./song.h \
+ ./sync.h \
+ ./undo.h \
+ ./ladspa.h \
+ ./wave.h \
+ ./device.h \
+ ./instruments/midictrledit.h \
+ ./instruments/minstrument.h \
+ ./instruments/editinstrument.h \
+ ./icons.h \
+ ./thread.h \
+ ./arranger/tlist.h \
+ ./arranger/arranger.h \
+ ./arranger/alayout.h \
+ ./arranger/pcanvas.h \
+ ./globals.h \
+ ./audio.h \
+ ./transpose.h \
+ ./transport.h \
+ ./widgets/section.h \
+ ./widgets/mixdowndialog.h \
+ ./widgets/dimap.h \
+ ./widgets/fontsel.h \
+ ./widgets/lcombo.h \
+ ./widgets/pitchedit.h \
+ ./widgets/tb1.h \
+ ./widgets/gatetime.h \
+ ./widgets/comboQuant.h \
+ ./widgets/ctrlcombo.h \
+ ./widgets/comment.h \
+ ./widgets/filedialog.h \
+ ./widgets/sclif.h \
+ ./widgets/scrollscale.h \
+ ./widgets/bigtime.h \
+ ./widgets/metronome.h \
+ ./widgets/combobox.h \
+ ./widgets/ttoolbutton.h \
+ ./widgets/drange.h \
+ ./widgets/scldiv.h \
+ ./widgets/vscale.h \
+ ./widgets/posedit.h \
+ ./widgets/genset.h \
+ ./widgets/shortcutcapturedialog.h \
+ ./widgets/wtscale.h \
+ ./widgets/mmath.h \
+ ./widgets/canvas.h \
+ ./widgets/shortcutconfig.h \
+ ./widgets/pitchlabel.h \
+ ./widgets/tools.h \
+ ./widgets/swidget.h \
+ ./widgets/splitter.h \
+ ./widgets/knob.h \
+ ./widgets/poslabel.h \
+ ./widgets/velocity.h \
+ ./widgets/midisyncimpl.h \
+ ./widgets/ttoolbar.h \
+ ./widgets/nentry.h \
+ ./widgets/action.h \
+ ./widgets/slider.h \
+ ./widgets/dentry.h \
+ ./widgets/siglabel.h \
+ ./widgets/checkbox.h \
+ ./widgets/mtscale.h \
+ ./widgets/spinboxFP.h \
+ ./widgets/view.h \
+ ./widgets/sigscale.h \
+ ./widgets/noteinfo.h \
+ ./widgets/doublelabel.h \
+ ./widgets/utils.h \
+ ./widgets/hitscale.h \
+ ./widgets/intlabel.h \
+ ./widgets/sigedit.h \
+ ./widgets/mlabel.h \
+ ./widgets/header.h \
+ ./widgets/tempolabel.h \
+ ./widgets/sliderbase.h \
+ ./widgets/scldraw.h \
+ ./widgets/citem.h \
+ ./widgets/songinfo.h \
+ ./mididev.h \
+ ./midictrl.h \
+ ./midiseq.h \
+ ./midifile.h \
+ ./shortcuts.h \
+ ./memory.h \
+ ./helper.h \
+ ./trackview.h \
+ ./plugin.h
+
+SOURCES = \
+ ./ctrl/ctrlpanel.cpp \
+ ./ctrl/ctrledit.cpp \
+ ./ctrl/ctrlcanvas.cpp \
+ ./route.cpp \
+ ./undo.cpp \
+ ./midievent.cpp \
+ ./xml.cpp \
+ ./memory.cpp \
+ ./key.cpp \
+ ./midiseq.cpp \
+ ./song.cpp \
+ ./liste/listedit.cpp \
+ ./liste/editevent.cpp \
+ ./mixer/strip.cpp \
+ ./mixer/auxknob.cpp \
+ ./mixer/rack.cpp \
+ ./mixer/amixer.cpp \
+ ./mixer/routedialog.cpp \
+ ./mixer/panknob.cpp \
+ ./mixer/mstrip.cpp \
+ ./mixer/astrip.cpp \
+ ./mixer/meter.cpp \
+ ./transpose.cpp \
+ ./eventlist.cpp \
+ ./transport.cpp \
+ ./wavetrack.cpp \
+ ./audioprefetch.cpp \
+ ./helper.cpp \
+ ./miditransform.cpp \
+ ./ctrl.cpp \
+ ./sig.cpp \
+ ./confmport.cpp \
+ ./shortcuts.cpp \
+ ./audio.cpp \
+ ./part.cpp \
+ ./patchbay/patchbay.cpp \
+ ./appearance.cpp \
+ ./mpevent.cpp \
+ ./midi.cpp \
+ ./event.cpp \
+ ./midiedit/drumedit.cpp \
+ ./midiedit/piano.cpp \
+ ./midiedit/ecanvas.cpp \
+ ./midiedit/quantconfig.cpp \
+ ./midiedit/pianoroll.cpp \
+ ./midiedit/dlist.cpp \
+ ./midiedit/dcanvas.cpp \
+ ./midiedit/prcanvas.cpp \
+ ./midiedit/drummap.cpp \
+ ./plugin.cpp \
+ ./conf.cpp \
+ ./driver/jack.cpp \
+ ./driver/alsamidi.cpp \
+ ./driver/dummyaudio.cpp \
+ ./midictrl.cpp \
+ ./songfile.cpp \
+ ./gconfig.cpp \
+ ./mtc.cpp \
+ ./marker/marker.cpp \
+ ./marker/markerview.cpp \
+ ./master/master.cpp \
+ ./master/tscale.cpp \
+ ./master/lmaster.cpp \
+ ./master/masteredit.cpp \
+ ./sync.cpp \
+ ./wave.cpp \
+ ./midieditor.cpp \
+ ./waveedit/waveview.cpp \
+ ./waveedit/waveedit.cpp \
+ ./mplugins/mitplugin.cpp \
+ ./mplugins/midiitransform.cpp \
+ ./mplugins/mrconfig.cpp \
+ ./mplugins/mittranspose.cpp \
+ ./mplugins/midifilterimpl.cpp \
+ ./cobject.cpp \
+ ./midifile.cpp \
+ ./midiport.cpp \
+ ./exportmidi.cpp \
+ ./value.cpp \
+ ./synth.cpp \
+ ./waveevent.cpp \
+ ./icons.cpp \
+ ./instruments/minstrument.cpp \
+ ./instruments/editinstrument.cpp \
+ ./instruments/midictrledit.cpp \
+ ./app.cpp \
+ ./arranger/arranger.cpp \
+ ./arranger/trackinfo.cpp \
+ ./arranger/pcanvas.cpp \
+ ./arranger/alayout.cpp \
+ ./arranger/tlist.cpp \
+ ./audiotrack.cpp \
+ ./seqmsg.cpp \
+ ./widgets/swidget.cpp \
+ ./widgets/ttoolbutton.cpp \
+ ./widgets/siglabel.cpp \
+ ./widgets/pitchedit.cpp \
+ ./widgets/knob.cpp \
+ ./widgets/tempolabel.cpp \
+ ./widgets/dentry.cpp \
+ ./widgets/midisyncimpl.cpp \
+ ./widgets/musewidgetsplug.cpp \
+ ./widgets/scldiv.cpp \
+ ./widgets/pitchlabel.cpp \
+ ./widgets/tools.cpp \
+ ./widgets/poslabel.cpp \
+ ./widgets/scldraw.cpp \
+ ./widgets/tb1.cpp \
+ ./widgets/gatetime.cpp \
+ ./widgets/sigscale.cpp \
+ ./widgets/vscale.cpp \
+ ./widgets/lcombo.cpp \
+ ./widgets/noteinfo.cpp \
+ ./widgets/mtscale.cpp \
+ ./widgets/scrollscale.cpp \
+ ./widgets/ttoolbar.cpp \
+ ./widgets/slider.cpp \
+ ./widgets/doublelabel.cpp \
+ ./widgets/citem.cpp \
+ ./widgets/intlabel.cpp \
+ ./widgets/sigedit.cpp \
+ ./widgets/combobox.cpp \
+ ./widgets/genset.cpp \
+ ./widgets/checkbox.cpp \
+ ./widgets/sliderbase.cpp \
+ ./widgets/comboQuant.cpp \
+ ./widgets/wtscale.cpp \
+ ./widgets/nentry.cpp \
+ ./widgets/canvas.cpp \
+ ./widgets/splitter.cpp \
+ ./widgets/posedit.cpp \
+ ./widgets/fontsel.cpp \
+ ./widgets/mixdowndialog.cpp \
+ ./widgets/ctrlcombo.cpp \
+ ./widgets/comment.cpp \
+ ./widgets/metronome.cpp \
+ ./widgets/mlabel.cpp \
+ ./widgets/spinboxFP.cpp \
+ ./widgets/drange.cpp \
+ ./widgets/velocity.cpp \
+ ./widgets/shortcutconfig.cpp \
+ ./widgets/header.cpp \
+ ./widgets/hitscale.cpp \
+ ./widgets/view.cpp \
+ ./widgets/bigtime.cpp \
+ ./widgets/filedialog.cpp \
+ ./widgets/sclif.cpp \
+ ./widgets/utils.cpp \
+ ./widgets/dimap.cpp \
+ ./widgets/mmath.cpp \
+ ./mididev.cpp \
+ ./node.cpp \
+ ./track.cpp \
+ ./pos.cpp \
+ ./globals.cpp \
+ ./importmidi.cpp \
+ ./thread.cpp \
+ ./help.cpp \
+ ./tempo.cpp
+
+FORMS = \
+ ./liste/editctrlbase.ui \
+ ./mixer/midiportroutebase.ui \
+ ./mixer/routedialogbase.ui \
+ ./patchbay/patchbaybase.ui \
+ ./mplugins/mrconfigbase.ui \
+ ./mplugins/midifilter.ui \
+ ./mplugins/rhythmbase.ui \
+ ./instruments/editinstrumentbase.ui \
+ ./instruments/ccontrolbase.ui \
+ ./widgets/synthconfigbase.ui \
+ ./widgets/mixdowndialogbase.ui \
+ ./widgets/aboutbox.ui \
+ ./widgets/editnotedialogbase.ui \
+ ./widgets/commentbase.ui \
+ ./widgets/fdialogbuttons.ui \
+ ./widgets/metronomebase.ui \
+ ./widgets/gensetbase.ui \
+ ./widgets/shortcutcapturedialogbase.ui \
+ ./widgets/mtrackinfobase.ui \
+ ./widgets/editmetadialogbase.ui \
+ ./widgets/gatetimebase.ui \
+ ./widgets/configmidifilebase.ui \
+ ./widgets/editsysexdialogbase.ui \
+ ./widgets/wtrackinfobase.ui \
+ ./widgets/midisync.ui \
+ ./widgets/appearancebase.ui \
+ ./widgets/velocitybase.ui \
+ ./widgets/cliplisteditorbase.ui \
+ ./widgets/mittransposebase.ui \
+ ./widgets/transformbase.ui \
+ ./widgets/transposebase.ui \
+ ./widgets/editctrl7dialogbase.ui \
+ ./widgets/shortcutconfigbase.ui \
+ ./widgets/itransformbase.ui
+
+TRANSLATIONS = \
+ ../share/locale/muse_de.ts \
+ ../share/locale/muse_fr.ts \
+ ../share/locale/muse_sv_SE.ts \
+ ../share/locale/muse_es.ts \
+ ../share/locale/muse_ru.ts \
+ ../share/locale/muse_pl.ts
+
diff --git a/attic/muse2-oom/muse2/muse/muse.qrc b/attic/muse2-oom/muse2/muse/muse.qrc
new file mode 100644
index 00000000..a197225d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/muse.qrc
@@ -0,0 +1,80 @@
+<!DOCTYPE RCC>
+<RCC version="1.0">
+ <qresource prefix="/">
+ <file>style.qss</file>
+ <file>images/frame.png</file>
+ <file>images/frame_clipping.png</file>
+ <file>images/up_arrow.png</file>
+ <file>images/up_arrow_disabled.png</file>
+ <file>images/down_arrow.png</file>
+ <file>images/down_arrow_disabled.png</file>
+ <file>images/spinup.png</file>
+ <file>images/spinup_off.png</file>
+ <file>images/spinup_hover.png</file>
+ <file>images/spinup_pressed.png</file>
+ <file>images/spindown.png</file>
+ <file>images/spindown_off.png</file>
+ <file>images/spindown_hover.png</file>
+ <file>images/spindown_pressed.png</file>
+ <file>images/toolbar_handle.png</file>
+ <file>images/slider_thumb.png</file>
+ <file>images/slider_thumb_h.png</file>
+ <file>images/knob.png</file>
+ <file>images/knob_aux.png</file>
+ <file>images/icons/add_tracks.png</file>
+ <file>images/icons/delete_track.png</file>
+ <file>images/icons/eraser.png</file>
+ <file>images/icons/eventfilter.png</file>
+ <file>images/icons/eventlist.png</file>
+ <file>images/icons/manage-midi-devices.png</file>
+ <file>images/icons/matrix.png</file>
+ <file>images/icons/matrix-percussion.png</file>
+ <file>images/icons/move.png</file>
+ <file>images/icons/move_track_down.png</file>
+ <file>images/icons/move_track_up.png</file>
+ <file>images/icons/mute-all.png</file>
+ <file>images/icons/pencil.png</file>
+ <file>images/icons/programchange.png</file>
+ <file>images/icons/quantize.png</file>
+ <file>images/icons/resize.png</file>
+ <file>images/icons/select.png</file>
+ <file>images/icons/split.png</file>
+ <file>images/icons/step_by_step.png</file>
+ <file>images/icons/transport-cursor-to-pointer.png</file>
+ <file>images/icons/transport-ffwd.png</file>
+ <file>images/icons/transport-ffwd-end.png</file>
+ <file>images/icons/transport-panic.png</file>
+ <file>images/icons/transport-play.png</file>
+ <file>images/icons/transport-pointer-to-cursor.png</file>
+ <file>images/icons/transport-record.png</file>
+ <file>images/icons/transport-rewind.png</file>
+ <file>images/icons/transport-rewind-end.png</file>
+ <file>images/icons/transport-solo.png</file>
+ <file>images/icons/transport-stop.png</file>
+ <file>images/icons/transport-tracking.png</file>
+ <file>images/icons/un-mute-all.png</file>
+ <file>images/icons/velocity.png</file>
+ <file>images/icons/mixer-record.png</file>
+ <file>images/icons/mixer-record_on.png</file>
+ <file>images/icons/mixer-solo.png</file>
+ <file>images/icons/mixer-solo_on.png</file>
+ <file>images/icons/mixer-mute.png</file>
+ <file>images/icons/mixer-mute_on.png</file>
+ <file>images/icons/mixer-stereo.png</file>
+ <file>images/icons/mixer-mono.png</file>
+ <file>images/icons/mixer-exit.png</file>
+ <file>images/icons/mixer-exit_on.png</file>
+ <file>images/icons/mixer-in.png</file>
+ <file>images/icons/mixer-out.png</file>
+ <file>images/icons/mixer-pre.png</file>
+ <file>images/icons/mixer-pre_on.png</file>
+ <file>images/icons/blank_record.png</file>
+ <file>images/top_rack.png</file>
+ <file>images/bottom_rack.png</file>
+ <file>images/flagSP.png</file>
+ <file>images/icons/up.png</file>
+ <file>images/icons/down.png</file>
+ <file>images/icons/garbage.png</file>
+ </qresource>
+</RCC>
+
diff --git a/attic/muse2-oom/muse2/muse/muse.qrc.ORIG b/attic/muse2-oom/muse2/muse/muse.qrc.ORIG
new file mode 100644
index 00000000..0603ba96
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/muse.qrc.ORIG
@@ -0,0 +1,85 @@
+<!DOCTYPE RCC>
+<RCC version="1.0">
+ <qresource>
+ <file>style.qss</file>
+ <file>xpm/muse_icon_64x64.png</file>
+ <file>xpm/splash.png</file>
+ <file>xpm/filenew.png</file>
+ <file>xpm/fileopen.png</file>
+ <file>xpm/filesave.png</file>
+ <file>xpm/punchin.xpm</file>
+ <file>xpm/punchout.xpm</file>
+ <file>xpm/loop.xpm</file>
+ <file>xpm/start.xpm</file>
+ <file>xpm/stop.xpm</file>
+ <file>xpm/play.xpm</file>
+ <file>xpm/frewind.xpm</file>
+ <file>xpm/fforward.xpm</file>
+ <file>xpm/folder_new.png</file>
+ <file>xpm/recordOn.svg</file>
+ <file>xpm/recordOff.svg</file>
+ <file>xpm/greendot.svg</file>
+ <file>xpm/darkgreendot.svg</file>
+ <file>xpm/activeon.svg</file>
+ <file>xpm/activeoff.svg</file>
+ <file>xpm/on.svg</file>
+ <file>xpm/off.svg</file>
+ <file>xpm/mono.svg</file>
+ <file>xpm/stereo.svg</file>
+ <file>xpm/loop.xpm</file>
+ <file>xpm/punchin.xpm</file>
+ <file>xpm/punchout.xpm</file>
+ <file>xpm/undo.xpm</file>
+ <file>xpm/redo.xpm</file>
+ <file>xpm/panic.xpm</file>
+ <file>xpm/piano.xpm</file>
+ <file>xpm/view_transport_window.xpm</file>
+ <file>xpm/view_bigtime_window.xpm</file>
+ <file>xpm/view_cliplist.xpm</file>
+ <file>xpm/view_marker.xpm</file>
+ <file>xpm/view_mixer.xpm</file>
+ <file>xpm/pointer.xpm</file>
+ <file>xpm/pencil.xpm</file>
+ <file>xpm/delete.xpm</file>
+ <file>xpm/cut.xpm</file>
+ <file>xpm/glue.xpm</file>
+ <file>xpm/quant.xpm</file>
+ <file>xpm/draw.xpm</file>
+ <file>xpm/editmute.xpm</file>
+
+ <file>xpm/select_all.xpm</file>
+ <file>xpm/select_deselect_all.xpm</file>
+ <file>xpm/select_invert_selection.xpm</file>
+ <file>xpm/select_inside_loop.xpm</file>
+ <file>xpm/select_outside_loop.xpm</file>
+ <file>xpm/editcut.xpm</file>
+ <file>xpm/editcopy.xpm</file>
+ <file>xpm/editpaste.xpm</file>
+ <file>xpm/edit_drumms.xpm</file>
+ <file>xpm/edit_mastertrack.xpm</file>
+ <file>xpm/edit_list.xpm</file>
+ <file>xpm/wave.xpm</file>
+
+ </qresource>
+
+ <qresource lang="de">
+ <file alias="muse.qm">../share/locale/muse_de.qm</file>
+ </qresource>
+
+ <qresource lang="es">
+ <file alias="muse.qm">../share/locale/muse_es.qm</file>
+ </qresource>
+
+ <qresource lang="fr">
+ <file alias="muse.qm">../share/locale/muse_fr.qm</file>
+ </qresource>
+
+ <qresource lang="ru">
+ <file alias="muse.qm">../share/locale/muse_ru.qm</file>
+ </qresource>
+
+ <qresource lang="sv">
+ <file alias="muse.qm">../share/locale/muse_sv_SE.qm</file>
+ </qresource>
+</RCC>
+
diff --git a/attic/muse2-oom/muse2/muse/node.cpp b/attic/muse2-oom/muse2/muse/node.cpp
new file mode 100644
index 00000000..8db0a3d3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/node.cpp
@@ -0,0 +1,1911 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: node.cpp,v 1.36.2.25 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 2000-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <cmath>
+#include <assert.h>
+#include <sndfile.h>
+#include <stdlib.h>
+
+#include "node.h"
+#include "globals.h"
+#include "gconfig.h"
+#include "song.h"
+#include "xml.h"
+#include "plugin.h"
+#include "synth.h"
+#include "audiodev.h"
+#include "audio.h"
+#include "wave.h"
+#include "utils.h" //debug
+#include "ticksynth.h" // metronome
+#include "al/dsp.h"
+
+// Uncomment this (and make sure to set Jack buffer size high like 2048)
+// to see process flow messages.
+//#define NODE_DEBUG
+//#define FIFO_DEBUG
+
+// Added by Tim. p3.3.18
+//#define METRONOME_DEBUG
+
+//---------------------------------------------------------
+// isMute
+//---------------------------------------------------------
+
+bool MidiTrack::isMute() const
+ {
+ if (_solo || (_internalSolo && !_mute))
+ return false;
+
+ if (_soloRefCnt)
+ return true;
+
+ return _mute;
+ }
+
+bool AudioTrack::isMute() const
+ {
+ if (_solo || (_internalSolo && !_mute))
+ return false;
+
+ if (_soloRefCnt)
+ return true;
+
+ return _mute;
+ }
+
+//---------------------------------------------------------
+// setSolo
+//---------------------------------------------------------
+
+void MidiTrack::setSolo(bool val)
+{
+ if(_solo != val)
+ {
+ _solo = val;
+ updateSoloStates(false);
+ }
+}
+
+void AudioTrack::setSolo(bool val)
+{
+ if(_solo != val)
+ {
+ _solo = val;
+ updateSoloStates(false);
+ }
+
+ if (isMute())
+ resetMeter();
+}
+
+//---------------------------------------------------------
+// setInternalSolo
+//---------------------------------------------------------
+
+void Track::setInternalSolo(unsigned int val)
+{
+ _internalSolo = val;
+}
+
+//---------------------------------------------------------
+// clearSoloRefCounts
+// This is a static member function. Required for outside access.
+// Clears the internal static reference counts.
+//---------------------------------------------------------
+
+void Track::clearSoloRefCounts()
+{
+ _soloRefCnt = 0;
+}
+
+//---------------------------------------------------------
+// updateSoloState
+//---------------------------------------------------------
+
+void Track::updateSoloState()
+{
+ if(_solo)
+ _soloRefCnt++;
+ else
+ if(_soloRefCnt && !_tmpSoloChainNoDec)
+ _soloRefCnt--;
+}
+
+//---------------------------------------------------------
+// updateInternalSoloStates
+//---------------------------------------------------------
+
+void Track::updateInternalSoloStates()
+{
+ if(_tmpSoloChainTrack->solo())
+ {
+ _internalSolo++;
+ _soloRefCnt++;
+ }
+ else
+ if(!_tmpSoloChainNoDec)
+ {
+ if(_internalSolo)
+ _internalSolo--;
+ if(_soloRefCnt)
+ _soloRefCnt--;
+ }
+}
+
+//---------------------------------------------------------
+// updateInternalSoloStates
+//---------------------------------------------------------
+
+void MidiTrack::updateInternalSoloStates()
+{
+ if(this == _tmpSoloChainTrack)
+ return;
+
+ Track::updateInternalSoloStates();
+}
+
+//---------------------------------------------------------
+// updateInternalSoloStates
+//---------------------------------------------------------
+
+void AudioTrack::updateInternalSoloStates()
+{
+ if(this == _tmpSoloChainTrack)
+ return;
+
+ Track::updateInternalSoloStates();
+
+ if(_tmpSoloChainDoIns)
+ {
+ if(type() == AUDIO_SOFTSYNTH)
+ {
+ const MidiTrackList* ml = song->midis();
+ for(ciMidiTrack im = ml->begin(); im != ml->end(); ++im)
+ {
+ MidiTrack* mt = *im;
+ if(mt->outPort() >= 0 && mt->outPort() == ((SynthI*)this)->midiPort())
+ mt->updateInternalSoloStates();
+ }
+ }
+
+ const RouteList* rl = inRoutes();
+ for(ciRoute ir = rl->begin(); ir != rl->end(); ++ir)
+ {
+ if(ir->type == Route::TRACK_ROUTE)
+ ir->track->updateInternalSoloStates();
+ }
+ }
+ else
+ {
+ const RouteList* rl = outRoutes();
+ for(ciRoute ir = rl->begin(); ir != rl->end(); ++ir)
+ {
+ if(ir->type == Route::TRACK_ROUTE)
+ ir->track->updateInternalSoloStates();
+ }
+ }
+}
+
+//---------------------------------------------------------
+// updateSoloStates
+//---------------------------------------------------------
+
+void MidiTrack::updateSoloStates(bool noDec)
+{
+ if(noDec && !_solo)
+ return;
+
+ _tmpSoloChainTrack = this;
+ _tmpSoloChainDoIns = false;
+ _tmpSoloChainNoDec = noDec;
+ updateSoloState();
+
+ if(outPort() >= 0)
+ {
+ MidiDevice *md = midiPorts[outPort()].device();
+ if(md && md->isSynti())
+ ((SynthI*)md)->updateInternalSoloStates();
+ }
+}
+
+//---------------------------------------------------------
+// updateSoloStates
+//---------------------------------------------------------
+
+void AudioTrack::updateSoloStates(bool noDec)
+{
+ if(noDec && !_solo)
+ return;
+
+ _tmpSoloChainTrack = this;
+ _tmpSoloChainNoDec = noDec;
+ updateSoloState();
+
+ _tmpSoloChainDoIns = true;
+ if(type() == AUDIO_SOFTSYNTH)
+ {
+ const MidiTrackList* ml = song->midis();
+ for(ciMidiTrack im = ml->begin(); im != ml->end(); ++im)
+ {
+ MidiTrack* mt = *im;
+ if(mt->outPort() >= 0 && mt->outPort() == ((SynthI*)this)->midiPort())
+ mt->updateInternalSoloStates();
+ }
+ }
+
+ {
+ const RouteList* rl = inRoutes();
+ for(ciRoute ir = rl->begin(); ir != rl->end(); ++ir)
+ {
+ if(ir->type == Route::TRACK_ROUTE)
+ ir->track->updateInternalSoloStates();
+ }
+ }
+ _tmpSoloChainDoIns = false;
+ {
+ const RouteList* rl = outRoutes();
+ for(ciRoute ir = rl->begin(); ir != rl->end(); ++ir)
+ {
+ if(ir->type == Route::TRACK_ROUTE)
+ ir->track->updateInternalSoloStates();
+ }
+ }
+}
+
+//---------------------------------------------------------
+// setMute
+//---------------------------------------------------------
+
+void Track::setMute(bool val)
+ {
+ _mute = val;
+ }
+
+//---------------------------------------------------------
+// setOff
+//---------------------------------------------------------
+
+void Track::setOff(bool val)
+ {
+ _off = val;
+ }
+
+//---------------------------------------------------------
+// copyData
+//---------------------------------------------------------
+
+//void AudioTrack::copyData(unsigned pos, int dstChannels, unsigned nframes, float** dstBuffer)
+void AudioTrack::copyData(unsigned pos, int dstChannels, int srcStartChan, int srcChannels, unsigned nframes, float** dstBuffer)
+{
+ //Changed by T356. 12/12/09.
+ // Overhaul and streamline to eliminate multiple processing during one process loop.
+ // Was causing ticking sound with synths + multiple out routes because synths were being processed multiple times.
+ // Make better use of AudioTrack::outBuffers as a post-effect pre-volume cache system for multiple calls here during processing.
+ // Previously only WaveTrack used them. (Changed WaveTrack as well).
+
+ if(srcStartChan == -1)
+ srcStartChan = 0;
+
+ int srcChans = (srcChannels == -1) ? channels() : srcChannels;
+ int srcTotalOutChans = totalOutChannels();
+ if(channels() == 1)
+ srcTotalOutChans = 1;
+
+ #ifdef NODE_DEBUG
+ printf("MusE: AudioTrack::copyData name:%s processed:%d\n", name().toLatin1().constData(), processed());
+ #endif
+
+ // Special consideration for metronome: It is not part of the track list,
+ // and it has no in or out routes, yet multiple output tracks may call addData on it !
+ // We can't tell how many output tracks call it, so we can only assume there might be more than one.
+ // Not strictly necessary here because only addData is ever called, but just to be consistent...
+ //bool usedirectbuf = (outRoutes()->size() <= 1) || (type() == AUDIO_OUTPUT);
+ bool usedirectbuf = ((outRoutes()->size() <= 1) || (type() == AUDIO_OUTPUT)) && (this != metronome);
+
+ int i;
+
+ // p3.3.38
+ //float* buffer[srcChannels];
+ float* buffer[srcTotalOutChans];
+
+
+ //float data[nframes * srcChannels];
+ //for(i = 0; i < srcChannels; ++i)
+ // buffer[i] = data + i * nframes;
+
+ // precalculate stereo volume
+ double vol[2];
+ double _volume = volume();
+ double _pan = pan();
+ vol[0] = _volume * (1.0 - _pan);
+ vol[1] = _volume * (1.0 + _pan);
+ float meter[srcChans];
+
+ // Have we been here already during this process cycle?
+ if(processed())
+ {
+ // If there is only one (or no) output routes, it's an error - we've been called more than once per process cycle!
+ #ifdef NODE_DEBUG
+ if(usedirectbuf)
+ printf("MusE: AudioTrack::copyData Error! One or no out routes, but already processed! Copying local buffers anyway...\n");
+ #endif
+
+ // Is there already some data gathered from a previous call during this process cycle?
+ if(_haveData)
+ {
+ // Point the input buffers at our local cached 'pre-volume' buffers. They need processing, so continue on after.
+ //for(i = 0; i < srcChannels; ++i)
+ // buffer[i] = outBuffers[i];
+ // p3.3.38
+ for(i = 0; i < srcTotalOutChans; ++i)
+ buffer[i] = outBuffers[i];
+ }
+ else
+ {
+ // No data was available from a previous call during this process cycle. Zero the supplied buffers and just return.
+ for(i = 0; i < dstChannels; ++i)
+ {
+ if(config.useDenormalBias)
+ {
+ for(unsigned int q = 0; q < nframes; ++q)
+ dstBuffer[i][q] = denormalBias;
+ }
+ else
+ memset(dstBuffer[i], 0, sizeof(float) * nframes);
+ }
+ return;
+ }
+ }
+ else
+ {
+ // First time here during this process cycle.
+
+ // Point the input buffers at a temporary stack buffer.
+ //float data[nframes * srcChannels];
+ //for(i = 0; i < srcChannels; ++i)
+ // buffer[i] = data + i * nframes;
+ // p3.3.38
+ float data[nframes * srcTotalOutChans];
+ for(i = 0; i < srcTotalOutChans; ++i)
+ buffer[i] = data + i * nframes;
+
+ // getData can use the supplied buffers, or change buffer to point to its own local buffers or Jack buffers etc.
+ // For ex. if this is an audio input, Jack will set the pointers for us in AudioInput::getData!
+ // p3.3.29 1/27/10 Don't do any processing at all if off. Whereas, mute needs to be ready for action at all times,
+ // so still call getData before it. Off is NOT meant to be toggled rapidly, but mute is !
+ //if(!getData(pos, srcChannels, nframes, buffer) || off() || (isMute() && !_prefader))
+ //if(off() || !getData(pos, srcChannels, nframes, buffer) || (isMute() && !_prefader))
+ // p3.3.38
+ if(off() || !getData(pos, srcTotalOutChans, nframes, buffer) || (isMute() && !_prefader))
+ {
+ #ifdef NODE_DEBUG
+ printf("MusE: AudioTrack::copyData name:%s dstChannels:%d zeroing buffers\n", name().toLatin1().constData(), dstChannels);
+ #endif
+
+ // No data was available. Zero the supplied buffers.
+ unsigned int q;
+ for(i = 0; i < dstChannels; ++i)
+ {
+ if(config.useDenormalBias)
+ {
+ for(q = 0; q < nframes; ++q)
+ dstBuffer[i][q] = denormalBias;
+ }
+ else
+ memset(dstBuffer[i], 0, sizeof(float) * nframes);
+ }
+
+ for(i = 0; i < srcChans; ++i)
+ {
+ //_meter[i] = 0;
+ _meter[i] = 0.0;
+
+ /*
+ if(!usedirectbuf)
+ {
+ if(config.useDenormalBias)
+ {
+ for(q = 0; q < nframes; ++q)
+ outBuffers[i][q] = denormalBias;
+ }
+ else
+ memset(outBuffers[i], 0, sizeof(float) * nframes);
+ }
+ */
+ }
+
+ _haveData = false;
+ _processed = true;
+ return;
+ }
+
+ //---------------------------------------------------
+ // apply plugin chain
+ //---------------------------------------------------
+
+ // p3.3.41
+ //fprintf(stderr, "AudioTrack::copyData %s efx apply srcChans:%d\n", name().toLatin1().constData(), srcChans);
+ _efxPipe->apply(srcChans, nframes, buffer);
+
+ //---------------------------------------------------
+ // aux sends
+ //---------------------------------------------------
+
+ if(hasAuxSend() && !isMute())
+ {
+ AuxList* al = song->auxs();
+ unsigned naux = al->size();
+ for(unsigned k = 0; k < naux; ++k)
+ {
+ float m = _auxSend[k];
+ if(m <= 0.0001) // optimize
+ continue;
+ AudioAux* a = (AudioAux*)((*al)[k]);
+ float** dst = a->sendBuffer();
+ int auxChannels = a->channels();
+ if((srcChans ==1 && auxChannels==1) || srcChans == 2)
+ {
+ for(int ch = 0; ch < srcChans; ++ch)
+ {
+ float* db = dst[ch % a->channels()]; // no matter whether there's one or two dst buffers
+ float* sb = buffer[ch];
+ for(unsigned f = 0; f < nframes; ++f)
+ *db++ += (*sb++ * m * vol[ch]); // add to mix
+ }
+ }
+ else if(srcChans==1 && auxChannels==2) // copy mono to both channels
+ {
+ for(int ch = 0; ch < auxChannels; ++ch)
+ {
+ float* db = dst[ch % a->channels()];
+ float* sb = buffer[0];
+ for(unsigned f = 0; f < nframes; ++f)
+ *db++ += (*sb++ * m * vol[ch]); // add to mix
+ }
+ }
+ }
+ }
+
+ //---------------------------------------------------
+ // prefader metering
+ //---------------------------------------------------
+
+ if(_prefader)
+ {
+ for(i = 0; i < srcChans; ++i)
+ {
+ float* p = buffer[i];
+ meter[i] = 0.0;
+ for(unsigned k = 0; k < nframes; ++k)
+ {
+ double f = fabs(*p);
+ if(f > meter[i])
+ meter[i] = f;
+ ++p;
+ }
+ //_meter[i] = lrint(meter[i] * 32767.0);
+ _meter[i] = meter[i];
+ if(_meter[i] > _peak[i])
+ _peak[i] = _meter[i];
+ }
+ }
+
+ if(isMute())
+ {
+ unsigned int q;
+ for(i = 0; i < dstChannels; ++i)
+ {
+ if(config.useDenormalBias)
+ {
+ for(q = 0; q < nframes; q++)
+ dstBuffer[i][q] = denormalBias;
+ }
+ else
+ memset(dstBuffer[i], 0, sizeof(float) * nframes);
+ }
+
+ /*
+ if(!usedirectbuf)
+ {
+ for(i = 0; i < srcChannels; ++i)
+ {
+ if(config.useDenormalBias)
+ {
+ for(q = 0; q < nframes; ++q)
+ outBuffers[i][q] = denormalBias;
+ }
+ else
+ memset(outBuffers[i], 0, sizeof(float) * nframes);
+ }
+ }
+ */
+
+ _haveData = false;
+ _processed = true;
+ return;
+ }
+
+ // If we're using local cached 'pre-volume' buffers, copy the input buffers (as they are right now: post-effect pre-volume) back to them.
+ if(!usedirectbuf)
+ {
+ //for(i = 0; i < srcChannels; ++i)
+ // AL::dsp->cpy(outBuffers[i], buffer[i], nframes);
+ // p3.3.38
+ for(i = 0; i < srcTotalOutChans; ++i)
+ AL::dsp->cpy(outBuffers[i], buffer[i], nframes);
+ }
+
+ // We have some data! Set to true.
+ _haveData = true;
+ }
+
+ // Sanity check. Is source starting channel out of range? Just zero and return.
+ if(srcStartChan >= srcTotalOutChans)
+ {
+ unsigned int q;
+ for(i = 0; i < dstChannels; ++i)
+ {
+ if(config.useDenormalBias)
+ {
+ for(q = 0; q < nframes; q++)
+ dstBuffer[i][q] = denormalBias;
+ }
+ else
+ memset(dstBuffer[i], 0, sizeof(float) * nframes);
+ }
+ _processed = true;
+ return;
+ }
+ // Force a source range to fit actual available total out channels.
+ if((srcStartChan + srcChans) > srcTotalOutChans)
+ srcChans = srcTotalOutChans - srcStartChan;
+
+ //---------------------------------------------------
+ // apply volume
+ // postfader metering
+ //---------------------------------------------------
+
+
+ if(srcChans == dstChannels)
+ {
+ if(_prefader)
+ {
+ for(int c = 0; c < dstChannels; ++c)
+ {
+ // p3.3.38
+ //float* sp = buffer[c];
+ float* sp = buffer[c + srcStartChan];
+
+ float* dp = dstBuffer[c];
+ for(unsigned k = 0; k < nframes; ++k)
+ *dp++ = (*sp++ * vol[c]);
+ }
+ }
+ else
+ {
+ for(int c = 0; c < dstChannels; ++c)
+ {
+ meter[c] = 0.0;
+
+ // p3.3.38
+ //float* sp = buffer[c];
+ float* sp = buffer[c + srcStartChan];
+
+ float* dp = dstBuffer[c];
+ //printf("2 dstBuffer[c]=%d\n",long(dstBuffer[c]));
+ for(unsigned k = 0; k < nframes; ++k)
+ {
+ float val = *sp++ * vol[c];
+ *dp++ = val;
+ double f = fabs(val);
+ if(f > meter[c])
+ meter[c] = f;
+ }
+ //_meter[c] = lrint(meter[c] * 32767.0);
+ _meter[c] = meter[c];
+ if(_meter[c] > _peak[c])
+ _peak[c] = _meter[c];
+ }
+ }
+ }
+ else if(srcChans == 1 && dstChannels == 2)
+ {
+ // p3.3.38
+ //float* sp = buffer[0];
+ float* sp = buffer[srcStartChan];
+
+ if(_prefader)
+ {
+ for(int c = 0; c < dstChannels; ++c)
+ {
+ float* dp = dstBuffer[c];
+ for(unsigned k = 0; k < nframes; ++k)
+ *dp++ = (*sp++ * vol[c]);
+ }
+ }
+ else
+ {
+ meter[0] = 0.0;
+ for(unsigned k = 0; k < nframes; ++k)
+ {
+ float val = *sp++;
+ double f = fabs(val) * _volume;
+ if(f > meter[0])
+ meter[0] = f;
+ *(dstBuffer[0] + k) = val * vol[0];
+ *(dstBuffer[1] + k) = val * vol[1];
+ }
+ //_meter[0] = lrint(meter[0] * 32767.0);
+ _meter[0] = meter[0];
+ if(_meter[0] > _peak[0])
+ _peak[0] = _meter[0];
+ }
+ }
+ else if(srcChans == 2 && dstChannels == 1)
+ {
+ // p3.3.38
+ //float* sp1 = buffer[0];
+ //float* sp2 = buffer[1];
+ float* sp1 = buffer[srcStartChan];
+ float* sp2 = buffer[srcStartChan + 1];
+
+ if(_prefader)
+ {
+ float* dp = dstBuffer[0];
+ for(unsigned k = 0; k < nframes; ++k)
+ *dp++ = (*sp1++ * vol[0] + *sp2++ * vol[1]);
+ }
+ else
+ {
+ float* dp = dstBuffer[0];
+ meter[0] = 0.0;
+ meter[1] = 0.0;
+ for(unsigned k = 0; k < nframes; ++k)
+ {
+ float val1 = *sp1++ * vol[0];
+ float val2 = *sp2++ * vol[1];
+ double f1 = fabs(val1);
+ if(f1 > meter[0])
+ meter[0] = f1;
+ double f2 = fabs(val2);
+ if(f2 > meter[1])
+ meter[1] = f2;
+ *dp++ = (val1 + val2);
+ }
+ //_meter[0] = lrint(meter[0] * 32767.0);
+ _meter[0] = meter[0];
+ if(_meter[0] > _peak[0])
+ _peak[0] = _meter[0];
+ //_meter[1] = lrint(meter[1] * 32767.0);
+ _meter[1] = meter[1];
+ if(_meter[1] > _peak[1])
+ _peak[1] = _meter[1];
+ }
+ }
+
+ _processed = true;
+}
+
+//---------------------------------------------------------
+// addData
+//---------------------------------------------------------
+
+//void AudioTrack::addData(unsigned pos, int dstChannels, unsigned nframes, float** dstBuffer)
+void AudioTrack::addData(unsigned pos, int dstChannels, int srcStartChan, int srcChannels, unsigned nframes, float** dstBuffer)
+{
+ //Changed by T356. 12/12/09.
+ // Overhaul and streamline to eliminate multiple processing during one process loop.
+ // Was causing ticking sound with synths + multiple out routes because synths were being processed multiple times.
+ // Make better use of AudioTrack::outBuffers as a post-effect pre-volume cache system for multiple calls here during processing.
+ // Previously only WaveTrack used them. (Changed WaveTrack as well).
+
+ //Added by Tim. p3.3.16
+ #ifdef NODE_DEBUG
+ printf("MusE: AudioTrack::addData name:%s processed:%d\n", name().toLatin1().constData(), processed());
+ #endif
+
+ if (off())
+ {
+ _processed = true;
+ return;
+ }
+
+ if(srcStartChan == -1)
+ srcStartChan = 0;
+
+ int srcChans = (srcChannels == -1) ? channels() : srcChannels;
+ int srcTotalOutChans = totalOutChannels();
+ if(channels() == 1)
+ srcTotalOutChans = 1;
+
+ // Special consideration for metronome: It is not part of the track list,
+ // and it has no in or out routes, yet multiple output tracks may call addData on it !
+ // We can't tell how many output tracks call it, so we can only assume there might be more than one.
+ //bool usedirectbuf = (outRoutes()->size() <= 1) || (type() == AUDIO_OUTPUT);
+ bool usedirectbuf = ((outRoutes()->size() <= 1) || (type() == AUDIO_OUTPUT)) && (this != metronome);
+
+ int i;
+
+ // p3.3.38
+ //float* buffer[srcChannels];
+ float* buffer[srcTotalOutChans];
+
+ //float data[nframes * srcChannels];
+ //for (i = 0; i < srcChannels; ++i)
+ // buffer[i] = data + i * nframes;
+
+ // precalculate stereo volume
+ double vol[2];
+ double _volume = volume();
+ double _pan = pan();
+ vol[0] = _volume * (1.0 - _pan);
+ vol[1] = _volume * (1.0 + _pan);
+ float meter[srcChans];
+
+ // Have we been here already during this process cycle?
+ if(processed())
+ {
+ // If there is only one (or no) output routes, it's an error - we've been called more than once per process cycle!
+ #ifdef NODE_DEBUG
+ if(usedirectbuf)
+ printf("MusE: AudioTrack::addData Error! One or no out routes, but already processed! Copying local buffers anyway...\n");
+ #endif
+
+ // Is there already some data gathered from a previous call during this process cycle?
+ if(_haveData)
+ {
+ // Point the input buffers at our local cached 'pre-volume' buffers. They need processing, so continue on after.
+ //for(i = 0; i < srcChannels; ++i)
+ // buffer[i] = outBuffers[i];
+ // p3.3.38
+ for(i = 0; i < srcTotalOutChans; ++i)
+ buffer[i] = outBuffers[i];
+ }
+ else
+ // No data was available from a previous call during this process cycle. Nothing to add, just return.
+ return;
+ }
+ else
+ {
+ // First time here during this process cycle.
+
+ // Point the input buffers at a temporary stack buffer.
+ //float data[nframes * srcChannels];
+ //for(i = 0; i < srcChannels; ++i)
+ // buffer[i] = data + i * nframes;
+ // p3.3.38
+ float data[nframes * srcTotalOutChans];
+ for(i = 0; i < srcTotalOutChans; ++i)
+ buffer[i] = data + i * nframes;
+
+
+ // getData can use the supplied buffers, or change buffer to point to its own local buffers or Jack buffers etc.
+ // For ex. if this is an audio input, Jack will set the pointers for us.
+ //if(!getData(pos, srcChannels, nframes, buffer))
+ // p3.3.38
+ if(!getData(pos, srcTotalOutChans, nframes, buffer))
+ {
+ // No data was available. Nothing to add, but zero our local buffers and the meters.
+ for(i = 0; i < srcChans; ++i)
+ {
+ // If we're using local buffers, we must zero them so that the next thing requiring them
+ // during this process cycle will see zeros.
+ /*
+ if(!usedirectbuf)
+ {
+ if(config.useDenormalBias)
+ {
+ for(unsigned int q = 0; q < nframes; ++q)
+ outBuffers[i][q] = denormalBias;
+ }
+ else
+ memset(outBuffers[i], 0, sizeof(float) * nframes);
+ }
+ */
+
+ //_meter[i] = 0;
+ _meter[i] = 0.0;
+ }
+
+ _haveData = false;
+ _processed = true;
+ return;
+ }
+
+ /*
+ // p3.3.41 Added.
+ unsigned int q;
+ for(i = 0; i < srcChans; ++i)
+ {
+ if(config.useDenormalBias)
+ {
+ for(q = 0; q < nframes; ++q)
+ {
+ if(q & 1)
+ buffer[i][q] -= denormalBias;
+ else
+ buffer[i][q] += denormalBias;
+ }
+ }
+ }
+ */
+
+ //---------------------------------------------------
+ // apply plugin chain
+ //---------------------------------------------------
+
+ // p3.3.41
+ //fprintf(stderr, "AudioTrack::addData %s efx apply srcChans:%d nframes:%ld %e %e %e %e\n",
+ // name().toLatin1().constData(), srcChans, nframes, buffer[0][0], buffer[0][1], buffer[0][2], buffer[0][3]);
+ _efxPipe->apply(srcChans, nframes, buffer);
+ // p3.3.41
+ //fprintf(stderr, "AudioTrack::addData after efx: %e %e %e %e\n",
+ // buffer[0][0], buffer[0][1], buffer[0][2], buffer[0][3]);
+
+ //---------------------------------------------------
+ // aux sends
+ //---------------------------------------------------
+
+ if(hasAuxSend() && !isMute())
+ {
+ AuxList* al = song->auxs();
+ unsigned naux = al->size();
+ for(unsigned k = 0; k < naux; ++k)
+ {
+ float m = _auxSend[k];
+ if(m <= 0.0001) // optimize
+ continue;
+ AudioAux* a = (AudioAux*)((*al)[k]);
+ float** dst = a->sendBuffer();
+ int auxChannels = a->channels();
+ if((srcChans ==1 && auxChannels==1) || srcChans==2)
+ {
+ for(int ch = 0; ch < srcChans; ++ch)
+ {
+ float* db = dst[ch % a->channels()];
+ float* sb = buffer[ch];
+ for(unsigned f = 0; f < nframes; ++f)
+ *db++ += (*sb++ * m * vol[ch]); // add to mix
+ }
+ }
+ else if(srcChans == 1 && auxChannels == 2)
+ {
+ for(int ch = 0; ch < auxChannels; ++ch)
+ {
+ float* db = dst[ch % a->channels()];
+ float* sb = buffer[0];
+ for(unsigned f = 0; f < nframes; ++f)
+ *db++ += (*sb++ * m * vol[ch]); // add to mix
+ }
+ }
+ }
+ }
+
+ //---------------------------------------------------
+ // prefader metering
+ //---------------------------------------------------
+
+ if(_prefader)
+ {
+ for(i = 0; i < srcChans; ++i)
+ {
+ float* p = buffer[i];
+ meter[i] = 0.0;
+ for(unsigned k = 0; k < nframes; ++k)
+ {
+ double f = fabs(*p);
+ if(f > meter[i])
+ meter[i] = f;
+ ++p;
+ }
+ //_meter[i] = lrint(meter[i] * 32767.0);
+ _meter[i] = meter[i];
+ if(_meter[i] > _peak[i])
+ _peak[i] = _meter[i];
+ }
+ }
+
+ if(isMute())
+ {
+ // If we're using local buffers, we must zero them.
+ /*
+ if(!usedirectbuf)
+ {
+ for(i = 0; i < srcChannels; ++i)
+ {
+ if(config.useDenormalBias)
+ {
+ for(unsigned int q = 0; q < nframes; ++q)
+ outBuffers[i][q] = denormalBias;
+ }
+ else
+ memset(outBuffers[i], 0, sizeof(float) * nframes);
+ }
+ }
+ */
+
+ _haveData = false;
+ _processed = true;
+ return;
+ }
+
+ // If we're using local cached 'pre-volume' buffers, copy the input buffers (as they are right now: post-effect pre-volume) back to them.
+ if(!usedirectbuf)
+ {
+ //for(i = 0; i < srcChannels; ++i)
+ // AL::dsp->cpy(outBuffers[i], buffer[i], nframes);
+ // p3.3.38
+ for(i = 0; i < srcTotalOutChans; ++i)
+ AL::dsp->cpy(outBuffers[i], buffer[i], nframes);
+ }
+
+ // We have some data! Set to true.
+ _haveData = true;
+ }
+
+ // Sanity check. Is source starting channel out of range? Just zero and return.
+ if(srcStartChan >= srcTotalOutChans)
+ {
+ unsigned int q;
+ for(i = 0; i < dstChannels; ++i)
+ {
+ if(config.useDenormalBias)
+ {
+ for(q = 0; q < nframes; q++)
+ dstBuffer[i][q] = denormalBias;
+ }
+ else
+ memset(dstBuffer[i], 0, sizeof(float) * nframes);
+ }
+ _processed = true;
+ return;
+ }
+ // Force a source range to fit actual available total out channels.
+ if((srcStartChan + srcChans) > srcTotalOutChans)
+ srcChans = srcTotalOutChans - srcStartChan;
+
+ //---------------------------------------------------
+ // apply volume
+ // postfader metering
+ //---------------------------------------------------
+
+ if(srcChans == dstChannels)
+ {
+ if(_prefader)
+ {
+ for(int c = 0; c < dstChannels; ++c)
+ {
+ // p3.3.38
+ //float* sp = buffer[c];
+ float* sp = buffer[c + srcStartChan];
+
+ float* dp = dstBuffer[c];
+ for(unsigned k = 0; k < nframes; ++k)
+ *dp++ += (*sp++ * vol[c]);
+ }
+ }
+ else
+ {
+ for(int c = 0; c < dstChannels; ++c)
+ {
+ meter[c] = 0.0;
+ // p3.3.38
+ //float* sp = buffer[c];
+ float* sp = buffer[c + srcStartChan];
+
+ float* dp = dstBuffer[c];
+ for(unsigned k = 0; k < nframes; ++k)
+ {
+ float val = *sp++ * vol[c];
+ *dp++ += val;
+ double f = fabs(val);
+ if (f > meter[c])
+ meter[c] = f;
+ }
+ //_meter[c] = lrint(meter[c] * 32767.0);
+ _meter[c] = meter[c];
+ if(_meter[c] > _peak[c])
+ _peak[c] = _meter[c];
+ }
+ }
+ }
+ else if(srcChans == 1 && dstChannels == 2)
+ {
+ // p3.3.38
+ float* sp = buffer[srcStartChan];
+
+ if(_prefader)
+ {
+ for(int c = 0; c < dstChannels; ++c)
+ {
+ float* dp = dstBuffer[c];
+ //float* sp = buffer[0];
+ for(unsigned k = 0; k < nframes; ++k)
+ *dp++ += (*sp++ * vol[c]);
+ }
+ }
+ else
+ {
+ //float* sp = buffer[0];
+ meter[0] = 0.0;
+ for(unsigned k = 0; k < nframes; ++k)
+ {
+ float val = *sp++;
+ double f = fabs(val) * _volume;
+ if(f > meter[0])
+ meter[0] = f;
+ *(dstBuffer[0] + k) += val * vol[0];
+ *(dstBuffer[1] + k) += val * vol[1];
+ }
+ //_meter[0] = lrint(meter[0] * 32767.0);
+ _meter[0] = meter[0];
+ if(_meter[0] > _peak[0])
+ _peak[0] = _meter[0];
+ }
+ }
+ else if(srcChans == 2 && dstChannels == 1)
+ {
+ // p3.3.38
+ //float* sp1 = buffer[0];
+ //float* sp2 = buffer[1];
+ float* sp1 = buffer[srcStartChan];
+ float* sp2 = buffer[srcStartChan + 1];
+
+ if(_prefader)
+ {
+ float* dp = dstBuffer[0];
+ for(unsigned k = 0; k < nframes; ++k)
+ *dp++ += (*sp1++ * vol[0] + *sp2++ * vol[1]);
+ }
+ else
+ {
+ float* dp = dstBuffer[0];
+ meter[0] = 0.0;
+ meter[1] = 0.0;
+ for(unsigned k = 0; k < nframes; ++k)
+ {
+ float val1 = *sp1++ * vol[0];
+ float val2 = *sp2++ * vol[1];
+ double f1 = fabs(val1);
+ if(f1 > meter[0])
+ meter[0] = f1;
+ double f2 = fabs(val2);
+ if(f2 > meter[1])
+ meter[1] = f2;
+ *dp++ += (val1 + val2);
+ }
+ //_meter[0] = lrint(meter[0] * 32767.0);
+ _meter[0] = meter[0];
+ if(_meter[0] > _peak[0])
+ _peak[0] = _meter[0];
+ //_meter[1] = lrint(meter[1] * 32767.0);
+ _meter[1] = meter[1];
+ if(_meter[1] > _peak[1])
+ _peak[1] = _meter[1];
+ }
+ }
+
+ _processed = true;
+}
+
+//---------------------------------------------------------
+// readVolume
+//---------------------------------------------------------
+
+void AudioTrack::readVolume(Xml& xml)
+ {
+ int ch = 0;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ xml.unknown("readVolume");
+ break;
+ case Xml::Text:
+ setVolume(xml.s1().toDouble());
+ break;
+ case Xml::Attribut:
+ if (xml.s1() == "ch")
+ ch = xml.s2().toInt();
+ break;
+ case Xml::TagEnd:
+ if (xml.s1() == "volume")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+// Removed by T356
+// "recfile" tag not saved anymore
+/*
+//---------------------------------------------------------
+// readRecfile
+//---------------------------------------------------------
+
+void AudioTrack::readRecfile(Xml& xml)
+ {
+ QString path;
+ int channels = 2;
+ int format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ if (token == Xml::Error || token == Xml::End)
+ break;
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::TagStart:
+ if (tag == "path")
+ path = xml.parse1();
+ else if (tag == "channels")
+ channels = xml.parseInt();
+ else if (tag == "format")
+ format = xml.parseInt();
+ else if (tag == "samplebits")
+ ;
+ else
+ xml.unknown("recfile");
+ break;
+ case Xml::TagEnd:
+ if (tag == "recfile") {
+ if (QFile::exists(path)) {
+ setRecFile(getWave(path, true));
+ }
+ else {
+ setRecFile(new SndFile(path));
+ recFile()->setFormat(format, channels, sampleRate);
+ if (recFile()->openWrite()) {
+ fprintf(stderr, "create wave file(%s) failed: %s\n",
+ path.toLatin1().constData(), recFile()->strerror().toLatin1().constData());
+ delete _recFile;
+ _recFile = 0;
+ }
+ }
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+*/
+
+//---------------------------------------------------------
+// setChannels
+//---------------------------------------------------------
+
+void Track::setChannels(int n)
+ {
+ if(n > MAX_CHANNELS)
+ _channels = MAX_CHANNELS;
+ else
+ _channels = n;
+ for (int i = 0; i < _channels; ++i) {
+ //_meter[i] = 0;
+ _meter[i] = 0.0;
+ //_peak[i] = 0;
+ _peak[i] = 0.0;
+ }
+ }
+
+void AudioInput::setChannels(int n)
+ {
+ if (n == _channels)
+ return;
+//was ist mit: void* jackPorts[MAX_CHANNELS];
+ AudioTrack::setChannels(n);
+ }
+
+void AudioOutput::setChannels(int n)
+ {
+ if (n == _channels)
+ return;
+ AudioTrack::setChannels(n);
+ }
+
+//---------------------------------------------------------
+// putFifo
+//---------------------------------------------------------
+
+void AudioTrack::putFifo(int channels, unsigned long n, float** bp)
+ {
+ if (fifo.put(channels, n, bp, audio->pos().frame())) {
+ printf(" overrun ???\n");
+ }
+ }
+
+//---------------------------------------------------------
+// getData
+// return false if no data available
+//---------------------------------------------------------
+
+bool AudioTrack::getData(unsigned pos, int channels, unsigned nframes, float** buffer)
+ {
+ // use supplied buffers
+
+ RouteList* rl = inRoutes();
+
+ #ifdef NODE_DEBUG
+ printf("AudioTrack::getData name:%s inRoutes:%d\n", name().toLatin1().constData(), rl->size());
+ #endif
+
+ iRoute ir = rl->begin();
+ if (ir == rl->end())
+ return false;
+
+ if(ir->track->isMidiTrack())
+ return false;
+
+ #ifdef NODE_DEBUG
+ printf(" calling copyData on %s...\n", ir->track->name().toLatin1().constData());
+ #endif
+
+ // p3.3.38
+ //((AudioTrack*)ir->track)->copyData(pos, channels, nframes, buffer);
+ ((AudioTrack*)ir->track)->copyData(pos, channels,
+ //(ir->track->type() == Track::AUDIO_SOFTSYNTH && ir->channel != -1) ? ir->channel : 0,
+ ir->channel,
+ ir->channels,
+ nframes, buffer);
+
+ // p3.3.41
+ //fprintf(stderr, "AudioTrack::getData %s data: nframes:%ld %e %e %e %e\n", name().toLatin1().constData(), nframes, buffer[0][0], buffer[0][1], buffer[0][2], buffer[0][3]);
+
+ ++ir;
+ for (; ir != rl->end(); ++ir) {
+ #ifdef NODE_DEBUG
+ printf(" calling addData on %s...\n", ir->track->name().toLatin1().constData());
+ #endif
+
+ if(ir->track->isMidiTrack())
+ continue;
+
+ // p3.3.38
+ //((AudioTrack*)ir->track)->addData(pos, channels, nframes, buffer);
+ ((AudioTrack*)ir->track)->addData(pos, channels,
+ //(ir->track->type() == Track::AUDIO_SOFTSYNTH && ir->channel != -1) ? ir->channel : 0,
+ ir->channel,
+ ir->channels,
+ nframes, buffer);
+ }
+ return true;
+ }
+
+//---------------------------------------------------------
+// getData
+// return true if data
+//---------------------------------------------------------
+
+bool AudioInput::getData(unsigned, int channels, unsigned nframes, float** buffer)
+ {
+ if (!checkAudioDevice()) return false;
+ for (int ch = 0; ch < channels; ++ch)
+ {
+ void* jackPort = jackPorts[ch];
+ //float* jackbuf = 0;
+
+ //if (jackPort) {
+ // p3.3.41 Do not get buffers of unconnected client ports. Causes repeating leftover data, can be loud, or DC !
+ if (jackPort && audioDevice->connections(jackPort))
+ {
+ //buffer[ch] = audioDevice->getBuffer(jackPort, nframes);
+ // p3.3.41 If the client port buffer is also used by another channel (connected to the same jack port),
+ // don't directly set pointer, copy the data instead.
+ // Otherwise the next channel will interfere - it will overwrite the buffer !
+ // Verified symptoms: Can't use a splitter. Mono noise source on a stereo track sounds in mono. Etc...
+ // TODO: Problem: What if other Audio Input tracks share the same jack ports as this Audio Input track?
+ // Users will expect that Audio Inputs just work even if the input routes originate from the same jack port.
+ // Solution: Rather than having to iterate all other channels, and all other Audio Input tracks and check
+ // their channel port buffers (if that's even possible) in order to determine if the buffer is shared,
+ // let's just copy always, for now shall we ?
+ float* jackbuf = audioDevice->getBuffer(jackPort, nframes);
+ //memcpy(buffer[ch], jackbuf, nframes* sizeof(float));
+ AL::dsp->cpy(buffer[ch], jackbuf, nframes);
+
+ if (config.useDenormalBias)
+ {
+ for (unsigned int i=0; i < nframes; i++)
+ buffer[ch][i] += denormalBias;
+
+ // p3.3.41
+ //fprintf(stderr, "AudioInput::getData %s Jack port %p efx apply channels:%d nframes:%ld %e %e %e %e\n",
+ // name().toLatin1().constData(), jackPort, channels, nframes, buffer[0][0], buffer[0][1], buffer[0][2], buffer[0][3]);
+ }
+ }
+ else
+ {
+ if (config.useDenormalBias)
+ {
+ for (unsigned int i=0; i < nframes; i++)
+ buffer[ch][i] = denormalBias;
+ }
+ else
+ {
+ memset(buffer[ch], 0, nframes * sizeof(float));
+ }
+
+ // p3.3.41
+ //fprintf(stderr, "AudioInput::getData %s No Jack port efx apply channels:%d nframes:%ld %e %e %e %e\n",
+ // name().toLatin1().constData(), channels, nframes, buffer[0][0], buffer[0][1], buffer[0][2], buffer[0][3]);
+ }
+ }
+ return true;
+}
+
+//---------------------------------------------------------
+// setName
+//---------------------------------------------------------
+
+void AudioInput::setName(const QString& s)
+ {
+ _name = s;
+ if (!checkAudioDevice()) return;
+ for (int i = 0; i < channels(); ++i) {
+ char buffer[128];
+ snprintf(buffer, 128, "%s-%d", _name.toLatin1().constData(), i);
+ if (jackPorts[i])
+ audioDevice->setPortName(jackPorts[i], buffer);
+ else {
+ //jackPorts[i] = audioDevice->registerInPort(buffer);
+ jackPorts[i] = audioDevice->registerInPort(buffer, false);
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// resetMeter
+//---------------------------------------------------------
+
+void Track::resetMeter()
+ {
+ for (int i = 0; i < _channels; ++i)
+ //_meter[i] = 0;
+ _meter[i] = 0.0;
+ }
+
+//---------------------------------------------------------
+// resetPeaks
+//---------------------------------------------------------
+
+void Track::resetPeaks()
+ {
+ for (int i = 0; i < _channels; ++i)
+ //_peak[i] = 0;
+ _peak[i] = 0.0;
+ _lastActivity = 0;
+ }
+
+//---------------------------------------------------------
+// resetAllMeter
+//---------------------------------------------------------
+
+void Track::resetAllMeter()
+ {
+ TrackList* tl = song->tracks();
+ for (iTrack i = tl->begin(); i != tl->end(); ++i)
+ (*i)->resetMeter();
+ }
+
+//---------------------------------------------------------
+// setRecordFlag2
+// real time part (executed in audio thread)
+//---------------------------------------------------------
+
+void AudioTrack::setRecordFlag2(bool f)
+ {
+ if (f == _recordFlag)
+ return;
+ _recordFlag = f;
+ if (!_recordFlag)
+ resetMeter();
+ }
+
+//---------------------------------------------------------
+// setMute
+//---------------------------------------------------------
+
+void AudioTrack::setMute(bool f)
+ {
+ _mute = f;
+ if (_mute)
+ resetAllMeter();
+ }
+
+//---------------------------------------------------------
+// setOff
+//---------------------------------------------------------
+
+void AudioTrack::setOff(bool val)
+ {
+ _off = val;
+ if (val)
+ resetAllMeter();
+ }
+
+//---------------------------------------------------------
+// setPrefader
+//---------------------------------------------------------
+
+void AudioTrack::setPrefader(bool val)
+ {
+ _prefader = val;
+ if (!_prefader && isMute())
+ resetAllMeter();
+ }
+
+//---------------------------------------------------------
+// canEnableRecord
+//---------------------------------------------------------
+
+bool WaveTrack::canEnableRecord() const
+ {
+ return (!noInRoute() || (this == song->bounceTrack));
+ }
+
+//---------------------------------------------------------
+// record
+//---------------------------------------------------------
+
+void AudioTrack::record()
+ {
+ unsigned pos = 0;
+ float* buffer[_channels];
+
+ //printf("AudioTrack: record() fifo %p, count=%d\n", &fifo, fifo.getCount());
+
+ while(fifo.getCount()) {
+
+ if (fifo.get(_channels, segmentSize, buffer, &pos)) {
+ printf("AudioTrack::record(): empty fifo\n");
+ return;
+ }
+ if (_recFile) {
+ // Line removed by Tim. p3.3.8 Oct 28, 2009
+ //_recFile->seek(pos, 0);
+ //
+ // Fix for recorded waves being shifted ahead by an amount
+ // equal to start record position.
+ //
+ // From libsndfile ChangeLog:
+ // 2008-05-11 Erik de Castro Lopo <erikd AT mega-nerd DOT com>
+ // * src/sndfile.c
+ // Allow seeking past end of file during write.
+ //
+ // I don't know why this line would even be called, because the FIFOs'
+ // 'pos' members operate in absolute frames, which at this point
+ // would be shifted ahead by the start of the wave part.
+ // So if you begin recording a new wave part at bar 4, for example, then
+ // this line is seeking the record file to frame 288000 even before any audio is written!
+ // Therefore, just let the write do its thing and progress naturally,
+ // it should work OK since everything was OK before the libsndfile change...
+ //
+ // Tested: With the line, audio record looping sort of works, albiet with the start offset added to
+ // the wave file. And it overwrites existing audio. (Check transport window 'overwrite' function. Tie in somehow...)
+ // With the line, looping does NOT work with libsndfile from around early 2007 (my distro's version until now).
+ // Therefore it seems sometime between libsndfile ~2007 and today, libsndfile must have allowed
+ // "seek (behind) on write", as well as the "seek past end" change of 2008...
+ //
+ // Ok, so removing that line breaks *possible* record audio 'looping' functionality, revealed with
+ // later libsndfile.
+ // Try this... And while we're at it, honour the punchin/punchout, and loop functions !
+ //
+ // If punchin is on, or we have looped at least once, use left marker as offset.
+ // Note that audio::startRecordPos is reset to (roughly) the left marker pos upon loop !
+ // (Not any more! I changed Audio::Process)
+ // Since it is possible to start loop recording before the left marker (with punchin off), we must
+ // use startRecordPos or loopFrame or left marker, depending on punchin and whether we have looped yet.
+ unsigned fr;
+ if(song->punchin() && (audio->loopCount() == 0))
+ fr = song->lPos().frame();
+ else
+ if((audio->loopCount() > 0) && (audio->getStartRecordPos().frame() > audio->loopFrame()))
+ fr = audio->loopFrame();
+ else
+ fr = audio->getStartRecordPos().frame();
+ // Now seek and write. If we are looping and punchout is on, don't let punchout point interfere with looping point.
+ if( (pos >= fr) && (!song->punchout() || (!song->loop() && pos < song->rPos().frame())) )
+ {
+ pos -= fr;
+ // Added by Tim. p3.3.8
+ //int position = _recFile->seek(0, SEEK_CUR);
+ //printf("AudioTrack::record loopcnt:%d lframe:%d newpos:%d curpos:%d start:%d end:%d\n", audio->loopCount(), audio->loopFrame(), pos, position, audio->getStartRecordPos().frame(), audio->getEndRecordPos().frame());
+
+ _recFile->seek(pos, 0);
+ _recFile->write(_channels, buffer, segmentSize);
+ }
+
+ }
+ else {
+ printf("AudioNode::record(): no recFile\n");
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// processInit
+//---------------------------------------------------------
+
+void AudioOutput::processInit(unsigned nframes)
+ {
+ _nframes = nframes;
+ if (!checkAudioDevice()) return;
+ for (int i = 0; i < channels(); ++i) {
+ if (jackPorts[i]) {
+ buffer[i] = audioDevice->getBuffer(jackPorts[i], nframes);
+ if (config.useDenormalBias) {
+ for (unsigned int j=0; j < nframes; j++)
+ buffer[i][j] += denormalBias;
+ }
+ }
+ else
+ printf("PANIC: processInit: no buffer from audio driver\n");
+ }
+ }
+
+//---------------------------------------------------------
+// process
+// synthesize "n" frames at buffer offset "offset"
+// current frame position is "pos"
+//---------------------------------------------------------
+
+void AudioOutput::process(unsigned pos, unsigned offset, unsigned n)
+{
+ //Added by Tim. p3.3.16
+ #ifdef NODE_DEBUG
+ printf("MusE: AudioOutput::process name:%s processed:%d\n", name().toLatin1().constData(), processed());
+ #endif
+
+ for (int i = 0; i < _channels; ++i) {
+ buffer1[i] = buffer[i] + offset;
+ }
+
+ // p3.3.38
+ //copyData(pos, _channels, n, buffer1);
+ copyData(pos, _channels, -1, -1, n, buffer1);
+}
+
+//---------------------------------------------------------
+// silence
+//---------------------------------------------------------
+
+void AudioOutput::silence(unsigned n)
+ {
+ processInit(n);
+ for (int i = 0; i < channels(); ++i)
+ if (config.useDenormalBias) {
+ for (unsigned int j=0; j < n; j++)
+ buffer[i][j] = denormalBias;
+ } else {
+ memset(buffer[i], 0, n * sizeof(float));
+ }
+ }
+
+//---------------------------------------------------------
+// processWrite
+//---------------------------------------------------------
+
+void AudioOutput::processWrite()
+ {
+ if (audio->isRecording() && song->bounceOutput == this) {
+ if (audio->freewheel()) {
+ WaveTrack* track = song->bounceTrack;
+ if (track && track->recordFlag() && track->recFile())
+ track->recFile()->write(_channels, buffer, _nframes);
+ if (recordFlag() && recFile())
+ _recFile->write(_channels, buffer, _nframes);
+ }
+ else {
+ WaveTrack* track = song->bounceTrack;
+ if (track && track->recordFlag() && track->recFile())
+ track->putFifo(_channels, _nframes, buffer);
+ if (recordFlag() && recFile())
+ putFifo(_channels, _nframes, buffer);
+ }
+ }
+ // Changed by Tim. p3.3.18
+ //if (audioClickFlag && song->click()) {
+ if (sendMetronome() && audioClickFlag && song->click()) {
+
+ // Added by Tim. p3.3.18
+ #ifdef METRONOME_DEBUG
+ printf("MusE: AudioOutput::processWrite Calling metronome->addData frame:%u channels:%d frames:%lu\n", audio->pos().frame(), _channels, _nframes);
+ #endif
+
+ // p3.3.38
+ //metronome->addData(audio->pos().frame(), _channels, _nframes, buffer);
+ metronome->addData(audio->pos().frame(), _channels, -1, -1, _nframes, buffer);
+ }
+ }
+//---------------------------------------------------------
+// setName
+//---------------------------------------------------------
+
+void AudioOutput::setName(const QString& s)
+ {
+ _name = s;
+ if (!checkAudioDevice()) return;
+ for (int i = 0; i < channels(); ++i) {
+ char buffer[128];
+ snprintf(buffer, 128, "%s-%d", _name.toLatin1().constData(), i);
+ if (jackPorts[i]) {
+ audioDevice->setPortName(jackPorts[i], buffer);
+ }
+ else {
+ //jackPorts[i] = audioDevice->registerOutPort(buffer);
+ jackPorts[i] = audioDevice->registerOutPort(buffer, false);
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// Fifo
+//---------------------------------------------------------
+
+Fifo::Fifo()
+ {
+ muse_atomic_init(&count);
+ //nbuffer = FIFO_BUFFER;
+ nbuffer = fifoLength;
+ buffer = new FifoBuffer*[nbuffer];
+ for (int i = 0; i < nbuffer; ++i)
+ buffer[i] = new FifoBuffer;
+ clear();
+ }
+
+Fifo::~Fifo()
+ {
+ for (int i = 0; i < nbuffer; ++i)
+ {
+ // p3.3.45
+ if(buffer[i]->buffer)
+ {
+ //printf("Fifo::~Fifo freeing buffer\n");
+ free(buffer[i]->buffer);
+ }
+
+ delete buffer[i];
+ }
+
+ delete[] buffer;
+ muse_atomic_destroy(&count);
+ }
+
+//---------------------------------------------------------
+// put
+// return true if fifo full
+//---------------------------------------------------------
+
+bool Fifo::put(int segs, unsigned long samples, float** src, unsigned pos)
+ {
+ // Added by Tim. p3.3.17
+ #ifdef FIFO_DEBUG
+ printf("FIFO::put segs:%d samples:%lu pos:%u\n", segs, samples, pos);
+ #endif
+
+ if (muse_atomic_read(&count) == nbuffer) {
+ printf("FIFO %p overrun... %d\n", this, count.counter);
+ return true;
+ }
+ FifoBuffer* b = buffer[widx];
+ int n = segs * samples;
+ if (b->maxSize < n) {
+ if (b->buffer)
+ {
+ // Changed by Tim. p3.3.15
+ //delete[] b->buffer;
+ free(b->buffer);
+ // p3.3.45
+ b->buffer = 0;
+ }
+ // Changed by Tim. p3.3.15
+ //b->buffer = new float[n];
+ posix_memalign((void**)&(b->buffer), 16, sizeof(float) * n);
+ // p3.3.45
+ if(!b->buffer)
+ {
+ printf("Fifo::put could not allocate buffer segs:%d samples:%lu pos:%u\n", segs, samples, pos);
+ return true;
+ }
+
+ b->maxSize = n;
+ }
+ // p3.3.45
+ if(!b->buffer)
+ {
+ printf("Fifo::put no buffer! segs:%d samples:%lu pos:%u\n", segs, samples, pos);
+ return true;
+ }
+
+ b->size = samples;
+ b->segs = segs;
+ b->pos = pos;
+ for (int i = 0; i < segs; ++i)
+ //memcpy(b->buffer + i * samples, src[i], samples * sizeof(float));
+ AL::dsp->cpy(b->buffer + i * samples, src[i], samples);
+ add();
+ return false;
+ }
+
+//---------------------------------------------------------
+// get
+// return true if fifo empty
+//---------------------------------------------------------
+
+bool Fifo::get(int segs, unsigned long samples, float** dst, unsigned* pos)
+ {
+ // Added by Tim. p3.3.17
+ #ifdef FIFO_DEBUG
+ printf("FIFO::get segs:%d samples:%lu\n", segs, samples);
+ #endif
+
+ if (muse_atomic_read(&count) == 0) {
+ printf("FIFO %p underrun... %d\n", this,count.counter); //by willyfoobar: added count to output //see Fifo::put()
+ return true;
+ }
+ FifoBuffer* b = buffer[ridx];
+ // p3.3.45
+ if(!b->buffer)
+ {
+ printf("Fifo::get no buffer! segs:%d samples:%lu b->pos:%u\n", segs, samples, b->pos);
+ return true;
+ }
+
+ if (pos)
+ *pos = b->pos;
+
+ for (int i = 0; i < segs; ++i)
+ dst[i] = b->buffer + samples * (i % b->segs);
+ remove();
+ return false;
+ }
+
+int Fifo::getCount()
+ {
+ return muse_atomic_read(&count);
+ }
+//---------------------------------------------------------
+// remove
+//---------------------------------------------------------
+
+void Fifo::remove()
+ {
+ ridx = (ridx + 1) % nbuffer;
+ muse_atomic_dec(&count);
+ }
+
+//---------------------------------------------------------
+// getWriteBuffer
+//---------------------------------------------------------
+
+bool Fifo::getWriteBuffer(int segs, unsigned long samples, float** buf, unsigned pos)
+ {
+ // Added by Tim. p3.3.17
+ #ifdef FIFO_DEBUG
+ printf("Fifo::getWriteBuffer segs:%d samples:%lu pos:%u\n", segs, samples, pos);
+ #endif
+
+ if (muse_atomic_read(&count) == nbuffer)
+ return true;
+ FifoBuffer* b = buffer[widx];
+ int n = segs * samples;
+ if (b->maxSize < n) {
+ if (b->buffer)
+ {
+ // Changed by Tim. p3.3.15
+ //delete[] b->buffer;
+ free(b->buffer);
+ // p3.3.45
+ b->buffer = 0;
+ }
+
+ // Changed by Tim. p3.3.15
+ //b->buffer = new float[n];
+ posix_memalign((void**)&(b->buffer), 16, sizeof(float) * n);
+ // p3.3.45
+ if(!b->buffer)
+ {
+ printf("Fifo::getWriteBuffer could not allocate buffer segs:%d samples:%lu pos:%u\n", segs, samples, pos);
+ return true;
+ }
+
+ b->maxSize = n;
+ }
+
+ // p3.3.45
+ if(!b->buffer)
+ {
+ printf("Fifo::getWriteBuffer no buffer! segs:%d samples:%lu pos:%u\n", segs, samples, pos);
+ return true;
+ }
+
+ for (int i = 0; i < segs; ++i)
+ buf[i] = b->buffer + i * samples;
+
+ b->size = samples;
+ b->segs = segs;
+ b->pos = pos;
+ return false;
+ }
+
+//---------------------------------------------------------
+// add
+//---------------------------------------------------------
+
+void Fifo::add()
+ {
+ widx = (widx + 1) % nbuffer;
+ muse_atomic_inc(&count);
+ }
+
+//---------------------------------------------------------
+// setChannels
+//---------------------------------------------------------
+
+void AudioTrack::setChannels(int n)
+ {
+ Track::setChannels(n);
+ if (_efxPipe)
+ _efxPipe->setChannels(n);
+ }
+
+//---------------------------------------------------------
+// setTotalOutChannels
+//---------------------------------------------------------
+
+void AudioTrack::setTotalOutChannels(int num)
+{
+ if(num == _totalOutChannels)
+ return;
+
+ int chans = _totalOutChannels;
+ // Number of allocated buffers is always MAX_CHANNELS or more, even if _totalOutChannels is less.
+ if(chans < MAX_CHANNELS)
+ chans = MAX_CHANNELS;
+ for(int i = 0; i < chans; ++i)
+ {
+ if(outBuffers[i])
+ free(outBuffers[i]);
+ }
+ delete[] outBuffers;
+
+ _totalOutChannels = num;
+ chans = num;
+ // Number of allocated buffers is always MAX_CHANNELS or more, even if _totalOutChannels is less.
+ if(chans < MAX_CHANNELS)
+ chans = MAX_CHANNELS;
+
+ outBuffers = new float*[chans];
+ for (int i = 0; i < chans; ++i)
+ posix_memalign((void**)&outBuffers[i], 16, sizeof(float) * segmentSize);
+
+ chans = num;
+ // Limit the actual track (meters, copying etc, all 'normal' operation) to two-channel stereo.
+ if(chans > MAX_CHANNELS)
+ chans = MAX_CHANNELS;
+
+ setChannels(chans);
+}
+
+//---------------------------------------------------------
+// setTotalInChannels
+//---------------------------------------------------------
+
+void AudioTrack::setTotalInChannels(int num)
+{
+ if(num == _totalInChannels)
+ return;
+
+ _totalInChannels = num;
+}
+
diff --git a/attic/muse2-oom/muse2/muse/node.h b/attic/muse2-oom/muse2/muse/node.h
new file mode 100644
index 00000000..b54faea9
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/node.h
@@ -0,0 +1,131 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: node.h,v 1.8.2.2 2006/04/13 19:09:48 spamatica Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __AUDIONODE_H__
+#define __AUDIONODE_H__
+
+#include <list>
+
+#ifndef i386
+#include <pthread.h>
+typedef struct { pthread_mutex_t lock; int counter; } muse_atomic_t;
+#else
+typedef struct { int counter; } muse_atomic_t;
+#endif
+
+static inline int muse_atomic_read(muse_atomic_t *v) {
+#ifndef i386
+ int ret;
+ pthread_mutex_lock(&v->lock);
+ ret = v->counter;
+ pthread_mutex_unlock(&v->lock);
+ return ret;
+#else
+ return v->counter;
+#endif
+}
+
+static inline void muse_atomic_set(muse_atomic_t *v, int i) {
+#ifndef i386
+ pthread_mutex_lock(&v->lock);
+ v->counter = i;
+ pthread_mutex_unlock(&v->lock);
+#else
+ v->counter = i;
+#endif
+}
+static inline void muse_atomic_inc(muse_atomic_t *v) {
+#ifndef i386
+ pthread_mutex_lock(&v->lock);
+ v->counter++;
+ pthread_mutex_unlock(&v->lock);
+#else
+ __asm__ __volatile__(
+ "lock ; " "incl %0"
+ :"=m" (v->counter)
+ :"m" (v->counter));
+#endif
+}
+static inline void muse_atomic_dec(muse_atomic_t *v) {
+#ifndef i386
+ pthread_mutex_lock(&v->lock);
+ v->counter--;
+ pthread_mutex_unlock(&v->lock);
+#else
+ __asm__ __volatile__(
+ "lock ; " "decl %0"
+ :"=m" (v->counter)
+ :"m" (v->counter));
+#endif
+}
+#ifndef i386
+static inline void muse_atomic_init(muse_atomic_t *v) {
+ pthread_mutex_init(&v->lock, NULL);
+ }
+#else
+static inline void muse_atomic_init(muse_atomic_t*) {}
+#endif
+
+#ifndef i386
+static inline void muse_atomic_destroy(muse_atomic_t *v) {
+ pthread_mutex_destroy(&v->lock);
+ }
+#else
+static inline void muse_atomic_destroy(muse_atomic_t*) {}
+#endif
+
+class Xml;
+class Pipeline;
+class SndFile;
+
+// superceeded by dynamic allocation of fifoLength
+//const int FIFO_BUFFER = 4096;//64;
+
+//---------------------------------------------------------
+// Fifo
+//---------------------------------------------------------
+
+struct FifoBuffer {
+ float* buffer;
+ int size;
+ int maxSize;
+ unsigned pos;
+ int segs;
+
+ FifoBuffer() {
+ buffer = 0;
+ size = 0;
+ maxSize = 0;
+ }
+ };
+
+class Fifo {
+ int nbuffer;
+ int ridx; // read index; only touched by reader
+ int widx; // write index; only touched by writer
+ muse_atomic_t count; // buffer count; writer increments, reader decrements
+ FifoBuffer** buffer;
+
+ public:
+ Fifo();
+ ~Fifo();
+ void clear() {
+ ridx = 0;
+ widx = 0;
+ muse_atomic_set(&count, 0);
+ }
+ bool put(int, unsigned long, float** buffer, unsigned pos);
+ bool getWriteBuffer(int, unsigned long, float** buffer, unsigned pos);
+ void add();
+ bool get(int, unsigned long, float** buffer, unsigned* pos);
+ void remove();
+ int getCount();
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/osc.cpp b/attic/muse2-oom/muse2/muse/osc.cpp
new file mode 100644
index 00000000..26cd3a8a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/osc.cpp
@@ -0,0 +1,1401 @@
+//=============================================================================
+// MusE
+// Linux Music Editor
+// $Id: osc.cpp,v 1.0.0.0 2010/04/22 03:39:58 terminator356 Exp $
+//
+// Copyright (C) 1999-2010 by Werner Schweer and others
+// OSC module added by Tim.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//=============================================================================
+
+#include "config.h"
+
+#ifdef OSC_SUPPORT
+
+// Turn on debugging messages
+//#define OSC_DEBUG
+
+#include <string.h>
+//#include <signal.h>
+//#include <dlfcn.h>
+#include <stdlib.h>
+#include <sys/stat.h>
+#include <errno.h>
+//#include <dssi.h>
+//#include <alsa/asoundlib.h>
+
+#include <QDir>
+#include <QFileInfo>
+#include <QString>
+#include <QStringList>
+#include <QProcess>
+#include <QTimer>
+
+#include <lo/lo.h>
+
+#ifdef DSSI_SUPPORT
+#include "dssihost.h"
+#endif
+
+#include "stringparam.h"
+#include "plugin.h"
+#include "track.h"
+#include "song.h"
+#include "synth.h"
+//#include "audio.h"
+//#include "jackaudio.h"
+//#include "midi.h"
+//#include "midiport.h"
+//#include "al/al.h"
+//#include "al/xml.h"
+//#include "xml.h"
+//#include "midictrl.h"
+//#include "ladspaplugin.h"
+
+#include "app.h"
+#include "globals.h"
+#include "globaldefs.h"
+//#include "al/dsp.h"
+
+static lo_server_thread serverThread = 0;
+///static char osc_path_tmp[1024];
+static char* url = 0;
+static bool oscServerRunning = false;
+
+//---------------------------------------------------------
+// oscError
+//---------------------------------------------------------
+
+static void oscError(int num, const char *msg, const char *path)
+ {
+ fprintf(stderr, "MusE: liblo server error %d in path %s: %s\n",
+ num, path, msg);
+ }
+
+//---------------------------------------------------------
+// oscDebugHandler
+//---------------------------------------------------------
+
+static int oscDebugHandler(const char* path, const char* types, lo_arg** argv,
+ int argc, void*, void*)
+ {
+ printf("MusE: got unhandled OSC message:\n path: <%s>\n", path);
+ for (int i = 0; i < argc; i++) {
+ printf(" arg %d '%c' ", i, types[i]);
+ lo_arg_pp(lo_type(types[i]), argv[i]);
+ printf("\n");
+ }
+ return 1;
+ }
+
+//---------------------------------------------------------
+// oscMessageHandler
+//---------------------------------------------------------
+
+int oscMessageHandler(const char* path, const char* types, lo_arg** argv,
+ int argc, void* data, void* user_data)
+{
+ const char* p = path;
+
+ #ifdef OSC_DEBUG
+ if(argc)
+ {
+ printf("oscMessageHandler: path:%s argc:%d\n", path, argc);
+ for(int i = 0; i < argc; ++i)
+ {
+ printf(" ");
+ lo_arg_pp((lo_type)types[i], argv[i]);
+ }
+ printf("\n");
+ }
+ else
+ {
+ printf("%s\n", path);
+ printf("oscMessageHandler: no args, path:%s\n", path);
+ }
+ #endif
+
+ bool isSynth = false;
+
+ #ifdef DSSI_SUPPORT
+ if(strncmp(p, "/dssi_synth/", 12) == 0)
+ {
+ isSynth = true;
+ p += 12;
+ }
+ else
+ #endif
+ if(strncmp(p, "/ladspa_efx/", 12) == 0)
+ {
+ p += 12;
+ }
+ else
+ return oscDebugHandler(path, types, argv, argc, data, user_data);
+
+ TrackList* tl = song->tracks();
+
+
+ #ifdef OSC_DEBUG
+ if(isSynth)
+ fprintf(stderr, "oscMessageHandler: got message for dssi synth...\n");
+ else
+ fprintf(stderr, "oscMessageHandler: got message for ladspa effect...\n");
+ #endif
+
+ // FIXME: Slowdowns: Shouldn't need these retries but they are needed, only upon creation of the synth.
+ // Need to fix the real source of the problem! The instance is taking too long to appear after creation.
+ //
+ ///for(int retry = 0; retry < 5000; ++retry)
+ {
+ ///#ifdef OSC_DEBUG
+ ///fprintf(stderr, "oscMessageHandler: search retry number:%d ...\n", retry);
+ ///#endif
+
+ //if(_uiOscPath)
+ // break;
+
+ #ifdef DSSI_SUPPORT
+ if(isSynth)
+ {
+ // Message is meant for a dssi synth. Check dssi synth instances...
+ SynthIList* sl = song->syntis();
+ for(iSynthI si = sl->begin(); si != sl->end(); ++si)
+ {
+ SynthI* synti = *si;
+
+ #ifdef OSC_DEBUG
+ fprintf(stderr, "oscMessageHandler: searching for:%s checking synth instance:%s\n", p, synti->name().toLatin1().constData());
+ #endif
+
+ QByteArray ba = synti->name().toLatin1();
+ const char* sub = strstr(p, ba.constData());
+ if(sub == NULL)
+ continue;
+
+ //DssiSynthIF* instance = (DssiSynthIF*)synti->sif();
+ DssiSynthIF* instance = dynamic_cast<DssiSynthIF*>(synti->sif());
+ if(!instance)
+ break;
+
+ QByteArray ba2 = synti->name().toLatin1();
+ p = sub + strlen(ba2.constData());
+
+ if (*p != '/' || *(p + 1) == 0)
+ {
+ fprintf(stderr, "oscMessageHandler error: synth: end of path or no /\n");
+ return oscDebugHandler(path, types, argv, argc, data, user_data);
+ }
+
+ ++p;
+
+ #ifdef OSC_DEBUG
+ fprintf(stderr, "oscMessageHandler: synth track:%s method:%s\n", synti->name().toLatin1().constData(), p);
+ #endif
+
+ OscIF& oscif = instance->oscIF();
+
+ if (!strcmp(p, "configure") && argc == 2 && !strcmp(types, "ss"))
+ return oscif.oscConfigure(argv);
+ else if (!strcmp(p, "control") && argc == 2 && !strcmp(types, "if"))
+ return oscif.oscControl(argv);
+ else if (!strcmp(p, "midi") && argc == 1 && !strcmp(types, "m"))
+ return oscif.oscMidi(argv);
+ else if (!strcmp(p, "program") && argc == 2 && !strcmp(types, "ii"))
+ return oscif.oscProgram(argv);
+ else if (!strcmp(p, "update") && argc == 1 && !strcmp(types, "s"))
+ return oscif.oscUpdate(argv);
+ else if (!strcmp(p, "exiting") && argc == 0)
+ return oscif.oscExiting(argv);
+ return oscDebugHandler(path, types, argv, argc, data, user_data);
+ }
+ }
+ else
+ #endif //DSSI_SUPPORT
+ // Message is meant for a ladspa effect. Check all ladspa effect instances...
+ for(ciTrack it = tl->begin(); it != tl->end(); ++it)
+ {
+ if((*it)->isMidiTrack())
+ continue;
+
+ Pipeline* efxPipe = ((AudioTrack*)*it)->efxPipe();
+ if(efxPipe)
+ {
+ for(ciPluginI ip = efxPipe->begin(); ip != efxPipe->end(); ++ip)
+ {
+ PluginI* instance = *ip;
+ if(!instance)
+ continue;
+
+ #ifdef OSC_DEBUG
+ fprintf(stderr, "oscMessageHandler: searching for:%s checking effect instance:%s label:%s lib:%s\n",
+ p, instance->name().toLatin1().constData(), instance->label().toLatin1().constData(), instance->lib().toLatin1().constData());
+ #endif
+
+ //const char* sub = strstr(p, instance->name().toLatin1().constData());
+ ///const char* sub = strstr(p, instance->label().toLatin1().constData());
+ QByteArray ba = instance->label().toLatin1();
+ const char* sub = strstr(p, ba.constData());
+ if(sub == NULL)
+ continue;
+
+ Plugin* plugin = instance->plugin();
+ if(!plugin)
+ break;
+
+ //p = sub + strlen(instance->name().toLatin1().constData());
+ QByteArray ba3 = instance->label().toLatin1();
+ p = sub + strlen(ba3.constData());
+
+ if (*p != '/' || *(p + 1) == 0)
+ {
+ fprintf(stderr, "oscMessageHandler: error: effect: end of path or no /\n");
+ return oscDebugHandler(path, types, argv, argc, data, user_data);
+ }
+
+ ++p;
+
+ #ifdef OSC_DEBUG
+ //fprintf(stderr, "oscMessageHandler: effect:%s method:%s\n", instance->name().toLatin1().constData(), p);
+ fprintf(stderr, "oscMessageHandler: effect:%s method:%s\n", instance->label().toLatin1().constData(), p);
+ #endif
+
+ OscIF& oscif = instance->oscIF();
+
+ if (!strcmp(p, "configure") && argc == 2 && !strcmp(types, "ss"))
+ return oscif.oscConfigure(argv);
+ else if (!strcmp(p, "control") && argc == 2 && !strcmp(types, "if"))
+ return oscif.oscControl(argv);
+ else if (!strcmp(p, "midi") && argc == 1 && !strcmp(types, "m"))
+ return oscif.oscMidi(argv);
+ else if (!strcmp(p, "program") && argc == 2 && !strcmp(types, "ii"))
+ return oscif.oscProgram(argv);
+ else if (!strcmp(p, "update") && argc == 1 && !strcmp(types, "s"))
+ return oscif.oscUpdate(argv);
+ else if (!strcmp(p, "exiting") && argc == 0)
+ return oscif.oscExiting(argv);
+ return oscDebugHandler(path, types, argv, argc, data, user_data);
+ }
+ }
+ }
+
+ ///usleep(1000);
+ }
+
+ fprintf(stderr, "oscMessageHandler: timeout error: no synth or effect instance found for given path\n");
+ return oscDebugHandler(path, types, argv, argc, data, user_data);
+}
+
+
+//---------------------------------------------------------
+// initOSC
+//---------------------------------------------------------
+
+void initOSC()
+{
+ if(url)
+ free(url);
+ url = 0;
+
+ // Create OSC thread
+ // Only if not created yet.
+ if(!serverThread)
+ {
+ serverThread = lo_server_thread_new(0, oscError);
+ if(!serverThread)
+ {
+ printf("initOSC() Failed to create OSC server!\n");
+ return;
+ }
+ }
+
+ ///snprintf(osc_path_tmp, 31, "/dssi");
+ // Test: Clear the temp path:
+ //snprintf(osc_path_tmp, 31, "");
+
+ ///char* tmp = lo_server_thread_get_url(serverThread);
+
+ url = lo_server_thread_get_url(serverThread);
+ if(!url)
+ {
+ lo_server_thread_free(serverThread);
+ printf("initOSC() Failed to get OSC server thread url !\n");
+ return;
+ }
+
+ ///url = (char *)malloc(strlen(tmp) + strlen(osc_path_tmp));
+ //url = (char *)malloc(strlen(tmp));
+
+ ///sprintf(url, "%s%s", tmp, osc_path_tmp + 1);
+ //sprintf(url, "%s", tmp, osc_path_tmp + 1);
+
+ ///free(tmp);
+
+ lo_method meth = 0;
+ meth = lo_server_thread_add_method(serverThread, 0, 0, oscMessageHandler, 0);
+ if(!meth)
+ {
+ printf("initOSC() Failed to add oscMessageHandler method to OSC server!\n");
+ // Does not return a value.
+ lo_server_thread_free(serverThread);
+ serverThread = 0;
+ free(url);
+ url = 0;
+ return;
+ }
+
+ // Does not return a value.
+ lo_server_thread_start(serverThread);
+}
+
+//---------------------------------------------------------
+// exitOSC
+//---------------------------------------------------------
+
+void exitOSC()
+{
+ oscServerRunning = false;
+ if(serverThread)
+ {
+ // Does not return a value.
+ lo_server_thread_stop(serverThread);
+ lo_server_thread_free(serverThread);
+ }
+ serverThread = 0;
+}
+
+//---------------------------------------------------------
+// startOSC
+//---------------------------------------------------------
+
+void startOSC()
+{
+ if(serverThread)
+ // Does not return a value.
+ lo_server_thread_start(serverThread);
+ oscServerRunning = true;
+}
+
+//---------------------------------------------------------
+// stopOSC
+//---------------------------------------------------------
+
+void stopOSC()
+{
+ if(serverThread)
+ // Does not return a value.
+ lo_server_thread_stop(serverThread);
+ oscServerRunning = false;
+}
+
+
+
+//---------------------------------------------------------
+// OscControlFifo
+// put
+// return true on fifo overflow
+//---------------------------------------------------------
+
+bool OscControlFifo::put(const OscControlValue& event)
+ {
+ if (size < OSC_FIFO_SIZE) {
+ fifo[wIndex] = event;
+ wIndex = (wIndex + 1) % OSC_FIFO_SIZE;
+ // q_atomic_increment(&size);
+ ++size;
+ return false;
+ }
+ return true;
+ }
+
+//---------------------------------------------------------
+// get
+//---------------------------------------------------------
+
+OscControlValue OscControlFifo::get()
+ {
+ OscControlValue event(fifo[rIndex]);
+ rIndex = (rIndex + 1) % OSC_FIFO_SIZE;
+ // q_atomic_decrement(&size);
+ --size;
+ return event;
+ }
+
+//---------------------------------------------------------
+// peek
+//---------------------------------------------------------
+
+const OscControlValue& OscControlFifo::peek(int n)
+ {
+ int idx = (rIndex + n) % OSC_FIFO_SIZE;
+ return fifo[idx];
+ }
+
+//---------------------------------------------------------
+// remove
+//---------------------------------------------------------
+
+void OscControlFifo::remove()
+ {
+ rIndex = (rIndex + 1) % OSC_FIFO_SIZE;
+ // q_atomic_decrement(&size);
+ --size;
+ }
+
+
+
+//---------------------------------------------------------
+// OscIF
+// Open Sound Control Interface
+//---------------------------------------------------------
+
+OscIF::OscIF()
+{
+ //_oscPluginI = 0;
+
+ //#ifdef DSSI_SUPPORT
+ //_oscSynthIF = 0;
+ //#endif
+
+ _uiOscTarget = 0;
+ _uiOscSampleRatePath = 0;
+ _uiOscShowPath = 0;
+ _uiOscControlPath = 0;
+ _uiOscConfigurePath = 0;
+ _uiOscProgramPath = 0;
+ _uiOscPath = 0;
+ //guiPid = -1;
+ _oscGuiQProc = 0;
+ _oscGuiVisible = false;
+
+ _oscControlFifos = 0;
+}
+
+OscIF::~OscIF()
+{
+ //if (guiPid != -1)
+ // kill(guiPid, SIGHUP);
+ if(_oscGuiQProc)
+ {
+ if(_oscGuiQProc->state())
+ {
+ #ifdef OSC_DEBUG
+ printf("OscIF::~OscIF terminating _oscGuiQProc\n");
+ #endif
+
+ //_oscGuiQProc->kill();
+ // "This tries to terminate the process the nice way. If the process is still running after 5 seconds,
+ // it terminates the process the hard way. The timeout should be chosen depending on the time the
+ // process needs to do all its cleanup: use a higher value if the process is likely to do a lot of
+ // computation or I/O on cleanup."
+ _oscGuiQProc->terminate();
+ QTimer::singleShot( 5000, _oscGuiQProc, SLOT( kill() ) );
+ }
+ //delete _oscGuiQProc;
+ }
+
+ if(_uiOscTarget)
+ lo_address_free(_uiOscTarget);
+ if(_uiOscSampleRatePath)
+ free(_uiOscSampleRatePath);
+ if(_uiOscShowPath)
+ free(_uiOscShowPath);
+ if(_uiOscControlPath)
+ free(_uiOscControlPath);
+ if(_uiOscConfigurePath)
+ free(_uiOscConfigurePath);
+ if(_uiOscProgramPath)
+ free(_uiOscProgramPath);
+ if(_uiOscPath)
+ free(_uiOscPath);
+
+ if(_oscControlFifos)
+ delete[] _oscControlFifos;
+}
+
+//---------------------------------------------------------
+// oscFifo
+//---------------------------------------------------------
+
+OscControlFifo* OscIF::oscFifo(unsigned long i) const
+{
+ if(!_oscControlFifos)
+ return 0;
+ return &_oscControlFifos[i];
+}
+
+//---------------------------------------------------------
+// oscUpdate
+//---------------------------------------------------------
+
+int OscIF::oscUpdate(lo_arg **argv)
+{
+ const char *purl = (char *)&argv[0]->s;
+
+ if(_uiOscTarget)
+ lo_address_free(_uiOscTarget);
+ _uiOscTarget = 0;
+ char* host = lo_url_get_hostname(purl);
+ char* port = lo_url_get_port(purl);
+ _uiOscTarget = lo_address_new(host, port);
+ free(host);
+ free(port);
+ if(!_uiOscTarget)
+ return 0;
+
+ if (_uiOscPath)
+ free(_uiOscPath);
+ _uiOscPath = lo_url_get_path(purl);
+ int pl = strlen(_uiOscPath);
+
+ if(_uiOscSampleRatePath)
+ free(_uiOscSampleRatePath);
+ _uiOscSampleRatePath = (char *)malloc(pl + 14);
+ sprintf(_uiOscSampleRatePath, "%s/sample-rate", _uiOscPath);
+
+ if (_uiOscControlPath)
+ free(_uiOscControlPath);
+ _uiOscControlPath = (char *)malloc(pl + 10);
+ sprintf(_uiOscControlPath, "%s/control", _uiOscPath);
+
+ if (_uiOscConfigurePath)
+ free(_uiOscConfigurePath);
+ _uiOscConfigurePath = (char *)malloc(pl + 12);
+ sprintf(_uiOscConfigurePath, "%s/configure", _uiOscPath);
+
+ if (_uiOscProgramPath)
+ free(_uiOscProgramPath);
+ _uiOscProgramPath = (char *)malloc(pl + 10);
+ sprintf(_uiOscProgramPath, "%s/program", _uiOscPath);
+
+ if (_uiOscShowPath)
+ free(_uiOscShowPath);
+ _uiOscShowPath = (char *)malloc(pl + 10);
+ sprintf(_uiOscShowPath, "%s/show", _uiOscPath);
+
+ /* At this point a more substantial host might also call
+ * configure() on the UI to set any state that it had remembered
+ * for the plugin instance. But we don't remember state for
+ * plugin instances (see our own configure() implementation in
+ * osc_configure_handler), and so we have nothing to send except
+ * the optional project directory.
+ */
+
+ #ifdef OSC_DEBUG
+ printf("OscIF::oscUpdate: _uiOscTarget:%p\n", _uiOscTarget);
+ if(url)
+ printf(" server url:%s\n", url);
+ else
+ printf(" no server url!\n");
+ printf(" update path:%s\n", purl);
+ printf(" _uiOscPath:%s\n", _uiOscPath);
+ printf(" _uiOscSampleRatePath:%s\n", _uiOscSampleRatePath);
+ printf(" _uiOscConfigurePath:%s\n", _uiOscConfigurePath);
+ printf(" _uiOscProgramPath:%s\n", _uiOscProgramPath);
+ printf(" _uiOscControlPath:%s\n",_uiOscControlPath);
+ printf(" _uiOscShowPath:%s\n", _uiOscShowPath);
+ printf(" museProject:%s\n", museProject.toLatin1().constData());
+ #endif
+
+ // Send sample rate.
+ lo_send(_uiOscTarget, _uiOscSampleRatePath, "i", sampleRate);
+
+ // Send project directory.
+ //lo_send(_uiOscTarget, _uiOscConfigurePath, "ss",
+ // DSSI_PROJECT_DIRECTORY_KEY, museProject.toLatin1().constData()); // song->projectPath()
+
+ // Done in sub-classes.
+ /*
+ #ifdef DSSI_SUPPORT
+ //lo_send(_uiOscTarget, _uiOscConfigurePath, "ss",
+ //DSSI_PROJECT_DIRECTORY_KEY, song->projectPath().toAscii().data());
+ lo_send(_uiOscTarget, _uiOscConfigurePath, "ss",
+ DSSI_PROJECT_DIRECTORY_KEY, museProject.toLatin1().constData());
+
+ if(_oscSynthIF)
+ {
+ for(ciStringParamMap r = _oscSynthIF->synthI->_stringParamMap.begin(); r != synti->_stringParamMap.end(); ++r)
+ {
+ rv = 0;
+ rv = dssi->configure(handle, r->first.c_str(), r->second.c_str());
+ if(rv)
+ {
+ fprintf(stderr, "MusE: Warning: plugin config key: %s value: %s \"%s\"\n", r->first.c_str(), r->second.c_str(), rv);
+ free(rv);
+ }
+ }
+ }
+ #endif
+ */
+
+ /*
+ char uiOscGuiPath[strlen(_uiOscPath)+6];
+ sprintf(uiOscGuiPath, "%s/%s", _uiOscPath, "show");
+
+ #ifdef OSC_DEBUG
+ printf("OscIF::oscUpdate Sending show uiOscGuiPath:%s\n", uiOscGuiPath);
+ #endif
+
+ lo_send(_uiOscTarget, uiOscGuiPath, "");
+
+ sprintf(uiOscGuiPath, "%s/%s", _uiOscPath, "hide");
+
+ #ifdef OSC_DEBUG
+ printf("OscIF::oscUpdate Sending hide uiOscGuiPath:%s\n", uiOscGuiPath);
+ #endif
+
+ lo_send(_uiOscTarget, uiOscGuiPath, "");
+ */
+
+#if 0
+ /* Send current bank/program (-FIX- another race...) */
+ if (instance->pendingProgramChange < 0) {
+ unsigned long bank = instance->currentBank;
+ unsigned long program = instance->currentProgram;
+ instance->uiNeedsProgramUpdate = 0;
+ if (instance->uiTarget) {
+ lo_send(instance->uiTarget, instance->ui_osc_program_path, "ii", bank, program);
+ }
+ }
+
+ /* Send control ports */
+ for (i = 0; i < instance->plugin->controlIns; i++) {
+ int in = i + instance->firstControlIn;
+ int port = pluginControlInPortNumbers[in];
+ lo_send(instance->uiTarget, instance->ui_osc_control_path, "if", port,
+ pluginControlIns[in]);
+ /* Avoid overloading the GUI if there are lots and lots of ports */
+ if ((i+1) % 50 == 0)
+ usleep(300000);
+ }
+#endif
+ return 0;
+}
+
+//---------------------------------------------------------
+// oscExiting
+//---------------------------------------------------------
+
+int OscIF::oscExiting(lo_arg**)
+{
+ // The gui is gone now, right?
+ _oscGuiVisible = false;
+
+ if(_oscGuiQProc)
+ {
+ if(_oscGuiQProc->state())
+ {
+ #ifdef OSC_DEBUG
+ printf("OscIF::oscExiting terminating _oscGuiQProc\n");
+ #endif
+
+ //_oscGuiQProc->kill();
+ // "This tries to terminate the process the nice way. If the process is still running after 5 seconds,
+ // it terminates the process the hard way. The timeout should be chosen depending on the time the
+ // process needs to do all its cleanup: use a higher value if the process is likely to do a lot of
+ // computation or I/O on cleanup."
+ _oscGuiQProc->terminate();
+ QTimer::singleShot( 5000, _oscGuiQProc, SLOT( kill() ) );
+ }
+ //delete _oscGuiQProc;
+ }
+
+ if(_uiOscTarget)
+ lo_address_free(_uiOscTarget);
+ _uiOscTarget = 0;
+ if(_uiOscSampleRatePath)
+ free(_uiOscSampleRatePath);
+ _uiOscSampleRatePath = 0;
+ if(_uiOscShowPath)
+ free(_uiOscShowPath);
+ _uiOscShowPath = 0;
+ if(_uiOscControlPath)
+ free(_uiOscControlPath);
+ _uiOscControlPath = 0;
+ if(_uiOscConfigurePath)
+ free(_uiOscConfigurePath);
+ _uiOscConfigurePath = 0;
+ if(_uiOscProgramPath)
+ free(_uiOscProgramPath);
+ _uiOscProgramPath = 0;
+ if(_uiOscPath)
+ free(_uiOscPath);
+ _uiOscPath = 0;
+
+ //if(_oscControlFifos)
+ // delete[] _oscControlFifos;
+
+ //const DSSI_Descriptor* dssi = synth->dssi;
+ //const LADSPA_Descriptor* ld = dssi->LADSPA_Plugin;
+ //if(ld->deactivate)
+ // ld->deactivate(handle);
+
+ /*
+ if (_uiOscPath == 0) {
+ printf("OscIF::oscExiting(): no _uiOscPath\n");
+ return 1;
+ }
+ char uiOscGuiPath[strlen(_uiOscPath)+6];
+
+ sprintf(uiOscGuiPath, "%s/%s", _uiOscPath, "quit");
+ #ifdef OSC_DEBUG
+ printf("OscIF::oscExiting(): sending quit to uiOscGuiPath:%s\n", uiOscGuiPath);
+ #endif
+
+ lo_send(_uiOscTarget, uiOscGuiPath, "");
+ */
+
+#if 0
+ int i;
+
+ if (verbose) {
+ printf("MusE: OSC: got exiting notification for instance %d\n",
+ instance->number);
+ }
+
+ if (instance->plugin) {
+
+ /*!!! No, this isn't safe -- plugins deactivated in this way
+ would still be included in a run_multiple_synths call unless
+ we re-jigged the instance array at the same time -- leave it
+ for now
+ if (instance->plugin->descriptor->LADSPA_Plugin->deactivate) {
+ instance->plugin->descriptor->LADSPA_Plugin->deactivate
+ (instanceHandles[instance->number]);
+ }
+ */
+ /* Leave this flag though, as we need it to determine when to exit */
+ instance->inactive = 1;
+ }
+
+ /* Do we have any plugins left running? */
+
+ for (i = 0; i < instance_count; ++i) {
+ if (!instances[i].inactive)
+ return 0;
+ }
+
+ if (verbose) {
+ printf("MusE: That was the last remaining plugin, exiting...\n");
+ }
+ exiting = 1;
+#endif
+ return 0;
+}
+
+//---------------------------------------------------------
+// oscSendProgram
+//---------------------------------------------------------
+
+void OscIF::oscSendProgram(unsigned long prog, unsigned long bank)
+{
+ if(_uiOscTarget && _uiOscProgramPath)
+ lo_send(_uiOscTarget, _uiOscProgramPath, "ii", bank, prog);
+}
+
+//---------------------------------------------------------
+// oscSendControl
+//---------------------------------------------------------
+
+void OscIF::oscSendControl(unsigned long dssiPort, float v)
+{
+ if(_uiOscTarget && _uiOscControlPath)
+ lo_send(_uiOscTarget, _uiOscControlPath, "if", dssiPort, v);
+}
+
+//---------------------------------------------------------
+// oscSendConfigure
+//---------------------------------------------------------
+
+void OscIF::oscSendConfigure(const char *key, const char *val)
+{
+ if(_uiOscTarget && _uiOscConfigurePath)
+ lo_send(_uiOscTarget, _uiOscConfigurePath, "ss", key, val);
+}
+
+//---------------------------------------------------------
+// oscInitGui
+//---------------------------------------------------------
+
+//bool OscIF::oscInitGui()
+bool OscIF::oscInitGui(const QString& typ, const QString& baseName, const QString& name,
+ const QString& label, const QString& filePath, const QString& dirPath)
+{
+ // Are we already running? We don't want to allow another process do we...
+ if((_oscGuiQProc != 0) && (_oscGuiQProc->state()))
+ return true;
+
+ if(!url)
+ {
+ fprintf(stderr, "OscIF::oscInitGui no server url!\n");
+ return false;
+ }
+
+ //
+ // start gui
+ //
+ //static char oscUrl[1024];
+ //char oscUrl[1024];
+ QString oscUrl;
+
+ /*
+ QString typ;
+ QString baseName;
+ QString name;
+ QString label;
+ QString filePath;
+ QString dirPath;
+ #ifdef DSSI_SUPPORT
+ if(_oscSynthIF)
+ {
+ //snprintf(oscUrl, 1024, "%s/%s", url, synti->name().toAscii().data());
+ //snprintf(oscUrl, 1024, "%s/%s", url, synti->name().ascii());
+ //snprintf(oscUrl, 1024, "%s/%s/%s", url, synth->info.baseName().ascii(), synti->name().ascii());
+ typ = QT_TRANSLATE_NOOP("@default", "dssi_synth");
+ baseName = _oscSynthIF->dssiSynth()->baseName(false);
+ label = _oscSynthIF->dssiSynthI()->name();
+ name = _oscSynthIF->dssiSynth()->name();
+
+ dirPath = _oscSynthIF->dssiSynth()->dirPath(false);
+ filePath = _oscSynthIF->dssiSynth()->filePath();
+ }
+ else
+ #endif
+ if(_oscPluginI)
+ {
+ typ = QT_TRANSLATE_NOOP("@default", "ladspa_efx");
+ baseName = _oscPluginI->plugin()->lib(false);
+ //name = _oscPluginI->name();
+ name = _oscPluginI->plugin()->label();
+ label = _oscPluginI->label();
+
+ dirPath = _oscPluginI->plugin()->dirPath(false);
+ //dirPath.replace("ladspa", "dssi", true);
+
+ filePath = _oscPluginI->plugin()->filePath();
+ //filePath.replace("ladspa", "dssi", true);
+ }
+ else
+ return false;
+ */
+
+ //snprintf(oscUrl, 1024, "%s/%s/%s", url, baseName.ascii(), name.ascii());
+ //snprintf(oscUrl, 1024, "%s%s/%s/%s", url, typ.toLatin1().constData(), baseName.toLatin1().constData(), name.toLatin1().constData());
+ //oscUrl = QString("%1%2/%3/%4").arg(QString(QT_TRANSLATE_NOOP("@default", url))).arg(typ).arg(baseName).arg(name);
+ oscUrl = QString("%1%2/%3/%4").arg(QString(QT_TRANSLATE_NOOP("@default", url))).arg(typ).arg(baseName).arg(label);
+
+ //QString guiPath(info.path() + "/" + info.baseName());
+ //QString guiPath(synth->info.dirPath() + "/" + synth->info.baseName());
+ QString guiPath(dirPath + "/" + baseName);
+
+ #ifdef OSC_DEBUG
+ fprintf(stderr, "OscIF::oscInitGui guiPath:%s\n", guiPath.toLatin1().constData());
+ #endif
+
+ QDir guiDir(guiPath, "*", QDir::Unsorted, QDir::Files);
+ if (guiDir.exists())
+ {
+ //const QFileInfoList list = guiDir.entryInfoList();
+ QStringList list = guiDir.entryList();
+
+ //for (int i = 0; i < list.size(); ++i) {
+ for (int i = 0; i < list.count(); ++i)
+ {
+
+ //QFileInfo fi = list.at(i);
+ QFileInfo fi(guiPath + QString("/") + list[i]);
+
+ QString gui(fi.filePath());
+ if (gui.contains('_') == 0)
+ continue;
+ struct stat buf;
+
+ //if (stat(gui.toAscii().data(), &buf)) {
+ if (stat(gui.toLatin1().constData(), &buf)) {
+
+ perror("stat failed");
+ continue;
+ }
+
+ #ifdef OSC_DEBUG
+ fprintf(stderr, "OscIF::oscInitGui %s %s %s %s\n",
+ //fi.filePath().toAscii().data(),
+ //fi.fileName().toAscii().data(),
+ fi.filePath().toLatin1().constData(),
+ //fi.fileName().ascii(),
+
+ oscUrl.toLatin1().constData(),
+
+ //synth->info.filePath().ascii(),
+ filePath.toLatin1().constData(),
+
+ //name().toAscii().data(),
+ //synth->name().ascii());
+ name.toLatin1().constData());
+ #endif
+
+ if ((S_ISREG(buf.st_mode) || S_ISLNK(buf.st_mode)) &&
+ (buf.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
+ {
+ // Changed by T356.
+ // fork + execlp were causing the processes to remain after closing gui, requiring manual kill.
+ // Changed to QProcess, works OK now.
+ //if((guiPid = fork()) == 0)
+ {
+ // No QProcess created yet? Do it now. Only once per SynthIF instance. Exists until parent destroyed.
+ if(_oscGuiQProc == 0)
+ _oscGuiQProc = new QProcess(muse);
+
+ QString program(fi.filePath());
+ QStringList arguments;
+ arguments << oscUrl
+ << filePath
+ << name
+ << QString("channel-1");
+
+ /* Leave out Qt3 stuff for reference - Orcan:
+ // Don't forget this, he he...
+ _oscGuiQProc->clearArguments();
+
+ _oscGuiQProc->addArgument(fi.filePath());
+ //_oscGuiQProc->addArgument(fi.fileName()); // No conventional 'Arg0' here.
+ //_oscGuiQProc->addArgument(QString(oscUrl));
+ _oscGuiQProc->addArgument(oscUrl);
+ //_oscGuiQProc->addArgument(synth->info.filePath());
+ _oscGuiQProc->addArgument(filePath);
+ //_oscGuiQProc->addArgument(synth->name());
+ _oscGuiQProc->addArgument(name);
+ _oscGuiQProc->addArgument(QString("channel-1"));
+ */
+ #ifdef OSC_DEBUG
+ fprintf(stderr, "OscIF::oscInitGui starting QProcess\n");
+ #endif
+ _oscGuiQProc->start(program, arguments);
+
+
+ if(_oscGuiQProc->state())
+ {
+ #ifdef OSC_DEBUG
+ fprintf(stderr, "OscIF::oscInitGui started QProcess\n");
+ #endif
+
+ //guiPid = _oscGuiQProc->processIdentifier();
+ }
+ else
+ {
+
+ /*
+ execlp(
+ //fi.filePath().toAscii().data(),
+ //fi.fileName().toAscii().data(),
+ fi.filePath().ascii(),
+ fi.fileName().ascii(),
+
+ oscUrl,
+
+ //info.filePath().toAscii().data(),
+ //name().toAscii().data(),
+ synth->info.filePath().ascii(),
+ synth->name().ascii(),
+
+ "channel 1", (void*)0);
+ */
+
+ fprintf(stderr, "exec %s %s %s %s failed: %s\n",
+ //fi.filePath().toAscii().data(),
+ //fi.fileName().toAscii().data(),
+ fi.filePath().toLatin1().constData(),
+ fi.fileName().toLatin1().constData(),
+
+ oscUrl.toLatin1().constData(),
+
+ //name().toAscii().data(),
+ //synth->name().ascii(),
+ name.toLatin1().constData(),
+
+ strerror(errno));
+
+ // It's Ok, Keep going. So nothing happens. So what. The timeout in showGui will just leave.
+ // Maybe it's a 'busy' issue somewhere - allow to try again later + save work now.
+ //exit(1);
+
+ }
+
+ #ifdef OSC_DEBUG
+ fprintf(stderr, "OscIF::oscInitGui after QProcess\n");
+ #endif
+ }
+ }
+ }
+ //synth->_hasGui = true;
+ }
+ else {
+ printf("OscIF::oscInitGui %s: no dir for gui found: %s\n",
+ //name().toAscii().data(), guiPath.toAscii().data());
+ //synth->name().ascii(), guiPath.ascii());
+ name.toLatin1().constData(), guiPath.toLatin1().constData());
+
+ //synth->_hasGui = false;
+ }
+
+ return true;
+}
+
+
+//---------------------------------------------------------
+// oscShowGui
+//---------------------------------------------------------
+
+void OscIF::oscShowGui(bool v)
+{
+ #ifdef OSC_DEBUG
+ printf("OscIF::oscShowGui(): v:%d visible:%d\n", v, oscGuiVisible());
+ #endif
+
+ if (v == oscGuiVisible())
+ return;
+
+ //if(guiPid == -1)
+ if((_oscGuiQProc == 0) || (!_oscGuiQProc->state()))
+ {
+ // We need an indicator that update was called - update must have been called to get new path etc...
+ // If the process is not running this path is invalid, right?
+ if(_uiOscPath)
+ free(_uiOscPath);
+ _uiOscPath = 0;
+
+ #ifdef OSC_DEBUG
+ printf("OscIF::oscShowGui(): No QProcess or process not running. Starting gui...\n");
+ #endif
+
+ if(!oscInitGui())
+ {
+ printf("OscIF::oscShowGui(): failed to initialize gui on oscInitGui()\n");
+ return;
+ }
+ }
+
+ //for (int i = 0; i < 5; ++i) {
+ for (int i = 0; i < 10; ++i) { // Give it a wee bit more time?
+ if (_uiOscPath)
+ break;
+ sleep(1);
+ }
+ if (_uiOscPath == 0) {
+ printf("OscIF::oscShowGui(): no _uiOscPath. Error: Timeout - synth gui did not start within 10 seconds.\n");
+ return;
+ }
+
+ char uiOscGuiPath[strlen(_uiOscPath)+6];
+ sprintf(uiOscGuiPath, "%s/%s", _uiOscPath, v ? "show" : "hide");
+
+ #ifdef OSC_DEBUG
+ printf("OscIF::oscShowGui(): Sending show/hide uiOscGuiPath:%s\n", uiOscGuiPath);
+ #endif
+
+ lo_send(_uiOscTarget, uiOscGuiPath, "");
+ _oscGuiVisible = v;
+}
+
+//---------------------------------------------------------
+// oscGuiVisible
+//---------------------------------------------------------
+
+bool OscIF::oscGuiVisible() const
+{
+ return _oscGuiVisible;
+}
+
+#ifdef DSSI_SUPPORT
+
+//---------------------------------------------------------
+// OscDssiIF::
+// oscSetSynthIF
+//---------------------------------------------------------
+
+//void OscIF::oscSetSynthIF(DssiSynthIF* s)
+void OscDssiIF::oscSetSynthIF(DssiSynthIF* s)
+{
+ _oscSynthIF = s;
+ if(_oscControlFifos)
+ delete[] _oscControlFifos;
+ _oscControlFifos = 0;
+
+ if(_oscSynthIF && _oscSynthIF->dssiSynth())
+ {
+ unsigned long ports = _oscSynthIF->dssiSynth()->inControls();
+ _oscControlFifos = new OscControlFifo[ports];
+ }
+}
+
+//---------------------------------------------------------
+// oscUpdate
+//---------------------------------------------------------
+
+int OscDssiIF::oscUpdate(lo_arg **argv)
+{
+ // Make sure to call base method.
+ OscIF::oscUpdate(argv);
+
+ // Send sample rate. No, done in base class.
+ //lo_send(_uiOscTarget, _uiOscSampleRatePath, "i", sampleRate);
+
+ // Send project directory. No, done in DssiSynthIF.
+ //lo_send(_uiOscTarget, _uiOscConfigurePath, "ss",
+ // DSSI_PROJECT_DIRECTORY_KEY, museProject.toLatin1().constData()); // song->projectPath()
+
+ if(_oscSynthIF)
+ _oscSynthIF->oscUpdate();
+
+ /*
+ if(_oscSynthIF)
+ {
+ // Send current string configuration parameters.
+ StringParamMap& map = _oscSynthIF->dssiSynthI()->stringParameters();
+ int i = 0;
+ for(ciStringParamMap r = map.begin(); r != map.end(); ++r)
+ {
+ lo_send(_uiOscTarget, _uiOscConfigurePath, "ss", r->first.c_str(), r->second.c_str());
+ // Avoid overloading the GUI if there are lots and lots of params.
+ if((i+1) % 50 == 0)
+ usleep(300000);
+ ++i;
+ }
+
+ // Send current bank and program.
+ unsigned long bank, prog;
+ _oscSynthIF->dssiSynthI()->currentProg(&prog, &bank, 0);
+ lo_send(_uiOscTarget, _uiOscProgramPath, "ii", bank, prog);
+
+ // Send current control values.
+ unsigned long ports = _oscSynthIF->dssiSynth()->inControls();
+ for(unsigned long i = 0; i < ports; ++i)
+ {
+ unsigned long k = _oscSynthIF->dssiSynth()->inControlPortIdx(i);
+ lo_send(_uiOscTarget, _uiOscControlPath, "if", k, _oscSynthIF->getParameter(i));
+ // Avoid overloading the GUI if there are lots and lots of ports.
+ if((i+1) % 50 == 0)
+ usleep(300000);
+ }
+ }
+ */
+
+ /*
+ char uiOscGuiPath[strlen(_uiOscPath)+6];
+ sprintf(uiOscGuiPath, "%s/%s", _uiOscPath, "show");
+
+ #ifdef OSC_DEBUG
+ printf("OscIF::oscUpdate Sending show uiOscGuiPath:%s\n", uiOscGuiPath);
+ #endif
+
+ lo_send(_uiOscTarget, uiOscGuiPath, "");
+
+ sprintf(uiOscGuiPath, "%s/%s", _uiOscPath, "hide");
+
+ #ifdef OSC_DEBUG
+ printf("OscIF::oscUpdate Sending hide uiOscGuiPath:%s\n", uiOscGuiPath);
+ #endif
+
+ lo_send(_uiOscTarget, uiOscGuiPath, "");
+ */
+
+#if 0
+ /* Send current bank/program (-FIX- another race...) */
+ if (instance->pendingProgramChange < 0) {
+ unsigned long bank = instance->currentBank;
+ unsigned long program = instance->currentProgram;
+ instance->uiNeedsProgramUpdate = 0;
+ if (instance->uiTarget) {
+ lo_send(instance->uiTarget, instance->ui_osc_program_path, "ii", bank, program);
+ }
+ }
+
+ /* Send control ports */
+ for (i = 0; i < instance->plugin->controlIns; i++) {
+ int in = i + instance->firstControlIn;
+ int port = pluginControlInPortNumbers[in];
+ lo_send(instance->uiTarget, instance->ui_osc_control_path, "if", port,
+ pluginControlIns[in]);
+ /* Avoid overloading the GUI if there are lots and lots of ports */
+ if ((i+1) % 50 == 0)
+ usleep(300000);
+ }
+#endif
+ return 0;
+}
+
+
+//---------------------------------------------------------
+// oscConfigure
+//---------------------------------------------------------
+
+int OscDssiIF::oscConfigure(lo_arg** argv)
+{
+ //OscIF::oscConfigure(argv);
+
+ if(_oscSynthIF)
+ _oscSynthIF->oscConfigure((const char*)&argv[0]->s, (const char*)&argv[1]->s);
+ return 0;
+}
+
+//---------------------------------------------------------
+// oscMidi
+//---------------------------------------------------------
+
+int OscDssiIF::oscMidi(lo_arg** argv)
+{
+ //OscIF::oscMidi(argv);
+
+ if(_oscSynthIF)
+ _oscSynthIF->oscMidi(argv[0]->m[1], argv[0]->m[2], argv[0]->m[3]);
+
+ return 0;
+}
+
+//---------------------------------------------------------
+// oscProgram
+//---------------------------------------------------------
+
+int OscDssiIF::oscProgram(lo_arg** argv)
+{
+ //OscIF::oscProgram(argv);
+
+ if(_oscSynthIF)
+ _oscSynthIF->oscProgram(argv[1]->i, argv[0]->i);
+
+ return 0;
+}
+
+//---------------------------------------------------------
+// oscControl
+//---------------------------------------------------------
+
+int OscDssiIF::oscControl(lo_arg** argv)
+{
+ //OscIF::oscControl(argv);
+
+ int port = argv[0]->i;
+ if(port < 0)
+ return 0;
+
+ if(_oscSynthIF)
+ _oscSynthIF->oscControl(argv[0]->i, argv[1]->f);
+
+ return 0;
+}
+
+//---------------------------------------------------------
+// oscInitGui
+//---------------------------------------------------------
+bool OscDssiIF::oscInitGui()
+{
+ if(!_oscSynthIF)
+ return false;
+
+ return OscIF::oscInitGui(QT_TRANSLATE_NOOP("@default", "dssi_synth"), _oscSynthIF->dssiSynth()->baseName(),
+ _oscSynthIF->dssiSynth()->name(), _oscSynthIF->dssiSynthI()->name(),
+ _oscSynthIF->dssiSynth()->filePath(), _oscSynthIF->dssiSynth()->path());
+}
+
+#endif // DSSI_SUPPORT
+
+
+//---------------------------------------------------------
+// OscEffectIF::
+// oscSetPluginI
+//---------------------------------------------------------
+
+void OscEffectIF::oscSetPluginI(PluginI* s)
+{
+ _oscPluginI = s;
+ if(_oscControlFifos)
+ delete[] _oscControlFifos;
+ _oscControlFifos = 0;
+
+ if(_oscPluginI && _oscPluginI->plugin())
+ {
+ unsigned long ports = _oscPluginI->plugin()->controlInPorts();
+ _oscControlFifos = new OscControlFifo[ports];
+ }
+}
+
+//---------------------------------------------------------
+// oscUpdate
+//---------------------------------------------------------
+
+int OscEffectIF::oscUpdate(lo_arg** argv)
+{
+ // Make sure to call base method.
+ OscIF::oscUpdate(argv);
+
+ // Send project directory. No, done in PluginI.
+ //lo_send(_uiOscTarget, _uiOscConfigurePath, "ss",
+ // DSSI_PROJECT_DIRECTORY_KEY, museProject.toLatin1().constData()); // song->projectPath()
+
+ if(_oscPluginI)
+ _oscPluginI->oscUpdate();
+
+ return 0;
+}
+
+//---------------------------------------------------------
+// oscConfigure
+//---------------------------------------------------------
+
+int OscEffectIF::oscConfigure(lo_arg** argv)
+{
+ //OscIF::oscConfigure(argv);
+
+ if(_oscPluginI)
+ _oscPluginI->oscConfigure((const char*)&argv[0]->s, (const char*)&argv[1]->s);
+
+ return 0;
+}
+
+//---------------------------------------------------------
+// oscControl
+//---------------------------------------------------------
+
+int OscEffectIF::oscControl(lo_arg** argv)
+{
+ //OscIF::oscControl(argv);
+
+ int port = argv[0]->i;
+ if(port < 0)
+ return 0;
+
+ if(_oscPluginI)
+ _oscPluginI->oscControl(argv[0]->i, argv[1]->f);
+
+ return 0;
+}
+
+//---------------------------------------------------------
+// oscInitGui
+//---------------------------------------------------------
+bool OscEffectIF::oscInitGui()
+{
+ if(!_oscPluginI)
+ return false;
+
+ return OscIF::oscInitGui(QT_TRANSLATE_NOOP("@default", "ladspa_efx"), _oscPluginI->plugin()->lib(false),
+ _oscPluginI->plugin()->label(), _oscPluginI->label(),
+ _oscPluginI->plugin()->filePath(), _oscPluginI->plugin()->dirPath(false));
+}
+
+
+#else //OSC_SUPPORT
+void initOSC() {}
+void exitOSC() {}
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/osc.h b/attic/muse2-oom/muse2/muse/osc.h
new file mode 100644
index 00000000..8e093e2c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/osc.h
@@ -0,0 +1,213 @@
+//=============================================================================
+// MusE
+// Linux Music Editor
+// $Id: osc.h,v 1.0.0.0 2010/04/22 10:05:00 terminator356 Exp $
+//
+// Copyright (C) 1999-2010 by Werner Schweer and others
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//=============================================================================
+
+#ifndef __OSC_H__
+#define __OSC_H__
+
+#include <lo/lo.h>
+
+#include "config.h"
+
+#ifdef DSSI_SUPPORT
+class DssiSynthIF;
+#endif
+
+class QProcess;
+class QString;
+class PluginI;
+class OscIF;
+
+// Keep the OSC fifo small. There may be thousands of controls, and each control needs a fifo.
+// Oops, no, if the user keeps adjusting a slider without releasing the mouse button, then all of the
+// events are sent at once upon releasing the button, meaning there might be thousands of events at once.
+#define OSC_FIFO_SIZE 512
+
+//---------------------------------------------------------
+// OscControlValue
+// Item struct for OscGuiControlFifo.
+//---------------------------------------------------------
+
+struct OscControlValue
+{
+ //int idx;
+ float value;
+ // maybe timestamp, too ?
+};
+
+//---------------------------------------------------------
+// OscControlFifo
+// A fifo for each of the OSC controls.
+//---------------------------------------------------------
+
+class OscControlFifo
+{
+ OscControlValue fifo[OSC_FIFO_SIZE];
+ volatile int size;
+ int wIndex;
+ int rIndex;
+
+ public:
+ OscControlFifo() { clear(); }
+ bool put(const OscControlValue& event); // returns true on fifo overflow
+ OscControlValue get();
+ const OscControlValue& peek(int n = 0);
+ void remove();
+ bool isEmpty() const { return size == 0; }
+ void clear() { size = 0, wIndex = 0, rIndex = 0; }
+ int getSize() const { return size; }
+};
+
+//---------------------------------------------------------
+// OscIF
+// Open Sound Control Interface
+//---------------------------------------------------------
+
+/*
+class OscIF
+{
+ private:
+ PluginI* _oscPluginI;
+
+ #ifdef DSSI_SUPPORT
+ DssiSynthIF* _oscSynthIF;
+ #endif
+
+ QProcess* _oscGuiQProc;
+ void* _uiOscTarget;
+ char* _uiOscShowPath;
+ char* _uiOscControlPath;
+ char* _uiOscConfigurePath;
+ char* _uiOscProgramPath;
+ char* _uiOscPath;
+ bool _oscGuiVisible;
+
+ OscControlFifo* _oscControlFifos;
+
+ public:
+ OscIF();
+ ~OscIF();
+
+ void oscSetPluginI(PluginI*);
+
+ #ifdef DSSI_SUPPORT
+ void oscSetSynthIF(DssiSynthIF*);
+ #endif
+
+ int oscUpdate(lo_arg**);
+ int oscProgram(lo_arg**);
+ int oscControl(lo_arg**);
+ int oscExiting(lo_arg**);
+ int oscMidi(lo_arg**);
+ int oscConfigure(lo_arg**);
+
+ bool oscInitGui();
+ void oscShowGui(bool);
+ bool oscGuiVisible() const;
+ OscControlFifo* oscFifo(unsigned long) const;
+};
+*/
+
+class OscIF
+{
+ protected:
+ QProcess* _oscGuiQProc;
+ void* _uiOscTarget;
+ char* _uiOscPath;
+ char* _uiOscSampleRatePath;
+ char* _uiOscConfigurePath;
+ char* _uiOscProgramPath;
+ char* _uiOscControlPath;
+ char* _uiOscShowPath;
+ bool _oscGuiVisible;
+
+ OscControlFifo* _oscControlFifos;
+
+ virtual bool oscInitGui(const QString& /*typ*/, const QString& /*baseName*/, const QString& /*name*/,
+ const QString& /*label*/, const QString& /*filePath*/, const QString& /*dirPath*/);
+
+ public:
+ OscIF();
+ virtual ~OscIF();
+
+ OscControlFifo* oscFifo(unsigned long) const;
+
+ virtual int oscUpdate(lo_arg**);
+ virtual int oscProgram(lo_arg**) { return 0; }
+ virtual int oscControl(lo_arg**) { return 0; }
+ virtual int oscExiting(lo_arg**);
+ virtual int oscMidi(lo_arg**) { return 0; }
+ virtual int oscConfigure(lo_arg**) { return 0; }
+
+ virtual void oscSendProgram(unsigned long /*prog*/, unsigned long /*bank*/);
+ virtual void oscSendControl(unsigned long /*dssiPort*/, float /*val*/);
+ virtual void oscSendConfigure(const char */*key*/, const char */*val*/);
+
+ virtual bool oscInitGui() { return false; }
+ virtual void oscShowGui(bool);
+ virtual bool oscGuiVisible() const;
+};
+
+class OscEffectIF : public OscIF
+{
+ protected:
+ PluginI* _oscPluginI;
+
+ public:
+ OscEffectIF() {}
+ //~OscEffectIF();
+
+ void oscSetPluginI(PluginI*);
+
+ virtual int oscUpdate(lo_arg**);
+ //virtual int oscProgram(lo_arg**);
+ virtual int oscControl(lo_arg**);
+ //virtual int oscExiting(lo_arg**);
+ //virtual int oscMidi(lo_arg**);
+ virtual int oscConfigure(lo_arg**);
+
+ virtual bool oscInitGui();
+};
+
+#ifdef DSSI_SUPPORT
+class OscDssiIF : public OscIF
+{
+ protected:
+ DssiSynthIF* _oscSynthIF;
+
+ public:
+ OscDssiIF() {}
+ //~OscDssiIF();
+
+ void oscSetSynthIF(DssiSynthIF*);
+
+ virtual int oscUpdate(lo_arg**);
+ virtual int oscProgram(lo_arg**);
+ virtual int oscControl(lo_arg**);
+ //virtual int oscExiting(lo_arg**);
+ virtual int oscMidi(lo_arg**);
+ virtual int oscConfigure(lo_arg**);
+
+ virtual bool oscInitGui();
+};
+#endif // DSSI_SUPPORT
+
+extern void initOSC();
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/part.cpp b/attic/muse2-oom/muse2/muse/part.cpp
new file mode 100644
index 00000000..99f070b2
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/part.cpp
@@ -0,0 +1,1433 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: part.cpp,v 1.12.2.17 2009/06/25 05:13:02 terminator356 Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <assert.h>
+#include <cmath>
+
+#include "song.h"
+#include "part.h"
+#include "track.h"
+#include "globals.h"
+#include "event.h"
+#include "audio.h"
+#include "wave.h"
+#include "midiport.h"
+#include "drummap.h"
+//#include "midiedit/drummap.h" // p4.0.2
+
+int Part::snGen;
+
+//---------------------------------------------------------
+// unchainClone
+//---------------------------------------------------------
+
+void unchainClone(Part* p)
+{
+ chainCheckErr(p);
+
+ // Unchain the part.
+ p->prevClone()->setNextClone(p->nextClone());
+ p->nextClone()->setPrevClone(p->prevClone());
+
+ // Isolate the part.
+ p->setPrevClone(p);
+ p->setNextClone(p);
+}
+
+//---------------------------------------------------------
+// chainClone
+// The quick way - if part to chain to is known...
+//---------------------------------------------------------
+
+void chainClone(Part* p1, Part* p2)
+{
+ chainCheckErr(p1);
+
+ // Make sure the part to be chained is unchained first.
+ p2->prevClone()->setNextClone(p2->nextClone());
+ p2->nextClone()->setPrevClone(p2->prevClone());
+
+ // Link the part to be chained.
+ p2->setPrevClone(p1);
+ p2->setNextClone(p1->nextClone());
+
+ // Re-link the existing part.
+ p1->nextClone()->setPrevClone(p2);
+ p1->setNextClone(p2);
+}
+
+//---------------------------------------------------------
+// chainCloneInternal
+// No error check, so it can be called by replaceClone()
+//---------------------------------------------------------
+
+void chainCloneInternal(Part* p)
+{
+ Track* t = p->track();
+ Part* p1 = 0;
+
+ // Look for a part with the same event list, that we can chain to.
+ // It's faster if track type is known...
+
+ if(!t || (t && t->isMidiTrack()))
+ {
+ MidiTrack* mt = 0;
+ MidiTrackList* mtl = song->midis();
+ for(ciMidiTrack imt = mtl->begin(); imt != mtl->end(); ++imt)
+ {
+ mt = *imt;
+ const PartList* pl = mt->cparts();
+ for(ciPart ip = pl->begin(); ip != pl->end(); ++ip)
+ {
+ // Added by Tim. p3.3.6
+ //printf("chainCloneInternal track %p %s part %p %s evlist %p\n", (*imt), (*imt)->name().toLatin1().constData(), ip->second, ip->second->name().toLatin1().constData(), ip->second->cevents());
+
+ if(ip->second != p && ip->second->cevents() == p->cevents())
+ {
+ p1 = ip->second;
+ break;
+ }
+ }
+ // If a suitable part was found on a different track, we're done. We will chain to it.
+ // Otherwise keep looking for parts on another track. If no others found, then we
+ // chain to any suitable part which was found on the same given track t.
+ if(p1 && mt != t)
+ break;
+ }
+ }
+ if((!p1 && !t) || (t && t->type() == Track::WAVE))
+ {
+ WaveTrack* wt = 0;
+ WaveTrackList* wtl = song->waves();
+ for(ciWaveTrack iwt = wtl->begin(); iwt != wtl->end(); ++iwt)
+ {
+ wt = *iwt;
+ const PartList* pl = wt->cparts();
+ for(ciPart ip = pl->begin(); ip != pl->end(); ++ip)
+ {
+ if(ip->second != p && ip->second->cevents() == p->cevents())
+ {
+ p1 = ip->second;
+ break;
+ }
+ }
+ if(p1 && wt != t)
+ break;
+ }
+ }
+
+ // No part found with same event list? Done.
+ if(!p1)
+ return;
+
+ // Make sure the part to be chained is unchained first.
+ p->prevClone()->setNextClone(p->nextClone());
+ p->nextClone()->setPrevClone(p->prevClone());
+
+ // Link the part to be chained.
+ p->setPrevClone(p1);
+ p->setNextClone(p1->nextClone());
+
+ // Re-link the existing part.
+ p1->nextClone()->setPrevClone(p);
+ p1->setNextClone(p);
+}
+
+//---------------------------------------------------------
+// chainClone
+// The slow way - if part to chain to is not known...
+//---------------------------------------------------------
+
+void chainClone(Part* p)
+{
+ chainCheckErr(p);
+ chainCloneInternal(p);
+}
+
+//---------------------------------------------------------
+// replaceClone
+//---------------------------------------------------------
+
+void replaceClone(Part* p1, Part* p2)
+{
+ chainCheckErr(p1);
+
+ // Make sure the replacement part is unchained first.
+ p2->prevClone()->setNextClone(p2->nextClone());
+ p2->nextClone()->setPrevClone(p2->prevClone());
+
+ // If the two parts share the same event list, then this MUST
+ // be a straight forward replacement operation. Continue on.
+ // If not, and either part has more than one ref count, then do this...
+ if(p1->cevents() != p2->cevents())
+ {
+ bool ret = false;
+ // If the part to be replaced is a single uncloned part,
+ // and the replacement part is not, then this operation
+ // MUST be an undo of a de-cloning of a cloned part.
+ //if(p1->cevents()->refCount() <= 1 && p2->cevents()->refCount() > 1)
+ if(p2->cevents()->refCount() > 1)
+ {
+ // Chain the replacement part. We don't know the chain it came from,
+ // so we use the slow method.
+ chainCloneInternal(p2);
+ //return;
+ ret = true;
+ }
+
+ // If the replacement part is a single uncloned part,
+ // and the part to be replaced is not, then this operation
+ // MUST be a de-cloning of a cloned part.
+ //if(p1->cevents()->refCount() > 1 && p2->cevents()->refCount() <= 1)
+ if(p1->cevents()->refCount() > 1)
+ {
+ // Unchain the part to be replaced.
+ p1->prevClone()->setNextClone(p1->nextClone());
+ p1->nextClone()->setPrevClone(p1->prevClone());
+ // Isolate the part.
+ p1->setPrevClone(p1);
+ p1->setNextClone(p1);
+ //return;
+ ret = true;
+ }
+
+ // Was the operation handled?
+ if(ret)
+ return;
+ // Note that two parts here with different event lists, each with more than one
+ // reference count, would be an error. It's not done anywhere in muse. But just
+ // to be sure, four lines above were changed to allow that condition.
+ // If each of the two different event lists, has only one ref count, we
+ // handle it like a regular replacement, below...
+ }
+
+ // If the part to be replaced is a clone not a single lone part, re-link its neighbours to the replacement part...
+ if(p1->prevClone() != p1)
+ {
+ p1->prevClone()->setNextClone(p2);
+ p2->setPrevClone(p1->prevClone());
+ }
+ else
+ p2->setPrevClone(p2);
+
+ if(p1->nextClone() != p1)
+ {
+ p1->nextClone()->setPrevClone(p2);
+ p2->setNextClone(p1->nextClone());
+ }
+ else
+ p2->setNextClone(p2);
+
+ // Link the replacement...
+ //p2->setPrevClone(p1->prevClone());
+ //p2->setNextClone(p1->nextClone());
+
+ // Isolate the replaced part.
+ p1->setNextClone(p1);
+ p1->setPrevClone(p1);
+ // Added by Tim. p3.3.6
+ //printf("replaceClone p1: %s %p arefs:%d p2: %s %p arefs:%d\n", p1->name().toLatin1().constData(), p1, );
+
+}
+
+//---------------------------------------------------------
+// unchainTrackParts
+//---------------------------------------------------------
+
+void unchainTrackParts(Track* t, bool decRefCount)
+{
+ PartList* pl = t->parts();
+ for(iPart ip = pl->begin(); ip != pl->end(); ++ip)
+ {
+ Part* p = ip->second;
+ chainCheckErr(p);
+
+ // Do we want to decrease the reference count?
+ if(decRefCount)
+ p->events()->incARef(-1);
+
+ // Unchain the part.
+ p->prevClone()->setNextClone(p->nextClone());
+ p->nextClone()->setPrevClone(p->prevClone());
+
+ // Isolate the part.
+ p->setPrevClone(p);
+ p->setNextClone(p);
+ }
+}
+
+//---------------------------------------------------------
+// chainTrackParts
+//---------------------------------------------------------
+
+void chainTrackParts(Track* t, bool incRefCount)
+{
+ PartList* pl = t->parts();
+ for(iPart ip = pl->begin(); ip != pl->end(); ++ip)
+ {
+ Part* p = ip->second;
+ chainCheckErr(p);
+
+ // Do we want to increase the reference count?
+ if(incRefCount)
+ p->events()->incARef(1);
+
+ // Added by Tim. p3.3.6
+ //printf("chainTrackParts track %p %s part %p %s evlist %p\n", t, t->name().toLatin1().constData(), p, p->name().toLatin1().constData(), p->cevents());
+
+ Part* p1 = 0;
+
+ // Look for a part with the same event list, that we can chain to.
+ // It's faster if track type is known...
+
+ if(!t || (t && t->isMidiTrack()))
+ {
+ MidiTrack* mt = 0;
+ MidiTrackList* mtl = song->midis();
+ for(ciMidiTrack imt = mtl->begin(); imt != mtl->end(); ++imt)
+ {
+ mt = *imt;
+ const PartList* pl = mt->cparts();
+ for(ciPart ip = pl->begin(); ip != pl->end(); ++ip)
+ {
+ // Added by Tim. p3.3.6
+ //printf("chainTrackParts track %p %s part %p %s evlist %p\n", mt, mt->name().toLatin1().constData(), ip->second, ip->second->name().toLatin1().constData(), ip->second->cevents());
+
+ if(ip->second != p && ip->second->cevents() == p->cevents())
+ {
+ p1 = ip->second;
+ break;
+ }
+ }
+ // If a suitable part was found on a different track, we're done. We will chain to it.
+ // Otherwise keep looking for parts on another track. If no others found, then we
+ // chain to any suitable part which was found on the same given track t.
+ if(p1 && mt != t)
+ break;
+ }
+ }
+ if((!p1 && !t) || (t && t->type() == Track::WAVE))
+ {
+ WaveTrack* wt = 0;
+ WaveTrackList* wtl = song->waves();
+ for(ciWaveTrack iwt = wtl->begin(); iwt != wtl->end(); ++iwt)
+ {
+ wt = *iwt;
+ const PartList* pl = wt->cparts();
+ for(ciPart ip = pl->begin(); ip != pl->end(); ++ip)
+ {
+ if(ip->second != p && ip->second->cevents() == p->cevents())
+ {
+ p1 = ip->second;
+ break;
+ }
+ }
+ if(p1 && wt != t)
+ break;
+ }
+ }
+
+ // No part found with same event list? Done.
+ if(!p1)
+ continue;
+
+ // Make sure the part to be chained is unchained first.
+ p->prevClone()->setNextClone(p->nextClone());
+ p->nextClone()->setPrevClone(p->prevClone());
+
+ // Link the part to be chained.
+ p->setPrevClone(p1);
+ p->setNextClone(p1->nextClone());
+
+ // Re-link the existing part.
+ p1->nextClone()->setPrevClone(p);
+ p1->setNextClone(p);
+ }
+}
+
+//---------------------------------------------------------
+// chainCheckErr
+//---------------------------------------------------------
+
+void chainCheckErr(Part* p)
+{
+ // At all times these must be true...
+ if(p->nextClone()->prevClone() != p)
+ printf("chainCheckErr: Next clone:%s %p prev clone:%s %p != %s %p\n", p->nextClone()->name().toLatin1().constData(), p->nextClone(), p->nextClone()->prevClone()->name().toLatin1().constData(), p->nextClone()->prevClone(), p->name().toLatin1().constData(), p);
+ if(p->prevClone()->nextClone() != p)
+ printf("chainCheckErr: Prev clone:%s %p next clone:%s %p != %s %p\n", p->prevClone()->name().toLatin1().constData(), p->prevClone(), p->prevClone()->nextClone()->name().toLatin1().constData(), p->prevClone()->nextClone(), p->name().toLatin1().constData(), p);
+}
+
+//---------------------------------------------------------
+// addPortCtrlEvents
+//---------------------------------------------------------
+
+void addPortCtrlEvents(Event& event, Part* part, bool doClones)
+{
+ // Traverse and process the clone chain ring until we arrive at the same part again.
+ // The loop is a safety net.
+ // Update: Due to the varying calls, and order of, incARefcount, (msg)ChangePart, replaceClone, and remove/addPortCtrlEvents,
+ // we can not rely on the reference count as a safety net in these routines. We will just have to trust the clone chain.
+ Part* p = part;
+ //int j = doClones ? p->cevents()->arefCount() : 1;
+ //if(j > 0)
+ {
+ //for(int i = 0; i < j; ++i)
+ while(1)
+ {
+ // Added by Tim. p3.3.6
+ //printf("addPortCtrlEvents i:%d %s %p events %p refs:%d arefs:%d\n", i, p->name().toLatin1().constData(), p, part->cevents(), part->cevents()->refCount(), j);
+
+ Track* t = p->track();
+ if(t && t->isMidiTrack())
+ {
+ MidiTrack* mt = (MidiTrack*)t;
+ int port = mt->outPort();
+ //const EventList* el = p->cevents();
+ unsigned len = p->lenTick();
+ //for(ciEvent ie = el->begin(); ie != el->end(); ++ie)
+ //{
+ //const Event& ev = ie->second;
+ // Added by Tim. p3.3.6
+ //printf("addPortCtrlEvents %s len:%d end:%d etick:%d\n", p->name().toLatin1().constData(), p->lenTick(), p->endTick(), event.tick());
+
+ // Do not add events which are past the end of the part.
+ if(event.tick() >= len)
+ break;
+
+ if(event.type() == Controller)
+ {
+ int ch = mt->outChannel();
+ int tck = event.tick() + p->tick();
+ int cntrl = event.dataA();
+ int val = event.dataB();
+ MidiPort* mp = &midiPorts[port];
+
+ // Is it a drum controller event, according to the track port's instrument?
+ if(mt->type() == Track::DRUM)
+ {
+ MidiController* mc = mp->drumController(cntrl);
+ if(mc)
+ {
+ int note = cntrl & 0x7f;
+ cntrl &= ~0xff;
+ ch = drumMap[note].channel;
+ mp = &midiPorts[drumMap[note].port];
+ cntrl |= drumMap[note].anote;
+ }
+ }
+
+ mp->setControllerVal(ch, tck, cntrl, val, p);
+ }
+ //}
+ }
+
+ if(!doClones)
+ break;
+ // Get the next clone in the chain ring.
+ p = p->nextClone();
+ // Same as original part? Finished.
+ if(p == part)
+ break;
+ }
+ }
+}
+
+//---------------------------------------------------------
+// addPortCtrlEvents
+//---------------------------------------------------------
+
+void addPortCtrlEvents(Part* part, bool doClones)
+{
+ // Traverse and process the clone chain ring until we arrive at the same part again.
+ // The loop is a safety net.
+ // Update: Due to the varying calls, and order of, incARefcount, (msg)ChangePart, replaceClone, and remove/addPortCtrlEvents,
+ // we can not rely on the reference count as a safety net in these routines. We will just have to trust the clone chain.
+ Part* p = part;
+ //int j = doClones ? p->cevents()->arefCount() : 1;
+ //if(j > 0)
+ {
+ //for(int i = 0; i < j; ++i)
+ while(1)
+ {
+ // Added by Tim. p3.3.6
+ //printf("addPortCtrlEvents i:%d %s %p events %p refs:%d arefs:%d\n", i, p->name().toLatin1().constData(), p, part->cevents(), part->cevents()->refCount(), j);
+
+ Track* t = p->track();
+ if(t && t->isMidiTrack())
+ {
+ MidiTrack* mt = (MidiTrack*)t;
+ int port = mt->outPort();
+ const EventList* el = p->cevents();
+ unsigned len = p->lenTick();
+ for(ciEvent ie = el->begin(); ie != el->end(); ++ie)
+ {
+ const Event& ev = ie->second;
+ // Added by T356. Do not add events which are past the end of the part.
+ if(ev.tick() >= len)
+ break;
+
+ if(ev.type() == Controller)
+ {
+ int ch = mt->outChannel();
+ int tck = ev.tick() + p->tick();
+ int cntrl = ev.dataA();
+ int val = ev.dataB();
+ MidiPort* mp = &midiPorts[port];
+
+ // Is it a drum controller event, according to the track port's instrument?
+ if(mt->type() == Track::DRUM)
+ {
+ MidiController* mc = mp->drumController(cntrl);
+ if(mc)
+ {
+ int note = cntrl & 0x7f;
+ cntrl &= ~0xff;
+ ch = drumMap[note].channel;
+ mp = &midiPorts[drumMap[note].port];
+ cntrl |= drumMap[note].anote;
+ }
+ }
+
+ mp->setControllerVal(ch, tck, cntrl, val, p);
+ }
+ }
+ }
+ if(!doClones)
+ break;
+ // Get the next clone in the chain ring.
+ p = p->nextClone();
+ // Same as original part? Finished.
+ if(p == part)
+ break;
+ }
+ }
+}
+
+//---------------------------------------------------------
+// removePortCtrlEvents
+//---------------------------------------------------------
+
+void removePortCtrlEvents(Event& event, Part* part, bool doClones)
+{
+ // Traverse and process the clone chain ring until we arrive at the same part again.
+ // The loop is a safety net.
+ // Update: Due to the varying calls, and order of, incARefcount, (msg)ChangePart, replaceClone, and remove/addPortCtrlEvents,
+ // we can not rely on the reference count as a safety net in these routines. We will just have to trust the clone chain.
+ Part* p = part;
+ //int j = doClones ? p->cevents()->arefCount() : 1;
+ //if(j > 0)
+ {
+ //for(int i = 0; i < j; ++i)
+ while(1)
+ {
+ Track* t = p->track();
+ if(t && t->isMidiTrack())
+ {
+ MidiTrack* mt = (MidiTrack*)t;
+ int port = mt->outPort();
+ //const EventList* el = p->cevents();
+ //unsigned len = p->lenTick();
+ //for(ciEvent ie = el->begin(); ie != el->end(); ++ie)
+ //{
+ //const Event& ev = ie->second;
+ // Added by T356. Do not remove events which are past the end of the part.
+ // No, actually, do remove ALL of them belonging to the part.
+ // Just in case there are stray values left after the part end.
+ //if(ev.tick() >= len)
+ // break;
+
+ if(event.type() == Controller)
+ {
+ int ch = mt->outChannel();
+ int tck = event.tick() + p->tick();
+ int cntrl = event.dataA();
+ MidiPort* mp = &midiPorts[port];
+
+ // Is it a drum controller event, according to the track port's instrument?
+ if(mt->type() == Track::DRUM)
+ {
+ MidiController* mc = mp->drumController(cntrl);
+ if(mc)
+ {
+ int note = cntrl & 0x7f;
+ cntrl &= ~0xff;
+ ch = drumMap[note].channel;
+ mp = &midiPorts[drumMap[note].port];
+ cntrl |= drumMap[note].anote;
+ }
+ }
+
+ mp->deleteController(ch, tck, cntrl, p);
+ }
+ //}
+ }
+
+ if(!doClones)
+ break;
+ // Get the next clone in the chain ring.
+ p = p->nextClone();
+ // Same as original part? Finished.
+ if(p == part)
+ break;
+ }
+ }
+}
+
+//---------------------------------------------------------
+// removePortCtrlEvents
+//---------------------------------------------------------
+
+void removePortCtrlEvents(Part* part, bool doClones)
+{
+ // Traverse and process the clone chain ring until we arrive at the same part again.
+ // The loop is a safety net.
+ // Update: Due to the varying calls, and order of, incARefcount, (msg)ChangePart, replaceClone, and remove/addPortCtrlEvents,
+ // we can not rely on the reference count as a safety net in these routines. We will just have to trust the clone chain.
+ Part* p = part;
+ //int j = doClones ? p->cevents()->arefCount() : 1;
+ //if(j > 0)
+ {
+ //for(int i = 0; i < j; ++i)
+ while(1)
+ {
+ Track* t = p->track();
+ if(t && t->isMidiTrack())
+ {
+ MidiTrack* mt = (MidiTrack*)t;
+ int port = mt->outPort();
+ const EventList* el = p->cevents();
+ //unsigned len = p->lenTick();
+ for(ciEvent ie = el->begin(); ie != el->end(); ++ie)
+ {
+ const Event& ev = ie->second;
+ // Added by T356. Do not remove events which are past the end of the part.
+ // No, actually, do remove ALL of them belonging to the part.
+ // Just in case there are stray values left after the part end.
+ //if(ev.tick() >= len)
+ // break;
+
+ if(ev.type() == Controller)
+ {
+ int ch = mt->outChannel();
+ int tck = ev.tick() + p->tick();
+ int cntrl = ev.dataA();
+ MidiPort* mp = &midiPorts[port];
+
+ // Is it a drum controller event, according to the track port's instrument?
+ if(mt->type() == Track::DRUM)
+ {
+ MidiController* mc = mp->drumController(cntrl);
+ if(mc)
+ {
+ int note = cntrl & 0x7f;
+ cntrl &= ~0xff;
+ ch = drumMap[note].channel;
+ mp = &midiPorts[drumMap[note].port];
+ cntrl |= drumMap[note].anote;
+ }
+ }
+
+ mp->deleteController(ch, tck, cntrl, p);
+ }
+ }
+ }
+
+ if(!doClones)
+ break;
+ // Get the next clone in the chain ring.
+ p = p->nextClone();
+ // Same as original part? Finished.
+ if(p == part)
+ break;
+ }
+ }
+}
+
+//---------------------------------------------------------
+// addEvent
+//---------------------------------------------------------
+
+iEvent Part::addEvent(Event& p)
+ {
+ return _events->add(p);
+ }
+
+//---------------------------------------------------------
+// index
+//---------------------------------------------------------
+
+int PartList::index(Part* part)
+ {
+ int index = 0;
+ for (iPart i = begin(); i != end(); ++i, ++index)
+ if (i->second == part) {
+ return index;
+ }
+ if(debugMsg)
+ printf("PartList::index(): not found!\n");
+ //return 0;
+ return -1;
+ }
+
+//---------------------------------------------------------
+// find
+//---------------------------------------------------------
+
+Part* PartList::find(int idx)
+ {
+ int index = 0;
+ for (iPart i = begin(); i != end(); ++i, ++index)
+ if (index == idx)
+ return i->second;
+ return 0;
+ }
+
+//---------------------------------------------------------
+// Part
+//---------------------------------------------------------
+
+Part::Part(Track* t)
+ {
+ _prevClone = this;
+ _nextClone = this;
+ setSn(newSn());
+ _track = t;
+ _selected = false;
+ _mute = false;
+ _colorIndex = 0;
+ _events = new EventList;
+ _events->incRef(1);
+ _events->incARef(1);
+ }
+
+//---------------------------------------------------------
+// Part
+//---------------------------------------------------------
+
+Part::Part(Track* t, EventList* ev)
+ {
+ _prevClone = this;
+ _nextClone = this;
+ setSn(newSn());
+ _track = t;
+ _selected = false;
+ _mute = false;
+ _colorIndex = 0;
+ _events = ev;
+ _events->incRef(1);
+ _events->incARef(1);
+ }
+
+//---------------------------------------------------------
+// MidiPart
+// copy constructor
+//---------------------------------------------------------
+
+MidiPart::MidiPart(const MidiPart& p) : Part(p)
+{
+ _prevClone = this;
+ _nextClone = this;
+ //setSn(newSn());
+ //_sn = p._sn;
+ //_name = p._name;
+ //_selected = p._selected;
+ //_mute = p._mute;
+ //_colorIndex = p._colorIndex;
+ //_track = p._track;
+ //_events = p._events;
+}
+
+//---------------------------------------------------------
+// WavePart
+//---------------------------------------------------------
+
+WavePart::WavePart(WaveTrack* t)
+ : Part(t)
+ {
+ setType(FRAMES);
+ }
+
+WavePart::WavePart(WaveTrack* t, EventList* ev)
+ : Part(t, ev)
+ {
+ setType(FRAMES);
+ }
+
+//---------------------------------------------------------
+// WavePart
+// copy constructor
+//---------------------------------------------------------
+
+WavePart::WavePart(const WavePart& p) : Part(p)
+{
+ _prevClone = this;
+ _nextClone = this;
+ //setSn(newSn());
+ //_sn = p._sn;
+ //_name = p._name;
+ //_selected = p._selected;
+ //_mute = p._mute;
+ //_colorIndex = p._colorIndex;
+ //_track = p._track;
+ //_events = p._events;
+}
+
+//---------------------------------------------------------
+// Part
+//---------------------------------------------------------
+
+Part::~Part()
+ {
+ _events->incRef(-1);
+ if (_events->refCount() <= 0)
+ delete _events;
+ }
+
+/*
+//---------------------------------------------------------
+// unchainClone
+//---------------------------------------------------------
+
+void Part::unchainClone()
+{
+ chainCheckErr();
+
+ _prevClone->setNextClone(_nextClone);
+ _nextClone->setPrevClone(_prevClone);
+
+ _prevClone = this;
+ _nextClone = this;
+}
+
+//---------------------------------------------------------
+// chainClone
+// The quick way - if part to chain to is known...
+//---------------------------------------------------------
+
+void Part::chainClone(const Part* p)
+{
+ chainCheckErr();
+
+ // Make sure the part is unchained first.
+ p->prevClone()->setNextClone(p->nextClone());
+ p->nextClone()->setPrevClone(p->prevClone());
+
+ p->setPrevClone(this);
+ p->setNextClone(_nextClone->prevClone());
+
+ _nextClone->setPrevClone(p);
+ _nextClone = (Part*)p;
+}
+
+//---------------------------------------------------------
+// chainClone
+// The slow way - if part to chain to is not known...
+//---------------------------------------------------------
+
+void Part::chainClone()
+{
+ chainCheckErr();
+
+ // Look for a part with the same event list, that we can chain to...
+ Part* p = 0;
+ if(!_track || (_track && _track->isMidiTrack()))
+ {
+ MidiTrackList* mtl = song->midis();
+ for(ciMidiTrack imt = mtl->begin(); imt != mtl->end(); ++imt)
+ {
+ const PartList* pl = (*imt)->cparts();
+ for(ciPart ip = pl->begin(); ip != pl->end(); ++ip)
+ {
+ if(ip->second != this && ip->second->events() == _events)
+ {
+ p = ip->second;
+ break;
+ }
+ }
+ }
+ }
+
+ if((!p && !_track) || (_track && _track->type() == Track::WAVE))
+ {
+ WaveTrackList* wtl = song->waves();
+ for(ciWaveTrack iwt = wtl->begin(); iwt != wtl->end(); ++iwt)
+ {
+ const PartList* pl = (*iwt)->cparts();
+ for(ciPart ip = pl->begin(); ip != pl->end(); ++ip)
+ {
+ if(ip->second != this && ip->second->events() == _events)
+ {
+ p = ip->second;
+ break;
+ }
+ }
+ }
+ }
+
+ // No part found with same event list? Done.
+ if(!p)
+ return;
+
+ // Make sure this part is unchained first.
+ _prevClone->setNextClone(_nextClone);
+ _nextClone->setPrevClone(_prevClone);
+
+ _prevClone = p;
+ _nextClone = p->nextClone();
+
+ p->nextClone()->setPrevClone(this);
+ p->setNextClone(this);
+}
+
+//---------------------------------------------------------
+// replaceClone
+//---------------------------------------------------------
+
+void Part::replaceClone(const Part* p)
+{
+ chainCheckErr();
+
+ // Make sure the part is unchained first.
+ p->prevClone()->setNextClone(p->nextClone());
+ p->nextClone()->setPrevClone(p->prevClone());
+
+ // If this part is a clone, not a single lone part...
+ if(_prevClone != this)
+ _prevClone->setNextClone(p);
+ if(_nextClone != this)
+ _nextClone->setPrevClone(p);
+
+ p->setPrevClone(_prevClone);
+ p->setNextClone(_nextClone);
+
+ _nextClone = this;
+ _prevClone = this;
+}
+
+//---------------------------------------------------------
+// chainCheckErr
+//---------------------------------------------------------
+
+void Part::chainCheckErr()
+{
+ if(_nextClone->prevClone() != this)
+ printf("Part::chainCheckErr Error! Next clone:%s %x prev clone:%s %x != this:%s %x\n", _nextClone->name().toLatin1().constData(), _nextClone, _nextClone->prevClone()->name().toLatin1().constData(), _nextClone->prevClone(), name().toLatin1().constData(), this);
+ if(_prevClone->nextClone() != this)
+ printf("Part::chainCheckErr Error! Prev clone:%s %x next clone:%s %x != this:%s %x\n", _prevClone->name().toLatin1().constData(), _prevClone, _prevClone->nextClone()->name().toLatin1().constData(), _prevClone->nextClone(), name().toLatin1().constData(), this);
+}
+*/
+
+//---------------------------------------------------------
+// findPart
+//---------------------------------------------------------
+
+iPart PartList::findPart(unsigned tick)
+ {
+ iPart i;
+ for (i = begin(); i != end(); ++i)
+ if (i->second->tick() == tick)
+ break;
+ return i;
+ }
+
+//---------------------------------------------------------
+// add
+//---------------------------------------------------------
+
+iPart PartList::add(Part* part)
+ {
+ // Added by T356. A part list containing wave parts should be sorted by
+ // frames. WaveTrack::fetchData() relies on the sorting order, and
+ // there was a bug that waveparts were sometimes muted because of
+ // incorrect sorting order (by ticks).
+ // Also, when the tempo map is changed, every wavepart would have to be
+ // re-added to the part list so that the proper sorting order (by ticks)
+ // could be achieved.
+ // Note that in a med file, the tempo list is loaded AFTER all the tracks.
+ // There was a bug that all the wave parts' tick values were not correct,
+ // since they were computed BEFORE the tempo map was loaded.
+ if(part->type() == Pos::FRAMES)
+ return insert(std::pair<const int, Part*> (part->frame(), part));
+ else
+ return insert(std::pair<const int, Part*> (part->tick(), part));
+ }
+
+//---------------------------------------------------------
+// remove
+//---------------------------------------------------------
+
+void PartList::remove(Part* part)
+ {
+ iPart i;
+ for (i = begin(); i != end(); ++i) {
+ if (i->second == part) {
+ erase(i);
+ break;
+ }
+ }
+ assert(i != end());
+ }
+
+//---------------------------------------------------------
+// addPart
+//---------------------------------------------------------
+
+void Song::addPart(Part* part)
+ {
+ // adjust song len:
+ unsigned epos = part->tick() + part->lenTick();
+
+ if (epos > len())
+ _len = epos;
+ part->track()->addPart(part);
+
+ //part->addPortCtrlEvents();
+ // Indicate do not do clones.
+ addPortCtrlEvents(part, false);
+ }
+
+//---------------------------------------------------------
+// removePart
+//---------------------------------------------------------
+
+void Song::removePart(Part* part)
+ {
+ //part->removePortCtrlEvents();
+ // Indicate do not do clones.
+ //removePortCtrlEvents(part);
+ removePortCtrlEvents(part, false);
+ Track* track = part->track();
+ track->parts()->remove(part);
+ }
+
+//---------------------------------------------------------
+// cmdResizePart
+//---------------------------------------------------------
+
+void Song::cmdResizePart(Track* track, Part* oPart, unsigned int len)
+ {
+ switch(track->type()) {
+ case Track::WAVE:
+ {
+ WavePart* nPart = new WavePart(*(WavePart*)oPart);
+ EventList* el = nPart->events();
+ unsigned new_partlength = tempomap.deltaTick2frame(oPart->tick(), oPart->tick() + len);
+ //printf("new partlength in frames: %d\n", new_partlength);
+
+ // If new nr of frames is less than previous what can happen is:
+ // - 0 or more events are beginning after the new final position. Those are removed from the part
+ // - The last event begins before new final position and ends after it. If so, it will be resized to end at new part length
+ if (new_partlength < oPart->lenFrame()) {
+ startUndo();
+
+ for (iEvent i = el->begin(); i != el->end(); i++) {
+ Event e = i->second;
+ unsigned event_startframe = e.frame();
+ unsigned event_endframe = event_startframe + e.lenFrame();
+ //printf("Event frame=%d, length=%d\n", event_startframe, event_length);
+ if (event_endframe < new_partlength)
+ continue;
+ if (event_startframe > new_partlength) { // If event start was after the new length, remove it from part
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgDeleteEvent(e, nPart, false);
+ audio->msgDeleteEvent(e, nPart, false, false, false);
+ continue;
+ }
+ if (event_endframe > new_partlength) { // If this event starts before new length and ends after, shrink it
+ Event newEvent = e.clone();
+ newEvent.setLenFrame(new_partlength - event_startframe);
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(e, newEvent, nPart, false);
+ audio->msgChangeEvent(e, newEvent, nPart, false, false, false);
+ }
+ }
+ nPart->setLenFrame(new_partlength);
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangePart(oPart, nPart, false);
+ audio->msgChangePart(oPart, nPart, false, false, false);
+
+ endUndo(SC_PART_MODIFIED);
+ }
+ // If the part is expanded there can be no additional events beginning after the previous final position
+ // since those are removed if the part has been shrunk at some time (see above)
+ // The only thing we need to check is the final event: If it has data after the previous final position,
+ // we'll expand that event
+ else {
+ if(!el->empty())
+ {
+ iEvent i = el->end();
+ i--;
+ Event last = i->second;
+ unsigned last_start = last.frame();
+ SndFileR file = last.sndFile();
+ if (file.isNull())
+ return;
+
+ unsigned clipframes = (file.samples() - last.spos());// / file.channels();
+ Event newEvent = last.clone();
+ //printf("SndFileR samples=%d channels=%d event samplepos=%d clipframes=%d\n", file.samples(), file.channels(), last.spos(), clipframes);
+
+ unsigned new_eventlength = new_partlength - last_start;
+ if (new_eventlength > clipframes) // Shrink event length if new partlength exceeds last clip
+ new_eventlength = clipframes;
+
+ newEvent.setLenFrame(new_eventlength);
+ startUndo();
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(last, newEvent, nPart, false);
+ audio->msgChangeEvent(last, newEvent, nPart, false, false, false);
+ }
+ else
+ {
+ startUndo();
+ }
+
+ nPart->setLenFrame(new_partlength);
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangePart(oPart, nPart, false);
+ audio->msgChangePart(oPart, nPart, false, false, false);
+ endUndo(SC_PART_MODIFIED);
+ }
+ }
+ break;
+ case Track::MIDI:
+ case Track::DRUM:
+ {
+ startUndo();
+
+ MidiPart* nPart = new MidiPart(*(MidiPart*)oPart);
+ nPart->setLenTick(len);
+ // Indicate no undo, and do port controller values but not clone parts.
+ audio->msgChangePart(oPart, nPart, false, true, false);
+
+ // cut Events in nPart
+ // Changed by T356. Don't delete events if this is a clone part.
+ // The other clones might be longer than this one and need these events.
+ if(nPart->cevents()->arefCount() <= 1)
+ {
+ if(oPart->lenTick() > len) {
+ EventList* el = nPart->events();
+ iEvent ie = el->lower_bound(len);
+ for (; ie != el->end();) {
+ iEvent i = ie;
+ ++ie;
+ // Indicate no undo, and do port controller values and clone parts.
+ audio->msgDeleteEvent(i->second, nPart, false, true, true);
+ }
+ }
+ }
+
+ /*
+ // cut Events in nPart
+ // Changed by T356. Don't delete events if this is a clone part.
+ // The other clones might be longer than this one and need these events.
+ if(oPart->cevents()->arefCount() <= 1)
+ {
+ if (oPart->lenTick() > len) {
+ EventList* el = nPart->events();
+ iEvent ie = el->lower_bound(len);
+ for (; ie != el->end();) {
+ iEvent i = ie;
+ ++ie;
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgDeleteEvent(i->second, nPart, false);
+ audio->msgDeleteEvent(i->second, nPart, false, false, false);
+ }
+ }
+ }
+ // Indicate no undo, and do port controller values but not clone parts.
+ //audio->msgChangePart(oPart, nPart, false);
+ audio->msgChangePart(oPart, nPart, false, true, false);
+ */
+
+ endUndo(SC_PART_MODIFIED);
+ break;
+ }
+ default:
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// splitPart
+// split part "part" at "tick" position
+// create two new parts p1 and p2
+//---------------------------------------------------------
+
+void Track::splitPart(Part* part, int tickpos, Part*& p1, Part*& p2)
+ {
+ int l1 = 0; // len of first new part (ticks or samples)
+ int l2 = 0; // len of second new part
+
+ int samplepos = tempomap.tick2frame(tickpos);
+
+ switch (type()) {
+ case WAVE:
+ l1 = samplepos - part->frame();
+ l2 = part->lenFrame() - l1;
+ break;
+ case MIDI:
+ case DRUM:
+ l1 = tickpos - part->tick();
+ l2 = part->lenTick() - l1;
+ break;
+ default:
+ return;
+ }
+
+ if (l1 <= 0 || l2 <= 0)
+ return;
+
+ p1 = newPart(part); // new left part
+ p2 = newPart(part); // new right part
+
+ // Added by Tim. p3.3.6
+ //printf("Track::splitPart part ev %p sz:%d ref:%d p1 %p sz:%d ref:%d p2 %p sz:%d ref:%d\n", part->events(), part->events()->size(), part->events()->arefCount(), p1->events(), p1->events()->size(), p1->events()->arefCount(), p2->events(), p2->events()->size(), p2->events()->arefCount());
+
+ switch (type()) {
+ case WAVE:
+ p1->setLenFrame(l1);
+ p2->setFrame(samplepos);
+ p2->setLenFrame(l2);
+ break;
+ case MIDI:
+ case DRUM:
+ p1->setLenTick(l1);
+ p2->setTick(tickpos);
+ p2->setLenTick(l2);
+ break;
+ default:
+ break;
+ }
+
+ p2->setSn(p2->newSn());
+
+ EventList* se = part->events();
+ EventList* de1 = p1->events();
+ EventList* de2 = p2->events();
+
+ if (type() == WAVE) {
+ int ps = part->frame();
+ int d1p1 = p1->frame();
+ int d2p1 = p1->endFrame();
+ int d1p2 = p2->frame();
+ int d2p2 = p2->endFrame();
+ for (iEvent ie = se->begin(); ie != se->end(); ++ie) {
+ Event event = ie->second;
+ int s1 = event.frame() + ps;
+ int s2 = event.endFrame() + ps;
+
+ if ((s2 > d1p1) && (s1 < d2p1)) {
+ Event si = event.mid(d1p1 - ps, d2p1 - ps);
+ de1->add(si);
+ }
+ if ((s2 > d1p2) && (s1 < d2p2)) {
+ Event si = event.mid(d1p2 - ps, d2p2 - ps);
+ de2->add(si);
+ }
+ }
+ }
+ else {
+ for (iEvent ie = se->begin(); ie != se->end(); ++ie) {
+ Event event = ie->second.clone();
+ int t = event.tick();
+ if (t >= l1) {
+ event.move(-l1);
+ de2->add(event);
+ }
+ else
+ de1->add(event);
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// cmdSplitPart
+//---------------------------------------------------------
+
+void Song::cmdSplitPart(Track* track, Part* part, int tick)
+ {
+ int l1 = tick - part->tick();
+ int l2 = part->lenTick() - l1;
+ if (l1 <= 0 || l2 <= 0)
+ return;
+ Part* p1;
+ Part* p2;
+ track->splitPart(part, tick, p1, p2);
+
+ startUndo();
+ // Indicate no undo, and do port controller values but not clone parts.
+ //audio->msgChangePart(part, p1, false);
+ audio->msgChangePart(part, p1, false, true, false);
+ audio->msgAddPart(p2, false);
+ endUndo(SC_TRACK_MODIFIED | SC_PART_MODIFIED | SC_PART_INSERTED);
+ }
+
+//---------------------------------------------------------
+// changePart
+//---------------------------------------------------------
+
+void Song::changePart(Part* oPart, Part* nPart)
+ {
+ nPart->setSn(oPart->sn());
+
+ Track* oTrack = oPart->track();
+ Track* nTrack = nPart->track();
+
+ // Added by Tim. p3.3.6
+ //printf("Song::changePart before oPart->removePortCtrlEvents oldPart refs:%d Arefs:%d newPart refs:%d Arefs:%d\n", oPart->events()->refCount(), oPart->events()->arefCount(), nPart->events()->refCount(), nPart->events()->arefCount());
+
+ // Removed. Port controller events will have to be add/removed separately from this routine.
+ //oPart->removePortCtrlEvents();
+ //removePortCtrlEvents(oPart);
+
+ // Added by Tim. p3.3.6
+ //printf("Song::changePart after oPart->removePortCtrlEvents oldPart refs:%d Arefs:%d newPart refs:%d Arefs:%d\n", oPart->events()->refCount(), oPart->events()->arefCount(), nPart->events()->refCount(), nPart->events()->arefCount());
+
+ oTrack->parts()->remove(oPart);
+ nTrack->parts()->add(nPart);
+
+ // Added by Tim. p3.3.6
+ //printf("Song::changePart after add(nPart) oldPart refs:%d Arefs:%d newPart refs:%d Arefs:%d\n", oPart->events()->refCount(), oPart->events()->arefCount(), nPart->events()->refCount(), nPart->events()->arefCount());
+
+ //nPart->addPortCtrlEvents();
+ //addPortCtrlEvents(nPart);
+
+ // Added by Tim. p3.3.6
+ //printf("Song::changePart after nPart->addPortCtrlEvents() oldPart refs:%d Arefs:%d newPart refs:%d Arefs:%d\n", oPart->events()->refCount(), oPart->events()->arefCount(), nPart->events()->refCount(), nPart->events()->arefCount());
+
+ // Added by T356.
+ // adjust song len:
+ unsigned epos = nPart->tick() + nPart->lenTick();
+ if (epos > len())
+ _len = epos;
+
+ // Added by Tim. p3.3.6
+ //printf("Song::changePart after len adjust oldPart refs:%d Arefs:%d newPart refs:%d Arefs:%d\n", oPart->events()->refCount(), oPart->events()->arefCount(), nPart->events()->refCount(), nPart->events()->arefCount());
+
+ }
+
+//---------------------------------------------------------
+// cmdGluePart
+//---------------------------------------------------------
+
+void Song::cmdGluePart(Track* track, Part* oPart)
+ {
+ // p3.3.54
+ if(track->type() != Track::WAVE && !track->isMidiTrack())
+ return;
+
+ PartList* pl = track->parts();
+ Part* nextPart = 0;
+
+ for (iPart ip = pl->begin(); ip != pl->end(); ++ip) {
+ if (ip->second == oPart) {
+ ++ip;
+ if (ip == pl->end())
+ return;
+ nextPart = ip->second;
+ break;
+ }
+ }
+
+ Part* nPart = track->newPart(oPart);
+ nPart->setLenTick(nextPart->tick() + nextPart->lenTick() - oPart->tick());
+
+ // populate nPart with Events from oPart and nextPart
+
+ EventList* sl1 = oPart->events();
+ EventList* dl = nPart->events();
+
+ for (iEvent ie = sl1->begin(); ie != sl1->end(); ++ie)
+ dl->add(ie->second);
+
+ EventList* sl2 = nextPart->events();
+
+ //int frameOffset = nextPart->frame() - oPart->frame();
+ //for (iEvent ie = sl2->begin(); ie != sl2->end(); ++ie) {
+ // Event event = ie->second.clone();
+ // event.setFrame(event.frame() + frameOffset);
+ // dl->add(event);
+ // }
+ // p3.3.54 Changed.
+ if(track->type() == Track::WAVE)
+ {
+ int frameOffset = nextPart->frame() - oPart->frame();
+ for (iEvent ie = sl2->begin(); ie != sl2->end(); ++ie)
+ {
+ Event event = ie->second.clone();
+ event.setFrame(event.frame() + frameOffset);
+ dl->add(event);
+ }
+ }
+ else
+ if(track->isMidiTrack())
+ {
+ int tickOffset = nextPart->tick() - oPart->tick();
+ for (iEvent ie = sl2->begin(); ie != sl2->end(); ++ie)
+ {
+ Event event = ie->second.clone();
+ event.setTick(event.tick() + tickOffset);
+ dl->add(event);
+ }
+ }
+
+ startUndo();
+ audio->msgRemovePart(nextPart, false);
+ // Indicate no undo, and do port controller values but not clone parts.
+ //audio->msgChangePart(oPart, nPart, false);
+ audio->msgChangePart(oPart, nPart, false, true, false);
+ endUndo(SC_PART_MODIFIED | SC_PART_REMOVED);
+ }
+
+//---------------------------------------------------------
+// dump
+//---------------------------------------------------------
+
+void Part::dump(int n) const
+ {
+ for (int i = 0; i < n; ++i)
+ putchar(' ');
+ printf("Part: <%s> ", _name.toLatin1().constData());
+ for (int i = 0; i < n; ++i)
+ putchar(' ');
+ PosLen::dump();
+ }
+
+void WavePart::dump(int n) const
+ {
+ Part::dump(n);
+ for (int i = 0; i < n; ++i)
+ putchar(' ');
+ printf("WavePart\n");
+ }
+
+void MidiPart::dump(int n) const
+ {
+ Part::dump(n);
+ for (int i = 0; i < n; ++i)
+ putchar(' ');
+ printf("MidiPart\n");
+ }
+
+//---------------------------------------------------------
+// clone
+//---------------------------------------------------------
+
+MidiPart* MidiPart::clone() const
+ {
+ return new MidiPart(*this);
+ }
+
+WavePart* WavePart::clone() const
+ {
+ return new WavePart(*this);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/part.h b/attic/muse2-oom/muse2/muse/part.h
new file mode 100644
index 00000000..11ff2fd4
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/part.h
@@ -0,0 +1,175 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: part.h,v 1.5.2.4 2009/05/24 21:43:44 terminator356 Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __PART_H__
+#define __PART_H__
+
+#include <map>
+
+// Added by T356.
+#include <uuid/uuid.h>
+
+#include "event.h"
+#include "audioconvert.h"
+
+class QString;
+
+class Track;
+class MidiTrack;
+class WaveTrack;
+class Xml;
+class Part;
+//class AudioConvertMap;
+
+// typedef std::multimap<unsigned, Event*, std::less<unsigned> >::iterator iEvent;
+
+struct ClonePart {
+ //const EventList* el;
+ const Part* cp;
+ int id;
+ uuid_t uuid;
+ //ClonePart(const EventList* e, int i) : el(e), id(i) {}
+ //ClonePart(const Part* p, int i) : cp(p), id(i) {}
+ ClonePart(const Part*, int i = -1);
+ };
+
+typedef std::list<ClonePart> CloneList;
+typedef CloneList::iterator iClone;
+
+//---------------------------------------------------------
+// Part
+//---------------------------------------------------------
+
+class Part : public PosLen {
+ static int snGen;
+ int _sn;
+
+ QString _name;
+ bool _selected;
+ bool _mute;
+ int _colorIndex;
+
+ protected:
+ Track* _track;
+ EventList* _events;
+ Part* _prevClone;
+ Part* _nextClone;
+
+ public:
+ Part(Track*);
+ Part(Track*, EventList*);
+ virtual ~Part();
+ int sn() { return _sn; }
+ void setSn(int n) { _sn = n; }
+ int newSn() { return snGen++; }
+
+ virtual Part* clone() const = 0;
+
+ const QString& name() const { return _name; }
+ void setName(const QString& s) { _name = s; }
+ bool selected() const { return _selected; }
+ void setSelected(bool f) { _selected = f; }
+ bool mute() const { return _mute; }
+ void setMute(bool b) { _mute = b; }
+ Track* track() const { return _track; }
+ void setTrack(Track*t) { _track = t; }
+ EventList* events() const { return _events; }
+ const EventList* cevents() const { return _events; }
+ int colorIndex() const { return _colorIndex; }
+ void setColorIndex(int idx) { _colorIndex = idx; }
+
+ Part* prevClone() { return _prevClone; }
+ Part* nextClone() { return _nextClone; }
+ void setPrevClone(Part* p) { _prevClone = p; }
+ void setNextClone(Part* p) { _nextClone = p; }
+
+ iEvent addEvent(Event& p);
+
+ //virtual void read(Xml&, int newPartOffset=0, bool toTrack = true);
+ //virtual void write(int, Xml&) const;
+ //virtual void write(int, Xml&, bool isCopy = false) const;
+ virtual void write(int, Xml&, bool isCopy = false, bool forceWavePaths = false) const;
+
+// virtual Event* newEvent() const = 0;
+ virtual void dump(int n = 0) const;
+ };
+
+//---------------------------------------------------------
+// MidiPart
+//---------------------------------------------------------
+
+class MidiPart : public Part {
+
+ public:
+ MidiPart(MidiTrack* t) : Part((Track*)t) {}
+ MidiPart(MidiTrack* t, EventList* ev) : Part((Track*)t, ev) {}
+ MidiPart(const MidiPart& p);
+ virtual ~MidiPart() {}
+ virtual MidiPart* clone() const;
+ MidiTrack* track() const { return (MidiTrack*)Part::track(); }
+
+// virtual Event* newEvent() const;
+ virtual void dump(int n = 0) const;
+ };
+
+//---------------------------------------------------------
+// WavePart
+//---------------------------------------------------------
+
+class WavePart : public Part {
+
+ // p3.3.31
+ AudioConvertMap _converters;
+
+ public:
+ WavePart(WaveTrack* t);
+ WavePart(WaveTrack* t, EventList* ev);
+ WavePart(const WavePart& p);
+ virtual ~WavePart() {}
+ virtual WavePart* clone() const;
+ WaveTrack* track() const { return (WaveTrack*)Part::track(); }
+
+// virtual Event* newEvent() const;
+ virtual void dump(int n = 0) const;
+ };
+
+//---------------------------------------------------------
+// PartList
+//---------------------------------------------------------
+
+typedef std::multimap<int, Part*, std::less<unsigned> >::iterator iPart;
+typedef std::multimap<int, Part*, std::less<unsigned> >::const_iterator ciPart;
+
+class PartList : public std::multimap<int, Part*, std::less<unsigned> > {
+ public:
+ iPart findPart(unsigned tick);
+ iPart add(Part*);
+ void remove(Part* part);
+ int index(Part*);
+ Part* find(int idx);
+ };
+
+extern void chainClone(Part* p);
+extern void chainClone(Part* p1, Part* p2);
+extern void unchainClone(Part* p);
+extern void replaceClone(Part* p1, Part* p2);
+extern void chainCheckErr(Part* p);
+extern void unchainTrackParts(Track* t, bool decRefCount);
+extern void chainTrackParts(Track* t, bool incRefCount);
+extern void addPortCtrlEvents(Part* part, bool doClones);
+extern void addPortCtrlEvents(Event& event, Part* part, bool doClones);
+extern void removePortCtrlEvents(Part* part, bool doClones);
+extern void removePortCtrlEvents(Event& event, Part* part, bool doClones);
+extern CloneList cloneList;
+//extern CloneList copyCloneList;
+//extern void updateCloneList(Part* oPart, Part* nPart);
+//extern void clearClipboardAndCloneList();
+extern Part* readXmlPart(Xml&, Track*, bool doClone = false, bool toTrack = true);
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/plugin.cpp b/attic/muse2-oom/muse2/muse/plugin.cpp
new file mode 100644
index 00000000..5bacf092
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/plugin.cpp
@@ -0,0 +1,3880 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: plugin.cpp,v 1.21.2.23 2009/12/15 22:07:12 spamatica Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <dlfcn.h>
+#include <cmath>
+#include <math.h>
+
+#include <QButtonGroup>
+#include <QCheckBox>
+#include <QComboBox>
+#include <QDir>
+#include <QFile>
+#include <QGridLayout>
+#include <QGroupBox>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QMainWindow>
+#include <QMessageBox>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QSignalMapper>
+#include <QSizePolicy>
+#include <QScrollArea>
+#include <QTimer>
+#include <QToolBar>
+#include <QToolButton>
+#include <QTreeWidget>
+#include <QVBoxLayout>
+#include <QWhatsThis>
+
+#include "globals.h"
+#include "gconfig.h"
+#include "filedialog.h"
+#include "slider.h"
+#include "midictrl.h"
+#include "plugin.h"
+#include "xml.h"
+#include "icons.h"
+#include "song.h"
+#include "doublelabel.h"
+#include "fastlog.h"
+#include "checkbox.h"
+
+#include "audio.h"
+#include "al/dsp.h"
+
+#include "config.h"
+
+// Turn on debugging messages.
+//#define PLUGIN_DEBUGIN
+
+PluginList plugins;
+
+/*
+static const char* preset_file_pattern[] = {
+ QT_TRANSLATE_NOOP("@default", "Presets (*.pre *.pre.gz *.pre.bz2)"),
+ QT_TRANSLATE_NOOP("@default", "All Files (*)"),
+ 0
+ };
+
+static const char* preset_file_save_pattern[] = {
+ QT_TRANSLATE_NOOP("@default", "Presets (*.pre)"),
+ QT_TRANSLATE_NOOP("@default", "gzip compressed presets (*.pre.gz)"),
+ QT_TRANSLATE_NOOP("@default", "bzip2 compressed presets (*.pre.bz2)"),
+ QT_TRANSLATE_NOOP("@default", "All Files (*)"),
+ 0
+ };
+*/
+
+int PluginDialog::selectedPlugType = 0;
+QStringList PluginDialog::sortItems = QStringList();
+
+//---------------------------------------------------------
+// ladspa2MidiControlValues
+//---------------------------------------------------------
+
+bool ladspa2MidiControlValues(const LADSPA_Descriptor* plugin, int port, int ctlnum, int* min, int* max, int* def)
+{
+ LADSPA_PortRangeHint range = plugin->PortRangeHints[port];
+ LADSPA_PortRangeHintDescriptor desc = range.HintDescriptor;
+
+ float fmin, fmax, fdef;
+ int imin, imax;
+ float frng;
+ //int idef;
+
+ //ladspaControlRange(plugin, port, &fmin, &fmax);
+
+ bool hasdef = ladspaDefaultValue(plugin, port, &fdef);
+ //bool isint = desc & LADSPA_HINT_INTEGER;
+ MidiController::ControllerType t = midiControllerType(ctlnum);
+
+ #ifdef PLUGIN_DEBUGIN
+ printf("ladspa2MidiControlValues: ctlnum:%d ladspa port:%d has default?:%d default:%f\n", ctlnum, port, hasdef, fdef);
+ #endif
+
+ if(desc & LADSPA_HINT_TOGGLED)
+ {
+ #ifdef PLUGIN_DEBUGIN
+ printf("ladspa2MidiControlValues: has LADSPA_HINT_TOGGLED\n");
+ #endif
+
+ *min = 0;
+ *max = 1;
+ *def = (int)lrint(fdef);
+ return hasdef;
+ }
+
+ float m = 1.0;
+ if(desc & LADSPA_HINT_SAMPLE_RATE)
+ {
+ #ifdef PLUGIN_DEBUGIN
+ printf("ladspa2MidiControlValues: has LADSPA_HINT_SAMPLE_RATE\n");
+ #endif
+
+ m = float(sampleRate);
+ }
+
+ if(desc & LADSPA_HINT_BOUNDED_BELOW)
+ {
+ #ifdef PLUGIN_DEBUGIN
+ printf("ladspa2MidiControlValues: has LADSPA_HINT_BOUNDED_BELOW\n");
+ #endif
+
+ fmin = range.LowerBound * m;
+ }
+ else
+ fmin = 0.0;
+
+ if(desc & LADSPA_HINT_BOUNDED_ABOVE)
+ {
+ #ifdef PLUGIN_DEBUGIN
+ printf("ladspa2MidiControlValues: has LADSPA_HINT_BOUNDED_ABOVE\n");
+ #endif
+
+ fmax = range.UpperBound * m;
+ }
+ else
+ fmax = 1.0;
+
+ frng = fmax - fmin;
+ imin = lrint(fmin);
+ imax = lrint(fmax);
+ //irng = imax - imin;
+
+ int ctlmn = 0;
+ int ctlmx = 127;
+
+ #ifdef PLUGIN_DEBUGIN
+ printf("ladspa2MidiControlValues: port min:%f max:%f \n", fmin, fmax);
+ #endif
+
+ //bool isneg = (fmin < 0.0);
+ bool isneg = (imin < 0);
+ int bias = 0;
+ switch(t)
+ {
+ case MidiController::RPN:
+ case MidiController::NRPN:
+ case MidiController::Controller7:
+ if(isneg)
+ {
+ ctlmn = -64;
+ ctlmx = 63;
+ bias = -64;
+ }
+ else
+ {
+ ctlmn = 0;
+ ctlmx = 127;
+ }
+ break;
+ case MidiController::Controller14:
+ case MidiController::RPN14:
+ case MidiController::NRPN14:
+ if(isneg)
+ {
+ ctlmn = -8192;
+ ctlmx = 8191;
+ bias = -8192;
+ }
+ else
+ {
+ ctlmn = 0;
+ ctlmx = 16383;
+ }
+ break;
+ case MidiController::Program:
+ ctlmn = 0;
+ //ctlmx = 0xffffff;
+ ctlmx = 0x3fff; // FIXME: Really should not happen or be allowed. What to do here...
+ break;
+ case MidiController::Pitch:
+ ctlmn = -8192;
+ ctlmx = 8191;
+ break;
+ case MidiController::Velo: // cannot happen
+ default:
+ break;
+ }
+ //int ctlrng = ctlmx - ctlmn;
+ float fctlrng = float(ctlmx - ctlmn);
+
+ // Is it an integer control?
+ if(desc & LADSPA_HINT_INTEGER)
+ {
+ #ifdef PLUGIN_DEBUGIN
+ printf("ladspa2MidiControlValues: has LADSPA_HINT_INTEGER\n");
+ #endif
+
+ // If the upper or lower limit is beyond the controller limits, just scale the whole range to fit.
+ // We could get fancy by scaling only the negative or positive domain, or each one separately, but no...
+ //if((imin < ctlmn) || (imax > ctlmx))
+ //{
+ // float scl = float(irng) / float(fctlrng);
+ // if((ctlmn - imin) > (ctlmx - imax))
+ // scl = float(ctlmn - imin);
+ // else
+ // scl = float(ctlmx - imax);
+ //}
+ // No, instead just clip the limits. ie fit the range into clipped space.
+ if(imin < ctlmn)
+ imin = ctlmn;
+ if(imax > ctlmx)
+ imax = ctlmx;
+
+ *min = imin;
+ *max = imax;
+
+ //int idef = (int)lrint(fdef);
+ //if(idef < ctlmn)
+ // idef = ctlmn;
+ //if(idef > ctlmx)
+ // idef = ctlmx;
+ //*def = idef;
+
+ *def = (int)lrint(fdef);
+
+ return hasdef;
+ }
+
+ // It's a floating point control, just use wide open maximum range.
+ *min = ctlmn;
+ *max = ctlmx;
+
+ // Orcan: commented out next 2 lines to suppress compiler warning:
+ //float fbias = (fmin + fmax) / 2.0;
+ //float normbias = fbias / frng;
+ float normdef = fdef / frng;
+ fdef = normdef * fctlrng;
+
+ // FIXME: TODO: Incorrect... Fix this somewhat more trivial stuff later....
+
+ *def = (int)lrint(fdef) + bias;
+
+ #ifdef PLUGIN_DEBUGIN
+ printf("ladspa2MidiControlValues: setting default:%d\n", *def);
+ #endif
+
+ return hasdef;
+}
+
+//---------------------------------------------------------
+// midi2LadspaValue
+//---------------------------------------------------------
+
+float midi2LadspaValue(const LADSPA_Descriptor* plugin, int port, int ctlnum, int val)
+{
+ LADSPA_PortRangeHint range = plugin->PortRangeHints[port];
+ LADSPA_PortRangeHintDescriptor desc = range.HintDescriptor;
+
+ float fmin, fmax;
+ int imin;
+ //int imax;
+ float frng;
+ //int idef;
+
+ //ladspaControlRange(plugin, port, &fmin, &fmax);
+
+ //bool hasdef = ladspaDefaultValue(plugin, port, &fdef);
+ //bool isint = desc & LADSPA_HINT_INTEGER;
+ MidiController::ControllerType t = midiControllerType(ctlnum);
+
+ #ifdef PLUGIN_DEBUGIN
+ printf("midi2LadspaValue: ctlnum:%d ladspa port:%d val:%d\n", ctlnum, port, val);
+ #endif
+
+ float m = 1.0;
+ if(desc & LADSPA_HINT_SAMPLE_RATE)
+ {
+ #ifdef PLUGIN_DEBUGIN
+ printf("midi2LadspaValue: has LADSPA_HINT_SAMPLE_RATE\n");
+ #endif
+
+ m = float(sampleRate);
+ }
+
+ if(desc & LADSPA_HINT_BOUNDED_BELOW)
+ {
+ #ifdef PLUGIN_DEBUGIN
+ printf("midi2LadspaValue: has LADSPA_HINT_BOUNDED_BELOW\n");
+ #endif
+
+ fmin = range.LowerBound * m;
+ }
+ else
+ fmin = 0.0;
+
+ if(desc & LADSPA_HINT_BOUNDED_ABOVE)
+ {
+ #ifdef PLUGIN_DEBUGIN
+ printf("midi2LadspaValue: has LADSPA_HINT_BOUNDED_ABOVE\n");
+ #endif
+
+ fmax = range.UpperBound * m;
+ }
+ else
+ fmax = 1.0;
+
+ frng = fmax - fmin;
+ imin = lrint(fmin);
+ //imax = lrint(fmax);
+ //irng = imax - imin;
+
+ if(desc & LADSPA_HINT_TOGGLED)
+ {
+ #ifdef PLUGIN_DEBUGIN
+ printf("midi2LadspaValue: has LADSPA_HINT_TOGGLED\n");
+ #endif
+
+ if(val > 0)
+ return fmax;
+ else
+ return fmin;
+ }
+
+ int ctlmn = 0;
+ int ctlmx = 127;
+
+ #ifdef PLUGIN_DEBUGIN
+ printf("midi2LadspaValue: port min:%f max:%f \n", fmin, fmax);
+ #endif
+
+ //bool isneg = (fmin < 0.0);
+ bool isneg = (imin < 0);
+ int bval = val;
+ int cval = val;
+ switch(t)
+ {
+ case MidiController::RPN:
+ case MidiController::NRPN:
+ case MidiController::Controller7:
+ if(isneg)
+ {
+ ctlmn = -64;
+ ctlmx = 63;
+ bval -= 64;
+ cval -= 64;
+ }
+ else
+ {
+ ctlmn = 0;
+ ctlmx = 127;
+ cval -= 64;
+ }
+ break;
+ case MidiController::Controller14:
+ case MidiController::RPN14:
+ case MidiController::NRPN14:
+ if(isneg)
+ {
+ ctlmn = -8192;
+ ctlmx = 8191;
+ bval -= 8192;
+ cval -= 8192;
+ }
+ else
+ {
+ ctlmn = 0;
+ ctlmx = 16383;
+ cval -= 8192;
+ }
+ break;
+ case MidiController::Program:
+ ctlmn = 0;
+ ctlmx = 0xffffff;
+ break;
+ case MidiController::Pitch:
+ ctlmn = -8192;
+ ctlmx = 8191;
+ break;
+ case MidiController::Velo: // cannot happen
+ default:
+ break;
+ }
+ int ctlrng = ctlmx - ctlmn;
+ float fctlrng = float(ctlmx - ctlmn);
+
+ // Is it an integer control?
+ if(desc & LADSPA_HINT_INTEGER)
+ {
+ float ret = float(cval);
+ if(ret < fmin)
+ ret = fmin;
+ if(ret > fmax)
+ ret = fmax;
+ #ifdef PLUGIN_DEBUGIN
+ printf("midi2LadspaValue: has LADSPA_HINT_INTEGER returning:%f\n", ret);
+ #endif
+
+ return ret;
+ }
+
+ // Avoid divide-by-zero error below.
+ if(ctlrng == 0)
+ return 0.0;
+
+ // It's a floating point control, just use wide open maximum range.
+ float normval = float(bval) / fctlrng;
+ //float fbias = (fmin + fmax) / 2.0;
+ //float normfbias = fbias / frng;
+ //float ret = (normdef + normbias) * fctlrng;
+ //float normdef = fdef / frng;
+
+ float ret = normval * frng + fmin;
+
+ #ifdef PLUGIN_DEBUGIN
+ printf("midi2LadspaValue: float returning:%f\n", ret);
+ #endif
+
+ return ret;
+}
+
+
+// Works but not needed.
+/*
+//---------------------------------------------------------
+// ladspa2MidiController
+//---------------------------------------------------------
+
+MidiController* ladspa2MidiController(const LADSPA_Descriptor* plugin, int port, int ctlnum)
+{
+ int min, max, def;
+
+ if(!ladspa2MidiControlValues(plugin, port, ctlnum, &min, &max, &def))
+ return 0;
+
+ MidiController* mc = new MidiController(QString(plugin->PortNames[port]), ctlnum, min, max, def);
+
+ return mc;
+}
+*/
+
+//----------------------------------------------------------------------------------
+// defaultValue
+// If no default ladspa value found, still sets *def to 1.0, but returns false.
+//---------------------------------------------------------------------------------
+
+//float ladspaDefaultValue(const LADSPA_Descriptor* plugin, int k)
+bool ladspaDefaultValue(const LADSPA_Descriptor* plugin, int port, float* val)
+{
+ LADSPA_PortRangeHint range = plugin->PortRangeHints[port];
+ LADSPA_PortRangeHintDescriptor rh = range.HintDescriptor;
+// bool isLog = LADSPA_IS_HINT_LOGARITHMIC(rh);
+ //double val = 1.0;
+ float m = (rh & LADSPA_HINT_SAMPLE_RATE) ? float(sampleRate) : 1.0f;
+ if (LADSPA_IS_HINT_DEFAULT_MINIMUM(rh))
+ {
+ *val = range.LowerBound * m;
+ return true;
+ }
+ else if (LADSPA_IS_HINT_DEFAULT_LOW(rh))
+ {
+ if (LADSPA_IS_HINT_LOGARITHMIC(rh))
+ {
+ *val = exp(fast_log10(range.LowerBound * m) * .75 +
+ log(range.UpperBound * m) * .25);
+ return true;
+ }
+ else
+ {
+ *val = range.LowerBound*.75*m + range.UpperBound*.25*m;
+ return true;
+ }
+ }
+ else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(rh))
+ {
+ if (LADSPA_IS_HINT_LOGARITHMIC(rh))
+ {
+ *val = exp(log(range.LowerBound * m) * .5 +
+ log10(range.UpperBound * m) * .5);
+ return true;
+ }
+ else
+ {
+ *val = range.LowerBound*.5*m + range.UpperBound*.5*m;
+ return true;
+ }
+ }
+ else if (LADSPA_IS_HINT_DEFAULT_HIGH(rh))
+ {
+ if (LADSPA_IS_HINT_LOGARITHMIC(rh))
+ {
+ *val = exp(log(range.LowerBound * m) * .25 +
+ log(range.UpperBound * m) * .75);
+ return true;
+ }
+ else
+ {
+ *val = range.LowerBound*.25*m + range.UpperBound*.75*m;
+ return true;
+ }
+ }
+ else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(rh))
+ {
+ *val = range.UpperBound*m;
+ return true;
+ }
+ else if (LADSPA_IS_HINT_DEFAULT_0(rh))
+ {
+ *val = 0.0;
+ return true;
+ }
+ else if (LADSPA_IS_HINT_DEFAULT_1(rh))
+ {
+ *val = 1.0;
+ return true;
+ }
+ else if (LADSPA_IS_HINT_DEFAULT_100(rh))
+ {
+ *val = 100.0;
+ return true;
+ }
+ else if (LADSPA_IS_HINT_DEFAULT_440(rh))
+ {
+ *val = 440.0;
+ return true;
+ }
+
+ // No default found. Set return value to 1.0, but return false.
+ *val = 1.0;
+ return false;
+}
+
+//---------------------------------------------------------
+// ladspaControlRange
+//---------------------------------------------------------
+
+void ladspaControlRange(const LADSPA_Descriptor* plugin, int i, float* min, float* max)
+ {
+ LADSPA_PortRangeHint range = plugin->PortRangeHints[i];
+ LADSPA_PortRangeHintDescriptor desc = range.HintDescriptor;
+ if (desc & LADSPA_HINT_TOGGLED) {
+ *min = 0.0;
+ *max = 1.0;
+ return;
+ }
+ float m = 1.0;
+ if (desc & LADSPA_HINT_SAMPLE_RATE)
+ m = float(sampleRate);
+
+ if (desc & LADSPA_HINT_BOUNDED_BELOW)
+ *min = range.LowerBound * m;
+ else
+ *min = 0.0;
+ if (desc & LADSPA_HINT_BOUNDED_ABOVE)
+ *max = range.UpperBound * m;
+ else
+ *max = 1.0;
+ }
+
+//---------------------------------------------------------
+// Plugin
+//---------------------------------------------------------
+
+Plugin::Plugin(QFileInfo* f, const LADSPA_Descriptor* d, bool isDssi)
+{
+ _isDssi = isDssi;
+ #ifdef DSSI_SUPPORT
+ dssi_descr = NULL;
+ #endif
+
+ fi = *f;
+ plugin = NULL;
+ ladspa = NULL;
+ _handle = 0;
+ _references = 0;
+ _instNo = 0;
+ _label = QString(d->Label);
+ _name = QString(d->Name);
+ _uniqueID = d->UniqueID;
+ _maker = QString(d->Maker);
+ _copyright = QString(d->Copyright);
+
+ _portCount = d->PortCount;
+ //_portDescriptors = 0;
+ //if(_portCount)
+ // _portDescriptors = new LADSPA_PortDescriptor[_portCount];
+
+
+ _inports = 0;
+ _outports = 0;
+ _controlInPorts = 0;
+ _controlOutPorts = 0;
+ for(unsigned long k = 0; k < _portCount; ++k)
+ {
+ LADSPA_PortDescriptor pd = d->PortDescriptors[k];
+ //_portDescriptors[k] = pd;
+ if(pd & LADSPA_PORT_AUDIO)
+ {
+ if(pd & LADSPA_PORT_INPUT)
+ ++_inports;
+ else
+ if(pd & LADSPA_PORT_OUTPUT)
+ ++_outports;
+ }
+ else
+ if(pd & LADSPA_PORT_CONTROL)
+ {
+ if(pd & LADSPA_PORT_INPUT)
+ ++_controlInPorts;
+ else
+ if(pd & LADSPA_PORT_OUTPUT)
+ ++_controlOutPorts;
+ }
+ }
+
+ _inPlaceCapable = !LADSPA_IS_INPLACE_BROKEN(d->Properties);
+
+ // By T356. Blacklist vst plugins in-place configurable for now. At one point they
+ // were working with in-place here, but not now, and RJ also reported they weren't working.
+ // Fixes problem with vst plugins not working or feeding back loudly.
+ // I can only think of two things that made them stop working:
+ // 1): I switched back from Jack-2 to Jack-1
+ // 2): I changed winecfg audio to use Jack instead of ALSA.
+ // Will test later...
+ // Possibly the first one because under Mandriva2007.1 (Jack-1), no matter how hard I tried,
+ // the same problem existed. It may have been when using Jack-2 with Mandriva2009 that they worked.
+ // Apparently the plugins are lying about their in-place capability.
+ // Quote:
+ /* Property LADSPA_PROPERTY_INPLACE_BROKEN indicates that the plugin
+ may cease to work correctly if the host elects to use the same data
+ location for both input and output (see connect_port()). This
+ should be avoided as enabling this flag makes it impossible for
+ hosts to use the plugin to process audio `in-place.' */
+ // Examination of all my ladspa and vst synths and effects plugins showed only one -
+ // EnsembleLite (EnsLite VST) has the flag set, but it is a vst synth and is not involved here!
+ // Yet many (all?) ladspa vst effect plugins exhibit this problem.
+ // Changed by Tim. p3.3.14
+ if ((_inports != _outports) || (fi.completeBaseName() == QString("dssi-vst") && !config.vstInPlace))
+ _inPlaceCapable = false;
+}
+
+Plugin::~Plugin()
+{
+ //if(_portDescriptors)
+ // delete[] _portDescriptors;
+}
+
+//---------------------------------------------------------
+// incReferences
+//---------------------------------------------------------
+
+int Plugin::incReferences(int val)
+{
+ #ifdef PLUGIN_DEBUGIN
+ fprintf(stderr, "Plugin::incReferences _references:%d val:%d\n", _references, val);
+ #endif
+
+ int newref = _references + val;
+
+ if(newref == 0)
+ {
+ _references = 0;
+ if(_handle)
+ {
+ #ifdef PLUGIN_DEBUGIN
+ fprintf(stderr, "Plugin::incReferences no more instances, closing library\n");
+ #endif
+
+ dlclose(_handle);
+ }
+
+ _handle = 0;
+ ladspa = NULL;
+ plugin = NULL;
+ rpIdx.clear();
+
+ #ifdef DSSI_SUPPORT
+ dssi_descr = NULL;
+ #endif
+
+ return 0;
+ }
+
+ //if(_references == 0)
+ if(_handle == 0)
+ {
+ //_references = 0;
+ _handle = dlopen(fi.filePath().toLatin1().constData(), RTLD_NOW);
+ //handle = dlopen(fi.absFilePath().toLatin1().constData(), RTLD_NOW);
+
+ if(_handle == 0)
+ {
+ fprintf(stderr, "Plugin::incReferences dlopen(%s) failed: %s\n",
+ fi.filePath().toLatin1().constData(), dlerror());
+ //fi.absFilePath().toLatin1().constData(), dlerror());
+ return 0;
+ }
+
+ #ifdef DSSI_SUPPORT
+ DSSI_Descriptor_Function dssi = (DSSI_Descriptor_Function)dlsym(_handle, "dssi_descriptor");
+ if(dssi)
+ {
+ const DSSI_Descriptor* descr;
+ for(int i = 0;; ++i)
+ {
+ descr = dssi(i);
+ if(descr == NULL)
+ break;
+
+ QString label(descr->LADSPA_Plugin->Label);
+ // Listing effect plugins only while excluding synths:
+ // Do exactly what dssi-vst.cpp does for listing ladspa plugins.
+ //if(label == _name &&
+ if(label == _label &&
+ !descr->run_synth &&
+ !descr->run_synth_adding &&
+ !descr->run_multiple_synths &&
+ !descr->run_multiple_synths_adding)
+ {
+ _isDssi = true;
+ ladspa = NULL;
+ dssi_descr = descr;
+ plugin = descr->LADSPA_Plugin;
+ break;
+ }
+ }
+ }
+ else
+ #endif // DSSI_SUPPORT
+ {
+ LADSPA_Descriptor_Function ladspadf = (LADSPA_Descriptor_Function)dlsym(_handle, "ladspa_descriptor");
+ if(ladspadf)
+ {
+ const LADSPA_Descriptor* descr;
+ for(int i = 0;; ++i)
+ {
+ descr = ladspadf(i);
+ if(descr == NULL)
+ break;
+
+ QString label(descr->Label);
+ //if(label == _name)
+ if(label == _label)
+ {
+ _isDssi = false;
+ ladspa = ladspadf;
+ plugin = descr;
+
+ #ifdef DSSI_SUPPORT
+ dssi_descr = NULL;
+ #endif
+
+ break;
+ }
+ }
+ }
+ }
+
+ if(plugin != NULL)
+ {
+ //_instNo = 0;
+ _name = QString(plugin->Name);
+ _uniqueID = plugin->UniqueID;
+ _maker = QString(plugin->Maker);
+ _copyright = QString(plugin->Copyright);
+
+ //if(_portDescriptors)
+ // delete[] _portDescriptors;
+ //_portDescriptors = 0;
+ _portCount = plugin->PortCount;
+ //if(_portCount)
+ // _portDescriptors = new LADSPA_PortDescriptor[_portCount];
+
+ _inports = 0;
+ _outports = 0;
+ _controlInPorts = 0;
+ _controlOutPorts = 0;
+ for(unsigned long k = 0; k < _portCount; ++k)
+ {
+ LADSPA_PortDescriptor pd = plugin->PortDescriptors[k];
+ //_portDescriptors[k] = pd;
+ if(pd & LADSPA_PORT_AUDIO)
+ {
+ if(pd & LADSPA_PORT_INPUT)
+ ++_inports;
+ else
+ if(pd & LADSPA_PORT_OUTPUT)
+ ++_outports;
+
+ rpIdx.push_back((unsigned long)-1);
+ }
+ else
+ if(pd & LADSPA_PORT_CONTROL)
+ {
+ if(pd & LADSPA_PORT_INPUT)
+ {
+ rpIdx.push_back(_controlInPorts);
+ ++_controlInPorts;
+ }
+ else
+ if(pd & LADSPA_PORT_OUTPUT)
+ {
+ rpIdx.push_back((unsigned long)-1);
+ ++_controlOutPorts;
+ }
+ }
+ }
+
+ _inPlaceCapable = !LADSPA_IS_INPLACE_BROKEN(plugin->Properties);
+
+ // Blacklist vst plugins in-place configurable for now.
+ if ((_inports != _outports) || (fi.completeBaseName() == QString("dssi-vst") && !config.vstInPlace))
+ _inPlaceCapable = false;
+ }
+ }
+
+ if(plugin == NULL)
+ {
+ dlclose(_handle);
+ _handle = 0;
+ _references = 0;
+ fprintf(stderr, "Plugin::incReferences Error: %s no plugin!\n", fi.filePath().toLatin1().constData());
+ return 0;
+ }
+
+ _references = newref;
+
+ //QString guiPath(info.dirPath() + "/" + info.baseName());
+ //QDir guiDir(guiPath, "*", QDir::Unsorted, QDir::Files);
+ //_hasGui = guiDir.exists();
+
+ return _references;
+}
+
+//---------------------------------------------------------
+// range
+//---------------------------------------------------------
+
+void Plugin::range(unsigned long i, float* min, float* max) const
+ {
+ LADSPA_PortRangeHint range = plugin->PortRangeHints[i];
+ LADSPA_PortRangeHintDescriptor desc = range.HintDescriptor;
+ if (desc & LADSPA_HINT_TOGGLED) {
+ *min = 0.0;
+ *max = 1.0;
+ return;
+ }
+ float m = 1.0;
+ if (desc & LADSPA_HINT_SAMPLE_RATE)
+ m = float(sampleRate);
+
+ if (desc & LADSPA_HINT_BOUNDED_BELOW)
+ *min = range.LowerBound * m;
+ else
+ *min = 0.0;
+ if (desc & LADSPA_HINT_BOUNDED_ABOVE)
+ *max = range.UpperBound * m;
+ else
+ *max = 1.0;
+ }
+
+//---------------------------------------------------------
+// defaultValue
+//---------------------------------------------------------
+
+double Plugin::defaultValue(unsigned long port) const
+{
+ if(port >= plugin->PortCount)
+ return 0.0;
+
+ LADSPA_PortRangeHint range = plugin->PortRangeHints[port];
+ LADSPA_PortRangeHintDescriptor rh = range.HintDescriptor;
+ double val = 1.0;
+ if (LADSPA_IS_HINT_DEFAULT_MINIMUM(rh))
+ val = range.LowerBound;
+ else if (LADSPA_IS_HINT_DEFAULT_LOW(rh))
+ if (LADSPA_IS_HINT_LOGARITHMIC(range.HintDescriptor))
+ val = exp(fast_log10(range.LowerBound) * .75 +
+ log(range.UpperBound) * .25);
+ else
+ val = range.LowerBound*.75 + range.UpperBound*.25;
+ else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(rh))
+ if (LADSPA_IS_HINT_LOGARITHMIC(range.HintDescriptor))
+ val = exp(log(range.LowerBound) * .5 +
+ log(range.UpperBound) * .5);
+ else
+ val = range.LowerBound*.5 + range.UpperBound*.5;
+ else if (LADSPA_IS_HINT_DEFAULT_HIGH(rh))
+ if (LADSPA_IS_HINT_LOGARITHMIC(range.HintDescriptor))
+ val = exp(log(range.LowerBound) * .25 +
+ log(range.UpperBound) * .75);
+ else
+ val = range.LowerBound*.25 + range.UpperBound*.75;
+ else if (LADSPA_IS_HINT_DEFAULT_MAXIMUM(rh))
+ val = range.UpperBound;
+ else if (LADSPA_IS_HINT_DEFAULT_0(rh))
+ val = 0.0;
+ else if (LADSPA_IS_HINT_DEFAULT_1(rh))
+ val = 1.0;
+ else if (LADSPA_IS_HINT_DEFAULT_100(rh))
+ val = 100.0;
+ else if (LADSPA_IS_HINT_DEFAULT_440(rh))
+ val = 440.0;
+
+ return val;
+}
+
+//---------------------------------------------------------
+// loadPluginLib
+//---------------------------------------------------------
+
+static void loadPluginLib(QFileInfo* fi)
+{
+ void* handle = dlopen(fi->filePath().toAscii().constData(), RTLD_NOW);
+ if (handle == 0) {
+ fprintf(stderr, "dlopen(%s) failed: %s\n",
+ fi->filePath().toAscii().constData(), dlerror());
+ return;
+ }
+
+ #ifdef DSSI_SUPPORT
+ DSSI_Descriptor_Function dssi = (DSSI_Descriptor_Function)dlsym(handle, "dssi_descriptor");
+ if(dssi)
+ {
+ const DSSI_Descriptor* descr;
+ for (int i = 0;; ++i)
+ {
+ descr = dssi(i);
+ if (descr == 0)
+ break;
+
+ // Listing effect plugins only while excluding synths:
+ // Do exactly what dssi-vst.cpp does for listing ladspa plugins.
+ if(!descr->run_synth &&
+ !descr->run_synth_adding &&
+ !descr->run_multiple_synths &&
+ !descr->run_multiple_synths_adding)
+ {
+ // Make sure it doesn't already exist.
+ if(plugins.find(fi->completeBaseName(), QString(descr->LADSPA_Plugin->Label)) != 0)
+ continue;
+
+ #ifdef PLUGIN_DEBUGIN
+ fprintf(stderr, "loadPluginLib: dssi effect name:%s inPlaceBroken:%d\n", descr->LADSPA_Plugin->Name, LADSPA_IS_INPLACE_BROKEN(descr->LADSPA_Plugin->Properties));
+ #endif
+
+ //LADSPA_Properties properties = descr->LADSPA_Plugin->Properties;
+ //bool inPlaceBroken = LADSPA_IS_INPLACE_BROKEN(properties);
+ //plugins.add(fi, descr, !inPlaceBroken);
+ if(debugMsg)
+ fprintf(stderr, "loadPluginLib: adding dssi effect plugin:%s name:%s label:%s\n", fi->filePath().toLatin1().constData(), descr->LADSPA_Plugin->Name, descr->LADSPA_Plugin->Label);
+
+ plugins.add(fi, descr->LADSPA_Plugin, true);
+ }
+ }
+ }
+ else
+ #endif
+ {
+ LADSPA_Descriptor_Function ladspa = (LADSPA_Descriptor_Function)dlsym(handle, "ladspa_descriptor");
+ if(!ladspa)
+ {
+ const char *txt = dlerror();
+ if(txt)
+ {
+ fprintf(stderr,
+ "Unable to find ladspa_descriptor() function in plugin "
+ "library file \"%s\": %s.\n"
+ "Are you sure this is a LADSPA plugin file?\n",
+ fi->filePath().toAscii().constData(),
+ txt);
+ }
+ dlclose(handle);
+ return;
+ }
+
+ const LADSPA_Descriptor* descr;
+ for (int i = 0;; ++i)
+ {
+ descr = ladspa(i);
+ if (descr == NULL)
+ break;
+
+ // Make sure it doesn't already exist.
+ if(plugins.find(fi->completeBaseName(), QString(descr->Label)) != 0)
+ continue;
+
+ #ifdef PLUGIN_DEBUGIN
+ fprintf(stderr, "loadPluginLib: ladspa effect name:%s inPlaceBroken:%d\n", descr->Name, LADSPA_IS_INPLACE_BROKEN(descr->Properties));
+ #endif
+
+ //LADSPA_Properties properties = descr->Properties;
+ //bool inPlaceBroken = LADSPA_IS_INPLACE_BROKEN(properties);
+ //plugins.add(fi, ladspa, descr, !inPlaceBroken);
+ if(debugMsg)
+ fprintf(stderr, "loadPluginLib: adding ladspa plugin:%s name:%s label:%s\n", fi->filePath().toLatin1().constData(), descr->Name, descr->Label);
+ plugins.add(fi, descr);
+ }
+ }
+
+ dlclose(handle);
+}
+
+//---------------------------------------------------------
+// loadPluginDir
+//---------------------------------------------------------
+
+static void loadPluginDir(const QString& s)
+ {
+ if (debugMsg)
+ printf("scan ladspa plugin dir <%s>\n", s.toLatin1().constData());
+ QDir pluginDir(s, QString("*.so")); // ddskrjo
+ if (pluginDir.exists()) {
+ QFileInfoList list = pluginDir.entryInfoList();
+ QFileInfoList::iterator it=list.begin();
+ while(it != list.end()) {
+ loadPluginLib(&*it);
+ ++it;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// initPlugins
+//---------------------------------------------------------
+
+void initPlugins()
+ {
+ loadPluginDir(museGlobalLib + QString("/plugins"));
+
+ const char* p = 0;
+
+ // Take care of DSSI plugins first...
+ #ifdef DSSI_SUPPORT
+ const char* dssiPath = getenv("DSSI_PATH");
+ if (dssiPath == 0)
+ dssiPath = "/usr/local/lib64/dssi:/usr/lib64/dssi:/usr/local/lib/dssi:/usr/lib/dssi";
+ p = dssiPath;
+ while (*p != '\0') {
+ const char* pe = p;
+ while (*pe != ':' && *pe != '\0')
+ pe++;
+
+ int n = pe - p;
+ if (n) {
+ char* buffer = new char[n + 1];
+ strncpy(buffer, p, n);
+ buffer[n] = '\0';
+ loadPluginDir(QString(buffer));
+ delete[] buffer;
+ }
+ p = pe;
+ if (*p == ':')
+ p++;
+ }
+ #endif
+
+ // Now do LADSPA plugins...
+ const char* ladspaPath = getenv("LADSPA_PATH");
+ if (ladspaPath == 0)
+ ladspaPath = "/usr/local/lib64/ladspa:/usr/lib64/ladspa:/usr/local/lib/ladspa:/usr/lib/ladspa";
+ p = ladspaPath;
+
+ if(debugMsg)
+ fprintf(stderr, "loadPluginDir: ladspa path:%s\n", ladspaPath);
+
+ while (*p != '\0') {
+ const char* pe = p;
+ while (*pe != ':' && *pe != '\0')
+ pe++;
+
+ int n = pe - p;
+ if (n) {
+ char* buffer = new char[n + 1];
+ strncpy(buffer, p, n);
+ buffer[n] = '\0';
+ if(debugMsg)
+ fprintf(stderr, "loadPluginDir: loading ladspa dir:%s\n", buffer);
+
+ loadPluginDir(QString(buffer));
+ delete[] buffer;
+ }
+ p = pe;
+ if (*p == ':')
+ p++;
+ }
+ }
+
+//---------------------------------------------------------
+// find
+//---------------------------------------------------------
+
+Plugin* PluginList::find(const QString& file, const QString& name)
+ {
+ for (iPlugin i = begin(); i != end(); ++i) {
+ if ((file == i->lib()) && (name == i->label()))
+ return &*i;
+ }
+ //printf("Plugin <%s> not found\n", name.ascii());
+ return 0;
+ }
+
+//---------------------------------------------------------
+// Pipeline
+//---------------------------------------------------------
+
+Pipeline::Pipeline()
+ : std::vector<PluginI*>()
+ {
+ // Added by Tim. p3.3.15
+ for (int i = 0; i < MAX_CHANNELS; ++i)
+ posix_memalign((void**)(buffer + i), 16, sizeof(float) * segmentSize);
+
+ for (int i = 0; i < PipelineDepth; ++i)
+ push_back(0);
+ }
+
+//---------------------------------------------------------
+// ~Pipeline
+//---------------------------------------------------------
+
+Pipeline::~Pipeline()
+ {
+ removeAll();
+ for (int i = 0; i < MAX_CHANNELS; ++i)
+ ::free(buffer[i]);
+ }
+
+//---------------------------------------------------------
+// setChannels
+//---------------------------------------------------------
+
+void Pipeline::setChannels(int n)
+ {
+ for (int i = 0; i < PipelineDepth; ++i)
+ if ((*this)[i])
+ (*this)[i]->setChannels(n);
+ }
+
+//---------------------------------------------------------
+// insert
+// give ownership of object plugin to Pipeline
+//---------------------------------------------------------
+
+void Pipeline::insert(PluginI* plugin, int index)
+ {
+ remove(index);
+ (*this)[index] = plugin;
+ }
+
+//---------------------------------------------------------
+// remove
+//---------------------------------------------------------
+
+void Pipeline::remove(int index)
+ {
+ PluginI* plugin = (*this)[index];
+ if (plugin)
+ delete plugin;
+ (*this)[index] = 0;
+ }
+
+//---------------------------------------------------------
+// removeAll
+//---------------------------------------------------------
+
+void Pipeline::removeAll()
+ {
+ for (int i = 0; i < PipelineDepth; ++i)
+ remove(i);
+ }
+
+//---------------------------------------------------------
+// isOn
+//---------------------------------------------------------
+
+bool Pipeline::isOn(int idx) const
+ {
+ PluginI* p = (*this)[idx];
+ if (p)
+ return p->on();
+ return false;
+ }
+
+//---------------------------------------------------------
+// setOn
+//---------------------------------------------------------
+
+void Pipeline::setOn(int idx, bool flag)
+ {
+ PluginI* p = (*this)[idx];
+ if (p) {
+ p->setOn(flag);
+ if (p->gui())
+ p->gui()->setOn(flag);
+ }
+ }
+
+//---------------------------------------------------------
+// label
+//---------------------------------------------------------
+
+QString Pipeline::label(int idx) const
+ {
+ PluginI* p = (*this)[idx];
+ if (p)
+ return p->label();
+ return QString("");
+ }
+
+//---------------------------------------------------------
+// name
+//---------------------------------------------------------
+
+QString Pipeline::name(int idx) const
+ {
+ PluginI* p = (*this)[idx];
+ if (p)
+ return p->name();
+ return QString("empty");
+ }
+
+//---------------------------------------------------------
+// empty
+//---------------------------------------------------------
+
+bool Pipeline::empty(int idx) const
+ {
+ PluginI* p = (*this)[idx];
+ return p == 0;
+ }
+
+//---------------------------------------------------------
+// move
+//---------------------------------------------------------
+
+void Pipeline::move(int idx, bool up)
+{
+ PluginI* p1 = (*this)[idx];
+ if (up)
+ {
+ (*this)[idx] = (*this)[idx-1];
+
+ if((*this)[idx])
+ (*this)[idx]->setID(idx);
+
+ (*this)[idx-1] = p1;
+
+ if(p1)
+ {
+ p1->setID(idx - 1);
+ if(p1->track())
+ audio->msgSwapControllerIDX(p1->track(), idx, idx - 1);
+ }
+ }
+ else
+ {
+ (*this)[idx] = (*this)[idx+1];
+
+ if((*this)[idx])
+ (*this)[idx]->setID(idx);
+
+ (*this)[idx+1] = p1;
+
+ if(p1)
+ {
+ p1->setID(idx + 1);
+ if(p1->track())
+ audio->msgSwapControllerIDX(p1->track(), idx, idx + 1);
+ }
+ }
+}
+
+//---------------------------------------------------------
+// isDssiPlugin
+//---------------------------------------------------------
+
+bool Pipeline::isDssiPlugin(int idx) const
+{
+ PluginI* p = (*this)[idx];
+ if(p)
+ return p->isDssiPlugin();
+
+ return false;
+}
+
+//---------------------------------------------------------
+// showGui
+//---------------------------------------------------------
+
+void Pipeline::showGui(int idx, bool flag)
+ {
+ PluginI* p = (*this)[idx];
+ if (p)
+ p->showGui(flag);
+ }
+
+//---------------------------------------------------------
+// showNativeGui
+//---------------------------------------------------------
+
+void Pipeline::showNativeGui(int idx, bool flag)
+ {
+ #ifdef OSC_SUPPORT
+ PluginI* p = (*this)[idx];
+ if (p)
+ p->oscIF().oscShowGui(flag);
+ #endif
+ }
+
+//---------------------------------------------------------
+// deleteGui
+//---------------------------------------------------------
+
+void Pipeline::deleteGui(int idx)
+{
+ if(idx >= PipelineDepth)
+ return;
+ PluginI* p = (*this)[idx];
+ if(p)
+ p->deleteGui();
+}
+
+//---------------------------------------------------------
+// deleteAllGuis
+//---------------------------------------------------------
+
+void Pipeline::deleteAllGuis()
+{
+ for(int i = 0; i < PipelineDepth; i++)
+ deleteGui(i);
+}
+
+//---------------------------------------------------------
+// guiVisible
+//---------------------------------------------------------
+
+bool Pipeline::guiVisible(int idx)
+ {
+ PluginI* p = (*this)[idx];
+ if (p)
+ return p->guiVisible();
+ return false;
+ }
+
+//---------------------------------------------------------
+// nativeGuiVisible
+//---------------------------------------------------------
+
+bool Pipeline::nativeGuiVisible(int idx)
+ {
+ PluginI* p = (*this)[idx];
+ if (p)
+ return p->nativeGuiVisible();
+ return false;
+ }
+
+//---------------------------------------------------------
+// apply
+//---------------------------------------------------------
+
+void Pipeline::apply(int ports, unsigned long nframes, float** buffer1)
+{
+ // prepare a second set of buffers in case a plugin is not
+ // capable of inPlace processing
+
+ // Removed by Tim. p3.3.15
+ //float* buffer2[ports];
+ //float data[nframes * ports];
+ //for (int i = 0; i < ports; ++i)
+ // buffer2[i] = data + i * nframes;
+
+ // p3.3.41
+ //fprintf(stderr, "Pipeline::apply data: nframes:%ld %e %e %e %e\n", nframes, buffer1[0][0], buffer1[0][1], buffer1[0][2], buffer1[0][3]);
+
+ bool swap = false;
+
+ for (iPluginI ip = begin(); ip != end(); ++ip) {
+ PluginI* p = *ip;
+ if (p && p->on()) {
+ if (p->inPlaceCapable())
+ {
+ if (swap)
+ //p->connect(ports, buffer2, buffer2);
+ p->connect(ports, buffer, buffer);
+ else
+ p->connect(ports, buffer1, buffer1);
+ }
+ else
+ {
+ if (swap)
+ //p->connect(ports, buffer2, buffer1);
+ p->connect(ports, buffer, buffer1);
+ else
+ //p->connect(ports, buffer1, buffer2);
+ p->connect(ports, buffer1, buffer);
+ swap = !swap;
+ }
+ p->apply(nframes);
+ }
+ }
+ if (swap)
+ {
+ for (int i = 0; i < ports; ++i)
+ //memcpy(buffer1[i], buffer2[i], sizeof(float) * nframes);
+ //memcpy(buffer1[i], buffer[i], sizeof(float) * nframes);
+ AL::dsp->cpy(buffer1[i], buffer[i], nframes);
+ }
+
+ // p3.3.41
+ //fprintf(stderr, "Pipeline::apply after data: nframes:%ld %e %e %e %e\n", nframes, buffer1[0][0], buffer1[0][1], buffer1[0][2], buffer1[0][3]);
+
+}
+
+//---------------------------------------------------------
+// PluginI
+//---------------------------------------------------------
+
+void PluginI::init()
+ {
+ _plugin = 0;
+ instances = 0;
+ handle = 0;
+ controls = 0;
+ controlsOut = 0;
+ controlPorts = 0;
+ controlOutPorts = 0;
+ _gui = 0;
+ _on = true;
+ initControlValues = false;
+ _showNativeGuiPending = false;
+ }
+
+PluginI::PluginI()
+ {
+ _id = -1;
+ _track = 0;
+
+ init();
+ }
+
+//---------------------------------------------------------
+// PluginI
+//---------------------------------------------------------
+
+PluginI::~PluginI()
+ {
+ if (_plugin) {
+ deactivate();
+ _plugin->incReferences(-1);
+ }
+ if (_gui)
+ delete _gui;
+ if (controlsOut)
+ delete[] controlsOut;
+ if (controls)
+ delete[] controls;
+ if (handle)
+ delete[] handle;
+ }
+
+//---------------------------------------------------------
+// setID
+//---------------------------------------------------------
+
+void PluginI::setID(int i)
+{
+ _id = i;
+}
+
+//---------------------------------------------------------
+// updateControllers
+//---------------------------------------------------------
+
+void PluginI::updateControllers()
+{
+ if(!_track)
+ return;
+
+ for(int i = 0; i < controlPorts; ++i)
+ //audio->msgSetPluginCtrlVal(this, genACnum(_id, i), controls[i].val);
+ // p3.3.43
+ audio->msgSetPluginCtrlVal(_track, genACnum(_id, i), controls[i].val);
+}
+
+//---------------------------------------------------------
+// valueType
+//---------------------------------------------------------
+
+CtrlValueType PluginI::valueType() const
+ {
+ return VAL_LINEAR;
+ }
+
+//---------------------------------------------------------
+// setChannel
+//---------------------------------------------------------
+
+void PluginI::setChannels(int c)
+{
+ // p3.3.41 Removed
+ //if (channel == c)
+ // return;
+
+ // p3.3.41
+ channel = c;
+
+ //int ni = c / _plugin->outports();
+ //if (ni == 0)
+ // ni = 1;
+ // p3.3.41 Some plugins have zero out ports, causing exception with the above line.
+ // Also, pick the least number of ins or outs, and base the number of instances on that.
+ unsigned long ins = _plugin->inports();
+ unsigned long outs = _plugin->outports();
+ /*
+ unsigned long minports = ~0ul;
+ if(outs && outs < minports)
+ minports = outs;
+ if(ins && ins < minports)
+ minports = ins;
+ if(minports == ~0ul)
+ minports = 1;
+ int ni = c / minports;
+ */
+ int ni = 1;
+ if(outs)
+ ni = c / outs;
+ else
+ if(ins)
+ ni = c / ins;
+
+ if(ni < 1)
+ ni = 1;
+
+ if (ni == instances)
+ return;
+
+ // p3.3.41 Moved above.
+ //channel = c;
+
+ // remove old instances:
+ deactivate();
+ delete[] handle;
+ instances = ni;
+ handle = new LADSPA_Handle[instances];
+ for (int i = 0; i < instances; ++i) {
+ handle[i] = _plugin->instantiate();
+ if (handle[i] == NULL) {
+ printf("cannot instantiate instance %d\n", i);
+ return;
+ }
+ }
+
+ int curPort = 0;
+ int curOutPort = 0;
+ unsigned long ports = _plugin->ports();
+ for (unsigned long k = 0; k < ports; ++k)
+ {
+ LADSPA_PortDescriptor pd = _plugin->portd(k);
+ if (pd & LADSPA_PORT_CONTROL)
+ {
+ if(pd & LADSPA_PORT_INPUT)
+ {
+ for (int i = 0; i < instances; ++i)
+ _plugin->connectPort(handle[i], k, &controls[curPort].val);
+ controls[curPort].idx = k;
+ ++curPort;
+ }
+ else
+ if(pd & LADSPA_PORT_OUTPUT)
+ {
+ for (int i = 0; i < instances; ++i)
+ _plugin->connectPort(handle[i], k, &controlsOut[curOutPort].val);
+ controlsOut[curOutPort].idx = k;
+ ++curOutPort;
+ }
+ }
+ }
+
+ activate();
+}
+
+//---------------------------------------------------------
+// defaultValue
+//---------------------------------------------------------
+
+double PluginI::defaultValue(unsigned int param) const
+{
+//#warning controlPorts should really be unsigned
+ if(param >= (unsigned)controlPorts)
+ return 0.0;
+
+ return _plugin->defaultValue(controls[param].idx);
+}
+
+LADSPA_Handle Plugin::instantiate()
+{
+ LADSPA_Handle h = plugin->instantiate(plugin, sampleRate);
+ if(h == NULL)
+ {
+ fprintf(stderr, "Plugin::instantiate() Error: plugin:%s instantiate failed!\n", plugin->Label);
+ return NULL;
+ }
+
+ //QString guiPath(info.dirPath() + "/" + info.baseName());
+ //QDir guiDir(guiPath, "*", QDir::Unsorted, QDir::Files);
+ //_hasGui = guiDir.exists();
+
+ return h;
+}
+
+//---------------------------------------------------------
+// initPluginInstance
+// return true on error
+//---------------------------------------------------------
+
+bool PluginI::initPluginInstance(Plugin* plug, int c)
+ {
+ channel = c;
+ if(plug == 0)
+ {
+ printf("initPluginInstance: zero plugin\n");
+ return true;
+ }
+ _plugin = plug;
+
+ _plugin->incReferences(1);
+
+ #ifdef OSC_SUPPORT
+ _oscif.oscSetPluginI(this);
+ #endif
+
+ QString inst("-" + QString::number(_plugin->instNo()));
+ _name = _plugin->name() + inst;
+ _label = _plugin->label() + inst;
+
+ //instances = channel/plug->outports();
+ // p3.3.41 Some plugins have zero out ports, causing exception with the above line.
+ // Also, pick the least number of ins or outs, and base the number of instances on that.
+ unsigned long ins = plug->inports();
+ unsigned long outs = plug->outports();
+ /*
+ unsigned long minports = ~0ul;
+ if(outs && outs < minports)
+ minports = outs;
+ if(ins && ins < minports)
+ minports = ins;
+ if(minports == ~0ul)
+ minports = 1;
+ instances = channel / minports;
+ if(instances < 1)
+ instances = 1;
+ */
+ if(outs)
+ {
+ instances = channel / outs;
+ if(instances < 1)
+ instances = 1;
+ }
+ else
+ if(ins)
+ {
+ instances = channel / ins;
+ if(instances < 1)
+ instances = 1;
+ }
+ else
+ instances = 1;
+
+ handle = new LADSPA_Handle[instances];
+ for(int i = 0; i < instances; ++i)
+ {
+ #ifdef PLUGIN_DEBUGIN
+ fprintf(stderr, "PluginI::initPluginInstance instance:%d\n", i);
+ #endif
+
+ handle[i] = _plugin->instantiate();
+ //if (handle[i] == 0)
+ if(handle[i] == NULL)
+ return true;
+ }
+
+ unsigned long ports = _plugin->ports();
+
+ controlPorts = 0;
+ controlOutPorts = 0;
+
+ for(unsigned long k = 0; k < ports; ++k)
+ {
+ LADSPA_PortDescriptor pd = _plugin->portd(k);
+ if(pd & LADSPA_PORT_CONTROL)
+ {
+ if(pd & LADSPA_PORT_INPUT)
+ ++controlPorts;
+ else
+ if(pd & LADSPA_PORT_OUTPUT)
+ ++controlOutPorts;
+ }
+ }
+
+ controls = new Port[controlPorts];
+ controlsOut = new Port[controlOutPorts];
+
+ int i = 0;
+ int ii = 0;
+ for(unsigned long k = 0; k < ports; ++k)
+ {
+ LADSPA_PortDescriptor pd = _plugin->portd(k);
+ if(pd & LADSPA_PORT_CONTROL)
+ {
+ if(pd & LADSPA_PORT_INPUT)
+ {
+ double val = _plugin->defaultValue(k);
+ controls[i].val = val;
+ controls[i].tmpVal = val;
+ controls[i].enCtrl = true;
+ controls[i].en2Ctrl = true;
+ ++i;
+ }
+ else
+ if(pd & LADSPA_PORT_OUTPUT)
+ {
+ //double val = _plugin->defaultValue(k);
+ controlsOut[ii].val = 0.0;
+ controlsOut[ii].tmpVal = 0.0;
+ controlsOut[ii].enCtrl = false;
+ controlsOut[ii].en2Ctrl = false;
+ ++ii;
+ }
+ }
+ }
+ unsigned long curPort = 0;
+ unsigned long curOutPort = 0;
+ for(unsigned long k = 0; k < ports; ++k)
+ {
+ LADSPA_PortDescriptor pd = _plugin->portd(k);
+ if(pd & LADSPA_PORT_CONTROL)
+ {
+ if(pd & LADSPA_PORT_INPUT)
+ {
+ for(int i = 0; i < instances; ++i)
+ _plugin->connectPort(handle[i], k, &controls[curPort].val);
+ controls[curPort].idx = k;
+ ++curPort;
+ }
+ else
+ if(pd & LADSPA_PORT_OUTPUT)
+ {
+ for(int i = 0; i < instances; ++i)
+ _plugin->connectPort(handle[i], k, &controlsOut[curOutPort].val);
+ controlsOut[curOutPort].idx = k;
+ ++curOutPort;
+ }
+ }
+ }
+ activate();
+ return false;
+ }
+
+//---------------------------------------------------------
+// connect
+//---------------------------------------------------------
+
+void PluginI::connect(int ports, float** src, float** dst)
+ {
+ int port = 0;
+ for (int i = 0; i < instances; ++i) {
+ for (unsigned long k = 0; k < _plugin->ports(); ++k) {
+ if (isAudioIn(k)) {
+ _plugin->connectPort(handle[i], k, src[port]);
+ port = (port + 1) % ports;
+ }
+ }
+ }
+ port = 0;
+ for (int i = 0; i < instances; ++i) {
+ for (unsigned long k = 0; k < _plugin->ports(); ++k) {
+ if (isAudioOut(k)) {
+ _plugin->connectPort(handle[i], k, dst[port]);
+ port = (port + 1) % ports; // overwrite output?
+// ++port;
+// if (port >= ports) {
+// return;
+// }
+ }
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// deactivate
+//---------------------------------------------------------
+
+void PluginI::deactivate()
+ {
+ for (int i = 0; i < instances; ++i) {
+ _plugin->deactivate(handle[i]);
+ _plugin->cleanup(handle[i]);
+ }
+ }
+
+//---------------------------------------------------------
+// activate
+//---------------------------------------------------------
+
+void PluginI::activate()
+ {
+ for (int i = 0; i < instances; ++i)
+ _plugin->activate(handle[i]);
+ if (initControlValues) {
+ for (int i = 0; i < controlPorts; ++i) {
+ controls[i].val = controls[i].tmpVal;
+ }
+ }
+ else {
+ //
+ // get initial control values from plugin
+ //
+ for (int i = 0; i < controlPorts; ++i) {
+ controls[i].tmpVal = controls[i].val;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// setControl
+// set plugin instance controller value by name
+//---------------------------------------------------------
+
+bool PluginI::setControl(const QString& s, double val)
+ {
+ for (int i = 0; i < controlPorts; ++i) {
+ if (_plugin->portName(controls[i].idx) == s) {
+ controls[i].val = controls[i].tmpVal = val;
+ return false;
+ }
+ }
+ printf("PluginI:setControl(%s, %f) controller not found\n",
+ s.toLatin1().constData(), val);
+ return true;
+ }
+
+//---------------------------------------------------------
+// saveConfiguration
+//---------------------------------------------------------
+
+void PluginI::writeConfiguration(int level, Xml& xml)
+ {
+ xml.tag(level++, "plugin file=\"%s\" label=\"%s\" channel=\"%d\"",
+ //_plugin->lib().toLatin1().constData(), _plugin->label().toLatin1().constData(), instances * _plugin->inports());
+ // p3.3.41
+ //_plugin->lib().toLatin1().constData(), _plugin->label().toLatin1().constData(), channel);
+ Xml::xmlString(_plugin->lib()).toLatin1().constData(), Xml::xmlString(_plugin->label()).toLatin1().constData(), channel);
+
+ for (int i = 0; i < controlPorts; ++i) {
+ int idx = controls[i].idx;
+ QString s("control name=\"%1\" val=\"%2\" /");
+ //xml.tag(level, s.arg(_plugin->portName(idx)).arg(controls[i].tmpVal).toLatin1().constData());
+ xml.tag(level, s.arg(Xml::xmlString(_plugin->portName(idx)).toLatin1().constData()).arg(controls[i].tmpVal).toLatin1().constData());
+ }
+ if (_on == false)
+ xml.intTag(level, "on", _on);
+ if (guiVisible()) {
+ xml.intTag(level, "gui", 1);
+ xml.geometryTag(level, "geometry", _gui);
+ }
+ if (nativeGuiVisible()) {
+ xml.intTag(level, "nativegui", 1);
+ // TODO:
+ //xml.geometryTag(level, "nativegeometry", ?);
+ }
+ xml.tag(level--, "/plugin");
+ }
+
+//---------------------------------------------------------
+// loadControl
+//---------------------------------------------------------
+
+bool PluginI::loadControl(Xml& xml)
+ {
+ QString file;
+ QString label;
+ QString name("mops");
+ double val = 0.0;
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return true;
+ case Xml::TagStart:
+ xml.unknown("PluginI-Control");
+ break;
+ case Xml::Attribut:
+ if (tag == "name")
+ name = xml.s2();
+ else if (tag == "val")
+ val = xml.s2().toDouble();
+ break;
+ case Xml::TagEnd:
+ if (tag == "control") {
+ if (setControl(name, val)) {
+ return false;
+ }
+ initControlValues = true;
+ }
+ return true;
+ default:
+ break;
+ }
+ }
+ return true;
+ }
+
+//---------------------------------------------------------
+// readConfiguration
+// return true on error
+//---------------------------------------------------------
+
+bool PluginI::readConfiguration(Xml& xml, bool readPreset)
+ {
+ QString file;
+ QString label;
+ if (!readPreset)
+ //instances = 1;
+ // p3.3.41
+ channel = 1;
+
+ for (;;) {
+ Xml::Token token(xml.parse());
+ const QString& tag(xml.s1());
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return true;
+ case Xml::TagStart:
+ if (!readPreset && _plugin == 0) {
+ _plugin = plugins.find(file, label);
+
+ //if (_plugin && initPluginInstance(_plugin, instances)) {
+ // p3.3.41
+ if (_plugin && initPluginInstance(_plugin, channel)) {
+ _plugin = 0;
+ xml.parse1();
+ break;
+ }
+ }
+ if (tag == "control")
+ loadControl(xml);
+ else if (tag == "on") {
+ bool flag = xml.parseInt();
+ if (!readPreset)
+ _on = flag;
+ }
+ else if (tag == "gui") {
+ bool flag = xml.parseInt();
+ showGui(flag);
+ }
+ else if (tag == "nativegui") {
+ // We can't tell OSC to show the native plugin gui
+ // until the parent track is added to the lists.
+ // OSC needs to find the plugin in the track lists.
+ // Use this 'pending' flag so it gets done later.
+ _showNativeGuiPending = xml.parseInt();
+ }
+ else if (tag == "geometry") {
+ QRect r(readGeometry(xml, tag));
+ if (_gui) {
+ _gui->resize(r.size());
+ _gui->move(r.topLeft());
+ }
+ }
+ else
+ xml.unknown("PluginI");
+ break;
+ case Xml::Attribut:
+ if (tag == "file") {
+ QString s = xml.s2();
+ if (readPreset) {
+ if (s != plugin()->lib()) {
+ printf("Error: Wrong preset type %s. Type must be a %s\n",
+ s.toLatin1().constData(), plugin()->lib().toLatin1().constData());
+ return true;
+ }
+ }
+ else {
+ file = s;
+ }
+ }
+ else if (tag == "label") {
+ if (!readPreset)
+ label = xml.s2();
+ }
+ else if (tag == "channel") {
+ if (!readPreset)
+ //instances = xml.s2().toInt();
+ // p3.3.41
+ channel = xml.s2().toInt();
+ }
+ break;
+ case Xml::TagEnd:
+ if (tag == "plugin") {
+ if (!readPreset && _plugin == 0) {
+ _plugin = plugins.find(file, label);
+ if (_plugin == 0)
+ return true;
+
+ //if (initPluginInstance(_plugin, instances))
+ // p3.3.41
+ if (initPluginInstance(_plugin, channel))
+ return true;
+ }
+ if (_gui)
+ _gui->updateValues();
+ return false;
+ }
+ return true;
+ default:
+ break;
+ }
+ }
+ return true;
+ }
+
+//---------------------------------------------------------
+// showGui
+//---------------------------------------------------------
+
+void PluginI::showGui()
+ {
+ if (_plugin) {
+ if (_gui == 0)
+ makeGui();
+ if (_gui->isVisible())
+ _gui->hide();
+ else
+ _gui->show();
+ }
+ }
+
+void PluginI::showGui(bool flag)
+ {
+ if (_plugin) {
+ if (flag) {
+ if (_gui == 0)
+ makeGui();
+ _gui->show();
+ }
+ else {
+ if (_gui)
+ _gui->hide();
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// guiVisible
+//---------------------------------------------------------
+
+bool PluginI::guiVisible()
+ {
+ return _gui && _gui->isVisible();
+ }
+
+//---------------------------------------------------------
+// showNativeGui
+//---------------------------------------------------------
+
+void PluginI::showNativeGui()
+{
+ #ifdef OSC_SUPPORT
+ if (_plugin)
+ {
+ if (_oscif.oscGuiVisible())
+ _oscif.oscShowGui(false);
+ else
+ _oscif.oscShowGui(true);
+ }
+ #endif
+ _showNativeGuiPending = false;
+}
+
+void PluginI::showNativeGui(bool flag)
+{
+ #ifdef OSC_SUPPORT
+ if(_plugin)
+ {
+ _oscif.oscShowGui(flag);
+ }
+ #endif
+ _showNativeGuiPending = false;
+}
+
+//---------------------------------------------------------
+// nativeGuiVisible
+//---------------------------------------------------------
+
+bool PluginI::nativeGuiVisible()
+{
+ #ifdef OSC_SUPPORT
+ return _oscif.oscGuiVisible();
+ #endif
+
+ return false;
+}
+
+//---------------------------------------------------------
+// makeGui
+//---------------------------------------------------------
+
+void PluginI::makeGui()
+ {
+ _gui = new PluginGui(this);
+ }
+
+//---------------------------------------------------------
+// deleteGui
+//---------------------------------------------------------
+void PluginI::deleteGui()
+{
+ if(_gui)
+ {
+ delete _gui;
+ _gui = 0;
+ }
+}
+
+//---------------------------------------------------------
+// enableAllControllers
+//---------------------------------------------------------
+
+void PluginI::enableAllControllers(bool v)
+{
+ for(int i = 0; i < controlPorts; ++i)
+ controls[i].enCtrl = v;
+}
+
+//---------------------------------------------------------
+// enable2AllControllers
+//---------------------------------------------------------
+
+void PluginI::enable2AllControllers(bool v)
+{
+ for(int i = 0; i < controlPorts; ++i)
+ controls[i].en2Ctrl = v;
+}
+
+//---------------------------------------------------------
+// apply
+//---------------------------------------------------------
+
+void PluginI::apply(int n)
+{
+ // Process control value changes.
+ //if(automation && _track && _track->automationType() != AUTO_OFF && _id != -1)
+ //{
+ // for(int i = 0; i < controlPorts; ++i)
+ // {
+ // if( controls[i].enCtrl && controls[i].en2Ctrl )
+ // controls[i].tmpVal = _track->pluginCtrlVal(genACnum(_id, i));
+ // }
+ //}
+
+ unsigned long ctls = controlPorts;
+ for(unsigned long k = 0; k < ctls; ++k)
+ {
+ // First, update the temporary value if needed...
+
+ #ifdef OSC_SUPPORT
+ // Process OSC gui input control fifo events.
+ // It is probably more important that these are processed so that they take precedence over all other
+ // events because OSC + DSSI/DSSI-VST are fussy about receiving feedback via these control ports, from GUI changes.
+
+ OscControlFifo* cfifo = _oscif.oscFifo(k);
+ //if(!cfifo)
+ // continue;
+
+ // If there are 'events' in the fifo, get exactly one 'event' per control per process cycle...
+ //if(!cfifo->isEmpty())
+ if(cfifo && !cfifo->isEmpty())
+ {
+ OscControlValue v = cfifo->get();
+
+ #ifdef PLUGIN_DEBUGIN
+ fprintf(stderr, "PluginI::apply OscControlFifo event input control number:%ld value:%f\n", k, v.value);
+ #endif
+
+ // Set the ladspa control port value.
+ controls[k].tmpVal = v.value;
+
+ // Need to update the automation value, otherwise it overwrites later with the last automation value.
+ if(_track && _id != -1)
+ {
+ // Since we are now in the audio thread context, there's no need to send a message,
+ // just modify directly.
+ //audio->msgSetPluginCtrlVal(this, genACnum(_id, k), controls[k].val);
+ // p3.3.43
+ //audio->msgSetPluginCtrlVal(_track, genACnum(_id, k), controls[k].val);
+ _track->setPluginCtrlVal(genACnum(_id, k), v.value);
+
+ // Record automation.
+ // NO! Take care of this immediately in the OSC control handler, because we don't want
+ // the silly delay associated with processing the fifo one-at-a-time here.
+
+ //AutomationType at = _track->automationType();
+ // TODO: Taken from our native gui control handlers.
+ // This may need modification or may cause problems -
+ // we don't have the luxury of access to the dssi gui controls !
+ //if(at == AUTO_WRITE || (audio->isPlaying() && at == AUTO_TOUCH))
+ // enableController(k, false);
+ //_track->recordAutomation(id, v.value);
+ }
+ }
+ else
+ #endif // OSC_SUPPORT
+ {
+ // Process automation control value.
+ if(automation && _track && _track->automationType() != AUTO_OFF && _id != -1)
+ {
+ if(controls[k].enCtrl && controls[k].en2Ctrl )
+ controls[k].tmpVal = _track->pluginCtrlVal(genACnum(_id, k));
+ }
+ }
+
+ // Now update the actual value from the temporary value...
+ controls[k].val = controls[k].tmpVal;
+ }
+
+ //for (int i = 0; i < controlPorts; ++i)
+ // controls[i].val = controls[i].tmpVal;
+
+ for (int i = 0; i < instances; ++i)
+ {
+ // p3.3.41
+ //fprintf(stderr, "PluginI::apply handle %d\n", i);
+ _plugin->apply(handle[i], n);
+ }
+ }
+
+//---------------------------------------------------------
+// oscConfigure
+//---------------------------------------------------------
+
+#ifdef OSC_SUPPORT
+int Plugin::oscConfigure(LADSPA_Handle handle, const char* key, const char* value)
+ {
+ #ifdef PLUGIN_DEBUGIN
+ printf("Plugin::oscConfigure effect plugin label:%s key:%s value:%s\n", plugin->Label, key, value);
+ #endif
+
+ #ifdef DSSI_SUPPORT
+ if(!dssi_descr || !dssi_descr->configure)
+ return 0;
+
+ if (!strncmp(key, DSSI_RESERVED_CONFIGURE_PREFIX,
+ strlen(DSSI_RESERVED_CONFIGURE_PREFIX))) {
+ fprintf(stderr, "Plugin::oscConfigure OSC: UI for plugin '%s' attempted to use reserved configure key \"%s\", ignoring\n",
+ plugin->Label, key);
+
+ return 0;
+ }
+
+ char* message = dssi_descr->configure(handle, key, value);
+ if (message) {
+ printf("Plugin::oscConfigure on configure '%s' '%s', plugin '%s' returned error '%s'\n",
+ //key, value, synti->name().toAscii().data(), message);
+ key, value, plugin->Label, message);
+
+ free(message);
+ }
+
+ // also call back on UIs for plugins other than the one
+ // that requested this:
+ // if (n != instance->number && instances[n].uiTarget) {
+ // lo_send(instances[n].uiTarget,
+ // instances[n].ui_osc_configure_path, "ss", key, value);
+ // }
+
+ // configure invalidates bank and program information, so
+ // we should do this again now:
+ //queryPrograms();
+
+ #endif // DSSI_SUPPORT
+
+ return 0;
+}
+
+//---------------------------------------------------------
+// oscConfigure
+//---------------------------------------------------------
+
+int PluginI::oscConfigure(const char *key, const char *value)
+ {
+ if(!_plugin)
+ return 0;
+
+ // This is pretty much the simplest legal implementation of
+ // configure in a DSSI host.
+
+ // The host has the option to remember the set of (key,value)
+ // pairs associated with a particular instance, so that if it
+ // wants to restore the "same" instance on another occasion it can
+ // just call configure() on it for each of those pairs and so
+ // restore state without any input from a GUI. Any real-world GUI
+ // host will probably want to do that. This host doesn't have any
+ // concept of restoring an instance from one run to the next, so
+ // we don't bother remembering these at all.
+
+ //const char *key = (const char *)&argv[0]->s;
+ //const char *value = (const char *)&argv[1]->s;
+
+ #ifdef PLUGIN_DEBUGIN
+ printf("PluginI::oscConfigure effect plugin name:%s label:%s key:%s value:%s\n", _name.toLatin1().constData(), _label.toLatin1().constData(), key, value);
+ #endif
+
+ #ifdef DSSI_SUPPORT
+ // FIXME: Don't think this is right, should probably do as example shows below.
+ for(int i = 0; i < instances; ++i)
+ _plugin->oscConfigure(handle[i], key, value);
+
+ // also call back on UIs for plugins other than the one
+ // that requested this:
+ // if (n != instance->number && instances[n].uiTarget) {
+ // lo_send(instances[n].uiTarget,
+ // instances[n].ui_osc_configure_path, "ss", key, value);
+ // }
+
+ // configure invalidates bank and program information, so
+ // we should do this again now:
+ //queryPrograms();
+ #endif // DSSI_SUPPORT
+
+ return 0;
+}
+
+//---------------------------------------------------------
+// oscUpdate
+//---------------------------------------------------------
+
+int PluginI::oscUpdate()
+{
+ #ifdef DSSI_SUPPORT
+ // Send project directory.
+ _oscif.oscSendConfigure(DSSI_PROJECT_DIRECTORY_KEY, museProject.toLatin1().constData()); // song->projectPath()
+ #endif
+
+ /*
+ // Send current string configuration parameters.
+ StringParamMap& map = synti->stringParameters();
+ int i = 0;
+ for(ciStringParamMap r = map.begin(); r != map.end(); ++r)
+ {
+ _oscIF.oscSendConfigure(r->first.c_str(), r->second.c_str());
+ // Avoid overloading the GUI if there are lots and lots of params.
+ if((i+1) % 50 == 0)
+ usleep(300000);
+ ++i;
+ }
+
+ // Send current bank and program.
+ unsigned long bank, prog;
+ synti->currentProg(&prog, &bank, 0);
+ _oscIF.oscSendProgram(prog, bank);
+
+ // Send current control values.
+ unsigned long ports = synth->_controlInPorts;
+ for(unsigned long i = 0; i < ports; ++i)
+ {
+ unsigned long k = synth->pIdx(i);
+ _oscIF.oscSendControl(k, controls[i]);
+ // Avoid overloading the GUI if there are lots and lots of ports.
+ if((i+1) % 50 == 0)
+ usleep(300000);
+ }
+
+ */
+
+ return 0;
+}
+
+//---------------------------------------------------------
+// oscControl
+//---------------------------------------------------------
+
+int PluginI::oscControl(unsigned long port, float value)
+{
+ //int port = argv[0]->i;
+ //LADSPA_Data value = argv[1]->f;
+
+ #ifdef PLUGIN_DEBUGIN
+ printf("PluginI::oscControl received oscControl port:%ld val:%f\n", port, value);
+ #endif
+
+ //int controlPorts = synth->_controller;
+
+ //if(port >= controlPorts)
+ //if(port < 0 || port >= _plugin->rpIdx.size())
+ //{
+ //fprintf(stderr, "DssiSynthIF::oscControl: port number:%d is out of range of number of ports:%d\n", port, controlPorts);
+ // fprintf(stderr, "PluginI::oscControl: port number:%d is out of range of index list size:%d\n", port, _plugin->rpIdx.size());
+ // return 0;
+ //}
+
+ // Convert from DSSI port number to control input port index.
+ //unsigned long cport = _plugin->rpIdx[port];
+ unsigned long cport = _plugin->port2InCtrl(port);
+
+ if((int)cport == -1)
+ {
+ fprintf(stderr, "PluginI::oscControl: port number:%ld is not a control input\n", port);
+ return 0;
+ }
+
+ // (From DSSI module).
+ // p3.3.39 Set the DSSI control input port's value.
+ // Observations: With a native DSSI synth like LessTrivialSynth, the native GUI's controls do not change the sound at all
+ // ie. they don't update the DSSI control port values themselves.
+ // Hence in response to the call to this oscControl, sent by the native GUI, it is required to that here.
+/// controls[cport].val = value;
+ // DSSI-VST synths however, unlike DSSI synths, DO change their OWN sound in response to their gui controls.
+ // AND this function is called !
+ // Despite the descrepency we are STILL required to update the DSSI control port values here
+ // because dssi-vst is WAITING FOR A RESPONSE! (A CHANGE in the control port value).
+ // It will output something like "...4 events expected..." and count that number down as 4 actual control port value CHANGES
+ // are done here in response. Normally it says "...0 events expected..." when MusE is the one doing the DSSI control changes.
+ // TODO: May need FIFOs on each control(!) so that the control changes get sent one per process cycle!
+ // Observed countdown not actually going to zero upon string of changes.
+ // Try this ...
+ OscControlFifo* cfifo = _oscif.oscFifo(cport);
+ if(cfifo)
+ {
+ OscControlValue cv;
+ //cv.idx = cport;
+ cv.value = value;
+ if(cfifo->put(cv))
+ {
+ fprintf(stderr, "PluginI::oscControl: fifo overflow: in control number:%ld\n", cport);
+ }
+ }
+
+ // Record automation:
+ // Take care of this immediately, because we don't want the silly delay associated with
+ // processing the fifo one-at-a-time in the apply().
+ // NOTE: Ahh crap! We don't receive control events until the user RELEASES a control !
+ // So the events all arrive at once when the user releases a control.
+ // That makes this pretty useless... But what the heck...
+ if(_track && _id != -1)
+ {
+ int id = genACnum(_id, cport);
+ AutomationType at = _track->automationType();
+
+ // TODO: Taken from our native gui control handlers.
+ // This may need modification or may cause problems -
+ // we don't have the luxury of access to the dssi gui controls !
+ if(at == AUTO_WRITE || (audio->isPlaying() && at == AUTO_TOUCH))
+ enableController(cport, false);
+
+ _track->recordAutomation(id, value);
+ }
+
+ /*
+ const DSSI_Descriptor* dssi = synth->dssi;
+ const LADSPA_Descriptor* ld = dssi->LADSPA_Plugin;
+
+ ciMidiCtl2LadspaPort ip = synth->port2MidiCtlMap.find(cport);
+ if(ip != synth->port2MidiCtlMap.end())
+ {
+ // TODO: TODO: Update midi MusE's midi controller knobs, sliders, boxes etc with a call to the midi port's setHwCtrlState() etc.
+ // But first we need a ladspa2MidiValue() function! ...
+ //
+ //
+ //float val = ladspa2MidiValue(ld, i, ?, ?);
+
+ }
+ */
+
+#if 0
+ int port = argv[0]->i;
+ LADSPA_Data value = argv[1]->f;
+
+ if (port < 0 || port > instance->plugin->descriptor->LADSPA_Plugin->PortCount) {
+ fprintf(stderr, "MusE: OSC: %s port number (%d) is out of range\n",
+ instance->friendly_name, port);
+ return 0;
+ }
+ if (instance->pluginPortControlInNumbers[port] == -1) {
+ fprintf(stderr, "MusE: OSC: %s port %d is not a control in\n",
+ instance->friendly_name, port);
+ return 0;
+ }
+ pluginControlIns[instance->pluginPortControlInNumbers[port]] = value;
+ if (verbose) {
+ printf("MusE: OSC: %s port %d = %f\n",
+ instance->friendly_name, port, value);
+ }
+#endif
+ return 0;
+ }
+
+#endif // OSC_SUPPORT
+
+
+//---------------------------------------------------------
+// PluginDialog
+// select Plugin dialog
+//---------------------------------------------------------
+
+PluginDialog::PluginDialog(QWidget* parent)
+ : QDialog(parent)
+ {
+ setWindowTitle(tr("MusE: select plugin"));
+ QVBoxLayout* layout = new QVBoxLayout(this);
+
+ pList = new QTreeWidget(this);
+ pList->setColumnCount(11);
+ pList->setSortingEnabled(true);
+ QStringList headerLabels;
+ headerLabels << tr("Lib");
+ headerLabels << tr("Label");
+ headerLabels << tr("Name");
+ headerLabels << tr("AI");
+ headerLabels << tr("AO");
+ headerLabels << tr("CI");
+ headerLabels << tr("CO");
+ headerLabels << tr("IP");
+ headerLabels << tr("id");
+ headerLabels << tr("Maker");
+ headerLabels << tr("Copyright");
+
+ int sizes[] = { 110, 110, 0, 30, 30, 30, 30, 30, 40, 110, 110 };
+ for (int i = 0; i < 11; ++i) {
+ if (sizes[i] == 0) {
+ pList->header()->setResizeMode(i, QHeaderView::Stretch);
+ }
+ else {
+ if (sizes[i] <= 40) // hack alert!
+ pList->header()->setResizeMode(i, QHeaderView::Custom);
+ pList->header()->resizeSection(i, sizes[i]);
+ }
+ }
+
+ pList->setHeaderLabels(headerLabels);
+
+ pList->setSelectionBehavior(QAbstractItemView::SelectRows);
+ pList->setSelectionMode(QAbstractItemView::SingleSelection);
+ pList->setAlternatingRowColors(true);
+
+ fillPlugs(selectedPlugType);
+ layout->addWidget(pList);
+
+ //---------------------------------------------------
+ // Ok/Cancel Buttons
+ //---------------------------------------------------
+
+ QBoxLayout* w5 = new QHBoxLayout;
+ layout->addLayout(w5);
+
+ okB = new QPushButton(tr("Ok"), this);
+ okB->setDefault(true);
+ QPushButton* cancelB = new QPushButton(tr("Cancel"), this);
+ okB->setFixedWidth(80);
+ okB->setEnabled(false);
+ cancelB->setFixedWidth(80);
+ w5->addWidget(okB);
+ w5->addSpacing(12);
+ w5->addWidget(cancelB);
+
+ QGroupBox* plugSelGroup = new QGroupBox;
+ plugSelGroup->setTitle("Show plugs:");
+ QHBoxLayout* psl = new QHBoxLayout;
+ plugSelGroup->setLayout(psl);
+
+ QButtonGroup* plugSel = new QButtonGroup(plugSelGroup);
+ onlySM = new QRadioButton;
+ onlySM->setText(tr("Mono and Stereo"));
+ onlySM->setCheckable(true);
+ plugSel->addButton(onlySM);
+ psl->addWidget(onlySM);
+ onlyS = new QRadioButton;
+ onlyS->setText(tr("Stereo"));
+ onlyS->setCheckable(true);
+ plugSel->addButton(onlyS);
+ psl->addWidget(onlyS);
+ onlyM = new QRadioButton;
+ onlyM->setText(tr("Mono"));
+ onlyM->setCheckable(true);
+ plugSel->addButton(onlyM);
+ psl->addWidget(onlyM);
+ allPlug = new QRadioButton;
+ allPlug->setText(tr("Show All"));
+ allPlug->setCheckable(true);
+ plugSel->addButton(allPlug);
+ psl->addWidget(allPlug);
+ plugSel->setExclusive(true);
+
+ switch(selectedPlugType) {
+ case SEL_SM: onlySM->setChecked(true); break;
+ case SEL_S: onlyS->setChecked(true); break;
+ case SEL_M: onlyM->setChecked(true); break;
+ case SEL_ALL: allPlug->setChecked(true); break;
+ }
+
+ plugSelGroup->setToolTip(tr("Select which types of plugins should be visible in the list.<br>"
+ "Note that using mono plugins on stereo tracks is not a problem, two will be used in parallell.<br>"
+ "Also beware that the 'all' alternative includes plugins that probably not are usable by MusE."));
+
+ w5->addSpacing(12);
+ w5->addWidget(plugSelGroup);
+ w5->addSpacing(12);
+
+ QLabel *sortLabel = new QLabel;
+ sortLabel->setText(tr("Search in 'Label' and 'Name':"));
+ w5->addWidget(sortLabel);
+ w5->addSpacing(2);
+
+ sortBox = new QComboBox(this);
+ sortBox->setEditable(true);
+ if (!sortItems.empty())
+ sortBox->addItems(sortItems);
+
+ sortBox->setMinimumSize(100, 10);
+ w5->addWidget(sortBox);
+ w5->addStretch(-1);
+
+ if (!sortBox->currentText().isEmpty())
+ fillPlugs(sortBox->currentText());
+ else
+ fillPlugs(selectedPlugType);
+
+ connect(pList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), SLOT(accept()));
+ connect(pList, SIGNAL(itemClicked(QTreeWidgetItem*,int)), SLOT(enableOkB()));
+ connect(cancelB, SIGNAL(clicked()), SLOT(reject()));
+ connect(okB, SIGNAL(clicked()), SLOT(accept()));
+ connect(plugSel, SIGNAL(buttonClicked(QAbstractButton*)), SLOT(fillPlugs(QAbstractButton*)));
+ connect(sortBox, SIGNAL(editTextChanged(const QString&)),SLOT(fillPlugs(const QString&)));
+ sortBox->setFocus();
+ }
+
+//---------------------------------------------------------
+// enableOkB
+//---------------------------------------------------------
+
+void PluginDialog::enableOkB()
+ {
+ okB->setEnabled(true);
+ }
+
+//---------------------------------------------------------
+// value
+//---------------------------------------------------------
+
+Plugin* PluginDialog::value()
+ {
+ QTreeWidgetItem* item = pList->currentItem();
+ if (item)
+ return plugins.find(item->text(0), item->text(1));
+ printf("plugin not found\n");
+ return 0;
+ }
+
+//---------------------------------------------------------
+// accept
+//---------------------------------------------------------
+
+void PluginDialog::accept()
+ {
+ if (!sortBox->currentText().isEmpty()) {
+ foreach (QString item, sortItems)
+ if(item == sortBox->currentText()) {
+ QDialog::accept();
+ return;
+ }
+ sortItems.push_front(sortBox->currentText());
+ }
+ QDialog::accept();
+ }
+
+//---------------------------------------------------------
+// fillPlugs
+//---------------------------------------------------------
+
+void PluginDialog::fillPlugs(QAbstractButton* ab)
+ {
+ if (ab == allPlug)
+ fillPlugs(SEL_ALL);
+ else if (ab == onlyM)
+ fillPlugs(SEL_M);
+ else if (ab == onlyS)
+ fillPlugs(SEL_S);
+ else if (ab == onlySM)
+ fillPlugs(SEL_SM);
+ }
+
+void PluginDialog::fillPlugs(int nbr)
+{
+ pList->clear();
+ for (iPlugin i = plugins.begin(); i != plugins.end(); ++i) {
+ int ai = i->inports();
+ int ao = i->outports();
+ int ci = i->controlInPorts();
+ int co = i->controlOutPorts();
+ bool addFlag = false;
+ switch (nbr) {
+ case SEL_SM: // stereo & mono
+ if ((ai == 1 || ai == 2) && (ao == 1 || ao ==2)) {
+ addFlag = true;
+ }
+ break;
+ case SEL_S: // stereo
+ if ((ai == 1 || ai == 2) && ao ==2) {
+ addFlag = true;
+ }
+ break;
+ case SEL_M: // mono
+ if (ai == 1 && ao == 1) {
+ addFlag = true;
+ }
+ break;
+ case SEL_ALL: // all
+ addFlag = true;
+ break;
+ }
+ if (addFlag) {
+ QTreeWidgetItem* item = new QTreeWidgetItem;
+ item->setText(0, i->lib());
+ item->setText(1, i->label());
+ item->setText(2, i->name());
+ item->setText(3, QString().setNum(ai));
+ item->setText(4, QString().setNum(ao));
+ item->setText(5, QString().setNum(ci));
+ item->setText(6, QString().setNum(co));
+ item->setText(7, QString().setNum(i->inPlaceCapable()));
+ item->setText(8, QString().setNum(i->id()));
+ item->setText(9, i->maker());
+ item->setText(10, i->copyright());
+ pList->addTopLevelItem(item);
+ }
+ }
+ selectedPlugType = nbr;
+}
+
+void PluginDialog::fillPlugs(const QString &sortValue)
+{
+ pList->clear();
+ for (iPlugin i = plugins.begin(); i != plugins.end(); ++i) {
+ int ai = i->inports();
+ int ao = i->outports();
+ int ci = i->controlInPorts();
+ int co = i->controlOutPorts();
+
+ bool addFlag = false;
+
+ if (i->label().toLower().contains(sortValue.toLower()))
+ addFlag = true;
+ else if (i->name().toLower().contains(sortValue.toLower()))
+ addFlag = true;
+ if (addFlag) {
+ QTreeWidgetItem* item = new QTreeWidgetItem;
+ item->setText(0, i->lib());
+ item->setText(1, i->label());
+ item->setText(2, i->name());
+ item->setText(3, QString().setNum(ai));
+ item->setText(4, QString().setNum(ao));
+ item->setText(5, QString().setNum(ci));
+ item->setText(6, QString().setNum(co));
+ item->setText(7, QString().setNum(i->inPlaceCapable()));
+ item->setText(8, QString().setNum(i->id()));
+ item->setText(9, i->maker());
+ item->setText(10, i->copyright());
+ pList->addTopLevelItem(item);
+ }
+ }
+}
+
+//---------------------------------------------------------
+// getPlugin
+//---------------------------------------------------------
+
+Plugin* PluginDialog::getPlugin(QWidget* parent)
+ {
+ PluginDialog* dialog = new PluginDialog(parent);
+ if (dialog->exec())
+ return dialog->value();
+ return 0;
+ }
+
+// TODO: We need to use .qrc files to use icons in WhatsThis bubbles. See Qt
+// Resource System in Qt documentation - ORCAN
+//const char* presetOpenText = "<img source=\"fileopen\"> "
+// "Click this button to load a saved <em>preset</em>.";
+const char* presetOpenText = "Click this button to load a saved <em>preset</em>.";
+const char* presetSaveText = "Click this button to save curent parameter "
+ "settings as a <em>preset</em>. You will be prompted for a file name.";
+const char* presetBypassText = "Click this button to bypass effect unit";
+
+//---------------------------------------------------------
+// PluginGui
+//---------------------------------------------------------
+
+//PluginGui::PluginGui(PluginI* p)
+// p3.3.43
+PluginGui::PluginGui(PluginIBase* p)
+ : QMainWindow(0)
+ {
+ gw = 0;
+ params = 0;
+ plugin = p;
+ setWindowTitle(plugin->name());
+
+ QToolBar* tools = addToolBar(tr("File Buttons"));
+
+ QAction* fileOpen = new QAction(QIcon(*openIconS), tr("Load Preset"), this);
+ connect(fileOpen, SIGNAL(triggered()), this, SLOT(load()));
+ tools->addAction(fileOpen);
+
+ QAction* fileSave = new QAction(QIcon(*saveIconS), tr("Save Preset"), this);
+ connect(fileSave, SIGNAL(triggered()), this, SLOT(save()));
+ tools->addAction(fileSave);
+
+ tools->addAction(QWhatsThis::createAction(this));
+
+ onOff = new QAction(QIcon(*exitIconS), tr("bypass plugin"), this);
+ onOff->setCheckable(true);
+ onOff->setChecked(plugin->on());
+ onOff->setToolTip(tr("bypass plugin"));
+ connect(onOff, SIGNAL(toggled(bool)), SLOT(bypassToggled(bool)));
+ tools->addAction(onOff);
+
+ // TODO: We need to use .qrc files to use icons in WhatsThis bubbles. See Qt
+ // Resource System in Qt documentation - ORCAN
+ //Q3MimeSourceFactory::defaultFactory()->setPixmap(QString("fileopen"), *openIcon );
+ fileOpen->setWhatsThis(tr(presetOpenText));
+ onOff->setWhatsThis(tr(presetBypassText));
+ fileSave->setWhatsThis(tr(presetSaveText));
+
+ QString id;
+ //id.setNum(plugin->plugin()->id());
+ id.setNum(plugin->pluginID());
+ QString name(museGlobalShare + QString("/plugins/") + id + QString(".ui"));
+ QFile uifile(name);
+ if (uifile.exists()) {
+ //
+ // construct GUI from *.ui file
+ //
+ PluginLoader loader;
+ QFile file(uifile.fileName());
+ file.open(QFile::ReadOnly);
+ mw = loader.load(&file, this);
+ file.close();
+ setCentralWidget(mw);
+
+ QObjectList l = mw->children();
+ QObject *obj;
+
+ nobj = 0;
+ QList<QObject*>::iterator it;
+ for (it = l.begin(); it != l.end(); ++it) {
+ obj = *it;
+ QByteArray ba = obj->objectName().toLatin1();
+ const char* name = ba.constData();
+ if (*name !='P')
+ continue;
+ int parameter = -1;
+ sscanf(name, "P%d", &parameter);
+ if (parameter == -1)
+ continue;
+ ++nobj;
+ }
+ it = l.begin();
+ gw = new GuiWidgets[nobj];
+ nobj = 0;
+ QSignalMapper* mapper = new QSignalMapper(this);
+ connect(mapper, SIGNAL(mapped(int)), SLOT(guiParamChanged(int)));
+
+ QSignalMapper* mapperPressed = new QSignalMapper(this);
+ QSignalMapper* mapperReleased = new QSignalMapper(this);
+ connect(mapperPressed, SIGNAL(mapped(int)), SLOT(guiParamPressed(int)));
+ connect(mapperReleased, SIGNAL(mapped(int)), SLOT(guiParamReleased(int)));
+
+ for (it = l.begin(); it != l.end(); ++it) {
+ obj = *it;
+ QByteArray ba = obj->objectName().toLatin1();
+ const char* name = ba.constData();
+ if (*name !='P')
+ continue;
+ int parameter = -1;
+ sscanf(name, "P%d", &parameter);
+ if (parameter == -1)
+ continue;
+
+ mapper->setMapping(obj, nobj);
+ mapperPressed->setMapping(obj, nobj);
+ mapperReleased->setMapping(obj, nobj);
+
+ gw[nobj].widget = (QWidget*)obj;
+ gw[nobj].param = parameter;
+ gw[nobj].type = -1;
+
+ if (strcmp(obj->metaObject()->className(), "Slider") == 0) {
+ gw[nobj].type = GuiWidgets::SLIDER;
+ ((Slider*)obj)->setId(nobj);
+ ((Slider*)obj)->setCursorHoming(true);
+ for(int i = 0; i < nobj; i++)
+ {
+ if(gw[i].type == GuiWidgets::DOUBLE_LABEL && gw[i].param == parameter)
+ ((DoubleLabel*)gw[i].widget)->setSlider((Slider*)obj);
+ }
+ connect(obj, SIGNAL(sliderMoved(double,int)), mapper, SLOT(map()));
+ connect(obj, SIGNAL(sliderPressed(int)), SLOT(guiSliderPressed(int)));
+ connect(obj, SIGNAL(sliderReleased(int)), SLOT(guiSliderReleased(int)));
+ connect(obj, SIGNAL(sliderRightClicked(const QPoint &, int)), SLOT(guiSliderRightClicked(const QPoint &, int)));
+ }
+ else if (strcmp(obj->metaObject()->className(), "DoubleLabel") == 0) {
+ gw[nobj].type = GuiWidgets::DOUBLE_LABEL;
+ ((DoubleLabel*)obj)->setId(nobj);
+ for(int i = 0; i < nobj; i++)
+ {
+ if(gw[i].type == GuiWidgets::SLIDER && gw[i].param == parameter)
+ {
+ ((DoubleLabel*)obj)->setSlider((Slider*)gw[i].widget);
+ break;
+ }
+ }
+ connect(obj, SIGNAL(valueChanged(double,int)), mapper, SLOT(map()));
+ }
+ else if (strcmp(obj->metaObject()->className(), "QCheckBox") == 0) {
+ gw[nobj].type = GuiWidgets::QCHECKBOX;
+ connect(obj, SIGNAL(toggled(bool)), mapper, SLOT(map()));
+ connect(obj, SIGNAL(pressed()), mapperPressed, SLOT(map()));
+ connect(obj, SIGNAL(released()), mapperReleased, SLOT(map()));
+ }
+ else if (strcmp(obj->metaObject()->className(), "QComboBox") == 0) {
+ gw[nobj].type = GuiWidgets::QCOMBOBOX;
+ connect(obj, SIGNAL(activated(int)), mapper, SLOT(map()));
+ }
+ else {
+ printf("unknown widget class %s\n", obj->metaObject()->className());
+ continue;
+ }
+ ++nobj;
+ }
+ updateValues(); // otherwise the GUI won't have valid data
+ }
+ else {
+ //mw = new QWidget(this);
+ //setCentralWidget(mw);
+ // p3.4.43
+ view = new QScrollArea;
+ view->setWidgetResizable(true);
+ setCentralWidget(view);
+ //view->setVScrollBarMode(QScrollView::AlwaysOff);
+
+ mw = new QWidget;
+ QGridLayout* grid = new QGridLayout;
+ grid->setSpacing(2);
+
+ mw->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
+
+ int n = plugin->parameters();
+ params = new GuiParam[n];
+
+ // Changed p3.3.43
+ //resize(280, n*20+30);
+ //int nh = n*20+40;
+ //if(nh > 760)
+ // nh = 760;
+ //resize(280, nh);
+
+ //int style = Slider::BgTrough | Slider::BgSlot;
+ QFontMetrics fm = fontMetrics();
+ int h = fm.height() + 4;
+
+ for (int i = 0; i < n; ++i) {
+ QLabel* label = 0;
+ LADSPA_PortRangeHint range = plugin->range(i);
+ double lower = 0.0; // default values
+ double upper = 1.0;
+ double dlower = lower;
+ double dupper = upper;
+ double val = plugin->param(i);
+ double dval = val;
+ params[i].hint = range.HintDescriptor;
+
+ if (LADSPA_IS_HINT_BOUNDED_BELOW(range.HintDescriptor)) {
+ dlower = lower = range.LowerBound;
+ }
+ if (LADSPA_IS_HINT_BOUNDED_ABOVE(range.HintDescriptor)) {
+ dupper = upper = range.UpperBound;
+ }
+ if (LADSPA_IS_HINT_SAMPLE_RATE(range.HintDescriptor)) {
+ lower *= sampleRate;
+ upper *= sampleRate;
+ dlower = lower;
+ dupper = upper;
+ }
+ if (LADSPA_IS_HINT_LOGARITHMIC(range.HintDescriptor)) {
+ if (lower == 0.0)
+ lower = 0.001;
+ dlower = fast_log10(lower)*20.0;
+ dupper = fast_log10(upper)*20.0;
+ dval = fast_log10(val) * 20.0;
+ }
+ if (LADSPA_IS_HINT_TOGGLED(range.HintDescriptor)) {
+ params[i].type = GuiParam::GUI_SWITCH;
+ CheckBox* cb = new CheckBox(mw, i, "param");
+ cb->setId(i);
+ cb->setText(QString(plugin->paramName(i)));
+ cb->setChecked(plugin->param(i) != 0.0);
+ cb->setFixedHeight(h);
+ params[i].actuator = cb;
+ }
+ else {
+ label = new QLabel(QString(plugin->paramName(i)), 0);
+ params[i].type = GuiParam::GUI_SLIDER;
+ params[i].label = new DoubleLabel(val, lower, upper, 0);
+ params[i].label->setFrame(true);
+ params[i].label->setPrecision(2);
+ params[i].label->setId(i);
+
+ //params[i].label->setContentsMargins(2, 2, 2, 2);
+ //params[i].label->setFixedHeight(h);
+
+ Slider* s = new Slider(0, "param", Qt::Horizontal,
+ Slider::None); //, style);
+
+ s->setCursorHoming(true);
+ s->setId(i);
+ //s->setFixedHeight(h);
+ s->setRange(dlower, dupper);
+ if(LADSPA_IS_HINT_INTEGER(range.HintDescriptor))
+ s->setStep(1.0);
+ s->setValue(dval);
+ params[i].actuator = s;
+ params[i].label->setSlider((Slider*)params[i].actuator);
+ }
+ //params[i].actuator->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum));
+ params[i].actuator->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
+ if (params[i].type == GuiParam::GUI_SLIDER) {
+ //label->setFixedHeight(20);
+ //label->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum));
+ label->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
+ //params[i].label->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum));
+ params[i].label->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
+ grid->addWidget(label, i, 0);
+ grid->addWidget(params[i].label, i, 1);
+ grid->addWidget(params[i].actuator, i, 2);
+ }
+ else if (params[i].type == GuiParam::GUI_SWITCH) {
+ //grid->addMultiCellWidget(params[i].actuator, i, i, 0, 2);
+ grid->addWidget(params[i].actuator, i, 0, 1, 3);
+ }
+ if (params[i].type == GuiParam::GUI_SLIDER) {
+ connect(params[i].actuator, SIGNAL(sliderMoved(double,int)), SLOT(sliderChanged(double,int)));
+ connect(params[i].label, SIGNAL(valueChanged(double,int)), SLOT(labelChanged(double,int)));
+ connect(params[i].actuator, SIGNAL(sliderPressed(int)), SLOT(ctrlPressed(int)));
+ connect(params[i].actuator, SIGNAL(sliderReleased(int)), SLOT(ctrlReleased(int)));
+ connect(params[i].actuator, SIGNAL(sliderRightClicked(const QPoint &, int)), SLOT(ctrlRightClicked(const QPoint &, int)));
+ }
+ else if (params[i].type == GuiParam::GUI_SWITCH){
+ connect(params[i].actuator, SIGNAL(checkboxPressed(int)), SLOT(ctrlPressed(int)));
+ connect(params[i].actuator, SIGNAL(checkboxReleased(int)), SLOT(ctrlReleased(int)));
+ connect(params[i].actuator, SIGNAL(checkboxRightClicked(const QPoint &, int)), SLOT(ctrlRightClicked(const QPoint &, int)));
+ }
+ }
+ // p3.3.43
+ resize(280, height());
+
+ grid->setColumnStretch(2, 10);
+ mw->setLayout(grid);
+ view->setWidget(mw);
+ }
+ connect(heartBeatTimer, SIGNAL(timeout()), SLOT(heartBeat()));
+ }
+
+//---------------------------------------------------------
+// PluginGui
+//---------------------------------------------------------
+
+PluginGui::~PluginGui()
+ {
+ if (gw)
+ delete[] gw;
+ if (params)
+ delete[] params;
+ }
+
+//---------------------------------------------------------
+// heartBeat
+//---------------------------------------------------------
+
+void PluginGui::heartBeat()
+{
+ updateControls();
+}
+
+//---------------------------------------------------------
+// ctrlPressed
+//---------------------------------------------------------
+
+void PluginGui::ctrlPressed(int param)
+{
+ AutomationType at = AUTO_OFF;
+ AudioTrack* track = plugin->track();
+ if(track)
+ at = track->automationType();
+
+ if(at != AUTO_OFF)
+ plugin->enableController(param, false);
+
+ int id = plugin->id();
+
+ if(id == -1)
+ return;
+
+ id = genACnum(id, param);
+
+ if(params[param].type == GuiParam::GUI_SLIDER)
+ {
+ double val = ((Slider*)params[param].actuator)->value();
+ if (LADSPA_IS_HINT_LOGARITHMIC(params[param].hint))
+ val = pow(10.0, val/20.0);
+ else if (LADSPA_IS_HINT_INTEGER(params[param].hint))
+ val = rint(val);
+ plugin->setParam(param, val);
+ ((DoubleLabel*)params[param].label)->setValue(val);
+
+ // p3.3.43
+ //audio->msgSetPluginCtrlVal(((PluginI*)plugin), id, val);
+
+ if(track)
+ {
+ // p3.3.43
+ audio->msgSetPluginCtrlVal(track, id, val);
+
+ track->startAutoRecord(id, val);
+ }
+ }
+ else if(params[param].type == GuiParam::GUI_SWITCH)
+ {
+ double val = (double)((CheckBox*)params[param].actuator)->isChecked();
+ plugin->setParam(param, val);
+
+ // p3.3.43
+ //audio->msgSetPluginCtrlVal(((PluginI*)plugin), id, val);
+
+ if(track)
+ {
+ // p3.3.43
+ audio->msgSetPluginCtrlVal(track, id, val);
+
+ track->startAutoRecord(id, val);
+ }
+ }
+}
+
+//---------------------------------------------------------
+// ctrlReleased
+//---------------------------------------------------------
+
+void PluginGui::ctrlReleased(int param)
+{
+ AutomationType at = AUTO_OFF;
+ AudioTrack* track = plugin->track();
+ if(track)
+ at = track->automationType();
+
+ // Special for switch - don't enable controller until transport stopped.
+ if(at != AUTO_WRITE && ((params[param].type != GuiParam::GUI_SWITCH
+ || !audio->isPlaying()
+ || at != AUTO_TOUCH) || (!audio->isPlaying() && at == AUTO_TOUCH)) )
+ plugin->enableController(param, true);
+
+ int id = plugin->id();
+ if(!track || id == -1)
+ return;
+ id = genACnum(id, param);
+
+ if(params[param].type == GuiParam::GUI_SLIDER)
+ {
+ double val = ((Slider*)params[param].actuator)->value();
+ if (LADSPA_IS_HINT_LOGARITHMIC(params[param].hint))
+ val = pow(10.0, val/20.0);
+ else if (LADSPA_IS_HINT_INTEGER(params[param].hint))
+ val = rint(val);
+ track->stopAutoRecord(id, val);
+ }
+ //else if(params[param].type == GuiParam::GUI_SWITCH)
+ //{
+ //double val = (double)((CheckBox*)params[param].actuator)->isChecked();
+ // No concept of 'untouching' a checkbox. Remain 'touched' until stop.
+ //plugin->track()->stopAutoRecord(genACnum(plugin->id(), param), val);
+ //}
+}
+
+//---------------------------------------------------------
+// ctrlRightClicked
+//---------------------------------------------------------
+
+void PluginGui::ctrlRightClicked(const QPoint &p, int param)
+{
+ int id = plugin->id();
+ if(id != -1)
+ //song->execAutomationCtlPopup((AudioTrack*)plugin->track(), p, genACnum(id, param));
+ song->execAutomationCtlPopup(plugin->track(), p, genACnum(id, param));
+}
+
+//---------------------------------------------------------
+// sliderChanged
+//---------------------------------------------------------
+
+void PluginGui::sliderChanged(double val, int param)
+{
+ AutomationType at = AUTO_OFF;
+ AudioTrack* track = plugin->track();
+ if(track)
+ at = track->automationType();
+
+ if(at == AUTO_WRITE || (audio->isPlaying() && at == AUTO_TOUCH))
+ plugin->enableController(param, false);
+
+ if (LADSPA_IS_HINT_LOGARITHMIC(params[param].hint))
+ val = pow(10.0, val/20.0);
+ else if (LADSPA_IS_HINT_INTEGER(params[param].hint))
+ val = rint(val);
+ if (plugin->param(param) != val) {
+ plugin->setParam(param, val);
+ ((DoubleLabel*)params[param].label)->setValue(val);
+ }
+
+ int id = plugin->id();
+ if(id == -1)
+ return;
+ id = genACnum(id, param);
+
+ // p3.3.43
+ //audio->msgSetPluginCtrlVal(((PluginI*)plugin), id, val);
+
+ if(track)
+ {
+ // p3.3.43
+ audio->msgSetPluginCtrlVal(track, id, val);
+
+ track->recordAutomation(id, val);
+ }
+}
+
+//---------------------------------------------------------
+// labelChanged
+//---------------------------------------------------------
+
+void PluginGui::labelChanged(double val, int param)
+{
+ AutomationType at = AUTO_OFF;
+ AudioTrack* track = plugin->track();
+ if(track)
+ at = track->automationType();
+
+ if(at == AUTO_WRITE || (audio->isPlaying() && at == AUTO_TOUCH))
+ plugin->enableController(param, false);
+
+ double dval = val;
+ if (LADSPA_IS_HINT_LOGARITHMIC(params[param].hint))
+ dval = fast_log10(val) * 20.0;
+ else if (LADSPA_IS_HINT_INTEGER(params[param].hint))
+ dval = rint(val);
+ if (plugin->param(param) != val) {
+ plugin->setParam(param, val);
+ ((Slider*)params[param].actuator)->setValue(dval);
+ }
+
+ int id = plugin->id();
+ if(id == -1)
+ return;
+
+ id = genACnum(id, param);
+
+ // p3.3.43
+ //audio->msgSetPluginCtrlVal(((PluginI*)plugin), id, val);
+
+ if(track)
+ {
+ // p3.3.43
+ audio->msgSetPluginCtrlVal(track, id, val);
+
+ track->startAutoRecord(id, val);
+ }
+}
+
+//---------------------------------------------------------
+// load
+//---------------------------------------------------------
+
+void PluginGui::load()
+ {
+ QString s("presets/plugins/");
+ //s += plugin->plugin()->label();
+ s += plugin->pluginLabel();
+ s += "/";
+
+ QString fn = getOpenFileName(s, preset_file_pattern,
+ this, tr("MusE: load preset"), 0);
+ if (fn.isEmpty())
+ return;
+ bool popenFlag;
+ FILE* f = fileOpen(this, fn, QString(".pre"), "r", popenFlag, true);
+ if (f == 0)
+ return;
+
+ Xml xml(f);
+ int mode = 0;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ QString tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (mode == 0 && tag == "muse")
+ mode = 1;
+ else if (mode == 1 && tag == "plugin") {
+
+ if(plugin->readConfiguration(xml, true))
+ {
+ QMessageBox::critical(this, QString("MusE"),
+ tr("Error reading preset. Might not be right type for this plugin"));
+ goto ende;
+ }
+
+ mode = 0;
+ }
+ else
+ xml.unknown("PluginGui");
+ break;
+ case Xml::Attribut:
+ break;
+ case Xml::TagEnd:
+ if (!mode && tag == "muse")
+ {
+ plugin->updateControllers();
+ goto ende;
+ }
+ default:
+ break;
+ }
+ }
+ende:
+ if (popenFlag)
+ pclose(f);
+ else
+ fclose(f);
+ }
+
+//---------------------------------------------------------
+// save
+//---------------------------------------------------------
+
+void PluginGui::save()
+ {
+ QString s("presets/plugins/");
+ //s += plugin->plugin()->label();
+ s += plugin->pluginLabel();
+ s += "/";
+
+ //QString fn = getSaveFileName(s, preset_file_pattern, this,
+ QString fn = getSaveFileName(s, preset_file_save_pattern, this,
+ tr("MusE: save preset"));
+ if (fn.isEmpty())
+ return;
+ bool popenFlag;
+ FILE* f = fileOpen(this, fn, QString(".pre"), "w", popenFlag, false, true);
+ if (f == 0)
+ return;
+ Xml xml(f);
+ xml.header();
+ xml.tag(0, "muse version=\"1.0\"");
+ plugin->writeConfiguration(1, xml);
+ xml.tag(1, "/muse");
+
+ if (popenFlag)
+ pclose(f);
+ else
+ fclose(f);
+ }
+
+//---------------------------------------------------------
+// bypassToggled
+//---------------------------------------------------------
+
+void PluginGui::bypassToggled(bool val)
+ {
+ plugin->setOn(val);
+ song->update(SC_ROUTE);
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void PluginGui::setOn(bool val)
+ {
+ onOff->blockSignals(true);
+ onOff->setChecked(val);
+ onOff->blockSignals(false);
+ }
+
+//---------------------------------------------------------
+// updateValues
+//---------------------------------------------------------
+
+void PluginGui::updateValues()
+ {
+ if (params) {
+ for (int i = 0; i < plugin->parameters(); ++i) {
+ GuiParam* gp = &params[i];
+ if (gp->type == GuiParam::GUI_SLIDER) {
+ double lv = plugin->param(i);
+ double sv = lv;
+ if (LADSPA_IS_HINT_LOGARITHMIC(params[i].hint))
+ sv = fast_log10(lv) * 20.0;
+ else if (LADSPA_IS_HINT_INTEGER(params[i].hint))
+ {
+ sv = rint(lv);
+ lv = sv;
+ }
+ gp->label->setValue(lv);
+ ((Slider*)(gp->actuator))->setValue(sv);
+ }
+ else if (gp->type == GuiParam::GUI_SWITCH) {
+ ((CheckBox*)(gp->actuator))->setChecked(int(plugin->param(i)));
+ }
+ }
+ }
+ else if (gw) {
+ for (int i = 0; i < nobj; ++i) {
+ QWidget* widget = gw[i].widget;
+ int type = gw[i].type;
+ int param = gw[i].param;
+ double val = plugin->param(param);
+ switch(type) {
+ case GuiWidgets::SLIDER:
+ ((Slider*)widget)->setValue(val);
+ break;
+ case GuiWidgets::DOUBLE_LABEL:
+ ((DoubleLabel*)widget)->setValue(val);
+ break;
+ case GuiWidgets::QCHECKBOX:
+ ((QCheckBox*)widget)->setChecked(int(val));
+ break;
+ case GuiWidgets::QCOMBOBOX:
+ ((QComboBox*)widget)->setCurrentIndex(int(val));
+ break;
+ }
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// updateControls
+//---------------------------------------------------------
+
+void PluginGui::updateControls()
+ {
+ if(!automation || !plugin->track() || plugin->id() == -1)
+ return;
+ AutomationType at = plugin->track()->automationType();
+ if(at == AUTO_OFF)
+ return;
+ if (params) {
+ for (int i = 0; i < plugin->parameters(); ++i) {
+ GuiParam* gp = &params[i];
+ if (gp->type == GuiParam::GUI_SLIDER) {
+ if( plugin->controllerEnabled(i) && plugin->controllerEnabled2(i) )
+ {
+ double lv = plugin->track()->pluginCtrlVal(genACnum(plugin->id(), i));
+ double sv = lv;
+ if (LADSPA_IS_HINT_LOGARITHMIC(params[i].hint))
+ sv = fast_log10(lv) * 20.0;
+ else
+ if (LADSPA_IS_HINT_INTEGER(params[i].hint))
+ {
+ sv = rint(lv);
+ lv = sv;
+ }
+ if(((Slider*)(gp->actuator))->value() != sv)
+ {
+ //printf("PluginGui::updateControls slider\n");
+
+ gp->label->blockSignals(true);
+ ((Slider*)(gp->actuator))->blockSignals(true);
+ ((Slider*)(gp->actuator))->setValue(sv);
+ gp->label->setValue(lv);
+ ((Slider*)(gp->actuator))->blockSignals(false);
+ gp->label->blockSignals(false);
+ }
+ }
+
+ }
+ else if (gp->type == GuiParam::GUI_SWITCH) {
+ if( plugin->controllerEnabled(i) && plugin->controllerEnabled2(i) )
+ {
+ bool v = (int)plugin->track()->pluginCtrlVal(genACnum(plugin->id(), i));
+ if(((CheckBox*)(gp->actuator))->isChecked() != v)
+ {
+ //printf("PluginGui::updateControls switch\n");
+
+ ((CheckBox*)(gp->actuator))->blockSignals(true);
+ ((CheckBox*)(gp->actuator))->setChecked(v);
+ ((CheckBox*)(gp->actuator))->blockSignals(false);
+ }
+ }
+ }
+ }
+ }
+ else if (gw) {
+ for (int i = 0; i < nobj; ++i) {
+ QWidget* widget = gw[i].widget;
+ int type = gw[i].type;
+ int param = gw[i].param;
+ switch(type) {
+ case GuiWidgets::SLIDER:
+ if( plugin->controllerEnabled(param) && plugin->controllerEnabled2(param) )
+ {
+ double v = plugin->track()->pluginCtrlVal(genACnum(plugin->id(), param));
+ if(((Slider*)widget)->value() != v)
+ {
+ //printf("PluginGui::updateControls slider\n");
+
+ ((Slider*)widget)->blockSignals(true);
+ ((Slider*)widget)->setValue(v);
+ ((Slider*)widget)->blockSignals(false);
+ }
+ }
+ break;
+ case GuiWidgets::DOUBLE_LABEL:
+ if( plugin->controllerEnabled(param) && plugin->controllerEnabled2(param) )
+ {
+ double v = plugin->track()->pluginCtrlVal(genACnum(plugin->id(), param));
+ if(((DoubleLabel*)widget)->value() != v)
+ {
+ //printf("PluginGui::updateControls label\n");
+
+ ((DoubleLabel*)widget)->blockSignals(true);
+ ((DoubleLabel*)widget)->setValue(v);
+ ((DoubleLabel*)widget)->blockSignals(false);
+ }
+ }
+ break;
+ case GuiWidgets::QCHECKBOX:
+ if( plugin->controllerEnabled(param) && plugin->controllerEnabled2(param) )
+ {
+ bool b = (bool) plugin->track()->pluginCtrlVal(genACnum(plugin->id(), param));
+ if(((QCheckBox*)widget)->isChecked() != b)
+ {
+ //printf("PluginGui::updateControls checkbox\n");
+
+ ((QCheckBox*)widget)->blockSignals(true);
+ ((QCheckBox*)widget)->setChecked(b);
+ ((QCheckBox*)widget)->blockSignals(false);
+ }
+ }
+ break;
+ case GuiWidgets::QCOMBOBOX:
+ if( plugin->controllerEnabled(param) && plugin->controllerEnabled2(param) )
+ {
+ int n = (int) plugin->track()->pluginCtrlVal(genACnum(plugin->id(), param));
+ if(((QComboBox*)widget)->currentIndex() != n)
+ {
+ //printf("PluginGui::updateControls combobox\n");
+
+ ((QComboBox*)widget)->blockSignals(true);
+ ((QComboBox*)widget)->setCurrentIndex(n);
+ ((QComboBox*)widget)->blockSignals(false);
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// guiParamChanged
+//---------------------------------------------------------
+
+void PluginGui::guiParamChanged(int idx)
+{
+ QWidget* w = gw[idx].widget;
+ int param = gw[idx].param;
+ int type = gw[idx].type;
+
+ AutomationType at = AUTO_OFF;
+ AudioTrack* track = plugin->track();
+ if(track)
+ at = track->automationType();
+
+ if(at == AUTO_WRITE || (audio->isPlaying() && at == AUTO_TOUCH))
+ plugin->enableController(param, false);
+
+ double val = 0.0;
+ switch(type) {
+ case GuiWidgets::SLIDER:
+ val = ((Slider*)w)->value();
+ break;
+ case GuiWidgets::DOUBLE_LABEL:
+ val = ((DoubleLabel*)w)->value();
+ break;
+ case GuiWidgets::QCHECKBOX:
+ val = double(((QCheckBox*)w)->isChecked());
+ break;
+ case GuiWidgets::QCOMBOBOX:
+ val = double(((QComboBox*)w)->currentIndex());
+ break;
+ }
+
+ for (int i = 0; i < nobj; ++i) {
+ QWidget* widget = gw[i].widget;
+ if (widget == w || param != gw[i].param)
+ continue;
+ int type = gw[i].type;
+ switch(type) {
+ case GuiWidgets::SLIDER:
+ ((Slider*)widget)->setValue(val);
+ break;
+ case GuiWidgets::DOUBLE_LABEL:
+ ((DoubleLabel*)widget)->setValue(val);
+ break;
+ case GuiWidgets::QCHECKBOX:
+ ((QCheckBox*)widget)->setChecked(int(val));
+ break;
+ case GuiWidgets::QCOMBOBOX:
+ ((QComboBox*)widget)->setCurrentIndex(int(val));
+ break;
+ }
+ }
+
+ int id = plugin->id();
+ if(track && id != -1)
+ {
+ id = genACnum(id, param);
+
+ // p3.3.43
+ //audio->msgSetPluginCtrlVal(((PluginI*)plugin), id, val);
+
+ //if(track)
+ //{
+ // p3.3.43
+ audio->msgSetPluginCtrlVal(track, id, val);
+
+ switch(type)
+ {
+ case GuiWidgets::DOUBLE_LABEL:
+ case GuiWidgets::QCHECKBOX:
+ track->startAutoRecord(id, val);
+ break;
+ default:
+ track->recordAutomation(id, val);
+ break;
+ }
+ //}
+ }
+ plugin->setParam(param, val);
+}
+
+//---------------------------------------------------------
+// guiParamPressed
+//---------------------------------------------------------
+
+void PluginGui::guiParamPressed(int idx)
+ {
+ int param = gw[idx].param;
+
+ AutomationType at = AUTO_OFF;
+ AudioTrack* track = plugin->track();
+ if(track)
+ at = track->automationType();
+
+ if(at != AUTO_OFF)
+ plugin->enableController(param, false);
+
+ int id = plugin->id();
+ if(!track || id == -1)
+ return;
+
+ id = genACnum(id, param);
+
+ // NOTE: For this to be of any use, the freeverb gui 2142.ui
+ // would have to be used, and changed to use CheckBox and ComboBox
+ // instead of QCheckBox and QComboBox, since both of those would
+ // need customization (Ex. QCheckBox doesn't check on click).
+ /*
+ switch(type) {
+ case GuiWidgets::QCHECKBOX:
+ double val = (double)((CheckBox*)w)->isChecked();
+ track->startAutoRecord(id, val);
+ break;
+ case GuiWidgets::QCOMBOBOX:
+ double val = (double)((ComboBox*)w)->currentIndex();
+ track->startAutoRecord(id, val);
+ break;
+ }
+ */
+ }
+
+//---------------------------------------------------------
+// guiParamReleased
+//---------------------------------------------------------
+
+void PluginGui::guiParamReleased(int idx)
+ {
+ int param = gw[idx].param;
+ int type = gw[idx].type;
+
+ AutomationType at = AUTO_OFF;
+ AudioTrack* track = plugin->track();
+ if(track)
+ at = track->automationType();
+
+ // Special for switch - don't enable controller until transport stopped.
+ if(at != AUTO_WRITE && (type != GuiWidgets::QCHECKBOX
+ || !audio->isPlaying()
+ || at != AUTO_TOUCH))
+ plugin->enableController(param, true);
+
+ int id = plugin->id();
+
+ if(!track || id == -1)
+ return;
+
+ id = genACnum(id, param);
+
+ // NOTE: For this to be of any use, the freeverb gui 2142.ui
+ // would have to be used, and changed to use CheckBox and ComboBox
+ // instead of QCheckBox and QComboBox, since both of those would
+ // need customization (Ex. QCheckBox doesn't check on click).
+ /*
+ switch(type) {
+ case GuiWidgets::QCHECKBOX:
+ double val = (double)((CheckBox*)w)->isChecked();
+ track->stopAutoRecord(id, param);
+ break;
+ case GuiWidgets::QCOMBOBOX:
+ double val = (double)((ComboBox*)w)->currentIndex();
+ track->stopAutoRecord(id, param);
+ break;
+ }
+ */
+ }
+
+//---------------------------------------------------------
+// guiSliderPressed
+//---------------------------------------------------------
+
+void PluginGui::guiSliderPressed(int idx)
+ {
+ int param = gw[idx].param;
+ QWidget *w = gw[idx].widget;
+
+ AutomationType at = AUTO_OFF;
+ AudioTrack* track = plugin->track();
+ if(track)
+ at = track->automationType();
+
+ int id = plugin->id();
+
+ if(at == AUTO_WRITE || (at == AUTO_READ || at == AUTO_TOUCH))
+ plugin->enableController(param, false);
+
+ if(!track || id == -1)
+ return;
+
+ id = genACnum(id, param);
+
+ double val = ((Slider*)w)->value();
+ plugin->setParam(param, val);
+
+ //audio->msgSetPluginCtrlVal(((PluginI*)plugin), id, val);
+ // p3.3.43
+ audio->msgSetPluginCtrlVal(track, id, val);
+
+ track->startAutoRecord(id, val);
+
+ // Needed so that paging a slider updates a label or other buddy control.
+ for (int i = 0; i < nobj; ++i) {
+ QWidget* widget = gw[i].widget;
+ if (widget == w || param != gw[i].param)
+ continue;
+ int type = gw[i].type;
+ switch(type) {
+ case GuiWidgets::SLIDER:
+ ((Slider*)widget)->setValue(val);
+ break;
+ case GuiWidgets::DOUBLE_LABEL:
+ ((DoubleLabel*)widget)->setValue(val);
+ break;
+ case GuiWidgets::QCHECKBOX:
+ ((QCheckBox*)widget)->setChecked(int(val));
+ break;
+ case GuiWidgets::QCOMBOBOX:
+ ((QComboBox*)widget)->setCurrentIndex(int(val));
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// guiSliderReleased
+//---------------------------------------------------------
+
+void PluginGui::guiSliderReleased(int idx)
+ {
+ int param = gw[idx].param;
+ QWidget *w = gw[idx].widget;
+
+ AutomationType at = AUTO_OFF;
+ AudioTrack* track = plugin->track();
+ if(track)
+ at = track->automationType();
+
+ if(at != AUTO_WRITE || (!audio->isPlaying() && at == AUTO_TOUCH))
+ plugin->enableController(param, true);
+
+ int id = plugin->id();
+
+ if(!track || id == -1)
+ return;
+
+ id = genACnum(id, param);
+
+ double val = ((Slider*)w)->value();
+ track->stopAutoRecord(id, val);
+ }
+
+//---------------------------------------------------------
+// guiSliderRightClicked
+//---------------------------------------------------------
+
+void PluginGui::guiSliderRightClicked(const QPoint &p, int idx)
+{
+ int param = gw[idx].param;
+ int id = plugin->id();
+ if(id != -1)
+ //song->execAutomationCtlPopup((AudioTrack*)plugin->track(), p, genACnum(id, param));
+ song->execAutomationCtlPopup(plugin->track(), p, genACnum(id, param));
+}
+
+//---------------------------------------------------------
+// PluginLoader
+//---------------------------------------------------------
+QWidget* PluginLoader::createWidget(const QString & className, QWidget * parent, const QString & name)
+{
+ if(className == QString("DoubleLabel"))
+ return new DoubleLabel(parent, name.toLatin1().constData());
+ if(className == QString("Slider"))
+ return new Slider(parent, name.toLatin1().constData(), Qt::Horizontal);
+
+ return QUiLoader::createWidget(className, parent, name);
+};
diff --git a/attic/muse2-oom/muse2/muse/plugin.h b/attic/muse2-oom/muse2/muse/plugin.h
new file mode 100644
index 00000000..031eb566
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/plugin.h
@@ -0,0 +1,565 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: plugin.h,v 1.9.2.13 2009/12/06 01:25:21 terminator356 Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __PLUGIN_H__
+#define __PLUGIN_H__
+
+#include <list>
+#include <vector>
+
+#include <QDialog>
+#include <QFileInfo>
+#include <QMainWindow>
+#include <QUiLoader>
+
+
+#include "ladspa.h"
+#include "globals.h"
+#include "globaldefs.h"
+#include "ctrl.h"
+
+//#include "stringparam.h"
+
+#include "config.h"
+
+#ifdef OSC_SUPPORT
+//class OscIF;
+#include "osc.h"
+#endif
+
+#ifdef DSSI_SUPPORT
+#include <dssi.h>
+#endif
+
+class QAbstractButton;
+class QComboBox;
+class QRadioButton;
+class QScrollArea;
+class QToolButton;
+class QToolButton;
+class QTreeWidget;
+
+class Xml;
+class Slider;
+class DoubleLabel;
+class AudioTrack;
+class MidiController;
+
+//---------------------------------------------------------
+// PluginLoader
+//---------------------------------------------------------
+
+class PluginLoader : public QUiLoader
+{
+ public:
+ virtual QWidget* createWidget(const QString & className, QWidget * parent = 0, const QString & name = QString());
+ PluginLoader(QObject * parent = 0) : QUiLoader(parent) {}
+};
+
+//---------------------------------------------------------
+// Plugin
+//---------------------------------------------------------
+
+class Plugin {
+ protected:
+ void* _handle;
+ int _references;
+ int _instNo;
+ QFileInfo fi;
+ LADSPA_Descriptor_Function ladspa;
+ const LADSPA_Descriptor *plugin;
+ unsigned long _uniqueID;
+ QString _label;
+ QString _name;
+ QString _maker;
+ QString _copyright;
+
+ bool _isDssi;
+ #ifdef DSSI_SUPPORT
+ const DSSI_Descriptor* dssi_descr;
+ #endif
+
+ //LADSPA_PortDescriptor* _portDescriptors;
+ unsigned long _portCount;
+ unsigned long _inports;
+ unsigned long _outports;
+ unsigned long _controlInPorts;
+ unsigned long _controlOutPorts;
+ std::vector<unsigned long> rpIdx; // Port number to control input index. Item is -1 if it's not a control input.
+
+ bool _inPlaceCapable;
+
+ public:
+ Plugin(QFileInfo* f, const LADSPA_Descriptor* d, bool isDssi = false);
+ ~Plugin();
+
+ QString label() const { return _label; }
+ QString name() const { return _name; }
+ unsigned long id() const { return _uniqueID; }
+ QString maker() const { return _maker; }
+ QString copyright() const { return _copyright; }
+ QString lib(bool complete = true) /*const*/ { return complete ? fi.completeBaseName() : fi.baseName(); } // ddskrjo const
+ QString dirPath(bool complete = true) const { return complete ? fi.absolutePath() : fi.path(); }
+ QString filePath() const { return fi.filePath(); }
+ int references() const { return _references; }
+ int incReferences(int);
+ int instNo() { return _instNo++; }
+
+ bool isDssiPlugin() const { return _isDssi; }
+
+ LADSPA_Handle instantiate();
+ void activate(LADSPA_Handle handle) {
+ if (plugin && plugin->activate)
+ plugin->activate(handle);
+ }
+ void deactivate(LADSPA_Handle handle) {
+ if (plugin && plugin->deactivate)
+ plugin->deactivate(handle);
+ }
+ void cleanup(LADSPA_Handle handle) {
+ if (plugin && plugin->cleanup)
+ plugin->cleanup(handle);
+ }
+ void connectPort(LADSPA_Handle handle, int port, float* value) {
+ if(plugin)
+ plugin->connect_port(handle, port, value);
+ }
+ void apply(LADSPA_Handle handle, int n) {
+ if(plugin)
+ plugin->run(handle, n);
+ }
+
+ #ifdef OSC_SUPPORT
+ int oscConfigure(LADSPA_Handle /*handle*/, const char* /*key*/, const char* /*value*/);
+ #endif
+
+ //int ports() { return plugin ? plugin->PortCount : 0; }
+ unsigned long ports() { return _portCount; }
+
+ LADSPA_PortDescriptor portd(unsigned long k) const {
+ return plugin ? plugin->PortDescriptors[k] : 0;
+ //return _portDescriptors[k];
+ }
+
+ LADSPA_PortRangeHint range(unsigned long i) {
+ // FIXME:
+ //return plugin ? plugin->PortRangeHints[i] : 0;
+ return plugin->PortRangeHints[i];
+ }
+
+ double defaultValue(unsigned long port) const;
+ void range(unsigned long i, float*, float*) const;
+
+ const char* portName(unsigned long i) {
+ return plugin ? plugin->PortNames[i] : 0;
+ }
+
+ // Returns (int)-1 if not an input control.
+ unsigned long port2InCtrl(unsigned long p) { return p >= rpIdx.size() ? (unsigned long)-1 : rpIdx[p]; }
+
+ unsigned long inports() const { return _inports; }
+ unsigned long outports() const { return _outports; }
+ unsigned long controlInPorts() const { return _controlInPorts; }
+ unsigned long controlOutPorts() const { return _controlOutPorts; }
+ bool inPlaceCapable() const { return _inPlaceCapable; }
+
+ /*
+ bool isLog(int k) const {
+ LADSPA_PortRangeHint r = plugin->PortRangeHints[pIdx[k]];
+ return LADSPA_IS_HINT_LOGARITHMIC(r.HintDescriptor);
+ }
+ bool isBool(int k) const {
+ return LADSPA_IS_HINT_TOGGLED(plugin->PortRangeHints[pIdx[k]].HintDescriptor);
+ }
+ bool isInt(int k) const {
+ LADSPA_PortRangeHint r = plugin->PortRangeHints[pIdx[k]];
+ return LADSPA_IS_HINT_INTEGER(r.HintDescriptor);
+ }
+ */
+ };
+
+typedef std::list<Plugin>::iterator iPlugin;
+
+//---------------------------------------------------------
+// PluginList
+//---------------------------------------------------------
+
+class PluginList : public std::list<Plugin> {
+ public:
+ void add(QFileInfo* fi, const LADSPA_Descriptor* d, bool isDssi = false)
+ {
+ push_back(Plugin(fi, d, isDssi));
+ }
+
+ Plugin* find(const QString&, const QString&);
+ PluginList() {}
+ };
+
+//---------------------------------------------------------
+// Port
+//---------------------------------------------------------
+
+struct Port {
+ int idx;
+ float val;
+ float tmpVal;
+
+ bool enCtrl; // Enable controller stream.
+ bool en2Ctrl; // Second enable controller stream (and'ed with enCtrl).
+ };
+
+//---------------------------------------------------------
+// GuiParam
+//---------------------------------------------------------
+
+struct GuiParam {
+ enum {
+ GUI_SLIDER, GUI_SWITCH
+ };
+ int type;
+ int hint;
+
+ DoubleLabel* label;
+ QWidget* actuator; // Slider or Toggle Button (SWITCH)
+ };
+
+//---------------------------------------------------------
+// GuiWidgets
+//---------------------------------------------------------
+
+struct GuiWidgets {
+ enum {
+ SLIDER, DOUBLE_LABEL, QCHECKBOX, QCOMBOBOX
+ };
+ QWidget* widget;
+ int type;
+ int param;
+ };
+
+class PluginI;
+
+/*
+class PluginBase
+{
+ public:
+ bool on() const { return _on; }
+ void setOn(bool val) { _on = val; }
+ int pluginID() { return plugin()->id(); }
+ int id() { return _id; }
+ QString pluginLabel() const { return _plugin->label(); }
+ QString name() const { return _name; }
+
+ AudioTrack* track() { return _track; }
+
+ void enableController(int i, bool v = true) { controls[i].enCtrl = v; }
+ bool controllerEnabled(int i) const { return controls[i].enCtrl; }
+ bool controllerEnabled2(int i) const { return controls[i].en2Ctrl; }
+ void updateControllers();
+
+ void writeConfiguration(int level, Xml& xml);
+ bool readConfiguration(Xml& xml, bool readPreset=false);
+
+ int parameters() const { return controlPorts; }
+ void setParam(int i, double val) { controls[i].tmpVal = val; }
+ double param(int i) const { return controls[i].val; }
+ const char* paramName(int i) { return _plugin->portName(controls[i].idx); }
+ LADSPA_PortRangeHint range(int i)
+ {
+ return _plugin->range(controls[i].idx);
+ }
+};
+*/
+
+//---------------------------------------------------------
+// PluginIBase
+//---------------------------------------------------------
+
+class PluginIBase
+{
+ public:
+ virtual bool on() const = 0;
+ virtual void setOn(bool /*val*/) = 0;
+ virtual int pluginID() = 0;
+ virtual int id() = 0;
+ virtual QString pluginLabel() const = 0;
+ virtual QString name() const = 0;
+
+ virtual AudioTrack* track() = 0;
+
+ virtual void enableController(int /*i*/, bool v = true) = 0;
+ virtual bool controllerEnabled(int /*i*/) const = 0;
+ virtual bool controllerEnabled2(int /*i*/) const = 0;
+ virtual void updateControllers() = 0;
+
+ virtual void writeConfiguration(int /*level*/, Xml& /*xml*/) = 0;
+ virtual bool readConfiguration(Xml& /*xml*/, bool readPreset=false) = 0;
+
+ virtual int parameters() const = 0;
+ virtual void setParam(int /*i*/, double /*val*/) = 0;
+ virtual double param(int /*i*/) const = 0;
+ virtual const char* paramName(int /*i*/) = 0;
+ virtual LADSPA_PortRangeHint range(int /*i*/) = 0;
+};
+
+//---------------------------------------------------------
+// PluginGui
+//---------------------------------------------------------
+
+class PluginGui : public QMainWindow {
+ Q_OBJECT
+
+ //PluginI* plugin; // plugin instance
+ PluginIBase* plugin; // plugin instance
+
+ GuiParam* params;
+ int nobj; // number of widgets in gw
+ GuiWidgets* gw;
+
+ QAction* onOff;
+ QWidget* mw; // main widget
+ QScrollArea* view;
+
+ void updateControls();
+
+ private slots:
+ void load();
+ void save();
+ void bypassToggled(bool);
+ void sliderChanged(double, int);
+ void labelChanged(double, int);
+ void guiParamChanged(int);
+ void ctrlPressed(int);
+ void ctrlReleased(int);
+ void guiParamPressed(int);
+ void guiParamReleased(int);
+ void guiSliderPressed(int);
+ void guiSliderReleased(int);
+ void ctrlRightClicked(const QPoint &, int);
+ void guiSliderRightClicked(const QPoint &, int);
+
+ protected slots:
+ void heartBeat();
+
+ public:
+ //PluginGui(PluginI*);
+ PluginGui(PluginIBase*);
+
+ ~PluginGui();
+ void setOn(bool);
+ void updateValues();
+ };
+
+//---------------------------------------------------------
+// PluginI
+// plugin instance
+//---------------------------------------------------------
+
+#define AUDIO_IN (LADSPA_PORT_AUDIO | LADSPA_PORT_INPUT)
+#define AUDIO_OUT (LADSPA_PORT_AUDIO | LADSPA_PORT_OUTPUT)
+
+//class PluginI {
+class PluginI : public PluginIBase {
+ Plugin* _plugin;
+ int channel;
+ int instances;
+ AudioTrack* _track;
+ int _id;
+
+ LADSPA_Handle* handle; // per instance
+ Port* controls;
+ Port* controlsOut;
+
+ int controlPorts;
+ int controlOutPorts;
+ PluginGui* _gui;
+ bool _on;
+ bool initControlValues;
+ QString _name;
+ QString _label;
+
+ //#ifdef DSSI_SUPPORT
+ //StringParamMap _stringParamMap;
+ //#endif
+
+ #ifdef OSC_SUPPORT
+ OscEffectIF _oscif;
+ #endif
+ bool _showNativeGuiPending;
+
+ void init();
+ void makeGui();
+
+ public:
+ PluginI();
+ ~PluginI();
+
+ Plugin* plugin() const { return _plugin; }
+ bool on() const { return _on; }
+ void setOn(bool val) { _on = val; }
+ PluginGui* gui() const { return _gui; }
+ void deleteGui();
+
+ void setTrack(AudioTrack* t) { _track = t; }
+ AudioTrack* track() { return _track; }
+ int pluginID() { return _plugin->id(); }
+ void setID(int i);
+ int id() { return _id; }
+ void updateControllers();
+
+ bool initPluginInstance(Plugin*, int channels);
+ void setChannels(int);
+ void connect(int ports, float** src, float** dst);
+ void apply(int n);
+
+ void enableController(int i, bool v = true) { controls[i].enCtrl = v; }
+ bool controllerEnabled(int i) const { return controls[i].enCtrl; }
+ void enable2Controller(int i, bool v = true) { controls[i].en2Ctrl = v; }
+ bool controllerEnabled2(int i) const { return controls[i].en2Ctrl; }
+ void enableAllControllers(bool v = true);
+ void enable2AllControllers(bool v = true);
+
+ void activate();
+ void deactivate();
+ QString pluginLabel() const { return _plugin->label(); }
+ QString label() const { return _label; }
+ QString name() const { return _name; }
+ CtrlValueType valueType() const;
+ QString lib() const { return _plugin->lib(); }
+
+ #ifdef OSC_SUPPORT
+ OscEffectIF& oscIF() { return _oscif; }
+ /*
+ int oscConfigure(lo_arg**);
+ int oscControl(lo_arg**);
+ //int oscUpdate(lo_arg**);
+ //int oscExiting(lo_arg**);
+ */
+
+ int oscControl(unsigned long /*dssiPort*/, float /*val*/);
+ int oscConfigure(const char */*key*/, const char */*val*/);
+ int oscUpdate();
+ //int oscExiting();
+ #endif
+
+ void writeConfiguration(int level, Xml& xml);
+ bool readConfiguration(Xml& xml, bool readPreset=false);
+ bool loadControl(Xml& xml);
+ bool setControl(const QString& s, double val);
+ void showGui();
+ void showGui(bool);
+ bool isDssiPlugin() const { return _plugin->isDssiPlugin(); }
+ void showNativeGui();
+ void showNativeGui(bool);
+ bool isShowNativeGuiPending() { return _showNativeGuiPending; }
+ bool guiVisible();
+ bool nativeGuiVisible();
+ int parameters() const { return controlPorts; }
+ void setParam(int i, double val) { controls[i].tmpVal = val; }
+ double param(int i) const { return controls[i].val; }
+ double defaultValue(unsigned int param) const;
+ const char* paramName(int i) { return _plugin->portName(controls[i].idx); }
+ LADSPA_PortDescriptor portd(int i) const { return _plugin->portd(controls[i].idx); }
+ void range(int i, float* min, float* max) const {
+ _plugin->range(controls[i].idx, min, max);
+ }
+ bool isAudioIn(int k) {
+ return (_plugin->portd(k) & AUDIO_IN) == AUDIO_IN;
+ }
+ bool isAudioOut(int k) {
+ return (_plugin->portd(k) & AUDIO_OUT) == AUDIO_OUT;
+ }
+ bool inPlaceCapable() const { return _plugin->inPlaceCapable(); }
+ LADSPA_PortRangeHint range(int i) {
+ return _plugin->range(controls[i].idx);
+ }
+ };
+
+//---------------------------------------------------------
+// Pipeline
+// chain of connected efx inserts
+//---------------------------------------------------------
+
+const int PipelineDepth = 4;
+
+class Pipeline : public std::vector<PluginI*> {
+ float* buffer[MAX_CHANNELS];
+
+ public:
+ Pipeline();
+ ~Pipeline();
+
+ void insert(PluginI* p, int index);
+ void remove(int index);
+ void removeAll();
+ bool isOn(int idx) const;
+ void setOn(int, bool);
+ QString label(int idx) const;
+ QString name(int idx) const;
+ void showGui(int, bool);
+ bool isDssiPlugin(int) const;
+ void showNativeGui(int, bool);
+ void deleteGui(int idx);
+ void deleteAllGuis();
+ bool guiVisible(int);
+ bool nativeGuiVisible(int);
+ void apply(int ports, unsigned long nframes, float** buffer);
+ void move(int idx, bool up);
+ bool empty(int idx) const;
+ void setChannels(int);
+ };
+
+typedef Pipeline::iterator iPluginI;
+typedef Pipeline::const_iterator ciPluginI;
+
+//---------------------------------------------------------
+// PluginDialog
+//---------------------------------------------------------
+
+enum { SEL_SM, SEL_S, SEL_M, SEL_ALL };
+
+class PluginDialog : public QDialog {
+ QTreeWidget* pList;
+ QRadioButton* allPlug;
+ QRadioButton* onlyM;
+ QRadioButton* onlyS;
+ QRadioButton* onlySM;
+ QPushButton *okB;
+
+ Q_OBJECT
+
+ public:
+ PluginDialog(QWidget* parent=0);
+ static Plugin* getPlugin(QWidget* parent);
+ Plugin* value();
+ void accept();
+
+ public slots:
+ void fillPlugs(QAbstractButton*);
+ void fillPlugs(int i);
+ void fillPlugs(const QString& sortValue);
+
+ private slots:
+ void enableOkB();
+
+ private:
+ QComboBox *sortBox;
+ static int selectedPlugType;
+ static QStringList sortItems;
+ };
+
+extern void initPlugins();
+extern PluginList plugins;
+
+extern bool ladspaDefaultValue(const LADSPA_Descriptor* plugin, int port, float* val);
+extern void ladspaControlRange(const LADSPA_Descriptor* plugin, int i, float* min, float* max);
+extern bool ladspa2MidiControlValues(const LADSPA_Descriptor* plugin, int port, int ctlnum, int* min, int* max, int* def);
+//extern MidiController* ladspa2MidiController(const LADSPA_Descriptor* plugin, int port, int ctlnum);
+extern float midi2LadspaValue(const LADSPA_Descriptor* plugin, int port, int ctlnum, int val);
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/pos.cpp b/attic/muse2-oom/muse2/muse/pos.cpp
new file mode 100644
index 00000000..5a86673d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/pos.cpp
@@ -0,0 +1,568 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: pos.cpp,v 1.11.2.1 2006/09/19 19:07:08 spamatica Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <cmath>
+
+#include "pos.h"
+#include "xml.h"
+#include "tempo.h"
+#include "globals.h"
+///#include "sig.h"
+#include "al/sig.h"
+
+extern int mtcType;
+
+//---------------------------------------------------------
+// Pos
+//---------------------------------------------------------
+
+Pos::Pos()
+ {
+ _type = TICKS;
+ _tick = 0;
+ _frame = 0;
+ sn = -1;
+ }
+
+Pos::Pos(const Pos& p)
+ {
+ _type = p._type;
+ sn = p.sn;
+ _tick = p._tick;
+ _frame = p._frame;
+ }
+
+Pos::Pos(unsigned t, bool ticks)
+ {
+ if (ticks) {
+ _type = TICKS;
+ _tick = t;
+ }
+ else {
+ _type = FRAMES;
+ _frame = t;
+ }
+ sn = -1;
+ }
+
+Pos::Pos(const QString& s)
+ {
+ int m, b, t;
+ sscanf(s.toLatin1(), "%04d.%02d.%03d", &m, &b, &t);
+ _tick = AL::sigmap.bar2tick(m, b, t);
+ _type = TICKS;
+ sn = -1;
+ }
+
+Pos::Pos(int measure, int beat, int tick)
+ {
+ _tick = AL::sigmap.bar2tick(measure, beat, tick);
+ _type = TICKS;
+ sn = -1;
+ }
+
+Pos::Pos(int min, int sec, int frame, int subframe)
+ {
+ double time = min * 60.0 + sec;
+
+ double f = frame + subframe/100.0;
+ switch(mtcType) {
+ case 0: // 24 frames sec
+ time += f * 1.0/24.0;
+ break;
+ case 1: // 25
+ time += f * 1.0/25.0;
+ break;
+ case 2: // 30 drop frame
+ time += f * 1.0/30.0;
+ break;
+ case 3: // 30 non drop frame
+ time += f * 1.0/30.0;
+ break;
+ }
+ _type = FRAMES;
+ _frame = lrint(time * sampleRate);
+ sn = -1;
+ }
+
+//---------------------------------------------------------
+// setType
+//---------------------------------------------------------
+
+void Pos::setType(TType t)
+ {
+ if (t == _type)
+ return;
+
+ if (_type == TICKS) {
+ // convert from ticks to frames
+ _frame = tempomap.tick2frame(_tick, _frame, &sn);
+ }
+ else {
+ // convert from frames to ticks
+ _tick = tempomap.frame2tick(_frame, _tick, &sn);
+ }
+ _type = t;
+ }
+
+//---------------------------------------------------------
+// operator+=
+//---------------------------------------------------------
+
+Pos& Pos::operator+=(Pos a)
+ {
+ switch(_type) {
+ case FRAMES:
+ _frame += a.frame();
+ break;
+ case TICKS:
+ _tick += a.tick();
+ break;
+ }
+ sn = -1; // invalidate cached values
+ return *this;
+ }
+
+//---------------------------------------------------------
+// operator+=
+//---------------------------------------------------------
+
+Pos& Pos::operator+=(int a)
+ {
+ switch(_type) {
+ case FRAMES:
+ _frame += a;
+ break;
+ case TICKS:
+ _tick += a;
+ break;
+ }
+ sn = -1; // invalidate cached values
+ return *this;
+ }
+
+Pos operator+(Pos a, int b)
+ {
+ Pos c;
+ c.setType(a.type());
+ return c += b;
+ }
+
+Pos operator+(Pos a, Pos b)
+ {
+ Pos c = a;
+ return c += b;
+ }
+
+bool Pos::operator>=(const Pos& s) const
+ {
+ if (_type == FRAMES)
+ return _frame >= s.frame();
+ else
+ return _tick >= s.tick();
+ }
+
+bool Pos::operator>(const Pos& s) const
+ {
+ if (_type == FRAMES)
+ return _frame > s.frame();
+ else
+ return _tick > s.tick();
+ }
+
+bool Pos::operator<(const Pos& s) const
+ {
+ if (_type == FRAMES)
+ return _frame < s.frame();
+ else
+ return _tick < s.tick();
+ }
+
+bool Pos::operator<=(const Pos& s) const
+ {
+ if (_type == FRAMES)
+ return _frame <= s.frame();
+ else
+ return _tick <= s.tick();
+ }
+
+bool Pos::operator==(const Pos& s) const
+ {
+ if (_type == FRAMES)
+ return _frame == s.frame();
+ else
+ return _tick == s.tick();
+ }
+
+//---------------------------------------------------------
+// tick
+//---------------------------------------------------------
+
+unsigned Pos::tick() const
+ {
+ if (_type == FRAMES)
+ _tick = tempomap.frame2tick(_frame, _tick, &sn);
+ return _tick;
+ }
+
+//---------------------------------------------------------
+// frame
+//---------------------------------------------------------
+
+unsigned Pos::frame() const
+ {
+ if (_type == TICKS)
+ _frame = tempomap.tick2frame(_tick, _frame, &sn);
+ return _frame;
+ }
+
+//---------------------------------------------------------
+// setTick
+//---------------------------------------------------------
+
+void Pos::setTick(unsigned pos)
+ {
+ _tick = pos;
+ sn = -1;
+ if (_type == FRAMES)
+ _frame = tempomap.tick2frame(pos, &sn);
+ }
+
+//---------------------------------------------------------
+// setFrame
+//---------------------------------------------------------
+
+void Pos::setFrame(unsigned pos)
+ {
+ _frame = pos;
+ sn = -1;
+ if (_type == TICKS)
+ _tick = tempomap.frame2tick(pos, &sn);
+ }
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+void Pos::write(int level, Xml& xml, const char* name) const
+ {
+ xml.nput(level++, "<%s ", name);
+
+ switch(_type) {
+ case TICKS:
+ xml.nput("tick=\"%d\"", _tick);
+ break;
+ case FRAMES:
+ xml.nput("frame=\"%d\"", _frame);
+ break;
+ }
+ xml.put(" />", name);
+ }
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+void Pos::read(Xml& xml, const char* name)
+ {
+ sn = -1;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+
+ case Xml::TagStart:
+ xml.unknown(name);
+ break;
+
+ case Xml::Attribut:
+ if (tag == "tick") {
+ _tick = xml.s2().toInt();
+ _type = TICKS;
+ }
+ else if (tag == "frame") {
+ _frame = xml.s2().toInt();
+ _type = FRAMES;
+ }
+ else if (tag == "sample") { // obsolete
+ _frame = xml.s2().toInt();
+ _type = FRAMES;
+ }
+ else
+ xml.unknown(name);
+ break;
+
+ case Xml::TagEnd:
+ if (tag == name)
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// PosLen
+//---------------------------------------------------------
+
+PosLen::PosLen()
+ {
+ _lenTick = 0;
+ _lenFrame = 0;
+ sn = -1;
+ }
+
+PosLen::PosLen(const PosLen& p)
+ : Pos(p)
+ {
+ _lenTick = p._lenTick;
+ _lenFrame = p._lenFrame;
+ sn = -1;
+ }
+
+//---------------------------------------------------------
+// dump
+//---------------------------------------------------------
+
+void PosLen::dump(int n) const
+ {
+ Pos::dump(n);
+ printf(" Len(");
+ switch(type()) {
+ case FRAMES:
+ printf("samples=%d)\n", _lenFrame);
+ break;
+ case TICKS:
+ printf("ticks=%d)\n", _lenTick);
+ break;
+ }
+ }
+
+void Pos::dump(int /*n*/) const
+ {
+ printf("Pos(%s, sn=%d, ", type() == FRAMES ? "Frames" : "Ticks", sn);
+ switch(type()) {
+ case FRAMES:
+ printf("samples=%d)", _frame);
+ break;
+ case TICKS:
+ printf("ticks=%d)", _tick);
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+void PosLen::write(int level, Xml& xml, const char* name) const
+ {
+ xml.nput(level++, "<%s ", name);
+
+ switch(type()) {
+ case TICKS:
+ xml.nput("tick=\"%d\" len=\"%d\"", tick(), _lenTick);
+ break;
+ case FRAMES:
+ xml.nput("sample=\"%d\" len=\"%d\"", frame(), _lenFrame);
+ break;
+ }
+ xml.put(" />", name);
+ }
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+void PosLen::read(Xml& xml, const char* name)
+ {
+ sn = -1;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+
+ case Xml::TagStart:
+ xml.unknown(name);
+ break;
+
+ case Xml::Attribut:
+ if (tag == "tick") {
+ setType(TICKS);
+ setTick(xml.s2().toInt());
+ }
+ else if (tag == "sample") {
+ setType(FRAMES);
+ setFrame(xml.s2().toInt());
+ }
+ else if (tag == "len") {
+ int n = xml.s2().toInt();
+ switch(type()) {
+ case TICKS:
+ setLenTick(n);
+ break;
+ case FRAMES:
+ setLenFrame(n);
+ break;
+ }
+ }
+ else
+ xml.unknown(name);
+ break;
+
+ case Xml::TagEnd:
+ if (tag == name)
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// setLenTick
+//---------------------------------------------------------
+
+void PosLen::setLenTick(unsigned len)
+ {
+ _lenTick = len;
+ sn = -1;
+// if (type() == FRAMES)
+ _lenFrame = tempomap.deltaTick2frame(tick(), tick() + len, &sn);
+ }
+
+//---------------------------------------------------------
+// setLenFrame
+//---------------------------------------------------------
+
+void PosLen::setLenFrame(unsigned len)
+ {
+ _lenFrame = len;
+ sn = -1;
+// if (type() == TICKS)
+ _lenTick = tempomap.deltaFrame2tick(frame(), frame() + len, &sn);
+ }
+
+//---------------------------------------------------------
+// lenTick
+//---------------------------------------------------------
+
+unsigned PosLen::lenTick() const
+ {
+ if (type() == FRAMES)
+ _lenTick = tempomap.deltaFrame2tick(frame(), frame() + _lenFrame, &sn);
+ return _lenTick;
+ }
+
+//---------------------------------------------------------
+// lenFrame
+//---------------------------------------------------------
+
+unsigned PosLen::lenFrame() const
+ {
+ if (type() == TICKS)
+ _lenFrame = tempomap.deltaTick2frame(tick(), tick() + _lenTick, &sn);
+ return _lenFrame;
+ }
+
+//---------------------------------------------------------
+// end
+//---------------------------------------------------------
+
+Pos PosLen::end() const
+ {
+ Pos pos(*this);
+ pos.invalidSn();
+ switch(type()) {
+ case FRAMES:
+ pos.setFrame(pos.frame() + _lenFrame);
+ break;
+ case TICKS:
+ pos.setTick(pos.tick() + _lenTick);
+ break;
+ }
+ return pos;
+ }
+
+//---------------------------------------------------------
+// setPos
+//---------------------------------------------------------
+
+void PosLen::setPos(const Pos& pos)
+ {
+ switch(pos.type()) {
+ case FRAMES:
+ setFrame(pos.frame());
+ break;
+ case TICKS:
+ setTick(pos.tick());
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// mbt
+//---------------------------------------------------------
+
+void Pos::mbt(int* bar, int* beat, int* tk) const
+ {
+ AL::sigmap.tickValues(tick(), bar, beat, (unsigned*)tk);
+ }
+
+//---------------------------------------------------------
+// msf
+//---------------------------------------------------------
+
+void Pos::msf(int* min, int* sec, int* fr, int* subFrame) const
+ {
+ double time = double(frame()) / double(sampleRate);
+ *min = int(time) / 60;
+ *sec = int(time) % 60;
+ double rest = time - (*min * 60 + *sec);
+ switch(mtcType) {
+ case 0: // 24 frames sec
+ rest *= 24;
+ break;
+ case 1: // 25
+ rest *= 25;
+ break;
+ case 2: // 30 drop frame
+ rest *= 30;
+ break;
+ case 3: // 30 non drop frame
+ rest *= 30;
+ break;
+ }
+ *fr = int(rest);
+ *subFrame = int((rest- *fr)*100);
+ }
+
+//---------------------------------------------------------
+// isValid
+//---------------------------------------------------------
+
+bool Pos::isValid(int,int,int)
+ {
+ return true;
+ }
+
+//---------------------------------------------------------
+// isValid
+//---------------------------------------------------------
+
+bool Pos::isValid(int,int,int,int)
+ {
+ return true;
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/pos.h b/attic/muse2-oom/muse2/muse/pos.h
new file mode 100644
index 00000000..33c08f6b
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/pos.h
@@ -0,0 +1,99 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: pos.h,v 1.8 2004/07/14 15:27:26 wschweer Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __POS_H__
+#define __POS_H__
+
+class Xml;
+class QString;
+
+//---------------------------------------------------------
+// Pos
+// depending on type _tick or _frame is a cached
+// value. When the tempomap changes, all cached values
+// are invalid. Sn is used to check for tempomap
+// changes.
+//---------------------------------------------------------
+
+class Pos {
+ public:
+ enum TType { TICKS, FRAMES };
+
+ private:
+ TType _type;
+ mutable int sn;
+ mutable unsigned _tick;
+ mutable unsigned _frame;
+
+ public:
+ Pos();
+ Pos(const Pos&);
+ Pos(int,int,int);
+ Pos(int,int,int,int);
+ Pos(unsigned, bool ticks=true);
+ Pos(const QString&);
+ void dump(int n = 0) const;
+ void mbt(int*, int*, int*) const;
+ void msf(int*, int*, int*, int*) const;
+
+ void invalidSn() { sn = -1; }
+
+ TType type() const { return _type; }
+ void setType(TType t);
+
+ Pos& operator+=(Pos a);
+ Pos& operator+=(int a);
+
+ bool operator>=(const Pos& s) const;
+ bool operator>(const Pos& s) const;
+ bool operator<(const Pos& s) const;
+ bool operator<=(const Pos& s) const;
+ bool operator==(const Pos& s) const;
+
+ friend Pos operator+(Pos a, Pos b);
+ friend Pos operator+(Pos a, int b);
+
+ unsigned tick() const;
+ unsigned frame() const;
+ void setTick(unsigned);
+ void setFrame(unsigned);
+
+ void write(int level, Xml&, const char*) const;
+ void read(Xml& xml, const char*);
+ bool isValid() const { return true; }
+ static bool isValid(int m, int b, int t);
+ static bool isValid(int, int, int, int);
+ };
+
+//---------------------------------------------------------
+// PosLen
+//---------------------------------------------------------
+
+class PosLen : public Pos {
+ mutable unsigned _lenTick;
+ mutable unsigned _lenFrame;
+ mutable int sn;
+
+ public:
+ PosLen();
+ PosLen(const PosLen&);
+ void dump(int n = 0) const;
+
+ void write(int level, Xml&, const char*) const;
+ void read(Xml& xml, const char*);
+ void setLenTick(unsigned);
+ void setLenFrame(unsigned);
+ unsigned lenTick() const;
+ unsigned lenFrame() const;
+ Pos end() const;
+ unsigned endTick() const { return end().tick(); }
+ unsigned endFrame() const { return end().frame(); }
+ void setPos(const Pos&);
+ };
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/remote/CMakeLists.txt b/attic/muse2-oom/muse2/muse/remote/CMakeLists.txt
new file mode 100644
index 00000000..87ad9672
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/remote/CMakeLists.txt
@@ -0,0 +1,58 @@
+#=============================================================================
+# MusE
+# Linux Music Editor
+# $Id:$
+#
+# Copyright (C) 2002-2006 by Werner Schweer and others
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#=============================================================================
+
+##
+## List of source files to compile
+##
+file (GLOB remote_source_files
+ pyapi.cpp
+ )
+
+##
+## Define target
+##
+add_library(remote SHARED
+ ${remote_source_files}
+ ${PROJECT_BINARY_DIR}/all.h.pch
+ )
+
+##
+## Append to the list of translations
+##
+set (FILES_TO_TRANSLATE
+ ${FILES_TO_TRANSLATE}
+ ${remote_source_files}
+ CACHE INTERNAL ""
+ )
+
+##
+## Compilation flags and target name
+##
+set_source_files_properties(
+ pyapi.cpp
+ PROPERTIES COMPILE_FLAGS "-fPIC -include ${PROJECT_BINARY_DIR}/all.h -include ${PYTHON_INCLUDES} -DENABLE_PYTHON"
+ )
+
+##
+## Install location
+##
+install(TARGETS remote
+ DESTINATION ${MusE_MODULES_DIR}
+ )
diff --git a/attic/muse2-oom/muse2/muse/remote/pyapi.cpp b/attic/muse2-oom/muse2/muse/remote/pyapi.cpp
new file mode 100644
index 00000000..84543b18
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/remote/pyapi.cpp
@@ -0,0 +1,1140 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// (C) Copyright 2009 Mathias Gyllengahm (lunar_shuttle@users.sf.net)
+//=========================================================
+#include <Python.h>
+#include <iostream>
+#include <fstream>
+#include <string>
+#include <pthread.h>
+
+#include <QApplication>
+
+#include "pyapi.h"
+#include "song.h"
+#include "tempo.h"
+#include "track.h"
+#include "audio.h"
+#include "gconfig.h"
+#include "midictrl.h"
+#include "midiport.h"
+#include "plugin.h"
+#include "midi.h"
+#include "app.h"
+
+// Steals ref: PyList_SetItem, PyTuple_SetItem
+using namespace std;
+
+static pthread_t pyapiThread;
+//------------------------------------------------------------
+QPybridgeEvent::QPybridgeEvent(QPybridgeEvent::EventType _type, int _p1, int _p2)
+ :QEvent(QEvent::User),
+ type(_type),
+ p1(_p1),
+ p2(_p2)
+{
+}
+//------------------------------------------------------------
+// Get current position
+//------------------------------------------------------------
+PyObject* getCPos(PyObject*, PyObject*)
+{
+ return Py_BuildValue("i", song->cpos());
+}
+//------------------------------------------------------------
+// Get position of left locator
+//------------------------------------------------------------
+PyObject* getLPos(PyObject*, PyObject*)
+{
+ return Py_BuildValue("i", song->lpos());
+}
+//------------------------------------------------------------
+// Get position of right locator
+//------------------------------------------------------------
+PyObject* getRPos(PyObject*, PyObject*)
+{
+ return Py_BuildValue("i", song->rpos());
+}
+//------------------------------------------------------------
+// Start playing from current position
+//------------------------------------------------------------
+PyObject* startPlay(PyObject*, PyObject*)
+{
+ //song->setPlay(true);
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_SETPLAY);
+ QApplication::postEvent(song, pyevent);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+//------------------------------------------------------------
+// Stop playing
+//------------------------------------------------------------
+PyObject* stopPlay(PyObject*, PyObject*)
+{
+ //song->setStop(true);
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_SETSTOP);
+ QApplication::postEvent(song, pyevent);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+//------------------------------------------------------------
+// Rewind to start
+//------------------------------------------------------------
+PyObject* rewindStart(PyObject*, PyObject*)
+{
+ //song->rewindStart();
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_REWIND);
+ QApplication::postEvent(song, pyevent);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+//------------------------------------------------------------
+// Get tempo at specific position
+//------------------------------------------------------------
+PyObject* getTempo(PyObject*, PyObject* args)
+{
+ int tick;
+ if (!PyArg_ParseTuple(args, "i", &tick)) {
+ return Py_BuildValue("i", 1000);
+ }
+
+ int tempovalue = tempomap.tempo(tick);
+ return Py_BuildValue("i", tempovalue);
+}
+//------------------------------------------------------------
+// Get track names
+//------------------------------------------------------------
+PyObject* getTrackNames(PyObject*, PyObject*)
+{
+ TrackList* tracks = song->tracks();
+ PyObject* res = Py_BuildValue("[]");
+ for (ciTrack t = tracks->begin(); t != tracks->end(); ++t) {
+ Track* track = *t;
+ PyObject* ptrackname = Py_BuildValue("s", track->name().toLatin1());
+ PyList_Append(res, ptrackname);
+ Py_DECREF(ptrackname);
+ }
+
+ return res;
+}
+//------------------------------------------------------------
+// Find part by serial nr
+//------------------------------------------------------------
+Part* findPartBySerial(int sn)
+{
+ TrackList* tracks = song->tracks();
+ for (ciTrack t = tracks->begin(); t != tracks->end(); ++t) {
+ Track* track = *t;
+ PartList* parts = track->parts();
+ for (ciPart p = parts->begin(); p != parts->end(); p++) {
+ Part* part = p->second;
+ if (part->sn() == sn)
+ return part;
+ }
+ }
+
+ return NULL;
+}
+//------------------------------------------------------------
+// Get parts from track
+//------------------------------------------------------------
+PyObject* getParts(PyObject*, PyObject* args)
+{
+ TrackList* tracks = song->tracks();
+ const char* trackname;
+ if (!PyArg_ParseTuple(args, "s", &trackname)) {
+ return NULL;
+ }
+
+ PyObject* pyparts = Py_BuildValue("[]");
+ for (ciTrack t = tracks->begin(); t != tracks->end(); ++t) {
+ Track* track = *t;
+ if (track->name() != trackname)
+ continue;
+
+ PartList* parts = track->parts();
+ for (ciPart p = parts->begin(); p != parts->end(); p++) {
+ Part* part = p->second;
+
+ MidiPart* mpart = (MidiPart*) part;
+ PyObject* pypart = PyDict_New();
+ int tick = mpart->tick();
+ int lentick = mpart->lenTick();
+ int serialnr = mpart->sn();
+ PyObject* pstrtick = Py_BuildValue("s","tick");
+ PyObject* pitick = Py_BuildValue("i", tick);
+ PyObject* pstrid = Py_BuildValue("s","id");
+ PyObject* pstrserial = Py_BuildValue("i", serialnr);
+ PyObject* pstrlen = Py_BuildValue("s","len");
+ PyObject* pstrtick2 = Py_BuildValue("i", lentick);
+
+ PyDict_SetItem(pypart, pstrtick, pitick);
+ PyDict_SetItem(pypart, pstrid, pstrserial);
+ PyDict_SetItem(pypart, pstrlen, pstrtick2);
+
+ Py_DECREF(pstrtick);
+ Py_DECREF(pitick);
+ Py_DECREF(pstrid);
+ Py_DECREF(pstrserial);
+ Py_DECREF(pstrlen);
+ Py_DECREF(pstrtick2);
+
+ // Pack midi events into list before wrapping it all up
+ EventList* events = mpart->events();
+ PyObject* pyevents = Py_BuildValue("[]");
+ for (ciEvent e = events->begin(); e != events->end(); e++) {
+ PyObject* pyevent = PyDict_New(); // The event structure - a dictionary with keys 'type','tick','data'
+
+ const Event& event = e->second;
+ unsigned tick = e->first;
+ PyObject* eventdata = Py_BuildValue("[i,i,i]", event.dataA(), event.dataB(), event.dataC());
+ PyObject* pstrdata = Py_BuildValue("s", "data");
+ pstrtick = Py_BuildValue("s", "tick");
+ PyObject* pitickval = Py_BuildValue("i", tick);
+ PyDict_SetItem(pyevent, pstrdata, eventdata);
+ PyDict_SetItem(pyevent, pstrtick, pitickval);
+ Py_DECREF(eventdata);
+ Py_DECREF(pstrdata);
+ Py_DECREF(pstrtick);
+ Py_DECREF(pitickval);
+
+ switch(event.type()) {
+ case Note: {
+ PyObject* pstrtype = Py_BuildValue("s", "type");
+ PyObject* pstrnote = Py_BuildValue("s", "note");
+ PyObject* pstrlen = Py_BuildValue("s", "len");
+ PyObject* pilentick = Py_BuildValue("i", event.lenTick());
+ PyDict_SetItem(pyevent, pstrtype, pstrnote);
+ PyDict_SetItem(pyevent, pstrlen, pilentick);
+ Py_DECREF(pstrtype);
+ Py_DECREF(pstrnote);
+ Py_DECREF(pstrlen);
+ Py_DECREF(pilentick);
+ break;
+ }
+ case Controller: {
+ PyObject* pstrtype = Py_BuildValue("s", "type");
+ PyObject* pstrctrl = Py_BuildValue("s", "ctrl");
+ PyDict_SetItem(pyevent, pstrtype, pstrctrl);
+ Py_DECREF(pstrtype);
+ Py_DECREF(pstrctrl);
+ break;
+ }
+ default:
+ printf("Event type not supported yet: %d\n", event.type());
+ break;
+ }
+ PyList_Append(pyevents, pyevent);
+ Py_DECREF(pyevent);
+ }
+ Py_DECREF(pyevents);
+ // Add the event list to the pypart dictionary
+ PyObject* pystrevents = Py_BuildValue("s", "events");
+ PyDict_SetItem(pypart, pystrevents, pyevents);
+ Py_DECREF(pystrevents);
+ PyList_Append(pyparts, pypart);
+ Py_DECREF(pypart);
+ }
+
+ return pyparts;
+ }
+
+ return NULL;
+}
+
+//------------------------------------------------------------
+// parsePythonPart
+// get part id/serialno from python part structure
+//------------------------------------------------------------
+int getPythonPartId(PyObject* part)
+{
+ PyObject* pyid = PyDict_GetItemString(part, "id");
+ int id = PyInt_AsLong(pyid);
+ return id;
+}
+
+//------------------------------------------------------------
+// addPyPartEventsToMusePart
+// parse events from python part structure into muse part
+//------------------------------------------------------------
+bool addPyPartEventsToMusePart(MidiPart* npart, PyObject* part)
+{
+ PyObject* events;
+
+ if (PyDict_Check(part) == false) {
+ printf("Not a dict!\n");
+ return false;
+ }
+ PyObject* pstrevents = Py_BuildValue("s","events");
+ if (PyDict_Contains(part, pstrevents) == false) {
+ Py_DECREF(pstrevents);
+ printf("No events in part data...\n");
+ return false;
+ }
+ Py_DECREF(pstrevents);
+
+ events = PyDict_GetItemString(part, "events");
+
+ if (PyList_Check(events) == false) {
+ printf("Events not a list!\n");
+ return false;
+ }
+
+ //
+ // Go through event list, create MusE events of them and add to new part
+ //
+ Py_ssize_t len = PyList_Size(events);
+ for (Py_ssize_t i=0; i<len; i++) {
+ PyObject* pevent = PyList_GetItem(events, i);
+ if (PyDict_Check(pevent) == false) {
+ printf("Event is not a dictionary!\n");
+ return false;
+ }
+ PyObject* p_etick = PyDict_GetItemString(pevent, "tick");
+ PyObject* p_type = PyDict_GetItemString(pevent, "type");
+ PyObject* p_len = PyDict_GetItemString(pevent, "len");
+ PyObject* p_data = PyDict_GetItemString(pevent, "data"); // list
+
+ int etick = PyInt_AsLong(p_etick);
+ int elen = PyInt_AsLong(p_len);
+ string type = string(PyString_AsString(p_type));
+ int data[3];
+
+ // Traverse data list:
+ for (int j=0; j<3; j++) {
+ PyObject* plItem = PyList_GetItem(p_data, j);
+ data[j] = PyInt_AsLong(plItem);
+ }
+ if (type == "note" || type == "ctrl") {
+ Event event(Note);
+ event.setA(data[0]);
+ event.setB(data[1]);
+ event.setC(data[2]);
+ event.setTick(etick);
+ event.setLenTick(elen);
+ npart->events()->add(event);
+ }
+ else
+ printf("Unhandled event type from python: %s\n", type.c_str());
+ }
+
+ return true;
+}
+//------------------------------------------------------------
+// Create a new part at a particular tick and track
+//------------------------------------------------------------
+PyObject* createPart(PyObject*, PyObject* args)
+{
+ const char* trackname;
+ unsigned tick, tickLen;
+ PyObject* part;
+
+ if (!PyArg_ParseTuple(args, "siiO", &trackname, &tick, &tickLen, &part)) {
+ return NULL;
+ }
+
+ QString qtrackname(trackname);
+ MidiTrack* track = (MidiTrack*) song->findTrack(trackname);
+ if (track == NULL)
+ return NULL;
+
+ MidiPart* npart = new MidiPart(track);
+ npart->setTick(tick);
+ npart->setLenTick(tickLen);
+ addPyPartEventsToMusePart(npart, part);
+
+ song->addPart(npart);
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_UPDATE, SC_TRACK_MODIFIED);
+ QApplication::postEvent(song, pyevent);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+//------------------------------------------------------------
+// Modify a particular part:
+// args: new part data, old part data is used from the part with the same id as the one sent here
+// TODO: Lots and lots of refcount stuff
+//------------------------------------------------------------
+PyObject* modifyPart(PyObject*, PyObject* part)
+{
+ int id = getPythonPartId(part);
+
+ Part* opart = NULL;
+ // Verify a part with that id actually exists, then get it
+ TrackList* tracks = song->tracks();
+ for (ciTrack t = tracks->begin(); t != tracks->end(); ++t) {
+ Track* track = *t;
+ for (ciPart p = track->parts()->begin(); p != track->parts()->end(); p++) {
+ if (p->second->sn() == id) {
+ opart = p->second;
+ break;
+ }
+ }
+ }
+
+ if (opart == NULL) {
+ printf("Part doesn't exist!\n");
+ return NULL;
+ }
+
+ // Remove all note and controller events from current part eventlist
+ std::list< std::pair<const unsigned, Event> > elist;
+ MidiPart* npart = new MidiPart((MidiTrack*)opart->track());
+ npart->setTick(opart->tick());
+ npart->setLenTick(opart->lenTick());
+ npart->setSn(opart->sn());
+
+ for (iEvent e = opart->events()->begin(); e != opart->events()->end(); e++) {
+ Event& event = e->second;
+ if (event.type() == Note || event.type() == Controller)
+ continue;
+
+ npart->events()->add(event);
+ }
+
+ addPyPartEventsToMusePart(npart, part);
+
+ //song->startUndo();
+ song->changePart(opart, npart);
+ //song->endUndo(SC_TRACK_MODIFIED | SC_PART_MODIFIED | SC_PART_INSERTED); // Crash! Probably since the call ends up in Qt GUI thread from this thread
+
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_UPDATE, SC_TRACK_MODIFIED | SC_PART_MODIFIED | SC_PART_INSERTED);
+ QApplication::postEvent(song, pyevent);
+
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+//------------------------------------------------------------
+// deletePart
+// delete part by serial nr
+//------------------------------------------------------------
+PyObject* deletePart(PyObject*, PyObject* args)
+{
+ int id;
+ if (!PyArg_ParseTuple(args, "i", &id)) {
+ return NULL;
+ }
+
+ Part* part = findPartBySerial(id);
+ if (part == NULL)
+ return NULL;
+
+ song->removePart(part);
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_UPDATE, SC_TRACK_MODIFIED | SC_PART_REMOVED);
+ QApplication::postEvent(song, pyevent);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+//------------------------------------------------------------
+// setPos
+//------------------------------------------------------------
+PyObject* setPos(PyObject*, PyObject* args)
+{
+ int index;
+ int ticks;
+ if (!PyArg_ParseTuple(args, "ii", &index, &ticks)) {
+ return NULL;
+ }
+
+ //song->setPos(index, ticks);
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_POSCHANGE, index, ticks);
+ QApplication::postEvent(song, pyevent);
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+
+//------------------------------------------------------------
+// setLen
+//------------------------------------------------------------
+PyObject* setSongLen(PyObject*, PyObject* args)
+{
+ unsigned len;
+
+ if (!PyArg_ParseTuple(args, "i", &len)) {
+ return NULL;
+ }
+ //song->setLen(len);// Appears to not be ok to call from python thread, we do it with event instead
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONGLEN_CHANGE, len);
+ QApplication::postEvent(song, pyevent);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+//------------------------------------------------------------
+// getLen
+//------------------------------------------------------------
+PyObject* getSongLen(PyObject*, PyObject*)
+{
+ PyObject* pylen = Py_BuildValue("i", song->len());
+
+ return pylen;
+}
+//------------------------------------------------------------
+// getDivision
+//------------------------------------------------------------
+PyObject* getDivision(PyObject*, PyObject*)
+{
+ return Py_BuildValue("i", config.division);
+}
+//------------------------------------------------------------
+// setTrackParameter
+//------------------------------------------------------------
+PyObject* setMidiTrackParameter(PyObject*, PyObject* args)
+{
+ const char* trackname;
+ const char* paramname;
+ int value;
+ if(!PyArg_ParseTuple(args, "ssi", &trackname, &paramname, &value))
+ return NULL;
+
+ Track* track = song->findTrack(QString(trackname));
+ if (track == NULL)
+ return NULL;
+
+ MidiTrack* mt = (MidiTrack*) track;
+
+ QString qparamname(paramname);
+ bool changed = false;
+ if (qparamname == "velocity") {
+ changed = true;
+ mt->velocity = value;
+ }
+ else if (qparamname == "compression") {
+ changed = true;
+ mt->compression = value;
+ }
+ else if (qparamname == "transposition") {
+ changed = true;
+ mt->transposition = value;
+ }
+ else if (qparamname == "delay") {
+ changed = true;
+ mt->delay = value;
+ }
+
+ if (changed) {
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_UPDATE, SC_TRACK_MODIFIED);
+ QApplication::postEvent(song, pyevent);
+ }
+
+ return Py_BuildValue("b", changed); // true/false depending on whether anythin was changed
+}
+//------------------------------------------------------------
+// Set loop
+//------------------------------------------------------------
+PyObject* setLoop(PyObject*, PyObject* args)
+{
+ bool loopFlag;
+ if(!PyArg_ParseTuple(args, "b", &loopFlag))
+ return NULL;
+
+ song->setLoop(loopFlag);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+//------------------------------------------------------------
+// Get loop value
+//------------------------------------------------------------
+PyObject* getLoop(PyObject*, PyObject*)
+{
+ return Py_BuildValue("b", song->getLoop());
+}
+//------------------------------------------------------------
+// getMute trackname
+//------------------------------------------------------------
+PyObject* getMute(PyObject*, PyObject* args)
+{
+ const char* trackname;
+ if (!PyArg_ParseTuple(args, "s", &trackname)) {
+ return NULL;
+ }
+
+ Track* track = song->findTrack(QString(trackname));
+ if (track == NULL)
+ return NULL;
+
+ return Py_BuildValue("b", track->isMute());
+}
+//------------------------------------------------------------
+// setMute (trackname, boolean)
+//------------------------------------------------------------
+PyObject* setMute(PyObject*, PyObject* args)
+{
+ const char* trackname;
+ bool muted;
+
+ if (!PyArg_ParseTuple(args, "sb", &trackname, &muted)) {
+ return NULL;
+ }
+
+ Track* track = song->findTrack(QString(trackname));
+ if (track == NULL)
+ return NULL;
+
+ int mutedint = 1;
+ if (muted == false)
+ mutedint = 0;
+
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_SETMUTE, mutedint);
+ pyevent->setS1(trackname);
+ QApplication::postEvent(song, pyevent);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+//------------------------------------------------------------
+// setController
+//------------------------------------------------------------
+void setController(const char* trackname, int ctrltype, int ctrlval)
+{
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_SETCTRL, ctrltype, ctrlval);
+ pyevent->setS1(trackname);
+ QApplication::postEvent(song, pyevent);
+}
+
+//------------------------------------------------------------
+// setMidiControllerValue
+//------------------------------------------------------------
+PyObject* setMidiControllerValue(PyObject*, PyObject* args)
+{
+ const char* trackname;
+ int ctrltype;
+ int value;
+
+ if (!PyArg_ParseTuple(args, "sii", &trackname, &ctrltype, &value)) {
+ return NULL;
+ }
+
+ setController(trackname, ctrltype, value);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+//------------------------------------------------------------
+// getMidiControllerValue
+//------------------------------------------------------------
+PyObject* getMidiControllerValue(PyObject*, PyObject* args)
+{
+ const char* trackname;
+ int ctrltype;
+
+ if (!PyArg_ParseTuple(args, "si", &trackname, &ctrltype)) {
+ return NULL;
+ }
+
+ Track* t = song->findTrack(QString(trackname));
+ if (t == NULL)
+ return NULL;
+
+ if (t->isMidiTrack() == false) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
+
+ MidiTrack* track = (MidiTrack*) t;
+ int channel = track->outChannel();
+ int outport = track->outPort();
+ MidiPort* mp = &midiPorts[outport];
+ if (mp == NULL)
+ return Py_BuildValue("i", -1);
+
+ int value = mp->hwCtrlState(channel, ctrltype);
+ return Py_BuildValue("i", value);
+}
+//------------------------------------------------------------
+// setAudioTrackVolume
+//------------------------------------------------------------
+PyObject* setAudioTrackVolume(PyObject*, PyObject* args)
+{
+ const char* trackname;
+ double volume = 0.0f;
+
+ if (!PyArg_ParseTuple(args, "sd", &trackname, &volume)) {
+ return NULL;
+ }
+
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_SETAUDIOVOL);
+ pyevent->setD1(volume);
+ pyevent->setS1(trackname);
+ QApplication::postEvent(song, pyevent);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+//------------------------------------------------------------
+// getAudioTrackVolume
+//------------------------------------------------------------
+PyObject* getAudioTrackVolume(PyObject*, PyObject* args)
+{
+ const char* trackname;
+
+ if (!PyArg_ParseTuple(args, "s", &trackname)) {
+ return NULL;
+ }
+
+ Track* t = song->findTrack(QString(trackname));
+ if (t == NULL)
+ return NULL;
+
+ if (t->type() == Track::DRUM || t->type() == Track::MIDI)
+ return NULL;
+
+ AudioTrack* track = (AudioTrack*) t;
+ return Py_BuildValue("d", track->volume());
+}
+
+//------------------------------------------------------------
+// getSelectedTrack
+//------------------------------------------------------------
+PyObject* getSelectedTrack(PyObject*, PyObject*)
+{
+ TrackList* tracks = song->tracks();
+ for (ciTrack t = tracks->begin(); t != tracks->end(); ++t) {
+ Track* track = *t;
+ if (track->selected())
+ return Py_BuildValue("s", track->name().toLatin1());
+ }
+
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+
+//------------------------------------------------------------
+// importPart
+//------------------------------------------------------------
+PyObject* importPart(PyObject*, PyObject* args)
+{
+ const char* trackname;
+ const char* filename;
+ int tick;
+
+ if (!PyArg_ParseTuple(args, "ssi", &trackname, &filename, &tick)) {
+ return NULL;
+ }
+
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_IMPORT_PART, tick);
+ pyevent->setS1(trackname);
+ pyevent->setS2(filename);
+ QApplication::postEvent(song, pyevent);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+//------------------------------------------------------------
+// getTrackEffects
+//------------------------------------------------------------
+PyObject* getTrackEffects(PyObject*, PyObject* args)
+{
+ const char* trackname;
+ if (!PyArg_ParseTuple(args, "s", &trackname)) {
+ return NULL;
+ }
+
+ Track* t = song->findTrack(QString(trackname));
+ if (t == NULL)
+ return NULL;
+
+ if (t->type() != Track::WAVE)
+ return NULL;
+
+ AudioTrack* track = (AudioTrack*) t;
+ PyObject* pyfxnames = Py_BuildValue("[]");
+ const Pipeline* pipeline = track->efxPipe();
+ for (int i = 0; i < PipelineDepth; i++) {
+ QString name = pipeline->name(i);
+ printf("fx %d name: %s\n", i, name.toLatin1());
+ PyObject* pyname = Py_BuildValue("s", name.toLatin1());
+ PyList_Append(pyfxnames, pyname);
+ Py_DECREF(pyname);
+ }
+
+ return pyfxnames;
+}
+//------------------------------------------------------------
+// toggleTrackEffect
+//------------------------------------------------------------
+PyObject* toggleTrackEffect(PyObject*, PyObject* args)
+{
+ const char* trackname;
+ int fxid;
+ bool onoff;
+
+ if (!PyArg_ParseTuple(args, "sib", &trackname, &fxid, &onoff))
+ return NULL;
+
+ Track* t = song->findTrack(QString(trackname));
+ if (t == NULL)
+ return NULL;
+
+ if (t->type() != Track::WAVE)
+ return NULL;
+
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_TOGGLE_EFFECT, fxid, onoff);
+ pyevent->setS1(trackname);
+
+ QApplication::postEvent(song, pyevent);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+//------------------------------------------------------------
+// changeTrackName
+//------------------------------------------------------------
+PyObject* changeTrackName(PyObject*, PyObject* args)
+{
+ const char* trackname;
+ const char* newname;
+
+ if (!PyArg_ParseTuple(args, "ss", &trackname, &newname))
+ return NULL;
+
+ Track* t = song->findTrack(QString(trackname));
+ if (t == NULL)
+ return Py_BuildValue("b", false);
+
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_CHANGE_TRACKNAME);
+ pyevent->setS1(trackname);
+ pyevent->setS2(newname);
+ QApplication::postEvent(song, pyevent);
+ QPybridgeEvent* pyevent2 = new QPybridgeEvent(QPybridgeEvent::SONG_UPDATE, SC_TRACK_MODIFIED);
+ QApplication::postEvent(song, pyevent2);
+ return Py_BuildValue("b", true);
+}
+//------------------------------------------------------------
+// addMidiTrack
+//------------------------------------------------------------
+PyObject* addMidiTrack(PyObject*, PyObject*)
+{
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_ADD_TRACK, Track::MIDI);
+ QApplication::postEvent(song, pyevent);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+//------------------------------------------------------------
+// addWaveTrack
+//------------------------------------------------------------
+PyObject* addWaveTrack(PyObject*, PyObject*)
+{
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_ADD_TRACK, Track::WAVE);
+ QApplication::postEvent(song, pyevent);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+//------------------------------------------------------------
+// addInput
+//------------------------------------------------------------
+PyObject* addInput(PyObject*, PyObject*)
+{
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_ADD_TRACK, Track::AUDIO_INPUT);
+ QApplication::postEvent(song, pyevent);
+ Py_INCREF(Py_None);
+ return Py_None;
+}
+//------------------------------------------------------------
+// addOutput
+//------------------------------------------------------------
+PyObject* addOutput(PyObject*, PyObject*)
+{
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_ADD_TRACK, Track::AUDIO_OUTPUT);
+ QApplication::postEvent(song, pyevent);
+ return Py_None;
+}
+//------------------------------------------------------------
+// addGroup
+//------------------------------------------------------------
+PyObject* addGroup(PyObject*, PyObject*)
+{
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_ADD_TRACK, Track::AUDIO_GROUP);
+ QApplication::postEvent(song, pyevent);
+ return Py_None;
+}
+//------------------------------------------------------------
+// deleteTrack
+//------------------------------------------------------------
+PyObject* deleteTrack(PyObject*, PyObject* args)
+{
+ const char* trackname;
+
+ if (!PyArg_ParseTuple(args, "s", &trackname))
+ return NULL;
+
+ QPybridgeEvent* pyevent = new QPybridgeEvent(QPybridgeEvent::SONG_DELETE_TRACK);
+ pyevent->setS1(trackname);
+ QApplication::postEvent(song, pyevent);
+ return Py_None;
+}
+//------------------------------------------------------------
+// getOutputRoute
+//------------------------------------------------------------
+/*
+PyObject* getOutputRoute(PyObject*, PyObject* args)
+{
+ const char* trackname;
+
+ if (!PyArg_ParseTuple(args, "s", &trackname))
+ return NULL;
+
+ Track* tt = song->findTrack(QString(trackname));
+ if (tt == NULL)
+ return Py_BuildValue("b", false);
+
+ PyObject* routes = Py_BuildValue("[]");
+ if (tt->type() == Track::WAVE && tt->type() == Track::AUDIO_AUX) {
+ AudioTrack* t = (AudioTrack*)tt;
+ RouteList* r = t->outRoutes();
+
+ OutputList* al = song->outputs();
+ for (iAudioOutput i = al->begin(); i != al->end(); ++i) {
+ Track* track = *i;
+ if (t == track)
+ continue;
+
+ QString s(track->name());
+
+ // for (iRoute ir = r->begin(); ir != r->end(); ++ir) {
+ // if (ir->type == 0 && ir->track == track) {
+ // s += "*";
+ // PyList_Append(routes, Py_BuildValue("s", s.toLatin1()));
+ // break;
+ // }
+ // }
+ //
+ }
+ }
+ else if (tt->type() == Track::AUDIO_OUTPUT) {
+ }
+
+
+
+ return routes;
+}
+*/
+//------------------------------------------------------------
+// Global method definitions for MusE:s Python API
+//
+// This is where global functions in Python is linked to their equivalent C/C++ functions
+//------------------------------------------------------------
+PyMethodDef g_methodDefinitions[] =
+{
+ { "startPlay", startPlay, METH_VARARGS, "Starts playing the song from current position" },
+ { "stopPlay", stopPlay, METH_VARARGS, "Stops playback if currently playing" },
+ { "rewindStart", rewindStart, METH_VARARGS, "Set current position to beginning of song" },
+ { "getCPos", getCPos, METH_NOARGS, "Get current position (in ticks)" },
+ { "getLPos", getLPos, METH_NOARGS, "Get position of left locator (in ticks)" },
+ { "getRPos", getRPos, METH_NOARGS, "Get position of right locator (in ticks)" },
+ { "setPos", setPos, METH_VARARGS, "Set position of locators or current position" },
+ { "getTempo", getTempo, METH_VARARGS, "Get tempo of the song at a particular tick" },
+ { "setLoop", setLoop, METH_VARARGS, "Set loop mode on/off" },
+ { "getLoop", getLoop, METH_NOARGS, "Get loop value" },
+
+ { "getTrackNames", getTrackNames, METH_VARARGS, "Get track names (which are unique)" },
+ { "getParts", getParts, METH_VARARGS, "Get part data from a track" },
+ { "createPart", createPart, METH_VARARGS, "Create a part" },
+ { "modifyPart", modifyPart, METH_O, "Modify a particular part" },
+ { "deletePart", deletePart, METH_VARARGS, "Remove part with a particular serial nr" },
+ { "getSelectedTrack", getSelectedTrack, METH_NOARGS, "Get first selected track" },
+ { "importPart", importPart, METH_VARARGS, "Import part file to a track at a particular position" },
+ { "changeTrackName", changeTrackName, METH_VARARGS, "Change track name" },
+ { "addMidiTrack", addMidiTrack, METH_NOARGS, "Add a midi track" },
+ { "addWaveTrack", addWaveTrack, METH_NOARGS, "Add a wave track" },
+ { "addInput", addInput, METH_NOARGS, "Add audio input" },
+ { "addOutput", addOutput, METH_NOARGS, "Add audio output" },
+ { "addGroup", addGroup, METH_NOARGS, "Add audio group" },
+ { "deleteTrack", deleteTrack, METH_VARARGS, "Delete a track" },
+
+ { "getTrackEffects", getTrackEffects, METH_VARARGS, "Get names of LADSPA effects on a track" },
+ { "toggleTrackEffect", toggleTrackEffect, METH_VARARGS, "Toggle LADSPA effect on/off" },
+ //{ "getOutputRoute", getOutputRoute, METH_VARARGS, "Get route for an audio output" },
+
+ { "setSongLen", setSongLen, METH_VARARGS, "Set length of song (in ticks)" },
+ { "getSongLen", getSongLen, METH_VARARGS, "Get length of song (in ticks)" },
+
+ { "getMute", getMute, METH_VARARGS, "Get track mute property (if track is played or not)" },
+ { "setMute", setMute, METH_VARARGS, "Set track mute property (if track should be played or not)" },
+ { "setMidiControllerValue", setMidiControllerValue, METH_VARARGS, "Set midi controller value for a track" },
+ { "getMidiControllerValue", getMidiControllerValue, METH_VARARGS, "Get midi controller value for a track" },
+ { "setAudioTrackVolume", setAudioTrackVolume, METH_VARARGS, "Set volume on audio track/aux/output/input" },
+ { "getAudioTrackVolume", getAudioTrackVolume, METH_VARARGS, "Get audio track/aux/output/input volume" },
+
+ { "setMidiTrackParameter", setMidiTrackParameter, METH_VARARGS, "Set transposition, velocity, compression or delay on track level" },
+
+ { "getDivision", getDivision, METH_VARARGS, "Number of ticks per 1/4 (?)" },
+
+ {NULL, NULL, NULL, NULL}
+};
+
+/**
+ * This function launches the Pyro name service, which blocks execution
+ * Thus it needs its own thread
+ **/
+static void* pyapithreadfunc(void*)
+{
+ Py_Initialize();
+ PyImport_AddModule("muse");
+ Py_InitModule( "muse", g_methodDefinitions );
+
+ //
+ // Access the "__main__" module and its name-space dictionary.
+ //
+
+ PyObject *pMainModule = PyImport_AddModule( "__main__" );
+ PyObject *pMainDictionary = PyModule_GetDict( pMainModule );
+ string launcherfilename = string(SHAREDIR) + string("/pybridge/museplauncher.py");
+ printf("Initiating MusE Pybridge launcher from %s\n", launcherfilename.c_str());
+ FILE* fp = fopen(launcherfilename.c_str(),"r");
+ PyRun_File(fp, launcherfilename.c_str(), Py_file_input, pMainDictionary, pMainDictionary);
+ fclose(fp);
+
+ return NULL;
+}
+
+/**
+ * This function currently only launches the thread. There should be some kind of check that
+ * things are up and running as they are supposed to
+ */
+bool initPythonBridge()
+{
+ if (pthread_create(&pyapiThread, NULL, ::pyapithreadfunc, 0)) {
+ return false;
+ }
+ return true; // TODO: Verify that things are up and running!
+}
+
+//---------------------------------------------------------
+// event
+//
+// Function in Song class, run in the Qt event thread context.
+// Handles events sent from the Python bridge subsystem
+//
+// This is part of Qt:s event handling and events are fed
+// here via QApplication::postEvent since gui updates should
+// be done by Qt:s GUI thread. QApplication::postEvent is
+// a static method, which is threadsafe. Using the song object
+// from the Python thread is dangerous when it comes to
+// operations that manipulate the gui itself (read is ok)
+//---------------------------------------------------------
+bool Song::event(QEvent* _e)
+{
+ if (_e->type() != QEvent::User)
+ return false; //ignore all events except user events, which are events from Python bridge subsystem
+
+ QPybridgeEvent* e = (QPybridgeEvent*) _e;
+ switch (e->getType()) {
+ case QPybridgeEvent::SONG_UPDATE:
+ this->update(e->getP1());
+ break;
+ case QPybridgeEvent::SONGLEN_CHANGE:
+ this->setLen(e->getP1());
+ break;
+ case QPybridgeEvent::SONG_POSCHANGE:
+ this->setPos(e->getP1(), e->getP2());
+ break;
+ case QPybridgeEvent::SONG_SETPLAY:
+ this->setPlay(true);
+ break;
+ case QPybridgeEvent::SONG_SETSTOP:
+ this->setStop(true);
+ break;
+ case QPybridgeEvent::SONG_REWIND:
+ this->rewindStart();
+ break;
+ case QPybridgeEvent::SONG_SETMUTE: {
+ Track* track = this->findTrack(e->getS1());
+ if (track == NULL)
+ return false;
+
+ bool muted = e->getP1() == 1;
+ track->setMute(muted);
+ this->update(SC_MUTE | SC_TRACK_MODIFIED);
+ break;
+ }
+ case QPybridgeEvent::SONG_SETCTRL: {
+ Track* t = this->findTrack(e->getS1());
+ if (t == NULL)
+ return false;
+
+ if (t->isMidiTrack() == false)
+ return false;
+
+ MidiTrack* track = (MidiTrack*) t;
+ int chan = track->outChannel();
+
+ int num = e->getP1();
+ int val = e->getP2();
+ int tick = song->cpos();
+ MidiPlayEvent ev(tick, track->outPort(), chan, ME_CONTROLLER, num, val);
+ audio->msgPlayMidiEvent(&ev);
+ song->update(SC_MIDI_CONTROLLER);
+ break;
+ }
+ case QPybridgeEvent::SONG_SETAUDIOVOL: {
+ Track* t = this->findTrack(e->getS1());
+ if (t == NULL)
+ return false;
+
+ if (t->type() == Track::DRUM || t->type() == Track::MIDI)
+ return false;
+
+ AudioTrack* track = (AudioTrack*) t;
+ track->setVolume(e->getD1());
+ break;
+ }
+ case QPybridgeEvent::SONG_IMPORT_PART: {
+ Track* track = this->findTrack(e->getS1());
+ QString filename = e->getS2();
+ unsigned int tick = e->getP1();
+ if (track == NULL)
+ return false;
+
+ muse->importPartToTrack(filename, tick, track);
+ break;
+ }
+ case QPybridgeEvent::SONG_TOGGLE_EFFECT: {
+ Track* t = this->findTrack(e->getS1());
+ if (t == NULL)
+ return false;
+
+ if (t->type() != Track::WAVE)
+ return false;
+
+ int fxid = e->getP1();
+
+ if (fxid > PipelineDepth)
+ return false;
+
+ int onoff = (e->getP2() == 1);
+
+ AudioTrack* track = (AudioTrack*) t;
+ Pipeline* pipeline = track->efxPipe();
+ pipeline->setOn(fxid, onoff);
+ break;
+ }
+ case QPybridgeEvent::SONG_ADD_TRACK:
+ song->addTrack(e->getP1());
+ break;
+ case QPybridgeEvent::SONG_CHANGE_TRACKNAME: {
+ Track* t = this->findTrack(e->getS1());
+ if (t == NULL)
+ return false;
+ t->setName(e->getS2());
+ break;
+ }
+ case QPybridgeEvent::SONG_DELETE_TRACK: {
+ Track* t = this->findTrack(e->getS1());
+ if (t == NULL)
+ return false;
+
+ audio->msgRemoveTrack(t);
+ break;
+ }
+ default:
+ printf("Unknown pythonthread event received: %d\n", e->getType());
+ break;
+ }
+
+
+ return true;
+}
+
+
diff --git a/attic/muse2-oom/muse2/muse/remote/pyapi.h b/attic/muse2-oom/muse2/muse/remote/pyapi.h
new file mode 100644
index 00000000..7501e591
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/remote/pyapi.h
@@ -0,0 +1,40 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// (C) Copyright 2009 Mathias Gyllengahm (lunar_shuttle@users.sf.net)
+//=========================================================
+#ifndef PYAPI_H
+#define PYAPI_H
+
+#include <QEvent>
+
+class QPybridgeEvent : public QEvent
+{
+public:
+ enum EventType { SONG_UPDATE=0, SONGLEN_CHANGE, SONG_POSCHANGE, SONG_SETPLAY, SONG_SETSTOP, SONG_REWIND, SONG_SETMUTE,
+ SONG_SETCTRL, SONG_SETAUDIOVOL, SONG_IMPORT_PART, SONG_TOGGLE_EFFECT, SONG_ADD_TRACK, SONG_CHANGE_TRACKNAME,
+ SONG_DELETE_TRACK };
+ QPybridgeEvent( QPybridgeEvent::EventType _type, int _p1=0, int _p2=0);
+ EventType getType() { return type; }
+ int getP1() { return p1; }
+ int getP2() { return p2; }
+ void setS1(QString in) { s1 = in; }
+ void setS2(QString in) { s2 = in; }
+ const QString& getS1() { return s1; }
+ const QString& getS2() { return s2; }
+ double getD1() { return d1; }
+ void setD1(double _d1) { d1 = _d1; }
+
+private:
+ EventType type;
+ int p1, p2;
+ double d1;
+ QString s1;
+ QString s2;
+
+};
+
+bool initPythonBridge();
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/route.cpp b/attic/muse2-oom/muse2/muse/route.cpp
new file mode 100644
index 00000000..19f8d09f
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/route.cpp
@@ -0,0 +1,1685 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: route.cpp,v 1.18.2.3 2008/05/21 00:28:52 terminator356 Exp $
+//
+// (C) Copyright 2003-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QWidget>
+
+#include "song.h"
+#include "route.h"
+#include "node.h"
+#include "audio.h"
+#include "track.h"
+#include "synth.h"
+#include "audiodev.h"
+#include "xml.h"
+#include "midiport.h"
+#include "driver/jackmidi.h"
+#include "driver/alsamidi.h"
+
+//#define ROUTE_DEBUG
+
+//#define ROUTE_MIDIPORT_NAME_PREFIX "MusE MidiPort "
+const QString ROUTE_MIDIPORT_NAME_PREFIX = "MusE MidiPort ";
+
+//---------------------------------------------------------
+// Route
+//---------------------------------------------------------
+
+Route::Route(void* t, int ch)
+ {
+ jackPort = t;
+ midiPort = -1;
+ channel = ch;
+ channels = -1;
+ remoteChannel = -1;
+ type = JACK_ROUTE;
+ }
+
+//Route::Route(AudioTrack* t, int ch)
+Route::Route(Track* t, int ch, int chans)
+//Route::Route(Track* t, int ch)
+ {
+ track = t;
+ midiPort = -1;
+ channel = ch;
+ channels = chans;
+ remoteChannel = -1;
+ type = TRACK_ROUTE;
+ }
+
+//Route::Route(MidiJackDevice* d)
+Route::Route(MidiDevice* d, int ch)
+{
+ device = d;
+ midiPort = -1;
+ channel = ch;
+ channels = -1;
+ remoteChannel = -1;
+ /*
+ //if(dynamic_cast<MidiJackDevice*>(d))
+ if(d->deviceType() == MidiDevice::JACK_MIDI)
+ type = JACK_MIDI_ROUTE;
+ else
+ //if(dynamic_cast<MidiAlsaDevice*>(d))
+ if(d->deviceType() == MidiDevice::ALSA_MIDI)
+ type = ALSA_MIDI_ROUTE;
+ */
+ type = MIDI_DEVICE_ROUTE;
+}
+
+Route::Route(int port, int ch) // p3.3.49
+{
+ track = 0;
+ midiPort = port;
+ channel = ch;
+ channels = -1;
+ remoteChannel = -1;
+ type = MIDI_PORT_ROUTE;
+}
+
+//Route::Route(const QString& s, bool dst, int ch)
+Route::Route(const QString& s, bool dst, int ch, int rtype)
+ {
+ //Route node(name2route(s, dst));
+ Route node(name2route(s, dst, rtype));
+ channel = node.channel;
+ if(channel == -1)
+ channel = ch;
+ //if(channels == -1)
+ // channels = chans;
+ channels = node.channels;
+ remoteChannel = node.remoteChannel;
+ type = node.type;
+ if(type == TRACK_ROUTE)
+ {
+ track = node.track;
+ midiPort = -1;
+ }
+ else
+ if(type == JACK_ROUTE)
+ {
+ jackPort = node.jackPort;
+ midiPort = -1;
+ }
+ /*
+ else
+ if (type == JACK_MIDI_ROUTE)
+ device = node.device;
+ else
+ if (type == ALSA_MIDI_ROUTE)
+ device = node.device;
+ */
+ else
+ if(type == MIDI_DEVICE_ROUTE)
+ {
+ device = node.device;
+ midiPort = -1;
+ }
+ else
+ if(type == MIDI_PORT_ROUTE) // p3.3.49
+ {
+ track = 0;
+ midiPort = node.midiPort; //
+ }
+ }
+
+Route::Route()
+ {
+ track = 0;
+ midiPort = -1;
+ channel = -1;
+ channels = -1;
+ remoteChannel = -1;
+ type = TRACK_ROUTE;
+ }
+
+//---------------------------------------------------------
+// addRoute
+//---------------------------------------------------------
+
+void addRoute(Route src, Route dst)
+{
+ #ifdef ROUTE_DEBUG
+ fprintf(stderr, "addRoute:\n");
+ #endif
+
+ if (!src.isValid() || !dst.isValid())
+ {
+ if(!src.isValid())
+ fprintf(stderr, "addRoute: invalid src\n");
+ if(!dst.isValid())
+ fprintf(stderr, "addRoute: invalid dst\n");
+ return;
+ }
+
+// printf("addRoute %d.%d:<%s> %d.%d:<%s>\n",
+// src.type, src.channel, src.name().toLatin1().constData(),
+// dst.type, dst.channel, dst.name().toLatin1().constData());
+ if (src.type == Route::JACK_ROUTE)
+ {
+ //if (dst.type != TRACK_ROUTE)
+ //{
+ // fprintf(stderr, "addRoute: bad route 1\n");
+ // exit(-1);
+ // return;
+ //}
+
+ if (dst.type == Route::TRACK_ROUTE)
+ {
+ if (dst.track->type() != Track::AUDIO_INPUT)
+ {
+ fprintf(stderr, "addRoute: source is jack, dest:%s is track but not audio input\n", dst.track->name().toLatin1().constData());
+ //exit(-1);
+ return;
+ }
+ if (dst.channel < 0)
+ {
+ fprintf(stderr, "addRoute: source is jack, dest:%s is track but invalid channel:%d\n", dst.track->name().toLatin1().constData(), dst.channel);
+ //exit(-1);
+ return;
+ }
+
+ //src.channel = src.dstChannel = dst.channel;
+ src.channel = dst.channel;
+ //src.channels = dst.channels = 1;
+ RouteList* inRoutes = dst.track->inRoutes();
+ for (iRoute i = inRoutes->begin(); i != inRoutes->end(); ++i)
+ {
+ if (*i == src) // route already there
+ {
+ //#ifdef ROUTE_DEBUG
+ fprintf(stderr, "addRoute: src track route already exists.\n");
+ //#endif
+ return;
+ }
+ }
+ #ifdef ROUTE_DEBUG
+ fprintf(stderr, "addRoute: src Jack dst track name: %s pushing source route\n", dst.track->name().toLatin1().constData());
+ #endif
+ inRoutes->push_back(src);
+ }
+ else
+ //if (dst.type == Route::JACK_MIDI_ROUTE)
+ if (dst.type == Route::MIDI_DEVICE_ROUTE)
+ //if (dst.type == Route::MIDI_PORT_ROUTE) // p3.3.49
+ {
+ //MidiDevice *md = midiPorts[dst.midiPort].device();
+ //if(dst.device->deviceType() == MidiDevice::JACK_MIDI)
+ //if(!md)
+ //{
+ // fprintf(stderr, "addRoute: source is Jack, but no destination port device\n");
+ // return;
+ //}
+
+ if(dst.device->deviceType() == MidiDevice::JACK_MIDI)
+ //if(md->deviceType() == MidiDevice::JACK_MIDI)
+ {
+ src.channel = dst.channel;
+ //src.channel = -1;
+ //src.channel = 0;
+ //src.channel = src.dstChannel = dst.channel;
+ //src.channels = dst.channels = 1;
+ //dst.channel = -1;
+
+ RouteList* routes = dst.device->inRoutes();
+ for (iRoute i = routes->begin(); i != routes->end(); ++i)
+ {
+ if (*i == src) // route already there
+ {
+ //#ifdef ROUTE_DEBUG
+ fprintf(stderr, "addRoute: src Jack midi route already exists.\n");
+ //#endif
+ return;
+ }
+ }
+ #ifdef ROUTE_DEBUG
+ fprintf(stderr, "addRoute: src Jack dst Jack midi name: %s pushing source route\n", dst.device->name().toLatin1().constData());
+ #endif
+ routes->push_back(src);
+ }
+ else
+ {
+ fprintf(stderr, "addRoute: source is Jack, but destination is not jack midi - type:%d\n", dst.device->deviceType());
+ // exit(-1);
+ return;
+ }
+ }
+ else
+ {
+ fprintf(stderr, "addRoute: source is Jack, but destination is not track or midi - type:%d \n", dst.type);
+ // exit(-1);
+ return;
+ }
+ }
+ else if (dst.type == Route::JACK_ROUTE)
+ {
+ //if (src.type != TRACK_ROUTE)
+ //{
+ // fprintf(stderr, "addRoute: bad route 3\n");
+ // exit(-1);
+ // return;
+ //}
+
+ if (src.type == Route::TRACK_ROUTE)
+ {
+ if (src.track->type() != Track::AUDIO_OUTPUT)
+ {
+ fprintf(stderr, "addRoute: destination is jack, source is track but not audio output\n");
+ // exit(-1);
+ return;
+ }
+ if (src.channel < 0)
+ {
+ fprintf(stderr, "addRoute: destination is jack, source:%s is track but invalid channel:%d\n", src.track->name().toLatin1().constData(), src.channel);
+ // exit(-1);
+ return;
+ }
+
+ RouteList* outRoutes = src.track->outRoutes();
+ //dst.channel = dst.dstChannel = src.channel;
+ dst.channel = src.channel;
+ //dst.channels = src.channels = 1;
+
+ for (iRoute i = outRoutes->begin(); i != outRoutes->end(); ++i)
+ {
+ if (*i == dst) // route already there
+ {
+ #ifdef ROUTE_DEBUG
+ fprintf(stderr, "addRoute: dst track route already exists.\n");
+ #endif
+ return;
+ }
+ }
+ #ifdef ROUTE_DEBUG
+ fprintf(stderr, "addRoute: dst Jack src track name: %s pushing destination route\n", src.track->name().toLatin1().constData());
+ #endif
+ outRoutes->push_back(dst);
+ }
+ else
+ //if (src.type == Route::JACK_MIDI_ROUTE)
+ if (src.type == Route::MIDI_DEVICE_ROUTE)
+ {
+ if(src.device->deviceType() == MidiDevice::JACK_MIDI)
+ {
+ dst.channel = src.channel;
+ //dst.channel = -1;
+ //src.channel = -1;
+ //dst.channel = dst.dstChannel = src.channel;
+ //dst.channels = src.channels = 1;
+
+ RouteList* routes = src.device->outRoutes();
+ for (iRoute i = routes->begin(); i != routes->end(); ++i)
+ {
+ if (*i == dst) // route already there
+ {
+ //#ifdef ROUTE_DEBUG
+ fprintf(stderr, "addRoute: dst Jack midi route already exists.\n");
+ //#endif
+ return;
+ }
+ }
+ #ifdef ROUTE_DEBUG
+ fprintf(stderr, "addRoute: dst Jack src Jack midi name: %s pushing destination route\n", src.device->name().toLatin1().constData());
+ #endif
+ routes->push_back(dst);
+ }
+ else
+ {
+ fprintf(stderr, "addRoute: destination is Jack, but source is not jack midi - type:%d\n", src.device->deviceType());
+ // exit(-1);
+ return;
+ }
+ }
+ else
+ {
+ fprintf(stderr, "addRoute: destination is Jack, but source is not track or midi - type:%d \n", src.type);
+ // exit(-1);
+ return;
+ }
+ }
+ else if(src.type == Route::MIDI_PORT_ROUTE) // p3.3.49
+ {
+ if(dst.type != Route::TRACK_ROUTE)
+ {
+ fprintf(stderr, "addRoute: source is midi port:%d, but destination is not track\n", src.midiPort);
+ return;
+ }
+ if(dst.channel < 1 || dst.channel >= (1 << MIDI_CHANNELS))
+ {
+ fprintf(stderr, "addRoute: source is midi port:%d, but destination channel mask:%d out of range\n", src.midiPort, dst.channel);
+ return;
+ }
+
+ //MidiDevice *md = midiPorts[src.midiPort].device();
+ //if(!md)
+ //{
+ // fprintf(stderr, "addRoute: source is midi port, but no destination port device\n");
+ // return;
+ //}
+
+ MidiPort *mp = &midiPorts[src.midiPort];
+
+ src.channel = dst.channel;
+ RouteList* outRoutes = mp->outRoutes();
+ //for (iRoute i = outRoutes->begin(); i != outRoutes->end(); ++i)
+ iRoute ir = outRoutes->begin(); // p3.3.50
+ for ( ; ir != outRoutes->end(); ++ir)
+ {
+ //if (*i == dst) // route already there
+ if (ir->type == Route::TRACK_ROUTE && ir->track == dst.track) // p3.3.50 Does a route to the track exist?
+ {
+ //#ifdef ROUTE_DEBUG
+ //fprintf(stderr, "addRoute: src midi port:%d dst track:%s route already exists.\n", src.midiPort, dst.track->name().toLatin1().constData());
+ //#endif
+ ir->channel |= dst.channel; // p3.3.50 Bitwise OR the desired channel bit with the existing bit mask.
+ break;
+
+ //return;
+ }
+ }
+ #ifdef ROUTE_DEBUG
+ fprintf(stderr, "addRoute: src midi port:%d dst track name:%s pushing dst and src routes\n", src.midiPort, dst.track->name().toLatin1().constData());
+ #endif
+
+ if(ir == outRoutes->end()) // p3.3.50 Only if route not found, add the route, with the requested channel bits as mask to start with.
+ outRoutes->push_back(dst);
+
+ RouteList* inRoutes = dst.track->inRoutes();
+
+ // p3.3.50 Make sure only one single route, with a channel mask, can ever exist.
+ ir = inRoutes->begin();
+ for ( ; ir != inRoutes->end(); ++ir)
+ {
+ if (ir->type == Route::MIDI_PORT_ROUTE && ir->midiPort == src.midiPort) // p3.3.50 Does a route to the midi port exist?
+ {
+ ir->channel |= src.channel; // p3.3.50 Bitwise OR the desired channel bit with the existing bit mask.
+ break;
+ }
+ }
+
+ if(ir == inRoutes->end()) // p3.3.50 Only if route not found, add the route, with the requested channel bits as mask to start with.
+ inRoutes->push_back(src);
+ }
+ else if(dst.type == Route::MIDI_PORT_ROUTE) // p3.3.49
+ {
+ if(src.type != Route::TRACK_ROUTE)
+ {
+ fprintf(stderr, "addRoute: destination is midi port:%d, but source is not track\n", dst.midiPort);
+ return;
+ }
+ if(src.channel < 1 || src.channel >= (1 << MIDI_CHANNELS))
+ {
+ fprintf(stderr, "addRoute: destination is midi port:%d, but source channel mask:%d out of range\n", dst.midiPort, src.channel);
+ return;
+ }
+
+
+ //MidiDevice *md = midiPorts[dst.midiPort].device();
+ //if(!md)
+ //{
+ // fprintf(stderr, "addRoute: dst is midi port, but no destination port device\n");
+ // return;
+ //}
+
+ dst.channel = src.channel;
+ RouteList* outRoutes = src.track->outRoutes();
+
+ //for (iRoute i = outRoutes->begin(); i != outRoutes->end(); ++i)
+ iRoute ir = outRoutes->begin(); // p3.3.50
+ for ( ; ir != outRoutes->end(); ++ir)
+ {
+ //if (*i == dst) // route already there
+ if (ir->type == Route::MIDI_PORT_ROUTE && ir->midiPort == dst.midiPort) // p3.3.50 Does a route to the midi port exist?
+ {
+ //#ifdef ROUTE_DEBUG
+ //fprintf(stderr, "addRoute: dst midi port:%d src track:%s route already exists.\n", dst.midiPort, src.track->name().toLatin1().constData());
+ //#endif
+ //return;
+
+ ir->channel |= dst.channel; // p3.3.50 Bitwise OR the desired channel bit with the existing bit mask.
+ break;
+ }
+ }
+
+ if(ir == outRoutes->end()) // p3.3.50 Only if route not found, add the route, with the requested channel bits as mask to start with.
+ outRoutes->push_back(dst);
+
+ MidiPort *mp = &midiPorts[dst.midiPort];
+
+ #ifdef ROUTE_DEBUG
+ fprintf(stderr, "addRoute: src track:%s dst midi port:%d pushing dst and src routes\n", src.track->name().toLatin1().constData(), dst.midiPort);
+ #endif
+ RouteList* inRoutes = mp->inRoutes();
+
+ // p3.3.50 Make sure only one single route, with a channel mask, can ever exist.
+ ir = inRoutes->begin();
+ for ( ; ir != inRoutes->end(); ++ir)
+ {
+ if (ir->type == Route::TRACK_ROUTE && ir->track == src.track) // p3.3.50 Does a route to the track exist?
+ {
+ ir->channel |= src.channel; // p3.3.50 Bitwise OR the desired channel bit with the existing bit mask.
+ break;
+ }
+ }
+
+ if(ir == inRoutes->end()) // p3.3.50 Only if route not found, add the route, with the requested channel bits as mask to start with.
+ inRoutes->push_back(src);
+ //inRoutes->insert(inRoutes->begin(), src);
+ }
+ else
+ {
+ if(src.type != Route::TRACK_ROUTE || dst.type != Route::TRACK_ROUTE) // p3.3.49
+ {
+ fprintf(stderr, "addRoute: source or destination are not track routes\n");
+ return;
+ }
+
+ // Removed p3.3.49
+ /*
+ //if ((src.type == Route::JACK_MIDI_ROUTE) || (src.type == Route::ALSA_MIDI_ROUTE))
+ if(src.type == Route::MIDI_DEVICE_ROUTE)
+ {
+ //src.channel = src.dstChannel = dst.dstChannel = dst.channel;
+ src.channel = dst.channel;
+ //src.channels = dst.channels = 1;
+ RouteList* outRoutes = src.device->outRoutes();
+ #ifdef ROUTE_DEBUG
+ fprintf(stderr, "addRoute: src name: %s looking for existing dest in out routes...\n", src.device->name().toLatin1().constData());
+ #endif
+ for (iRoute i = outRoutes->begin(); i != outRoutes->end(); ++i)
+ {
+ if (*i == dst) // route already there
+ {
+ //#ifdef ROUTE_DEBUG
+ fprintf(stderr, "addRoute: src Jack or ALSA midi route already exists.\n");
+ //#endif
+ return;
+ }
+ }
+ #ifdef ROUTE_DEBUG
+ fprintf(stderr, "addRoute: src midi dst name: %s pushing destination and source routes\n", dst.track->name().toLatin1().constData());
+ #endif
+
+ outRoutes->push_back(dst);
+ RouteList* inRoutes = dst.track->inRoutes();
+ inRoutes->push_back(src);
+ }
+ else
+ */
+
+ {
+ ///if(dst.type == Route::MIDI_DEVICE_ROUTE) // Removed p3.3.49
+ //{
+ /// dst.channel = src.channel;
+ //src.channel = src.dstChannel = dst.dstChannel = dst.channel;
+ //src.channels = dst.channels = 1;
+ //}
+ //else
+ //{
+ //src.channel = src.dstChannel = dst.dstChannel = dst.channel;
+ //src.channels = dst.channels = 1;
+ //}
+
+ RouteList* outRoutes = src.track->outRoutes();
+
+ //
+ // Must enforce to ensure channel and channels are valid if defaults of -1 passed.
+ //
+ if(src.track->type() == Track::AUDIO_SOFTSYNTH)
+ {
+ if(src.channel == -1)
+ src.channel = 0;
+ if(src.channels == -1)
+ src.channels = src.track->channels();
+ //if(dst.type == Route::TRACK_ROUTE) // p3.3.49 Removed
+ //{
+ //if(dst.channel == -1)
+ // dst.channel = 0;
+ //if(dst.channels == -1)
+ // Yes, that's correct: dst channels = src track channels.
+ // dst.channels = src.track->channels();
+ dst.channel = src.channel;
+ dst.channels = src.channels;
+ dst.remoteChannel = src.remoteChannel;
+ //}
+ }
+ //if(dst.type == Route::TRACK_ROUTE && dst.track->type() == Track::AUDIO_SOFTSYNTH)
+ //{
+ // if(dst.channel == -1)
+ // dst.channel = 0;
+ // if(dst.channels == -1)
+ // Yes, that's correct: dst channels = src track channels.
+ // dst.channels = src.track->channels();
+ //}
+
+ for (iRoute i = outRoutes->begin(); i != outRoutes->end(); ++i)
+ {
+ if (*i == dst) // route already there
+ // TODO:
+ //if (i->type == dst.type && i->channel == dst.channel)
+ {
+ //if(i->type == Route::TRACK_ROUTE)
+ {
+ //if(i->track == dst.track)
+ {
+ //if(i->channels == dst.channels)
+ {
+ //#ifdef ROUTE_DEBUG
+ fprintf(stderr, "addRoute: src track route already exists.\n");
+ //#endif
+ return;
+ }
+ //else
+ //{
+
+ //}
+ }
+ }
+ }
+ }
+ outRoutes->push_back(dst);
+ RouteList* inRoutes;
+
+ // Removed p3.3.49
+ /*
+ //if ((dst.type == Route::JACK_MIDI_ROUTE) || (dst.type == Route::ALSA_MIDI_ROUTE))
+ if(dst.type == Route::MIDI_DEVICE_ROUTE)
+ {
+ #ifdef ROUTE_DEBUG
+ fprintf(stderr, "addRoute: src track dst midi name: %s pushing destination and source routes\n", dst.device->name().toLatin1().constData());
+ #endif
+ inRoutes = dst.device->inRoutes();
+ }
+ else
+ */
+
+ {
+ #ifdef ROUTE_DEBUG
+ //fprintf(stderr, "addRoute: src track ch:%d chs:%d dst track ch:%d chs:%d name: %s pushing destination and source routes\n", src.channel, src.channels, dst.channel, dst.channels, dst.track->name().toLatin1().constData());
+ fprintf(stderr, "addRoute: src track ch:%d chs:%d remch:%d dst track ch:%d chs:%d remch:%d name: %s pushing dest and source routes\n",
+ src.channel, src.channels, src.remoteChannel, dst.channel, dst.channels, dst.remoteChannel, dst.track->name().toLatin1().constData());
+ //fprintf(stderr, "addRoute: src track ch:%d dst track ch:%d name: %s pushing destination and source routes\n", src.channel, dst.channel, dst.track->name().toLatin1().constData());
+ #endif
+ inRoutes = dst.track->inRoutes();
+ }
+
+
+ //
+ // make sure AUDIO_AUX is processed last
+ //
+ if (src.track->type() == Track::AUDIO_AUX)
+ inRoutes->push_back(src);
+ else
+ inRoutes->insert(inRoutes->begin(), src);
+ }
+ }
+}
+
+//---------------------------------------------------------
+// removeRoute
+//---------------------------------------------------------
+
+void removeRoute(Route src, Route dst)
+{
+ //printf("removeRoute %d.%d:<%s> %d.%d:<%s>\n",
+ // src.type, src.channel, src.name().toLatin1().constData(),
+ // dst.type, dst.channel, dst.name().toLatin1().constData());
+
+ if (src.type == Route::JACK_ROUTE)
+ {
+ //if (dst.type != TRACK_ROUTE)
+ //{
+ // fprintf(stderr, "removeRoute: bad route 1\n");
+ // exit(-1);
+ // return;
+ //}
+ if(!dst.isValid())
+ {
+ printf("removeRoute: source is jack, invalid destination\n");
+ return;
+ }
+
+ if (dst.type == Route::TRACK_ROUTE)
+ {
+ if (dst.track->type() != Track::AUDIO_INPUT)
+ {
+ fprintf(stderr, "removeRoute: source is jack, destination is track but not audio input\n");
+ // exit(-1);
+ return;
+ }
+ RouteList* inRoutes = dst.track->inRoutes();
+ iRoute i;
+ for (i = inRoutes->begin(); i != inRoutes->end(); ++i)
+ {
+ if (*i == src)
+ {
+ inRoutes->erase(i);
+ break;
+ }
+ }
+ }
+ else
+ //if (dst.type == Route::JACK_MIDI_ROUTE)
+ if (dst.type == Route::MIDI_DEVICE_ROUTE)
+ {
+ RouteList* routes = dst.device->inRoutes();
+ iRoute i;
+ for (i = routes->begin(); i != routes->end(); ++i)
+ {
+ if (*i == src)
+ {
+ routes->erase(i);
+ break;
+ }
+ }
+ }
+ else
+ {
+ fprintf(stderr, "removeRoute: source is jack, destination unknown\n");
+ // exit(-1);
+ return;
+ }
+ }
+ else if (dst.type == Route::JACK_ROUTE)
+ {
+ //if (src.type != TRACK_ROUTE)
+ //{
+ // fprintf(stderr, "removeRoute: bad route 3\n");
+ // exit(-1);
+ // return;
+ //}
+ if(!src.isValid())
+ {
+ printf("removeRoute: destination is jack, invalid source\n");
+ return;
+ }
+
+ if (src.type == Route::TRACK_ROUTE)
+ {
+ if (src.track->type() != Track::AUDIO_OUTPUT)
+ {
+ fprintf(stderr, "removeRoute: destination is jack, source is track but not audio output\n");
+ // exit(-1);
+ return;
+ }
+ RouteList* outRoutes = src.track->outRoutes();
+ iRoute i;
+ for (i = outRoutes->begin(); i != outRoutes->end(); ++i)
+ {
+ if (*i == dst) {
+ outRoutes->erase(i);
+ break;
+ }
+ }
+ }
+ else
+ //if (src.type == Route::JACK_MIDI_ROUTE)
+ if (src.type == Route::MIDI_DEVICE_ROUTE)
+ {
+ RouteList* routes = src.device->outRoutes();
+ iRoute i;
+ for (i = routes->begin(); i != routes->end(); ++i)
+ {
+ if (*i == dst) {
+ routes->erase(i);
+ break;
+ }
+ }
+ }
+ else
+ {
+ fprintf(stderr, "removeRoute: destination is jack, source unknown\n");
+ // exit(-1);
+ return;
+ }
+ }
+ else if(src.type == Route::MIDI_PORT_ROUTE) // p3.3.49
+ {
+ if(dst.type != Route::TRACK_ROUTE)
+ {
+ fprintf(stderr, "removeRoute: source is midi port:%d, but destination is not track\n", src.midiPort);
+ return;
+ }
+
+ if(src.isValid())
+ {
+ MidiPort *mp = &midiPorts[src.midiPort];
+ RouteList* outRoutes = mp->outRoutes();
+ for (iRoute i = outRoutes->begin(); i != outRoutes->end(); ++i)
+ {
+ //if (*i == dst)
+ if (i->type == Route::TRACK_ROUTE && i->track == dst.track) // p3.3.50 Is there a route to the track?
+ {
+ i->channel &= ~dst.channel; // p3.3.50 Unset the desired channel bits.
+ if(i->channel == 0) // Only if there are no channel bits set, erase the route.
+ outRoutes->erase(i);
+
+ break; // For safety, keep looking and remove any more found.
+ // No, must break, else crash. There should only be one route anyway...
+ }
+ }
+ }
+ else
+ printf("removeRoute: source is midi port:%d but invalid\n", src.midiPort);
+
+ if(dst.isValid())
+ {
+ RouteList* inRoutes = dst.track->inRoutes();
+ for (iRoute i = inRoutes->begin(); i != inRoutes->end(); ++i)
+ {
+ //if (*i == src)
+ if (i->type == Route::MIDI_PORT_ROUTE && i->midiPort == src.midiPort) // p3.3.50 Is there a route to the midi port?
+ {
+ i->channel &= ~src.channel; // p3.3.50 Unset the desired channel bits.
+ if(i->channel == 0) // Only if there are no channel bits set, erase the route.
+ inRoutes->erase(i);
+
+ break; // For safety, keep looking and remove any more found.
+ // No, must break, else crash. There should only be one route anyway...
+ }
+ }
+ }
+ else
+ printf("removeRoute: source is midi port:%d but destination track invalid\n", src.midiPort);
+ }
+ else if(dst.type == Route::MIDI_PORT_ROUTE) // p3.3.49
+ {
+ if(src.type != Route::TRACK_ROUTE)
+ {
+ fprintf(stderr, "removeRoute: destination is midi port:%d, but source is not track\n", dst.midiPort);
+ return;
+ }
+
+ if(src.isValid())
+ {
+ RouteList* outRoutes = src.track->outRoutes();
+ for (iRoute i = outRoutes->begin(); i != outRoutes->end(); ++i)
+ {
+ //if (*i == dst)
+ if (i->type == Route::MIDI_PORT_ROUTE && i->midiPort == dst.midiPort) // p3.3.50 Is there a route to the midi port?
+ {
+ i->channel &= ~dst.channel; // p3.3.50 Unset the desired channel bits.
+ if(i->channel == 0) // Only if there are no channel bits set, erase the route.
+ outRoutes->erase(i);
+
+ break; // For safety, keep looking and remove any more found.
+ // No, must break, else crash. There should only be one route anyway...
+ }
+ }
+ }
+ else
+ printf("removeRoute: destination is midi port:%d but source track is invalid\n", dst.midiPort);
+
+ if(dst.isValid())
+ {
+ MidiPort *mp = &midiPorts[src.midiPort];
+ RouteList* inRoutes = mp->inRoutes();
+ for (iRoute i = inRoutes->begin(); i != inRoutes->end(); ++i)
+ {
+ //if (*i == src)
+ if (i->type == Route::TRACK_ROUTE && i->track == src.track) // p3.3.50 Is there a route to the track?
+ {
+ i->channel &= ~src.channel; // p3.3.50 Unset the desired channel bits.
+ if(i->channel == 0) // Only if there are no channel bits set, erase the route.
+ inRoutes->erase(i);
+
+ break; // For safety, keep looking and remove any more found.
+ // No, must break, else crash. There should only be one route anyway...
+ }
+ }
+ }
+ else
+ printf("removeRoute: destination is midi port:%d but invalid\n", dst.midiPort);
+ }
+ else
+ {
+ if(src.type != Route::TRACK_ROUTE || dst.type != Route::TRACK_ROUTE) // p3.3.49
+ {
+ fprintf(stderr, "removeRoute: source and destination are not tracks\n");
+ return;
+ }
+
+ // Removed p3.3.49
+ /*
+ //if((src.type == Route::JACK_MIDI_ROUTE) || (src.type == Route::ALSA_MIDI_ROUTE))
+ if(src.type == Route::MIDI_DEVICE_ROUTE)
+ {
+ if(src.isValid())
+ {
+ RouteList* outRoutes = src.device->outRoutes();
+ for (iRoute i = outRoutes->begin(); i != outRoutes->end(); ++i)
+ {
+ if (*i == dst) {
+ outRoutes->erase(i);
+ break;
+ }
+ }
+ }
+ else
+ printf("removeRoute: source is midi but invalid\n");
+
+ if(dst.isValid())
+ {
+ RouteList* inRoutes = dst.track->inRoutes();
+ for (iRoute i = inRoutes->begin(); i != inRoutes->end(); ++i)
+ {
+ if (*i == src) {
+ inRoutes->erase(i);
+ break;
+ }
+ }
+ }
+ else
+ printf("removeRoute: source is midi but destination invalid\n");
+ }
+ else
+ */
+
+ {
+ if(src.isValid())
+ {
+ RouteList* outRoutes = src.track->outRoutes();
+ for (iRoute i = outRoutes->begin(); i != outRoutes->end(); ++i)
+ {
+ if (*i == dst) {
+ outRoutes->erase(i);
+ break;
+ }
+ }
+ }
+ else
+ printf("removeRoute: source is track but invalid\n");
+
+ if(dst.isValid())
+ {
+ RouteList* inRoutes;
+
+ //if ((dst.type == Route::JACK_MIDI_ROUTE) || (dst.type == Route::ALSA_MIDI_ROUTE))
+ // Removed p3.3.49
+ /*
+ if (dst.type == Route::MIDI_DEVICE_ROUTE)
+ inRoutes = dst.device->inRoutes();
+ else
+ */
+
+ inRoutes = dst.track->inRoutes();
+ for (iRoute i = inRoutes->begin(); i != inRoutes->end(); ++i)
+ {
+ if (*i == src) {
+ inRoutes->erase(i);
+ break;
+ }
+ }
+ }
+ else
+ printf("removeRoute: source is track but destination invalid\n");
+ }
+ }
+}
+
+//---------------------------------------------------------
+// removeAllRoutes
+// If src is valid, disconnects all output routes from it.
+// If dst is valid, disconnects all input routes to it.
+// src and dst Route are used SIMPLY because Route provides convenient way to
+// specify the different pointer types (track, port, jack)
+// This routine will ONLY look at the pointer, not the channel or port etc...
+// So far it only works with MidiDevice <-> Jack.
+//---------------------------------------------------------
+
+// p3.3.55
+void removeAllRoutes(Route src, Route dst)
+{
+ if(src.isValid())
+ {
+ if(src.type == Route::MIDI_DEVICE_ROUTE)
+ src.device->outRoutes()->clear();
+ else
+ printf("removeAllRoutes: source is not midi device\n");
+ }
+
+ if(dst.isValid())
+ {
+ if(dst.type == Route::MIDI_DEVICE_ROUTE)
+ dst.device->inRoutes()->clear();
+ else
+ printf("removeAllRoutes: dest is not midi device\n");
+ }
+}
+
+//---------------------------------------------------------
+// track2name
+// create string name representation for audio node
+//---------------------------------------------------------
+
+static QString track2name(const Track* n)
+ {
+ if (n == 0)
+ return QWidget::tr("None");
+ return n->name();
+ }
+
+//---------------------------------------------------------
+// name
+// create string name representation for audio node
+//---------------------------------------------------------
+
+QString Route::name() const
+{
+ // p3.3.38 Removed
+ /*
+ QString s;
+ if ((type == TRACK_ROUTE) && (channel != -1)) {
+// if (channel != -1) {
+ QString c;
+ c.setNum(channel+1);
+ s = c + ":";
+ }
+ */
+
+ if(type == MIDI_DEVICE_ROUTE)
+ {
+ if(device)
+ {
+ // p3.3.55 Removed for unified jack in/out devices, the actual port names are now different from device name.
+ // Like this: device: "MyJackDevice1" -> inport: "MyJackDevice1_in" outport: "MyJackDevice1_out"
+ /*
+ if(device->deviceType() == MidiDevice::JACK_MIDI)
+ return audioDevice->portName(device->clientPort());
+ else
+ */
+
+ //if(device->deviceType() == MidiDevice::ALSA_MIDI)
+ return device->name();
+ }
+ return QWidget::tr("None");
+ }
+ else
+ if(type == JACK_ROUTE)
+ {
+ if (!checkAudioDevice()) return "";
+ //return s + audioDevice->portName(jackPort);
+ return audioDevice->portName(jackPort);
+ }
+ else
+ if(type == MIDI_PORT_ROUTE) // p3.3.49
+ {
+ return ROUTE_MIDIPORT_NAME_PREFIX + QString().setNum(midiPort);
+ }
+ else
+ //return s + track2name(track);
+ return track2name(track);
+}
+
+//---------------------------------------------------------
+// name2route
+//---------------------------------------------------------
+
+//Route name2route(const QString& rn, bool dst)
+Route name2route(const QString& rn, bool /*dst*/, int rtype)
+{
+// printf("name2route %s\n", rn.toLatin1().constData());
+ int channel = -1;
+ //int channel = 0;
+ QString s(rn);
+ // Support old route style in med files. Obsolete.
+ if (rn[0].isNumber() && rn[1]==':')
+ {
+ channel = rn[0].toAscii() - int('1');
+ s = rn.mid(2);
+ }
+
+ if(rtype == -1)
+ {
+ //if(dst)
+ //{
+ if(checkAudioDevice())
+ {
+ void* p = audioDevice->findPort(s.toLatin1().constData());
+ if(p)
+ return Route(p, channel);
+ }
+
+ TrackList* tl = song->tracks();
+ for(iTrack i = tl->begin(); i != tl->end(); ++i)
+ {
+ if((*i)->isMidiTrack())
+ {
+ MidiTrack* track = (MidiTrack*)*i;
+ if(track->name() == s)
+ return Route(track, channel);
+ }
+ else
+ {
+ AudioTrack* track = (AudioTrack*)*i;
+ if(track->name() == s)
+ return Route(track, channel);
+ }
+ }
+
+ for(iMidiDevice i = midiDevices.begin(); i != midiDevices.end(); ++i)
+ {
+ if((*i)->name() == s)
+ return Route(*i, channel);
+ }
+
+ // p3.3.49
+ if(s.left(ROUTE_MIDIPORT_NAME_PREFIX.length()) == ROUTE_MIDIPORT_NAME_PREFIX)
+ {
+ bool ok = false;
+ int port = s.mid(ROUTE_MIDIPORT_NAME_PREFIX.length()).toInt(&ok);
+ if(ok)
+ return Route(port, channel);
+ }
+ }
+ else
+ {
+ //if(dst)
+ //{
+ if(rtype == Route::TRACK_ROUTE)
+ {
+ TrackList* tl = song->tracks();
+ for(iTrack i = tl->begin(); i != tl->end(); ++i)
+ {
+ if((*i)->isMidiTrack())
+ {
+ MidiTrack* track = (MidiTrack*)*i;
+ if(track->name() == s)
+ return Route(track, channel);
+ }
+ else
+ {
+ AudioTrack* track = (AudioTrack*)*i;
+ if(track->name() == s)
+ return Route(track, channel);
+ //return Route(track, channel, 1);
+ //return Route(track, channel, track->channels());
+ }
+ }
+ }
+ else
+ //if((rtype == Route::JACK_MIDI_ROUTE) || (rtype == Route::ALSA_MIDI_ROUTE))
+ // TODO Distinguish the device types
+ if(rtype == Route::MIDI_DEVICE_ROUTE)
+ {
+ for(iMidiDevice i = midiDevices.begin(); i != midiDevices.end(); ++i)
+ {
+ if((*i)->name() == s)
+ //if (jmd->name() == rn)
+ return Route(*i, channel);
+
+ /*
+ MidiJackDevice* jmd = dynamic_cast<MidiJackDevice*>(*i);
+ if(jmd)
+ {
+ if(jmd->name() == s)
+ //if (jmd->name() == rn)
+ return Route(jmd);
+ }
+ MidiAlsaDevice* amd = dynamic_cast<MidiAlsaDevice*>(*i);
+ if(amd)
+ {
+ // TODO
+ if(amd->name() == s)
+ //if (amd->name() == rn)
+ return Route(amd);
+ }
+ */
+ }
+ }
+ else
+ if(rtype == Route::JACK_ROUTE)
+ {
+ if(checkAudioDevice())
+ {
+ void* p = audioDevice->findPort(s.toLatin1().constData());
+ if(p)
+ return Route(p, channel);
+ }
+ }
+ else
+ if(rtype == Route::MIDI_PORT_ROUTE) // p3.3.49
+ {
+ if(s.left(ROUTE_MIDIPORT_NAME_PREFIX.length()) == ROUTE_MIDIPORT_NAME_PREFIX)
+ {
+ bool ok = false;
+ int port = s.mid(ROUTE_MIDIPORT_NAME_PREFIX.length()).toInt(&ok);
+ if(ok)
+ return Route(port, channel);
+ }
+ }
+ }
+
+ printf(" name2route: <%s> not found\n", rn.toLatin1().constData());
+ return Route((Track*) 0, channel);
+ //return Route((Track*) 0, channel, 1);
+}
+
+//---------------------------------------------------------
+// checkRoute
+// return true if route is valid
+//---------------------------------------------------------
+
+bool checkRoute(const QString& s, const QString& d)
+ {
+ Route src(s, false, -1);
+ Route dst(d, true, -1);
+
+ if (!(src.isValid() && dst.isValid()) || (src == dst))
+ return false;
+ if (src.type == Route::JACK_ROUTE)
+ {
+ //if (dst.type != TRACK_ROUTE) {
+ // return false;
+ // }
+
+ if (dst.type == Route::TRACK_ROUTE)
+ {
+ if (dst.track->type() != Track::AUDIO_INPUT) {
+ return false;
+ }
+ src.channel = dst.channel;
+ RouteList* inRoutes = dst.track->inRoutes();
+ for (iRoute i = inRoutes->begin(); i != inRoutes->end(); ++i)
+ {
+ if (*i == src) { // route already there
+ return false;
+ }
+ }
+ }
+ else
+ //if (dst.type == Route::JACK_MIDI_ROUTE)
+ if (dst.type == Route::MIDI_DEVICE_ROUTE)
+ {
+ //src.channel = dst.channel;
+ src.channel = -1;
+ //dst.channel = -1;
+ RouteList* routes = dst.device->inRoutes();
+ for (iRoute i = routes->begin(); i != routes->end(); ++i)
+ {
+ if (*i == src) { // route already there
+ return false;
+ }
+ }
+ }
+ else
+ return false;
+ }
+ else if (dst.type == Route::JACK_ROUTE)
+ {
+ //if (src.type != TRACK_ROUTE) {
+ // return false;
+ // }
+
+ if (src.type == Route::TRACK_ROUTE)
+ {
+ if (src.track->type() != Track::AUDIO_OUTPUT) {
+ return false;
+ }
+ RouteList* outRoutes = src.track->outRoutes();
+ dst.channel = src.channel;
+ for (iRoute i = outRoutes->begin(); i != outRoutes->end(); ++i)
+ {
+ if (*i == dst) { // route already there
+ return false;
+ }
+ }
+ }
+ else
+ //if (src.type == Route::JACK_MIDI_ROUTE)
+ if (src.type == Route::MIDI_DEVICE_ROUTE)
+ {
+ RouteList* routes = src.device->outRoutes();
+ //dst.channel = src.channel;
+ dst.channel = -1;
+ //src.channel = -1;
+ for (iRoute i = routes->begin(); i != routes->end(); ++i)
+ {
+ if (*i == dst) { // route already there
+ return false;
+ }
+ }
+ }
+ else
+ return false;
+ }
+ else if (src.type == Route::MIDI_PORT_ROUTE) // p3.3.49
+ {
+ RouteList* outRoutes = midiPorts[src.midiPort].outRoutes();
+ for (iRoute i = outRoutes->begin(); i != outRoutes->end(); ++i)
+ {
+ if (*i == dst) { // route already there
+ return false;
+ }
+ }
+ }
+ //else if (dst.type == Route::MIDI_PORT_ROUTE) // p3.3.49
+ //{
+ //}
+ else
+ {
+ //RouteList* outRoutes = ((src.type == Route::JACK_MIDI_ROUTE) || (src.type == Route::ALSA_MIDI_ROUTE)) ?
+ // src.device->outRoutes() : src.track->outRoutes();
+ RouteList* outRoutes = (src.type == Route::MIDI_DEVICE_ROUTE) ? src.device->outRoutes() : src.track->outRoutes();
+
+ for (iRoute i = outRoutes->begin(); i != outRoutes->end(); ++i)
+ {
+ if (*i == dst) { // route already there
+ return false;
+ }
+ }
+ }
+ return true;
+ }
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+void Route::read(Xml& xml)
+{
+ QString s;
+ int dtype = MidiDevice::ALSA_MIDI;
+ int port = -1; // p3.3.49
+ unsigned char rtype = Route::TRACK_ROUTE;
+
+ for (;;)
+ {
+ const QString& tag = xml.s1();
+ Xml::Token token = xml.parse();
+ switch (token)
+ {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ //case Xml::TagStart:
+ // xml.unknown("Route");
+ // break;
+ case Xml::Attribut:
+ #ifdef ROUTE_DEBUG
+ printf("Route::read(): attribute:%s\n", tag.toLatin1().constData());
+ #endif
+ if(tag == "type")
+ rtype = xml.s2().toInt();
+ else
+ if(tag == "devtype")
+ {
+ dtype = xml.s2().toInt();
+ rtype = Route::MIDI_DEVICE_ROUTE;
+ }
+ else
+ if(tag == "name")
+ s = xml.s2();
+ else
+ if(tag == "mport") // p3.3.49
+ {
+ port = xml.s2().toInt();
+ rtype = Route::MIDI_PORT_ROUTE;
+ }
+ else
+ printf("Route::read(): unknown attribute:%s\n", tag.toLatin1().constData());
+ break;
+ case Xml::TagEnd:
+ #ifdef ROUTE_DEBUG
+ printf("Route::read(): tag end type:%d channel:%d name:%s\n", rtype, channel, s.toLatin1().constData());
+ #endif
+ if(rtype == MIDI_PORT_ROUTE) // p3.3.49
+ {
+ if(port >= 0 && port < MIDI_PORTS)
+ {
+ type = rtype;
+ midiPort = port;
+ }
+ else
+ printf("Route::read(): midi port <%d> out of range\n", port);
+ }
+ else
+ if(!s.isEmpty())
+ {
+ if(rtype == TRACK_ROUTE)
+ {
+ TrackList* tl = song->tracks();
+ iTrack i = tl->begin();
+ for ( ; i != tl->end(); ++i)
+ {
+ Track* t = *i;
+ if (t->name() == s)
+ {
+ track = t;
+ type = rtype;
+ break;
+ }
+ }
+ if(i == tl->end())
+ printf("Route::read(): track <%s> not found\n", s.toLatin1().constData());
+ }
+ else
+ if(rtype == JACK_ROUTE)
+ {
+ void* jport = audioDevice->findPort(s.toLatin1().constData());
+ if(jport == 0)
+ printf("Route::read(): jack port <%s> not found\n", s.toLatin1().constData());
+ else
+ {
+ jackPort = jport;
+ type = rtype;
+ }
+ }
+ else
+ if(rtype == MIDI_DEVICE_ROUTE)
+ {
+ iMidiDevice imd = midiDevices.begin();
+ for( ; imd != midiDevices.end(); ++imd)
+ {
+ MidiDevice* md = *imd;
+ if(md->name() == s && md->deviceType() == dtype)
+ {
+ // p3.3.45
+ // We found a device, but if it is not in use by the song (port is -1), ignore it.
+ // This prevents loading and propagation of bogus routes in the med file.
+ if(md->midiPort() == -1)
+ break;
+
+ device = md;
+ type = rtype;
+ break;
+ }
+ }
+ if(imd == midiDevices.end())
+ printf("Route::read(): midi device <%s> not found\n", s.toLatin1().constData());
+ }
+ }
+ return;
+ default:
+ break;
+ }
+ }
+}
+
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+void Song::readRoute(Xml& xml)
+{
+ QString src;
+ QString dst;
+ int ch = -1;
+ int chs = -1;
+ int remch = -1;
+
+ Route sroute, droute;
+
+ for (;;)
+ {
+ const QString& tag = xml.s1();
+ Xml::Token token = xml.parse();
+ switch (token)
+ {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ // p3.3.38 2010/02/03 Support old routes in med files. Now obsolete!
+ if (tag == "srcNode")
+ src = xml.parse1();
+ else if (tag == "dstNode")
+ dst = xml.parse1();
+ // Support new routes.
+ else if (tag == "source")
+ {
+ sroute.read(xml);
+ sroute.channel = ch;
+ sroute.channels = chs;
+ sroute.remoteChannel = remch;
+ }
+ else if (tag == "dest")
+ {
+ droute.read(xml);
+ droute.channel = ch;
+ droute.channels = chs;
+ droute.remoteChannel = remch;
+ }
+ else
+ xml.unknown("readRoute");
+ break;
+ case Xml::Attribut:
+ #ifdef ROUTE_DEBUG
+ printf("Song::readRoute(): attribute:%s\n", tag.toLatin1().constData());
+ #endif
+ if(tag == "channel")
+ ch = xml.s2().toInt();
+ else
+ if(tag == "channels")
+ chs = xml.s2().toInt();
+ else
+ if(tag == "remch")
+ remch = xml.s2().toInt();
+ else
+ if(tag == "channelMask") // p3.3.50 New channel mask for midi port-track routes.
+ ch = xml.s2().toInt();
+ else
+ printf("Song::readRoute(): unknown attribute:%s\n", tag.toLatin1().constData());
+ break;
+ case Xml::TagEnd:
+ if (xml.s1() == "Route")
+ {
+ // Support old routes in med files. Now obsolete!
+ if(!src.isEmpty() && !dst.isEmpty())
+ {
+ Route s = name2route(src, false);
+ Route d = name2route(dst, true);
+ addRoute(s, d);
+ }
+ else
+ // Support new routes.
+ if(sroute.isValid() && droute.isValid())
+ {
+ // p3.3.49 Support pre- 1.1-RC2 midi-device-to-track routes. Obsolete. Replaced with midi port routes.
+ if(sroute.type == Route::MIDI_DEVICE_ROUTE && droute.type == Route::TRACK_ROUTE)
+ {
+ if(sroute.device->midiPort() >= 0 && sroute.device->midiPort() < MIDI_PORTS
+ && ch >= 0 && ch < MIDI_CHANNELS) // p3.3.50
+ {
+ sroute.midiPort = sroute.device->midiPort();
+ sroute.device = 0;
+ sroute.type = Route::MIDI_PORT_ROUTE;
+
+ sroute.channel = 1 << ch; // p3.3.50 Convert to new bit-wise channel mask.
+ droute.channel = sroute.channel;
+
+ addRoute(sroute, droute);
+ }
+ else
+ printf(" Warning - device:%s to track route, no device midi port or chan:%d out of range. Ignoring route!\n",
+ sroute.device->name().toLatin1().constData(), ch);
+ }
+ else if(sroute.type == Route::TRACK_ROUTE && droute.type == Route::MIDI_DEVICE_ROUTE)
+ {
+ if(droute.device->midiPort() >= 0 && droute.device->midiPort() < MIDI_PORTS
+ && ch >= 0 && ch < MIDI_CHANNELS) // p3.3.50
+ {
+ droute.midiPort = droute.device->midiPort();
+ droute.device = 0;
+ droute.type = Route::MIDI_PORT_ROUTE;
+
+ droute.channel = 1 << ch; // p3.3.50 Convert to new bit-wise channel mask.
+ sroute.channel = droute.channel;
+
+ addRoute(sroute, droute);
+ }
+ else
+ printf(" Warning - track to device:%s route, no device midi port or chan:%d out of range. Ignoring route!\n",
+ droute.device->name().toLatin1().constData(), ch);
+ }
+ else
+ {
+ //printf("adding new route...\n");
+ addRoute(sroute, droute);
+ }
+ }
+ else
+ printf(" Warning - route invalid. Ignoring route!\n");
+
+ return;
+ }
+ default:
+ break;
+ }
+ }
+}
+
+//---------------------------------------------------------
+// removeRoute
+//---------------------------------------------------------
+
+void RouteList::removeRoute(const Route& r)
+ {
+ //printf("RouteList::removeRoute:\n");
+ //r.dump();
+ //printf("Searching routes:\n");
+
+ for (iRoute i = begin(); i != end(); ++i) {
+ //i->dump();
+ if (r == *i) {
+ erase(i);
+ return;
+ }
+ }
+ printf("internal error: cannot remove Route\n");
+ }
+
+//---------------------------------------------------------
+// dump
+//---------------------------------------------------------
+
+void Route::dump() const
+{
+ if (type == TRACK_ROUTE)
+ {
+ if(track)
+ printf("Route dump: track <%s> channel %d channels %d\n", track->name().toLatin1().constData(), channel, channels);
+ //printf("Route dump: track <%s> channel %d\n", track->name().toLatin1().constData(), channel);
+ //else
+ // printf("Route dump: invalid track, channel %d\n", channel);
+ }
+ else
+ if (type == JACK_ROUTE)
+ {
+ if(checkAudioDevice())
+ printf("Route dump: jack audio port <%s> channel %d\n", audioDevice->portName(jackPort).toLatin1().constData(), channel);
+ }
+ else
+ if (type == MIDI_PORT_ROUTE) // p3.3.49
+ {
+ printf("Route dump: midi port <%d> channel mask %d\n", midiPort, channel);
+ }
+ else
+ if (type == MIDI_DEVICE_ROUTE)
+ {
+ printf("Route dump: ");
+ if(device)
+ {
+ if(device->deviceType() == MidiDevice::JACK_MIDI)
+ {
+ if(checkAudioDevice())
+ //printf("jack midi port device <%s> ", audioDevice->portName(device->clientPort()).toLatin1().constData());
+ // p3.3.55
+ {
+ printf("jack midi device <%s> ", device->name().toLatin1().constData());
+ if(device->inClientPort())
+ printf("input port <%s> ",
+ audioDevice->portName(device->inClientPort()).toLatin1().constData());
+ if(device->outClientPort())
+ printf("output port <%s> ",
+ audioDevice->portName(device->outClientPort()).toLatin1().constData());
+ }
+ }
+ else
+ if(device->deviceType() == MidiDevice::ALSA_MIDI)
+ printf("alsa midi device <%s> ", device->name().toLatin1().constData());
+ else
+ if(device->deviceType() == MidiDevice::SYNTH_MIDI)
+ printf("synth midi device <%s> ", device->name().toLatin1().constData());
+ else
+ printf("is midi but unknown device type:%d, ", device->deviceType());
+ }
+ else
+ printf("is midi but invalid device, ");
+
+ printf("channel:%d\n", channel);
+ }
+ else
+ printf("Route dump: unknown route type:%d\n", type);
+}
+
+//---------------------------------------------------------
+// operator==
+//---------------------------------------------------------
+
+bool Route::operator==(const Route& a) const
+{
+ //if (type == MIDI_PORT_ROUTE) // p3.3.50
+ //{
+ // Use new channel mask. True if all the bits in a.channel are contained in this route's channel.
+ // Hmm, not commutative... Two such routes are equal if _____ what? ... Code-specific for now.
+ // return midiPort == a.midiPort && (channel & a.channel) == a.channel;
+ //}
+ //else
+
+ if ((type == a.type) && (channel == a.channel))
+ //if (type == a.type)
+ {
+ if (type == TRACK_ROUTE)
+ {
+ return track == a.track && channels == a.channels && remoteChannel == a.remoteChannel;
+ }
+ else
+ if(channel == a.channel)
+ {
+ if (type == JACK_ROUTE)
+ {
+ //if (!checkAudioDevice()) return false;
+ //return audioDevice->portName(jackPort) == audioDevice->portName(a.jackPort);
+ // p3.3.55 Simplified.
+ return jackPort == a.jackPort;
+ }
+ else
+ if (type == MIDI_PORT_ROUTE) // p3.3.49
+ {
+ return midiPort == a.midiPort;
+ }
+ else
+ if (type == MIDI_DEVICE_ROUTE)
+ {
+ // p3.3.55 Changed for unified jack in/out devices, the actual port names are now different from device name.
+ // Like this: device: "MyJackDevice1" -> inport: "MyJackDevice1_in" outport: "MyJackDevice1_out"
+ /*
+ if(device && a.device && device->deviceType() == a.device->deviceType())
+ {
+ if(device->deviceType() == MidiDevice::JACK_MIDI)
+ {
+ if (!checkAudioDevice()) return false;
+ return audioDevice->portName(device->clientPort()) == audioDevice->portName(a.device->clientPort());
+ }
+ else
+ if(device->deviceType() == MidiDevice::ALSA_MIDI)
+ // TODO: OK ??
+ return device->clientPort() == a.device->clientPort() && (channel == a.channel);
+ else
+ if(device->deviceType() == MidiDevice::SYNTH_MIDI)
+ return device->name() == a.device->name();
+ }
+ */
+ return device == a.device;
+ }
+ }
+ }
+ return false;
+}
+
diff --git a/attic/muse2-oom/muse2/muse/route.h b/attic/muse2-oom/muse2/muse/route.h
new file mode 100644
index 00000000..2f29bcf8
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/route.h
@@ -0,0 +1,103 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: route.h,v 1.5.2.1 2008/05/21 00:28:52 terminator356 Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __ROUTE_H__
+#define __ROUTE_H__
+
+#include <vector>
+#include <map>
+
+#include "globaldefs.h"
+
+class QString;
+class Track;
+class MidiDevice;
+class Xml;
+
+//---------------------------------------------------------
+// Route
+//---------------------------------------------------------
+
+struct Route {
+ enum { TRACK_ROUTE=0, JACK_ROUTE=1, MIDI_DEVICE_ROUTE=2, MIDI_PORT_ROUTE=3 }; // p3.3.49
+
+ union {
+ //AudioTrack* track;
+ Track* track;
+ //MidiJackDevice* device;
+ MidiDevice* device;
+ void* jackPort;
+ };
+
+ int midiPort; // p3.3.49 Midi port number. Best not to put this in the union to avoid problems?
+
+ //snd_seq_addr_t alsaAdr;
+
+ // Starting source channel (of the owner of this route). Normally zero for mono or stereo tracks, higher for multi-channel tracks.
+ // p3.3.50 NOTICE: channel is now a bit-wise channel mask, for MidiPort <-> MidiTrack routes.
+ // This saves many routes: Instead of one route per channel as before, there can now be only one single route with a channel mask,
+ // for each MidiPort <-> MidiTrack combination.
+ int channel;
+ // Number of (audio) channels being routed.
+ int channels;
+
+ // Allow for multi-channel syntis to feed to/from regular tracks, and to feed one to another.
+ // If a synti is feeding to/from a regular track, remoteChannel is the 'starting' channel of this multi-channel synti.
+ // If a synti is feeding to/from another synti, this is not used and individual channels are routed using channel instead.
+ int remoteChannel;
+
+ unsigned char type; // 0 - track, 1 - jackPort, 2 - midi device, 3 - midi port
+
+ Route(void* t, int ch=-1);
+ Route(Track* t, int ch = -1, int chans = -1);
+ Route(MidiDevice* d, int ch);
+ Route(int port, int ch); // p3.3.49
+ Route(const QString&, bool dst, int ch, int rtype = -1);
+ Route();
+
+ QString name() const;
+ bool operator==(const Route& a) const;
+ bool isValid() const {
+ return ((type == TRACK_ROUTE) && (track != 0)) || ((type == JACK_ROUTE) && (jackPort != 0)) ||
+ ((type == MIDI_DEVICE_ROUTE) && (device != 0)) ||
+ ((type == MIDI_PORT_ROUTE) && (midiPort >= 0) && (midiPort < MIDI_PORTS)); // p3.3.49
+ }
+ void read(Xml& xml);
+ void dump() const;
+ };
+
+
+//---------------------------------------------------------
+// RouteList
+//---------------------------------------------------------
+
+struct RouteList : public std::vector<Route> {
+ void removeRoute(const Route& r);
+ };
+
+typedef RouteList::iterator iRoute;
+typedef RouteList::const_iterator ciRoute;
+
+extern void addRoute(Route, Route);
+extern void removeRoute(Route, Route);
+extern void removeAllRoutes(Route, Route); // p3.3.55
+extern Route name2route(const QString&, bool dst, int rtype = -1);
+extern bool checkRoute(const QString&, const QString&);
+
+//---------------------------------------------------------
+// RouteMenuMap
+//---------------------------------------------------------
+
+typedef std::map<int, Route, std::less<int> >::iterator iRouteMenuMap;
+typedef std::map<int, Route, std::less<int> >::const_iterator ciRouteMenuMap;
+typedef std::map<int, Route, std::less<int> > RouteMenuMap;
+typedef std::pair<int, Route> pRouteMenuMap;
+typedef std::pair<iRouteMenuMap, bool > rpRouteMenuMap;
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/seqmsg.cpp b/attic/muse2-oom/muse2/muse/seqmsg.cpp
new file mode 100644
index 00000000..d2225190
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/seqmsg.cpp
@@ -0,0 +1,1269 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: seqmsg.cpp,v 1.32.2.17 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+
+#include "song.h"
+#include "midiport.h"
+#include "minstrument.h"
+#include "app.h"
+#include "amixer.h"
+#include "tempo.h"
+///#include "sig.h"
+#include "al/sig.h"
+#include "audio.h"
+#include "mididev.h"
+#include "audiodev.h"
+#include "alsamidi.h"
+#include "audio.h"
+#include "arranger.h"
+#include "plugin.h"
+#include "driver/jackmidi.h"
+
+//---------------------------------------------------------
+// sendMsg
+//---------------------------------------------------------
+
+void Audio::sendMsg(AudioMsg* m)
+ {
+ static int sno = 0;
+
+ if (_running) {
+ m->serialNo = sno++;
+ //DEBUG:
+ msg = m;
+ // wait for next audio "process" call to finish operation
+ int no = -1;
+ int rv = read(fromThreadFdr, &no, sizeof(int));
+ if (rv != sizeof(int))
+ perror("Audio: read pipe failed");
+ else if (no != (sno-1)) {
+ fprintf(stderr, "audio: bad serial number, read %d expected %d\n",
+ no, sno-1);
+ }
+ }
+ else {
+ // if audio is not running (during initialization)
+ // process commands immediatly
+ processMsg(m);
+ }
+ }
+
+//---------------------------------------------------------
+// sendMessage
+// send request from gui to sequencer
+// wait until request is processed
+//---------------------------------------------------------
+
+bool Audio::sendMessage(AudioMsg* m, bool doUndo)
+ {
+ if (doUndo)
+ song->startUndo();
+ sendMsg(m);
+ if (doUndo)
+ song->endUndo(0); // song->endMsgCmd();
+ return false;
+ }
+
+//---------------------------------------------------------
+// msgRemoveRoute
+//---------------------------------------------------------
+
+void Audio::msgRemoveRoute(Route src, Route dst)
+{
+ msgRemoveRoute1(src, dst);
+ //if (!checkAudioDevice()) return;
+ if (src.type == Route::JACK_ROUTE)
+ {
+ if (!checkAudioDevice()) return;
+
+ //if(dst.type == Route::JACK_MIDI_ROUTE)
+ if(dst.type == Route::MIDI_DEVICE_ROUTE)
+ {
+ //MidiJackDevice* jmd = dynamic_cast<MidiJackDevice*>(dst.device);
+ //if(jmd)
+ if(dst.device)
+ {
+ if(dst.device->deviceType() == MidiDevice::JACK_MIDI)
+ //audioDevice->disconnect(src.jackPort, dst.device->clientPort());
+ audioDevice->disconnect(src.jackPort, dst.device->inClientPort()); // p3.3.55
+ //else
+ //{
+ // TODO...
+ //MidiAlsaDevice* amd = dynamic_cast<MidiAlsaDevice*>(dst.device);
+ //if(amd)
+ //}
+ }
+ }
+ else
+ audioDevice->disconnect(src.jackPort, ((AudioInput*)dst.track)->jackPort(dst.channel));
+ }
+ else if (dst.type == Route::JACK_ROUTE)
+ {
+ if (!checkAudioDevice()) return;
+
+ //if(src.type == Route::JACK_MIDI_ROUTE)
+ if(src.type == Route::MIDI_DEVICE_ROUTE)
+ {
+ //MidiJackDevice* jmd = dynamic_cast<MidiJackDevice*>(src.device);
+ //if(jmd)
+ if(src.device)
+ {
+ if(src.device->deviceType() == MidiDevice::JACK_MIDI)
+ //audioDevice->disconnect(src.device->clientPort(), dst.jackPort);
+ audioDevice->disconnect(src.device->outClientPort(), dst.jackPort); // p3.3.55
+ //else
+ //{
+ // TODO...
+ //MidiAlsaDevice* amd = dynamic_cast<MidiAlsaDevice*>(src.device);
+ //if(amd)
+ //}
+ }
+ }
+ else
+ audioDevice->disconnect(((AudioOutput*)src.track)->jackPort(src.channel), dst.jackPort);
+ }
+}
+
+//---------------------------------------------------------
+// msgRemoveRoute1
+//---------------------------------------------------------
+
+void Audio::msgRemoveRoute1(Route src, Route dst)
+ {
+ AudioMsg msg;
+ msg.id = AUDIO_ROUTEREMOVE;
+ msg.sroute = src;
+ msg.droute = dst;
+ sendMsg(&msg);
+ }
+
+//---------------------------------------------------------
+// msgRemoveRoutes
+//---------------------------------------------------------
+
+// p3.3.55
+void Audio::msgRemoveRoutes(Route src, Route dst)
+{
+ msgRemoveRoutes1(src, dst);
+
+ // TODO
+ /*
+ //if (!checkAudioDevice()) return;
+ if (src.type == Route::JACK_ROUTE)
+ {
+ if (!checkAudioDevice()) return;
+
+ //if(dst.type == Route::JACK_MIDI_ROUTE)
+ if(dst.type == Route::MIDI_DEVICE_ROUTE)
+ {
+ //MidiJackDevice* jmd = dynamic_cast<MidiJackDevice*>(dst.device);
+ //if(jmd)
+ if(dst.device)
+ {
+ if(dst.device->deviceType() == MidiDevice::JACK_MIDI)
+ //audioDevice->disconnect(src.jackPort, dst.device->clientPort());
+ audioDevice->disconnect(src.jackPort, dst.device->inClientPort());
+ //else
+ //{
+ // TODO...
+ //MidiAlsaDevice* amd = dynamic_cast<MidiAlsaDevice*>(dst.device);
+ //if(amd)
+ //}
+ }
+ }
+ else
+ audioDevice->disconnect(src.jackPort, ((AudioInput*)dst.track)->jackPort(dst.channel));
+ }
+ else if (dst.type == Route::JACK_ROUTE)
+ {
+ if (!checkAudioDevice()) return;
+
+ //if(src.type == Route::JACK_MIDI_ROUTE)
+ if(src.type == Route::MIDI_DEVICE_ROUTE)
+ {
+ //MidiJackDevice* jmd = dynamic_cast<MidiJackDevice*>(src.device);
+ //if(jmd)
+ if(src.device)
+ {
+ if(src.device->deviceType() == MidiDevice::JACK_MIDI)
+ //audioDevice->disconnect(src.device->clientPort(), dst.jackPort);
+ audioDevice->disconnect(src.device->outClientPort(), dst.jackPort);
+ //else
+ //{
+ // TODO...
+ //MidiAlsaDevice* amd = dynamic_cast<MidiAlsaDevice*>(src.device);
+ //if(amd)
+ //}
+ }
+ }
+ else
+ audioDevice->disconnect(((AudioOutput*)src.track)->jackPort(src.channel), dst.jackPort);
+ }
+
+ */
+}
+
+//---------------------------------------------------------
+// msgRemoveRoutes1
+//---------------------------------------------------------
+
+// p3.3.55
+void Audio::msgRemoveRoutes1(Route src, Route dst)
+ {
+ AudioMsg msg;
+ msg.id = AUDIO_REMOVEROUTES;
+ msg.sroute = src;
+ msg.droute = dst;
+ sendMsg(&msg);
+ }
+
+//---------------------------------------------------------
+// msgAddRoute
+//---------------------------------------------------------
+
+void Audio::msgAddRoute(Route src, Route dst)
+ {
+ if (src.type == Route::JACK_ROUTE)
+ {
+ if (!checkAudioDevice()) return;
+ if (isRunning())
+ {
+ //if(dst.type == Route::JACK_MIDI_ROUTE)
+ if(dst.type == Route::MIDI_DEVICE_ROUTE)
+ {
+ //MidiJackDevice* jmd = dynamic_cast<MidiJackDevice*>(dst.device);
+ //if(jmd)
+ if(dst.device)
+ {
+ if(dst.device->deviceType() == MidiDevice::JACK_MIDI)
+ //audioDevice->connect(src.jackPort, dst.device->clientPort());
+ audioDevice->connect(src.jackPort, dst.device->inClientPort()); // p3.3.55
+ //else
+ //{
+ // TODO...
+ //MidiAlsaDevice* amd = dynamic_cast<MidiAlsaDevice*>(dst.device);
+ //if(amd)
+ //}
+ }
+ }
+ else
+ audioDevice->connect(src.jackPort, ((AudioInput*)dst.track)->jackPort(dst.channel));
+ }
+ }
+ else if (dst.type == Route::JACK_ROUTE)
+ {
+ if (!checkAudioDevice()) return;
+ if (audio->isRunning())
+ {
+ //if(src.type == Route::JACK_MIDI_ROUTE)
+ if(src.type == Route::MIDI_DEVICE_ROUTE)
+ {
+ //MidiJackDevice* jmd = dynamic_cast<MidiJackDevice*>(src.device);
+ //if(jmd)
+ if(src.device)
+ {
+ if(src.device->deviceType() == MidiDevice::JACK_MIDI)
+ //audioDevice->connect(src.device->clientPort(), dst.jackPort);
+ audioDevice->connect(src.device->outClientPort(), dst.jackPort); // p3.3.55
+ //else
+ //{
+ // TODO...
+ //MidiAlsaDevice* amd = dynamic_cast<MidiAlsaDevice*>(src.device);
+ //if(amd)
+ //}
+ }
+ }
+ else
+ audioDevice->connect(((AudioOutput*)src.track)->jackPort(dst.channel), dst.jackPort);
+ }
+ }
+ msgAddRoute1(src, dst);
+ }
+
+//---------------------------------------------------------
+// msgAddRoute1
+//---------------------------------------------------------
+
+void Audio::msgAddRoute1(Route src, Route dst)
+ {
+ AudioMsg msg;
+ msg.id = AUDIO_ROUTEADD;
+ msg.sroute = src;
+ msg.droute = dst;
+ sendMsg(&msg);
+ }
+
+//---------------------------------------------------------
+// msgAddPlugin
+//---------------------------------------------------------
+
+void Audio::msgAddPlugin(AudioTrack* node, int idx, PluginI* plugin)
+ {
+ AudioMsg msg;
+ msg.id = AUDIO_ADDPLUGIN;
+ msg.snode = node;
+ msg.ival = idx;
+ msg.plugin = plugin;
+ sendMsg(&msg);
+ }
+
+//---------------------------------------------------------
+// msgSetRecord
+//---------------------------------------------------------
+
+void Audio::msgSetRecord(AudioTrack* node, bool val)
+ {
+ AudioMsg msg;
+ msg.id = AUDIO_RECORD;
+ msg.snode = node;
+ msg.ival = int(val);
+ sendMsg(&msg);
+ }
+
+//---------------------------------------------------------
+// msgSetVolume
+//---------------------------------------------------------
+
+void Audio::msgSetVolume(AudioTrack* src, double val)
+ {
+ AudioMsg msg;
+ msg.id = AUDIO_VOL;
+ msg.snode = src;
+ msg.dval = val;
+ sendMsg(&msg);
+ //muse->arranger->controllerChanged(src);
+ }
+
+//---------------------------------------------------------
+// msgSetPan
+//---------------------------------------------------------
+
+void Audio::msgSetPan(AudioTrack* node, double val)
+ {
+ AudioMsg msg;
+ msg.id = AUDIO_PAN;
+ msg.snode = node;
+ msg.dval = val;
+ sendMsg(&msg);
+ //muse->arranger->controllerChanged(node);
+ }
+
+//---------------------------------------------------------
+// msgSetPrefader
+//---------------------------------------------------------
+
+void Audio::msgSetPrefader(AudioTrack* node, int val)
+ {
+ AudioMsg msg;
+ msg.id = AUDIO_SET_PREFADER;
+ msg.snode = node;
+ msg.ival = val;
+ sendMsg(&msg);
+ }
+
+//---------------------------------------------------------
+// msgSetChannels
+//---------------------------------------------------------
+
+void Audio::msgSetChannels(AudioTrack* node, int n)
+ {
+ if (n == node->channels())
+ return;
+ QString name = node->name();
+ int mc = std::max(n, node->channels());
+
+ if (!name.isEmpty())
+ {
+ if (node->type() == Track::AUDIO_INPUT)
+ {
+ if (!checkAudioDevice()) return;
+ AudioInput* ai = (AudioInput*)node;
+ for (int i = 0; i < mc; ++i)
+ {
+ if (i < n && ai->jackPort(i) == 0)
+ {
+ char buffer[128];
+ snprintf(buffer, 128, "%s-%d", name.toLatin1().constData(), i);
+ //ai->setJackPort(i, audioDevice->registerInPort(buffer));
+ ai->setJackPort(i, audioDevice->registerInPort(buffer, false));
+ }
+ else if ((i >= n) && ai->jackPort(i))
+ {
+ RouteList* ir = node->inRoutes();
+ for (iRoute ii = ir->begin(); ii != ir->end(); ++ii)
+ {
+ Route r = *ii;
+ if ((r.type == Route::JACK_ROUTE) && (r.channel == i))
+ {
+ msgRemoveRoute(r, Route(node,i));
+ break;
+ }
+ }
+ audioDevice->unregisterPort(ai->jackPort(i));
+ ai->setJackPort(i, 0);
+ }
+ }
+ }
+ else if (node->type() == Track::AUDIO_OUTPUT)
+ {
+ if (!checkAudioDevice()) return;
+ AudioOutput* ao = (AudioOutput*)node;
+ for (int i = 0; i < mc; ++i)
+ {
+ void* jp = ao->jackPort(i);
+ if (i < n && jp == 0)
+ {
+ char buffer[128];
+ snprintf(buffer, 128, "%s-%d", name.toLatin1().constData(), i);
+ //ao->setJackPort(i, audioDevice->registerOutPort(buffer));
+ ao->setJackPort(i, audioDevice->registerOutPort(buffer, false));
+ }
+ else if (i >= n && jp)
+ {
+ RouteList* ir = node->outRoutes();
+ for (iRoute ii = ir->begin(); ii != ir->end(); ++ii)
+ {
+ Route r = *ii;
+ if ((r.type == Route::JACK_ROUTE) && (r.channel == i))
+ {
+ msgRemoveRoute(Route(node,i), r);
+ break;
+ }
+ }
+ audioDevice->unregisterPort(jp);
+ ao->setJackPort(i, 0);
+ }
+ }
+ }
+ }
+
+ /* TODO TODO: Change all stereo routes to mono.
+ // If we are going from stereo to mono we need to disconnect any stray synti 'mono last channel'...
+ if(n == 1 && node->channels() > 1)
+ {
+ // This should always happen - syntis are fixed channels, user cannot change them. But to be safe...
+ if(node->type() != Track::AUDIO_SOFTSYNTH)
+ {
+ if(node->type() != Track::AUDIO_INPUT)
+ {
+ RouteList* rl = node->inRoutes();
+ for(iRoute r = rl->begin(); r != rl->end(); ++r)
+ {
+ // Only interested in synth tracks.
+ if(r->type != Route::TRACK_ROUTE || r->track->type() != Track::AUDIO_SOFTSYNTH)
+ continue;
+ // If it's the last channel...
+ if(r->channel + 1 == ((AudioTrack*)r->track)->totalOutChannels())
+ {
+ msgRemoveRoute(*r, Route(node, r->channel));
+ //msgRemoveRoute(r, Route(node, r->remoteChannel));
+ break;
+ }
+ }
+ }
+
+ if(node->type() != Track::AUDIO_OUTPUT)
+ {
+ RouteList* rl = node->outRoutes();
+ for(iRoute r = rl->begin(); r != rl->end(); ++r)
+ {
+ // Only interested in synth tracks.
+ if(r->type != Route::TRACK_ROUTE || r->track->type() != Track::AUDIO_SOFTSYNTH)
+ continue;
+ // If it's the last channel...
+ if(r->channel + 1 == ((AudioTrack*)r->track)->totalOutChannels())
+ {
+ msgRemoveRoute(Route(node, r->channel), *r);
+ //msgRemoveRoute(Route(node, r->remoteChannel), r);
+ break;
+ }
+ }
+ }
+ }
+ }
+ */
+
+ AudioMsg msg;
+ msg.id = AUDIO_SET_CHANNELS;
+ msg.snode = node;
+ msg.ival = n;
+ sendMsg(&msg);
+ }
+
+//---------------------------------------------------------
+// msgSetPluginCtrlVal
+//---------------------------------------------------------
+
+//void Audio::msgSetPluginCtrlVal(PluginI* plugin, int param, double val)
+// p3.3.43
+void Audio::msgSetPluginCtrlVal(AudioTrack* track, int param, double val)
+{
+ AudioMsg msg;
+
+ msg.id = AUDIO_SET_PLUGIN_CTRL_VAL;
+ msg.ival = param;
+ msg.dval = val;
+ //msg.plugin = plugin;
+ msg.snode = track;
+ sendMsg(&msg);
+ //muse->arranger->controllerChanged(track);
+}
+
+//---------------------------------------------------------
+// msgSwapControllerIDX
+//---------------------------------------------------------
+
+void Audio::msgSwapControllerIDX(AudioTrack* node, int idx1, int idx2)
+{
+ AudioMsg msg;
+
+ msg.id = AUDIO_SWAP_CONTROLLER_IDX;
+ msg.snode = node;
+ msg.a = idx1;
+ msg.b = idx2;
+ sendMsg(&msg);
+ //muse->arranger->controllerChanged(node);
+}
+
+//---------------------------------------------------------
+// msgClearControllerEvents
+//---------------------------------------------------------
+
+void Audio::msgClearControllerEvents(AudioTrack* node, int acid)
+{
+ AudioMsg msg;
+
+ msg.id = AUDIO_CLEAR_CONTROLLER_EVENTS;
+ msg.snode = node;
+ msg.ival = acid;
+ sendMsg(&msg);
+ //muse->arranger->controllerChanged(node);
+}
+
+//---------------------------------------------------------
+// msgSeekPrevACEvent
+//---------------------------------------------------------
+
+void Audio::msgSeekPrevACEvent(AudioTrack* node, int acid)
+{
+ AudioMsg msg;
+
+ msg.id = AUDIO_SEEK_PREV_AC_EVENT;
+ msg.snode = node;
+ msg.ival = acid;
+ sendMsg(&msg);
+}
+
+//---------------------------------------------------------
+// msgSeekNextACEvent
+//---------------------------------------------------------
+
+void Audio::msgSeekNextACEvent(AudioTrack* node, int acid)
+{
+ AudioMsg msg;
+
+ msg.id = AUDIO_SEEK_NEXT_AC_EVENT;
+ msg.snode = node;
+ msg.ival = acid;
+ sendMsg(&msg);
+}
+
+//---------------------------------------------------------
+// msgEraseACEvent
+//---------------------------------------------------------
+
+void Audio::msgEraseACEvent(AudioTrack* node, int acid, int frame)
+{
+ AudioMsg msg;
+
+ msg.id = AUDIO_ERASE_AC_EVENT;
+ msg.snode = node;
+ msg.ival = acid;
+ msg.a = frame;
+ sendMsg(&msg);
+ //muse->arranger->controllerChanged(node);
+}
+
+//---------------------------------------------------------
+// msgEraseRangeACEvents
+//---------------------------------------------------------
+
+void Audio::msgEraseRangeACEvents(AudioTrack* node, int acid, int frame1, int frame2)
+{
+ AudioMsg msg;
+
+ msg.id = AUDIO_ERASE_RANGE_AC_EVENTS;
+ msg.snode = node;
+ msg.ival = acid;
+ msg.a = frame1;
+ msg.b = frame2;
+ sendMsg(&msg);
+ //muse->arranger->controllerChanged(node);
+}
+
+//---------------------------------------------------------
+// msgAddACEvent
+//---------------------------------------------------------
+
+void Audio::msgAddACEvent(AudioTrack* node, int acid, int frame, double val)
+{
+ AudioMsg msg;
+
+ msg.id = AUDIO_ADD_AC_EVENT;
+ msg.snode = node;
+ msg.ival = acid;
+ msg.a = frame;
+ msg.dval = val;
+ sendMsg(&msg);
+ //muse->arranger->controllerChanged(node);
+}
+
+//---------------------------------------------------------
+// msgSetSolo
+//---------------------------------------------------------
+
+void Audio::msgSetSolo(Track* track, bool val)
+{
+ AudioMsg msg;
+ msg.id = AUDIO_SET_SOLO;
+ msg.track = track;
+ msg.ival = int(val);
+ sendMsg(&msg);
+}
+
+//---------------------------------------------------------
+// msgSetSegSize
+//---------------------------------------------------------
+
+void Audio::msgSetSegSize(int bs, int sr)
+ {
+ AudioMsg msg;
+ msg.id = AUDIO_SET_SEG_SIZE;
+ msg.ival = bs;
+ msg.iival = sr;
+ sendMsg(&msg);
+ }
+
+//---------------------------------------------------------
+// msgSeek
+//---------------------------------------------------------
+
+void Audio::msgSeek(const Pos& pos)
+ {
+ if (!checkAudioDevice()) return;
+ //audioDevice->seekTransport(pos.frame());
+ // p3.3.23
+ //printf("Audio::msgSeek before audioDevice->seekTransport frame:%d\n", pos.frame());
+ audioDevice->seekTransport(pos);
+ // p3.3.23
+ //printf("Audio::msgSeek after audioDevice->seekTransport frame:%d\n", pos.frame());
+ }
+
+//---------------------------------------------------------
+// msgUndo
+//---------------------------------------------------------
+
+void Audio::msgUndo()
+ {
+ AudioMsg msg;
+ msg.id = SEQM_UNDO;
+ sendMsg(&msg);
+ }
+
+//---------------------------------------------------------
+// msgRedo
+//---------------------------------------------------------
+
+void Audio::msgRedo()
+ {
+ AudioMsg msg;
+ msg.id = SEQM_REDO;
+ sendMsg(&msg);
+ }
+
+//---------------------------------------------------------
+// msgPlay
+//---------------------------------------------------------
+
+void Audio::msgPlay(bool val)
+ {
+ if (val) {
+ if (audioDevice)
+ {
+ unsigned sfr = song->cPos().frame();
+ unsigned dcfr = audioDevice->getCurFrame();
+ if(dcfr != sfr)
+ //audioDevice->seekTransport(sfr);
+ audioDevice->seekTransport(song->cPos());
+ audioDevice->startTransport();
+ }
+
+ }else {
+ if (audioDevice)
+ audioDevice->stopTransport();
+ _bounce = false;
+ }
+ }
+
+//---------------------------------------------------------
+// msgShowInstrumentGui
+//---------------------------------------------------------
+
+void Audio::msgShowInstrumentGui(MidiInstrument* instr, bool val)
+ {
+ instr->showGui(val);
+ AudioMsg msg;
+ msg.id = MIDI_SHOW_INSTR_GUI;
+ msg.p1 = instr;
+ msg.a = val;
+ sendMessage(&msg, false);
+ }
+
+//---------------------------------------------------------
+// msgAddTrack
+//---------------------------------------------------------
+
+void Song::msgInsertTrack(Track* track, int idx, bool doUndoFlag)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_ADD_TRACK;
+ msg.track = track;
+ msg.ival = idx;
+ if (doUndoFlag) {
+ song->startUndo();
+ undoOp(UndoOp::AddTrack, idx, track);
+ }
+ audio->sendMsg(&msg);
+ if (doUndoFlag)
+ endUndo(SC_TRACK_INSERTED);
+ }
+
+//---------------------------------------------------------
+// msgRemoveTrack
+//---------------------------------------------------------
+
+void Audio::msgRemoveTrack(Track* track, bool doUndoFlag)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_REMOVE_TRACK;
+ msg.track = track;
+ sendMessage(&msg, doUndoFlag);
+ }
+
+//---------------------------------------------------------
+// msgRemoveTracks
+// remove all selected tracks
+//---------------------------------------------------------
+
+void Audio::msgRemoveTracks()
+{
+ bool loop;
+ do
+ {
+ loop = false;
+ TrackList* tl = song->tracks();
+ for (iTrack t = tl->begin(); t != tl->end(); ++t)
+ {
+ Track* tr = *t;
+ if (tr->selected())
+ {
+ song->removeTrack1(tr);
+ msgRemoveTrack(tr, false);
+ song->removeTrack3(tr);
+ loop = true;
+ break;
+ }
+ }
+ }
+ while (loop);
+
+ /*
+ // TESTED: DIDN'T WORK: It still skipped some selected tracks !
+ // Quote from SGI STL: "Erasing an element from a map also does not invalidate any iterators,
+ // except, of course, for iterators that actually point to the element
+ // that is being erased."
+ // Well that doesn't seem true here...
+
+ TrackList* tl = song->tracks();
+ for(ciTrack t = tl->begin(); t != tl->end() ; )
+ {
+ if((*t)->selected())
+ {
+ // Changed 20070102: - Iterator t becomes invalid after msgRemoveTrack.
+ ciTrack tt = t;
+ ++t;
+ Track* tr = *tt;
+
+ song->removeTrack1(tr);
+ msgRemoveTrack(tr, false);
+ song->removeTrack3(tr);
+
+ }
+ else
+ ++t;
+
+ }
+ */
+
+}
+
+//---------------------------------------------------------
+// msgChangeTrack
+// oldTrack - copy of the original track befor modification
+// newTrack - modified original track
+//---------------------------------------------------------
+
+void Audio::msgChangeTrack(Track* oldTrack, Track* newTrack, bool doUndoFlag)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_CHANGE_TRACK;
+ msg.p1 = oldTrack;
+ msg.p2 = newTrack;
+ sendMessage(&msg, doUndoFlag);
+ }
+
+//---------------------------------------------------------
+// msgMoveTrack
+// move track idx1 to slot idx2
+//---------------------------------------------------------
+
+void Audio::msgMoveTrack(int idx1, int idx2, bool doUndoFlag)
+ {
+ if (idx1 < 0 || idx2 < 0) // sanity check
+ return;
+ int n = song->tracks()->size();
+ if (idx1 >= n || idx2 >= n) // sanity check
+ return;
+ AudioMsg msg;
+ msg.id = SEQM_MOVE_TRACK;
+ msg.a = idx1;
+ msg.b = idx2;
+ sendMessage(&msg, doUndoFlag);
+ }
+
+//---------------------------------------------------------
+// msgAddPart
+//---------------------------------------------------------
+
+void Audio::msgAddPart(Part* part, bool doUndoFlag)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_ADD_PART;
+ msg.p1 = part;
+ sendMessage(&msg, doUndoFlag);
+ }
+
+//---------------------------------------------------------
+// msgRemovePart
+//---------------------------------------------------------
+
+void Audio::msgRemovePart(Part* part, bool doUndoFlag)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_REMOVE_PART;
+ msg.p1 = part;
+ sendMessage(&msg, doUndoFlag);
+ }
+
+//---------------------------------------------------------
+// msgRemoveParts
+// remove selected parts; return true if any part was
+// removed
+//---------------------------------------------------------
+
+bool Song::msgRemoveParts()
+ {
+ bool loop;
+ bool partSelected = false;
+ do {
+ loop = false;
+ TrackList* tl = song->tracks();
+
+ for (iTrack it = tl->begin(); it != tl->end(); ++it) {
+ PartList* pl = (*it)->parts();
+ for (iPart ip = pl->begin(); ip != pl->end(); ++ip) {
+ if (ip->second->selected()) {
+ if ((*it)->type() == Track::WAVE) {
+ audio->msgRemovePart((WavePart*)(ip->second));
+ }
+ else {
+ audio->msgRemovePart(ip->second, false);
+ }
+ loop = true;
+ partSelected = true;
+ break;
+ }
+ }
+ if (loop)
+ break;
+ }
+ } while (loop);
+ return partSelected;
+ }
+
+//---------------------------------------------------------
+// msgChangePart
+//---------------------------------------------------------
+
+//void Audio::msgChangePart(Part* oldPart, Part* newPart, bool doUndoFlag)
+void Audio::msgChangePart(Part* oldPart, Part* newPart, bool doUndoFlag, bool doCtrls, bool doClones)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_CHANGE_PART;
+ msg.p1 = oldPart;
+ msg.p2 = newPart;
+ msg.a = doCtrls;
+ msg.b = doClones;
+ sendMessage(&msg, doUndoFlag);
+ }
+
+//---------------------------------------------------------
+// msgAddEvent
+//---------------------------------------------------------
+
+//void Audio::msgAddEvent(Event& event, Part* part, bool doUndoFlag)
+void Audio::msgAddEvent(Event& event, Part* part, bool doUndoFlag, bool doCtrls, bool doClones)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_ADD_EVENT;
+ msg.ev1 = event;
+ msg.p2 = part;
+ msg.a = doCtrls;
+ msg.b = doClones;
+ sendMessage(&msg, doUndoFlag);
+ }
+
+//---------------------------------------------------------
+// msgDeleteEvent
+//---------------------------------------------------------
+
+//void Audio::msgDeleteEvent(Event& event, Part* part, bool doUndoFlag)
+void Audio::msgDeleteEvent(Event& event, Part* part, bool doUndoFlag, bool doCtrls, bool doClones)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_REMOVE_EVENT;
+ msg.ev1 = event;
+ msg.p2 = part;
+ msg.a = doCtrls;
+ msg.b = doClones;
+ sendMessage(&msg, doUndoFlag);
+ }
+
+//---------------------------------------------------------
+// msgChangeEvent
+//---------------------------------------------------------
+
+//void Audio::msgChangeEvent(Event& oe, Event& ne, Part* part, bool doUndoFlag)
+void Audio::msgChangeEvent(Event& oe, Event& ne, Part* part, bool doUndoFlag, bool doCtrls, bool doClones)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_CHANGE_EVENT;
+ msg.ev1 = oe;
+ msg.ev2 = ne;
+ msg.p3 = part;
+ msg.a = doCtrls;
+ msg.b = doClones;
+ sendMessage(&msg, doUndoFlag);
+ }
+
+//---------------------------------------------------------
+// msgAddTempo
+//---------------------------------------------------------
+
+void Audio::msgAddTempo(int tick, int tempo, bool doUndoFlag)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_ADD_TEMPO;
+ msg.a = tick;
+ msg.b = tempo;
+ sendMessage(&msg, doUndoFlag);
+ }
+
+//---------------------------------------------------------
+// msgSetTempo
+//---------------------------------------------------------
+
+void Audio::msgSetTempo(int tick, int tempo, bool doUndoFlag)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_SET_TEMPO;
+ msg.a = tick;
+ msg.b = tempo;
+ sendMessage(&msg, doUndoFlag);
+ }
+
+//---------------------------------------------------------
+// msgSetGlobalTempo
+//---------------------------------------------------------
+
+void Audio::msgSetGlobalTempo(int val)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_SET_GLOBAL_TEMPO;
+ msg.a = val;
+ sendMessage(&msg, false);
+ }
+
+//---------------------------------------------------------
+// msgDeleteTempo
+//---------------------------------------------------------
+
+void Audio::msgDeleteTempo(int tick, int tempo, bool doUndoFlag)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_REMOVE_TEMPO;
+ msg.a = tick;
+ msg.b = tempo;
+ sendMessage(&msg, doUndoFlag);
+ }
+
+//---------------------------------------------------------
+// msgAddSig
+//---------------------------------------------------------
+
+void Audio::msgAddSig(int tick, int z, int n, bool doUndoFlag)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_ADD_SIG;
+ msg.a = tick;
+ msg.b = z;
+ msg.c = n;
+ sendMessage(&msg, doUndoFlag);
+ }
+
+//---------------------------------------------------------
+// msgRemoveSig
+//! sends remove tempo signature message
+//---------------------------------------------------------
+
+void Audio::msgRemoveSig(int tick, int z, int n, bool doUndoFlag)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_REMOVE_SIG;
+ msg.a = tick;
+ msg.b = z;
+ msg.c = n;
+ sendMessage(&msg, doUndoFlag);
+ }
+
+//---------------------------------------------------------
+// msgScanAlsaMidiPorts
+//---------------------------------------------------------
+
+void Audio::msgScanAlsaMidiPorts()
+ {
+ AudioMsg msg;
+ msg.id = SEQM_SCAN_ALSA_MIDI_PORTS;
+ sendMessage(&msg, false);
+ }
+
+//---------------------------------------------------------
+// msgResetMidiDevices
+//---------------------------------------------------------
+
+void Audio::msgResetMidiDevices()
+ {
+ AudioMsg msg;
+ msg.id = SEQM_RESET_DEVICES;
+ sendMessage(&msg, false);
+ }
+
+//---------------------------------------------------------
+// msgInitMidiDevices
+//---------------------------------------------------------
+
+void Audio::msgInitMidiDevices()
+ {
+ AudioMsg msg;
+ msg.id = SEQM_INIT_DEVICES;
+ sendMessage(&msg, false);
+ }
+
+//---------------------------------------------------------
+// panic
+//---------------------------------------------------------
+
+void Audio::msgPanic()
+ {
+ AudioMsg msg;
+ msg.id = SEQM_PANIC;
+ sendMessage(&msg, false);
+ }
+
+//---------------------------------------------------------
+// localOff
+//---------------------------------------------------------
+
+void Audio::msgLocalOff()
+ {
+ AudioMsg msg;
+ msg.id = SEQM_MIDI_LOCAL_OFF;
+ sendMessage(&msg, false);
+ }
+
+//---------------------------------------------------------
+// msgUpdateSoloStates
+//---------------------------------------------------------
+
+void Audio::msgUpdateSoloStates()
+ {
+ AudioMsg msg;
+ msg.id = SEQM_UPDATE_SOLO_STATES;
+ sendMsg(&msg);
+ }
+
+//---------------------------------------------------------
+// msgSetAux
+//---------------------------------------------------------
+
+void Audio::msgSetAux(AudioTrack* track, int idx, double val)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_SET_AUX;
+ msg.snode = track;
+ msg.ival = idx;
+ msg.dval = val;
+ sendMessage(&msg, false);
+ }
+
+//---------------------------------------------------------
+// msgPlayMidiEvent
+//---------------------------------------------------------
+
+void Audio::msgPlayMidiEvent(const MidiPlayEvent* event)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_PLAY_MIDI_EVENT;
+ msg.p1 = event;
+ sendMessage(&msg, false);
+ }
+
+//---------------------------------------------------------
+// msgSetHwCtrlState
+//---------------------------------------------------------
+
+void Audio::msgSetHwCtrlState(MidiPort* port, int ch, int ctrl, int val)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_SET_HW_CTRL_STATE;
+ msg.p1 = port;
+ msg.a = ch;
+ msg.b = ctrl;
+ msg.c = val;
+ sendMessage(&msg, false);
+ }
+
+//---------------------------------------------------------
+// msgSetHwCtrlState
+//---------------------------------------------------------
+
+void Audio::msgSetHwCtrlStates(MidiPort* port, int ch, int ctrl, int val, int lastval)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_SET_HW_CTRL_STATE;
+ msg.p1 = port;
+ msg.a = ch;
+ msg.b = ctrl;
+ msg.c = val;
+ msg.ival = lastval;
+ sendMessage(&msg, false);
+ }
+
+//---------------------------------------------------------
+// msgSetTrackOutChannel
+//---------------------------------------------------------
+
+void Audio::msgSetTrackOutChannel(MidiTrack* track, int ch)
+{
+ AudioMsg msg;
+ msg.id = SEQM_SET_TRACK_OUT_CHAN;
+ msg.p1 = track;
+ msg.a = ch;
+ sendMessage(&msg, false);
+}
+
+//---------------------------------------------------------
+// msgSetTrackOutPort
+//---------------------------------------------------------
+
+void Audio::msgSetTrackOutPort(MidiTrack* track, int port)
+{
+ AudioMsg msg;
+ msg.id = SEQM_SET_TRACK_OUT_PORT;
+ msg.p1 = track;
+ msg.a = port;
+ sendMessage(&msg, false);
+}
+
+//---------------------------------------------------------
+// msgRemapPortDrumCtlEvents
+//---------------------------------------------------------
+
+void Audio::msgRemapPortDrumCtlEvents(int mapidx, int newnote, int newchan, int newport)
+{
+ AudioMsg msg;
+ msg.id = SEQM_REMAP_PORT_DRUM_CTL_EVS;
+ msg.ival = mapidx;
+ msg.a = newnote;
+ msg.b = newchan;
+ msg.c = newport;
+ sendMessage(&msg, false);
+}
+
+//---------------------------------------------------------
+// msgChangeAllPortDrumCtlEvents
+//---------------------------------------------------------
+
+void Audio::msgChangeAllPortDrumCtrlEvents(bool add, bool drumonly)
+{
+ AudioMsg msg;
+ msg.id = SEQM_CHANGE_ALL_PORT_DRUM_CTL_EVS;
+ msg.a = (int)add;
+ msg.b = (int)drumonly;
+ sendMessage(&msg, false);
+}
+
+//---------------------------------------------------------
+// msgSetSendMetronome
+//---------------------------------------------------------
+
+void Audio::msgSetSendMetronome(AudioTrack* track, bool b)
+{
+ AudioMsg msg;
+ msg.id = AUDIO_SET_SEND_METRONOME;
+ msg.snode = track;
+ msg.ival = (int)b;
+ sendMessage(&msg, false);
+}
+
+//---------------------------------------------------------
+// msgBounce
+// start bounce operation
+//---------------------------------------------------------
+
+void Audio::msgBounce()
+ {
+ _bounce = true;
+ if (!checkAudioDevice()) return;
+ //audioDevice->seekTransport(song->lPos().frame());
+ audioDevice->seekTransport(song->lPos());
+ }
+
+//---------------------------------------------------------
+// msgIdle
+//---------------------------------------------------------
+
+void Audio::msgIdle(bool on)
+ {
+ AudioMsg msg;
+ msg.id = SEQM_IDLE;
+ msg.a = on;
+ sendMessage(&msg, false);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/shortcuts.cpp b/attic/muse2-oom/muse2/muse/shortcuts.cpp
new file mode 100644
index 00000000..c02aee22
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/shortcuts.cpp
@@ -0,0 +1,359 @@
+//
+// C++ Implementation: shortcuts
+//
+// Description:
+// Definition of shortcuts used in the application
+//
+// Author: Mathias Lundgren <lunar_shuttle@users.sourceforge.net>, (C) 2003
+//
+// Copyright: Mathias Lundgren (lunar_shuttle@users.sourceforge.net) (C) 2003
+//
+//
+#include "shortcuts.h"
+#include <QTranslator>
+#include <QKeySequence>
+
+
+ShortCut shortcuts[SHRT_NUM_OF_ELEMENTS];
+void defShrt(int shrt, int key, const char* descr, int type, const char* xml)
+{
+ shortcuts[shrt].key = key;
+ shortcuts[shrt].descr = QT_TRANSLATE_NOOP("@default", descr);
+ shortcuts[shrt].type = type;
+ shortcuts[shrt].xml = xml;
+}
+
+
+void initShortCuts()
+ {
+ //Global:
+ defShrt(SHRT_PLAY_SONG, Qt::Key_Enter, "Transport: Start playback from current location", GLOBAL_SHRT, "play");
+ defShrt(SHRT_TOGGLE_METRO, Qt::Key_C, "Transport: Toggle metronome", GLOBAL_SHRT,"toggle_metro");
+ defShrt(SHRT_STOP, Qt::Key_Insert,"Transport: Stop Playback", GLOBAL_SHRT, "stop");
+ defShrt(SHRT_GOTO_START, Qt::Key_W, "Transport: Goto Start", GLOBAL_SHRT, "goto_start");
+ defShrt(SHRT_PLAY_TOGGLE, Qt::Key_Space, "Transport: Play, Stop, Rewind", GLOBAL_SHRT, "play_toggle");
+ defShrt(SHRT_GOTO_LEFT, Qt::Key_End, "Transport: Goto left marker" , GLOBAL_SHRT, "goto_left");
+ defShrt(SHRT_GOTO_RIGHT, Qt::Key_PageDown, "Transport: Goto right marker" , GLOBAL_SHRT, "goto_right");
+ defShrt(SHRT_TOGGLE_LOOP, Qt::Key_Slash, "Transport: Toggle Loop section", GLOBAL_SHRT, "toggle_loop");
+ defShrt(SHRT_START_REC, Qt::Key_Asterisk, "Transport: Toggle Record", GLOBAL_SHRT, "toggle_rec");
+ defShrt(SHRT_REC_CLEAR, Qt::Key_Backspace, "Transport: Clear all rec enabled tracks", GLOBAL_SHRT, "rec_clear");
+
+ defShrt(SHRT_COPY, Qt::CTRL + Qt::Key_C, "Edit: Copy", INVIS_SHRT, "copy");
+ defShrt(SHRT_UNDO, Qt::CTRL + Qt::Key_Z, "Edit: Undo", INVIS_SHRT, "undo");
+ defShrt(SHRT_REDO, Qt::CTRL + Qt::Key_Y, "Edit: Redo", INVIS_SHRT, "redo");
+ defShrt(SHRT_CUT, Qt::CTRL + Qt::Key_X, "Edit: Cut", INVIS_SHRT, "cut");
+ defShrt(SHRT_PASTE, Qt::CTRL + Qt::Key_V, "Edit: Paste", INVIS_SHRT, "paste");
+ defShrt(SHRT_DELETE, Qt::Key_Delete, "Edit: Delete", INVIS_SHRT, "delete");
+
+ //-----------------------------------------------------------
+ // Arranger:
+ defShrt(SHRT_NEW, Qt::CTRL + Qt::Key_N, "File: New project", ARRANG_SHRT + DEDIT_SHRT, "new_project");
+ defShrt(SHRT_OPEN, Qt::CTRL + Qt::Key_O, "File: Open from disk", ARRANG_SHRT + DEDIT_SHRT, "open_project");
+ defShrt(SHRT_SAVE, Qt::CTRL + Qt::Key_S, "File: Save project", ARRANG_SHRT + DEDIT_SHRT, "save_project");
+ //-----------------------------------------------------------
+
+ defShrt(SHRT_OPEN_RECENT, Qt::CTRL + Qt::Key_1, "File: Open recent file", ARRANG_SHRT, "open_recent");
+ defShrt(SHRT_SAVE_AS, 0 , "File: Save as", ARRANG_SHRT, "save_project_as");
+ defShrt(SHRT_LOAD_TEMPLATE, 0 , "File: Load template", ARRANG_SHRT, "load_template");
+// defShrt(SHRT_CONFIG_PRINTER, Qt::CTRL + Qt::Key_P, "Configure printer", ARRANG_SHRT, "config_printer");
+ defShrt(SHRT_IMPORT_MIDI, 0 , "File: Import midi file", ARRANG_SHRT, "import_midi");
+ defShrt(SHRT_EXPORT_MIDI, 0 , "File: Export midi file", ARRANG_SHRT, "export_midi");
+ defShrt(SHRT_IMPORT_PART, 0 , "File: Import midi part", ARRANG_SHRT, "import_part");
+ defShrt(SHRT_IMPORT_AUDIO, 0 , "File: Import audio file", ARRANG_SHRT, "import_audio");
+ defShrt(SHRT_QUIT, Qt::CTRL + Qt::Key_Q, "File: Quit MusE", ARRANG_SHRT, "quit");
+// defShrt(SHRT_DESEL_PARTS, Qt::CTRL + Qt::Key_B, "Deselect all parts", ARRANG_SHRT, "deselect_parts");
+ defShrt(SHRT_SELECT_PRTSTRACK, Qt::CTRL+ Qt::ALT + Qt::Key_P, "Edit: Select parts on track", ARRANG_SHRT, "select_parts_on_track");
+ defShrt(SHRT_OPEN_PIANO, Qt::CTRL + Qt::Key_E, "Open pianoroll", ARRANG_SHRT, "open_pianoroll");
+ defShrt(SHRT_OPEN_DRUMS, Qt::CTRL + Qt::Key_D, "Open drumeditor", ARRANG_SHRT, "open_drumedit");
+ defShrt(SHRT_OPEN_LIST, Qt::CTRL + Qt::Key_L, "Open listeditor", ARRANG_SHRT, "open_listedit");
+ defShrt(SHRT_OPEN_WAVE, Qt::CTRL + Qt::Key_W, "Open waveeditor", ARRANG_SHRT, "open_waveedit");
+ defShrt(SHRT_OPEN_GRAPHIC_MASTER, Qt::CTRL + Qt::Key_M, "Open graphical mastertrack editor", ARRANG_SHRT, "open_graph_master");
+ defShrt(SHRT_OPEN_LIST_MASTER, Qt::CTRL + Qt::SHIFT + Qt::Key_M, "Open list mastertrack editor", ARRANG_SHRT, "open_list_master");
+ defShrt(SHRT_OPEN_MIDI_TRANSFORM, Qt::CTRL + Qt::Key_T, "Open midi transformer", ARRANG_SHRT, "open_midi_transform");
+ defShrt(SHRT_ADD_MIDI_TRACK, Qt::CTRL + Qt::Key_J, "Add midi track", ARRANG_SHRT, "add_midi_track");
+ defShrt(SHRT_ADD_DRUM_TRACK, 0, "Add drum track", ARRANG_SHRT, "add_drum_track");
+ defShrt(SHRT_ADD_WAVE_TRACK, 0, "Add wave track", ARRANG_SHRT, "add_wave_track");
+ defShrt(SHRT_ADD_AUDIO_OUTPUT, 0, "Add audio output", ARRANG_SHRT, "add_audio_output");
+ defShrt(SHRT_ADD_AUDIO_GROUP, 0, "Add audio group", ARRANG_SHRT, "add_audio_group");
+ defShrt(SHRT_ADD_AUDIO_INPUT, 0, "Add audio input", ARRANG_SHRT, "add_audio_input");
+ defShrt(SHRT_ADD_AUDIO_AUX , 0, "Add audio aux", ARRANG_SHRT, "add_audio_aux");
+ defShrt(SHRT_GLOBAL_CUT, 0, "Structure: Global cut", ARRANG_SHRT, "global_cut");
+ defShrt(SHRT_GLOBAL_INSERT, 0, "Structure: Global insert", ARRANG_SHRT, "global_insert");
+ defShrt(SHRT_GLOBAL_SPLIT, 0, "Structure: Global split", ARRANG_SHRT, "global_split");
+ defShrt(SHRT_COPY_RANGE, 0, "Structure: Copy range", ARRANG_SHRT, "copy_range");
+ defShrt(SHRT_CUT_EVENTS, 0, "Structure: Cut events", ARRANG_SHRT, "cut_events");
+ //defShrt(SHRT_OPEN_MIXER, Qt::Key_F10, "View: Open mixer window", ARRANG_SHRT, "toggle_mixer");
+ defShrt(SHRT_OPEN_MIXER, Qt::Key_F10, "View: Open mixer #1 window", ARRANG_SHRT, "toggle_mixer");
+ defShrt(SHRT_OPEN_MIXER2, Qt::CTRL + Qt::Key_F10, "View: Open mixer #2 window", ARRANG_SHRT, "toggle_mixer2");
+ defShrt(SHRT_OPEN_TRANSPORT, Qt::Key_F11, "View: Toggle transport window", ARRANG_SHRT, "toggle_transport");
+ defShrt(SHRT_OPEN_BIGTIME, Qt::Key_F12, "View: Toggle bigtime window", ARRANG_SHRT, "toggle_bigtime");
+ defShrt(SHRT_OPEN_MARKER, Qt::Key_F9, "View: Open marker window", ARRANG_SHRT, "marker_window");
+
+ defShrt(SHRT_FOLLOW_JUMP, 0, "Settings: Follow song by page", ARRANG_SHRT, "follow_jump");
+ defShrt(SHRT_FOLLOW_NO, 0, "Settings: Follow song off", ARRANG_SHRT, "follow_no");
+ defShrt(SHRT_FOLLOW_CONTINUOUS, 0, "Settings: Follow song continuous", ARRANG_SHRT, "follow_continuous");
+
+ defShrt(SHRT_GLOBAL_CONFIG, 0, "Settings: Global configuration", ARRANG_SHRT, "configure_global");
+ defShrt(SHRT_CONFIG_SHORTCUTS, 0, "Settings: Configure shortcuts", ARRANG_SHRT, "configure_shortcuts");
+ defShrt(SHRT_CONFIG_METRONOME, 0, "Settings: Configure metronome", ARRANG_SHRT, "configure_metronome");
+ defShrt(SHRT_CONFIG_MIDISYNC, 0, "Settings: Midi sync configuration", ARRANG_SHRT, "configure_midi_sync");
+ defShrt(SHRT_MIDI_FILE_CONFIG, 0, "Settings: Midi file import/export configuration", ARRANG_SHRT, "configure_midi_file");
+ defShrt(SHRT_APPEARANCE_SETTINGS, 0, "Settings: Appearance settings", ARRANG_SHRT, "configure_appearance_settings");
+ defShrt(SHRT_CONFIG_MIDI_PORTS, 0, "Settings: Midi ports / Soft Synth", ARRANG_SHRT, "configure_midi_ports");
+ defShrt(SHRT_CONFIG_AUDIO_PORTS, 0, "Settings: Audio subsystem configuration", ARRANG_SHRT, "configure_audio_ports");
+ //defShrt(SHRT_SAVE_GLOBAL_CONFIG, 0, "Save global configuration", ARRANG_SHRT, "configure_save_global");
+
+ defShrt(SHRT_MIDI_EDIT_INSTRUMENTS, 0, "Midi: Edit midi instruments", ARRANG_SHRT, "midi_edit_instruments");
+ defShrt(SHRT_MIDI_INPUT_TRANSFORM, 0, "Midi: Open midi input transform", ARRANG_SHRT, "midi_open_input_transform");
+ defShrt(SHRT_MIDI_INPUT_FILTER, 0, "Midi: Open midi input filter", ARRANG_SHRT, "midi_open_input_filter");
+ defShrt(SHRT_MIDI_INPUT_TRANSPOSE, 0, "Midi: Midi input transpose", ARRANG_SHRT, "midi_open_input_transpose");
+ defShrt(SHRT_MIDI_REMOTE_CONTROL, 0, "Midi: Midi remote control", ARRANG_SHRT, "midi_remote_control");
+#ifdef BUILD_EXPERIMENTAL
+ defShrt(SHRT_RANDOM_RHYTHM_GENERATOR,0,"Midi: Random rhythm generator", ARRANG_SHRT, "midi_random_rhythm_generator");
+#endif
+ defShrt(SHRT_MIDI_RESET, 0, "Midi: Reset midi", ARRANG_SHRT, "midi_reset");
+ defShrt(SHRT_MIDI_INIT, 0, "Midi: Init midi", ARRANG_SHRT, "midi_init");
+ defShrt(SHRT_MIDI_LOCAL_OFF, 0, "Midi: Midi local off", ARRANG_SHRT, "midi_local_off");
+
+ defShrt(SHRT_AUDIO_BOUNCE_TO_TRACK, 0, "Audio: Bounce audio to track", ARRANG_SHRT, "audio_bounce_to_track");
+ defShrt(SHRT_AUDIO_BOUNCE_TO_FILE, 0, "Audio: Bounce audio to file", ARRANG_SHRT, "audio_bounce_to_file");
+ defShrt(SHRT_AUDIO_RESTART, 0, "Audio: Restart audio", ARRANG_SHRT, "audio_restart");
+
+ defShrt(SHRT_MIXER_AUTOMATION, 0, "Automation: Mixer automation", ARRANG_SHRT, "mixer_automation");
+ defShrt(SHRT_MIXER_SNAPSHOT, 0, "Automation: Take mixer snapshot", ARRANG_SHRT, "mixer_snapshot");
+ defShrt(SHRT_MIXER_AUTOMATION_CLEAR,0, "Automation: Clear mixer automation", ARRANG_SHRT, "mixer_automation_clear");
+
+// defShrt(SHRT_OPEN_CLIPS, 0, "View audio clips", ARRANG_SHRT, "view_audio_clips");
+ defShrt(SHRT_OPEN_HELP, Qt::Key_F1, "Help: Open Manual", ARRANG_SHRT, "open_help");
+ defShrt(SHRT_START_WHATSTHIS, Qt::SHIFT + Qt::Key_F1, "Help: Toggle whatsthis mode", ARRANG_SHRT, "toggle_whatsthis");
+
+ defShrt(SHRT_EDIT_PART, Qt::Key_Return, "Edit: Edit selected part", ARRANG_SHRT, "edit_selected_part");
+ defShrt(SHRT_SEL_ABOVE, Qt::Key_Up, "Edit: Select nearest part on track above", ARRANG_SHRT, "sel_part_above");
+ defShrt(SHRT_SEL_ABOVE_ADD, Qt::SHIFT + Qt::Key_Up, "Edit: Add nearest part on track above", ARRANG_SHRT, "sel_part_above_add");
+ defShrt(SHRT_SEL_BELOW, Qt::Key_Down, "Edit: Select nearest part on track below", ARRANG_SHRT, "sel_part_below");
+ defShrt(SHRT_SEL_BELOW_ADD, Qt::SHIFT + Qt::Key_Down, "Edit: Add nearest part on track below", ARRANG_SHRT, "sel_part_below_add");
+
+ defShrt(SHRT_INSERT, Qt::CTRL+Qt::SHIFT+ Qt::Key_I, "Edit: Insert parts, moving time", ARRANG_SHRT, "insert_parts");
+ defShrt(SHRT_INSERTMEAS, Qt::CTRL+Qt::SHIFT+ Qt::Key_M, "Edit: Insert empty measure", ARRANG_SHRT, "insert_measure");
+
+ defShrt(SHRT_PASTE_CLONE, Qt::CTRL+Qt::SHIFT+Qt::Key_V, "Edit: Paste clone", ARRANG_SHRT, "paste_clone");
+ defShrt(SHRT_PASTE_TO_TRACK, Qt::CTRL+Qt::Key_B, "Edit: Paste to track", ARRANG_SHRT, "paste_to_track");
+ defShrt(SHRT_PASTE_CLONE_TO_TRACK, Qt::CTRL+Qt::SHIFT+Qt::Key_B, "Edit: Paste clone to track", ARRANG_SHRT, "paste_clone_to_track");
+
+ defShrt(SHRT_SEL_TRACK_ABOVE, Qt::CTRL + Qt::Key_Up, "Select track above", ARRANG_SHRT, "sel_track_above");
+ defShrt(SHRT_SEL_TRACK_BELOW, Qt::CTRL + Qt::Key_Down, "Select track below", ARRANG_SHRT, "sel_track_below");
+
+ //-----------------------------------------------------------
+
+ defShrt(SHRT_TRANSPOSE, 0, "Midi: Transpose", ARRANG_SHRT + PROLL_SHRT, "midi_transpose");
+
+ //-----------------------------------------------------------
+
+ defShrt(SHRT_SELECT_ALL, Qt::CTRL + Qt::Key_A, "Edit: Select all", ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, "sel_all");
+ defShrt(SHRT_SELECT_NONE, Qt::CTRL + Qt::SHIFT + Qt::Key_A, "Edit: Select none", ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, "sel_none");
+ defShrt(SHRT_SELECT_INVERT, Qt::CTRL + Qt::Key_I, "Edit: Invert Selection", ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, "sel_inv");
+ defShrt(SHRT_SELECT_ILOOP, 0, "Edit: Select events/parts inside locators", ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, "sel_ins_loc");
+ defShrt(SHRT_SELECT_OLOOP, 0, "Edit: Select events/parts outside locators", ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, "sel_out_loc");
+ defShrt(SHRT_SELECT_PREV_PART, Qt::ALT + Qt::Key_Left, "Edit: Select previous part", ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, "sel_prv_prt");
+ defShrt(SHRT_SELECT_NEXT_PART, Qt::ALT + Qt::Key_Right, "Edit: Select next part", ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, "sel_nxt_prt");
+ defShrt(SHRT_SEL_LEFT, Qt::Key_Left, "Edit: Select nearest part/event to the left", ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, "sel_left");
+ defShrt(SHRT_SEL_LEFT_ADD, Qt::Key_Left + Qt::SHIFT, "Edit: Add nearest part/event to the left to selection", PROLL_SHRT + DEDIT_SHRT, "sel_left_add");
+ defShrt(SHRT_SEL_RIGHT, Qt::Key_Right, "Edit: Select nearest part/event to the left", ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT,"sel_right");
+ defShrt(SHRT_SEL_RIGHT_ADD, Qt::Key_Right + Qt::SHIFT, "Edit: Add nearest part/event to the right to selection", PROLL_SHRT + DEDIT_SHRT,"sel_right_add");
+ defShrt(SHRT_LOCATORS_TO_SELECTION, Qt::ALT + Qt::Key_P, "Edit: Set locators to selection", ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, "loc_to_sel");
+ defShrt(SHRT_INC_PITCH, Qt::CTRL + Qt::Key_Up, "Edit: Increase pitch", PROLL_SHRT + DEDIT_SHRT, "sel_inc_pitch");
+ defShrt(SHRT_DEC_PITCH, Qt::CTRL + Qt::Key_Down, "Edit: Decrease pitch", PROLL_SHRT + DEDIT_SHRT, "sel_dec_pitch");
+ defShrt(SHRT_INC_POS, Qt::CTRL + Qt::Key_Right, "Edit: Increase event position", PROLL_SHRT + DEDIT_SHRT, "sel_inc_pos");
+ defShrt(SHRT_DEC_POS, Qt::CTRL + Qt::Key_Left, "Edit: Decrease event position", PROLL_SHRT + DEDIT_SHRT, "sel_dec_pos");
+ defShrt(SHRT_ZOOM_IN, Qt::CTRL + Qt::Key_PageUp, "View: Zoom in", PROLL_SHRT + DEDIT_SHRT, "zoom_in");
+ defShrt(SHRT_ZOOM_OUT, Qt::CTRL + Qt::Key_PageDown, "View: Zoom out", PROLL_SHRT + DEDIT_SHRT, "zoom_out");
+ defShrt(SHRT_GOTO_CPOS, Qt::Key_C, "View: Goto Current Position", PROLL_SHRT + DEDIT_SHRT, "goto_cpos");
+ defShrt(SHRT_SCROLL_LEFT, Qt::Key_H, "View: Scroll left", PROLL_SHRT + DEDIT_SHRT, "scroll_left");
+ defShrt(SHRT_SCROLL_RIGHT, Qt::Key_L, "View: Scroll left", PROLL_SHRT + DEDIT_SHRT, "scroll_right");
+
+ //-----------------------------------------------------------
+ //Drum:
+ //-----------------------------------------------------------
+
+ defShrt(SHRT_FIXED_LEN, Qt::ALT + Qt::Key_L, "Edit: Set Fixed Length on Midi Events", PROLL_SHRT + DEDIT_SHRT, "midi_fixed_len");
+
+ //-----------------------------------------------------------
+ //Pianoroll:
+ //-----------------------------------------------------------
+
+ defShrt(SHRT_OVER_QUANTIZE, 0, "Quantize: Over Quantize", PROLL_SHRT, "midi_over_quant");
+ defShrt(SHRT_ON_QUANTIZE, 0, "Quantize: Note On Quantize", PROLL_SHRT, "midi_quant_noteon");
+ defShrt(SHRT_ONOFF_QUANTIZE, 0, "Quantize: Note On/Off Quantize", PROLL_SHRT,"midi_quant_noteoff");
+ defShrt(SHRT_ITERATIVE_QUANTIZE,0,"Quantize: Iterative Quantize", PROLL_SHRT,"midi_quant_iterative");
+ defShrt(SHRT_CONFIG_QUANT, Qt::CTRL + Qt::ALT + Qt::Key_Q, "Quantize: Configure quant", PROLL_SHRT, "config_quant");
+ defShrt(SHRT_MODIFY_GATE_TIME, 0, "Quantize: Modify Gate Time", PROLL_SHRT, "midi_mod_gate_time");
+ defShrt(SHRT_MODIFY_VELOCITY, 0, "Quantize: Modify Velocity", PROLL_SHRT, "midi_mod_velo");
+ defShrt(SHRT_CRESCENDO, 0, "Edit: Crescendo", PROLL_SHRT, "midi_crescendo");
+ defShrt(SHRT_THIN_OUT, 0, "Edit: Thin Out", PROLL_SHRT, "midi_thin_out");
+ defShrt(SHRT_ERASE_EVENT, 0, "Edit: Erase Event", PROLL_SHRT, "midi_erase_event");
+ defShrt(SHRT_DELETE_OVERLAPS, 0, "Edit: Delete Overlaps", PROLL_SHRT, "midi_delete_overlaps");
+ defShrt(SHRT_NOTE_SHIFT, 0, "Edit: Note Shift", PROLL_SHRT, "midi_note_shift");
+ defShrt(SHRT_MOVE_CLOCK, 0, "Edit: Move Clock", PROLL_SHRT, "midi_move_clock");
+ defShrt(SHRT_COPY_MEASURE, 0, "Edit: Copy Measure", PROLL_SHRT, "midi_copy_measure");
+ defShrt(SHRT_ERASE_MEASURE, 0, "Edit: Erase Measure", PROLL_SHRT,"midi_erase_measure");
+ defShrt(SHRT_DELETE_MEASURE, 0, "Edit: Delete Measure", PROLL_SHRT, "midi_delete_measure");
+ defShrt(SHRT_CREATE_MEASURE, 0, "Edit: Create Measure", PROLL_SHRT, "midi_create_measure");
+ defShrt(SHRT_EVENT_COLOR, Qt::Key_E, "Edit: Change Event Color", PROLL_SHRT, "change_event_color");
+ defShrt(SHRT_ADD_PROGRAM, Qt::Key_Backslash, "Edit: Insert Program Change", PROLL_SHRT, "add_program_change");
+ defShrt(SHRT_DEL_PROGRAM, Qt::CTRL + Qt::Key_Backslash, "Edit: Delete Program Change", PROLL_SHRT, "delete_program_change");
+ defShrt(SHRT_SEL_INSTRUMENT, Qt::Key_I, "Edit: Select Instrument", PROLL_SHRT, "midi_instrument");
+
+
+ // Shortcuts for tools
+ // global
+ defShrt(SHRT_TOOL_POINTER, Qt::Key_A, "Tool: Pointer", ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, "pointer_tool");
+ defShrt(SHRT_TOOL_PENCIL, Qt::Key_D, "Tool: Pencil", ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, "pencil_tool");
+ defShrt(SHRT_TOOL_RUBBER, Qt::Key_R, "Tool: Eraser", ARRANG_SHRT + PROLL_SHRT + DEDIT_SHRT, "eraser_tool");
+ // piano roll & drum editor
+ defShrt(SHRT_TOOL_LINEDRAW, 0, "Tool: Line Draw", PROLL_SHRT + DEDIT_SHRT, "line_draw_tool");
+ // arranger
+ defShrt(SHRT_TOOL_SCISSORS, Qt::Key_S, "Tool: Scissor", ARRANG_SHRT, "scissor_tool");
+ defShrt(SHRT_TOOL_GLUE, Qt::Key_G, "Tool: Glue", ARRANG_SHRT, "glue_tool");
+ defShrt(SHRT_TOOL_MUTE, 0, "Tool: Mute", ARRANG_SHRT, "mute_tool");
+
+ //Increase/decrease current position, is going to be in arranger & drumeditor as well
+ // p4.0.10 Editors and arranger handle these by themselves, otherwise global handler will now use them, too.
+ defShrt(SHRT_POS_INC, Qt::Key_Plus, "Transport: Increase current position", GLOBAL_SHRT, "curpos_increase");
+ defShrt(SHRT_POS_DEC, Qt::Key_Minus, "Transport: Decrease current position", GLOBAL_SHRT, "curpos_decrease");
+
+ defShrt(SHRT_POS_INC_NOSNAP, Qt::SHIFT + Qt::Key_Plus, "Transport: Increase current position, no snap", GLOBAL_SHRT, "curpos_increase_nosnap");
+ defShrt(SHRT_POS_DEC_NOSNAP, Qt::SHIFT + Qt::Key_Minus, "Transport: Decrease current position, no snap", GLOBAL_SHRT, "curpos_decrease_nosnap");
+
+ /*
+ defShrt(SHRT_POS_INC_BAR, Qt::CTRL + Qt::ALT + Qt::Key_Plus, "Transport: Increase current position", GLOBAL_SHRT, "curpos_increase_bar");
+ defShrt(SHRT_POS_DEC_BAR, Qt::CTRL + Qt::ALT + Qt::Key_Minus, "Transport: Decrease current position", GLOBAL_SHRT, "curpos_decrease_bar");
+ defShrt(SHRT_POS_INC_BAR_NOSNAP, Qt::SHIFT + Qt::CTRL + Qt::ALT + Qt::Key_Plus, "Transport: Increase current position", GLOBAL_SHRT, "curpos_increase_bar_nosnap");
+ defShrt(SHRT_POS_DEC_BAR_NOSNAP, Qt::SHIFT + Qt::CTRL + Qt::ALT + Qt::Key_Minus, "Transport: Decrease current position", GLOBAL_SHRT, "curpos_decrease_bar_nosnap");
+
+ defShrt(SHRT_POS_INC_BEAT, Qt::ALT + Qt::Key_Plus, "Transport: Increase current position", GLOBAL_SHRT, "curpos_increase_beat");
+ defShrt(SHRT_POS_DEC_BEAT, Qt::ALT + Qt::Key_Minus, "Transport: Decrease current position", GLOBAL_SHRT, "curpos_decrease_beat");
+ defShrt(SHRT_POS_INC_BEAT_NOSNAP, Qt::SHIFT + Qt::ALT + Qt::Key_Plus, "Transport: Increase current position", GLOBAL_SHRT, "curpos_increase_beat_nosnap");
+ defShrt(SHRT_POS_DEC_BEAT_NOSNAP, Qt::SHIFT + Qt::ALT + Qt::Key_Minus, "Transport: Decrease current position", GLOBAL_SHRT, "curpos_decrease_beat_nosnap");
+
+ defShrt(SHRT_POS_INC_TICK, Qt::CTRL + Qt::Key_Plus, "Transport: Increase current position", GLOBAL_SHRT, "curpos_increase_tick");
+ defShrt(SHRT_POS_DEC_TICK, Qt::CTRL + Qt::Key_Minus, "Transport: Decrease current position", GLOBAL_SHRT, "curpos_decrease_tick");
+ defShrt(SHRT_POS_INC_TICK_NOSNAP, Qt::SHIFT + Qt::CTRL + Qt::Key_Plus, "Transport: Increase current position", GLOBAL_SHRT, "curpos_increase_tick");
+ defShrt(SHRT_POS_DEC_TICK_NOSNAP, Qt::SHIFT + Qt::CTRL + Qt::Key_Minus, "Transport: Decrease current position", GLOBAL_SHRT, "curpos_decrease_tick");
+
+ defShrt(SHRT_POS_INC_FRAME, Qt::Key_N, "Transport: Increase current position", GLOBAL_SHRT, "curpos_increase_frame");
+ defShrt(SHRT_POS_DEC_FRAME, Qt::Key_B, "Transport: Decrease current position", GLOBAL_SHRT, "curpos_decrease_frame");
+
+ defShrt(SHRT_POS_INC_SECOND, Qt::CTRL + Qt::Key_N, "Transport: Increase current position", GLOBAL_SHRT, "curpos_increase_second");
+ defShrt(SHRT_POS_DEC_SECOND, Qt::CTRL + Qt::Key_B, "Transport: Decrease current position", GLOBAL_SHRT, "curpos_decrease_second");
+ defShrt(SHRT_POS_INC_SECOND_NOSNAP, Qt::SHIFT + Qt::CTRL + Qt::Key_N, "Transport: Increase current position", GLOBAL_SHRT, "curpos_increase_second_nosnap");
+ defShrt(SHRT_POS_DEC_SECOND_NOSNAP, Qt::SHIFT + Qt::CTRL + Qt::Key_B, "Transport: Decrease current position", GLOBAL_SHRT, "curpos_decrease_second_nosnap");
+
+ defShrt(SHRT_POS_INC_MINUTE, Qt::ALT + Qt::Key_N, "Transport: Increase current position", GLOBAL_SHRT, "curpos_increase_minute");
+ defShrt(SHRT_POS_DEC_MINUTE, Qt::ALT + Qt::Key_B, "Transport: Decrease current position", GLOBAL_SHRT, "curpos_decrease_minute");
+ defShrt(SHRT_POS_INC_MINUTE_NOSNAP, Qt::SHIFT + Qt::ALT + Qt::Key_N, "Transport: Increase current position", GLOBAL_SHRT, "curpos_increase_minute_nosnap");
+ defShrt(SHRT_POS_DEC_MINUTE_NOSNAP, Qt::SHIFT + Qt::ALT + Qt::Key_B, "Transport: Decrease current position", GLOBAL_SHRT, "curpos_decrease_minute_nosnap");
+ */
+
+
+ defShrt(SHRT_SET_QUANT_1, Qt::Key_1, "Quantize: Set quantize to 1/1 note", PROLL_SHRT, "midi_quant_1");
+ defShrt(SHRT_SET_QUANT_2, Qt::Key_2, "Quantize: Set quantize to 1/2 note", PROLL_SHRT, "midi_quant_2");
+ defShrt(SHRT_SET_QUANT_3, Qt::Key_3, "Quantize: Set quantize to 1/4 note", PROLL_SHRT, "midi_quant_3");
+ defShrt(SHRT_SET_QUANT_4, Qt::Key_4, "Quantize: Set quantize to 1/8 note", PROLL_SHRT, "midi_quant_4");
+ defShrt(SHRT_SET_QUANT_5, Qt::Key_5, "Quantize: Set quantize to 1/16 note", PROLL_SHRT, "midi_quant_5");
+ defShrt(SHRT_SET_QUANT_6, Qt::Key_6, "Quantize: Set quantize to 1/32 note", PROLL_SHRT, "midi_quant_6");
+ defShrt(SHRT_SET_QUANT_7, Qt::Key_7, "Quantize: Set quantize to 1/64 note", PROLL_SHRT, "midi_quant_7");
+
+ defShrt(SHRT_TOGGLE_TRIOL, Qt::Key_T, "Quantize: Toggle triol quantization", PROLL_SHRT, "midi_quant_triol");
+ defShrt(SHRT_TOGGLE_PUNCT, Qt::Key_Period, "Quantize: Toggle punctuation quantization", PROLL_SHRT, "midi_quant_punct");
+ defShrt(SHRT_TOGGLE_PUNCT2, Qt::Key_Comma, "Quantize: Toggle punctuation quantization (2)", PROLL_SHRT, "midi_quant_punct2");
+ defShrt(SHRT_INSERT_AT_LOCATION, Qt::SHIFT + Qt::Key_Right, "Edit: Insert at location", PROLL_SHRT, "midi_insert_at_loc");
+
+ defShrt(SHRT_INCREASE_LEN, Qt::CTRL + Qt::SHIFT + Qt::Key_Right, "Edit: Increase length", PROLL_SHRT, "increase_len");
+ defShrt(SHRT_DECREASE_LEN, Qt::CTRL + Qt::SHIFT + Qt::Key_Left, "Edit: Decrease length", PROLL_SHRT, "decrease_len");
+
+ //-----------------------------------------------------------
+ // List edit:
+ //-----------------------------------------------------------
+
+ defShrt(SHRT_LE_INS_NOTES, Qt::CTRL + Qt::Key_N, "Insert Note", LEDIT_SHRT, "le_ins_note");
+ defShrt(SHRT_LE_INS_SYSEX, Qt::CTRL + Qt::Key_S, "Insert SysEx", LEDIT_SHRT, "le_ins_sysex");
+ defShrt(SHRT_LE_INS_CTRL, Qt::CTRL + Qt::Key_T, "Insert Ctrl", LEDIT_SHRT, "le_ins_ctrl");
+ defShrt(SHRT_LE_INS_META, 0, "Insert Meta", LEDIT_SHRT, "le_ins_meta");
+ defShrt(SHRT_LE_INS_CHAN_AFTERTOUCH, Qt::CTRL + Qt::Key_A, "Insert Channel Aftertouch", LEDIT_SHRT, "le_ins_afttouch");
+ defShrt(SHRT_LE_INS_POLY_AFTERTOUCH, Qt::CTRL + Qt::Key_P, "Insert Key Aftertouch", LEDIT_SHRT, "le_ins_poly");
+
+ //-----------------------------------------------------------
+ // List masteredit:
+ //-----------------------------------------------------------
+ defShrt(SHRT_LM_INS_TEMPO, Qt::CTRL + Qt::Key_T, "Insert Tempo", LMEDIT_SHRT, "lm_ins_tempo");
+ defShrt(SHRT_LM_INS_SIG , Qt::CTRL + Qt::Key_R, "Insert Signature", LMEDIT_SHRT, "lm_ins_sig");
+ defShrt(SHRT_LM_EDIT_BEAT, Qt::CTRL + Qt::SHIFT+ Qt::Key_E, "Change Event Position", LMEDIT_SHRT, "lm_edit_beat");
+ defShrt(SHRT_LM_EDIT_VALUE, Qt::CTRL + Qt::Key_E, "Edit Event Value", LMEDIT_SHRT, "lm_edit_val");
+
+ defShrt(SHRT_NEXT_MARKER, Qt::Key_F6, "Goto Next Marker", ARRANG_SHRT, "me_sel_next");
+ defShrt(SHRT_PREV_MARKER, Qt::Key_F5, "Goto Prev Marker", ARRANG_SHRT, "me_sel_prev");
+
+ }
+
+ const shortcut_cg shortcut_category[SHRT_NUM_OF_CATEGORIES] = {
+ { GLOBAL_SHRT, "Global" },
+ { ARRANG_SHRT, "Arranger" },
+ { PROLL_SHRT, "Pianoroll" },
+ { DEDIT_SHRT, "Drumeditor" },
+ { LEDIT_SHRT, "List editor" },
+ { LMEDIT_SHRT, "List Mastertrack" },
+// { SCORE_SHRT, "Score editor" },
+// { WAVE_SHRT, "Wave editor" },
+ { ALL_SHRT , "All categories" }
+ };
+
+int getShrtByTag(const char* xml)
+ {
+ for (int i=0; i<SHRT_NUM_OF_ELEMENTS; i++) {
+ if (shortcuts[i].xml) {
+ if (strcmp(shortcuts[i].xml, xml) == 0)
+ return i;
+ }
+ }
+ return -1;
+ }
+
+void writeShortCuts(int level, Xml& xml)
+ {
+ xml.tag(level++, "shortcuts");
+ for (int i=0; i < SHRT_NUM_OF_ELEMENTS; i++) {
+ if (shortcuts[i].xml != NULL && shortcuts[i].type != INVIS_SHRT) //Avoid nullptr & hardcoded shortcuts
+ xml.intTag(level, shortcuts[i].xml, shortcuts[i].key);
+ }
+ xml.etag(level, "shortcuts");
+ }
+
+void readShortCuts(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ if (token == Xml::Error || token == Xml::End)
+ break;
+
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::TagStart: {
+ if (tag.length()) {
+ int index = getShrtByTag(tag.toAscii().constData());
+ if (index == -1) //No such tag found
+ printf("Config file might be corrupted. Unknown shortcut: %s\n",tag.toLatin1().constData());
+ else {
+ //printf("Index: %d\n",index);
+ shortcuts[index].key = xml.parseInt();
+ //printf("shortcuts[%d].key = %d, %s\n",index, shortcuts[index].key, shortcuts[index].descr);
+ }
+ }
+ }
+ case Xml::TagEnd:
+ if (tag == "shortcuts")
+ return;
+ default:
+ break;
+ }
+ }
+ }
diff --git a/attic/muse2-oom/muse2/muse/shortcuts.h b/attic/muse2-oom/muse2/muse/shortcuts.h
new file mode 100644
index 00000000..2148ddcc
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/shortcuts.h
@@ -0,0 +1,326 @@
+//
+// C++ Interface: shortcuts
+//
+// Description:
+// Datastructures and declaration of shortcuts used in the application
+//
+// Author: Mathias Lundgren <lunar_shuttle@users.sourceforge.net>, (C) 2003
+//
+// Copyright: Mathias Lundgren (lunar_shuttle@users.sourceforge.net) (C) 2003
+//
+//
+#ifndef __SHORTCUTS_H__
+#define __SHORTCUTS_H__
+
+#include <list>
+#include "xml.h"
+
+//
+// Shortcut categories
+//
+#define PROLL_SHRT 1 // Pianoroll shortcut
+#define DEDIT_SHRT 2 // Drumedit shortcut
+#define LEDIT_SHRT 4 // Listedit shortcut
+#define SCORE_SHRT 8 // Score shortcut
+#define ARRANG_SHRT 16 // Arrenger shortcut
+#define TRANSP_SHRT 32 // Transport shortcut
+#define WAVE_SHRT 64 // Waveedit shortcut
+#define GLOBAL_SHRT 128 // Global shortcuts
+#define LMEDIT_SHRT 256 // List masteredit
+#define MEDIT_SHRT 512 // Master editor
+#define ALL_SHRT 1023 // All shortcuts
+#define INVIS_SHRT 1024 // Shortcuts not shown in the config-dialog. Hard-coded. To avoid conflicts
+
+#define SHRT_NUM_OF_CATEGORIES 7 //Number of shortcut categories
+
+struct shortcut
+ {
+ int key;
+ const char* descr;
+ const char* xml; //xml-tag for config-file
+ int type;
+ };
+
+struct shortcut_cg
+ {
+ int id_flag;
+ const char* name;
+ };
+
+typedef struct shortcut ShortCut ;
+
+enum {
+ //Transport/Positioning
+ SHRT_PLAY_SONG, //Enter
+ SHRT_PLAY_TOGGLE, //Space
+ SHRT_STOP, //Insert
+ SHRT_GOTO_START, // W
+ SHRT_GOTO_LEFT, //End-keypad
+ SHRT_GOTO_RIGHT, //Cursordown-keypad
+ SHRT_POS_INC, // Plus
+ SHRT_POS_DEC, // Minus
+ SHRT_TOGGLE_LOOP, // Slash
+ SHRT_TOGGLE_METRO, // C
+ SHRT_START_REC, // *(keypad)
+ SHRT_REC_CLEAR, // *(keypad)
+
+ //Main + Drumeditor
+ SHRT_NEW, //Ctrl+N
+ SHRT_OPEN, //Ctrl+O
+ SHRT_SAVE, //Ctrl+S
+
+ //Used throughout the app:
+ SHRT_UNDO, //Ctrl+Z
+ SHRT_REDO, //Ctrl+Y
+ SHRT_COPY, //Ctrl+C
+ SHRT_CUT, //Ctrl+X
+ SHRT_PASTE, //Ctrl+V
+ SHRT_DELETE,//Delete
+
+
+ //Main:
+ SHRT_SAVE_AS, //Default: undefined
+ SHRT_OPEN_RECENT, //Ctrl+1
+ SHRT_LOAD_TEMPLATE, //Default: undefined
+ SHRT_CONFIG_PRINTER, //Ctrl+P
+ SHRT_IMPORT_MIDI, //Default: undefined
+ SHRT_EXPORT_MIDI, //Default: undefined
+ SHRT_IMPORT_PART, //!< Import midi part to current track & location, Default: undefined
+ SHRT_IMPORT_AUDIO, //Default: undefined
+ SHRT_QUIT, //Default: Ctrl+Q
+
+ SHRT_DESEL_PARTS, //Ctrl+B
+ SHRT_SELECT_PRTSTRACK, //Default: undefined
+ SHRT_OPEN_PIANO, //Ctrl+E
+ SHRT_OPEN_SCORE, //Ctrl+R
+ SHRT_OPEN_DRUMS, //Ctrl+D
+ SHRT_OPEN_LIST, //Ctrl+L
+ SHRT_OPEN_WAVE, //Ctrl+W
+ SHRT_OPEN_GRAPHIC_MASTER, //Ctrl+M
+ SHRT_OPEN_LIST_MASTER, //Ctrl+Shift+M
+ SHRT_OPEN_MIDI_TRANSFORM, //Ctrl+T
+
+ SHRT_GLOBAL_CUT, //Default: undefined
+ SHRT_GLOBAL_INSERT, //Default: undefined
+ SHRT_GLOBAL_SPLIT, //Default: undefined
+ SHRT_COPY_RANGE, //Default: undefined
+ SHRT_CUT_EVENTS, //Default: undefined
+
+ SHRT_OPEN_TRANSPORT, //F11
+ SHRT_OPEN_BIGTIME, //F12
+ SHRT_OPEN_MIXER, //Ctrl+*
+ SHRT_OPEN_MIXER2, //Ctrl+*
+ SHRT_OPEN_MARKER, // F9
+ SHRT_OPEN_CLIPS, //Default: undefined
+
+ SHRT_FOLLOW_JUMP, //Default: undefined
+ SHRT_FOLLOW_NO, //Default: undefined
+ SHRT_FOLLOW_CONTINUOUS, //Default: undefined
+
+ SHRT_GLOBAL_CONFIG, //Default: undefined
+ SHRT_CONFIG_SHORTCUTS, //Default: undefined
+ SHRT_CONFIG_METRONOME, //Default: undefined
+ SHRT_CONFIG_MIDISYNC, //Default: undefined
+ SHRT_MIDI_FILE_CONFIG, //Default: undefined
+ SHRT_APPEARANCE_SETTINGS, //Default: undefined
+ SHRT_CONFIG_MIDI_PORTS, //Default: undefined
+ SHRT_CONFIG_AUDIO_PORTS, //Default: undefined
+ //SHRT_SAVE_GLOBAL_CONFIG, //Default: undefined
+
+ SHRT_MIDI_EDIT_INSTRUMENTS, //Default: undefined
+ SHRT_MIDI_INPUT_TRANSFORM, //Default: undefined
+ SHRT_MIDI_INPUT_FILTER, //Default: undefined
+ SHRT_MIDI_INPUT_TRANSPOSE, //Default: undefined
+ SHRT_MIDI_REMOTE_CONTROL, //Default: undefined
+ SHRT_RANDOM_RHYTHM_GENERATOR, //Default: undefined
+ SHRT_MIDI_RESET, //Default: undefined
+ SHRT_MIDI_INIT, //Default: undefined
+ SHRT_MIDI_LOCAL_OFF, //Default: undefined
+
+ SHRT_AUDIO_BOUNCE_TO_TRACK, //Default: undefined
+ SHRT_AUDIO_BOUNCE_TO_FILE, //Default: undefined
+ SHRT_AUDIO_RESTART, //Default: undefined
+
+ SHRT_MIXER_AUTOMATION, //Default: undefined
+ SHRT_MIXER_SNAPSHOT, //Default: undefined
+ SHRT_MIXER_AUTOMATION_CLEAR, //Default: undefined
+
+ SHRT_ADD_MIDI_TRACK, //Default: Ctrl+J
+ SHRT_ADD_DRUM_TRACK, //Default: undefined
+ SHRT_ADD_WAVE_TRACK, //Default: undefined
+ SHRT_ADD_AUDIO_OUTPUT, //Default: undefined
+ SHRT_ADD_AUDIO_GROUP, //Default: undefined
+ SHRT_ADD_AUDIO_INPUT, //Default: undefined
+ SHRT_ADD_AUDIO_AUX, //Default: undefined
+ SHRT_RESET_MIDI, //Ctrl+Alt+Z
+
+ SHRT_OPEN_HELP, //F1
+ SHRT_START_WHATSTHIS, //Shift-F1
+
+ //Arranger, parts:
+ SHRT_EDIT_PART, //Enter
+ SHRT_SEL_ABOVE, //Up
+ SHRT_SEL_ABOVE_ADD, //move up and add to selection
+ SHRT_SEL_BELOW, //Down
+ SHRT_SEL_BELOW_ADD, //move down and add to selection
+
+ SHRT_INSERT, //Ctrl+Shift+I - insert parts instead of pasting
+ SHRT_INSERTMEAS, //Ctrl+Shift+M - insert measures
+
+ SHRT_PASTE_CLONE, //CTRL+SHIFT+Key_V
+ SHRT_PASTE_TO_TRACK, //CTRL+Key_B
+ SHRT_PASTE_CLONE_TO_TRACK, //CTRL+SHIFT+Key_B
+
+ //Arranger tracks
+ SHRT_SEL_TRACK_BELOW,
+ SHRT_SEL_TRACK_ABOVE,
+
+ //To be in arranger, pianoroll & drumeditor. p4.0.10 now globally handled, too.
+ SHRT_SELECT_ALL, //Ctrl+A
+ SHRT_SELECT_NONE, //Ctrl+Shift+A
+ SHRT_SELECT_INVERT, //Ctrl+I
+ SHRT_SELECT_ILOOP, //Default: Undefined
+ SHRT_SELECT_OLOOP, //Default: Undefined
+ SHRT_SELECT_PREV_PART, // Ctrl+-
+ SHRT_SELECT_NEXT_PART, // Ctrl++
+ SHRT_SEL_LEFT, //left
+ SHRT_SEL_LEFT_ADD, //move left and add to selection
+ SHRT_SEL_RIGHT, //Right
+ SHRT_SEL_RIGHT_ADD, //move right and add to selection
+ SHRT_INC_PITCH,
+ SHRT_DEC_PITCH,
+ SHRT_INC_POS,
+ SHRT_DEC_POS,
+
+ SHRT_POS_INC_NOSNAP,
+ SHRT_POS_DEC_NOSNAP,
+
+ /*
+ SHRT_POS_INC_BAR,
+ SHRT_POS_DEC_BAR,
+ SHRT_POS_INC_BAR_NOSNAP,
+ SHRT_POS_DEC_BAR_NOSNAP,
+
+ SHRT_POS_INC_BEAT,
+ SHRT_POS_DEC_BEAT,
+ SHRT_POS_INC_BEAT_NOSNAP,
+ SHRT_POS_DEC_BEAT_NOSNAP,
+
+ SHRT_POS_INC_TICK,
+ SHRT_POS_DEC_TICK,
+ SHRT_POS_INC_TICK_NOSNAP,
+ SHRT_POS_DEC_TICK_NOSNAP,
+
+ SHRT_POS_INC_MINUTE,
+ SHRT_POS_DEC_MINUTE,
+ SHRT_POS_INC_MINUTE_NOSNAP,
+ SHRT_POS_DEC_MINUTE_NOSNAP,
+
+ SHRT_POS_INC_SECOND,
+ SHRT_POS_DEC_SECOND,
+ SHRT_POS_INC_SECOND_NOSNAP,
+ SHRT_POS_DEC_SECOND_NOSNAP,
+
+ SHRT_POS_INC_FRAME,
+ SHRT_POS_DEC_FRAME,
+ */
+
+ SHRT_LOCATORS_TO_SELECTION, //Alt+P, currently in arranger & pianoroll
+ SHRT_INSERT_AT_LOCATION, //Shift+CrsrRight
+ SHRT_INCREASE_LEN,
+ SHRT_DECREASE_LEN,
+
+ SHRT_TOOL_1,//Shift+1 Pointer
+ SHRT_TOOL_2,//Shift+2 Pen
+ SHRT_TOOL_3,//Shift+3 Rubber
+ SHRT_TOOL_4,//Shift+4
+ SHRT_TOOL_5,//Shift+5
+ SHRT_TOOL_6,//Shift+6
+ SHRT_TRANSPOSE, //Default: undefined
+
+ //Shortcuts to be in pianoroll & drumeditor
+ SHRT_ZOOM_IN, // PgUp
+ SHRT_ZOOM_OUT, // PgDown
+ SHRT_GOTO_CPOS, // c
+ SHRT_SCROLL_LEFT, // h
+ SHRT_SCROLL_RIGHT, // l
+ SHRT_FIXED_LEN, //Alt+L, currently only drumeditor
+ SHRT_QUANTIZE, //q
+ SHRT_OVER_QUANTIZE, //Default: undefined
+ SHRT_ON_QUANTIZE, //Default: undefined
+ SHRT_ONOFF_QUANTIZE, //Default: undefined
+ SHRT_ITERATIVE_QUANTIZE, //Default: undefined
+ SHRT_CONFIG_QUANT, //Default: Ctrl+Alt+Q
+ SHRT_MODIFY_GATE_TIME, //Default: undefined
+ SHRT_MODIFY_VELOCITY,
+ SHRT_CRESCENDO,
+ SHRT_DELETE_OVERLAPS,
+
+ SHRT_THIN_OUT,
+ SHRT_ERASE_EVENT,
+ SHRT_NOTE_SHIFT,
+ SHRT_MOVE_CLOCK,
+ SHRT_COPY_MEASURE,
+ SHRT_ERASE_MEASURE,
+ SHRT_DELETE_MEASURE,
+ SHRT_CREATE_MEASURE,
+ SHRT_SET_QUANT_1, //1 - pianoroll
+ SHRT_SET_QUANT_2, //2 - pianoroll
+ SHRT_SET_QUANT_3, //3 - pianoroll
+ SHRT_SET_QUANT_4, //4 - pianoroll
+ SHRT_SET_QUANT_5, //5 - pianoroll
+ SHRT_SET_QUANT_6, //6 - pianoroll
+ SHRT_SET_QUANT_7, //7 - pianoroll
+ SHRT_TOGGLE_TRIOL, //t
+ SHRT_TOGGLE_PUNCT, //.-keypad
+ SHRT_TOGGLE_PUNCT2, // ,
+
+ SHRT_EVENT_COLOR, //e
+
+ SHRT_ADD_PROGRAM, //Add program change backslash
+ SHRT_DEL_PROGRAM, //Delete program change under cursor shit+backslash
+ SHRT_SEL_INSTRUMENT,
+
+ // Shortcuts for tools
+ // global
+ SHRT_TOOL_POINTER, //
+ SHRT_TOOL_PENCIL,
+ SHRT_TOOL_RUBBER,
+
+ // pianoroll and drum editor
+ SHRT_TOOL_LINEDRAW,
+
+ // arranger
+ SHRT_TOOL_SCISSORS,
+ SHRT_TOOL_GLUE,
+ SHRT_TOOL_MUTE,
+
+
+ //Listeditor:
+ SHRT_LE_INS_NOTES, //Ctrl+N
+ SHRT_LE_INS_SYSEX, //Ctrl+S
+ SHRT_LE_INS_CTRL, //Ctrl+T
+ SHRT_LE_INS_META, //Default: undefined
+ SHRT_LE_INS_CHAN_AFTERTOUCH,//Ctrl+A
+ SHRT_LE_INS_POLY_AFTERTOUCH,//Ctrl+P
+
+ //List master editor:
+ SHRT_LM_INS_TEMPO, // Ctrl+T
+ SHRT_LM_INS_SIG, // Ctrl+R
+ SHRT_LM_EDIT_BEAT, // Ctrl+Shift+E
+ SHRT_LM_EDIT_VALUE,// Ctrl+E
+
+ // Marker view
+ SHRT_NEXT_MARKER,
+ SHRT_PREV_MARKER,
+
+ //Last item:
+ SHRT_NUM_OF_ELEMENTS // must be last
+ };
+
+extern ShortCut shortcuts[SHRT_NUM_OF_ELEMENTS]; //size of last entry
+extern void initShortCuts();
+extern void writeShortCuts(int level, Xml& xml);
+extern void readShortCuts (Xml& xml);
+extern const shortcut_cg shortcut_category[SHRT_NUM_OF_CATEGORIES];
+#endif
diff --git a/attic/muse2-oom/muse2/muse/sig.cpp b/attic/muse2-oom/muse2/muse/sig.cpp
new file mode 100644
index 00000000..8bbebfae
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/sig.cpp
@@ -0,0 +1,439 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: sig.cpp,v 1.5.2.2 2009/03/09 02:05:17 terminator356 Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <assert.h>
+#include "sig.h"
+#include "gconfig.h"
+#include "xml.h"
+
+SigList sigmap;
+
+//---------------------------------------------------------
+// SigList
+//---------------------------------------------------------
+
+SigList::SigList()
+ {
+ insert(std::pair<const unsigned, SigEvent*> (MAX_TICK, new SigEvent(4, 4, 0)));
+ }
+
+//---------------------------------------------------------
+// add
+// signatures are only allowed at the beginning of
+// a bar
+//---------------------------------------------------------
+
+void SigList::add(unsigned tick, int z, int n)
+ {
+ if (z == 0 || n == 0) {
+ printf("SigList::add illegal signature %d/%d\n", z, n);
+
+ // Added p3.3.43
+ return;
+ }
+ tick = raster1(tick, 0);
+ iSigEvent e = upper_bound(tick);
+ assert(e != end());
+
+ if (tick == e->second->tick) {
+ e->second->z = z;
+ e->second->n = n;
+ }
+ else {
+ SigEvent* ne = e->second;
+ SigEvent* ev = new SigEvent(ne->z, ne->n, ne->tick);
+ ne->z = z;
+ ne->n = n;
+ ne->tick = tick;
+ insert(std::pair<const unsigned, SigEvent*> (tick, ev));
+ }
+ normalize();
+ }
+
+//---------------------------------------------------------
+// del
+//---------------------------------------------------------
+
+void SigList::del(unsigned tick)
+ {
+// printf("SigList::del(%d)\n", tick);
+ iSigEvent e = find(tick);
+ if (e == end()) {
+ printf("SigList::del(%d): not found\n", tick);
+ return;
+ }
+ iSigEvent ne = e;
+ ++ne;
+ if (ne == end()) {
+ printf("SigList::del() HALLO\n");
+ return;
+ }
+ ne->second->z = e->second->z;
+ ne->second->n = e->second->n;
+ ne->second->tick = e->second->tick;
+ erase(e);
+ normalize();
+ }
+
+//---------------------------------------------------------
+// SigList::normalize
+//---------------------------------------------------------
+
+void SigList::normalize()
+ {
+ int z = 0;
+ int n = 0;
+ unsigned tick = 0;
+ iSigEvent ee;
+
+ for (iSigEvent e = begin(); e != end();) {
+ if (z == e->second->z && n == e->second->n) {
+ e->second->tick = tick;
+ erase(ee);
+ }
+ z = e->second->z;
+ n = e->second->n;
+ ee = e;
+ tick = e->second->tick;
+ ++e;
+ }
+
+ int bar = 0;
+ for (iSigEvent e = begin(); e != end();) {
+ e->second->bar = bar;
+ int delta = e->first - e->second->tick;
+ int ticksB = ticks_beat(e->second->n);
+ int ticksM = ticksB * e->second->z;
+ bar += delta / ticksM;
+ if (delta % ticksM) // Teil eines Taktes
+ ++bar;
+ ++e;
+ }
+ }
+
+//---------------------------------------------------------
+// SigList::dump
+//---------------------------------------------------------
+
+void SigList::dump() const
+ {
+ printf("\nSigList:\n");
+ for (ciSigEvent i = begin(); i != end(); ++i) {
+ printf("%6d %06d Bar %3d %02d/%d\n",
+ i->first, i->second->tick,
+ i->second->bar, i->second->z, i->second->n);
+ }
+ }
+
+void SigList::clear()
+ {
+ for (iSigEvent i = begin(); i != end(); ++i)
+ delete i->second;
+ SIGLIST::clear();
+ insert(std::pair<const unsigned, SigEvent*> (MAX_TICK, new SigEvent(4, 4, 0)));
+ }
+
+//---------------------------------------------------------
+// ticksMeasure
+//---------------------------------------------------------
+
+int SigList::ticksMeasure(int Z, int N) const
+ {
+ return ticks_beat(N) * Z;
+ }
+
+int SigList::ticksMeasure(unsigned tick) const
+ {
+ ciSigEvent i = upper_bound(tick);
+ if (i == end()) {
+ printf("ticksMeasure: not found %d\n", tick);
+ // abort();
+ return 0;
+ }
+ return ticksMeasure(i->second->z, i->second->n);
+ }
+
+//---------------------------------------------------------
+// ticksBeat
+//---------------------------------------------------------
+
+int SigList::ticksBeat(unsigned tick) const
+ {
+ ciSigEvent i = upper_bound(tick);
+ assert(i != end());
+ return ticks_beat(i->second->n);
+ }
+
+int SigList::ticks_beat(int n) const
+ {
+ int m = config.division;
+ switch (n) {
+ case 1: m <<= 2; break; // 1536
+ case 2: m <<= 1; break; // 768
+ case 3: m += m >> 1; break; // 384+192
+ case 4: break; // 384
+ case 8: m >>= 1; break; // 192
+ case 16: m >>= 2; break; // 96
+ case 32: m >>= 3; break; // 48
+ case 64: m >>= 4; break; // 24
+ case 128: m >>= 5; break; // 12
+ default: assert(false); break;
+ }
+ return m;
+ }
+
+//---------------------------------------------------------
+// timesig
+//---------------------------------------------------------
+
+void SigList::timesig(unsigned tick, int& z, int& n) const
+ {
+ ciSigEvent i = upper_bound(tick);
+ if (i == end()) {
+ printf("timesig(%d): not found\n", tick);
+ // abort();
+ z = 4;
+ n = 4;
+ }
+ else {
+ z = i->second->z;
+ n = i->second->n;
+ }
+ }
+
+//---------------------------------------------------------
+// tickValues
+//---------------------------------------------------------
+
+void SigList::tickValues(unsigned t, int* bar, int* beat, unsigned* tick) const
+ {
+ ciSigEvent e = upper_bound(t);
+ if (e == end()) {
+ fprintf(stderr, "tickValues(0x%x) not found(%zd)\n", t, size());
+ // abort();
+ *bar = 0;
+ *beat = 0;
+ *tick = 0;
+ return;
+ }
+
+ int delta = t - e->second->tick;
+ int ticksB = ticks_beat(e->second->n);
+ int ticksM = ticksB * e->second->z;
+ *bar = e->second->bar + delta / ticksM;
+ int rest = delta % ticksM;
+ *beat = rest / ticksB;
+ *tick = rest % ticksB;
+ }
+
+//---------------------------------------------------------
+// bar2tick
+//---------------------------------------------------------
+
+unsigned SigList::bar2tick(int bar, int beat, unsigned tick) const
+ {
+ ciSigEvent e;
+
+ if (bar < 0)
+ bar = 0;
+ for (e = begin(); e != end();) {
+ ciSigEvent ee = e;
+ ++ee;
+ if (ee == end())
+ break;
+ if (bar < ee->second->bar)
+ break;
+ e = ee;
+ }
+ int ticksB = ticks_beat(e->second->n);
+ int ticksM = ticksB * e->second->z;
+ return e->second->tick + (bar-e->second->bar)*ticksM + ticksB*beat + tick;
+ }
+
+//---------------------------------------------------------
+// raster
+//---------------------------------------------------------
+
+unsigned SigList::raster(unsigned t, int raster) const
+ {
+ if (raster == 1)
+ return t;
+ ciSigEvent e = upper_bound(t);
+ if (e == end()) {
+ printf("SigList::raster(%x,)\n", t);
+ // abort();
+ return t;
+ }
+ int delta = t - e->second->tick;
+ int ticksM = ticks_beat(e->second->n) * e->second->z;
+ if (raster == 0)
+ raster = ticksM;
+ int rest = delta % ticksM;
+ int bb = (delta/ticksM)*ticksM;
+ return e->second->tick + bb + ((rest + raster/2)/raster)*raster;
+ }
+
+//---------------------------------------------------------
+// raster1
+// round down
+//---------------------------------------------------------
+
+unsigned SigList::raster1(unsigned t, int raster) const
+ {
+ if (raster == 1)
+ return t;
+ ciSigEvent e = upper_bound(t);
+ assert(e != end());
+
+ int delta = t - e->second->tick;
+ int ticksM = ticks_beat(e->second->n) * e->second->z;
+ if (raster == 0)
+ raster = ticksM;
+ int rest = delta % ticksM;
+ int bb = (delta/ticksM)*ticksM;
+ return e->second->tick + bb + (rest/raster)*raster;
+ }
+
+//---------------------------------------------------------
+// raster2
+// round up
+//---------------------------------------------------------
+
+unsigned SigList::raster2(unsigned t, int raster) const
+ {
+ if (raster == 1)
+ return t;
+ ciSigEvent e = upper_bound(t);
+ assert(e != end());
+
+ int delta = t - e->second->tick;
+ int ticksM = ticks_beat(e->second->n) * e->second->z;
+ if (raster == 0)
+ raster = ticksM;
+ int rest = delta % ticksM;
+ int bb = (delta/ticksM)*ticksM;
+ return e->second->tick + bb + ((rest+raster-1)/raster)*raster;
+ }
+
+//---------------------------------------------------------
+// rasterStep
+//---------------------------------------------------------
+
+int SigList::rasterStep(unsigned t, int raster) const
+ {
+ if (raster == 0) {
+ ciSigEvent e = upper_bound(t);
+ assert(e != end());
+ return ticks_beat(e->second->n) * e->second->z;
+ }
+ return raster;
+ }
+
+//---------------------------------------------------------
+// SigList::write
+//---------------------------------------------------------
+
+void SigList::write(int level, Xml& xml) const
+ {
+ xml.tag(level++, "siglist");
+ for (ciSigEvent i = begin(); i != end(); ++i)
+ i->second->write(level, xml, i->first);
+ xml.tag(level, "/siglist");
+ }
+
+//---------------------------------------------------------
+// SigList::read
+//---------------------------------------------------------
+
+void SigList::read(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "sig") {
+ SigEvent* t = new SigEvent();
+ unsigned tick = t->read(xml);
+ iSigEvent pos = find(tick);
+ if (pos != end())
+ erase(pos);
+ insert(std::pair<const unsigned, SigEvent*> (tick, t));
+ }
+ else
+ xml.unknown("SigList");
+ break;
+ case Xml::Attribut:
+ break;
+ case Xml::TagEnd:
+ if (tag == "siglist") {
+ normalize();
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// SigEvent::write
+//---------------------------------------------------------
+
+void SigEvent::write(int level, Xml& xml, int at) const
+ {
+ xml.tag(level++, "sig at=\"%d\"", at);
+ xml.intTag(level, "tick", tick);
+ xml.intTag(level, "nom", z);
+ xml.intTag(level, "denom", n);
+ xml.tag(level, "/sig");
+ }
+
+//---------------------------------------------------------
+// SigEvent::read
+//---------------------------------------------------------
+
+int SigEvent::read(Xml& xml)
+ {
+ int at = 0;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return 0;
+ case Xml::TagStart:
+ if (tag == "tick")
+ tick = xml.parseInt();
+ else if (tag == "nom")
+ z = xml.parseInt();
+ else if (tag == "denom")
+ n = xml.parseInt();
+ else
+ xml.unknown("SigEvent");
+ break;
+ case Xml::Attribut:
+ if (tag == "at")
+ at = xml.s2().toInt();
+ break;
+ case Xml::TagEnd:
+ if (tag == "sig")
+ return at;
+ default:
+ break;
+ }
+ }
+ return 0;
+ }
+
+
diff --git a/attic/muse2-oom/muse2/muse/sig.h b/attic/muse2-oom/muse2/muse/sig.h
new file mode 100644
index 00000000..6a561d6e
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/sig.h
@@ -0,0 +1,79 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: sig.h,v 1.2 2004/01/11 18:55:34 wschweer Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SIG_H__
+#define __SIG_H__
+
+#include <map>
+
+#ifndef MAX_TICK
+#define MAX_TICK (0x7fffffff/100)
+#endif
+
+class Xml;
+
+//---------------------------------------------------------
+// Signature Event
+//---------------------------------------------------------
+
+struct SigEvent {
+ int z, n; // takt signatur
+ unsigned tick; // ab dieser Position gilt signatur
+ int bar; // precomputed
+
+ int read(Xml&);
+ void write(int, Xml&, int) const;
+
+ SigEvent() { }
+ SigEvent(int Z, int N, unsigned tk) {
+ z = Z;
+ n = N;
+ tick = tk;
+ bar = 0;
+ }
+ };
+
+//---------------------------------------------------------
+// SigList
+//---------------------------------------------------------
+
+typedef std::map<unsigned, SigEvent*, std::less<unsigned> > SIGLIST;
+typedef SIGLIST::iterator iSigEvent;
+typedef SIGLIST::const_iterator ciSigEvent;
+typedef SIGLIST::reverse_iterator riSigEvent;
+typedef SIGLIST::const_reverse_iterator criSigEvent;
+
+class SigList : public SIGLIST {
+ int ticks_beat(int N) const;
+ void normalize();
+ int ticksMeasure(int z, int n) const;
+
+ public:
+ SigList();
+ void clear();
+ void add(unsigned tick, int z, int n);
+ void del(unsigned tick);
+
+ void read(Xml&);
+ void write(int, Xml&) const;
+ void dump() const;
+
+ void timesig(unsigned tick, int& z, int& n) const;
+ void tickValues(unsigned t, int* bar, int* beat, unsigned* tick) const;
+ unsigned bar2tick(int bar, int beat, unsigned tick) const;
+
+ int ticksMeasure(unsigned tick) const;
+ int ticksBeat(unsigned tick) const;
+ unsigned raster(unsigned tick, int raster) const;
+ unsigned raster1(unsigned tick, int raster) const;
+ unsigned raster2(unsigned tick, int raster) const;
+ int rasterStep(unsigned tick, int raster) const;
+ };
+
+extern SigList sigmap;
+#endif
diff --git a/attic/muse2-oom/muse2/muse/song.cpp b/attic/muse2-oom/muse2/muse/song.cpp
new file mode 100644
index 00000000..9174bbe4
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/song.cpp
@@ -0,0 +1,3911 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: song.cpp,v 1.59.2.52 2009/12/15 03:39:58 terminator356 Exp $
+//
+// (C) Copyright 2000-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <unistd.h>
+#include <stdio.h>
+#include <errno.h>
+
+#include <QAction>
+#include <QDir>
+#include <QMenu>
+#include <QMessageBox>
+#include <QPoint>
+#include <QSignalMapper>
+#include <QTextStream>
+
+#include "app.h"
+#include "driver/jackmidi.h"
+#include "driver/alsamidi.h"
+#include "song.h"
+#include "track.h"
+#include "undo.h"
+#include "key.h"
+#include "globals.h"
+#include "event.h"
+#include "drummap.h"
+#include "marker/marker.h"
+#include "synth.h"
+#include "audio.h"
+#include "mididev.h"
+#include "amixer.h"
+#include "midiseq.h"
+#include "audiodev.h"
+#include "gconfig.h"
+#include "sync.h"
+#include "midictrl.h"
+#include "menutitleitem.h"
+#include "midi.h"
+///#include "sig.h"
+#include "al/sig.h"
+#include <sys/wait.h>
+#include "trackview.h"
+
+extern void clearMidiTransforms();
+extern void clearMidiInputTransforms();
+Song* song;
+
+/*
+//---------------------------------------------------------
+// RoutingMenuItem
+//---------------------------------------------------------
+
+class RoutingMenuItem : public QCustomMenuItem
+{
+ Route route;
+ //virtual QSize sizeHint() { return QSize(80, h); }
+ virtual void paint(QPainter* p, const QColorGroup&, bool, bool, int x, int y, int w, int h)
+ {
+ p->fillRect(x, y, w, h, QBrush(lightGray));
+ p->drawText(x, y, w, h, AlignCenter, route.name());
+ }
+
+ public:
+ RoutingMenuItem(const Route& r) : route(r) { }
+};
+*/
+
+//---------------------------------------------------------
+// Song
+//---------------------------------------------------------
+
+Song::Song(const char* name)
+ :QObject(0)
+ {
+ setObjectName(name);
+ _arrangerRaster = 0; // Set to measure, the same as Arranger intial value. Arranger snap combo will set this.
+ noteFifoSize = 0;
+ noteFifoWindex = 0;
+ noteFifoRindex = 0;
+ undoList = new UndoList;
+ redoList = new UndoList;
+ _markerList = new MarkerList;
+ _globalPitchShift = 0;
+ clear(false);
+ }
+
+//---------------------------------------------------------
+// Song
+//---------------------------------------------------------
+
+Song::~Song()
+ {
+ delete undoList;
+ delete redoList;
+ delete _markerList;
+ }
+
+//---------------------------------------------------------
+// putEvent
+//---------------------------------------------------------
+
+void Song::putEvent(int pv)
+ {
+ if (noteFifoSize < REC_NOTE_FIFO_SIZE) {
+ recNoteFifo[noteFifoWindex] = pv;
+ noteFifoWindex = (noteFifoWindex + 1) % REC_NOTE_FIFO_SIZE;
+ ++noteFifoSize;
+ }
+ }
+
+//---------------------------------------------------------
+// setTempo
+// public slot
+//---------------------------------------------------------
+
+void Song::setTempo(int newTempo)
+ {
+ audio->msgSetTempo(pos[0].tick(), newTempo, true);
+ }
+
+//---------------------------------------------------------
+// setSig
+// called from transport window
+//---------------------------------------------------------
+
+void Song::setSig(int z, int n)
+ {
+ if (_masterFlag) {
+ audio->msgAddSig(pos[0].tick(), z, n);
+ }
+ }
+
+void Song::setSig(const AL::TimeSignature& sig)
+ {
+ if (_masterFlag) {
+ audio->msgAddSig(pos[0].tick(), sig.z, sig.n);
+ }
+ }
+
+//---------------------------------------------------------
+// addNewTrack
+// Called from GUI context
+// Besides normal track types, n includes synth menu ids from populateAddTrack()
+//---------------------------------------------------------
+
+Track* Song::addNewTrack(QAction* action)
+{
+ int n = action->data().toInt();
+ // Ignore negative numbers since this slot could be called by a menu or list etc. passing -1.
+ if(n < 0)
+ return 0;
+
+ // Synth sub-menu id?
+ if(n >= MENU_ADD_SYNTH_ID_BASE)
+ {
+ n -= MENU_ADD_SYNTH_ID_BASE;
+ if(n < (int)synthis.size())
+ {
+ //SynthI* si = createSynthI(synthis[n]->baseName());
+ //SynthI* si = createSynthI(synthis[n]->name());
+ SynthI* si = createSynthI(synthis[n]->baseName(), synthis[n]->name());
+ if(!si)
+ return 0;
+
+ // Add instance last in midi device list.
+ for (int i = 0; i < MIDI_PORTS; ++i)
+ {
+ MidiPort* port = &midiPorts[i];
+ MidiDevice* dev = port->device();
+ if (dev==0)
+ {
+ midiSeq->msgSetMidiDevice(port, si);
+ muse->changeConfig(true); // save configuration file
+ deselectTracks();
+ si->setSelected(true);
+ update();
+ return si;
+ }
+ }
+ deselectTracks();
+ si->setSelected(true);
+ update(SC_SELECTION);
+ return si;
+ }
+ else
+ return 0;
+ }
+ // Normal track.
+ else
+ {
+ // Ignore AUDIO_SOFTSYNTH, now that we have it as the synth menu id, since addTrack doesn't like it.
+ if((Track::TrackType)n == Track::AUDIO_SOFTSYNTH)
+ return 0;
+
+ Track* t = addTrack((Track::TrackType)n);
+ deselectTracks();
+ t->setSelected(true);
+ update(SC_SELECTION);
+ return t;
+ }
+}
+
+
+//---------------------------------------------------------/*{{{*/
+// addTrack
+// called from GUI context
+//---------------------------------------------------------
+
+Track* Song::addTrack(int t)
+ {
+ Track::TrackType type = (Track::TrackType) t;
+ Track* track = 0;
+ int lastAuxIdx = _auxs.size();
+ switch(type) {
+ case Track::MIDI:
+ track = new MidiTrack();
+ track->setType(Track::MIDI);
+ break;
+ case Track::DRUM:
+ track = new MidiTrack();
+ track->setType(Track::DRUM);
+ ((MidiTrack*)track)->setOutChannel(9);
+ break;
+ case Track::WAVE:
+ track = new WaveTrack();
+ ((AudioTrack*)track)->addAuxSend(lastAuxIdx);
+ break;
+ case Track::AUDIO_OUTPUT:
+ track = new AudioOutput();
+ break;
+ case Track::AUDIO_GROUP:
+ track = new AudioGroup();
+ ((AudioTrack*)track)->addAuxSend(lastAuxIdx);
+ break;
+ case Track::AUDIO_AUX:
+ track = new AudioAux();
+ break;
+ case Track::AUDIO_INPUT:
+ track = new AudioInput();
+ ((AudioTrack*)track)->addAuxSend(lastAuxIdx);
+ break;
+ case Track::AUDIO_SOFTSYNTH:
+ printf("not implemented: Song::addTrack(SOFTSYNTH)\n");
+ // ((AudioTrack*)track)->addAuxSend(lastAuxIdx);
+ break;
+ default:
+ printf("Song::addTrack() illegal type %d\n", type);
+ abort();
+ }
+ track->setDefaultName();
+ insertTrack1(track, -1);
+ msgInsertTrack(track, -1, true);
+ insertTrack3(track, -1);
+
+ // Add default track <-> midiport routes.
+ if(track->isMidiTrack())
+ {
+ MidiTrack* mt = (MidiTrack*)track;
+ int c, cbi, ch;
+ bool defOutFound = false; /// TODO: Remove this when multiple out routes supported.
+ for(int i = 0; i < MIDI_PORTS; ++i)
+ {
+ MidiPort* mp = &midiPorts[i];
+
+ c = mp->defaultInChannels();
+ if(c)
+ {
+ audio->msgAddRoute(Route(i, c), Route(track, c));
+ updateFlags |= SC_ROUTE;
+ }
+
+ if(!defOutFound) ///
+ {
+ c = mp->defaultOutChannels();
+ if(c)
+ {
+
+ /// TODO: Switch when multiple out routes supported.
+ #if 0
+ audio->msgAddRoute(Route(track, c), Route(i, c));
+ updateFlags |= SC_ROUTE;
+ #else
+ for(ch = 0; ch < MIDI_CHANNELS; ++ch)
+ {
+ cbi = 1 << ch;
+ if(c & cbi)
+ {
+ defOutFound = true;
+ mt->setOutPort(i);
+ mt->setOutChannel(ch);
+ updateFlags |= SC_ROUTE;
+ break;
+ }
+ }
+ #endif
+ }
+ }
+ }
+ }
+
+ //
+ // add default route to master
+ //
+ OutputList* ol = song->outputs();
+ if (!ol->empty()) {
+ AudioOutput* ao = ol->front();
+ switch(type) {
+ //case Track::MIDI:
+ //case Track::DRUM:
+ //case Track::AUDIO_OUTPUT:
+ // break;
+
+ case Track::WAVE:
+ //case Track::AUDIO_GROUP: // Removed by Tim.
+ case Track::AUDIO_AUX:
+ //case Track::AUDIO_INPUT: // Removed by Tim.
+ // p3.3.38
+ //case Track::AUDIO_SOFTSYNTH:
+ audio->msgAddRoute(Route((AudioTrack*)track, -1), Route(ao, -1));
+ updateFlags |= SC_ROUTE;
+ break;
+ // p3.3.38 It should actually never get here now, but just in case.
+ case Track::AUDIO_SOFTSYNTH:
+ audio->msgAddRoute(Route((AudioTrack*)track, 0, ((AudioTrack*)track)->channels()), Route(ao, 0, ((AudioTrack*)track)->channels()));
+ updateFlags |= SC_ROUTE;
+ break;
+ default:
+ break;
+ }
+ }
+ audio->msgUpdateSoloStates();
+ return track;
+ }/*}}}*/
+
+//---------------------------------------------------------
+// cmdRemoveTrack
+//---------------------------------------------------------
+
+void Song::cmdRemoveTrack(Track* track)
+ {
+ int idx = _tracks.index(track);
+ undoOp(UndoOp::DeleteTrack, idx, track);
+ removeTrack2(track);
+ updateFlags |= SC_TRACK_REMOVED;
+ }
+
+//---------------------------------------------------------
+// removeMarkedTracks
+//---------------------------------------------------------
+
+void Song::removeMarkedTracks()
+ {
+ bool loop;
+ do {
+ loop = false;
+ for (iTrack t = _tracks.begin(); t != _tracks.end(); ++t) {
+ if ((*t)->selected()) {
+ removeTrack2(*t);
+ loop = true;
+ break;
+ }
+ }
+ } while (loop);
+ }
+
+//---------------------------------------------------------
+// deselectTracks
+//---------------------------------------------------------
+
+void Song::deselectTracks()
+ {
+ for (iTrack t = _tracks.begin(); t != _tracks.end(); ++t)
+ (*t)->setSelected(false);
+ }
+
+//---------------------------------------------------------
+// changeTrack
+// oldTrack - copy of the original track befor modification
+// newTrack - modified original track
+//---------------------------------------------------------
+
+void Song::changeTrack(Track* oldTrack, Track* newTrack)
+ {
+ oldTrack->setSelected(false); //??
+ int idx = _tracks.index(newTrack);
+
+ //undoOp(UndoOp::ModifyTrack, oldTrack, newTrack);
+ undoOp(UndoOp::ModifyTrack, idx, oldTrack, newTrack);
+ updateFlags |= SC_TRACK_MODIFIED;
+ }
+
+//---------------------------------------------------------
+// addEvent
+// return true if event was added
+//---------------------------------------------------------
+
+bool Song::addEvent(Event& event, Part* part)
+ {
+ /*
+ if (event.type() == Controller) {
+ MidiTrack* track = (MidiTrack*)part->track();
+ int ch = track->outChannel();
+ int tick = event.tick() + part->tick();
+ int cntrl = event.dataA();
+ int val = event.dataB();
+ MidiPort* mp = &midiPorts[track->outPort()];
+
+ // Is it a drum controller event, according to the track port's instrument?
+ if(track->type() == Track::DRUM)
+ {
+ MidiController* mc = mp->drumController(cntrl);
+ if(mc)
+ {
+ int note = cntrl & 0x7f;
+ cntrl &= ~0xff;
+ ch = drumMap[note].channel;
+ mp = &midiPorts[drumMap[note].port];
+ cntrl |= drumMap[note].anote;
+ }
+ }
+
+ // Changed by T356.
+ //if (!mp->setCtrl(ch, tick, cntrl, val)) {
+ // mp->addManagedController(ch, cntrl);
+ // if (!mp->setCtrl(ch, tick, cntrl, val))
+ // return false;
+ // }
+ // Changed again. Don't depend on return value of this - search for the event, below.
+ //if(!mp->setControllerVal(ch, tick, cntrl, val, part))
+ // return false;
+ if(mp->setControllerVal(ch, tick, cntrl, val, part))
+ updateFlags |= SC_MIDI_CONTROLLER;
+ }
+ */
+
+ //addPortCtrlEvents(event, part);
+
+ // Return false if the event is already found.
+ // (But allow a port controller value, above, in case it is not already stored.)
+ if(part->events()->find(event) != part->events()->end())
+ {
+ // This can be normal for some (redundant) operations.
+ if(debugMsg)
+ printf("Song::addEvent event already found in part:%s size:%zd\n", part->name().toLatin1().constData(), part->events()->size());
+ return false;
+ }
+
+ part->events()->add(event);
+ return true;
+ }
+
+//---------------------------------------------------------
+// changeEvent
+//---------------------------------------------------------
+
+void Song::changeEvent(Event& oldEvent, Event& newEvent, Part* part)
+{
+ iEvent i = part->events()->find(oldEvent);
+
+ if (i == part->events()->end()) {
+ // This can be normal for some (redundant) operations.
+ if(debugMsg)
+ printf("Song::changeEvent event not found in part:%s size:%zd\n", part->name().toLatin1().constData(), part->events()->size());
+ // abort();
+ // Removed by T356. Allow it to add the new event.
+ // (And remove the old one from the midi port controller!)
+ //return;
+ }
+ else
+ part->events()->erase(i);
+
+ part->events()->add(newEvent);
+
+ /*
+ if (oldEvent.type() == Controller) {
+ MidiTrack* track = (MidiTrack*)part->track();
+ int ch = track->outChannel();
+ int tick = oldEvent.tick() + part->tick();
+ int cntrl = oldEvent.dataA();
+ MidiPort* mp = &midiPorts[track->outPort()];
+ // Is it a drum controller event, according to the track port's instrument?
+ if(track->type() == Track::DRUM)
+ {
+ MidiController* mc = mp->drumController(cntrl);
+ if(mc)
+ {
+ int note = cntrl & 0x7f;
+ cntrl &= ~0xff;
+ ch = drumMap[note].channel;
+ mp = &midiPorts[drumMap[note].port];
+ cntrl |= drumMap[note].anote;
+ }
+ }
+
+ mp->deleteController(ch, tick, cntrl, part);
+ }
+ */
+ //removePortCtrlEvents(oldEvent, part);
+
+ /*
+ if (newEvent.type() == Controller) {
+ MidiTrack* track = (MidiTrack*)part->track();
+ int ch = track->outChannel();
+ int tick = newEvent.tick() + part->tick();
+ int cntrl = newEvent.dataA();
+ int val = newEvent.dataB();
+ MidiPort* mp = &midiPorts[track->outPort()];
+ // Is it a drum controller event, according to the track port's instrument?
+ if(track->type() == Track::DRUM)
+ {
+ MidiController* mc = mp->drumController(cntrl);
+ if(mc)
+ {
+ int note = cntrl & 0x7f;
+ cntrl &= ~0xff;
+ ch = drumMap[note].channel;
+ mp = &midiPorts[drumMap[note].port];
+ cntrl |= drumMap[note].anote;
+ }
+ }
+
+ mp->setControllerVal(ch, tick, cntrl, val, part);
+ }
+ */
+ //addPortCtrlEvents(newEvent, part);
+}
+
+//---------------------------------------------------------
+// deleteEvent
+//---------------------------------------------------------
+
+void Song::deleteEvent(Event& event, Part* part)
+ {
+ /*
+ if (event.type() == Controller) {
+ MidiTrack* track = (MidiTrack*)part->track();
+ int ch = track->outChannel();
+ int tick = event.tick() + part->tick();
+ int cntrl = event.dataA();
+
+ MidiPort* mp = &midiPorts[track->outPort()];
+ // Is it a drum controller event, according to the track port's instrument?
+ if(track->type() == Track::DRUM)
+ {
+ MidiController* mc = mp->drumController(cntrl);
+ if(mc)
+ {
+ int note = cntrl & 0x7f;
+ cntrl &= ~0xff;
+ ch = drumMap[note].channel;
+ mp = &midiPorts[drumMap[note].port];
+ cntrl |= drumMap[note].anote;
+ }
+ }
+
+ mp->deleteController(ch, tick, cntrl, part);
+ }
+ */
+ //removePortCtrlEvents(event, part);
+
+ iEvent ev = part->events()->find(event);
+ if (ev == part->events()->end()) {
+ // This can be normal for some (redundant) operations.
+ if(debugMsg)
+ printf("Song::deleteEvent event not found in part:%s size:%zd\n", part->name().toLatin1().constData(), part->events()->size());
+ return;
+ }
+ part->events()->erase(ev);
+ }
+
+//---------------------------------------------------------
+// remapPortDrumCtrlEvents
+// Called when drum map anote, channel, or port is changed.
+//---------------------------------------------------------
+
+void Song::remapPortDrumCtrlEvents(int mapidx, int newnote, int newchan, int newport)
+{
+ if(mapidx == -1)
+ return;
+
+ for(ciMidiTrack it = _midis.begin(); it != _midis.end(); ++it)
+ {
+ MidiTrack* mt = *it;
+ if(mt->type() != Track::DRUM)
+ continue;
+
+ MidiPort* trackmp = &midiPorts[mt->outPort()];
+ const PartList* pl = mt->cparts();
+ for(ciPart ip = pl->begin(); ip != pl->end(); ++ip)
+ {
+ MidiPart* part = (MidiPart*)(ip->second);
+ const EventList* el = part->cevents();
+ unsigned len = part->lenTick();
+ for(ciEvent ie = el->begin(); ie != el->end(); ++ie)
+ {
+ const Event& ev = ie->second;
+ // Added by T356. Do not handle events which are past the end of the part.
+ if(ev.tick() >= len)
+ break;
+
+ if(ev.type() != Controller)
+ continue;
+
+ int cntrl = ev.dataA();
+
+ // Is it a drum controller event, according to the track port's instrument?
+ MidiController* mc = trackmp->drumController(cntrl);
+ if(!mc)
+ continue;
+
+ int note = cntrl & 0x7f;
+ // Does the index match?
+ if(note == mapidx)
+ {
+ int tick = ev.tick() + part->tick();
+ int ch = drumMap[note].channel;
+ int port = drumMap[note].port;
+ MidiPort* mp = &midiPorts[port];
+ cntrl = (cntrl & ~0xff) | drumMap[note].anote;
+
+ // Remove the port controller value.
+ mp->deleteController(ch, tick, cntrl, part);
+
+ if(newnote != -1 && newnote != drumMap[note].anote)
+ cntrl = (cntrl & ~0xff) | newnote;
+ if(newchan != -1 && newchan != ch)
+ ch = newchan;
+ if(newport != -1 && newport != port)
+ port = newport;
+
+ mp = &midiPorts[port];
+
+ // Add the port controller value.
+ mp->setControllerVal(ch, tick, cntrl, ev.dataB(), part);
+ }
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------
+// changeAllPortDrumCtlEvents
+// add true: add events. false: remove events
+// drumonly true: Do drum controller events ONLY. false (default): Do ALL controller events.
+//---------------------------------------------------------
+
+void Song::changeAllPortDrumCtrlEvents(bool add, bool drumonly)
+{
+ int ch, trackch, cntrl, tick;
+ MidiPort* mp, *trackmp;
+ for(ciMidiTrack it = _midis.begin(); it != _midis.end(); ++it)
+ {
+ MidiTrack* mt = *it;
+ if(mt->type() != Track::DRUM)
+ continue;
+
+ trackmp = &midiPorts[mt->outPort()];
+ trackch = mt->outChannel();
+ const PartList* pl = mt->cparts();
+ for(ciPart ip = pl->begin(); ip != pl->end(); ++ip)
+ {
+ MidiPart* part = (MidiPart*)(ip->second);
+ const EventList* el = part->cevents();
+ unsigned len = part->lenTick();
+ for(ciEvent ie = el->begin(); ie != el->end(); ++ie)
+ {
+ const Event& ev = ie->second;
+ // Added by T356. Do not handle events which are past the end of the part.
+ if(ev.tick() >= len)
+ break;
+
+ if(ev.type() != Controller)
+ continue;
+
+ cntrl = ev.dataA();
+ mp = trackmp;
+ ch = trackch;
+
+ // Is it a drum controller event, according to the track port's instrument?
+ if(trackmp->drumController(cntrl))
+ {
+ int note = cntrl & 0x7f;
+ ch = drumMap[note].channel;
+ mp = &midiPorts[drumMap[note].port];
+ cntrl = (cntrl & ~0xff) | drumMap[note].anote;
+ }
+ else
+ {
+ if(drumonly)
+ continue;
+ }
+
+ tick = ev.tick() + part->tick();
+
+ if(add)
+ // Add the port controller value.
+ mp->setControllerVal(ch, tick, cntrl, ev.dataB(), part);
+ else
+ // Remove the port controller value.
+ mp->deleteController(ch, tick, cntrl, part);
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------
+// cmdAddRecordedEvents
+// add recorded Events into part
+//---------------------------------------------------------
+
+void Song::cmdAddRecordedEvents(MidiTrack* mt, EventList* events, unsigned startTick)
+ {
+ if (events->empty()) {
+ if (debugMsg)
+ printf("no events recorded\n");
+ return;
+ }
+ iEvent s;
+ iEvent e;
+ unsigned endTick;
+
+ // Changed by Tim. p3.3.8
+
+ //if (punchin())
+ if((audio->loopCount() > 0 && startTick > lPos().tick()) || (punchin() && startTick < lPos().tick()))
+ {
+ startTick = lpos();
+ s = events->lower_bound(startTick);
+ }
+ else
+ {
+ s = events->begin();
+// startTick = s->first;
+ }
+
+ // Changed by Tim. p3.3.8
+
+ //if (punchout())
+ //{
+ // endTick = rpos();
+ // e = events->lower_bound(endTick);
+ //}
+ //else
+ //{
+ // search for last noteOff:
+ endTick = 0;
+ for (iEvent i = events->begin(); i != events->end(); ++i) {
+ Event ev = i->second;
+ unsigned l = ev.endTick();
+ if (l > endTick)
+ endTick = l;
+ }
+ // e = events->end();
+ //}
+ if((audio->loopCount() > 0) || (punchout() && endTick > rPos().tick()) )
+ {
+ endTick = rpos();
+ e = events->lower_bound(endTick);
+ }
+ else
+ e = events->end();
+
+ if (startTick > endTick) {
+ if (debugMsg)
+ printf("no events in record area\n");
+ return;
+ }
+
+ //---------------------------------------------------
+ // if startTick points into a part,
+ // record to that part
+ // else
+ // create new part
+ //---------------------------------------------------
+
+ PartList* pl = mt->parts();
+ MidiPart* part = 0;
+ iPart ip;
+ for (ip = pl->begin(); ip != pl->end(); ++ip) {
+ part = (MidiPart*)(ip->second);
+ unsigned partStart = part->tick();
+ unsigned partEnd = part->endTick();
+ if (startTick >= partStart && startTick < partEnd)
+ break;
+ }
+ if (ip == pl->end()) {
+ if (debugMsg)
+ printf("create new part for recorded events\n");
+ // create new part
+ part = new MidiPart(mt);
+
+ // Changed by Tim. p3.3.8
+
+ // Honour the Arranger snap settings. (Set to bar by default).
+ //startTick = roundDownBar(startTick);
+ //endTick = roundUpBar(endTick);
+ // Round the start down using the Arranger part snap raster value.
+ startTick = AL::sigmap.raster1(startTick, arrangerRaster());
+ // Round the end up using the Arranger part snap raster value.
+ endTick = AL::sigmap.raster2(endTick, arrangerRaster());
+
+ part->setTick(startTick);
+ part->setLenTick(endTick - startTick);
+ part->setName(mt->name());
+ // copy events
+ for (iEvent i = s; i != e; ++i) {
+ Event old = i->second;
+ Event event = old.clone();
+ event.setTick(old.tick() - startTick);
+ // addEvent also adds port controller values. So does msgAddPart, below. Let msgAddPart handle them.
+ //addEvent(event, part);
+ if(part->events()->find(event) == part->events()->end())
+ part->events()->add(event);
+ }
+ audio->msgAddPart(part);
+ updateFlags |= SC_PART_INSERTED;
+ return;
+ }
+
+ updateFlags |= SC_EVENT_INSERTED;
+
+ unsigned partTick = part->tick();
+ if (endTick > part->endTick()) {
+ // Determine new part length...
+ endTick = 0;
+ for (iEvent i = s; i != e; ++i) {
+ Event event = i->second;
+ unsigned tick = event.tick() - partTick + event.lenTick();
+ if (endTick < tick)
+ endTick = tick;
+ }
+ // Added by Tim. p3.3.8
+
+ // Round the end up (again) using the Arranger part snap raster value.
+ endTick = AL::sigmap.raster2(endTick, arrangerRaster());
+
+ // Remove all of the part's port controller values. Indicate do not do clone parts.
+ removePortCtrlEvents(part, false);
+ // Clone the part. This doesn't increment aref count, and doesn't chain clones.
+ // It also gives the new part a new serial number, but it is
+ // overwritten with the old one by Song::changePart(), below.
+ Part* newPart = part->clone();
+ // Set the new part's length.
+ newPart->setLenTick(endTick);
+ // Change the part.
+ changePart(part, newPart);
+ // Manually adjust reference counts.
+ part->events()->incARef(-1);
+ newPart->events()->incARef(1);
+ // Replace the part in the clone chain with the new part.
+ replaceClone(part, newPart);
+ // Now add all of the new part's port controller values. Indicate do not do clone parts.
+ addPortCtrlEvents(newPart, false);
+ // Create an undo op. Indicate do port controller values but not clone parts.
+ undoOp(UndoOp::ModifyPart, part, newPart, true, false);
+ updateFlags |= SC_PART_MODIFIED;
+
+ if (_recMode == REC_REPLACE)
+ {
+ iEvent si = newPart->events()->lower_bound(startTick - newPart->tick());
+ iEvent ei = newPart->events()->lower_bound(newPart->endTick() - newPart->tick());
+ for (iEvent i = si; i != ei; ++i)
+ {
+ Event event = i->second;
+ // Create an undo op. Indicate do port controller values and clone parts.
+ undoOp(UndoOp::DeleteEvent, event, newPart, true, true);
+ // Remove the event from the new part's port controller values, and do all clone parts.
+ removePortCtrlEvents(event, newPart, true);
+ }
+ newPart->events()->erase(si, ei);
+ }
+
+ for (iEvent i = s; i != e; ++i) {
+ Event event = i->second;
+ event.setTick(event.tick() - partTick);
+ Event e;
+ // Create an undo op. Indicate do port controller values and clone parts.
+ undoOp(UndoOp::AddEvent, e, event, newPart, true, true);
+
+ if(newPart->events()->find(event) == newPart->events()->end())
+ newPart->events()->add(event);
+
+ // Add the event to the new part's port controller values, and do all clone parts.
+ addPortCtrlEvents(event, newPart, true);
+ }
+
+
+ /*
+ if (_recMode == REC_REPLACE)
+ {
+ iEvent si = part->events()->lower_bound(startTick - part->tick());
+ iEvent ei = part->events()->lower_bound(part->endTick() - part->tick());
+
+ for (iEvent i = si; i != ei; ++i)
+ {
+ Event event = i->second;
+ // Create an undo op. Indicate do port controller values and clone parts.
+ //undoOp(UndoOp::DeleteEvent, event, part);
+ undoOp(UndoOp::DeleteEvent, event, part, true, true);
+
+ //if (event.type() == Controller) {
+ // MidiTrack* track = (MidiTrack*)part->track();
+ // int ch = track->outChannel();
+ // int tick = event.tick() + part->tick();
+ // int cntrl = event.dataA();
+ // midiPorts[track->outPort()].deleteController(ch, tick, cntrl, part);
+ // }
+
+ // Remove the event from the part's port controller values, and do all clone parts.
+ //removePortCtrlEvents(event, part, true);
+ }
+ part->events()->erase(si, ei);
+ }
+
+ // Remove all of the part's port controller values, and do all clone parts.
+ removePortCtrlEvents(part, true);
+
+ // Clone the part. This doesn't increment aref count, and doesn't chain clones.
+ // It also gives the new part a new serial number, but it is
+ // overwritten with the old one by Song::changePart(), below.
+ Part* newPart = part->clone();
+
+ endTick = 0;
+ for (iEvent i = s; i != e; ++i) {
+ Event event = i->second;
+ unsigned tick = event.tick() - partTick;
+ event.setTick(tick);
+ Event e;
+ // Create an undo op. Indicate do port controller values and clone parts.
+ //undoOp(UndoOp::AddEvent, e, event, newPart);
+ undoOp(UndoOp::AddEvent, e, event, newPart, true, true);
+
+ // addEvent also adds port controller values. So does msgChangePart, below. Let msgChangePart handle them.
+ //addEvent(event, (MidiPart*)newPart);
+ if(newPart->events()->find(event) == newPart->events()->end())
+ newPart->events()->add(event);
+
+ if (endTick < event.tick() + event.lenTick())
+ endTick = event.tick() + event.lenTick();
+ }
+ newPart->setLenTick(endTick); // endTick - part->tick()
+
+ //printf("Song::cmdAddRecordedEvents before changePart part:%p events:%p refs:%d Arefs:%d newPart:%p events:%p refs:%d Arefs:%d\n", part, part->events(), part->events()->refCount(), part->events()->arefCount(), newPart, newPart->events(), newPart->events()->refCount(), newPart->events()->arefCount());
+
+ // Change the part.
+ changePart(part, newPart);
+ // Manually adjust reference counts.
+ part->events()->incARef(-1);
+ newPart->events()->incARef(1);
+ // Replace the part in the clone chain with the new part.
+ replaceClone(part, newPart);
+ // Now add all of the new part's port controller values, and do all clone parts.
+ addPortCtrlEvents(newPart, true);
+
+ //printf("Song::cmdAddRecordedEvents after changePart part:%p events:%p refs:%d Arefs:%d newPart:%p events:%p refs:%d Arefs:%d\n", part, part->events(), part->events()->refCount(), part->events()->arefCount(), newPart, newPart->events(), newPart->events()->refCount(), newPart->events()->arefCount());
+
+ //undoOp(UndoOp::ModifyPart, part, newPart);
+ // Create an undo op. Indicate do not do port controller values and clone parts.
+ undoOp(UndoOp::ModifyPart, part, newPart, false, false);
+
+ // Removed by T356.
+ //part->events()->incARef(-1);
+
+ updateFlags |= SC_PART_MODIFIED;
+ //printf("Song::cmdAddRecordedEvents final part:%p events:%p refs:%d Arefs:%d newPart:%p events:%p refs:%d Arefs:%d\n", part, part->events(), part->events()->refCount(), part->events()->arefCount(), newPart, newPart->events(), newPart->events()->refCount(), newPart->events()->arefCount());
+ */
+
+ }
+ else {
+ if (_recMode == REC_REPLACE) {
+ iEvent si = part->events()->lower_bound(startTick - part->tick());
+ iEvent ei = part->events()->lower_bound(endTick - part->tick());
+
+ for (iEvent i = si; i != ei; ++i) {
+ Event event = i->second;
+ // Create an undo op. Indicate that controller values and clone parts were handled.
+ //undoOp(UndoOp::DeleteEvent, event, part);
+ undoOp(UndoOp::DeleteEvent, event, part, true, true);
+ /*
+ if (event.type() == Controller) {
+ MidiTrack* track = (MidiTrack*)part->track();
+ int ch = track->outChannel();
+ int tick = event.tick() + part->tick();
+ int cntrl = event.dataA();
+ midiPorts[track->outPort()].deleteController(ch, tick, cntrl, part);
+ }
+ */
+ // Remove the event from the part's port controller values, and do all clone parts.
+ removePortCtrlEvents(event, part, true);
+ }
+ part->events()->erase(si, ei);
+ }
+ for (iEvent i = s; i != e; ++i) {
+ Event event = i->second;
+ int tick = event.tick() - partTick;
+ event.setTick(tick);
+
+ // Create an undo op. Indicate that controller values and clone parts were handled.
+ //undoOp(UndoOp::AddEvent, event, part);
+ undoOp(UndoOp::AddEvent, event, part, true, true);
+
+ //addEvent(event, part);
+ if(part->events()->find(event) == part->events()->end())
+ part->events()->add(event);
+
+ // Add the event to the part's port controller values, and do all clone parts.
+ addPortCtrlEvents(event, part, true);
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// findTrack
+//---------------------------------------------------------
+
+MidiTrack* Song::findTrack(const Part* part) const
+ {
+ for (ciTrack t = _tracks.begin(); t != _tracks.end(); ++t) {
+ MidiTrack* track = dynamic_cast<MidiTrack*>(*t);
+ if (track == 0)
+ continue;
+ PartList* pl = track->parts();
+ for (iPart p = pl->begin(); p != pl->end(); ++p) {
+ if (part == p->second)
+ return track;
+ }
+ }
+ return 0;
+ }
+
+//---------------------------------------------------------
+// findTrack
+// find track by name
+//---------------------------------------------------------
+
+Track* Song::findTrack(const QString& name) const
+ {
+ for (ciTrack i = _tracks.begin(); i != _tracks.end(); ++i) {
+ if ((*i)->name() == name)
+ return *i;
+ }
+ return 0;
+ }
+
+//---------------------------------------------------------
+// setLoop
+// set transport loop flag
+//---------------------------------------------------------
+
+void Song::setLoop(bool f)
+ {
+ if (loopFlag != f) {
+ loopFlag = f;
+ loopAction->setChecked(loopFlag);
+ emit loopChanged(loopFlag);
+ }
+ }
+
+//---------------------------------------------------------
+// clearTrackRec
+//---------------------------------------------------------
+void Song::clearTrackRec()
+{
+ for (iTrack it = tracks()->begin(); it != tracks()->end(); ++it)
+ setRecordFlag(*it,false);
+}
+
+//---------------------------------------------------------
+// setRecord
+//---------------------------------------------------------
+void Song::setRecord(bool f, bool autoRecEnable)
+ {
+ if (f && museProject == museProjectInitPath ) { // check that there is a project stored before commencing
+ // no project, we need to create one.
+ if (!muse->saveAs())
+ return; // could not store project, won't enable record
+ }
+ if (recordFlag != f) {
+ if (f && autoRecEnable) {
+ bool alreadyRecEnabled = false;
+ Track *selectedTrack = 0;
+ // loop through list and check if any track is rec enabled
+ // if not then rec enable the selected track
+ WaveTrackList* wtl = waves();
+ for (iWaveTrack i = wtl->begin(); i != wtl->end(); ++i) {
+ if((*i)->recordFlag())
+ {
+ alreadyRecEnabled = true;
+ break;
+ }
+ if((*i)->selected())
+ selectedTrack = (*i);
+ }
+ if (!alreadyRecEnabled) {
+ MidiTrackList* mtl = midis();
+ for (iMidiTrack it = mtl->begin(); it != mtl->end(); ++it) {
+ if((*it)->recordFlag())
+ {
+ alreadyRecEnabled = true;
+ break;
+ }
+ if((*it)->selected())
+ selectedTrack = (*it);
+ }
+ }
+ if (!alreadyRecEnabled && selectedTrack) {
+ setRecordFlag(selectedTrack, true);
+ }
+ else if (alreadyRecEnabled) {
+ // do nothing
+ }
+ else {
+ // if there are no tracks, do not enable record
+ if (!waves()->size() && !midis()->size()) {
+ printf("No track to select, won't enable record\n");
+ f = false;
+ }
+ }
+ // prepare recording of wave files for all record enabled wave tracks
+ for (iWaveTrack i = wtl->begin(); i != wtl->end(); ++i) {
+ if((*i)->recordFlag())
+ {
+ (*i)->prepareRecording();
+ }
+ }
+
+#if 0
+ // check for midi devices suitable for recording
+ bool portFound = false;
+ for (int i = 0; i < MIDI_PORTS; ++i) {
+ MidiDevice* dev = midiPorts[i].device();
+ if (dev && (dev->rwFlags() & 0x2))
+ portFound = true;
+ }
+ if (!portFound) {
+ QMessageBox::critical(qApp->mainWidget(), "MusE: Record",
+ "There are no midi devices configured for recording");
+ f = false;
+ }
+#endif
+ }
+ else {
+ bounceTrack = 0;
+ }
+ if (audio->isPlaying() && f)
+ f = false;
+ recordFlag = f;
+ recordAction->setChecked(recordFlag);
+ emit recordChanged(recordFlag);
+ }
+ }
+
+//---------------------------------------------------------
+// setPunchin
+// set punchin flag
+//---------------------------------------------------------
+
+void Song::setPunchin(bool f)
+ {
+ if (punchinFlag != f) {
+ punchinFlag = f;
+ punchinAction->setChecked(punchinFlag);
+ emit punchinChanged(punchinFlag);
+ }
+ }
+
+//---------------------------------------------------------
+// setPunchout
+// set punchout flag
+//---------------------------------------------------------
+
+void Song::setPunchout(bool f)
+ {
+ if (punchoutFlag != f) {
+ punchoutFlag = f;
+ punchoutAction->setChecked(punchoutFlag);
+ emit punchoutChanged(punchoutFlag);
+ }
+ }
+
+//---------------------------------------------------------
+// setClick
+//---------------------------------------------------------
+
+void Song::setClick(bool val)
+ {
+ if (_click != val) {
+ _click = val;
+ emit clickChanged(_click);
+ }
+ }
+
+//---------------------------------------------------------
+// setQuantize
+//---------------------------------------------------------
+
+void Song::setQuantize(bool val)
+ {
+ if (_quantize != val) {
+ _quantize = val;
+ emit quantizeChanged(_quantize);
+ }
+ }
+
+//---------------------------------------------------------
+// setMasterFlag
+//---------------------------------------------------------
+
+void Song::setMasterFlag(bool val)
+ {
+ _masterFlag = val;
+ if (tempomap.setMasterFlag(cpos(), val))
+ {
+ //audioDevice->setMaster(val);
+ emit songChanged(SC_MASTER);
+ }
+ // Removed. p3.3.26
+ //audioDevice->setMaster(val);
+ }
+
+//---------------------------------------------------------
+// setPlay
+// set transport play flag
+//---------------------------------------------------------
+
+void Song::setPlay(bool f)
+ {
+ if (extSyncFlag.value()) {
+ if (debugMsg)
+ printf("not allowed while using external sync");
+ return;
+ }
+ // only allow the user to set the button "on"
+ if (!f)
+ playAction->setChecked(true);
+ else
+ audio->msgPlay(true);
+ }
+
+void Song::setStop(bool f)
+ {
+ if (extSyncFlag.value()) {
+ if (debugMsg)
+ printf("not allowed while using external sync");
+ return;
+ }
+ // only allow the user to set the button "on"
+ if (!f)
+ stopAction->setChecked(true);
+ else
+ audio->msgPlay(false);
+ }
+
+void Song::setStopPlay(bool f)
+ {
+ playAction->blockSignals(true);
+ stopAction->blockSignals(true);
+
+ emit playChanged(f); // signal transport window
+
+ playAction->setChecked(f);
+ stopAction->setChecked(!f);
+
+ stopAction->blockSignals(false);
+ playAction->blockSignals(false);
+ }
+
+//---------------------------------------------------------
+// swapTracks
+//---------------------------------------------------------
+
+void Song::swapTracks(int i1, int i2)
+ {
+ undoOp(UndoOp::SwapTrack, i1, i2);
+ Track* track = _tracks[i1];
+ _tracks[i1] = _tracks[i2];
+ _tracks[i2] = track;
+ }
+
+//---------------------------------------------------------
+// setPos
+// song->setPos(Song::CPOS, pos, true, true, true);
+//---------------------------------------------------------
+
+void Song::setPos(int idx, const Pos& val, bool sig,
+ bool isSeek, bool adjustScrollbar)
+ {
+// printf("setPos %d sig=%d,seek=%d,scroll=%d ",
+// idx, sig, isSeek, adjustScrollbar);
+// val.dump(0);
+// printf("\n");
+
+ // p3.3.23
+ //printf("Song::setPos before audio->msgSeek idx:%d isSeek:%d frame:%d\n", idx, isSeek, val.frame());
+ if (pos[idx] == val)
+ return;
+ if (idx == CPOS) {
+ _vcpos = val;
+ if (isSeek && !extSyncFlag.value()) {
+ audio->msgSeek(val);
+ // p3.3.23
+ //printf("Song::setPos after audio->msgSeek idx:%d isSeek:%d frame:%d\n", idx, isSeek, val.frame());
+ return;
+ }
+ }
+ pos[idx] = val;
+ bool swap = pos[LPOS] > pos[RPOS];
+ if (swap) { // swap lpos/rpos if lpos > rpos
+ Pos tmp = pos[LPOS];
+ pos[LPOS] = pos[RPOS];
+ pos[RPOS] = tmp;
+ }
+ if (sig) {
+ if (swap) {
+ emit posChanged(LPOS, pos[LPOS].tick(), adjustScrollbar);
+ emit posChanged(RPOS, pos[RPOS].tick(), adjustScrollbar);
+ if (idx != LPOS && idx != RPOS)
+ emit posChanged(idx, pos[idx].tick(), adjustScrollbar);
+ }
+ else
+ emit posChanged(idx, pos[idx].tick(), adjustScrollbar);
+ }
+
+ if (idx == CPOS) {
+ iMarker i1 = _markerList->begin();
+ iMarker i2 = i1;
+ bool currentChanged = false;
+ for (; i1 != _markerList->end(); ++i1) {
+ ++i2;
+ if (val.tick() >= i1->first && (i2==_markerList->end() || val.tick() < i2->first)) {
+ if (i1->second.current())
+ return;
+ i1->second.setCurrent(true);
+ if (currentChanged) {
+ emit markerChanged(MARKER_CUR);
+ return;
+ }
+ ++i1;
+ for (; i1 != _markerList->end(); ++i1) {
+ if (i1->second.current())
+ i1->second.setCurrent(false);
+ }
+ emit markerChanged(MARKER_CUR);
+ return;
+ }
+ else {
+ if (i1->second.current()) {
+ currentChanged = true;
+ i1->second.setCurrent(false);
+ }
+ }
+ }
+ if (currentChanged)
+ emit markerChanged(MARKER_CUR);
+ }
+ }
+
+//---------------------------------------------------------
+// forward
+//---------------------------------------------------------
+
+void Song::forward()
+ {
+ unsigned newPos = pos[0].tick() + config.division;
+ audio->msgSeek(Pos(newPos, true));
+ }
+
+//---------------------------------------------------------
+// rewind
+//---------------------------------------------------------
+
+void Song::rewind()
+ {
+ unsigned newPos;
+ if (unsigned(config.division) > pos[0].tick())
+ newPos = 0;
+ else
+ newPos = pos[0].tick() - config.division;
+ audio->msgSeek(Pos(newPos, true));
+ }
+
+//---------------------------------------------------------
+// rewindStart
+//---------------------------------------------------------
+
+void Song::rewindStart()
+ {
+ // Added by T356
+ //audio->msgIdle(true);
+
+ audio->msgSeek(Pos(0, true));
+
+ // Added by T356
+ //audio->msgIdle(false);
+ }
+
+//---------------------------------------------------------
+// update
+//---------------------------------------------------------
+
+void Song::update(int flags)
+ {
+ static int level = 0; // DEBUG
+ if (level) {
+ printf("Song::update %08x, level %d\n", flags, level);
+ return;
+ }
+ ++level;
+ emit songChanged(flags);
+ --level;
+ }
+
+//---------------------------------------------------------
+// updatePos
+//---------------------------------------------------------
+
+void Song::updatePos()
+ {
+ emit posChanged(0, pos[0].tick(), false);
+ emit posChanged(1, pos[1].tick(), false);
+ emit posChanged(2, pos[2].tick(), false);
+ }
+
+//---------------------------------------------------------
+// setChannelMute
+// mute all midi tracks associated with channel
+//---------------------------------------------------------
+
+void Song::setChannelMute(int channel, bool val)
+ {
+ for (iTrack i = _tracks.begin(); i != _tracks.end(); ++i) {
+ MidiTrack* track = dynamic_cast<MidiTrack*>(*i);
+ if (track == 0)
+ continue;
+ if (track->outChannel() == channel)
+ track->setMute(val);
+ }
+ emit songChanged(SC_MUTE);
+ }
+
+//---------------------------------------------------------
+// len
+//---------------------------------------------------------
+
+void Song::initLen()
+ {
+ _len = AL::sigmap.bar2tick(40, 0, 0); // default song len
+ for (iTrack t = _tracks.begin(); t != _tracks.end(); ++t) {
+ MidiTrack* track = dynamic_cast<MidiTrack*>(*t);
+ if (track == 0)
+ continue;
+ PartList* parts = track->parts();
+ for (iPart p = parts->begin(); p != parts->end(); ++p) {
+ unsigned last = p->second->tick() + p->second->lenTick();
+ if (last > _len)
+ _len = last;
+ }
+ }
+ _len = roundUpBar(_len);
+ }
+
+//---------------------------------------------------------
+// tempoChanged
+//---------------------------------------------------------
+
+void Song::tempoChanged()
+{
+ emit songChanged(SC_TEMPO);
+}
+
+//---------------------------------------------------------
+// roundUpBar
+//---------------------------------------------------------
+
+int Song::roundUpBar(int t) const
+ {
+ int bar, beat;
+ unsigned tick;
+ AL::sigmap.tickValues(t, &bar, &beat, &tick);
+ if (beat || tick)
+ return AL::sigmap.bar2tick(bar+1, 0, 0);
+ return t;
+ }
+
+//---------------------------------------------------------
+// roundUpBeat
+//---------------------------------------------------------
+
+int Song::roundUpBeat(int t) const
+ {
+ int bar, beat;
+ unsigned tick;
+ AL::sigmap.tickValues(t, &bar, &beat, &tick);
+ if (tick)
+ return AL::sigmap.bar2tick(bar, beat+1, 0);
+ return t;
+ }
+
+//---------------------------------------------------------
+// roundDownBar
+//---------------------------------------------------------
+
+int Song::roundDownBar(int t) const
+ {
+ int bar, beat;
+ unsigned tick;
+ AL::sigmap.tickValues(t, &bar, &beat, &tick);
+ return AL::sigmap.bar2tick(bar, 0, 0);
+ }
+
+//---------------------------------------------------------
+// dumpMaster
+//---------------------------------------------------------
+
+void Song::dumpMaster()
+ {
+ tempomap.dump();
+ AL::sigmap.dump();
+ }
+
+//---------------------------------------------------------
+// getSelectedParts
+//---------------------------------------------------------
+
+PartList* Song::getSelectedMidiParts() const
+ {
+ PartList* parts = new PartList();
+
+ //------------------------------------------------------
+ // wenn ein Part selektiert ist, diesen editieren
+ // wenn ein Track selektiert ist, den Ersten
+ // Part des Tracks editieren, die restlichen sind
+ // 'ghostparts'
+ // wenn mehrere Parts selektiert sind, dann Ersten
+ // editieren, die restlichen sind 'ghostparts'
+ //
+ // Rough translation:
+ /*
+ If a part is selected, edit that.
+ If a track is selected, edit the first
+ part of the track, the rest are
+ 'ghost parts'
+ When multiple parts are selected, then edit the first,
+ the rest are 'ghost parts'
+ */
+
+
+ // collect marked parts
+ for (ciMidiTrack t = _midis.begin(); t != _midis.end(); ++t) {
+ MidiTrack* track = *t;
+ PartList* pl = track->parts();
+ for (iPart p = pl->begin(); p != pl->end(); ++p) {
+ if (p->second->selected()) {
+ parts->add(p->second);
+ }
+ }
+ }
+ // if no part is selected, then search for selected track
+ // and collect all parts of this track
+
+ if (parts->empty()) {
+ for (ciTrack t = _tracks.begin(); t != _tracks.end(); ++t) {
+ if ((*t)->selected()) {
+ MidiTrack* track = dynamic_cast<MidiTrack*>(*t);
+ if (track == 0)
+ continue;
+ PartList* pl = track->parts();
+ for (iPart p = pl->begin(); p != pl->end(); ++p)
+ parts->add(p->second);
+ break;
+ }
+ }
+ }
+ return parts;
+ }
+
+PartList* Song::getSelectedWaveParts() const
+ {
+ PartList* parts = new PartList();
+
+ //------------------------------------------------------
+ // wenn ein Part selektiert ist, diesen editieren
+ // wenn ein Track selektiert ist, den Ersten
+ // Part des Tracks editieren, die restlichen sind
+ // 'ghostparts'
+ // wenn mehrere Parts selektiert sind, dann Ersten
+ // editieren, die restlichen sind 'ghostparts'
+ //
+
+ // markierte Parts sammeln
+ for (ciTrack t = _tracks.begin(); t != _tracks.end(); ++t) {
+ WaveTrack* track = dynamic_cast<WaveTrack*>(*t);
+ if (track == 0)
+ continue;
+ PartList* pl = track->parts();
+ for (iPart p = pl->begin(); p != pl->end(); ++p) {
+ if (p->second->selected()) {
+ parts->add(p->second);
+ }
+ }
+ }
+ // wenn keine Parts selektiert, dann markierten Track suchen
+ // und alle Parts dieses Tracks zusammensuchen
+
+ if (parts->empty()) {
+ for (ciTrack t = _tracks.begin(); t != _tracks.end(); ++t) {
+ if ((*t)->selected()) {
+ WaveTrack* track = dynamic_cast<WaveTrack*>(*t);
+ if (track == 0)
+ continue;
+ PartList* pl = track->parts();
+ for (iPart p = pl->begin(); p != pl->end(); ++p)
+ parts->add(p->second);
+ break;
+ }
+ }
+ }
+ return parts;
+ }
+
+void Song::setMType(MType t)
+ {
+// printf("set MType %d\n", t);
+ _mtype = t;
+ song->update(SC_SONG_TYPE); // p4.0.7 Tim.
+ }
+
+//---------------------------------------------------------
+// beat
+//---------------------------------------------------------
+
+void Song::beat()
+ {
+ // Keep the sync detectors running...
+ for(int port = 0; port < MIDI_PORTS; ++port)
+ {
+ // Must keep them running even if there's no device...
+ //if(midiPorts[port].device())
+ midiPorts[port].syncInfo().setTime();
+ }
+
+
+ int tick = audio->tickPos();
+ if (audio->isPlaying())
+ setPos(0, tick, true, false, true);
+
+ // p3.3.40 Update synth native guis at the heartbeat rate.
+ for(ciSynthI is = _synthIs.begin(); is != _synthIs.end(); ++is)
+ (*is)->guiHeartBeat();
+
+ while (noteFifoSize) {
+ int pv = recNoteFifo[noteFifoRindex];
+ noteFifoRindex = (noteFifoRindex + 1) % REC_NOTE_FIFO_SIZE;
+ int pitch = (pv >> 8) & 0xff;
+ int velo = pv & 0xff;
+
+ //---------------------------------------------------
+ // filter midi remote control events
+ //---------------------------------------------------
+
+ if (rcEnable && velo != 0) {
+ if (pitch == rcStopNote)
+ setStop(true);
+ else if (pitch == rcRecordNote)
+ setRecord(true);
+ else if (pitch == rcGotoLeftMarkNote)
+ setPos(0, pos[LPOS].tick(), true, true, true);
+ else if (pitch == rcPlayNote)
+ setPlay(true);
+ }
+ emit song->midiNote(pitch, velo);
+ --noteFifoSize;
+ }
+ }
+
+//---------------------------------------------------------
+// setLen
+//---------------------------------------------------------
+
+void Song::setLen(unsigned l)
+ {
+ _len = l;
+ update();
+ }
+
+//---------------------------------------------------------
+// addMarker
+//---------------------------------------------------------
+
+Marker* Song::addMarker(const QString& s, int t, bool lck)
+ {
+ Marker* marker = _markerList->add(s, t, lck);
+ emit markerChanged(MARKER_ADD);
+ return marker;
+ }
+
+//---------------------------------------------------------
+// addMarker
+//---------------------------------------------------------
+
+Marker* Song::getMarkerAt(int t)
+ {
+ iMarker markerI;
+ for (markerI=_markerList->begin(); markerI != _markerList->end(); ++markerI) {
+// if (i1->second.current())
+ if (unsigned(t) == markerI->second.tick())//prevent of copmiler warning: comparison signed/unsigned
+ return &markerI->second;
+ }
+ //Marker* marker = _markerList->add(s, t, lck);
+ return NULL;
+ }
+
+//---------------------------------------------------------
+// removeMarker
+//---------------------------------------------------------
+
+void Song::removeMarker(Marker* marker)
+ {
+ _markerList->remove(marker);
+ emit markerChanged(MARKER_REMOVE);
+ }
+
+Marker* Song::setMarkerName(Marker* m, const QString& s)
+ {
+ m->setName(s);
+ emit markerChanged(MARKER_NAME);
+ return m;
+ }
+
+Marker* Song::setMarkerTick(Marker* m, int t)
+ {
+ Marker mm(*m);
+ _markerList->remove(m);
+ mm.setTick(t);
+ m = _markerList->add(mm);
+ emit markerChanged(MARKER_TICK);
+ return m;
+ }
+
+Marker* Song::setMarkerLock(Marker* m, bool f)
+ {
+ m->setType(f ? Pos::FRAMES : Pos::TICKS);
+ emit markerChanged(MARKER_LOCK);
+ return m;
+ }
+
+//---------------------------------------------------------
+// setRecordFlag
+//---------------------------------------------------------
+
+void Song::setRecordFlag(Track* track, bool val)
+ {
+ if (track->type() == Track::WAVE) {
+ WaveTrack* audioTrack = (WaveTrack*)track;
+ if(!audioTrack->setRecordFlag1(val))
+ return;
+ audio->msgSetRecord(audioTrack, val);
+ }
+ else {
+ track->setRecordFlag1(val);
+ track->setRecordFlag2(val);
+ }
+// updateFlags |= SC_RECFLAG;
+ update(SC_RECFLAG);
+
+ }
+
+//---------------------------------------------------------
+// rescanAlsaPorts
+//---------------------------------------------------------
+
+void Song::rescanAlsaPorts()
+ {
+ emit midiPortsChanged();
+ }
+
+//---------------------------------------------------------
+// endMsgCmd
+//---------------------------------------------------------
+
+void Song::endMsgCmd()
+ {
+ if (updateFlags) {
+ redoList->clear(); // TODO: delete elements in list
+ undoAction->setEnabled(true);
+ redoAction->setEnabled(false);
+ emit songChanged(updateFlags);
+ }
+ }
+
+//---------------------------------------------------------
+// undo
+//---------------------------------------------------------
+
+void Song::undo()
+ {
+ updateFlags = 0;
+ if (doUndo1())
+ return;
+ audio->msgUndo();
+ doUndo3();
+ redoAction->setEnabled(true);
+ undoAction->setEnabled(!undoList->empty());
+
+ if(updateFlags && (SC_TRACK_REMOVED | SC_TRACK_INSERTED))
+ audio->msgUpdateSoloStates();
+
+ emit songChanged(updateFlags);
+ }
+
+//---------------------------------------------------------
+// redo
+//---------------------------------------------------------
+
+void Song::redo()
+ {
+ updateFlags = 0;
+ if (doRedo1())
+ return;
+ audio->msgRedo();
+ doRedo3();
+ undoAction->setEnabled(true);
+ redoAction->setEnabled(!redoList->empty());
+
+ if(updateFlags && (SC_TRACK_REMOVED | SC_TRACK_INSERTED))
+ audio->msgUpdateSoloStates();
+
+ emit songChanged(updateFlags);
+ }
+
+//---------------------------------------------------------
+// processMsg
+// executed in realtime thread context
+//---------------------------------------------------------
+
+void Song::processMsg(AudioMsg* msg)
+ {
+ switch(msg->id) {
+ case SEQM_UPDATE_SOLO_STATES:
+ updateSoloStates();
+ break;
+ case SEQM_UNDO:
+ doUndo2();
+ break;
+ case SEQM_REDO:
+ doRedo2();
+ break;
+ case SEQM_MOVE_TRACK:
+ if (msg->a > msg->b) {
+ for (int i = msg->a; i > msg->b; --i) {
+ swapTracks(i, i-1);
+ }
+ }
+ else {
+ for (int i = msg->a; i < msg->b; ++i) {
+ swapTracks(i, i+1);
+ }
+ }
+ updateFlags = SC_TRACK_MODIFIED;
+ break;
+ case SEQM_ADD_EVENT:
+ updateFlags = SC_EVENT_INSERTED;
+ if (addEvent(msg->ev1, (MidiPart*)msg->p2)) {
+ Event ev;
+ //undoOp(UndoOp::AddEvent, ev, msg->ev1, (Part*)msg->p2);
+ undoOp(UndoOp::AddEvent, ev, msg->ev1, (Part*)msg->p2, msg->a, msg->b);
+ }
+ else
+ updateFlags = 0;
+ if(msg->a)
+ addPortCtrlEvents(msg->ev1, (Part*)msg->p2, msg->b);
+ break;
+ case SEQM_REMOVE_EVENT:
+ {
+ Event event = msg->ev1;
+ MidiPart* part = (MidiPart*)msg->p2;
+ if(msg->a)
+ removePortCtrlEvents(event, part, msg->b);
+ Event e;
+ //undoOp(UndoOp::DeleteEvent, e, event, (Part*)part);
+ undoOp(UndoOp::DeleteEvent, e, event, (Part*)part, msg->a, msg->b);
+ deleteEvent(event, part);
+ updateFlags = SC_EVENT_REMOVED;
+ }
+ break;
+ case SEQM_CHANGE_EVENT:
+ if(msg->a)
+ removePortCtrlEvents(msg->ev1, (MidiPart*)msg->p3, msg->b);
+ changeEvent(msg->ev1, msg->ev2, (MidiPart*)msg->p3);
+ if(msg->a)
+ addPortCtrlEvents(msg->ev2, (Part*)msg->p3, msg->b);
+ //undoOp(UndoOp::ModifyEvent, msg->ev2, msg->ev1, (Part*)msg->p3);
+ undoOp(UndoOp::ModifyEvent, msg->ev2, msg->ev1, (Part*)msg->p3, msg->a, msg->b);
+ updateFlags = SC_EVENT_MODIFIED;
+ break;
+
+ case SEQM_ADD_TEMPO:
+ //printf("processMsg (SEQM_ADD_TEMPO) UndoOp::AddTempo. adding tempo at: %d with tempo=%d\n", msg->a, msg->b);
+ undoOp(UndoOp::AddTempo, msg->a, msg->b);
+ tempomap.addTempo(msg->a, msg->b);
+ updateFlags = SC_TEMPO;
+ break;
+
+ case SEQM_SET_TEMPO:
+ //printf("processMsg (SEQM_SET_TEMPO) UndoOp::AddTempo. adding tempo at: %d with tempo=%d\n", msg->a, msg->b);
+ undoOp(UndoOp::AddTempo, msg->a, msg->b);
+ tempomap.setTempo(msg->a, msg->b);
+ updateFlags = SC_TEMPO;
+ break;
+
+ case SEQM_SET_GLOBAL_TEMPO:
+ tempomap.setGlobalTempo(msg->a);
+ break;
+
+ case SEQM_REMOVE_TEMPO:
+ //printf("processMsg (SEQM_REMOVE_TEMPO) UndoOp::DeleteTempo. adding tempo at: %d with tempo=%d\n", msg->a, msg->b);
+ undoOp(UndoOp::DeleteTempo, msg->a, msg->b);
+ tempomap.delTempo(msg->a);
+ updateFlags = SC_TEMPO;
+ break;
+
+ case SEQM_ADD_SIG:
+ undoOp(UndoOp::AddSig, msg->a, msg->b, msg->c);
+ AL::sigmap.add(msg->a, AL::TimeSignature(msg->b, msg->c));
+ updateFlags = SC_SIG;
+ break;
+
+ case SEQM_REMOVE_SIG:
+ undoOp(UndoOp::DeleteSig, msg->a, msg->b, msg->c);
+ AL::sigmap.del(msg->a);
+ updateFlags = SC_SIG;
+ break;
+
+ default:
+ printf("unknown seq message %d\n", msg->id);
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// cmdAddPart
+//---------------------------------------------------------
+
+void Song::cmdAddPart(Part* part)
+ {
+ addPart(part);
+ undoOp(UndoOp::AddPart, part);
+ updateFlags = SC_PART_INSERTED;
+ }
+
+//---------------------------------------------------------
+// cmdRemovePart
+//---------------------------------------------------------
+
+void Song::cmdRemovePart(Part* part)
+ {
+ removePart(part);
+ undoOp(UndoOp::DeletePart, part);
+ part->events()->incARef(-1);
+ //part->unchainClone();
+ unchainClone(part);
+ updateFlags = SC_PART_REMOVED;
+ }
+
+//---------------------------------------------------------
+// cmdChangePart
+//---------------------------------------------------------
+
+//void Song::cmdChangePart(Part* oldPart, Part* newPart)
+void Song::cmdChangePart(Part* oldPart, Part* newPart, bool doCtrls, bool doClones)
+ {
+ //printf("Song::cmdChangePart before changePart oldPart:%p events:%p refs:%d Arefs:%d sn:%d newPart:%p events:%p refs:%d Arefs:%d sn:%d\n", oldPart, oldPart->events(), oldPart->events()->refCount(), oldPart->events()->arefCount(), oldPart->sn(), newPart, newPart->events(), newPart->events()->refCount(), newPart->events()->arefCount(), newPart->sn());
+
+ if(doCtrls)
+ removePortCtrlEvents(oldPart, doClones);
+
+ changePart(oldPart, newPart);
+
+ //undoOp(UndoOp::ModifyPart, oldPart, newPart);
+ undoOp(UndoOp::ModifyPart, oldPart, newPart, doCtrls, doClones);
+
+ // Changed by T356. Do not decrement ref count if the new part is a clone of the old part, since the event list
+ // will still be active.
+ if(oldPart->cevents() != newPart->cevents())
+ oldPart->events()->incARef(-1);
+
+ //oldPart->replaceClone(newPart);
+
+ //printf("Song::cmdChangePart before repl/unchClone oldPart:%p events:%p refs:%d Arefs:%d sn:%d newPart:%p events:%p refs:%d Arefs:%d sn:%d\n", oldPart, oldPart->events(), oldPart->events()->refCount(), oldPart->events()->arefCount(), oldPart->sn(), newPart, newPart->events(), newPart->events()->refCount(), newPart->events()->arefCount(), newPart->sn());
+
+ replaceClone(oldPart, newPart);
+
+ if(doCtrls)
+ addPortCtrlEvents(newPart, doClones);
+
+ //printf("Song::cmdChangePart after repl/unchClone oldPart:%p events:%p refs:%d Arefs:%d sn:%d newPart:%p events:%p refs:%d Arefs:%d sn:%d\n", oldPart, oldPart->events(), oldPart->events()->refCount(), oldPart->events()->arefCount(), oldPart->sn(), newPart, newPart->events(), newPart->events()->refCount(), newPart->events()->arefCount(), newPart->sn());
+
+ updateFlags = SC_PART_MODIFIED;
+ }
+
+//---------------------------------------------------------
+// panic
+//---------------------------------------------------------
+
+void Song::panic()
+ {
+ audio->msgPanic();
+ }
+
+//---------------------------------------------------------
+// clear
+// signal - emit signals for changes if true
+// called from constructor as clear(false) and
+// from MusE::clearSong() as clear(false)
+//---------------------------------------------------------
+
+void Song::clear(bool signal)
+ {
+ if(debugMsg)
+ printf("Song::clear\n");
+
+ bounceTrack = 0;
+
+ _tracks.clear();
+ _midis.clearDelete();
+ _waves.clearDelete();
+ _inputs.clearDelete(); // audio input ports
+ _outputs.clearDelete(); // audio output ports
+ _groups.clearDelete(); // mixer groups
+ _auxs.clearDelete(); // aux sends
+
+ // p3.3.45 Clear all midi port devices.
+ for(int i = 0; i < MIDI_PORTS; ++i)
+ {
+ // p3.3.50 Since midi ports are not deleted, clear all midi port in/out routes. They point to non-existant tracks now.
+ midiPorts[i].inRoutes()->clear();
+ midiPorts[i].outRoutes()->clear();
+
+ // p3.3.50 Reset this.
+ midiPorts[i].setFoundInSongFile(false);
+
+ // This will also close the device.
+ midiPorts[i].setMidiDevice(0);
+ }
+
+ _synthIs.clearDelete();
+
+ // p3.3.45 Make sure to delete Jack midi devices, and remove all ALSA midi device routes...
+ // Otherwise really nasty things happen when loading another song when one is already loaded.
+ // The loop is a safe way to delete while iterating.
+ bool loop;
+ do
+ {
+ loop = false;
+ for(iMidiDevice imd = midiDevices.begin(); imd != midiDevices.end(); ++imd)
+ {
+ //if((*imd)->deviceType() == MidiDevice::JACK_MIDI)
+ if(dynamic_cast< MidiJackDevice* >(*imd))
+ {
+ // Remove the device from the list.
+ midiDevices.erase(imd);
+ // Since Jack midi devices are created dynamically, we must delete them.
+ // The destructor unregisters the device from Jack, which also disconnects all device-to-jack routes.
+ // This will also delete all midi-track-to-device routes, they point to non-existant midi tracks
+ // which were all deleted above
+ delete (*imd);
+ loop = true;
+ break;
+ }
+ else
+ //if((*imd)->deviceType() == MidiDevice::ALSA_MIDI)
+ if(dynamic_cast< MidiAlsaDevice* >(*imd))
+ {
+ // With alsa devices, we must not delete them (they're always in the list). But we must
+ // clear all routes. They point to non-existant midi tracks, which were all deleted above.
+ (*imd)->inRoutes()->clear();
+ (*imd)->outRoutes()->clear();
+ }
+ }
+ }
+ while (loop);
+
+ tempomap.clear();
+ AL::sigmap.clear();
+ undoList->clearDelete();
+ redoList->clear();
+ _markerList->clear();
+ pos[0].setTick(0);
+ pos[1].setTick(0);
+ pos[2].setTick(0);
+ _vcpos.setTick(0);
+
+ Track::clearSoloRefCounts();
+ clearMidiTransforms();
+ clearMidiInputTransforms();
+
+ // Clear all midi port controller values.
+ for(int i = 0; i < MIDI_PORTS; ++i)
+ // Don't remove the controllers, just the values.
+ midiPorts[i].controller()->clearDelete(false);
+
+ _masterFlag = true;
+ loopFlag = false;
+ loopFlag = false;
+ punchinFlag = false;
+ punchoutFlag = false;
+ recordFlag = false;
+ soloFlag = false;
+ // seq
+ _mtype = MT_UNKNOWN;
+ _recMode = REC_OVERDUP;
+ _cycleMode = CYCLE_NORMAL;
+ _click = false;
+ _quantize = false;
+ _len = 0; // song len in ticks
+ _follow = JUMP;
+ // _tempo = 500000; // default tempo 120
+ dirty = false;
+ initDrumMap();
+ if (signal) {
+ emit loopChanged(false);
+ recordChanged(false);
+ }
+ }
+
+//---------------------------------------------------------
+// cleanupForQuit
+// called from Muse::closeEvent
+//---------------------------------------------------------
+
+void Song::cleanupForQuit()
+{
+ bounceTrack = 0;
+
+ if(debugMsg)
+ printf("MusE: Song::cleanupForQuit...\n");
+
+ _tracks.clear();
+
+ if(debugMsg)
+ printf("deleting _midis\n");
+ _midis.clearDelete();
+
+ if(debugMsg)
+ printf("deleting _waves\n");
+ _waves.clearDelete();
+
+ if(debugMsg)
+ printf("deleting _inputs\n");
+ _inputs.clearDelete(); // audio input ports
+
+ if(debugMsg)
+ printf("deleting _outputs\n");
+ _outputs.clearDelete(); // audio output ports
+
+ if(debugMsg)
+ printf("deleting _groups\n");
+ _groups.clearDelete(); // mixer groups
+
+ if(debugMsg)
+ printf("deleting _auxs\n");
+ _auxs.clearDelete(); // aux sends
+
+ if(debugMsg)
+ printf("deleting _synthIs\n");
+ _synthIs.clearDelete(); // each ~SynthI() -> deactivate3() -> ~SynthIF()
+
+ tempomap.clear();
+ AL::sigmap.clear();
+
+ if(debugMsg)
+ printf("deleting undoList, clearing redoList\n");
+ undoList->clearDelete();
+ redoList->clear(); // Check this - Should we do a clearDelete? IIRC it was OK this way - no clearDelete in case of same items in both lists.
+
+ _markerList->clear();
+
+ _tviews.clear();
+
+ if(debugMsg)
+ printf("deleting transforms\n");
+ clearMidiTransforms(); // Deletes stuff.
+ clearMidiInputTransforms(); // Deletes stuff.
+
+ if(debugMsg)
+ printf("deleting midiport controllers\n");
+ // Clear all midi port controllers and values.
+ for(int i = 0; i < MIDI_PORTS; ++i)
+ // Remove the controllers and the values.
+ midiPorts[i].controller()->clearDelete(true);
+
+ // Can't do this here. Jack isn't running. Fixed. Test OK so far.
+ #if 1
+ if(debugMsg)
+ printf("deleting midi devices except synths\n");
+ for(iMidiDevice imd = midiDevices.begin(); imd != midiDevices.end(); ++imd)
+ {
+ // Since Syntis are midi devices, there's no need to delete them below.
+ if((*imd)->isSynti())
+ continue;
+ delete (*imd);
+ }
+ midiDevices.clear(); // midi devices
+ #endif
+
+ if(debugMsg)
+ printf("deleting global available synths\n");
+ // Delete all synths.
+ std::vector<Synth*>::iterator is;
+ for(is = synthis.begin(); is != synthis.end(); ++is)
+ {
+ Synth* s = *is;
+
+ if(s)
+ delete s;
+ }
+ synthis.clear();
+
+ if(debugMsg)
+ printf("deleting midi instruments\n");
+ for(iMidiInstrument imi = midiInstruments.begin(); imi != midiInstruments.end(); ++imi)
+ {
+ // Since Syntis are midi instruments, there's no need to delete them below.
+ // Tricky, must cast as SynthI*.
+ SynthI* s = dynamic_cast <SynthI*> (*imi);
+ if(s)
+ continue;
+ delete (*imi);
+ }
+ midiInstruments.clear(); // midi devices
+
+ // Nothing required for ladspa plugin list, and rack instances of them
+ // are handled by ~AudioTrack.
+
+ if(debugMsg)
+ printf("...finished cleaning up.\n");
+}
+
+//---------------------------------------------------------
+// seqSignal
+// sequencer message to GUI
+// execution environment: gui thread
+//---------------------------------------------------------
+
+void Song::seqSignal(int fd)
+ {
+ char buffer[16];
+
+ int n = ::read(fd, buffer, 16);
+ if (n < 0) {
+ printf("Song: seqSignal(): READ PIPE failed: %s\n",
+ strerror(errno));
+ return;
+ }
+ for (int i = 0; i < n; ++i) {
+// printf("seqSignal to gui:<%c>\n", buffer[i]);
+ switch(buffer[i]) {
+ case '0': // STOP
+ stopRolling();
+ break;
+ case '1': // PLAY
+ setStopPlay(true);
+ break;
+ case '2': // record
+ setRecord(true);
+ break;
+ case '3': // START_PLAY + jack STOP
+ abortRolling();
+ break;
+ case 'P': // alsa ports changed
+ rescanAlsaPorts();
+ break;
+ case 'G':
+ clearRecAutomation(true);
+ setPos(0, audio->tickPos(), true, false, true);
+ break;
+ case 'S': // shutdown audio
+ muse->seqStop();
+
+ {
+ // give the user a sensible explanation
+ int btn = QMessageBox::critical( muse, tr("Jack shutdown!"),
+ tr("Jack has detected a performance problem which has lead to\n"
+ "MusE being disconnected.\n"
+ "This could happen due to a number of reasons:\n"
+ "- a performance issue with your particular setup.\n"
+ "- a bug in MusE (or possibly in another connected software).\n"
+ "- a random hiccup which might never occur again.\n"
+ "- jack was voluntary stopped by you or someone else\n"
+ "- jack crashed\n"
+ "If there is a persisting problem you are much welcome to discuss it\n"
+ "on the MusE mailinglist.\n"
+ "(there is information about joining the mailinglist on the MusE\n"
+ " homepage which is available through the help menu)\n"
+ "\n"
+ "To proceed check the status of Jack and try to restart it and then .\n"
+ "click on the Restart button."), "restart", "cancel");
+ if (btn == 0) {
+ printf("restarting!\n");
+ muse->seqRestart();
+ }
+ }
+
+ break;
+ case 'f': // start freewheel
+ if(debugMsg)
+ printf("Song: seqSignal: case f: setFreewheel start\n");
+
+ // Enabled by Tim. p3.3.6
+ if(config.freewheelMode)
+ audioDevice->setFreewheel(true);
+
+ break;
+
+ case 'F': // stop freewheel
+ if(debugMsg)
+ printf("Song: seqSignal: case F: setFreewheel stop\n");
+
+ // Enabled by Tim. p3.3.6
+ if(config.freewheelMode)
+ audioDevice->setFreewheel(false);
+
+ audio->msgPlay(false);
+#if 0
+ if (record())
+ audio->recordStop();
+ setStopPlay(false);
+#endif
+ break;
+
+ case 'C': // Graph changed
+ if (audioDevice)
+ audioDevice->graphChanged();
+ break;
+
+ // p3.3.37
+ case 'R': // Registration changed
+ if (audioDevice)
+ audioDevice->registrationChanged();
+ break;
+
+ default:
+ printf("unknown Seq Signal <%c>\n", buffer[i]);
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// recordEvent
+//---------------------------------------------------------
+
+void Song::recordEvent(MidiTrack* mt, Event& event)
+ {
+ //---------------------------------------------------
+ // if tick points into a part,
+ // record to that part
+ // else
+ // create new part
+ //---------------------------------------------------
+
+ unsigned tick = event.tick();
+ PartList* pl = mt->parts();
+ MidiPart* part = 0;
+ iPart ip;
+ for (ip = pl->begin(); ip != pl->end(); ++ip) {
+ part = (MidiPart*)(ip->second);
+ unsigned partStart = part->tick();
+ unsigned partEnd = partStart + part->lenTick();
+ if (tick >= partStart && tick < partEnd)
+ break;
+ }
+ updateFlags |= SC_EVENT_INSERTED;
+ if (ip == pl->end()) {
+ // create new part
+ part = new MidiPart(mt);
+ int startTick = roundDownBar(tick);
+ //int endTick = roundUpBar(tick);
+ int endTick = roundUpBar(tick + 1);
+ part->setTick(startTick);
+ part->setLenTick(endTick - startTick);
+ part->setName(mt->name());
+ event.move(-startTick);
+ part->events()->add(event);
+ audio->msgAddPart(part);
+ return;
+ }
+ part = (MidiPart*)(ip->second);
+ tick -= part->tick();
+ event.setTick(tick);
+
+ Event ev;
+ if(event.type() == Controller)
+ {
+ EventRange range = part->events()->equal_range(tick);
+ for(iEvent i = range.first; i != range.second; ++i)
+ {
+ ev = i->second;
+ // At the moment, Song::recordEvent() is only called by the 'Rec' buttons in the
+ // midi track info panel. So only controller types are fed to it. If other event types
+ // are to be passed, we will have to expand on this to check if equal. Instead, maybe add an isEqual() to Event class.
+ //if((ev.type() == Controller && event.type() == Controller || ev.type() == Controller && event.type() == Controller)
+ // && ev.dataA() == event.dataA() && ev.dataB() == event.dataB())
+ if(ev.type() == Controller && ev.dataA() == event.dataA())
+ {
+ // Don't bother if already set.
+ if(ev.dataB() == event.dataB())
+ return;
+ // Indicate do undo, and do port controller values and clone parts.
+ audio->msgChangeEvent(ev, event, part, true, true, true);
+ return;
+ }
+ }
+ }
+
+ // Indicate do undo, and do port controller values and clone parts.
+ //audio->msgAddEvent(event, part);
+ audio->msgAddEvent(event, part, true, true, true);
+ }
+
+//---------------------------------------------------------
+// execAutomationCtlPopup
+//---------------------------------------------------------
+
+int Song::execAutomationCtlPopup(AudioTrack* track, const QPoint& menupos, int acid)
+{
+ //enum { HEADER, SEP1, PREV_EVENT, NEXT_EVENT, SEP2, ADD_EVENT, CLEAR_EVENT, CLEAR_RANGE, CLEAR_ALL_EVENTS };
+ enum { HEADER, PREV_EVENT, NEXT_EVENT, SEP2, ADD_EVENT, CLEAR_EVENT, CLEAR_RANGE, CLEAR_ALL_EVENTS };
+ QMenu* menu = new QMenu;
+
+ int count = 0;
+ bool isEvent = false, canSeekPrev = false, canSeekNext = false, canEraseRange = false;
+ bool canAdd = false;
+ double ctlval = 0.0;
+ if(track)
+ {
+ ciCtrlList icl = track->controller()->find(acid);
+ if(icl != track->controller()->end())
+ {
+ CtrlList *cl = icl->second;
+ canAdd = true;
+ ctlval = cl->curVal();
+ count = cl->size();
+ if(count)
+ {
+ int frame = pos[0].frame();
+
+ iCtrl s = cl->lower_bound(frame);
+ iCtrl e = cl->upper_bound(frame);
+
+ isEvent = (s != cl->end() && s->second.frame == frame);
+
+ canSeekPrev = s != cl->begin();
+ canSeekNext = e != cl->end();
+
+ s = cl->lower_bound(pos[1].frame());
+
+ canEraseRange = s != cl->end()
+ && (int)pos[2].frame() > s->second.frame;
+ }
+ }
+ }
+
+ //menu->insertItem(tr("Automation:"), HEADER, HEADER);
+ //menu->setItemEnabled(HEADER, false);
+ //MenuTitleItem* title = new MenuTitleItem(tr("Automation:")); ddskrjo
+ //menu->insertItem(title, HEADER, HEADER); ddskrjo
+ menu->addAction(new MenuTitleItem(tr("Automation:"), menu));
+
+ //menu->insertSeparator(SEP1);
+
+ QAction* prevEvent = menu->addAction(tr("previous event"));
+ prevEvent->setData(PREV_EVENT);
+ prevEvent->setEnabled(canSeekPrev);
+
+ QAction* nextEvent = menu->addAction(tr("next event"));
+ nextEvent->setData(NEXT_EVENT);
+ nextEvent->setEnabled(canSeekNext);
+
+ //menu->insertSeparator(SEP2);
+ menu->addSeparator();
+
+ QAction* addEvent = new QAction(menu);
+ menu->addAction(addEvent);
+ if(isEvent)
+ addEvent->setText(tr("set event"));
+ else
+ addEvent->setText(tr("add event"));
+ addEvent->setData(ADD_EVENT);
+ addEvent->setEnabled(canAdd);
+
+ QAction* eraseEventAction = menu->addAction(tr("erase event"));
+ eraseEventAction->setData(CLEAR_EVENT);
+ eraseEventAction->setEnabled(isEvent);
+
+ QAction* eraseRangeAction = menu->addAction(tr("erase range"));
+ eraseRangeAction->setData(CLEAR_RANGE);
+ eraseRangeAction->setEnabled(canEraseRange);
+
+ QAction* clearAction = menu->addAction(tr("clear automation"));
+ clearAction->setData(CLEAR_ALL_EVENTS);
+ clearAction->setEnabled((bool)count);
+
+ QAction* act = menu->exec(menupos);
+ //delete menu;
+ if (!act || !track)
+ {
+ delete menu;
+ return -1;
+ }
+
+ //if(!track)
+ // return -1;
+
+ int sel = act->data().toInt();
+ delete menu;
+
+ switch(sel)
+ {
+ case ADD_EVENT:
+ audio->msgAddACEvent(track, acid, pos[0].frame(), ctlval);
+ break;
+ case CLEAR_EVENT:
+ audio->msgEraseACEvent(track, acid, pos[0].frame());
+ break;
+
+ case CLEAR_RANGE:
+ audio->msgEraseRangeACEvents(track, acid, pos[1].frame(), pos[2].frame());
+ break;
+
+ case CLEAR_ALL_EVENTS:
+ if(QMessageBox::question(muse, QString("Muse"),
+ tr("Clear all controller events?"), tr("&Ok"), tr("&Cancel"),
+ QString::null, 0, 1 ) == 0)
+ audio->msgClearControllerEvents(track, acid);
+ break;
+
+ case PREV_EVENT:
+ audio->msgSeekPrevACEvent(track, acid);
+ break;
+
+ case NEXT_EVENT:
+ audio->msgSeekNextACEvent(track, acid);
+ break;
+
+ default:
+ return -1;
+ break;
+ }
+
+ return sel;
+}
+
+//---------------------------------------------------------
+// execMidiAutomationCtlPopup
+//---------------------------------------------------------
+
+int Song::execMidiAutomationCtlPopup(MidiTrack* track, MidiPart* part, const QPoint& menupos, int ctlnum)
+{
+ if(!track && !part)
+ return -1;
+
+ //enum { HEADER, SEP1, PREV_EVENT, NEXT_EVENT, SEP2, ADD_EVENT, CLEAR_EVENT, CLEAR_RANGE, CLEAR_ALL_EVENTS };
+ enum { HEADER, ADD_EVENT, CLEAR_EVENT };
+ QMenu* menu = new QMenu;
+
+ //int count = 0;
+ bool isEvent = false;
+ //bool canSeekPrev = false, canSeekNext = false, canEraseRange = false;
+ //bool canAdd = false;
+ //double ctlval = 0.0;
+
+ MidiTrack* mt;
+ if(track)
+ mt = track;
+ else
+ mt = (MidiTrack*)part->track();
+ int portno = mt->outPort();
+ int channel = mt->outChannel();
+ MidiPort* mp = &midiPorts[portno];
+
+ int dctl = ctlnum;
+ // Is it a drum controller, according to the track port's instrument?
+ MidiController *mc = mp->drumController(ctlnum);
+ if(mc)
+ {
+ // Change the controller event's index into the drum map to an instrument note.
+ int note = ctlnum & 0x7f;
+ dctl &= ~0xff;
+ channel = drumMap[note].channel;
+ mp = &midiPorts[drumMap[note].port];
+ dctl |= drumMap[note].anote;
+ }
+
+ //printf("Song::execMidiAutomationCtlPopup ctlnum:%d dctl:%d anote:%d\n", ctlnum, dctl, drumMap[ctlnum & 0x7f].anote);
+
+ unsigned tick = cpos();
+
+ if(!part)
+ {
+ PartList* pl = mt->parts();
+ iPart ip;
+ for(ip = pl->begin(); ip != pl->end(); ++ip)
+ {
+ MidiPart* tpart = (MidiPart*)(ip->second);
+ unsigned partStart = tpart->tick();
+ unsigned partEnd = partStart + tpart->lenTick();
+ if(tick >= partStart && tick < partEnd)
+ {
+ // Prefer a selected part, otherwise keep looking...
+ if(tpart->selected())
+ {
+ part = tpart;
+ break;
+ }
+ else
+ // Remember the first part found...
+ if(!part)
+ part = tpart;
+ }
+ }
+ }
+
+ Event ev;
+ if(part)
+ {
+ unsigned partStart = part->tick();
+ unsigned partEnd = partStart + part->lenTick();
+ if(tick >= partStart && tick < partEnd)
+ {
+ EventRange range = part->events()->equal_range(tick - partStart);
+ for(iEvent i = range.first; i != range.second; ++i)
+ {
+ ev = i->second;
+ if(ev.type() == Controller)
+ {
+ //printf("Song::execMidiAutomationCtlPopup ev.dataA:%d\n", ev.dataA());
+
+ //if(ev.dataA() == dctl)
+ if(ev.dataA() == ctlnum)
+ {
+ isEvent = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+
+ //menu->insertItem(tr("Automation:"), HEADER, HEADER);
+ //menu->setItemEnabled(HEADER, false);
+ //MenuTitleItem* title = new MenuTitleItem(tr("Automation:")); ddskrjo
+ ///menu->insertItem(title, HEADER, HEADER); ddskrjo
+
+ //menu->insertSeparator(SEP1);
+
+// menu->insertItem(tr("previous event"), PREV_EVENT, PREV_EVENT);
+// menu->setItemEnabled(PREV_EVENT, canSeekPrev);
+
+// menu->insertItem(tr("next event"), NEXT_EVENT, NEXT_EVENT);
+// menu->setItemEnabled(NEXT_EVENT, canSeekNext);
+
+// menu->insertSeparator(SEP2);
+
+ QAction* addEvent = new QAction(menu);
+ menu->addAction(addEvent);
+ if(isEvent)
+ addEvent->setText(tr("set event"));
+ else
+ addEvent->setText(tr("add event"));
+ addEvent->setData(ADD_EVENT);
+ //addEvent->setEnabled(canAdd);
+ addEvent->setEnabled(true);
+
+ QAction* eraseEventAction = menu->addAction(tr("erase event"));
+ eraseEventAction->setData(CLEAR_EVENT);
+ eraseEventAction->setEnabled(isEvent);
+
+// menu->insertItem(tr("erase range"), CLEAR_RANGE, CLEAR_RANGE);
+// menu->setItemEnabled(CLEAR_RANGE, canEraseRange);
+
+// menu->insertItem(tr("clear automation"), CLEAR_ALL_EVENTS, CLEAR_ALL_EVENTS);
+// menu->setItemEnabled(CLEAR_ALL_EVENTS, (bool)count);
+
+
+ QAction* act = menu->exec(menupos);
+ //delete menu;
+ if (!act)
+ {
+ delete menu;
+ return -1;
+ }
+
+ //if(!part)
+ // return -1;
+
+ int sel = act->data().toInt();
+ delete menu;
+
+ switch(sel)
+ {
+ case ADD_EVENT:
+ {
+ //int val = mp->hwCtrlState(channel, ctlnum);
+ int val = mp->hwCtrlState(channel, dctl);
+ if(val == CTRL_VAL_UNKNOWN)
+ return -1;
+ Event e(Controller);
+ //e.setA(dctl);
+ e.setA(ctlnum);
+ e.setB(val);
+ // Do we replace an old event?
+ if(isEvent)
+ {
+ // Don't bother if already set.
+ if(ev.dataB() == val)
+ return -1;
+
+ e.setTick(tick - part->tick());
+ // Indicate do undo, and do port controller values and clone parts.
+ audio->msgChangeEvent(ev, e, part, true, true, true);
+ }
+ else
+ {
+ // Store a new event...
+ if(part)
+ {
+ e.setTick(tick - part->tick());
+ // Indicate do undo, and do port controller values and clone parts.
+ audio->msgAddEvent(e, part, true, true, true);
+ }
+ else
+ {
+ // Create a new part...
+ part = new MidiPart(mt);
+ int startTick = roundDownBar(tick);
+ int endTick = roundUpBar(tick + 1);
+ part->setTick(startTick);
+ part->setLenTick(endTick - startTick);
+ part->setName(mt->name());
+ e.setTick(tick - startTick);
+ part->events()->add(e);
+ // Allow undo.
+ audio->msgAddPart(part);
+ }
+ }
+ }
+ break;
+ case CLEAR_EVENT:
+ // Indicate do undo, and do port controller values and clone parts.
+ audio->msgDeleteEvent(ev, part, true, true, true);
+ break;
+
+ //case CLEAR_RANGE:
+ //audio->msgEraseRangeACEvents(track, acid, pos[1].frame(), pos[2].frame());
+ //break;
+
+ //case CLEAR_ALL_EVENTS:
+ //if(QMessageBox::question(muse, QString("Muse"),
+ // tr("Clear all controller events?"), tr("&Ok"), tr("&Cancel"),
+ // QString::null, 0, 1 ) == 0)
+ //audio->msgClearControllerEvents(track, acid);
+ //break;
+
+ //case PREV_EVENT:
+ //audio->msgSeekPrevACEvent(track, acid);
+ //break;
+
+ //case NEXT_EVENT:
+ //audio->msgSeekNextACEvent(track, acid);
+ //break;
+
+ default:
+ return -1;
+ break;
+ }
+
+ return sel;
+}
+
+//---------------------------------------------------------
+// updateSoloStates
+// This will properly set all soloing variables (including other tracks) based entirely
+// on the current values of all the tracks' _solo members.
+//---------------------------------------------------------
+
+void Song::updateSoloStates()
+{
+ Track::clearSoloRefCounts();
+ for(ciTrack i = _tracks.begin(); i != _tracks.end(); ++i)
+ (*i)->setInternalSolo(0);
+ for(ciTrack i = _tracks.begin(); i != _tracks.end(); ++i)
+ (*i)->updateSoloStates(true);
+}
+
+//---------------------------------------------------------
+// clearRecAutomation
+//---------------------------------------------------------
+
+void Song::clearRecAutomation(bool clearList)
+{
+ // Clear all pan/vol pressed and touched flags, and all rec event lists, if needed.
+ for (iTrack it = tracks()->begin(); it != tracks()->end(); ++it)
+ ((Track*)(*it))->clearRecAutomation(clearList);
+}
+
+//---------------------------------------------------------
+// processAutomationEvents
+//---------------------------------------------------------
+
+void Song::processAutomationEvents()
+{
+ // Just clear all pressed and touched flags, not rec event lists.
+ clearRecAutomation(false);
+ if (!automation)
+ return;
+ for(iTrack i = _tracks.begin(); i != _tracks.end(); ++i)
+ {
+ if(!(*i)->isMidiTrack())
+ // Process (and clear) rec events.
+ ((AudioTrack*)(*i))->processAutomationEvents();
+ }
+}
+
+//---------------------------------------------------------
+// abortRolling
+//---------------------------------------------------------
+
+void Song::abortRolling()
+{
+ if (record())
+ audio->recordStop();
+ setStopPlay(false);
+}
+
+//---------------------------------------------------------
+// stopRolling
+//---------------------------------------------------------
+
+void Song::stopRolling()
+ {
+ abortRolling();
+ processAutomationEvents();
+ }
+
+//---------------------------------------------------------
+// connectJackRoutes
+//---------------------------------------------------------
+
+void Song::connectJackRoutes(AudioTrack* track, bool disconnect)
+{
+ switch(track->type())
+ {
+ case Track::AUDIO_OUTPUT:
+ {
+ AudioOutput* ao = (AudioOutput*)track;
+ // This will re-register the track's jack ports.
+ if(!disconnect)
+ ao->setName(ao->name());
+ // Now reconnect the output routes.
+ if(checkAudioDevice() && audio->isRunning())
+ {
+ for(int ch = 0; ch < ao->channels(); ++ch)
+ {
+ RouteList* ir = ao->outRoutes();
+ for (iRoute ii = ir->begin(); ii != ir->end(); ++ii)
+ {
+ Route r = *ii;
+ if ((r.type == Route::JACK_ROUTE) && (r.channel == ch))
+ {
+ if(disconnect)
+ audioDevice->disconnect(ao->jackPort(ch), r.jackPort);
+ else
+ audioDevice->connect(ao->jackPort(ch), r.jackPort);
+ break;
+ }
+ }
+ if(disconnect)
+ {
+ audioDevice->unregisterPort(ao->jackPort(ch));
+ ao->setJackPort(ch, 0);
+ }
+ }
+ }
+ }
+ break;
+ case Track::AUDIO_INPUT:
+ {
+ AudioInput* ai = (AudioInput*)track;
+ // This will re-register the track's jack ports.
+ if(!disconnect)
+ ai->setName(ai->name());
+ // Now reconnect the input routes.
+ if(checkAudioDevice() && audio->isRunning())
+ {
+ for(int ch = 0; ch < ai->channels(); ++ch)
+ {
+ RouteList* ir = ai->inRoutes();
+ for (iRoute ii = ir->begin(); ii != ir->end(); ++ii)
+ {
+ Route r = *ii;
+ if ((r.type == Route::JACK_ROUTE) && (r.channel == ch))
+ {
+ if(disconnect)
+ audioDevice->disconnect(r.jackPort, ai->jackPort(ch));
+ else
+ audioDevice->connect(r.jackPort, ai->jackPort(ch));
+ break;
+ }
+ }
+ if(disconnect)
+ {
+ audioDevice->unregisterPort(ai->jackPort(ch));
+ ai->setJackPort(ch, 0);
+ }
+ }
+ }
+ }
+ break;
+ default:
+ break;
+ }
+}
+
+/*
+//---------------------------------------------------------
+// chooseMidiRoutes
+//---------------------------------------------------------
+
+void Song::chooseMidiRoutes(QButton* parent, MidiTrack* track, bool dst)
+{
+ if(!track)
+ return;
+
+ //if(!track->isMidiTrack())
+ // return;
+
+ QPoint ppt = QCursor::pos();
+ //QPoint ppt = parent->rect().bottomLeft();
+
+ //if(dst)
+ //{
+ // TODO
+
+ //}
+ //else
+ //{
+ RouteList* rl = dst ? track->outRoutes() : track->inRoutes();
+ //Route dst(track, -1);
+
+ QPopupMenu* pup = new QPopupMenu(parent);
+ pup->setCheckable(true);
+
+ int gid = 0;
+ int n;
+
+ // FIXME:
+ // Routes can't be re-read until the message sent from msgAddRoute1()
+ // has had time to be sent and actually affected the routes.
+ ///_redisplay:
+
+ pup->clear();
+ gid = 0;
+
+ //MidiInPortList* tl = song->midiInPorts();
+ //for(iMidiInPort i = tl->begin();i != tl->end(); ++i)
+ for(int i = 0; i < MIDI_PORTS; ++i)
+ {
+ //MidiInPort* track = *i;
+ // NOTE: Could possibly list all devices, bypassing ports, but no, let's stick wth ports.
+ MidiPort* mp = &midiPorts[i];
+ MidiDevice* md = mp->device();
+ if(!md)
+ continue;
+
+ if(!(md->rwFlags() & (dst ? 1 : 2)))
+ continue;
+
+ //printf("MidiStrip::iRoutePressed adding submenu portnum:%d\n", i);
+
+ //QMenu* m = menu->addMenu(track->name());
+ QPopupMenu* subp = new QPopupMenu(parent);
+
+ for(int ch = 0; ch < MIDI_CHANNELS; ++ch)
+ {
+ //QAction* a = m->addAction(QString("Channel %1").arg(ch+1));
+ //subp->insertItem(QT_TRANSLATE_NOOP("@default", QString("Channel %1").arg(ch+1)), i * MIDI_CHANNELS + ch);
+ gid = i * MIDI_CHANNELS + ch;
+
+ //printf("MidiStrip::iRoutePressed inserting gid:%d\n", gid);
+
+ subp->insertItem(QString("Channel %1").arg(ch+1), gid);
+ //a->setCheckable(true);
+ //Route src(track, ch, RouteNode::TRACK);
+ //Route src(md, ch);
+ //Route r = Route(src, dst);
+ //a->setData(QVariant::fromValue(r));
+ //a->setChecked(rl->indexOf(r) != -1);
+ Route srcRoute(md, ch);
+ for(iRoute ir = rl->begin(); ir != rl->end(); ++ir)
+ {
+ //if(*ir == dst)
+ if(*ir == srcRoute)
+ {
+ subp->setItemChecked(gid, true);
+ break;
+ }
+ }
+ }
+ pup->insertItem(QT_TRANSLATE_NOOP("@default", md->name()), subp);
+ }
+
+// QPopupMenu* pup = new QPopupMenu(iR);
+// pup->setCheckable(true);
+ //MidiTrack* t = (MidiTrack*)track;
+// RouteList* irl = track->inRoutes();
+
+// MidiTrack* t = (MidiTrack*)track;
+// int gid = 0;
+// for (int i = 0; i < channel; ++i)
+// {
+// char buffer[128];
+// snprintf(buffer, 128, "%s %d", tr("Channel").toLatin1().constData(), i+1);
+// MenuTitleItem* titel = new MenuTitleItem(QString(buffer));
+// pup->insertItem(titel);
+
+// if (!checkAudioDevice()) return;
+// std::list<QString> ol = audioDevice->outputPorts();
+// for (std::list<QString>::iterator ip = ol.begin(); ip != ol.end(); ++ip) {
+// int id = pup->insertItem(*ip, (gid * 16) + i);
+// Route dst(*ip, true, i);
+// ++gid;
+// for (iRoute ir = irl->begin(); ir != irl->end(); ++ir) {
+// if (*ir == dst) {
+// pup->setItemChecked(id, true);
+// break;
+// }
+// }
+// }
+// if (i+1 != channel)
+// pup->insertSeparator();
+// }
+
+ if(pup->count() == 0)
+ {
+ delete pup;
+ return;
+ }
+
+ //n = pup->exec(QCursor::pos());
+ n = pup->exec(ppt);
+ ///delete pup;
+ if (n != -1)
+ {
+ int mdidx = n / MIDI_CHANNELS;
+ int ch = n % MIDI_CHANNELS;
+
+ //if(debugMsg)
+ //printf("Song::chooseMidiRoutes mdidx:%d ch:%d\n", mdidx, ch);
+
+ MidiPort* mp = &midiPorts[mdidx];
+ MidiDevice* md = mp->device();
+ if(!md)
+ {
+ delete pup;
+ return;
+ }
+
+ //if(!(md->rwFlags() & 2))
+ if(!(md->rwFlags() & (dst ? 1 : 2)))
+ {
+ delete pup;
+ return;
+ }
+
+ //QString s(pup->text(n));
+ //QT_TRANSLATE_NOOP("@default", md->name())
+
+ //Route srcRoute(s, false, -1);
+ Route aRoute(md, ch);
+ //Route srcRoute(md, -1);
+ //Route dstRoute(track, -1);
+ Route bRoute(track, ch);
+
+ //if (track->type() == Track::AUDIO_INPUT)
+ // srcRoute.channel = dstRoute.channel = n & 0xf;
+ iRoute iir = rl->begin();
+ for (; iir != rl->end(); ++iir)
+ {
+ //if(*iir == (dst ? bRoute : aRoute))
+ if(*iir == aRoute)
+ break;
+ }
+ if (iir != rl->end())
+ {
+ // disconnect
+ if(dst)
+ {
+ //printf("Song::chooseMidiRoutes removing route src track name: %s dst device name: %s\n", track->name().toLatin1().constData(), md->name().toLatin1().constData());
+ audio->msgRemoveRoute(bRoute, aRoute);
+ }
+ else
+ {
+ //printf("Song::chooseMidiRoutes removing route src device name: %s dst track name: %s\n", md->name().toLatin1().constData(), track->name().toLatin1().constData());
+ audio->msgRemoveRoute(aRoute, bRoute);
+ }
+ }
+ else
+ {
+ // connect
+ if(dst)
+ {
+ //printf("Song::chooseMidiRoutes adding route src track name: %s dst device name: %s\n", track->name().toLatin1().constData(), md->name().toLatin1().constData());
+ audio->msgAddRoute(bRoute, aRoute);
+ }
+ else
+ {
+ //printf("Song::chooseMidiRoutes adding route src device name: %s dst track name: %s\n", md->name().toLatin1().constData(), track->name().toLatin1().constData());
+ audio->msgAddRoute(aRoute, bRoute);
+ }
+ }
+
+ //printf("Song::chooseMidiRoutes calling msgUpdateSoloStates\n");
+ audio->msgUpdateSoloStates();
+ //printf("Song::chooseMidiRoutes calling song->update\n");
+ song->update(SC_ROUTE);
+
+ // p3.3.46
+ ///goto _redisplay;
+ }
+ delete pup;
+ parent->setDown(false); // pup->exec() catches mouse release event
+ //printf("Song::chooseMidiRoutes end\n");
+
+ //}
+}
+*/
+
+//---------------------------------------------------------
+// insertTrackView
+// add a new trackview for the arranger
+//---------------------------------------------------------
+
+void Song::insertTrackView(TrackView* tv, int idx)
+{
+ iTrackView i = _tviews.index2iterator(idx);
+ _tviews.insert(i, tv);
+}
+
+//---------------------------------------------------------
+// cmdRemoveTrackView
+//---------------------------------------------------------
+
+void Song::cmdRemoveTrackView(TrackView* tv)
+{
+ int idx = _tviews.index(tv);
+ //undoOp(UndoOp::DeleteTrackView, idx, tv);
+ removeTrackView(tv);
+ updateFlags |= SC_TRACKVIEW_REMOVED;
+}
+
+//---------------------------------------------------------
+// removeTrackView
+// add a new trackview for the arranger
+//---------------------------------------------------------
+
+void Song::removeTrackView(TrackView* tv)
+{
+ _tviews.erase(tv);
+}
+
+//---------------------------------------------------------
+// addNewTrackView
+// add a new trackview for the arranger
+//---------------------------------------------------------
+
+TrackView* Song::addNewTrackView(int idx)
+{
+ TrackView* tv = addTrackView((Track::TrackType)idx);
+ return tv;
+}
+
+//---------------------------------------------------------/*{{{*/
+// addTrackView
+// called from GUI context
+//---------------------------------------------------------
+
+TrackView* Song::addTrackView(int t)
+{
+ Track::TrackType type = (Track::TrackType) t;
+ TrackView* tv = new TrackView();
+ switch(type) {
+ case Track::MIDI:
+ tv->setType(Track::MIDI);
+ break;
+ case Track::DRUM:
+ tv->setType(Track::MIDI);
+ break;
+ case Track::WAVE:
+ tv->setType(Track::WAVE);
+ break;
+ case Track::AUDIO_OUTPUT:
+ tv->setType(Track::AUDIO_OUTPUT);
+ break;
+ case Track::AUDIO_GROUP:
+ tv->setType(Track::AUDIO_GROUP);
+ break;
+ case Track::AUDIO_AUX:
+ tv->setType(Track::AUDIO_AUX);
+ break;
+ case Track::AUDIO_INPUT:
+ tv->setType(Track::AUDIO_INPUT);
+ break;
+ case Track::AUDIO_SOFTSYNTH:
+ printf("not implemented: Song::addTrackView(SOFTSYNTH)\n");
+ break;
+ default:
+ printf("Song::addTrackView() illegal type %d\n", type);
+ abort();
+ }
+ tv->setDefaultName();
+ //msgInsertTrackView(tv, -1, true);
+
+ return tv;
+}/*}}}*/
+
+//---------------------------------------------------------
+// findTrackView
+// find track view by name
+//---------------------------------------------------------
+
+TrackView* Song::findTrackView(const QString& name) const
+{
+ for (ciTrackView i = _tviews.begin(); i != _tviews.end(); ++i)
+ {
+ if ((*i)->viewName() == name)
+ return *i;
+ }
+ return 0;
+}
+
+
+//---------------------------------------------------------
+// insertTrack0
+//---------------------------------------------------------
+
+void Song::insertTrack0(Track* track, int idx)
+ {
+ insertTrack1(track, idx);
+ insertTrack2(track, idx); // audio->msgInsertTrack(track, idx, false);
+ insertTrack3(track, idx);
+ }
+
+//---------------------------------------------------------
+// insertTrack1
+// non realtime part of insertTrack
+//---------------------------------------------------------
+
+void Song::insertTrack1(Track* track, int /*idx*/)
+ {
+ //printf("Song::insertTrack1 track:%lx\n", track);
+
+ switch(track->type()) {
+ case Track::AUDIO_SOFTSYNTH:
+ {
+ SynthI* s = (SynthI*)track;
+ Synth* sy = s->synth();
+ if (!s->isActivated()) {
+ s->initInstance(sy, s->name());
+ }
+ }
+ break;
+ default:
+ break;
+ }
+
+ //printf("Song::insertTrack1 end of function\n");
+
+ }
+
+//---------------------------------------------------------
+// insertTrack2
+// realtime part
+//---------------------------------------------------------
+
+void Song::insertTrack2(Track* track, int idx)
+{
+ //printf("Song::insertTrack2 track:%lx\n", track);
+
+ int n;
+ switch(track->type()) {
+ case Track::MIDI:
+ case Track::DRUM:
+ _midis.push_back((MidiTrack*)track);
+ // Added by T356.
+ //((MidiTrack*)track)->addPortCtrlEvents();
+ addPortCtrlEvents(((MidiTrack*)track));
+
+ break;
+ case Track::WAVE:
+ _waves.push_back((WaveTrack*)track);
+ break;
+ case Track::AUDIO_OUTPUT:
+ _outputs.push_back((AudioOutput*)track);
+ // set default master & monitor if not defined
+ if (audio->audioMaster() == 0)
+ audio->setMaster((AudioOutput*)track);
+ if (audio->audioMonitor() == 0)
+ audio->setMonitor((AudioOutput*)track);
+ break;
+ case Track::AUDIO_GROUP:
+ _groups.push_back((AudioGroup*)track);
+ break;
+ case Track::AUDIO_AUX:
+ _auxs.push_back((AudioAux*)track);
+ break;
+ case Track::AUDIO_INPUT:
+ _inputs.push_back((AudioInput*)track);
+ break;
+ case Track::AUDIO_SOFTSYNTH:
+ {
+ SynthI* s = (SynthI*)track;
+ midiDevices.add(s);
+ midiInstruments.push_back(s);
+ _synthIs.push_back(s);
+ }
+ break;
+ default:
+ fprintf(stderr, "unknown track type %d\n", track->type());
+ // abort();
+ return;
+ }
+
+ //
+ // initialize missing aux send
+ //
+ iTrack i = _tracks.index2iterator(idx);
+ //printf("Song::insertTrack2 inserting into _tracks...\n");
+
+ _tracks.insert(i, track);
+ //printf("Song::insertTrack2 inserted\n");
+
+ n = _auxs.size();
+ for (iTrack i = _tracks.begin(); i != _tracks.end(); ++i) {
+ if ((*i)->isMidiTrack())
+ continue;
+ WaveTrack* wt = (WaveTrack*)*i;
+ if (wt->hasAuxSend()) {
+ wt->addAuxSend(n);
+ }
+ }
+
+ /*
+ //
+ // add routes
+ //
+
+ if (track->isMidiTrack())
+ return;
+ AudioTrack* at = (AudioTrack*)track;
+ Route src(at, -1);
+ if (at->type() == Track::AUDIO_OUTPUT) {
+ const RouteList* rl = at->inRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ r->track->outRoutes()->push_back(src);
+ }
+ else if (at->type() == Track::AUDIO_INPUT) {
+ const RouteList* rl = at->outRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ r->track->inRoutes()->push_back(src);
+ }
+ else {
+ const RouteList* rl = at->inRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ r->track->outRoutes()->push_back(src);
+ rl = at->outRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ r->track->inRoutes()->push_back(src);
+ }
+ */
+
+ // p3.3.38
+
+ //
+ // add routes
+ //
+
+ if (track->type() == Track::AUDIO_OUTPUT)
+ {
+ const RouteList* rl = track->inRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ {
+ //if(r->track == track)
+ // r->track->outRoutes()->push_back(*r);
+ // p3.3.50
+ Route src(track, r->channel, r->channels);
+ src.remoteChannel = r->remoteChannel;
+ r->track->outRoutes()->push_back(src);
+ }
+ }
+ else if (track->type() == Track::AUDIO_INPUT)
+ {
+ const RouteList* rl = track->outRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ {
+ //if(r->track == track)
+ // r->track->inRoutes()->push_back(*r);
+ // p3.3.50
+ Route src(track, r->channel, r->channels);
+ src.remoteChannel = r->remoteChannel;
+ r->track->inRoutes()->push_back(src);
+ }
+ }
+ else if (track->isMidiTrack()) // p3.3.50
+ {
+ const RouteList* rl = track->inRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ {
+ //printf("Song::insertTrack2 %s in route port:%d\n", track->name().toLatin1().constData(), r->midiPort); // p3.3.50
+ Route src(track, r->channel);
+ midiPorts[r->midiPort].outRoutes()->push_back(src);
+ }
+ rl = track->outRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ {
+ //printf("Song::insertTrack2 %s out route port:%d\n", track->name().toLatin1().constData(), r->midiPort); // p3.3.50
+ Route src(track, r->channel);
+ midiPorts[r->midiPort].inRoutes()->push_back(src);
+ }
+ }
+ else
+ {
+ const RouteList* rl = track->inRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ {
+ //if(r->track == track)
+ // r->track->outRoutes()->push_back(*r);
+ // p3.3.50
+ Route src(track, r->channel, r->channels);
+ src.remoteChannel = r->remoteChannel;
+ r->track->outRoutes()->push_back(src);
+ }
+ rl = track->outRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ {
+ //if(r->track == track)
+ // r->track->inRoutes()->push_back(*r);
+ // p3.3.50
+ Route src(track, r->channel, r->channels);
+ src.remoteChannel = r->remoteChannel;
+ r->track->inRoutes()->push_back(src);
+ }
+ }
+
+ //printf("Song::insertTrack2 end of function\n");
+
+}
+
+//---------------------------------------------------------
+// insertTrack3
+// non realtime part of insertTrack
+//---------------------------------------------------------
+
+void Song::insertTrack3(Track* /*track*/, int /*idx*/)//prevent compiler warning: unused parameter
+{
+ //printf("Song::insertTrack3\n");
+
+ /*
+ switch(track->type()) {
+ case Track::AUDIO_SOFTSYNTH:
+ break;
+ default:
+ break;
+ }
+ */
+}
+
+//---------------------------------------------------------
+// removeTrack0
+//---------------------------------------------------------
+
+void Song::removeTrack0(Track* track)
+ {
+ removeTrack1(track);
+ audio->msgRemoveTrack(track);
+ removeTrack3(track);
+ //delete track;
+ update(SC_TRACK_REMOVED);
+ }
+
+//---------------------------------------------------------
+// removeTrack1
+// non realtime part of removeTrack
+//---------------------------------------------------------
+
+void Song::removeTrack1(Track* track)
+ {
+ switch(track->type())
+ {
+ case Track::WAVE:
+ case Track::AUDIO_OUTPUT:
+ case Track::AUDIO_INPUT:
+ case Track::AUDIO_GROUP:
+ case Track::AUDIO_AUX:
+ case Track::AUDIO_SOFTSYNTH:
+ ((AudioTrack*)track)->deleteAllEfxGuis();
+ break;
+ default:
+ break;
+ }
+
+ switch(track->type())
+ {
+ case Track::AUDIO_OUTPUT:
+ case Track::AUDIO_INPUT:
+ connectJackRoutes((AudioTrack*)track, true);
+ break;
+ case Track::AUDIO_SOFTSYNTH:
+ {
+ SynthI* si = (SynthI*)track;
+ if(si->hasGui())
+ si->showGui(false);
+ }
+ break;
+ default:
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// removeTrack
+// called from RT context
+//---------------------------------------------------------
+
+void Song::removeTrack2(Track* track)
+{
+ //printf("Song::removeTrack2 track:%s\n", track->name().toLatin1().constData()); // p3.3.50
+
+ switch(track->type()) {
+ case Track::MIDI:
+ case Track::DRUM:
+ // Added by T356.
+ //((MidiTrack*)track)->removePortCtrlEvents();
+ removePortCtrlEvents(((MidiTrack*)track));
+ unchainTrackParts(track, true);
+
+ _midis.erase(track);
+ break;
+ case Track::WAVE:
+ // Added by T356.
+ unchainTrackParts(track, true);
+
+ _waves.erase(track);
+ break;
+ case Track::AUDIO_OUTPUT:
+ _outputs.erase(track);
+ break;
+ case Track::AUDIO_INPUT:
+ _inputs.erase(track);
+ break;
+ case Track::AUDIO_GROUP:
+ _groups.erase(track);
+ break;
+ case Track::AUDIO_AUX:
+ _auxs.erase(track);
+ break;
+ case Track::AUDIO_SOFTSYNTH:
+ {
+ SynthI* s = (SynthI*) track;
+ s->deactivate2();
+ _synthIs.erase(track);
+ }
+ break;
+ }
+ _tracks.erase(track);
+
+
+ /*
+ if (track->isMidiTrack())
+ return;
+ //
+ // remove routes
+ //
+
+ AudioTrack* at = (AudioTrack*)track;
+ Route src(at, -1);
+ if (at->type() == Track::AUDIO_OUTPUT) {
+ const RouteList* rl = at->inRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ r->track->outRoutes()->removeRoute(src);
+ }
+ else if (at->type() == Track::AUDIO_INPUT) {
+ const RouteList* rl = at->outRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ r->track->inRoutes()->removeRoute(src);
+ }
+ else {
+ const RouteList* rl = at->inRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ r->track->outRoutes()->removeRoute(src);
+ rl = at->outRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ r->track->inRoutes()->removeRoute(src);
+ }
+ */
+
+ // p3.3.38
+
+ //
+ // remove routes
+ //
+
+ if (track->type() == Track::AUDIO_OUTPUT)
+ {
+ const RouteList* rl = track->inRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ {
+ //if(r->track == track)
+ // r->track->outRoutes()->removeRoute(*r);
+ //printf("Song::removeTrack2 %s audio out track:%s\n", track->name().toLatin1().constData(), r->track->name().toLatin1().constData()); // p3.3.50
+ // p3.3.50
+ Route src(track, r->channel, r->channels);
+ src.remoteChannel = r->remoteChannel;
+ r->track->outRoutes()->removeRoute(src);
+ }
+ }
+ else if (track->type() == Track::AUDIO_INPUT)
+ {
+ const RouteList* rl = track->outRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ {
+ //if(r->track == track)
+ // r->track->inRoutes()->removeRoute(*r);
+ //printf("Song::removeTrack2 %s audio in track:%s\n", track->name().toLatin1().constData(), r->track->name().toLatin1().constData()); // p3.3.50
+ // p3.3.50
+ Route src(track, r->channel, r->channels);
+ src.remoteChannel = r->remoteChannel;
+ r->track->inRoutes()->removeRoute(src);
+ }
+ }
+ else if (track->isMidiTrack()) // p3.3.50
+ {
+ const RouteList* rl = track->inRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ {
+ //printf("Song::removeTrack2 %s in route port:%d\n", track->name().toLatin1().constData(), r->midiPort); // p3.3.50
+ Route src(track, r->channel);
+ midiPorts[r->midiPort].outRoutes()->removeRoute(src);
+ }
+ rl = track->outRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ {
+ //printf("Song::removeTrack2 %s out route port:%d\n", track->name().toLatin1().constData(), r->midiPort); // p3.3.50
+ Route src(track, r->channel);
+ midiPorts[r->midiPort].inRoutes()->removeRoute(src);
+ }
+ }
+ else
+ {
+ const RouteList* rl = track->inRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ {
+ //if(r->track == track)
+ // r->track->outRoutes()->removeRoute(*r);
+ //printf("Song::removeTrack2 %s in route track:%s\n", track->name().toLatin1().constData(), r->track->name().toLatin1().constData()); // p3.3.50
+ // p3.3.50
+ Route src(track, r->channel, r->channels);
+ src.remoteChannel = r->remoteChannel;
+ r->track->outRoutes()->removeRoute(src);
+ }
+ rl = track->outRoutes();
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ {
+ //if(r->track == track)
+ // r->track->inRoutes()->removeRoute(*r);
+ //printf("Song::removeTrack2 %s out route track:%s\n", track->name().toLatin1().constData(), r->track->name().toLatin1().constData()); // p3.3.50
+ // p3.3.50
+ Route src(track, r->channel, r->channels);
+ src.remoteChannel = r->remoteChannel;
+ r->track->inRoutes()->removeRoute(src);
+ }
+ }
+
+}
+
+//---------------------------------------------------------
+// removeTrack3
+// non realtime part of removeTrack
+//---------------------------------------------------------
+
+void Song::removeTrack3(Track* /*track*/)//prevent of compiler warning: unused parameter
+ {
+ /*
+ switch(track->type()) {
+ case Track::AUDIO_SOFTSYNTH:
+ {
+ SynthI* s = (SynthI*) track;
+ s->deactivate3();
+ }
+ break;
+ default:
+ break;
+ }
+ */
+ }
+
+//---------------------------------------------------------
+// executeScript
+//---------------------------------------------------------
+void Song::executeScript(const char* scriptfile, PartList* parts, int quant, bool onlyIfSelected)
+{
+ // a simple format for external processing
+ // will be extended if there is a need
+ //
+ // Semantics:
+ // PARTLEN <len in ticks>
+ // BEATLEN <len in ticks>
+ // QUANTLEN <len in ticks>
+ // NOTE <tick> <nr> <len in ticks> <velocity>
+ // CONTROLLER <tick> <a> <b> <c>
+ //
+ song->startUndo(); // undo this entire block
+ for (iPart i = parts->begin(); i != parts->end(); i++) {
+ //const char* tmp = tmpnam(NULL);
+ char tmp[16] = "muse-tmp-XXXXXX";
+ int fd = mkstemp(tmp);
+ printf("script input filename=%s\n",tmp);
+ //FILE *fp = fopen(tmp, "w");
+ FILE *fp = fdopen(fd , "w");
+ MidiPart *part = (MidiPart*)(i->second);
+ int partStart = part->endTick()-part->lenTick();
+ int z, n;
+ AL::sigmap.timesig(0, z, n);
+ fprintf(fp, "TIMESIG %d %d\n", z, n);
+ fprintf(fp, "PART %d %d\n", partStart, part->lenTick());
+ fprintf(fp, "BEATLEN %d\n", AL::sigmap.ticksBeat(0));
+ fprintf(fp, "QUANTLEN %d\n", quant);
+
+ //for (iCItem i = items.begin(); i != items.end(); ++i) {
+ for (iEvent e = part->events()->begin(); e != part->events()->end(); e++) {
+ Event ev = e->second;
+
+ if (ev.isNote())
+ {
+ if (onlyIfSelected && ev.selected() == false)
+ continue;
+
+ fprintf(fp,"NOTE %d %d %d %d\n", ev.tick(), ev.dataA(), ev.lenTick(), ev.dataB());
+ // Indicate no undo, and do not do port controller values and clone parts.
+ audio->msgDeleteEvent(ev, part, false, false, false);
+ } else if (ev.type()==Controller) {
+ fprintf(fp,"CONTROLLER %d %d %d %d\n", ev.tick(), ev.dataA(), ev.dataB(), ev.dataC());
+ // Indicate no undo, and do not do port controller values and clone parts.
+ audio->msgDeleteEvent(ev, part, false, false, false);
+ }
+ }
+ fclose(fp);
+
+ // Call external program, let it manipulate the file
+ int pid = fork();
+ if (pid == 0) {
+ if (execlp(scriptfile, scriptfile, tmp, NULL) == -1) {
+ perror("Failed to launch script!");
+ // Get out of here
+
+ // cannot report error through gui, we are in another fork!
+ //@!TODO: Handle unsuccessful attempts
+ exit(99);
+ }
+ exit(0);
+ }
+ else if (pid == -1) {
+ perror("fork failed");
+ }
+ else {
+ int status;
+ waitpid(pid, &status, 0);
+ if (WEXITSTATUS(status) != 0 ) {
+ QMessageBox::warning(muse, tr("MusE - external script failed"),
+ tr("MusE was unable to launch the script\n")
+ );
+ endUndo(SC_EVENT_REMOVED);
+ return;
+ }
+ else { // d0 the fun55or5!
+ // TODO: Create a new part, update the entire editor from it, hehh....
+
+ QFile file(tmp);
+ if ( file.open( QIODevice::ReadOnly ) ) {
+ QTextStream stream( &file );
+ QString line;
+ while ( !stream.atEnd() ) {
+ line = stream.readLine(); // line of text excluding '\n'
+ if (line.startsWith("NOTE"))
+ {
+ QStringList sl = line.split(" ");
+
+ Event e(Note);
+ int tick = sl[1].toInt();
+ int pitch = sl[2].toInt();
+ int len = sl[3].toInt();
+ int velo = sl[4].toInt();
+ printf ("tick=%d pitch=%d velo=%d len=%d\n", tick,pitch,velo,len);
+ e.setTick(tick);
+ e.setPitch(pitch);
+ e.setVelo(velo);
+ e.setLenTick(len);
+ // Indicate no undo, and do not do port controller values and clone parts.
+ audio->msgAddEvent(e, part, false, false, false);
+ }
+ if (line.startsWith("CONTROLLER"))
+ {
+ QStringList sl = line.split(" ");
+
+ Event e(Controller);
+ int tick = sl[1].toInt();
+ int a = sl[2].toInt();
+ int b = sl[3].toInt();
+ int c = sl[4].toInt();
+ printf ("tick=%d a=%d b=%d c=%d\n", tick,a,b,c);
+ e.setA(a);
+ e.setB(b);
+ e.setB(c);
+ // Indicate no undo, and do not do port controller values and clone parts.
+ audio->msgAddEvent(e, part, false, false, false);
+ }
+ }
+ file.close();
+ }
+ }
+ }
+ remove(tmp);
+ }
+
+ endUndo(SC_EVENT_REMOVED);
+}
+
+
+void Song::populateScriptMenu(QMenu* menuPlugins, QObject* receiver)
+{
+ //
+ // List scripts
+ //
+ QString distScripts = museGlobalShare + "/scripts";
+
+ QString userScripts = configPath + "/scripts";
+
+ QFileInfo distScriptsFi(distScripts);
+ if (distScriptsFi.isDir()) {
+ QDir dir = QDir(distScripts);
+ dir.setFilter(QDir::Executable | QDir::Files);
+ deliveredScriptNames = dir.entryList();
+ }
+ QFileInfo userScriptsFi(userScripts);
+ if (userScriptsFi.isDir()) {
+ QDir dir(userScripts);
+ dir.setFilter(QDir::Executable | QDir::Files);
+ userScriptNames = dir.entryList();
+ }
+
+ QSignalMapper* distSignalMapper = new QSignalMapper(this);
+ QSignalMapper* userSignalMapper = new QSignalMapper(this);
+
+ if (deliveredScriptNames.size() > 0 || userScriptNames.size() > 0) {
+ //menuPlugins = new QPopupMenu(this);
+ //menuBar()->insertItem(tr("&Plugins"), menuPlugins);
+ int id = 0;
+ if (deliveredScriptNames.size() > 0) {
+ for (QStringList::Iterator it = deliveredScriptNames.begin(); it != deliveredScriptNames.end(); it++, id++) {
+ //menuPlugins->insertItem(*it, this, SLOT(execDeliveredScript(int)), 0, id);
+ //menuPlugins->insertItem(*it, this, slot_deliveredscripts, 0, id);
+ QAction* act = menuPlugins->addAction(*it);
+ connect(act, SIGNAL(triggered()), distSignalMapper, SLOT(map()));
+ distSignalMapper->setMapping(act, id);
+ }
+ menuPlugins->addSeparator();
+ }
+ if (userScriptNames.size() > 0) {
+ for (QStringList::Iterator it = userScriptNames.begin(); it != userScriptNames.end(); it++, id++) {
+ //menuPlugins->insertItem(*it, this, slot_userscripts, 0, id);
+ QAction* act = menuPlugins->addAction(*it);
+ connect(act, SIGNAL(triggered()), userSignalMapper, SLOT(map()));
+ userSignalMapper->setMapping(act, id);
+ }
+ menuPlugins->addSeparator();
+ }
+ connect(distSignalMapper, SIGNAL(mapped(int)), receiver, SLOT(execDeliveredScript(int)));
+ connect(userSignalMapper, SIGNAL(mapped(int)), receiver, SLOT(execUserScript(int)));
+ }
+ return;
+}
+
+//---------------------------------------------------------
+// getScriptPath
+//---------------------------------------------------------
+QString Song::getScriptPath(int id, bool isdelivered)
+{
+ if (isdelivered) {
+ QString path = museGlobalShare + "/scripts/" + deliveredScriptNames[id];
+ return path;
+ }
+
+ QString path = configPath + "/scripts/" + userScriptNames[id - deliveredScriptNames.size()];
+ return path;
+}
+
diff --git a/attic/muse2-oom/muse2/muse/song.h b/attic/muse2-oom/muse2/muse/song.h
new file mode 100644
index 00000000..9d0e1f86
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/song.h
@@ -0,0 +1,429 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: song.h,v 1.35.2.25 2009/12/15 03:39:58 terminator356 Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SONG_H__
+#define __SONG_H__
+
+#include <QObject>
+#include <QStringList>
+
+#include "pos.h"
+#include "globaldefs.h"
+#include "tempo.h"
+///#include "sig.h"
+#include "al/sig.h"
+#include "undo.h"
+#include "track.h"
+#include "trackview.h"
+
+class QAction;
+class QFont;
+class QMenu;
+
+class SynthI;
+struct MidiMsg;
+struct AudioMsg;
+class Event;
+class Xml;
+class Sequencer;
+class Track;
+class Part;
+class MidiPart;
+class PartList;
+class MPEventList;
+class EventList;
+class MarkerList;
+class Marker;
+class SNode;
+
+class MidiPort;
+class MidiDevice;
+class AudioPort;
+class AudioDevice;
+
+#define SC_TRACK_INSERTED 1
+#define SC_TRACK_REMOVED 2
+#define SC_TRACK_MODIFIED 4
+#define SC_PART_INSERTED 8
+#define SC_PART_REMOVED 0x10
+#define SC_PART_MODIFIED 0x20
+#define SC_EVENT_INSERTED 0x40
+#define SC_EVENT_REMOVED 0x80
+#define SC_EVENT_MODIFIED 0x100
+#define SC_SIG 0x200 // timing signature
+#define SC_TEMPO 0x400 // tempo map changed
+#define SC_MASTER 0x800 // master flag changed
+#define SC_SELECTION 0x1000
+#define SC_MIDI_CONTROLLER 0x2000 // must update midi mixer
+#define SC_MUTE 0x4000
+#define SC_SOLO 0x8000
+#define SC_RECFLAG 0x10000
+#define SC_ROUTE 0x20000
+#define SC_CHANNELS 0x40000
+#define SC_CONFIG 0x80000 // midiPort-midiDevice
+#define SC_DRUMMAP 0x100000 // must update drumeditor
+#define SC_MIXER_VOLUME 0x200000
+#define SC_MIXER_PAN 0x400000
+#define SC_AUTOMATION 0x800000
+#define SC_AUX 0x1000000 // mixer aux changed
+#define SC_RACK 0x2000000 // mixer rack changed
+#define SC_CLIP_MODIFIED 0x4000000
+#define SC_MIDI_CONTROLLER_ADD 0x8000000 // a hardware midi controller was added or deleted
+#define SC_MIDI_TRACK_PROP 0x10000000 // a midi track's properties changed (channel, compression etc)
+#define SC_SONG_TYPE 0x20000000 // the midi song type (mtype) changed
+#define SC_TRACKVIEW_INSERTED 0x30000000
+#define SC_TRACKVIEW_REMOVED 0x40000000
+#define SC_TRACKVIEW_MODIFIED 0x50000000
+
+#define REC_NOTE_FIFO_SIZE 16
+
+//---------------------------------------------------------
+// Song
+//---------------------------------------------------------
+
+class Song : public QObject {
+ Q_OBJECT
+
+ public:
+ enum POS { CPOS = 0, LPOS, RPOS };
+ enum FollowMode { NO, JUMP, CONTINUOUS };
+ enum { REC_OVERDUP, REC_REPLACE };
+ enum { CYCLE_NORMAL, CYCLE_MIX, CYCLE_REPLACE };
+ enum { MARKER_CUR, MARKER_ADD, MARKER_REMOVE, MARKER_NAME,
+ MARKER_TICK, MARKER_LOCK };
+
+ private:
+ // fifo for note-on events
+ // - this events are read by the heart beat interrupt
+ // - used for single step recording in midi editors
+
+ int recNoteFifo[REC_NOTE_FIFO_SIZE];
+ volatile int noteFifoSize;
+ int noteFifoWindex;
+ int noteFifoRindex;
+
+ int updateFlags;
+
+ TrackList _tracks; // tracklist as seen by arranger
+ TrackViewList _tviews; // trackviewlist as seen by arranger
+ MidiTrackList _midis;
+ WaveTrackList _waves;
+ InputList _inputs; // audio input ports
+ OutputList _outputs; // audio output ports
+ GroupList _groups; // mixer groups
+ AuxList _auxs; // aux sends
+ SynthIList _synthIs;
+
+ UndoList* undoList;
+ UndoList* redoList;
+ Pos pos[3];
+ Pos _vcpos; // virtual CPOS (locate in progress)
+ MarkerList* _markerList;
+
+ bool _masterFlag;
+ bool loopFlag;
+ bool punchinFlag;
+ bool punchoutFlag;
+ bool recordFlag;
+ bool soloFlag;
+ enum MType _mtype;
+ int _recMode;
+ int _cycleMode;
+ bool _click;
+ bool _quantize;
+ int _arrangerRaster; // Used for audio rec new part snapping. Set by Arranger snap combo box.
+ unsigned _len; // song len in ticks
+ FollowMode _follow;
+ int _globalPitchShift;
+ void readMarker(Xml&);
+
+ QString songInfoStr; // contains user supplied song information, stored in song file.
+ QStringList deliveredScriptNames;
+ QStringList userScriptNames;
+
+ public:
+ Song(const char* name = 0);
+ ~Song();
+
+ void putEvent(int pv);
+ void endMsgCmd();
+ void processMsg(AudioMsg* msg);
+
+ void setMType(MType t);
+ MType mtype() const { return _mtype; }
+
+ void setFollow(FollowMode m) { _follow = m; }
+ FollowMode follow() const { return _follow; }
+
+ bool dirty;
+ WaveTrack* bounceTrack;
+ AudioOutput* bounceOutput;
+ void updatePos();
+
+ void read(Xml&);
+ void write(int, Xml&) const;
+ void writeFont(int level, Xml& xml, const char* name,
+ const QFont& font) const;
+ QFont readFont(Xml& xml, const char* name);
+ QString getSongInfo() { return songInfoStr; }
+ void setSongInfo(QString info) { songInfoStr = info; }
+
+ void clear(bool signal);
+ void update(int flags = -1);
+ void cleanupForQuit();
+
+ int globalPitchShift() const { return _globalPitchShift; }
+ void setGlobalPitchShift(int val) { _globalPitchShift = val; }
+
+ //-----------------------------------------
+ // Marker
+ //-----------------------------------------
+
+ MarkerList* marker() const { return _markerList; }
+ Marker* addMarker(const QString& s, int t, bool lck);
+ Marker* getMarkerAt(int t);
+ void removeMarker(Marker*);
+ Marker* setMarkerName(Marker*, const QString&);
+ Marker* setMarkerTick(Marker*, int);
+ Marker* setMarkerLock(Marker*, bool);
+ void setMarkerCurrent(Marker* m, bool f);
+
+ //-----------------------------------------
+ // transport
+ //-----------------------------------------
+
+ void setPos(int, const Pos&, bool sig = true, bool isSeek = true,
+ bool adjustScrollbar = false);
+ const Pos& cPos() const { return pos[0]; }
+ const Pos& lPos() const { return pos[1]; }
+ const Pos& rPos() const { return pos[2]; }
+ unsigned cpos() const { return pos[0].tick(); }
+ unsigned vcpos() const { return _vcpos.tick(); }
+ const Pos& vcPos() const { return _vcpos; }
+ unsigned lpos() const { return pos[1].tick(); }
+ unsigned rpos() const { return pos[2].tick(); }
+
+ bool loop() const { return loopFlag; }
+ bool record() const { return recordFlag; }
+ bool punchin() const { return punchinFlag; }
+ bool punchout() const { return punchoutFlag; }
+ bool masterFlag() const { return _masterFlag; }
+ void setRecMode(int val) { _recMode = val; }
+ int recMode() const { return _recMode; }
+ void setCycleMode(int val) { _cycleMode = val; }
+ int cycleMode() const { return _cycleMode; }
+ bool click() const { return _click; }
+ bool quantize() const { return _quantize; }
+ void setStopPlay(bool);
+ void stopRolling();
+ void abortRolling();
+
+ //-----------------------------------------
+ // access tempomap/sigmap (Mastertrack)
+ //-----------------------------------------
+
+ unsigned len() const { return _len; }
+ void setLen(unsigned l); // set songlen in ticks
+ int roundUpBar(int tick) const;
+ int roundUpBeat(int tick) const;
+ int roundDownBar(int tick) const;
+ void initLen();
+ void tempoChanged();
+
+ //-----------------------------------------
+ // event manipulations
+ //-----------------------------------------
+
+ //void cmdAddRecordedWave(WaveTrack* track, const Pos&, const Pos&);
+ void cmdAddRecordedWave(WaveTrack* track, Pos, Pos);
+ void cmdAddRecordedEvents(MidiTrack*, EventList*, unsigned);
+ bool addEvent(Event&, Part*);
+ void changeEvent(Event&, Event&, Part*);
+ void deleteEvent(Event&, Part*);
+ void cmdChangeWave(QString original, QString tmpfile, unsigned sx, unsigned ex);
+ void remapPortDrumCtrlEvents(int mapidx, int newnote, int newchan, int newport);
+ void changeAllPortDrumCtrlEvents(bool add, bool drumonly = false);
+
+ //-----------------------------------------
+ // part manipulations
+ //-----------------------------------------
+
+ void cmdResizePart(Track* t, Part* p, unsigned int size);
+ void cmdSplitPart(Track* t, Part* p, int tick);
+ void cmdGluePart(Track* t, Part* p);
+
+ void addPart(Part* part);
+ void removePart(Part* part);
+ void changePart(Part*, Part*);
+ PartList* getSelectedMidiParts() const;
+ PartList* getSelectedWaveParts() const;
+ bool msgRemoveParts();
+
+ //void cmdChangePart(Part* oldPart, Part* newPart);
+ void cmdChangePart(Part* oldPart, Part* newPart, bool doCtrls, bool doClones);
+ void cmdRemovePart(Part* part);
+ void cmdAddPart(Part* part);
+ int arrangerRaster() { return _arrangerRaster; } // Used by Song::cmdAddRecordedWave to snap new wave parts
+ void setArrangerRaster(int r) { _arrangerRaster = r; } // Used by Arranger snap combo box
+
+ //-----------------------------------------
+ // track manipulations
+ //-----------------------------------------
+
+ TrackList* tracks() { return &_tracks; }
+ MidiTrackList* midis() { return &_midis; }
+ WaveTrackList* waves() { return &_waves; }
+ InputList* inputs() { return &_inputs; }
+ OutputList* outputs() { return &_outputs; }
+ GroupList* groups() { return &_groups; }
+ AuxList* auxs() { return &_auxs; }
+ SynthIList* syntis() { return &_synthIs; }
+
+ void cmdRemoveTrack(Track* track);
+ void removeTrack0(Track* track);
+ void removeTrack1(Track* track);
+ void removeTrack2(Track* track);
+ void removeTrack3(Track* track);
+ void removeMarkedTracks();
+ void changeTrack(Track* oldTrack, Track* newTrack);
+ MidiTrack* findTrack(const Part* part) const;
+ Track* findTrack(const QString& name) const;
+ void swapTracks(int i1, int i2);
+ void setChannelMute(int channel, bool flag);
+ void setRecordFlag(Track*, bool);
+ void insertTrack0(Track*, int idx);
+ void insertTrack1(Track*, int idx);
+ void insertTrack2(Track*, int idx);
+ void insertTrack3(Track*, int idx);
+ void deselectTracks();
+ void readRoute(Xml& xml);
+ void recordEvent(MidiTrack*, Event&);
+ void msgInsertTrack(Track* track, int idx, bool u = true);
+ void clearRecAutomation(bool clearList);
+ void processAutomationEvents();
+ int execAutomationCtlPopup(AudioTrack*, const QPoint&, int);
+ int execMidiAutomationCtlPopup(MidiTrack*, MidiPart*, const QPoint&, int);
+ void connectJackRoutes(AudioTrack* track, bool disconnect);
+ void updateSoloStates();
+ //void chooseMidiRoutes(QButton* /*parent*/, MidiTrack* /*track*/, bool /*dst*/);
+
+ // TrackView
+ TrackViewList* trackviews() { return &_tviews; }
+ TrackView* findTrackView(const QString& name) const;
+ void insertTrackView(TrackView*, int idx);
+ void removeTrackView(TrackView*);
+ void cmdRemoveTrackView(TrackView*);
+ void msgInsertTrackView(TrackView*, int idx, bool u = true);
+
+ //-----------------------------------------
+ // undo, redo
+ //-----------------------------------------
+
+ void startUndo();
+ void endUndo(int);
+ //void undoOp(UndoOp::UndoType, Track* oTrack, Track* nTrack);
+ void undoOp(UndoOp::UndoType, int n, Track* oTrack, Track* nTrack);
+ void undoOp(UndoOp::UndoType, int, Track*);
+ void undoOp(UndoOp::UndoType, int, int, int = 0);
+ void undoOp(UndoOp::UndoType, Part*);
+ //void undoOp(UndoOp::UndoType, Event& nevent, Part*);
+ void undoOp(UndoOp::UndoType, Event& nevent, Part*, bool doCtrls, bool doClones);
+ //void undoOp(UndoOp::UndoType, Event& oevent, Event& nevent, Part*);
+ void undoOp(UndoOp::UndoType, Event& oevent, Event& nevent, Part*, bool doCtrls, bool doClones);
+ void undoOp(UndoOp::UndoType, SigEvent* oevent, SigEvent* nevent);
+ void undoOp(UndoOp::UndoType, int channel, int ctrl, int oval, int nval);
+ //void undoOp(UndoOp::UndoType, Part* oPart, Part* nPart);
+ void undoOp(UndoOp::UndoType, Part* oPart, Part* nPart, bool doCtrls, bool doClones);
+ void undoOp(UndoOp::UndoType type, const char* changedFile, const char* changeData, int startframe, int endframe);
+ void undoOp(UndoOp::UndoType type, Marker* copyMarker, Marker* realMarker);
+ bool doUndo1();
+ void doUndo2();
+ void doUndo3();
+ bool doRedo1();
+ void doRedo2();
+ void doRedo3();
+
+ void addUndo(UndoOp& i);
+
+ //-----------------------------------------
+ // Configuration
+ //-----------------------------------------
+
+ //SynthI* createSynthI(const QString& sclass);
+ SynthI* createSynthI(const QString& sclass, const QString& label = QString());
+
+ void rescanAlsaPorts();
+
+ //-----------------------------------------
+ // Debug
+ //-----------------------------------------
+
+ void dumpMaster();
+ void addUpdateFlags(int f) { updateFlags |= f; }
+
+ //-----------------------------------------
+ // Python bridge related
+ //-----------------------------------------
+#ifdef ENABLE_PYTHON
+ virtual bool event (QEvent* e );
+#endif
+ void executeScript(const char* scriptfile, PartList* parts, int quant, bool onlyIfSelected);
+
+ public slots:
+ void beat();
+
+ void undo();
+ void redo();
+
+ void setTempo(int t);
+ void setSig(int a, int b);
+ void setSig(const AL::TimeSignature&);
+ void setTempo(double tempo) { setTempo(int(60000000.0/tempo)); }
+
+ void setMasterFlag(bool flag);
+ bool getLoop() { return loopFlag; }
+ void setLoop(bool f);
+ void setRecord(bool f, bool autoRecEnable = true);
+ void clearTrackRec();
+ void setPlay(bool f);
+ void setStop(bool);
+ void forward();
+ void rewindStart();
+ void rewind();
+ void setPunchin(bool f);
+ void setPunchout(bool f);
+ void setClick(bool val);
+ void setQuantize(bool val);
+ void panic();
+ void seqSignal(int fd);
+ Track* addTrack(int);
+ Track* addNewTrack(QAction* action);
+ TrackView* addNewTrackView(int);
+ QString getScriptPath(int id, bool delivered);
+ void populateScriptMenu(QMenu* menuPlugins, QObject* receiver);
+ TrackView* addTrackView(int);
+
+ signals:
+ void songChanged(int);
+ void posChanged(int, unsigned, bool);
+ void loopChanged(bool);
+ void recordChanged(bool);
+ void playChanged(bool);
+ void punchinChanged(bool);
+ void punchoutChanged(bool);
+ void clickChanged(bool);
+ void quantizeChanged(bool);
+ void markerChanged(int);
+ void midiPortsChanged();
+ void midiNote(int pitch, int velo);
+ };
+
+extern Song* song;
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/songfile.cpp b/attic/muse2-oom/muse2/muse/songfile.cpp
new file mode 100644
index 00000000..0f477703
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/songfile.cpp
@@ -0,0 +1,1542 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: songfile.cpp,v 1.25.2.12 2009/11/04 15:06:07 spamatica Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <assert.h>
+#include <uuid/uuid.h>
+
+#include "app.h"
+#include "song.h"
+#include "arranger.h"
+//#include "arranger/arranger.h" // p4.0.2
+#include "cobject.h"
+#include "drumedit.h"
+//#include "midiedit/drumedit.h" // p4.0.2
+#include "pianoroll.h"
+//#include "midiedit/pianoroll.h" // p4.0.2
+#include "globals.h"
+#include "xml.h"
+#include "drummap.h"
+//#include "midiedit/drummap.h" // p4.0.2
+#include "event.h"
+#include "marker/marker.h"
+#include "midiport.h"
+#include "audio.h"
+#include "mitplugin.h"
+//#include "mplugins/mitplugin.h" // p4.0.2
+#include "wave.h"
+#include "midictrl.h"
+#include "amixer.h"
+//#include "mixer/amixer.h" // p4.0.2
+#include "conf.h"
+#include "driver/jackmidi.h"
+#include "trackview.h"
+
+//struct ClonePart {
+ //const EventList* el;
+// const Part* cp;
+// int id;
+ //ClonePart(const EventList* e, int i) : el(e), id(i) {}
+// ClonePart(const Part* p, int i) : cp(p), id(i) {}
+// };
+
+//typedef std::list<ClonePart> CloneList;
+//typedef CloneList::iterator iClone;
+
+//---------------------------------------------------------
+// ClonePart
+//---------------------------------------------------------
+
+ClonePart::ClonePart(const Part* p, int i)
+{
+ cp = p;
+ id = i;
+ uuid_generate(uuid);
+}
+
+//static CloneList cloneList;
+//static CloneList copyCloneList;
+CloneList cloneList;
+//CloneList copyCloneList;
+
+/*
+//---------------------------------------------------------
+// updateCloneList
+//---------------------------------------------------------
+
+void updateCloneList(Part* oPart, Part* nPart)
+{
+ for(iClone i = cloneList.begin(); i != cloneList.end(); ++i)
+ {
+ if(i->cp == oPart)
+ {
+ i->cp = nPart;
+ break;
+ }
+ }
+}
+
+void updateCloneList(PartList* oParts, PartList* nParts)
+{
+ for(iPart ip = oParts->begin(); ip != oParts->end(); ++ip)
+ {
+ for(iClone i = cloneList.begin(); i != cloneList.end(); ++i)
+ {
+ if(i->cp == oPart)
+ {
+ i->cp = nPart;
+ break;
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------
+// clearClipboardAndCloneList
+//---------------------------------------------------------
+
+void clearClipboardAndCloneList()
+{
+ //QApplication::clipboard()->clear(QClipboard::Clipboard);
+ cloneList.clear();
+}
+*/
+
+//---------------------------------------------------------
+// NKey::write
+//---------------------------------------------------------
+
+void NKey::write(int level, Xml& xml) const
+ {
+ xml.intTag(level, "key", val);
+ }
+
+//---------------------------------------------------------
+// NKey::read
+//---------------------------------------------------------
+
+void NKey::read(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::Text:
+ val = xml.s1().toInt();
+ break;
+ case Xml::TagEnd:
+ if (xml.s1() == "key")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// Scale::write
+//---------------------------------------------------------
+
+void Scale::write(int level, Xml& xml) const
+ {
+ xml.intTag(level, "scale", val);
+ }
+
+//---------------------------------------------------------
+// Scale::read
+//---------------------------------------------------------
+
+void Scale::read(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::Text:
+ val = xml.s1().toInt();
+ break;
+ case Xml::TagEnd:
+ if (xml.s1() == "scale")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// readXmlPart
+//---------------------------------------------------------
+
+Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack)
+ {
+ int id = -1;
+ Part* npart = 0;
+ uuid_t uuid;
+ uuid_clear(uuid);
+ bool uuidvalid = false;
+ bool clone = true;
+ bool wave = false;
+ bool isclone = false;
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return npart;
+ case Xml::TagStart:
+ // If the part has not been created yet...
+ if(!npart)
+ {
+ // If an id was found...
+ if(id != -1)
+ {
+ for(iClone i = cloneList.begin(); i != cloneList.end(); ++i)
+ {
+ // Is a matching part found in the clone list?
+ if(i->id == id)
+ {
+ // If it's a regular paste (not paste clone), and the original part is
+ // not a clone, defer so that a new copy is created in TagStart above.
+ //if(!doClone && i->cp->cevents()->arefCount() <= 1)
+ //if(!doClone && !isclone)
+ // break;
+
+ // This makes a clone, chains the part, and increases ref counts.
+ npart = track->newPart((Part*)i->cp, true);
+ break;
+ }
+ }
+ }
+ else
+ // If a uuid was found...
+ if(uuidvalid)
+ {
+ for(iClone i = cloneList.begin(); i != cloneList.end(); ++i)
+ {
+ // Is a matching part found in the clone list?
+ if(uuid_compare(uuid, i->uuid) == 0)
+ {
+ Track* cpt = i->cp->track();
+ // If we want to paste to the given track...
+ if(toTrack)
+ {
+ // If the given track type is not the same as the part's
+ // original track type, we can't continue. Just return.
+ if(!track || cpt->type() != track->type())
+ {
+ xml.skip("part");
+ return 0;
+ }
+ }
+ else
+ // ...else we want to paste to the part's original track.
+ {
+ // Make sure the track exists (has not been deleted).
+ if((cpt->isMidiTrack() && song->midis()->find(cpt) != song->midis()->end()) ||
+ (cpt->type() == Track::WAVE && song->waves()->find(cpt) != song->waves()->end()))
+ track = cpt;
+ else
+ // Track was not found. Try pasting to the given track, as above...
+ {
+ if(!track || cpt->type() != track->type())
+ {
+ // No luck. Just return.
+ xml.skip("part");
+ return 0;
+ }
+ }
+ }
+
+ // If it's a regular paste (not paste clone), and the original part is
+ // not a clone, defer so that a new copy is created in TagStart above.
+ //if(!doClone && i->cp->cevents()->arefCount() <= 1)
+ if(!doClone && !isclone)
+ break;
+
+ // This makes a clone, chains the part, and increases ref counts.
+ npart = track->newPart((Part*)i->cp, true);
+ break;
+ }
+ }
+ }
+
+ // If the part still has not been created yet...
+ if(!npart)
+ {
+ // A clone was not created from any matching part. Create a non-clone part now.
+ if(!track)
+ {
+ xml.skip("part");
+ return 0;
+ }
+ // If we're pasting to selected track and the 'wave'
+ // variable is valid, check for mismatch...
+ if(toTrack && uuidvalid)
+ {
+ // If both the part and track are not midi or wave...
+ if((wave && track->isMidiTrack()) ||
+ (!wave && track->type() == Track::WAVE))
+ {
+ xml.skip("part");
+ return 0;
+ }
+ }
+
+ if (track->isMidiTrack())
+ npart = new MidiPart((MidiTrack*)track);
+ else if (track->type() == Track::WAVE)
+ npart = new WavePart((WaveTrack*)track);
+ else
+ {
+ xml.skip("part");
+ return 0;
+ }
+
+ // Signify a new non-clone part was created.
+ // Even if the original part was itself a clone, clear this because the
+ // attribute section did not create a clone from any matching part.
+ clone = false;
+
+ // If an id or uuid was found, add the part to the clone list
+ // so that subsequent parts can look it up and clone from it...
+ if(id != -1)
+ {
+ ClonePart ncp(npart, id);
+ cloneList.push_back(ncp);
+ }
+ else
+ if(uuidvalid)
+ {
+ ClonePart ncp(npart);
+ // New ClonePart creates its own uuid, but we need to replace it.
+ uuid_copy(ncp.uuid, uuid);
+ cloneList.push_back(ncp);
+ }
+ }
+ }
+
+ if (tag == "name")
+ npart->setName(xml.parse1());
+ else if (tag == "poslen") {
+ ((PosLen*)npart)->read(xml, "poslen");
+ }
+ else if (tag == "pos") {
+ Pos pos;
+ pos.read(xml, "pos"); // obsolete
+ npart->setTick(pos.tick());
+ }
+ else if (tag == "len") {
+ Pos len;
+ len.read(xml, "len"); // obsolete
+ npart->setLenTick(len.tick());
+ }
+ else if (tag == "selected")
+ npart->setSelected(xml.parseInt());
+ else if (tag == "color")
+ npart->setColorIndex(xml.parseInt());
+ else if (tag == "mute")
+ npart->setMute(xml.parseInt());
+ else if (tag == "event")
+ {
+ // If a new non-clone part was created, accept the events...
+ if(!clone)
+ {
+ EventType type = Wave;
+ if(track->isMidiTrack())
+ type = Note;
+ Event e(type);
+ e.read(xml);
+ // stored tickpos for event has absolute value. However internally
+ // tickpos is relative to start of part, we substract tick().
+ // TODO: better handling for wave event
+ e.move( -npart->tick() );
+ int tick = e.tick();
+
+ // Do not discard events belonging to clone parts,
+ // at least not yet. A later clone might have a longer,
+ // fully accommodating part length!
+ //if ((tick < 0) || (tick >= (int) lenTick())) {
+ //if ((tick < 0) || ( id == -1 && !clone && (tick >= (int)lenTick()) ))
+ // No way to tell at the moment whether there will be clones referencing this...
+ // No choice but to accept all events past 0.
+ if(tick < 0)
+ {
+ //printf("readClone: warning: event not in part: %d - %d -%d, discarded\n",
+ printf("readClone: warning: event at tick:%d not in part:%s, discarded\n",
+ tick, npart->name().toLatin1().constData());
+ }
+ else
+ {
+ npart->events()->add(e);
+ }
+ }
+ else
+ // ...Otherwise a clone was created, so we don't need the events.
+ xml.skip(tag);
+ }
+ else
+ xml.unknown("readXmlPart");
+ break;
+ case Xml::Attribut:
+ if (tag == "type")
+ {
+ if(xml.s2() == "wave")
+ wave = true;
+ }
+ else if (tag == "cloneId")
+ {
+ id = xml.s2().toInt();
+ //if(id != -1)
+ //{
+ // for(iClone i = cloneList.begin(); i != cloneList.end(); ++i)
+ // {
+ // Is a matching part found in the clone list?
+ // if(i->id == id)
+ // {
+ // If it's a regular paste (not paste clone), and the original part is
+ // not a clone, defer so that a new copy is created in TagStart above.
+ //if(!doClone && i->cp->cevents()->arefCount() <= 1)
+ //if(!doClone && !isclone)
+ // break;
+
+ // This makes a clone, chains the part, and increases ref counts.
+ // npart = track->newPart((Part*)i->cp, true);
+ // break;
+ // }
+ // }
+ //}
+ }
+ else if (tag == "uuid")
+ {
+ uuid_parse(xml.s2().toLatin1().constData(), uuid);
+ if(!uuid_is_null(uuid))
+ {
+ uuidvalid = true;
+ /*
+ for(iClone i = cloneList.begin(); i != cloneList.end(); ++i)
+ {
+ // Is a matching part found in the clone list?
+ if(uuid_compare(uuid, i->uuid) == 0)
+ {
+ Track* cpt = i->cp->track();
+ // If we want to paste to the given track...
+ if(toTrack)
+ {
+ // If the given track type is not the same as the part's
+ // original track type, we can't continue. Just return.
+ if(!track || cpt->type() != track->type())
+ {
+ xml.skip("part");
+ return 0;
+ }
+ }
+ else
+ // ...else we want to paste to the part's original track.
+ {
+ // Make sure the track exists (has not been deleted).
+ if((cpt->isMidiTrack() && song->midis()->find(cpt) != song->midis()->end()) ||
+ (cpt->type() == Track::WAVE && song->waves()->find(cpt) != song->waves()->end()))
+ track = cpt;
+ else
+ // Track was not found. Try pasting to the given track, as above...
+ {
+ if(!track || cpt->type() != track->type())
+ {
+ // No luck. Just return.
+ xml.skip("part");
+ return 0;
+ }
+ }
+ }
+
+ // If it's a regular paste (not paste clone), and the original part is
+ // not a clone, defer so that a new copy is created in TagStart above.
+ //if(!doClone && i->cp->cevents()->arefCount() <= 1)
+ if(!doClone && !isclone)
+ break;
+
+ // This makes a clone, chains the part, and increases ref counts.
+ npart = track->newPart((Part*)i->cp, true);
+ break;
+ }
+ }
+ */
+ }
+ }
+ else if(tag == "isclone")
+ isclone = xml.s2().toInt();
+ break;
+ case Xml::TagEnd:
+ if (tag == "part")
+ return npart;
+ default:
+ break;
+ }
+ }
+ return npart;
+}
+
+//---------------------------------------------------------
+// Part::write
+// If isCopy is true, write the xml differently so that
+// we can have 'Paste Clone' feature.
+//---------------------------------------------------------
+
+//void Part::write(int level, Xml& xml) const
+void Part::write(int level, Xml& xml, bool isCopy, bool forceWavePaths) const
+ {
+ const EventList* el = cevents();
+ int id = -1;
+ uuid_t uuid;
+ uuid_clear(uuid);
+ bool dumpEvents = true;
+ bool wave = _track->type() == Track::WAVE;
+
+ if(isCopy)
+ {
+ //for(iClone i = copyCloneList.begin(); i != copyCloneList.end(); ++i)
+ for(iClone i = cloneList.begin(); i != cloneList.end(); ++i)
+ {
+ //if(i->el == el) {
+ if(i->cp->cevents() == el)
+ {
+ //id = i->id;
+ uuid_copy(uuid, i->uuid);
+ dumpEvents = false;
+ break;
+ }
+ }
+ //if(id == -1)
+ if(uuid_is_null(uuid))
+ {
+ //id = copyCloneList.size();
+ //id = cloneList.size();
+ //ClonePart cp(el, id);
+ //ClonePart cp(this, id);
+ ClonePart cp(this);
+ uuid_copy(uuid, cp.uuid);
+ //copyCloneList.push_back(cp);
+ cloneList.push_back(cp);
+ }
+ }
+ else
+ {
+ if (el->arefCount() > 1)
+ {
+ for (iClone i = cloneList.begin(); i != cloneList.end(); ++i)
+ {
+ //if (i->el == el) {
+ if (i->cp->cevents() == el)
+ {
+ id = i->id;
+ //uuid_copy(id, i->uid);
+ dumpEvents = false;
+ break;
+ }
+ }
+ if (id == -1)
+ //if(uuid_is_null(id))
+ {
+ id = cloneList.size();
+ //ClonePart cp(el, id);
+ ClonePart cp(this, id);
+ //ClonePart cp(this);
+ cloneList.push_back(cp);
+ }
+ }
+ }
+
+ // Special markers if this is a copy operation and the
+ // part is a clone.
+ if(isCopy)
+ {
+ char sid[40]; // uuid string is 36 chars. Try 40 for good luck.
+ sid[0] = 0;
+ uuid_unparse_lower(uuid, sid);
+ //if(midi)
+ // xml.nput(level, "<midipart uuid=\"%s\"", sid);
+ //else
+ if(wave)
+ xml.nput(level, "<part type=\"wave\" uuid=\"%s\"", sid);
+ else
+ xml.nput(level, "<part uuid=\"%s\"", sid);
+
+ if(el->arefCount() > 1)
+ xml.nput(" isclone=\"1\"");
+ xml.put(">");
+ level++;
+ }
+ else
+ if (id != -1)
+ //if(!uuid_is_null(id))
+ {
+ xml.tag(level++, "part cloneId=\"%d\"", id);
+ //char sid[40]; // uuid string is 36 chars. Try 40 for good luck.
+ //sid[0] = 0;
+ //uuid_unparse_lower(id, sid);
+ //xml.tag(level++, "part cloneId=\"%s\"", sid);
+ }
+ else
+ xml.tag(level++, "part");
+
+ xml.strTag(level, "name", _name);
+
+// PosLen poslen(*this);
+// int tickpos = tick();
+// poslen.setTick(tickpos);
+ PosLen::write(level, xml, "poslen");
+ xml.intTag(level, "selected", _selected);
+ xml.intTag(level, "color", _colorIndex);
+ if (_mute)
+ xml.intTag(level, "mute", _mute);
+ if (dumpEvents) {
+ for (ciEvent e = el->begin(); e != el->end(); ++e)
+ //e->second.write(level, xml, *this);
+ e->second.write(level, xml, *this, forceWavePaths);
+ }
+ xml.etag(level, "part");
+ }
+
+/*
+//---------------------------------------------------------
+// Part::read
+//---------------------------------------------------------
+
+void Part::read(Xml& xml, int, bool toTrack) // int newPartOffset
+ {
+ int id = -1;
+ bool containsEvents = false;
+ uuid_t uuid;
+ uuid_clear(uuid);
+ bool uuidvalid = false;
+ bool clone = false;
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "name")
+ _name = xml.parse1();
+ else if (tag == "poslen") {
+ PosLen::read(xml, "poslen");
+ }
+ else if (tag == "pos") {
+ Pos pos;
+ pos.read(xml, "pos"); // obsolete
+ setTick(pos.tick());
+ }
+ else if (tag == "len") {
+ Pos len;
+ len.read(xml, "len"); // obsolete
+ setLenTick(len.tick());
+ }
+ else if (tag == "selected")
+ _selected = xml.parseInt();
+ else if (tag == "color")
+ _colorIndex = xml.parseInt();
+ else if (tag == "mute")
+ _mute = xml.parseInt();
+ else if (tag == "event") {
+ containsEvents = true;
+ EventType type = Wave;
+ if (_track->isMidiTrack())
+ type = Note;
+ Event e(type);
+ e.read(xml);
+ // stored tickpos for event has absolute value. However internally
+ // tickpos is relative to start of part, we substract tick().
+ // TODO: better handling for wave event
+ e.move(-tick());
+ int tick = e.tick();
+
+ // Changed by T356. Do not discard events belonging to clone parts,
+ // at least not yet. A later clone might have a longer,
+ // fully accommodating part length!
+ //if ((tick < 0) || (tick >= (int) lenTick())) {
+ if ((tick < 0) || ( id == -1 && !clone && (tick >= (int)lenTick()) ))
+ {
+ //printf("Part::read: warning: event not in part: %d - %d -%d, discarded\n",
+ printf("Part::read: warning: event at tick:%d not in part:%s, discarded\n",
+ tick, name().toLatin1().constData());
+ }
+ else {
+ _events->add(e);
+*/
+
+
+ /*
+ // TODO: This should NOT be done here since the event list
+ // might be deleted below. Since after reading a part it
+ // likely (always?) that (msg)AddPart() or (msg)ChangePart()
+ // will be called (must check if they're ever called BEFORE
+ // Part::read), then those routines will take care of it,
+ // they are already coded to do so.
+ // Note the redundancy of doing it here AND (msg)Add/ChangePart !
+ // Try to eliminate this section altogether by verifying that
+ // (msg)Add/ChangePart (or one of the other routines which add port
+ // controller values) is always called after Part::read...
+ if (e.type() == Controller) {
+ MidiTrack* mt = (MidiTrack*)_track;
+ int channel = mt->outChannel();
+ MidiPort* mp = &midiPorts[mt->outPort()];
+ // tick is relative to part, controller needs an absolute value hence
+ // part offset is added. If newPartOffset was given we use that instead of
+ // the recorded offset!
+ if (!newPartOffset)
+ newPartOffset=this->tick();
+
+ int ctl = e.dataA();
+ if(mt->type() == Track::DRUM)
+ {
+ // Is it a drum controller event, according to the track port's instrument?
+ MidiController* mc = mp->drumController(ctl);
+ if(mc)
+ {
+ int note = ctl & 0x7f;
+ ctl &= ~0xff;
+ channel = drumMap[note].channel;
+ mp = &midiPorts[drumMap[note].port];
+ ctl |= drumMap[note].anote;
+ }
+ }
+
+ // Removed by T356
+ // check if controller exists
+ //if (mp->hwCtrlState(channel, e.dataA()) == CTRL_VAL_UNKNOWN) {
+ // mp->addManagedController(channel, e.dataA());
+ // }
+
+ // Changed by T356
+ // add controller value
+ //mp->setCtrl(channel, tick+newPartOffset, e.dataA(), e.dataB());
+ mp->setControllerVal(channel, tick+newPartOffset, ctl, e.dataB(), this);
+ }
+ */
+/*
+ }
+ }
+ else
+ xml.unknown("Part::read");
+ break;
+ case Xml::Attribut:
+ if (tag == "cloneId")
+ id = xml.s2().toInt();
+ else if (tag == "uuid")
+ {
+ uuid_parse(xml.s2().toLatin1().constData(), uuid);
+ if(!uuid_is_null(uuid))
+ uuidvalid = true;
+ }
+ else if (tag == "isclone")
+ clone = xml.s2().toInt();
+ break;
+ case Xml::TagEnd:
+ if (tag == "part")
+ {
+*/
+ /*
+ if (id != -1)
+ {
+
+ // clone part
+ if (containsEvents) {
+ // add to cloneList:
+ //ClonePart cp(_events, id);
+ ClonePart cp(this, id);
+ cloneList.push_back(cp);
+ }
+ else {
+ // replace event list with clone event
+ // list
+ for (iClone i = cloneList.begin();
+ i != cloneList.end(); ++i) {
+ if (i->id == id) {
+ delete _events;
+ //_events = (EventList*)(i->el);
+ _events = (EventList*)(i->cp->cevents());
+ _events->incRef(1);
+ _events->incARef(1);
+ //i->cp->chainClone(this);
+ chainClone((Part*)i->cp, this);
+ break;
+ }
+ }
+ }
+ */
+
+/*
+ if(id != -1)
+ {
+ // See if the part exists in the clone list.
+ // The clone list is also the copy/paste clone list.
+ // Care must be taken to ensure the list is ALWAYS EMPTY
+ // before loading or dropping parts INTO muse, because the
+ // current song parts are NOT the same as when the imported parts
+ // were created, (even if they were created from the current session,
+ // we should NOT look them up). Always back up the list, clear it,
+ // read part(s), then restore the list so that paste works after.
+ Part* cp = 0;
+ for(iClone i = cloneList.begin(); i != cloneList.end(); ++i)
+ {
+ if(i->id == id)
+ {
+ cp = (Part*)i->cp;
+ break;
+ }
+ }
+ // Was a matching part found in the clone list?
+ if(cp)
+ {
+ // Make this part a clone of that part. Use its event list...
+ delete _events;
+ _events = (EventList*)(cp->cevents());
+ _events->incRef(1);
+ _events->incARef(1);
+ chainClone(cp, this);
+ }
+ else
+ {
+ // No matching part to clone was found in the clone list.
+ // Does the part contain some events?
+ //if(containsEvents)
+ {
+ // Add the part to the clone list so that subsequent parts
+ // can look it up and clone from it...
+ ClonePart ncp(this, id);
+ cloneList.push_back(ncp);
+ }
+ // Otherwise this part has no matching part in the clone list
+ // and no events of its own. Nothing left to do, we now have
+ // a blank part with the original offset, colour etc.
+ }
+ }
+ else
+ // If a uuid was found, do the same as above. Using uuids
+ // allows foolproof rejection of copied parts not found
+ // in the clone list, particularly when copying parts from
+ // another instance of muse.
+ if(uuidvalid)
+ {
+ Part* cp = 0;
+ for(iClone i = cloneList.begin(); i != cloneList.end(); ++i)
+ {
+ if(uuid_compare(uuid, i->uuid) == 0)
+ {
+ cp = (Part*)i->cp;
+ break;
+ }
+ }
+ // If a matching part was found, and we want to paste to the original track...
+ if(cp && !toTrack)
+ {
+ // Make sure the track exists (has not been deleted).
+ if((cp->track()->isMidiTrack() && song->midis()->find(cp->track()) != song->midis()->end()) ||
+ (cp->track()->type() == Track::WAVE && song->waves()->find(cp->track()) != song->waves()->end()))
+ setTrack(cp->track());
+ }
+ // Was a matching part found in the clone list, and was it
+ // originally a clone part?
+ if(cp && clone)
+ {
+ // Make this part a clone of that part. Use its event list...
+ delete _events;
+ _events = (EventList*)(cp->cevents());
+ _events->incRef(1);
+ _events->incARef(1);
+ // Chain the clone.
+ // Use the slower function which makes sure it chains to a part
+ // within a valid (non-deleted) track.
+ //chainClone(cp, this);
+ chainClone(this);
+ }
+ else
+ {
+ // No matching part to clone was found in the clone list.
+ // Does the part contain some events?
+ //if(containsEvents)
+ {
+ // Add the part to the clone list so that subsequent parts
+ // can look it up and clone from it...
+ ClonePart ncp(this);
+ // New ClonePart creates its own uuid, but we need to replace it.
+ uuid_copy(ncp.uuid, uuid);
+ cloneList.push_back(ncp);
+ }
+ }
+ }
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+*/
+
+//---------------------------------------------------------
+// writeFont
+//---------------------------------------------------------
+
+void Song::writeFont(int level, Xml& xml, const char* name,
+ const QFont& font) const
+ {
+ xml.nput(level, "<%s family=\"%s\" size=\"%d\"",
+ //name, font.family().toLatin1().constData(), font.pointSize());
+ name, Xml::xmlString(font.family()).toLatin1().constData(), font.pointSize());
+ if (font.weight() != QFont::Normal)
+ xml.nput(" weight=\"%d\"", font.weight());
+ if (font.italic())
+ xml.nput(" italic=\"1\"");
+ xml.nput(" />\n");
+ }
+
+//---------------------------------------------------------
+// readFont
+//---------------------------------------------------------
+
+QFont Song::readFont(Xml& xml, const char* name)
+ {
+ QFont f;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return f;
+ case Xml::TagStart:
+ xml.unknown("readFont");
+ break;
+ case Xml::Attribut:
+ if (xml.s1() == "family")
+ f.setFamily(xml.s2());
+ else if (xml.s1() == "size")
+ f.setPointSize(xml.s2().toInt());
+ else if (xml.s1() == "weight")
+ f.setWeight(xml.s2().toInt());
+ else if (xml.s1() == "italic")
+ f.setItalic(xml.s2().toInt());
+ break;
+ case Xml::TagEnd:
+ if (xml.s1() == name)
+ return f;
+ default:
+ break;
+ }
+ }
+ return f;
+ }
+
+//---------------------------------------------------------
+// readPart
+//---------------------------------------------------------
+
+Part* MusE::readPart(Xml& xml)
+ {
+ Part* part = 0;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return part;
+ case Xml::Text:
+ {
+ int trackIdx, partIdx;
+ sscanf(tag.toLatin1().constData(), "%d:%d", &trackIdx, &partIdx);
+ Track* track = song->tracks()->index(trackIdx);
+ if (track)
+ part = track->parts()->find(partIdx);
+ }
+ break;
+ case Xml::TagStart:
+ xml.unknown("readPart");
+ break;
+ case Xml::TagEnd:
+ if (tag == "part")
+ return part;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// readToplevels
+//---------------------------------------------------------
+
+void MusE::readToplevels(Xml& xml)
+ {
+ PartList* pl = new PartList;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "part") {
+ Part* part = readPart(xml);
+ if (part)
+ pl->add(part);
+ }
+ else if (tag == "pianoroll") {
+ // p3.3.34
+ // Do not open if there are no parts.
+ // Had bogus '-1' part index for list edit in med file,
+ // causing list edit to segfault on song load.
+ // Somehow that -1 was put there on write, because the
+ // current part didn't exist anymore, so no index number
+ // could be found for it on write. Watching... may be fixed.
+ // But for now be safe for all the top levels...
+ if(!pl->empty())
+ {
+
+ startPianoroll(pl);
+ toplevels.back().cobject()->readStatus(xml);
+ pl = new PartList;
+ }
+ }
+ else if (tag == "drumedit") {
+ if(!pl->empty())
+ {
+ startDrumEditor(pl);
+ toplevels.back().cobject()->readStatus(xml);
+ pl = new PartList;
+ }
+ }
+ else if (tag == "listeditor") {
+ if(!pl->empty())
+ {
+ startListEditor(pl);
+ toplevels.back().cobject()->readStatus(xml);
+ pl = new PartList;
+ }
+ }
+ else if (tag == "master") {
+ startMasterEditor();
+ toplevels.back().cobject()->readStatus(xml);
+ }
+ else if (tag == "lmaster") {
+ startLMasterEditor();
+ toplevels.back().cobject()->readStatus(xml);
+ }
+ else if (tag == "marker") {
+ showMarker(true);
+ toplevels.back().cobject()->readStatus(xml);
+ }
+ else if (tag == "waveedit") {
+ if(!pl->empty())
+ {
+ startWaveEditor(pl);
+ toplevels.back().cobject()->readStatus(xml);
+ pl = new PartList;
+ }
+ }
+ else if (tag == "cliplist") {
+ startClipList(true);
+ toplevels.back().cobject()->readStatus(xml);
+ }
+ else
+ xml.unknown("MusE");
+ break;
+ case Xml::Attribut:
+ break;
+ case Xml::TagEnd:
+ if (tag == "toplevels") {
+ delete pl;
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// readCtrl
+//---------------------------------------------------------
+
+void MusE::readCtrl(Xml&, int /*prt*/, int /*channel*/)
+ {
+#if 0
+ ChannelState* iState = midiPorts[prt].iState(channel);
+
+ int idx = 0;
+ int val = -1;
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ xml.unknown("readCtrl");
+ break;
+ case Xml::Attribut:
+ if (xml.s1() == "idx")
+ idx = xml.s2().toInt();
+ else if (xml.s1() == "val")
+ val = xml.s2().toInt();
+ break;
+ case Xml::TagEnd:
+ if (xml.s1() == "ctrl") {
+ iState->controller[idx] = val;
+// printf("%d %d ctrl %d val %d\n", prt, channel, idx, val);
+ return;
+ }
+ default:
+ break;
+ }
+ }
+#endif
+ }
+
+//---------------------------------------------------------
+// readMidichannel
+//---------------------------------------------------------
+
+void MusE::readMidichannel(Xml& xml, int prt)
+ {
+ int channel = 0;
+// MidiPort* port = &midiPorts[prt];
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "pitch") {
+//TODO port->setCtrl(channel, 0, CTRL_PITCH, xml.parseInt());
+ }
+ else if (tag == "program") {
+//TODO port->setCtrl(channel, 0, CTRL_PROGRAM, xml.parseInt());
+ }
+ else if (tag == "ctrl")
+ readCtrl(xml, prt, channel);
+ else {
+ xml.unknown("readMidichannel");
+ }
+ break;
+ case Xml::Attribut:
+ if (tag == "ch") {
+ channel = xml.s2().toInt();
+ }
+ break;
+ case Xml::TagEnd:
+ if (tag == "midichannel")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// readMidiport
+//---------------------------------------------------------
+
+void MusE::readMidiport(Xml& xml)
+ {
+ int port = 0;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "midichannel")
+ readMidichannel(xml, port);
+ else {
+ xml.unknown("readMidiport");
+ }
+ break;
+ case Xml::Attribut:
+ if (tag == "port") {
+ port = xml.s2().toInt();
+ }
+ break;
+ case Xml::TagEnd:
+ if (tag == "midiport") {
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// readMarker
+//---------------------------------------------------------
+
+void Song::readMarker(Xml& xml)
+ {
+ Marker m;
+ m.read(xml);
+ _markerList->add(m);
+ }
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+void Song::read(Xml& xml)
+ {
+ cloneList.clear();
+ for (;;) {
+ Xml::Token token;
+ token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "master")
+ setMasterFlag(xml.parseInt());
+ else if (tag == "info")
+ songInfoStr = xml.parse1();
+ else if (tag == "loop")
+ setLoop(xml.parseInt());
+ else if (tag == "punchin")
+ setPunchin(xml.parseInt());
+ else if (tag == "punchout")
+ setPunchout(xml.parseInt());
+ else if (tag == "record")
+ setRecord(xml.parseInt());
+ else if (tag == "solo")
+ soloFlag = xml.parseInt();
+ else if (tag == "type")
+ _mtype = MType(xml.parseInt());
+ else if (tag == "recmode")
+ _recMode = xml.parseInt();
+ else if (tag == "cycle")
+ _cycleMode = xml.parseInt();
+ else if (tag == "click")
+ setClick(xml.parseInt());
+ else if (tag == "quantize")
+ _quantize = xml.parseInt();
+ else if (tag == "len")
+ _len = xml.parseInt();
+ else if (tag == "follow")
+ _follow = FollowMode(xml.parseInt());
+ else if (tag == "tempolist") {
+ tempomap.read(xml);
+ }
+ else if (tag == "siglist")
+ ///sigmap.read(xml);
+ AL::sigmap.read(xml);
+ else if (tag == "miditrack") {
+ MidiTrack* track = new MidiTrack();
+ track->read(xml);
+ insertTrack0(track, -1);
+ }
+ else if (tag == "drumtrack") {
+ MidiTrack* track = new MidiTrack();
+ track->setType(Track::DRUM);
+ track->read(xml);
+ insertTrack0(track, -1);
+ }
+ else if (tag == "wavetrack") {
+ WaveTrack* track = new WaveTrack();
+ track->read(xml);
+ insertTrack0(track,-1);
+ // Now that the track has been added to the lists in insertTrack2(),
+ // OSC can find the track and its plugins, and start their native guis if required...
+ track->showPendingPluginNativeGuis();
+ }
+ else if (tag == "AudioInput") {
+ AudioInput* track = new AudioInput();
+ track->read(xml);
+ insertTrack0(track,-1);
+ track->showPendingPluginNativeGuis();
+ }
+ else if (tag == "AudioOutput") {
+ AudioOutput* track = new AudioOutput();
+ track->read(xml);
+ insertTrack0(track,-1);
+ track->showPendingPluginNativeGuis();
+ }
+ else if (tag == "AudioGroup") {
+ AudioGroup* track = new AudioGroup();
+ track->read(xml);
+ insertTrack0(track,-1);
+ track->showPendingPluginNativeGuis();
+ }
+ else if (tag == "AudioAux") {
+ AudioAux* track = new AudioAux();
+ track->read(xml);
+ insertTrack0(track,-1);
+ track->showPendingPluginNativeGuis();
+ }
+ else if (tag == "SynthI") {
+ SynthI* track = new SynthI();
+ track->read(xml);
+ // Done in SynthI::read()
+ // insertTrack(track,-1);
+ //track->showPendingPluginNativeGuis();
+ }
+ else if (tag == "Route") {
+ readRoute(xml);
+ }
+ else if (tag == "marker")
+ readMarker(xml);
+ else if (tag == "globalPitchShift")
+ _globalPitchShift = xml.parseInt();
+ else if (tag == "automation")
+ automation = xml.parseInt();
+ else if (tag == "cpos") {
+ int pos = xml.parseInt();
+ Pos p(pos, true);
+ setPos(Song::CPOS, p, false, false, false);
+ }
+ else if (tag == "lpos") {
+ int pos = xml.parseInt();
+ Pos p(pos, true);
+ setPos(Song::LPOS, p, false, false, false);
+ }
+ else if (tag == "rpos") {
+ int pos = xml.parseInt();
+ Pos p(pos, true);
+ setPos(Song::RPOS, p, false, false, false);
+ }
+ else if (tag == "drummap")
+ readDrumMap(xml, false);
+ else if (tag == "trackview")
+ {//Read in our trackviews
+ TrackView* tv = new TrackView();
+ tv->read(xml);
+ }
+ else
+ xml.unknown("Song");
+ break;
+ case Xml::Attribut:
+ break;
+ case Xml::TagEnd:
+ if (tag == "song") {
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ dirty = false;
+
+ // Since cloneList is also used for copy/paste operations,
+ // clear the copy clone list again.
+ cloneList.clear();
+ }
+
+//---------------------------------------------------------
+// read
+// read song
+//---------------------------------------------------------
+
+void MusE::read(Xml& xml, bool skipConfig)
+ {
+ bool skipmode = true;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (skipmode && tag == "muse")
+ skipmode = false;
+ else if (skipmode)
+ break;
+ else if (tag == "configuration")
+ if (skipConfig)
+ //xml.skip(tag);
+ readConfiguration(xml,true /* only read sequencer settings */);
+ else
+ readConfiguration(xml, false);
+ else if (tag == "song")
+ {
+ song->read(xml);
+ audio->msgUpdateSoloStates();
+ }
+ else if (tag == "midiport")
+ readMidiport(xml);
+ else if (tag == "Controller") { // obsolete
+ MidiController* ctrl = new MidiController;
+ ctrl->read(xml);
+ delete ctrl;
+ }
+ else if (tag == "mplugin")
+ readStatusMidiInputTransformPlugin(xml);
+ else if (tag == "toplevels")
+ readToplevels(xml);
+ else
+ xml.unknown("muse");
+ break;
+ case Xml::Attribut:
+ if (tag == "version") {
+ int major = xml.s2().section('.', 0, 0).toInt();
+ int minor = xml.s2().section('.', 1, 1).toInt();
+ xml.setVersion(major, minor);
+ }
+ break;
+ case Xml::TagEnd:
+ if (!skipmode && tag == "muse")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+void Song::write(int level, Xml& xml) const
+ {
+ xml.tag(level++, "song");
+ xml.strTag(level, "info", songInfoStr);
+ xml.intTag(level, "automation", automation);
+ xml.intTag(level, "cpos", song->cpos());
+ xml.intTag(level, "rpos", song->rpos());
+ xml.intTag(level, "lpos", song->lpos());
+ xml.intTag(level, "master", _masterFlag);
+ xml.intTag(level, "loop", loopFlag);
+ xml.intTag(level, "punchin", punchinFlag);
+ xml.intTag(level, "punchout", punchoutFlag);
+ xml.intTag(level, "record", recordFlag);
+ xml.intTag(level, "solo", soloFlag);
+ xml.intTag(level, "type", _mtype);
+ xml.intTag(level, "recmode", _recMode);
+ xml.intTag(level, "cycle", _cycleMode);
+ xml.intTag(level, "click", _click);
+ xml.intTag(level, "quantize", _quantize);
+ xml.intTag(level, "len", _len);
+ xml.intTag(level, "follow", _follow);
+ if (_globalPitchShift)
+ xml.intTag(level, "globalPitchShift", _globalPitchShift);
+
+ // Make a backup of the current clone list, to retain any 'copy' items,
+ // so that pasting works properly after.
+ CloneList copyCloneList = cloneList;
+ cloneList.clear();
+
+ // write track views
+ for (ciTrackView i = _tviews.begin(); i != _tviews.end(); ++i)
+ {
+ (*i)->write(level, xml);
+ }
+ // write tracks
+ for (ciTrack i = _tracks.begin(); i != _tracks.end(); ++i)
+ (*i)->write(level, xml);
+
+ // write routing
+ for (ciTrack i = _tracks.begin(); i != _tracks.end(); ++i) {
+
+ // p3.3.38 Changed
+ //if ((*i)->isMidiTrack())
+ // continue;
+ //WaveTrack* track = (WaveTrack*)(*i);
+ //track->writeRouting(level, xml);
+
+ (*i)->writeRouting(level, xml);
+ }
+
+ // Write midi device routing.
+ for (iMidiDevice i = midiDevices.begin(); i != midiDevices.end(); ++i) {
+ //MidiJackDevice* mjd = dynamic_cast<MidiJackDevice*>(*i);
+ //if (!mjd)
+ // continue;
+ //mjd->writeRouting(level, xml);
+ (*i)->writeRouting(level, xml);
+ }
+
+ // p3.3.49 Write midi port routing.
+ for (int i = 0; i < MIDI_PORTS; ++i) {
+ midiPorts[i].writeRouting(level, xml);
+ }
+
+ tempomap.write(level, xml);
+ ///sigmap.write(level, xml);
+ AL::sigmap.write(level, xml);
+ _markerList->write(level, xml);
+
+ writeDrumMap(level, xml, false);
+ xml.tag(level, "/song");
+
+ // Restore backup of the clone list, to retain any 'copy' items,
+ // so that pasting works properly after.
+ cloneList.clear();
+ cloneList = copyCloneList;
+ }
+
+//---------------------------------------------------------
+// TrackView::write
+//---------------------------------------------------------
+
+void TrackView::write(int level, Xml& xml) const /*{{{*/
+{
+ QString tag = "trackview";
+
+ xml.put(level, "<%s name=\"%s\" selected=\"%d\" type=\"%d\"", tag.toUtf8().data(), _name.toUtf8().data(), _selected, _type);
+
+ //for(iTrack* t = _tracks.begin(); t != _tracks.end(); ++t)
+ for (ciTrack t = _tracks.begin(); t != _tracks.end(); ++t)
+ {
+ xml.strTag(level++, "vtrack", (*t)->name());
+ }
+ xml.put(level++, "</%s>", tag.toUtf8().data());
+}/*}}}*/
+
+//---------------------------------------------------------
+// write
+// write song
+//---------------------------------------------------------
+
+void MusE::write(Xml& xml) const
+ {
+ xml.header();
+
+ int level = 0;
+ xml.tag(level++, "muse version=\"2.0\"");
+ writeConfiguration(level, xml);
+
+ writeStatusMidiInputTransformPlugins(level, xml);
+
+ song->write(level, xml);
+
+ if (!toplevels.empty()) {
+ xml.tag(level++, "toplevels");
+ for (ciToplevel i = toplevels.begin(); i != toplevels.end(); ++i) {
+ if (i->cobject()->isVisible())
+ i->cobject()->writeStatus(level, xml);
+ }
+ xml.tag(level--, "/toplevels");
+ }
+
+ xml.tag(level, "/muse");
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/stringparam.cpp b/attic/muse2-oom/muse2/muse/stringparam.cpp
new file mode 100644
index 00000000..24e28e2f
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/stringparam.cpp
@@ -0,0 +1,112 @@
+//=============================================================================
+// MusE
+// Linux Music Editor
+// $Id: stringparam.cpp,v 1.0.0.0 2010/04/24 01:01:01 terminator356 Exp $
+//
+// Copyright (C) 1999-2010 by Werner Schweer and others
+// String parameter module added by Tim.
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//=============================================================================
+
+#include "stringparam.h"
+#include "xml.h"
+
+//---------------------------------------------------------
+// findKey
+//---------------------------------------------------------
+
+iStringParamMap StringParamMap::findKey(const char* key)
+{
+ iStringParamMap icm = find(std::string(key));
+ return icm;
+}
+
+//---------------------------------------------------------
+// set
+//---------------------------------------------------------
+
+void StringParamMap::set(const char* key, const char* value)
+{
+ iStringParamMap icm = find(std::string(key));
+ if(icm == end())
+ insert(std::pair<std::string, std::string>(key, value));
+ else
+ icm->second = std::string(value);
+}
+
+//---------------------------------------------------------
+// remove
+//---------------------------------------------------------
+
+void StringParamMap::remove(const char* key)
+{
+ erase(std::string(key));
+}
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+void StringParamMap::read(Xml& xml, const QString& name)
+{
+ QString n;
+ QString value;
+
+ for (;;)
+ {
+ Xml::Token token = xml.parse();
+ const QString tag = xml.s1();
+ switch (token)
+ {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ xml.unknown(name.toAscii().constData());
+ break;
+ case Xml::Attribut:
+ if(tag == "name")
+ n = xml.s2();
+ else
+ if(tag == "val")
+ value = xml.s2();
+ else
+ xml.unknown(name.toAscii().constData());
+ break;
+ case Xml::TagEnd:
+ if(tag == name)
+ {
+ // Add or modify the item.
+ set(n.toLatin1(), value.toLatin1());
+ return;
+ }
+ default:
+ break;
+ }
+ }
+}
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+void StringParamMap::write(int level, Xml& xml, const char* name) const
+{
+ if(empty())
+ return;
+
+ for(ciStringParamMap r = begin(); r != end(); ++r)
+ xml.tag(level, "%s name=\"%s\" val=\"%s\"/", name, r->first.c_str(), r->second.c_str());
+}
+
diff --git a/attic/muse2-oom/muse2/muse/stringparam.h b/attic/muse2-oom/muse2/muse/stringparam.h
new file mode 100644
index 00000000..0e05c987
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/stringparam.h
@@ -0,0 +1,49 @@
+//=============================================================================
+// MusE
+// Linux Music Editor
+// $Id: stringparam.h,v 1.0.0.0 2010/04/24 01:01:01 terminator356 Exp $
+//
+// Copyright (C) 1999-2010 by Werner Schweer and others
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//=============================================================================
+
+
+#ifndef __STRINGPARAM_H__
+#define __STRINGPARAM_H__
+
+#include <string>
+#include <map>
+
+class QString;
+class Xml;
+
+//typedef std::pair<std::string, std::string > StringParamMapItem;
+typedef std::map<std::string, std::string >::iterator iStringParamMap;
+typedef std::map<std::string, std::string >::const_iterator ciStringParamMap;
+
+class StringParamMap : public std::map<std::string, std::string >
+{
+ public:
+ void set(const char* /*key*/, const char* /*value*/);
+ void remove(const char* /*key*/);
+
+ iStringParamMap findKey(const char* /*key*/);
+ //int index(char* /*key*/);
+
+ void read(Xml& /*xml*/, const QString& /*name*/);
+ void write(int /*level*/, Xml& /*xml*/, const char* /*name*/) const;
+};
+
+
+#endif //__STRINGPARAM_H__ \ No newline at end of file
diff --git a/attic/muse2-oom/muse2/muse/style.qss b/attic/muse2-oom/muse2/muse/style.qss
new file mode 100644
index 00000000..2e3fbc73
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/style.qss
@@ -0,0 +1,814 @@
+/*
+ * this is the MusE application style sheet
+ */
+ QCanvas#ctrlCanvas
+ {
+ }
+ QScrollArea#scrollArea
+ {
+ background-color: green;
+ }
+/*Trackview editor styles*/
+TrackViewEditor QListView, TrackViewEditor QTextField, QTableView
+{
+ background-color: #d6d2d6;
+ border: 1px solid #29292a;
+ border-radius: 6px;
+ padding: 8px;
+}
+
+/*MidiTrackInfo styles*/
+MidiTrackInfo QTableView
+{
+ background-color: #d8dbe8;
+ border: 1px solid #29292a;
+ border-radius: 0px;
+ padding: 0px;
+ color: black;
+ font-size: 12px;
+ alternate-background-color: #bec0cf;
+}
+
+MidiTrackInfo QTableView QHeaderView::section
+{
+ text-align: left;
+ border: 0px solid black;
+ border-radius: 0px;
+ padding: 5px;
+ /*background-color: #936b9c;*/
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #727180, stop:0.1 #727180, stop:0.3 #4a4d5a, stop:1 #4a4d5a);
+ font-size: 12px;
+ color: #d6dfd6;
+}
+
+MidiTrackInfo QTableView::item
+{
+ padding-top: 8px;
+ padding-bottom: 8px;
+}
+
+MidiTrackInfo QTableView::item:selected
+{
+ background-color: #3d3e44;
+ border: none;
+}
+
+MidiTrackInfo QTableView::item:selected:active
+{
+ border: none;
+}
+
+MidiTrackInfo QTableView::item:selected:!active
+{
+ border: none;
+}
+
+
+
+/* Mixer Audio In Style*/
+QFrame#MixerAudioInStrip {
+ border: 1px solid #29292a;
+ /*background-color: #5f855f;*/
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #749f71, stop:0.5 #4d6a4c);
+ border-radius: 7px;
+}
+QFrame#MixerAudioInStrip QLabel {
+ background-color: none;
+ color: #d7d7d7;
+}
+QFrame#MixerAudioInStrip QFrame#MixerAudioInLabel {
+ border: 1px solid #393941;
+ border-radius: 3px;
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 white, stop:0.1 #4d6a4c, stop:0.9 #4d6a4c, stop:1 white);
+ color: #d7d7d7;
+ font-size: 10px;
+ padding: 3px;
+}
+
+/* Mixer Synth Style*/
+QFrame#MixerSynthStrip {
+ border: 1px solid #29292a;
+ /*background-color: #523218;*/
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #9b5a26, stop:0.5 #523218);
+ border-radius: 7px;
+}
+QFrame#MixerSynthStrip QLabel {
+ background-color: none;
+ color: #d7d7d7;
+}
+QFrame#MixerSynthStrip QFrame#MixerSynthLabel {
+ border: 1px solid #393941;
+ border-radius: 3px;
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 white, stop:0.1 #523218, stop:0.9 #523218, stop:1 white);
+ color: #d7d7d7;
+ font-size: 10px;
+ padding: 3px;
+}
+
+
+/* Mixer Wave Track Style*/
+QFrame#MixerWaveStrip {
+ border: 1px solid #5e5e5f;
+ /*background-color: #1d1f20;*/
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #4f7077, stop:0.5 #1e2122);
+ /*border-radius: 3px;*/
+ border-radius: 7px;
+}
+QFrame#MixerWaveStrip QLabel {
+ background-color: none;
+ color: #d7d7d7;
+}
+QFrame#MixerWaveStrip QLabel#MixerWaveLabel {
+ border: 1px solid #393941;
+ border-radius: 3px;
+ /*background-color: #6d437e;*/
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 white, stop:0.1 #1e2122, stop:0.9 #1e2122, stop:1 white);
+ color: #d7d7d7;
+ font-size: 10px;
+ padding: 3px;
+}
+
+/* Mixer Midi Track Style*/
+QFrame#MidiTrackStrip {
+ border: 1px solid #29292a;
+ /*background-color: #3d353d;*/
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #807187, stop:0.5 #504655);
+ border-radius: 7px;
+}
+QFrame#MidiTrackStrip QLabel {
+ background-color: none;
+ color: #d7d7d7;
+}
+QFrame#MidiTrackStrip QLabel#MidiTrackLabel {
+ border: 1px solid #393941;
+ border-radius: 3px;
+ /*background-color: #2e7083;*/
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 white, stop:0.1 #504655, stop:0.9 #504655, stop:1 white);
+ color: #d7d7d7;
+ font-size: 10px;
+ padding: 3px;
+}
+
+/* Mixer AudioGroup Track Style*/
+QFrame#MixerAudioGroupStrip {
+ border: 1px solid #29292a;
+ /*background-color: #4a5152;*/
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #6c797b, stop:0.5 #3a4041);
+ border-radius: 7px;
+}
+QFrame#MixerAudioGroupStrip QLabel {
+ background-color: none;
+ color: #d7d7d7;
+}
+QFrame#MixerAudioGroupStrip QLabel#MixerAudioGroupLabel
+{
+ border: 1px solid #393941;
+ border-radius: 3px;
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 white, stop:0.1 #3a4041, stop:0.9 #3a4041, stop:1 white);
+ color: #d7d7d7;
+ font-size: 10px;
+ padding: 3px;
+}
+
+/* Mixer Aux Track Style*/
+QFrame#MixerAuxStrip {
+ border: 1px solid #29292a;
+ /*background-color: #7e607e;*/
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #696eb0, stop:0.5 #343652);
+ border-radius: 7px;
+}
+QFrame#MixerAuxStrip QLabel {
+ background-color: none;
+ color: #d7d7d7;
+}
+QFrame#MixerAuxStrip QLabel#MixerAuxLabel
+{
+ border: 1px solid #393941;
+ border-radius: 3px;
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 white, stop:0.1 #343652, stop:0.9 #343652, stop:1 white);
+ color: #d7d7d7;
+ font-size: 10px;
+ padding: 3px;
+}
+
+/* Mixer Audio Out Style*/
+QFrame#MixerAudioOutStrip {
+ border: 1px solid #29292a;
+ /*background-color: #4e1010;*/
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #ab3232, stop:0.5 #4e1010);
+ border-radius: 7px;
+}
+QFrame#MixerAudioOutStrip QLabel {
+ background-color: none;
+ color: #d7d7d7;
+}
+QFrame#MixerAudioOutStrip QLabel#MixerAudioOutLabel {
+ border: 1px solid #393941;
+ border-radius: 3px;
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 white, stop:0.1 #4e1010, stop:0.9 #4e1010, stop:1 white);
+ color: #ededed;
+ font-size: 10px;
+ padding: 3px;
+}
+
+QLineEdit
+{
+ border-radius: 8px;
+ border-image: url(:/images/frame.png) 4;
+ border-width: 3;
+ border-color: #484848;
+ background-color: #010f14;
+ color: #03c0e2;
+}
+
+Dentry
+{
+ border-radius: 8px;
+ border-image: url(:/images/frame.png) 4;
+ border-width: 3;
+ border-color: #484848;
+ background-color: #010f14;
+ color: #03c0e2;
+}
+QPushButton
+{
+ color: #e2e5e5; border-radius: 3px; padding: 5px;
+ /*background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);*/
+ /*background-color: #393941;*/
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #626272, stop:0.1 #5b5b6b, stop: 1.0 #4d4d5b);
+ border: 1px solid #393941;
+}
+QPushButton:pressed, QPushButton::checked, QPushButton::hover
+{
+ color: #e2e5e5; border-radius: 3px; padding: 3px;
+ border: 1px solid #181819;
+ background-color: #393941;
+ /*background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #a1a1ab, stop: 0.1 #5f5f69, stop: 2 #484854);*/
+
+}
+QToolButton
+{
+ color: #e2e5e5; border-radius: 3px; padding: 0px;
+ /*background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);*/
+ /*background-color:#6f6e77;*/
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #626272, stop:0.1 #5b5b6b, stop: 1.0 #4d4d5b);
+ /*border: 1px solid #181819; */
+ border: 1px solid #393941;
+}
+QToolButton:pressed, QToolButton::checked, QToolButton::hover
+{
+ color: #e2e5e5; border-radius: 3px; padding: 0px;
+ border: 1px solid #181819;
+ background-color: #393941;
+}
+QToolButton#btnRecord, QToolButton#btnRecord::checked, QToolButton#btnRecord::pressed,
+QToolButton#btnMute, QToolButton#btnMute::checked, QToolButton#btnMute::pressed,
+QToolButton#btnSolo, QToolButton#btnSolo::checked, QToolButton#btnSolo::pressed,
+QToolButton#btnExit, QToolButton#btnExit::checked, QToolButton#btnExit::pressed,
+QToolButton#btnIns, QToolButton#btnIns::checked, QToolButton#btnIns::pressed,
+QToolButton#btnOuts, QToolButton#btnOuts::checked, QToolButton#btnOuts::pressed,
+QToolButton#btnStereo, QToolButton#btnStereo::checked, QToolButton#btnStereo::pressed,
+QToolButton#btnPre, QToolButton#btnPre::checked, QToolButton#btnPre::pressed, QToolButton#btnPre::hover
+{
+ background-color:none;
+ border: none;
+}
+/*QToolButton#btnMute::hover, QToolButton#btnSolo::hover, QToolButton#btnRecord::hover, QToolButton#btnPre::hover,
+QToolButton#btnExit::hover, QToolButton#btnIns::hover, QToolButton#btnOuts::hover, QToolButton#btnStereo::hover
+{
+ color: #e2e5e5; border-radius: 3px; padding: 0px;
+ border: 1px solid #181819;
+ background-color: #393941;
+}*/
+
+QLabel
+{
+ color: #e2e5e5; border: 0px;
+}
+QLabel::disabled
+{
+ color: #393941;
+}
+
+QSplitter::handle{
+background-color: #696977;
+}
+
+QFrame {
+border: 0px solid #595966;
+background-color: #595966
+}
+
+
+/*QListWidget#EffectRack {
+ background-color: red;
+ color:black;
+}*/
+MidiRack, EffectRack {
+ border-radius: 6px;
+ padding: 3px;
+ /*border-image: url(:/images/frame.png) 4;*/
+ /*background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #000c10, stop: 1.0 #1b0019);*/
+ border-width: 1;
+ border-color: #b883a1;
+ background-color: #000c10;
+ color: #b883a1;
+}
+/*
+QListWidget::item::focus{ border-style: none; }
+QListWidget::item:selected:active::text { border-style: none; }
+QListWidget::item::text
+{
+ border-style: none;
+}
+*/
+QListWidget#EffectRack::item:selected:active, QListWidget::item:selected {
+ border-radius: 3px;
+ border: 1px solid #b883a1;
+ background-color: #410122;
+ color: #dcc3d1;
+ text-decoration: none;
+ font-family: "fixed";
+}
+
+/*QListWidgetItem { background-color: #595966 }*/
+QWidget#MixerCenter { background-color: #595966 }
+/*QWidget#EffectRack {
+ background-color: #595966;
+}*/
+QMainWindow { background-color: #595966 }
+/*QWidget { background-color: #595966 }*/
+
+QTabBar::tab {
+ background-color: #595966;
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #E1E1E1, stop: 0.4 #DDDDDD, stop: 0.5 #D8D8D8, stop: 1.0 #D3D3D3);
+ border: 2px solid #C4C4C3;
+ border-bottom-color: #C2C7CB; /* same as the pane color */
+ border-top-left-radius: 4px;
+ border-top-right-radius: 4px;
+ min-width: 8ex;
+ padding: 2px;
+}
+
+QTabBar::tab:selected, QTabBar::tab:hover {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1, stop: 0 #fafafa, stop: 0.4 #f4f4f4, stop: 0.5 #e7e7e7, stop: 1.0 #fafafa);
+}
+
+QTabBar::tab:selected {
+ border-color: #9B9B9B;
+ border-bottom-color: #C2C7CB; /* same as pane color */
+}
+
+QTabBar::tab:!selected {
+ margin-top: 2px; /* make non-selected tabs look smaller */
+}
+
+QMainWindow, MidiTrackInfo, MidiStrip, AudioStrip, QMenu, Spinner, DoubleRange, SliderBase, QDialog, QTabWidget, QMessageBox, QScrollArea { background-color: #595966 }
+/*QMainWindow::toolBarBreak { color: green }*/
+
+/*QToolButton {
+ border: 0px;
+}*/
+QToolBar {
+background-color: #595966;
+color: #e2e5e5;
+border: 0px solid #393941;
+}
+QToolBar::item {
+ spacing: 3px; /* spacing between menu bar items */
+ padding: 3px;
+ background: transparent;
+ border-radius: 3px;
+ }
+
+QToolBar::item:selected { /* when selected using mouse or keyboard */
+ background: #a8a8a8;
+}
+
+QToolBar::item:pressed
+{
+ background: #888888;
+ image: url(:/images/down_arrow_disabled.png) 1;
+}
+QToolBar::handle, QToolBar::addToolBarBreak
+{
+ image: url(:/images/toolbar_handle.png) 1;
+}
+
+
+QMenuBar { background-color: #595966; color: #e2e5e5; border: 0px; font-size: 12pt; font-family: 'Arial';}
+QMenuBar::item {
+ spacing: 6px; /* spacing between menu bar items */
+ padding: 1px 4px;
+ background: transparent;
+ border-radius: 3px;
+ }
+
+ QMenuBar::item:selected { /* when selected using mouse or keyboard */
+ background: #a8a8a8;
+ }
+
+ QMenuBar::item:pressed {
+ background: #888888;
+ }
+
+
+ QScrollBar:horizontal {
+ border: 1px solid #393941;
+ background: #858599;
+ height: 15px;
+ margin: 0px 15px 0 15px;
+ }
+ QScrollBar::handle:horizontal {
+ /*border: 1px solid #393941;*/
+ border: 1px solid #5c5c5c;
+ /*background: #545463;*/
+ background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);
+ min-width: 15px;
+ }
+ QScrollBar::add-line:horizontal {
+ border: 1px solid #393941;
+ background: #585867;
+ width: 15px;
+ subcontrol-position: right;
+ subcontrol-origin: margin;
+ }
+
+ QScrollBar::sub-line:horizontal {
+ border: 1px solid #393941;
+ background: #585867;
+ width: 15px;
+ subcontrol-position: left;
+ subcontrol-origin: margin;
+ }
+QScrollBar:left-arrow:horizontal, QScrollBar::right-arrow:horizontal {
+ border: 1px solid #393941;
+ width: 3px;
+ height: 3px;
+ background: #dedede;
+ }
+
+ QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal {
+ background: none;
+ }
+ QScrollBar:vertical {
+ border: 1px solid #393941;
+ background: #858599;
+ width: 15px;
+ margin: 15px 0 15px 0px;
+ }
+ QScrollBar::handle:vertical {
+ /*border: 1px solid #393941;*/
+ border: 1px solid #5c5c5c;
+ /*background: #545463;*/
+ background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);
+ min-height: 15px;
+ }
+ QScrollBar::add-line:vertical {
+ border: 1px solid #393941;
+ background: #585867;
+ height: 15px;
+ subcontrol-position: bottom;
+ subcontrol-origin: margin;
+ }
+
+ QScrollBar::sub-line:vertical {
+ border: 1px solid #393941;
+ background: #585867;
+ height: 15px;
+ subcontrol-position: top;
+ subcontrol-origin: margin;
+ }
+QScrollBar:up-arrow:vertical, QScrollBar::down-arrow:vertical {
+ border: 1px solid #393941;
+ width: 3px;
+ height: 3px;
+ background: #dedede;
+ }
+
+ QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
+ background: none;
+ }
+
+QSlider::groove:horizontal
+{
+ border: 1px solid #393941;
+ height: 8px; /* the groove expands to the size of the slider by default. by giving it a height, it has a fixed size */
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #858599, stop:1 #6d6d7e);
+ margin: 2px 0;
+}
+QSlider::handle:horizontal
+{
+ background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);
+ border: 1px solid #5c5c5c;
+ width: 8px;
+ margin: -2px 0; /* handle is placed by default on the contents rect of the groove. Expand outside the groove */
+ border-radius: 3px;
+}
+/*
+Slider
+{
+
+ background-color: red;
+ border: 1px solid green;
+ border-radius: 3px;
+
+}
+Slider::groove:vertical
+{
+ background-color: blue;
+}
+*/
+QSlider::groove:vertical
+{
+ border: 1px solid #393941;
+ width: 8px; /* the groove expands to the size of the slider by default. by giving it a height, it has a fixed size */
+ background: qlineargradient(x1:0, y1:0, x2:0, y2:1, stop:0 #858599, stop:1 #6d6d7e);
+ margin: 0 2px;
+}
+QSlider::handle:vertical
+{
+ background: qlineargradient(x1:0, y1:0, x2:1, y2:1, stop:0 #b4b4b4, stop:1 #8f8f8f);
+ border: 1px solid #5c5c5c;
+ width: 8px;
+ height: 8px;
+ margin: 0 -2px; /* handle is placed by default on the contents rect of the groove. Expand outside the groove */
+ border-radius: 3px;
+}
+
+
+ QComboBox {
+ border: 1px solid #393941;
+ border-radius: 3px;
+ padding: 3px 18px 3px 6px;
+ min-width: 6em;
+ color: #e2e5e5;
+ }
+
+ QComboBox:editable {
+ background: #93a7b2;
+ }
+
+ QComboBox:over {
+ }
+
+ QComboBox:!editable, QComboBox::drop-down:editable {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #626272, stop:0.1 #5b5b6b, stop: 1.0 #4d4d5b);
+ }
+
+ /* QComboBox gets the "on" state when the popup is open */
+ QComboBox:!editable:on, QComboBox::drop-down:editable:on, QComboBox::hover {
+ background: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,
+ stop: 0 #9cadb6, stop:0.2 #5b5b6b, stop: 0.8 #4d4d5b, stop: 1.0 #9cadb6);
+ }
+
+ QComboBox:on { /* shift the text when the popup opens */
+ padding-top: 3px;
+ padding-left: 6px;
+ }
+
+ QComboBox::drop-down {
+ subcontrol-origin: padding;
+ subcontrol-position: top right;
+ width: 15px;
+
+ border-left-width: 1px;
+ border-left-color: #393941;
+ border-left-style: solid; /* just a single line */
+ border-top-right-radius: 3px; /* same radius as the QComboBox */
+ border-bottom-right-radius: 3px;
+ }
+
+ QComboBox::down-arrow {
+ image: url(:/images/down_arrow_disabled.png) 1;
+ }
+
+ QComboBox::down-arrow:on { /* shift the arrow when popup is open */
+ top: 1px;
+ left: 1px;
+ }
+ QComboBox QAbstractItemView {
+ border: 1px solid #e2e5e5;
+ selection-background-color: #93a7b2;
+ background-color: #d0d0d0;
+ }
+
+QHeaderView#header {
+ /*padding-right: 15px; make room for the arrows */
+ border-image: url(:/images/frame.png) 4;
+ border-width: 3;
+ border-right: 0;
+ background-color: #010f14;
+ color: #03c0e2;
+ /*color: #76ac01;*/
+ }
+
+QLabel#Cursor {
+ /*padding-right: 15px; make room for the arrows */
+ border-image: url(:/images/frame.png) 4;
+ border-width: 3;
+ border-right: 0;
+ background-color: #010f14;
+ color: #03c0e2;
+ /*color: #76ac01;*/
+ }
+
+QLabel#arrangerCursor {
+ /*padding-right: 15px; make room for the arrows */
+ border-image: url(:/images/frame.png) 4;
+ border-width: 3;
+ background-color: #010f14;
+ color: #03c0e2;
+ /*color: #76ac01;*/
+ }
+
+QLabel#pitchLabel {
+ /*padding-right: 15px; make room for the arrows */
+ border-image: url(:/images/frame.png) 4;
+ border-width: 3;
+ border-left: 0;
+ background-color: #010f14;
+ color: #03c0e2;
+ /*color: #76ac01;*/
+ }
+
+QAbstractSpinBox {
+ border-radius: 8px;
+ /*padding-right: 15px;*/ /* make room for the arrows */
+ border-image: url(:/images/frame.png) 4;
+ border-width: 3;
+ border-color: #484848;
+ background-color: #010f14;
+ color: #03c0e2;
+ /*color: #76ac01;*/
+ }
+
+ QAbstractSpinBox::up-button {
+ subcontrol-origin: border;
+ subcontrol-position: top right; /* position at the top right corner */
+
+ width: 16px; /* 16 + 2*1px border-width = 15px padding + 3px parent border */
+ border-image: url(:/images/spinup.png) 1;
+ border-width: 1px;
+ }
+
+ QAbstractSpinBox::up-button:hover {
+ border-image: url(:/images/spinup_hover.png) 1;
+ }
+
+ QAbstractSpinBox::up-button:pressed {
+ border-image: url(:/images/spinup_pressed.png) 1;
+ }
+
+ QAbstractSpinBox::up-arrow {
+ image: url(:/images/up_arrow.png);
+ width: 7px;
+ height: 7px;
+ }
+
+ QAbstractSpinBox::up-arrow:disabled, QSpinBox::up-arrow:off { /* off state when value is max */
+ image: url(:/images/up_arrow_disabled.png);
+ }
+
+ QAbstractSpinBox::down-button {
+ subcontrol-origin: border;
+ subcontrol-position: bottom right; /* position at bottom right corner */
+
+ width: 16px;
+ border-image: url(:/images/spindown.png) 1;
+ border-width: 1px;
+ border-top-width: 0;
+ }
+
+ QAbstractSpinBox::down-button:hover {
+ border-image: url(:/images/spindown_hover.png) 1;
+ }
+
+ QAbstractSpinBox::down-button:pressed {
+ border-image: url(:/images/spindown_pressed.png) 1;
+ }
+
+ QAbstractSpinBox::down-arrow {
+ image: url(:/images/down_arrow.png);
+ width: 7px;
+ height: 7px;
+ }
+
+ QAbstractSpinBox::down-arrow:disabled,
+ QAbstractSpinBox::down-arrow:off { /* off state when value in min */
+ image: url(:/images/down_arrow_disabled.png);
+ }
+
+/*
+ QScrollBar:vertical {
+ border: 1px solid #393941;
+ background: #858599;
+ height: 15px;
+ margin: 0px 20px 0 20px;
+ }
+ QScrollBar::handle:vertical {
+ border: 1px solid #393941;
+ background: #545463;
+ min-width: 20px;
+ }
+ QScrollBar::add-line:vertical {
+ border: 1px solid #393941;
+ background: #585867;
+ width: 20px;
+ subcontrol-position: right;
+ subcontrol-origin: margin;
+ }
+
+ QScrollBar::sub-line:vertical {
+ border: 1px solid #393941;
+ background: #585867;
+ width: 20px;
+ subcontrol-position: left;
+ subcontrol-origin: margin;
+ }
+QScrollBar:left-arrow:vertical, QScrollBar::right-arrow:vertical {
+ border: 1px solid #393941;
+ width: 3px;
+ height: 3px;
+ background: white;
+ }
+
+ QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical {
+ background: none;
+ }
+
+
+*/
+
+
+/*progRecordButton { background-color: #595966 }*/
+/* TODO */
+/*
+QLabel#midiChannelLabel { font-size: 6pt }
+MidiRack, EffectRack { font-size: 8pt }
+QLabel#trackLabel { font-size: 6pt }
+SimpleButton { font-size: 8pt }
+QToolButton#routeButton { font-size: 8pt }
+QToolButton#preButton { font-size: 8pt }
+
+TimeCanvas {
+ qproperty-fontSize1: 6;
+ qproperty-fontSize2: 8;
+ qproperty-fontSize3: 8
+ }
+
+QLabel#knobLabel { font-size: 8pt }
+Awl--MidiVolEntry { font-size: 5pt }
+Awl--MidiPanEntry { font-size: 5pt }
+Awl--VolEntry { font-size: 5pt }
+Awl--PanEntry { font-size: 5pt }
+
+QLabel#AudioOut {
+ font-size: 7pt;
+ background-color: white;
+ }
+
+QLabel#Group {
+ font-size: 7pt;
+ background-color: yellow;
+ }
+
+QLabel#Wave {
+ font-size: 7pt;
+ background-color: rgb(0,255,0);
+ }
+
+QLabel#AudioIn {
+ font-size: 7pt;
+ background-color: red;
+ }
+
+QLabel#Synth {
+ font-size: 7pt;
+ background-color: blue;
+ }
+
+QLabel#Midi {
+ font-size: 7pt;
+ background-color: gray;
+ }
+
+QLabel#MidiOut {
+ font-size: 7pt;
+ background-color: gray;
+ }
+
+QLabel#MidiIn {
+ font-size: 7pt;
+ background-color: gray;
+ }
+QLabel#M-Synth {
+ font-size: 7pt;
+ background-color: gray;
+ }
+
+*/
diff --git a/attic/muse2-oom/muse2/muse/sync.cpp b/attic/muse2-oom/muse2/muse/sync.cpp
new file mode 100644
index 00000000..9fe5f4d3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/sync.cpp
@@ -0,0 +1,1395 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: sync.cpp,v 1.6.2.12 2009/06/20 22:20:41 terminator356 Exp $
+//
+// (C) Copyright 2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <cmath>
+#include "sync.h"
+#include "song.h"
+#include "utils.h"
+#include "midiport.h"
+#include "mididev.h"
+#include "globals.h"
+#include "midiseq.h"
+#include "audio.h"
+#include "audiodev.h"
+//#include "driver/audiodev.h" // p4.0.2
+#include "gconfig.h"
+#include "xml.h"
+#include "midi.h"
+
+//int rxSyncPort = -1; // receive from all ports
+//int txSyncPort = 1;
+//int rxDeviceId = 0x7f; // any device
+//int txDeviceId = 0x7f; // any device
+//MidiSyncPort midiSyncPorts[MIDI_PORTS];
+int volatile curMidiSyncInPort = -1;
+
+bool debugSync = true;
+
+int mtcType = 1;
+MTC mtcOffset;
+BValue extSyncFlag(0, "extSync"); // false - MASTER, true - SLAVE
+//bool genMTCSync = false; // output MTC Sync
+//bool genMCSync = false; // output MidiClock Sync
+//bool genMMC = false; // output Midi Machine Control
+//bool acceptMTC = false;
+//bool acceptMC = true;
+//bool acceptMMC = true;
+BValue useJackTransport(0,"useJackTransport");
+bool volatile jackTransportMaster = true;
+
+static MTC mtcCurTime;
+static int mtcState; // 0-7 next expected quarter message
+static bool mtcValid;
+static int mtcLost;
+static bool mtcSync; // receive complete mtc frame?
+
+// p3.3.28
+static bool playPendingFirstClock = false;
+unsigned int syncSendFirstClockDelay = 1; // In milliseconds.
+//static int lastStoppedBeat = 0;
+static unsigned int curExtMidiSyncTick = 0;
+unsigned int volatile lastExtMidiSyncTick = 0;
+double volatile curExtMidiSyncTime = 0.0;
+double volatile lastExtMidiSyncTime = 0.0;
+
+// Not used yet.
+// static bool mcStart = false;
+// static int mcStartTick;
+
+// p3.3.25
+// From the "Introduction to the Volatile Keyword" at Embedded dot com
+/* A variable should be declared volatile whenever its value could change unexpectedly.
+ ... <such as> global variables within a multi-threaded application
+ ... So all shared global variables should be declared volatile */
+unsigned int volatile midiExtSyncTicks = 0;
+
+//---------------------------------------------------------
+// MidiSyncInfo
+//---------------------------------------------------------
+
+MidiSyncInfo::MidiSyncInfo()
+{
+ _port = -1;
+ _idOut = 127;
+ _idIn = 127;
+ _sendMC = false;
+ _sendMRT = false;
+ _sendMMC = false;
+ _sendMTC = false;
+ _recMC = false;
+ _recMRT = false;
+ _recMMC = false;
+ _recMTC = false;
+
+ _lastClkTime = 0.0;
+ _lastTickTime = 0.0;
+ _lastMRTTime = 0.0;
+ _lastMMCTime = 0.0;
+ _lastMTCTime = 0.0;
+ _clockTrig = false;
+ _tickTrig = false;
+ _MRTTrig = false;
+ _MMCTrig = false;
+ _MTCTrig = false;
+ _clockDetect = false;
+ _tickDetect = false;
+ _MRTDetect = false;
+ _MMCDetect = false;
+ _MTCDetect = false;
+ _recMTCtype = 0;
+ _recRewOnStart = true;
+ //_sendContNotStart = false;
+ _actDetectBits = 0;
+ for(int i = 0; i < MIDI_CHANNELS; ++i)
+ {
+ _lastActTime[i] = 0.0;
+ _actTrig[i] = false;
+ _actDetect[i] = false;
+ }
+}
+
+//---------------------------------------------------------
+// operator =
+//---------------------------------------------------------
+
+MidiSyncInfo& MidiSyncInfo::operator=(const MidiSyncInfo &sp)
+{
+ //_port = sp._port;
+
+ copyParams(sp);
+
+ _lastClkTime = sp._lastClkTime;
+ _lastTickTime = sp._lastTickTime;
+ _lastMRTTime = sp._lastMRTTime;
+ _lastMMCTime = sp._lastMMCTime;
+ _lastMTCTime = sp._lastMTCTime;
+ _clockTrig = sp._clockTrig;
+ _tickTrig = sp._tickTrig;
+ _MRTTrig = sp._MRTTrig;
+ _MMCTrig = sp._MMCTrig;
+ _MTCTrig = sp._MTCTrig;
+ _clockDetect = sp._clockDetect;
+ _tickDetect = sp._tickDetect;
+ _MRTDetect = sp._MRTDetect;
+ _MMCDetect = sp._MMCDetect;
+ _MTCDetect = sp._MTCDetect;
+ _recMTCtype = sp._recMTCtype;
+ for(int i = 0; i < MIDI_CHANNELS; ++i)
+ {
+ _lastActTime[i] = sp._lastActTime[i];
+ _actTrig[i] = sp._actTrig[i];
+ _actDetect[i] = sp._actDetect[i];
+ }
+ return *this;
+}
+
+//---------------------------------------------------------
+// copyParams
+//---------------------------------------------------------
+
+MidiSyncInfo& MidiSyncInfo::copyParams(const MidiSyncInfo &sp)
+{
+ //_port = sp._port;
+
+ _idOut = sp._idOut;
+ _idIn = sp._idIn;
+ _sendMC = sp._sendMC;
+ _sendMRT = sp._sendMRT;
+ _sendMMC = sp._sendMMC;
+ _sendMTC = sp._sendMTC;
+ setMCIn(sp._recMC);
+ _recMRT = sp._recMRT;
+ _recMMC = sp._recMMC;
+ _recMTC = sp._recMTC;
+ _recRewOnStart = sp._recRewOnStart;
+ //_sendContNotStart = sp._sendContNotStart;
+ return *this;
+}
+
+//---------------------------------------------------------
+// setTime
+//---------------------------------------------------------
+
+void MidiSyncInfo::setTime()
+{
+ // Note: CurTime() makes a system call to gettimeofday(),
+ // which apparently can be slow in some cases. So I avoid calling this function
+ // too frequently by calling it (at the heartbeat rate) in Song::beat(). T356
+ double t = curTime();
+
+ if(_clockTrig)
+ {
+ _clockTrig = false;
+ _lastClkTime = t;
+ }
+ else
+ if(_clockDetect && (t - _lastClkTime >= 1.0)) // Set detect indicator timeout to about 1 second.
+ {
+ _clockDetect = false;
+ // Give up the current midi sync in port number if we took it...
+ if(curMidiSyncInPort == _port)
+ curMidiSyncInPort = -1;
+ }
+
+ if(_tickTrig)
+ {
+ _tickTrig = false;
+ _lastTickTime = t;
+ }
+ else
+ if(_tickDetect && (t - _lastTickTime) >= 1.0) // Set detect indicator timeout to about 1 second.
+ _tickDetect = false;
+
+ if(_MRTTrig)
+ {
+ _MRTTrig = false;
+ _lastMRTTime = t;
+ }
+ else
+ if(_MRTDetect && (t - _lastMRTTime) >= 1.0) // Set detect indicator timeout to about 1 second.
+ {
+ _MRTDetect = false;
+ // Give up the current midi sync in port number if we took it...
+ //if(curMidiSyncInPort == _port)
+ // curMidiSyncInPort = -1;
+ }
+
+ if(_MMCTrig)
+ {
+ _MMCTrig = false;
+ _lastMMCTime = t;
+ }
+ else
+ if(_MMCDetect && (t - _lastMMCTime) >= 1.0) // Set detect indicator timeout to about 1 second.
+ {
+ _MMCDetect = false;
+ // Give up the current midi sync in port number if we took it...
+ //if(curMidiSyncInPort == _port)
+ // curMidiSyncInPort = -1;
+ }
+
+ if(_MTCTrig)
+ {
+ _MTCTrig = false;
+ _lastMTCTime = t;
+ }
+ else
+ if(_MTCDetect && (t - _lastMTCTime) >= 1.0) // Set detect indicator timeout to about 1 second.
+ {
+ _MTCDetect = false;
+ // Give up the current midi sync in port number if we took it...
+ if(curMidiSyncInPort == _port)
+ curMidiSyncInPort = -1;
+ }
+
+ for(int i = 0; i < MIDI_CHANNELS; i++)
+ {
+ if(_actTrig[i])
+ {
+ _actTrig[i] = false;
+ _lastActTime[i] = t;
+ }
+ else
+ if(_actDetect[i] && (t - _lastActTime[i]) >= 1.0) // Set detect indicator timeout to about 1 second.
+ {
+ _actDetect[i] = false;
+ //_actDetectBits &= ~bitShiftLU[i];
+ _actDetectBits &= ~(1 << i);
+ }
+ }
+}
+
+//---------------------------------------------------------
+// setMCIn
+//---------------------------------------------------------
+
+void MidiSyncInfo::setMCIn(const bool v)
+{
+ _recMC = v;
+ // If sync receive was turned off, clear the current midi sync in port number so another port can grab it.
+ if(!_recMC && _port != -1 && curMidiSyncInPort == _port)
+ curMidiSyncInPort = -1;
+}
+
+//---------------------------------------------------------
+// setMRTIn
+//---------------------------------------------------------
+
+void MidiSyncInfo::setMRTIn(const bool v)
+{
+ _recMRT = v;
+ // If sync receive was turned off, clear the current midi sync in port number so another port can grab it.
+ //if(!_recMRT && _port != -1 && curMidiSyncInPort == _port)
+ // curMidiSyncInPort = -1;
+}
+
+//---------------------------------------------------------
+// setMMCIn
+//---------------------------------------------------------
+
+void MidiSyncInfo::setMMCIn(const bool v)
+{
+ _recMMC = v;
+ // If sync receive was turned off, clear the current midi sync in port number so another port can grab it.
+ //if(!_recMMC && _port != -1 && curMidiSyncInPort == _port)
+ // curMidiSyncInPort = -1;
+}
+
+//---------------------------------------------------------
+// setMTCIn
+//---------------------------------------------------------
+
+void MidiSyncInfo::setMTCIn(const bool v)
+{
+ _recMTC = v;
+ // If sync receive was turned off, clear the current midi sync in port number so another port can grab it.
+ if(!_recMTC && _port != -1 && curMidiSyncInPort == _port)
+ curMidiSyncInPort = -1;
+}
+
+//---------------------------------------------------------
+// trigMCSyncDetect
+//---------------------------------------------------------
+
+void MidiSyncInfo::trigMCSyncDetect()
+{
+ _clockDetect = true;
+ _clockTrig = true;
+ // Set the current midi sync in port number if it's not taken...
+ if(_recMC && curMidiSyncInPort == -1)
+ curMidiSyncInPort = _port;
+}
+
+//---------------------------------------------------------
+// trigTickDetect
+//---------------------------------------------------------
+
+void MidiSyncInfo::trigTickDetect()
+{
+ _tickDetect = true;
+ _tickTrig = true;
+}
+
+//---------------------------------------------------------
+// trigMRTDetect
+//---------------------------------------------------------
+
+void MidiSyncInfo::trigMRTDetect()
+{
+ _MRTDetect = true;
+ _MRTTrig = true;
+ // Set the current midi sync in port number if it's not taken...
+ //if(_recMRT && curMidiSyncInPort == -1)
+ // curMidiSyncInPort = _port;
+}
+
+//---------------------------------------------------------
+// trigMMCDetect
+//---------------------------------------------------------
+
+void MidiSyncInfo::trigMMCDetect()
+{
+ _MMCDetect = true;
+ _MMCTrig = true;
+ // Set the current midi sync in port number if it's not taken...
+ //if(_recMMC && curMidiSyncInPort == -1)
+ // curMidiSyncInPort = _port;
+}
+
+//---------------------------------------------------------
+// trigMTCDetect
+//---------------------------------------------------------
+
+void MidiSyncInfo::trigMTCDetect()
+{
+ _MTCDetect = true;
+ _MTCTrig = true;
+ // Set the current midi sync in port number if it's not taken...
+ if(_recMTC && curMidiSyncInPort == -1)
+ curMidiSyncInPort = _port;
+}
+
+//---------------------------------------------------------
+// actDetect
+//---------------------------------------------------------
+
+bool MidiSyncInfo::actDetect(const int ch) const
+{
+ if(ch < 0 || ch >= MIDI_CHANNELS)
+ return false;
+
+ return _actDetect[ch];
+}
+
+//---------------------------------------------------------
+// trigActDetect
+//---------------------------------------------------------
+
+void MidiSyncInfo::trigActDetect(const int ch)
+{
+ if(ch < 0 || ch >= MIDI_CHANNELS)
+ return;
+
+ //_actDetectBits |= bitShiftLU[ch];
+ _actDetectBits |= (1 << ch);
+ _actDetect[ch] = true;
+ _actTrig[ch] = true;
+}
+
+//---------------------------------------------------------
+// isDefault
+//---------------------------------------------------------
+
+bool MidiSyncInfo::isDefault() const
+{
+ return(_idOut == 127 && _idIn == 127 && !_sendMC && !_sendMRT && !_sendMMC && !_sendMTC &&
+ /* !_sendContNotStart && */ !_recMC && !_recMRT && !_recMMC && !_recMTC && _recRewOnStart);
+}
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+void MidiSyncInfo::read(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token(xml.parse());
+ const QString& tag(xml.s1());
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "idOut")
+ _idOut = xml.parseInt();
+ else if (tag == "idIn")
+ _idIn = xml.parseInt();
+ else if (tag == "sendMC")
+ _sendMC = xml.parseInt();
+ else if (tag == "sendMRT")
+ _sendMRT = xml.parseInt();
+ else if (tag == "sendMMC")
+ _sendMMC = xml.parseInt();
+ else if (tag == "sendMTC")
+ _sendMTC = xml.parseInt();
+ //else if (tag == "sendContNotStart")
+ // _sendContNotStart = xml.parseInt();
+ else if (tag == "recMC")
+ _recMC = xml.parseInt();
+ else if (tag == "recMRT")
+ _recMRT = xml.parseInt();
+ else if (tag == "recMMC")
+ _recMMC = xml.parseInt();
+ else if (tag == "recMTC")
+ _recMTC = xml.parseInt();
+ else if (tag == "recRewStart")
+ _recRewOnStart = xml.parseInt();
+ else
+ xml.unknown("midiSyncInfo");
+ break;
+ case Xml::TagEnd:
+ if (tag == "midiSyncInfo")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+//void MidiSyncInfo::write(int level, Xml& xml, MidiDevice* md)
+void MidiSyncInfo::write(int level, Xml& xml)
+{
+ //if(!md)
+ // return;
+
+ // All defaults? Nothing to write.
+ //if(_idOut == 127 && _idIn == 127 && !_sendMC && !_sendMRT && !_sendMMC && !_sendMTC &&
+ // /* !_sendContNotStart && */ !_recMC && !_recMRT && !_recMMC && !_recMTC && _recRewOnStart)
+ // return;
+ if(isDefault())
+ return;
+
+ xml.tag(level++, "midiSyncInfo");
+ //xml.intTag(level, "idx", idx);
+ //xml.intTag(level++, "midiSyncPort", idx);
+ //xml.tag(level++, "midiSyncInfo idx=\"%d\"", idx);
+
+ //xml.strTag(level, "device", md->name());
+
+ if(_idOut != 127)
+ xml.intTag(level, "idOut", _idOut);
+ if(_idIn != 127)
+ xml.intTag(level, "idIn", _idIn);
+
+ if(_sendMC)
+ xml.intTag(level, "sendMC", true);
+ if(_sendMRT)
+ xml.intTag(level, "sendMRT", true);
+ if(_sendMRT)
+ xml.intTag(level, "sendMMC", true);
+ if(_sendMTC)
+ xml.intTag(level, "sendMTC", true);
+ //if(_sendContNotStart)
+ // xml.intTag(level, "sendContNotStart", true);
+
+ if(_recMC)
+ xml.intTag(level, "recMC", true);
+ if(_recMRT)
+ xml.intTag(level, "recMRT", true);
+ if(_recMMC)
+ xml.intTag(level, "recMMC", true);
+ if(_recMTC)
+ xml.intTag(level, "recMTC", true);
+ if(!_recRewOnStart)
+ xml.intTag(level, "recRewStart", false);
+
+ xml.etag(level, "midiSyncInfo");
+}
+
+//---------------------------------------------------------
+// mmcInput
+// Midi Machine Control Input received
+//---------------------------------------------------------
+
+//void MidiSeq::mmcInput(const unsigned char* p, int n)
+void MidiSeq::mmcInput(int port, const unsigned char* p, int n)
+ {
+ if (debugSync)
+ printf("mmcInput: n:%d %02x %02x %02x %02x\n",
+ n, p[2], p[3], p[4], p[5]);
+
+ MidiPort* mp = &midiPorts[port];
+ MidiSyncInfo& msync = mp->syncInfo();
+ // Trigger MMC detect in.
+ msync.trigMMCDetect();
+ // MMC locate SMPTE time code may contain format type bits. Grab them.
+ if(p[3] == 0x44 && p[4] == 6 && p[5] == 1)
+ msync.setRecMTCtype((p[6] >> 5) & 3);
+
+ // MMC in not turned on? Forget it.
+ if(!msync.MMCIn())
+ return;
+
+ //if (!(extSyncFlag.value() && acceptMMC))
+ //if(!extSyncFlag.value())
+ // return;
+
+ switch(p[3]) {
+ case 1:
+ if (debugSync)
+ printf(" MMC: STOP\n");
+
+ playPendingFirstClock = false;
+
+ //if ((state == PLAY || state == PRECOUNT))
+ if (audio->isPlaying())
+ audio->msgPlay(false);
+ playStateExt = false;
+ alignAllTicks();
+ //stopPlay();
+ break;
+ case 2:
+ if (debugSync)
+ printf(" MMC: PLAY\n");
+ case 3:
+ if (debugSync)
+ printf(" MMC: DEFERRED PLAY\n");
+ mtcState = 0;
+ mtcValid = false;
+ mtcLost = 0;
+ mtcSync = false;
+ //startPlay();
+ alignAllTicks();
+ audio->msgPlay(true);
+ playStateExt = true;
+ break;
+
+ case 4:
+ printf("MMC: FF not implemented\n");
+ playPendingFirstClock = false;
+ break;
+ case 5:
+ printf("MMC: REWIND not implemented\n");
+ playPendingFirstClock = false;
+ break;
+ case 6:
+ printf("MMC: REC STROBE not implemented\n");
+ playPendingFirstClock = false;
+ break;
+ case 7:
+ printf("MMC: REC EXIT not implemented\n");
+ playPendingFirstClock = false;
+ break;
+ case 0xd:
+ printf("MMC: RESET not implemented\n");
+ playPendingFirstClock = false;
+ break;
+ case 0x44:
+ if (p[5] == 0) {
+ printf("MMC: LOCATE IF not implemented\n");
+ break;
+ }
+ else if (p[5] == 1) {
+ if (!checkAudioDevice()) return;
+ MTC mtc(p[6] & 0x1f, p[7], p[8], p[9], p[10]);
+ int type = (p[6] >> 5) & 3;
+ //int mmcPos = tempomap.frame2tick(lrint(mtc.time()*sampleRate));
+ //int mmcPos = lrint(mtc.time()*sampleRate);
+ int mmcPos = lrint(mtc.time(type) * sampleRate);
+
+ //Pos tp(mmcPos, true);
+ Pos tp(mmcPos, false);
+ //audioDevice->seekTransport(tp.frame());
+ audioDevice->seekTransport(tp);
+ alignAllTicks();
+ //seek(tp);
+ if (debugSync) {
+ //printf("MMC: %f %d seek ", mtc.time(), mmcPos);
+ printf("MMC: LOCATE mtc type:%d time:%lf frame:%d mtc: ", type, mtc.time(), mmcPos);
+ mtc.print();
+ printf("\n");
+ }
+ //write(sigFd, "G", 1);
+ break;
+ }
+ // fall through
+ default:
+ printf("MMC %x %x, unknown\n", p[3], p[4]); break;
+ }
+ }
+
+//---------------------------------------------------------
+// mtcInputQuarter
+// process Quarter Frame Message
+//---------------------------------------------------------
+
+//void MidiSeq::mtcInputQuarter(int, unsigned char c)
+void MidiSeq::mtcInputQuarter(int port, unsigned char c)
+ {
+ static int hour, min, sec, frame;
+
+ // p3.3.28
+ //printf("MidiSeq::mtcInputQuarter c:%h\n", c);
+
+ int valL = c & 0xf;
+ int valH = valL << 4;
+
+ int _state = (c & 0x70) >> 4;
+ if (mtcState != _state)
+ mtcLost += _state - mtcState;
+ mtcState = _state + 1;
+
+ switch(_state) {
+ case 7:
+ hour = (hour & 0x0f) | valH;
+ break;
+ case 6:
+ hour = (hour & 0xf0) | valL;
+ break;
+ case 5:
+ min = (min & 0x0f) | valH;
+ break;
+ case 4:
+ min = (min & 0xf0) | valL;
+ break;
+ case 3:
+ sec = (sec & 0x0f) | valH;
+ break;
+ case 2:
+ sec = (sec & 0xf0) | valL;
+ break;
+ case 1:
+ frame = (frame & 0x0f) | valH;
+ break;
+ case 0: frame = (frame & 0xf0) | valL;
+ break;
+ }
+ frame &= 0x1f; // 0-29
+ sec &= 0x3f; // 0-59
+ min &= 0x3f; // 0-59
+ int tmphour = hour;
+ int type = (hour >> 5) & 3;
+ hour &= 0x1f;
+
+ if(mtcState == 8)
+ {
+ mtcValid = (mtcLost == 0);
+ mtcState = 0;
+ mtcLost = 0;
+ if(mtcValid)
+ {
+ mtcCurTime.set(hour, min, sec, frame);
+ if(port != -1)
+ {
+ MidiPort* mp = &midiPorts[port];
+ MidiSyncInfo& msync = mp->syncInfo();
+ msync.setRecMTCtype(type);
+ msync.trigMTCDetect();
+ // Not for the current in port? External sync not turned on? MTC in not turned on? Forget it.
+ if(port == curMidiSyncInPort && extSyncFlag.value() && msync.MTCIn())
+ {
+ if(debugSync)
+ printf("MidiSeq::mtcInputQuarter hour byte:%hx\n", tmphour);
+ mtcSyncMsg(mtcCurTime, type, !mtcSync);
+ }
+ }
+ mtcSync = true;
+ }
+ }
+ else if (mtcValid && (mtcLost == 0))
+ {
+ //mtcCurTime.incQuarter();
+ mtcCurTime.incQuarter(type);
+ //mtcSyncMsg(mtcCurTime, type, false);
+ }
+ }
+
+//---------------------------------------------------------
+// mtcInputFull
+// process Frame Message
+//---------------------------------------------------------
+
+//void MidiSeq::mtcInputFull(const unsigned char* p, int n)
+void MidiSeq::mtcInputFull(int port, const unsigned char* p, int n)
+ {
+ if (debugSync)
+ printf("mtcInputFull\n");
+ //if (!extSyncFlag.value())
+ // return;
+
+ if (p[3] != 1) {
+ if (p[3] != 2) { // silently ignore user bits
+ printf("unknown mtc msg subtype 0x%02x\n", p[3]);
+ dump(p, n);
+ }
+ return;
+ }
+ int hour = p[4];
+ int min = p[5];
+ int sec = p[6];
+ int frame = p[7];
+
+ frame &= 0x1f; // 0-29
+ sec &= 0x3f; // 0-59
+ min &= 0x3f; // 0-59
+ int type = (hour >> 5) & 3;
+ hour &= 0x1f;
+
+ mtcCurTime.set(hour, min, sec, frame);
+ mtcState = 0;
+ mtcValid = true;
+ mtcLost = 0;
+
+ // Added by Tim.
+ if(debugSync)
+ printf("mtcInputFull: time:%lf stime:%lf hour byte (all bits):%hx\n", mtcCurTime.time(), mtcCurTime.time(type), p[4]);
+ if(port != -1)
+ {
+ MidiPort* mp = &midiPorts[port];
+ MidiSyncInfo& msync = mp->syncInfo();
+ msync.setRecMTCtype(type);
+ msync.trigMTCDetect();
+ // MTC in not turned on? Forget it.
+ //if(extSyncFlag.value() && msync.MTCIn())
+ if(msync.MTCIn())
+ {
+ //Pos tp(lrint(mtcCurTime.time() * sampleRate), false);
+ Pos tp(lrint(mtcCurTime.time(type) * sampleRate), false);
+ audioDevice->seekTransport(tp);
+ alignAllTicks();
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// nonRealtimeSystemSysex
+//---------------------------------------------------------
+
+//void MidiSeq::nonRealtimeSystemSysex(const unsigned char* p, int n)
+void MidiSeq::nonRealtimeSystemSysex(int /*port*/, const unsigned char* p, int n)
+ {
+// int chan = p[2];
+ switch(p[3]) {
+ case 4:
+ printf("NRT Setup\n");
+ break;
+ default:
+ printf("unknown NRT Msg 0x%02x\n", p[3]);
+ dump(p, n);
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// setSongPosition
+// MidiBeat is a 14 Bit value. Each MidiBeat spans
+// 6 MIDI Clocks. Inother words, each MIDI Beat is a
+// 16th note (since there are 24 MIDI Clocks in a
+// quarter note).
+//---------------------------------------------------------
+
+void MidiSeq::setSongPosition(int port, int midiBeat)
+ {
+ if (midiInputTrace)
+ printf("set song position port:%d %d\n", port, midiBeat);
+
+ //midiPorts[port].syncInfo().trigMCSyncDetect();
+ midiPorts[port].syncInfo().trigMRTDetect();
+
+ //if (!extSyncFlag.value())
+ // External sync not on? Clock in not turned on?
+ //if(!extSyncFlag.value() || !midiPorts[port].syncInfo().MCIn())
+ if(!extSyncFlag.value() || !midiPorts[port].syncInfo().MRTIn())
+ return;
+
+ // Re-transmit song position to other devices if clock out turned on.
+ for(int p = 0; p < MIDI_PORTS; ++p)
+ //if(p != port && midiPorts[p].syncInfo().MCOut())
+ if(p != port && midiPorts[p].syncInfo().MRTOut())
+ midiPorts[p].sendSongpos(midiBeat);
+
+ curExtMidiSyncTick = (config.division * midiBeat) / 4;
+ lastExtMidiSyncTick = curExtMidiSyncTick;
+
+ //Pos pos((config.division * midiBeat) / 4, true);
+ Pos pos(curExtMidiSyncTick, true);
+
+ if (!checkAudioDevice()) return;
+
+ //audioDevice->seekTransport(pos.frame());
+ audioDevice->seekTransport(pos);
+ alignAllTicks(pos.frame());
+ if (debugSync)
+ printf("setSongPosition %d\n", pos.tick());
+ }
+
+
+
+//---------------------------------------------------------
+// set all runtime variables to the "in sync" value
+//---------------------------------------------------------
+void MidiSeq::alignAllTicks(int frameOverride)
+ {
+ //printf("alignAllTicks audioDriver->framePos=%d, audio->pos().frame()=%d\n",
+ // audioDevice->framePos(), audio->pos().frame());
+ unsigned curFrame;
+ if (!frameOverride)
+ curFrame = audio->pos().frame();
+ else
+ curFrame = frameOverride;
+
+ int tempo = tempomap.tempo(0);
+
+ // use the last old values to give start values for the tripple buffering
+ int recTickSpan = recTick1 - recTick2;
+ int songTickSpan = (int)(songtick1 - songtick2); //prevent compiler warning: casting double to int
+ storedtimediffs = 0; // pretend there is no sync history
+
+ mclock2=mclock1=0.0; // set all clock values to "in sync"
+
+ recTick = (int) ((double(curFrame)/double(sampleRate)) *
+ double(config.division * 1000000.0) / double(tempo) //prevent compiler warning: casting double to int
+ );
+ songtick1 = recTick - songTickSpan;
+ if (songtick1 < 0)
+ songtick1 = 0;
+ songtick2 = songtick1 - songTickSpan;
+ if (songtick2 < 0)
+ songtick2 = 0;
+ recTick1 = recTick - recTickSpan;
+ if (recTick1 < 0)
+ recTick1 = 0;
+ recTick2 = recTick1 - recTickSpan;
+ if (recTick2 < 0)
+ recTick2 = 0;
+ if (debugSync)
+ printf("alignAllTicks curFrame=%d recTick=%d tempo=%.3f frameOverride=%d\n",curFrame,recTick,(float)((1000000.0 * 60.0)/tempo), frameOverride);
+
+ }
+
+//---------------------------------------------------------
+// realtimeSystemInput
+// real time message received
+//---------------------------------------------------------
+void MidiSeq::realtimeSystemInput(int port, int c)
+ {
+
+ if (midiInputTrace)
+ printf("realtimeSystemInput port:%d 0x%x\n", port+1, c);
+
+ //if (midiInputTrace && (rxSyncPort != port) && rxSyncPort != -1) {
+ // if (debugSync)
+ // printf("rxSyncPort configured as %d; received sync from port %d\n",
+ // rxSyncPort, port);
+ // return;
+ // }
+
+ MidiPort* mp = &midiPorts[port];
+
+ // Trigger on any tick, clock, or realtime command.
+ if(c == ME_TICK) // Tick
+ mp->syncInfo().trigTickDetect();
+ else
+ if(c == ME_CLOCK) // Clock
+ mp->syncInfo().trigMCSyncDetect();
+ else
+ mp->syncInfo().trigMRTDetect(); // Other
+
+ // External sync not on? Clock in not turned on? Otherwise realtime in not turned on?
+ if(!extSyncFlag.value())
+ return;
+ if(c == ME_CLOCK)
+ {
+ if(!mp->syncInfo().MCIn())
+ return;
+ }
+ else
+ if(!mp->syncInfo().MRTIn())
+ return;
+
+
+ switch(c) {
+ case ME_CLOCK: // midi clock (24 ticks / quarter note)
+ {
+ // Not for the current in port? Forget it.
+ if(port != curMidiSyncInPort)
+ break;
+
+ // p3.3.31
+ //printf("midi clock:%f\n", curTime());
+
+ // Re-transmit clock to other devices if clock out turned on.
+ // Must be careful not to allow more than one clock input at a time.
+ // Would re-transmit mixture of multiple clocks - confusing receivers.
+ // Solution: Added curMidiSyncInPort.
+ // Maybe in MidiSeq::processTimerTick(), call sendClock for the other devices, instead of here.
+ for(int p = 0; p < MIDI_PORTS; ++p)
+ if(p != port && midiPorts[p].syncInfo().MCOut())
+ midiPorts[p].sendClock();
+
+ // p3.3.28
+ if(playPendingFirstClock)
+ {
+ playPendingFirstClock = false;
+ // Hopefully the transport will be ready by now, the seek upon start should mean the
+ // audio prefetch has already finished or at least started...
+ // Must comfirm that play does not force a complete prefetch again, but don't think so...
+ if(!audio->isPlaying())
+ audioDevice->startTransport();
+ }
+ //else
+ // This part will be run on the second and subsequent clocks, after start.
+ // Can't check audio state, might not be playing yet, we might miss some increments.
+ //if(audio->isPlaying())
+ if(playStateExt)
+ {
+ lastExtMidiSyncTime = curExtMidiSyncTime;
+ curExtMidiSyncTime = curTime();
+ int div = config.division/24;
+ midiExtSyncTicks += div;
+ lastExtMidiSyncTick = curExtMidiSyncTick;
+ curExtMidiSyncTick += div;
+ }
+
+//BEGIN : Original code:
+ /*
+ double mclock0 = curTime();
+ // Difference in time last 2 rounds:
+ double tdiff0 = mclock0 - mclock1;
+ double tdiff1 = mclock1 - mclock2;
+ double averagetimediff = 0.0;
+
+ if (mclock1 != 0.0) {
+ if (storedtimediffs < 24)
+ {
+ timediff[storedtimediffs] = mclock0 - mclock1;
+ storedtimediffs++;
+ }
+ else {
+ for (int i=0; i<23; i++) {
+ timediff[i] = timediff[i+1];
+ }
+ timediff[23] = mclock0 - mclock1;
+ }
+ // Calculate average timediff:
+ for (int i=0; i < storedtimediffs; i++) {
+ averagetimediff += timediff[i]/storedtimediffs;
+ }
+ }
+
+ // Compare w audio if playing:
+ if (playStateExt == true ) { //audio->isPlaying() state == PLAY
+ //BEGIN standard setup:
+ recTick += config.division / 24; // The one we're syncing to
+ int tempo = tempomap.tempo(0);
+ unsigned curFrame = audio->pos().frame();
+ double songtick = (double(curFrame)/double(sampleRate)) *
+ double(config.division * 1000000.0) / double(tempo);
+
+ double scale = double(tdiff0/averagetimediff);
+ double tickdiff = songtick - ((double) recTick - 24 + scale*24.0);
+
+ //END standard setup
+ if (debugSync) {
+ int m, b, t;
+ audio->pos().mbt(&m, &b, &t);
+
+ int song_beat = b + m*4; // if the time-signature is different than 4/4, this will be wrong.
+ int sync_beat = recTick/config.division;
+ printf("pT=%.3f rT=%d diff=%.3f songB=%d syncB=%d scale=%.3f, curFrame=%d",
+ songtick, recTick, tickdiff, song_beat, sync_beat, scale, curFrame);
+ }
+
+ //if ((mclock2 !=0.0) && (tdiff1 > 0.0) && fabs(tickdiff) > 0.5 && lastTempo != 0) {
+ if ((mclock2 !=0.0) && (tdiff1 > 0.0) && lastTempo != 0) {
+ // Interpolate:
+ double tickdiff1 = songtick1 - recTick1;
+ double tickdiff2 = songtick2 - recTick2;
+ double newtickdiff = (tickdiff1+tickdiff2)/250;
+ //tickdiff/5.0 +
+ tickdiff1/16.0 +
+ tickdiff2/24.0; //5 mins 30 secs on 116BPM, -p 512 jackd
+
+ if (newtickdiff != 0.0) {
+ int newTempo = tempomap.tempo(0);
+ //newTempo += int(24.0 * newtickdiff * scale);
+ newTempo += int(24.0 * newtickdiff);
+ if (debugSync)
+ printf(" tdiff=%f ntd=%f lt=%d tmpo=%.3f",
+ tdiff0, newtickdiff, lastTempo, (float)((1000000.0 * 60.0)/newTempo));
+ //syncTempo = newTempo;
+ tempomap.setTempo(0,newTempo);
+ }
+ if (debugSync)
+ printf("\n");
+ }
+ else if (debugSync)
+ printf("\n");
+
+ //BEGIN post calc
+ lastTempo = tempo;
+ recTick2 = recTick1;
+ recTick1 = recTick;
+ mclock2 = mclock1;
+ mclock1 = mclock0;
+ songtick2 = songtick1;
+ songtick1 = songtick;
+ //END post calc
+ break;
+ } // END state play
+ //
+ // Pre-sync (when audio is not running)
+ // Calculate tempo depending on time per pulse
+ //
+ if (mclock1 == 0.0) {
+ mp->device()->discardInput();
+ if (debugSync)
+ printf("Discarding input from port %d\n", port);
+ }
+ if ((mclock2 != 0.0) && (tdiff0 > 0.0)) {
+ int tempo0 = int(24000000.0 * tdiff0 + .5);
+ int tempo1 = int(24000000.0 * tdiff1 + .5);
+ int tempo = tempomap.tempo(0);
+
+ int diff0 = tempo0 - tempo;
+ int diff1 = tempo1 - tempo0;
+ if (diff0) {
+ int newTempo = tempo + diff0/8 + diff1/16;
+ if (debugSync)
+ printf("setting new tempo %d = %f\n", newTempo, (float)((1000000.0 * 60.0)/newTempo));
+ tempomap.setTempo(0, newTempo);
+ }
+ }
+ mclock2 = mclock1;
+ mclock1 = mclock0;
+ */
+//END : Original Code
+
+//BEGIN : Using external tempo map:
+ /*
+ double mclock0 = curTime();
+ // Difference in time last 2 rounds:
+ double tdiff0 = mclock0 - mclock1;
+ double tdiff1 = mclock1 - mclock2;
+ double averagetimediff = 0.0;
+
+ if (mclock1 != 0.0) {
+ if (storedtimediffs < 24)
+ {
+ timediff[storedtimediffs] = mclock0 - mclock1;
+ storedtimediffs++;
+ }
+ else {
+ for (int i=0; i<23; i++) {
+ timediff[i] = timediff[i+1];
+ }
+ timediff[23] = mclock0 - mclock1;
+ }
+ // Calculate average timediff:
+ for (int i=0; i < storedtimediffs; i++) {
+ averagetimediff += timediff[i]/storedtimediffs;
+ }
+ }
+
+ // Compare w audio if playing:
+ //if (playStateExt == true ) { //audio->isPlaying() state == PLAY
+ if (0) {
+ //BEGIN standard setup:
+ recTick += config.division / 24; // The one we're syncing to
+ int tempo = tempomap.tempo(0);
+ //unsigned curFrame = audio->pos().frame();
+ //double songtick = (double(curFrame)/double(sampleRate)) *
+ // double(config.division * 1000000.0) / double(tempo);
+ double songtick = tempomap.curTickExt(mclock0);
+
+ double scale = double(tdiff0/averagetimediff);
+ double tickdiff = songtick - ((double) recTick - 24 + scale*24.0);
+
+ //END standard setup
+ if (debugSync) {
+ int m, b, t;
+ audio->pos().mbt(&m, &b, &t);
+
+ int song_beat = b + m*4; // if the time-signature is different than 4/4, this will be wrong.
+ int sync_beat = recTick/config.division;
+ printf("pT=%.3f rT=%d diff=%.3f songB=%d syncB=%d scale=%.3f, curFrame=%d averagetimediff:%.3lf",
+ songtick, recTick, tickdiff, song_beat, sync_beat, scale, audio->pos().frame(), averagetimediff);
+ }
+
+ //if ((mclock2 !=0.0) && (tdiff1 > 0.0) && fabs(tickdiff) > 0.5 && lastTempo != 0) {
+ if ((mclock2 !=0.0) && (tdiff1 > 0.0) && lastTempo != 0) {
+ // Interpolate:
+ double tickdiff1 = songtick1 - recTick1;
+ double tickdiff2 = songtick2 - recTick2;
+ double newtickdiff = (tickdiff1+tickdiff2)/250;
+ ////double newtickdiff = (tickdiff1+tickdiff2) / 10.0;
+ //double newtickdiff = tickdiff/5.0 +
+ // tickdiff1/16.0 +
+ // tickdiff2/24.0; //5 mins 30 secs on 116BPM, -p 512 jackd
+
+ if (newtickdiff != 0.0) {
+ //int newTempo = tempomap.tempo(0);
+ int newTempo = tempo;
+ //newTempo += int(24.0 * newtickdiff * scale);
+ newTempo += int(24.0 * newtickdiff);
+ if (debugSync)
+ printf(" tdiff=%f ntd=%f lt=%d tmpo=%.3f",
+ tdiff0, newtickdiff, lastTempo, (float)((1000000.0 * 60.0)/newTempo));
+ //syncTempo = newTempo;
+ //tempomap.setTempo(0,newTempo);
+ // Don't set the last stable tempo.
+ //tempomap.setTempo(0, newTempo, false);
+ tempomap.setExtTempo(newTempo);
+ }
+ if (debugSync)
+ printf("\n");
+ }
+ else if (debugSync)
+ printf("\n");
+
+ //BEGIN post calc
+ lastTempo = tempo;
+ recTick2 = recTick1;
+ recTick1 = recTick;
+ mclock2 = mclock1;
+ mclock1 = mclock0;
+ songtick2 = songtick1;
+ songtick1 = songtick;
+ //END post calc
+ break;
+ } // END state play
+ //
+ // Pre-sync (when audio is not running)
+ // Calculate tempo depending on time per pulse
+ //
+ if (mclock1 == 0.0) {
+ mp->device()->discardInput();
+ if (debugSync)
+ printf("Discarding input from port %d\n", port);
+ }
+ if ((mclock2 != 0.0) && (tdiff0 > 0.0)) {
+
+ //int tempo0 = int(24000000.0 * tdiff0 + .5);
+ //int tempo1 = int(24000000.0 * tdiff1 + .5);
+ //int tempo = tempomap.tempo(0);
+ //int diff0 = tempo0 - tempo;
+ //int diff1 = tempo1 - tempo0;
+
+ //if (diff0) {
+ // int newTempo = tempo + diff0/8 + diff1/16;
+ // if (debugSync)
+ // printf("setting new tempo %d = %f\n", newTempo, (float)((1000000.0 * 60.0)/newTempo));
+ //tempomap.setTempo(0, newTempo);
+ // Don't set the last stable tempo.
+ //tempomap.setTempo(0, newTempo, false);
+ // tempomap.setExtTempo(newTempo);
+ // }
+
+ //double tempo0 = 24000000.0 * tdiff0;
+ //double tempo1 = 24000000.0 * tdiff1;
+ //int newTempo = int((tempo0 + tempo1) / 2.0);
+ int newTempo = int(averagetimediff * 24000000.0);
+ if(debugSync)
+ printf("setting new tempo %d = %f\n", newTempo, (float)((1000000.0 * 60.0)/newTempo));
+ tempomap.setExtTempo(newTempo);
+ }
+
+ mclock2 = mclock1;
+ mclock1 = mclock0;
+ */
+//END : Using external tempo map
+
+ }
+ break;
+ case ME_TICK: // midi tick (every 10 msec)
+ // FIXME: Unfinished? mcStartTick is uninitialized and Song::setPos doesn't set it either. Dangerous to allow this.
+ //if (mcStart) {
+ // song->setPos(0, mcStartTick);
+ // mcStart = false;
+ // return;
+ // }
+ break;
+ case ME_START: // start
+ // Re-transmit start to other devices if clock out turned on.
+ for(int p = 0; p < MIDI_PORTS; ++p)
+ //if(p != port && midiPorts[p].syncInfo().MCOut())
+ if(p != port && midiPorts[p].syncInfo().MRTOut())
+ {
+ // p3.3.31
+ // If we aren't rewinding on start, there's no point in re-sending start.
+ // Re-send continue instead, for consistency.
+ if(midiPorts[port].syncInfo().recRewOnStart())
+ midiPorts[p].sendStart();
+ else
+ midiPorts[p].sendContinue();
+ }
+ if (debugSync)
+ printf(" start\n");
+
+ // p3.3.31
+ //printf("midi start:%f\n", curTime());
+
+ if (1 /* !audio->isPlaying()*/ /*state == IDLE*/) {
+ if (!checkAudioDevice()) return;
+
+ // p3.3.31
+ // Rew on start option.
+ if(midiPorts[port].syncInfo().recRewOnStart())
+ {
+ curExtMidiSyncTick = 0;
+ lastExtMidiSyncTick = curExtMidiSyncTick;
+ //audioDevice->seekTransport(0);
+ audioDevice->seekTransport(Pos(0, false));
+ }
+
+ //unsigned curFrame = audio->curFrame();
+ //if (debugSync)
+ // printf(" curFrame=%d\n", curFrame);
+
+ alignAllTicks();
+ //if (debugSync)
+ // printf(" curFrame: %d curTick: %d tempo: %d\n", curFrame, recTick, tempomap.tempo(0));
+
+ storedtimediffs = 0;
+ for (int i=0; i<24; i++)
+ timediff[i] = 0.0;
+
+ // p3.3.26 1/23/10
+ // Changed because msgPlay calls audioDevice->seekTransport(song->cPos())
+ // and song->cPos() may not be changed to 0 yet, causing tranport not to go to 0.
+ //audio->msgPlay(true);
+ //audioDevice->startTransport();
+ // p3.3.28
+ playPendingFirstClock = true;
+
+ midiExtSyncTicks = 0;
+ playStateExt = true;
+ }
+ break;
+ case ME_CONTINUE: // continue
+ // Re-transmit continue to other devices if clock out turned on.
+ for(int p = 0; p < MIDI_PORTS; ++p)
+ //if(p != port && midiPorts[p].syncInfo().MCOut())
+ if(p != port && midiPorts[p].syncInfo().MRTOut())
+ midiPorts[p].sendContinue();
+
+ if (debugSync)
+ printf("realtimeSystemInput continue\n");
+
+ // p3.3.31
+ //printf("continue:%f\n", curTime());
+
+ if (1 /* !audio->isPlaying() */ /*state == IDLE */) {
+ //unsigned curFrame = audio->curFrame();
+ //recTick = tempomap.frame2tick(curFrame); // don't think this will work... (ml)
+ //alignAllTicks();
+
+ // p3.3.28
+ //audio->msgPlay(true);
+ // p3.3.31
+ // Begin incrementing immediately upon first clock reception.
+ playPendingFirstClock = true;
+
+ playStateExt = true;
+ }
+ break;
+ case ME_STOP: // stop
+ {
+ // p3.3.35
+ // Stop the increment right away.
+ midiExtSyncTicks = 0;
+ playStateExt = false;
+ playPendingFirstClock = false;
+
+ // Re-transmit stop to other devices if clock out turned on.
+ for(int p = 0; p < MIDI_PORTS; ++p)
+ //if(p != port && midiPorts[p].syncInfo().MCOut())
+ if(p != port && midiPorts[p].syncInfo().MRTOut())
+ midiPorts[p].sendStop();
+
+ //playPendingFirstClock = false;
+
+ //lastStoppedBeat = (audio->tickPos() * 4) / config.division;
+ //curExtMidiSyncTick = (config.division * lastStoppedBeat) / 4;
+
+ // p3.3.31
+ //printf("stop:%f\n", curTime());
+
+ if (audio->isPlaying() /*state == PLAY*/) {
+ audio->msgPlay(false);
+ //playStateExt = false;
+ }
+
+ if (debugSync)
+ printf("realtimeSystemInput stop\n");
+
+ // Just in case the process still runs a cycle or two and causes the
+ // audio tick position to increment, reset the incrementer and force
+ // the transport position to what the hardware thinks is the current position.
+ //midiExtSyncTicks = 0;
+ //Pos pos((config.division * lastStoppedBeat) / 4, true);
+ //Pos pos(curExtMidiSyncTick, true);
+ //audioDevice->seekTransport(pos);
+ }
+
+ break;
+ //case 0xfd: // unknown
+ //case ME_SENSE: // active sensing
+ //case ME_META: // system reset (reset is 0xff same enumeration as file meta event)
+ default:
+ break;
+ }
+
+ }
+
+//---------------------------------------------------------
+// mtcSyncMsg
+// process received mtc Sync
+// seekFlag - first complete mtc frame received after
+// start
+//---------------------------------------------------------
+
+void MidiSeq::mtcSyncMsg(const MTC& mtc, int type, bool seekFlag)
+ {
+ double time = mtc.time();
+ double stime = mtc.time(type);
+ if (debugSync)
+ printf("MidiSeq::mtcSyncMsg time:%lf stime:%lf seekFlag:%d\n", time, stime, seekFlag);
+
+ if (seekFlag && audio->isRunning() /*state == START_PLAY*/) {
+// int tick = tempomap.time2tick(time);
+ //state = PLAY;
+ //write(sigFd, "1", 1); // say PLAY to gui
+ if (!checkAudioDevice()) return;
+ if (debugSync)
+ printf("MidiSeq::mtcSyncMsg starting transport.\n");
+ audioDevice->startTransport();
+ return;
+ }
+
+ /*if (tempoSN != tempomap.tempoSN()) {
+ double cpos = tempomap.tick2time(_midiTick, 0);
+ samplePosStart = samplePos - lrint(cpos * sampleRate);
+ rtcTickStart = rtcTick - lrint(cpos * realRtcTicks);
+ tempoSN = tempomap.tempoSN();
+ }*/
+
+ //
+ // diff is the time in sec MusE is out of sync
+ //
+ /*double diff = time - (double(samplePosStart)/double(sampleRate));
+ if (debugSync)
+ printf(" state %d diff %f\n", mtcState, diff);
+ */
+ }
+
+
diff --git a/attic/muse2-oom/muse2/muse/sync.h b/attic/muse2-oom/muse2/muse/sync.h
new file mode 100644
index 00000000..47acece8
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/sync.h
@@ -0,0 +1,154 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: sync.h,v 1.1.1.1.2.2 2009/04/01 01:37:11 terminator356 Exp $
+//
+// (C) Copyright 2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SYNC_H__
+#define __SYNC_H__
+
+#include "mtc.h"
+#include "value.h"
+#include "globaldefs.h"
+
+class Xml;
+//class MidiDevice;
+
+//class MidiSyncPort
+class MidiSyncInfo
+{
+ private:
+ int _port;
+
+ int _idOut;
+ int _idIn;
+
+ bool _sendMC;
+ bool _sendMRT;
+ bool _sendMMC;
+ bool _sendMTC;
+ bool _recMC;
+ bool _recMRT;
+ bool _recMMC;
+ bool _recMTC;
+
+ int _recMTCtype;
+
+ bool _recRewOnStart;
+ //bool _sendContNotStart;
+
+ double _lastClkTime;
+ double _lastTickTime;
+ double _lastMRTTime;
+ double _lastMMCTime;
+ double _lastMTCTime;
+ double _lastActTime[MIDI_CHANNELS];
+ bool _clockTrig;
+ bool _tickTrig;
+ bool _MRTTrig;
+ bool _MMCTrig;
+ bool _MTCTrig;
+ bool _actTrig[MIDI_CHANNELS];
+ bool _clockDetect;
+ bool _tickDetect;
+ bool _MRTDetect;
+ bool _MMCDetect;
+ bool _MTCDetect;
+ bool _actDetect[MIDI_CHANNELS];
+ int _actDetectBits;
+
+ public:
+ MidiSyncInfo();
+ MidiSyncInfo& operator= (const MidiSyncInfo &sp);
+ MidiSyncInfo& copyParams(const MidiSyncInfo &sp);
+
+ int port() const { return _port; }
+ void setPort(const int p) { _port = p; }
+
+ int idOut() const { return _idOut; }
+ int idIn() const { return _idIn; }
+ void setIdOut(const int v) { _idOut = v; }
+ void setIdIn(const int v) { _idIn = v; }
+
+ bool MCOut() const { return _sendMC; }
+ bool MRTOut() const { return _sendMRT; }
+ bool MMCOut() const { return _sendMMC; }
+ bool MTCOut() const { return _sendMTC; }
+
+ bool MCIn() const { return _recMC; }
+ bool MRTIn() const { return _recMRT; }
+ bool MMCIn() const { return _recMMC; }
+ bool MTCIn() const { return _recMTC; }
+
+ void setMCOut(const bool v) { _sendMC = v; }
+ void setMRTOut(const bool v) { _sendMRT = v; }
+ void setMMCOut(const bool v) { _sendMMC = v; }
+ void setMTCOut(const bool v) { _sendMTC = v; }
+
+ void setMCIn(const bool v);
+ void setMRTIn(const bool v);
+ void setMMCIn(const bool v);
+ void setMTCIn(const bool v);
+
+ void setTime();
+
+ bool recRewOnStart() const { return _recRewOnStart; }
+ void setRecRewOnStart(const bool v) { _recRewOnStart = v; }
+ //bool sendContNotStart() const { return _sendContNotStart; }
+ //void setSendContNotStart(const bool v) { _sendContNotStart = v; }
+
+ bool MCSyncDetect() const { return _clockDetect; }
+ void trigMCSyncDetect();
+
+ bool tickDetect() const { return _tickDetect; }
+ void trigTickDetect();
+
+ bool MTCDetect() const { return _MTCDetect; }
+ void trigMTCDetect();
+ int recMTCtype() const { return _recMTCtype; }
+ void setRecMTCtype(int t) { _recMTCtype = t; }
+
+ bool MRTDetect() const { return _MRTDetect; }
+ void trigMRTDetect();
+
+ bool MMCDetect() const { return _MMCDetect; }
+ void trigMMCDetect();
+
+ int actDetectBits() const { return _actDetectBits; }
+ bool actDetect(const int ch) const;
+ void trigActDetect(const int ch);
+
+ bool isDefault() const;
+ void read(Xml& xml);
+ //void write(int level, Xml& xml, MidiDevice* md);
+ void write(int level, Xml& xml);
+};
+
+//extern MidiSync midiSyncPorts[MIDI_PORTS];
+
+extern bool debugSync;
+
+//extern int rxSyncPort;
+//extern int txSyncPort;
+//extern int rxDeviceId;
+//extern int txDeviceId;
+
+extern int mtcType;
+extern MTC mtcOffset;
+extern BValue extSyncFlag;
+//extern bool genMTCSync; // output MTC Sync
+//extern bool genMCSync; // output MidiClock Sync
+//extern bool genMMC; // output Midi Machine Control
+//extern bool acceptMTC;
+//extern bool acceptMC;
+//extern bool acceptMMC;
+extern int volatile curMidiSyncInPort;
+extern BValue useJackTransport;
+extern bool volatile jackTransportMaster;
+extern unsigned int syncSendFirstClockDelay; // In milliseconds.
+
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/synth.cpp b/attic/muse2-oom/muse2/muse/synth.cpp
new file mode 100644
index 00000000..defcd02e
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/synth.cpp
@@ -0,0 +1,953 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: synth.cpp,v 1.43.2.23 2009/12/15 03:39:58 terminator356 Exp $
+// (C) Copyright 2000-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "config.h"
+#include <sys/wait.h>
+#include <signal.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/mman.h>
+#include <vector>
+#include <fcntl.h>
+#include <dlfcn.h>
+
+#include <QDir>
+#include <QMenu>
+
+#include "app.h"
+#include "synth.h"
+#include "xml.h"
+#include "midi.h"
+#include "midiport.h"
+#include "mididev.h"
+//#include "libsynti/mess.h"
+#include "synti/libsynti/mess.h" // p4.0.2
+#include "song.h"
+#include "audio.h"
+#include "event.h"
+#include "mpevent.h"
+#include "audio.h"
+#include "midiseq.h"
+#include "midictrl.h"
+//#include "stringparam.h"
+
+std::vector<Synth*> synthis; // array of available synthis
+
+extern void connectNodes(AudioTrack*, AudioTrack*);
+
+/*
+//---------------------------------------------------------
+// description
+//---------------------------------------------------------
+
+const char* MessSynth::description() const
+ {
+ return _descr ? _descr->description : "";
+ }
+
+//---------------------------------------------------------
+// version
+//---------------------------------------------------------
+
+const char* MessSynth::version() const
+ {
+ return _descr ? _descr->version : "";
+ }
+*/
+
+bool MessSynthIF::guiVisible() const
+ {
+ return _mess ? _mess->guiVisible() : false;
+ }
+
+void MessSynthIF::showGui(bool v)
+ {
+ if (v == guiVisible())
+ return;
+ if (_mess)
+ _mess->showGui(v);
+ }
+
+bool MessSynthIF::hasGui() const
+ {
+ if (_mess)
+ return _mess->hasGui();
+ return false;
+ }
+
+MidiPlayEvent MessSynthIF::receiveEvent()
+ {
+ if (_mess)
+ return _mess->receiveEvent();
+ return MidiPlayEvent();
+ }
+
+int MessSynthIF::eventsPending() const
+ {
+ if (_mess)
+ return _mess->eventsPending();
+ return 0;
+ }
+
+void MessSynthIF::getGeometry(int* x, int* y, int* w, int* h) const
+ {
+ if (_mess)
+ _mess->getGeometry(x, y, w, h);
+ }
+
+void MessSynthIF::setGeometry(int x, int y, int w, int h)
+ {
+ if (_mess)
+ _mess->setGeometry(x, y, w, h);
+ }
+
+//---------------------------------------------------------
+// findSynth
+// search for synthesizer base class
+//---------------------------------------------------------
+
+//static Synth* findSynth(const QString& sclass)
+static Synth* findSynth(const QString& sclass, const QString& label)
+ {
+ for (std::vector<Synth*>::iterator i = synthis.begin();
+ i != synthis.end(); ++i)
+ {
+ //if ((*i)->baseName() == sclass)
+ //if ((*i)->name() == sclass)
+ if ( ((*i)->baseName() == sclass) && (label.isEmpty() || ((*i)->name() == label)) )
+
+ return *i;
+ }
+ printf("synthi class:%s label:%s not found\n", sclass.toLatin1().constData(), label.toLatin1().constData());
+ return 0;
+ }
+
+//---------------------------------------------------------
+// createSynthInstance
+// create a synthesizer instance of class "label"
+//---------------------------------------------------------
+
+//static SynthI* createSynthI(const QString& sclass)
+static SynthI* createSynthInstance(const QString& sclass, const QString& label)
+ {
+ //Synth* s = findSynth(sclass);
+ Synth* s = findSynth(sclass, label);
+ SynthI* si = 0;
+ if (s) {
+ si = new SynthI();
+ QString n;
+ n.setNum(s->instances());
+ //QString instance_name = s->baseName() + "-" + n;
+ QString instance_name = s->name() + "-" + n;
+
+ if (si->initInstance(s, instance_name)) {
+ delete si;
+ return 0;
+ }
+ }
+ else
+ printf("createSynthInstance: synthi class:%s label:%s not found\n", sclass.toLatin1().constData(), label.toLatin1().constData());
+ return si;
+ }
+
+//---------------------------------------------------------
+// Synth
+//---------------------------------------------------------
+
+//Synth::Synth(const QFileInfo& fi)
+// : info(fi)
+//Synth::Synth(const QFileInfo& fi, QString label)
+// : info(fi), _name(label)
+Synth::Synth(const QFileInfo& fi, QString label, QString descr, QString maker, QString ver)
+ : info(fi), _name(label), _description(descr), _maker(maker), _version(ver)
+ {
+ _instances = 0;
+ }
+
+//---------------------------------------------------------
+// instantiate
+//---------------------------------------------------------
+
+//void* MessSynth::instantiate()
+void* MessSynth::instantiate(const QString& instanceName)
+ {
+ ++_instances;
+
+ //QString n;
+ //n.setNum(_instances);
+ //QString instanceName = baseName() + "-" + n;
+
+ doSetuid();
+ QByteArray ba = info.filePath().toLatin1();
+ const char* path = ba.constData();
+
+ // load Synti dll
+ void* handle = dlopen(path, RTLD_NOW);
+ if (handle == 0) {
+ fprintf(stderr, "Synth::instantiate: dlopen(%s) failed: %s\n",
+ path, dlerror());
+ undoSetuid();
+ return 0;
+ }
+ typedef const MESS* (*MESS_Function)();
+ MESS_Function msynth = (MESS_Function)dlsym(handle, "mess_descriptor");
+
+ if (!msynth) {
+ const char *txt = dlerror();
+ if (txt) {
+ fprintf(stderr,
+ "Unable to find msynth_descriptor() function in plugin "
+ "library file \"%s\": %s.\n"
+ "Are you sure this is a MESS plugin file?\n",
+ info.filePath().toAscii().constData(), txt);
+ undoSetuid();
+ return 0;
+ }
+ }
+ _descr = msynth();
+ if (_descr == 0) {
+ fprintf(stderr, "Synth::instantiate: no MESS descr found\n");
+ undoSetuid();
+ return 0;
+ }
+ Mess* mess = _descr->instantiate(sampleRate, muse, &museProject, instanceName.toLatin1().constData());
+ undoSetuid();
+ return mess;
+ }
+
+//---------------------------------------------------------
+// SynthI
+//---------------------------------------------------------
+
+SynthI::SynthI()
+ : AudioTrack(AUDIO_SOFTSYNTH)
+ {
+ synthesizer = 0;
+ _sif = 0;
+ _rwFlags = 1;
+ _openFlags = 1;
+ _readEnable = false;
+ _writeEnable = false;
+
+ _curBankH = 0;
+ _curBankL = 0;
+ _curProgram = 0;
+
+ setVolume(1.0);
+ setPan(0.0);
+ }
+
+//---------------------------------------------------------
+// open
+//---------------------------------------------------------
+
+QString SynthI::open()
+{
+ // Make it behave like a regular midi device.
+ _readEnable = false;
+ _writeEnable = (_openFlags & 0x01);
+
+ return QString("OK");
+}
+
+//---------------------------------------------------------
+// close
+//---------------------------------------------------------
+
+void SynthI::close()
+{
+ _readEnable = false;
+ _writeEnable = false;
+}
+
+//---------------------------------------------------------
+// putMidiEvent
+//---------------------------------------------------------
+
+bool SynthI::putEvent(const MidiPlayEvent& ev)
+//bool SynthI::putMidiEvent(const MidiPlayEvent& ev)
+{
+ if(_writeEnable)
+ return _sif->putEvent(ev);
+
+ // Hmm, act as if the event went through?
+ //return true;
+ return false;
+}
+
+//---------------------------------------------------------
+// setName
+//---------------------------------------------------------
+
+void SynthI::setName(const QString& s)
+ {
+ AudioTrack::setName(s);
+ MidiDevice::setName(s);
+ }
+
+//---------------------------------------------------------
+// currentProg
+//---------------------------------------------------------
+
+void SynthI::currentProg(unsigned long *prog, unsigned long *bankL, unsigned long *bankH)
+{
+ if(prog)
+ *prog = _curProgram;
+ if(bankL)
+ *bankL = _curBankL;
+ if(bankH)
+ *bankH = _curBankH;
+}
+
+//---------------------------------------------------------
+// init
+//---------------------------------------------------------
+
+//bool MessSynthIF::init(Synth* s)
+bool MessSynthIF::init(Synth* s, SynthI* si)
+ {
+ //_mess = (Mess*)s->instantiate();
+ _mess = (Mess*)((MessSynth*)s)->instantiate(si->name());
+
+ return (_mess == 0);
+ }
+
+int MessSynthIF::channels() const
+ {
+ return _mess->channels();
+ }
+
+int MessSynthIF::totalOutChannels() const
+ {
+ return _mess->channels();
+ }
+
+int MessSynthIF::totalInChannels() const
+ {
+ return 0;
+ }
+
+//SynthIF* MessSynth::createSIF() const
+SynthIF* MessSynth::createSIF(SynthI* si)
+ {
+ //return new MessSynthIF(si);
+
+ MessSynthIF* sif = new MessSynthIF(si);
+ sif->init(this, si);
+ return sif;
+ }
+
+//---------------------------------------------------------
+// initInstance
+// returns false on success
+//---------------------------------------------------------
+
+bool SynthI::initInstance(Synth* s, const QString& instanceName)
+ {
+ synthesizer = s;
+ //sif = s->createSIF();
+ //_sif = s->createSIF(this);
+
+ //sif->init(s);
+
+ setName(instanceName); // set midi device name
+ setIName(instanceName); // set instrument name
+ _sif = s->createSIF(this);
+
+ // p3.3.38
+ //AudioTrack::setChannels(_sif->channels());
+ AudioTrack::setTotalOutChannels(_sif->totalOutChannels());
+ AudioTrack::setTotalInChannels(_sif->totalInChannels());
+
+ //---------------------------------------------------
+ // read available controller from synti
+ //---------------------------------------------------
+
+ int id = 0;
+ MidiControllerList* cl = MidiInstrument::controller();
+ for (;;) {
+ const char* name;
+ int ctrl;
+ int min;
+ int max;
+ int initval = CTRL_VAL_UNKNOWN;
+ id = _sif->getControllerInfo(id, &name, &ctrl, &min, &max, &initval);
+// printf("looking for params\n");
+ if (id == 0)
+ break;
+// printf("got parameter:: %s\n", name);
+
+
+ // Added by T356. Override existing program controller.
+ iMidiController i = cl->end();
+ if(ctrl == CTRL_PROGRAM)
+ {
+ for(i = cl->begin(); i != cl->end(); ++i)
+ {
+ if(i->second->num() == CTRL_PROGRAM)
+ {
+ delete i->second;
+ cl->erase(i);
+
+ break;
+ }
+ }
+ }
+
+ MidiController* c = new MidiController(QString(name), ctrl, min, max, initval);
+ cl->add(c);
+ }
+
+ EventList* iel = midiState();
+ if (!iel->empty()) {
+ for (iEvent i = iel->begin(); i != iel->end(); ++i) {
+ Event ev = i->second;
+ MidiPlayEvent pev(0, 0, 0, ev);
+ if (_sif->putEvent(pev))
+ break; // try later
+ }
+ iel->clear();
+ }
+
+ unsigned long idx = 0;
+ for (std::vector<float>::iterator i = initParams.begin(); i != initParams.end(); ++i, ++idx)
+ _sif->setParameter(idx, *i);
+
+ // p3.3.40 Since we are done with the (sometimes huge) initial parameters list, clear it.
+ // TODO: Decide: Maybe keep them around for a 'reset to previously loaded values' (revert) command? ...
+ initParams.clear();
+
+ return false;
+ }
+
+//---------------------------------------------------------
+// getControllerInfo
+//---------------------------------------------------------
+
+int MessSynthIF::getControllerInfo(int id, const char** name, int* ctrl, int* min, int* max, int* initval)
+ {
+ return _mess->getControllerInfo(id, name, ctrl, min, max, initval);
+ }
+
+//---------------------------------------------------------
+// SynthI::deactivate
+//---------------------------------------------------------
+
+void SynthI::deactivate2()
+ {
+ removeMidiInstrument(this);
+ midiDevices.remove(this);
+ if (midiPort() != -1) {
+ // synthi is attached
+ midiPorts[midiPort()].setMidiDevice(0);
+ }
+ }
+//---------------------------------------------------------
+// deactivate3
+//---------------------------------------------------------
+
+void SynthI::deactivate3()
+ {
+ _sif->deactivate3();
+ // Moved below by Tim. p3.3.14
+ //synthesizer->incInstances(-1);
+
+ if(debugMsg)
+ printf("SynthI::deactivate3 deleting _sif...\n");
+
+ delete _sif;
+ _sif = 0;
+
+ if(debugMsg)
+ printf("SynthI::deactivate3 decrementing synth instances...\n");
+
+ synthesizer->incInstances(-1);
+ }
+
+void MessSynthIF::deactivate3()
+ {
+ if (_mess) {
+ delete _mess;
+ _mess = 0;
+ }
+ }
+
+//---------------------------------------------------------
+// ~SynthI
+//---------------------------------------------------------
+
+SynthI::~SynthI()
+ {
+ deactivate2();
+ deactivate3();
+ }
+
+//---------------------------------------------------------
+// initMidiSynth
+// search for software synthis and advertise
+//---------------------------------------------------------
+
+void initMidiSynth()
+ {
+ QString s = museGlobalLib + "/synthi";
+
+ QDir pluginDir(s, QString("*.so")); // ddskrjo
+ if (debugMsg)
+ printf("searching for software synthesizer in <%s>\n", s.toLatin1().constData());
+ if (pluginDir.exists()) {
+ QFileInfoList list = pluginDir.entryInfoList();
+ QFileInfoList::iterator it=list.begin();
+ QFileInfo* fi;
+ while(it!=list.end()) {
+ fi = &*it;
+
+ //doSetuid();
+ QByteArray ba = fi->filePath().toLatin1();
+ const char* path = ba.constData();
+
+ // load Synti dll
+ //printf("initMidiSynth: dlopen file:%s name:%s desc:%s\n", fi->filePath().toLatin1().constData(), QString(descr->name), QString(descr->description), QString(""), QString(descr->version)));
+ void* handle = dlopen(path, RTLD_NOW);
+ if (handle == 0) {
+ fprintf(stderr, "initMidiSynth: MESS dlopen(%s) failed: %s\n", path, dlerror());
+ //undoSetuid();
+ //return 0;
+ ++it;
+ continue;
+ }
+ typedef const MESS* (*MESS_Function)();
+ MESS_Function msynth = (MESS_Function)dlsym(handle, "mess_descriptor");
+
+ if (!msynth) {
+ #if 1
+ const char *txt = dlerror();
+ if (txt) {
+ fprintf(stderr,
+ "Unable to find msynth_descriptor() function in plugin "
+ "library file \"%s\": %s.\n"
+ "Are you sure this is a MESS plugin file?\n",
+ path, txt);
+ //undoSetuid();
+ //return 0;
+ }
+ #endif
+ dlclose(handle);
+ ++it;
+ continue;
+ }
+ const MESS* descr = msynth();
+ if (descr == 0) {
+ fprintf(stderr, "initMidiSynth: no MESS descr found in %s\n", path);
+ //undoSetuid();
+ //return 0;
+ dlclose(handle);
+ ++it;
+ continue;
+ }
+ //Mess* mess = descr->instantiate(sampleRate, muse, &museProject, instanceName.toLatin1().constData());
+ //undoSetuid();
+
+
+
+
+ //synthis.push_back(new MessSynth(*fi));
+ synthis.push_back(new MessSynth(*fi, QString(descr->name), QString(descr->description), QString(""), QString(descr->version)));
+
+ dlclose(handle);
+ ++it;
+ }
+ if (debugMsg)
+ printf("%zd soft synth found\n", synthis.size());
+ }
+ }
+
+//---------------------------------------------------------
+// createSynthI
+// create a synthesizer instance of class "label"
+//---------------------------------------------------------
+
+//SynthI* Song::createSynthI(const QString& sclass)
+SynthI* Song::createSynthI(const QString& sclass, const QString& label)
+ {
+ //printf("Song::createSynthI calling ::createSynthI class:%s\n", sclass.toLatin1().constData());
+
+ //SynthI* si = ::createSynthI(sclass);
+ //SynthI* si = ::createSynthI(sclass, label);
+ SynthI* si = createSynthInstance(sclass, label);
+ if(!si)
+ return 0;
+ //printf("Song::createSynthI created SynthI. Before insertTrack1...\n");
+
+ insertTrack1(si, -1);
+ //printf("Song::createSynthI after insertTrack1. Before msgInsertTrack...\n");
+
+ msgInsertTrack(si, -1, true); // add to instance list
+ //printf("Song::createSynthI after msgInsertTrack. Before insertTrack3...\n");
+
+ insertTrack3(si, -1);
+
+ //printf("Song::createSynthI after insertTrack3. Adding default routes...\n");
+
+ OutputList* ol = song->outputs();
+ // add default route to master (first audio output)
+ if (!ol->empty()) {
+ AudioOutput* ao = ol->front();
+ // p3.3.38
+ //audio->msgAddRoute(Route(si, -1), Route(ao, -1));
+ //audio->msgAddRoute(Route((AudioTrack*)si, -1), Route(ao, -1));
+ // Make sure the route channel and channels are valid.
+ audio->msgAddRoute(Route((AudioTrack*)si, 0, ((AudioTrack*)si)->channels()), Route(ao, 0, ((AudioTrack*)si)->channels()));
+
+ audio->msgUpdateSoloStates();
+ }
+
+ // Now that the track has been added to the lists in insertTrack2(),
+ // if it's a dssi synth, OSC can find the synth, and initialize (and show) its native gui.
+ // No, initializing OSC without actually showing the gui doesn't work, at least for
+ // dssi-vst plugins - without showing the gui they exit after ten seconds.
+ //si->initGui();
+
+ return si;
+ }
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+void SynthI::write(int level, Xml& xml) const
+ {
+ xml.tag(level++, "SynthI");
+ AudioTrack::writeProperties(level, xml);
+ xml.strTag(level, "class", synth()->baseName());
+
+ // To support plugins like dssi-vst where all the baseNames are the same 'dssi-vst' and the label is the name of the dll file.
+ // Added by Tim. p3.3.16
+ xml.strTag(level, "label", synth()->name());
+
+ //---------------------------------------------
+ // if soft synth is attached to a midi port,
+ // write out port number
+ //---------------------------------------------
+
+ if (midiPort() != -1)
+ xml.intTag(level, "port", midiPort());
+
+ if (hasGui()) {
+ xml.intTag(level, "guiVisible", guiVisible());
+ int x, y, w, h;
+ w = 0;
+ h = 0;
+ getGeometry(&x, &y, &w, &h);
+ if (h || w)
+ xml.qrectTag(level, "geometry", QRect(x, y, w, h));
+ }
+
+ _stringParamMap.write(level, xml, "stringParam");
+
+ xml.tag(level, "curProgram bankH=\"%ld\" bankL=\"%ld\" prog=\"%ld\"/", _curBankH, _curBankL, _curProgram);
+
+ _sif->write(level, xml);
+ xml.etag(level, "SynthI");
+ }
+
+void MessSynthIF::write(int level, Xml& xml) const
+ {
+ //---------------------------------------------
+ // dump current state of synth
+ //---------------------------------------------
+
+ int len = 0;
+ const unsigned char* p;
+ _mess->getInitData(&len, &p);
+ if (len) {
+ xml.tag(level++, "midistate");
+ xml.nput(level++, "<event type=\"%d\"", Sysex);
+ xml.nput(" datalen=\"%d\">\n", len);
+ xml.nput(level, "");
+ for (int i = 0; i < len; ++i) {
+ if (i && ((i % 16) == 0)) {
+ xml.nput("\n");
+ xml.nput(level, "");
+ }
+ xml.nput("%02x ", p[i] & 0xff);
+ }
+ xml.nput("\n");
+ xml.tag(level--, "/event");
+ xml.etag(level--, "midistate");
+ }
+ }
+
+//---------------------------------------------------------
+// SynthI::readProgram
+//---------------------------------------------------------
+
+void SynthI::readProgram(Xml& xml, const QString& name)
+{
+ for (;;)
+ {
+ Xml::Token token = xml.parse();
+ const QString tag = xml.s1();
+ switch (token)
+ {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ xml.unknown(name.toAscii().constData());
+ break;
+ case Xml::Attribut:
+ if(tag == "bankH")
+ _curBankH = xml.s2().toUInt();
+ else
+ if(tag == "bankL")
+ _curBankL = xml.s2().toUInt();
+ else
+ if(tag == "prog")
+ _curProgram = xml.s2().toUInt();
+ else
+ xml.unknown(name.toAscii().constData());
+ break;
+ case Xml::TagEnd:
+ if(tag == name)
+ return;
+ default:
+ break;
+ }
+ }
+}
+
+//---------------------------------------------------------
+// SynthI::read
+//---------------------------------------------------------
+
+void SynthI::read(Xml& xml)
+ {
+ QString sclass;
+ QString label;
+
+ int port = -1;
+ bool startgui = false;
+ QRect r;
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "class")
+ sclass = xml.parse1();
+ else if (tag == "label")
+ label = xml.parse1();
+ else if (tag == "port")
+ port = xml.parseInt();
+ else if (tag == "guiVisible")
+ startgui = xml.parseInt();
+ else if (tag == "midistate")
+ readMidiState(xml);
+ else if (tag == "param") {
+ float val = xml.parseFloat();
+ initParams.push_back(val);
+ }
+ else if (tag == "stringParam")
+ _stringParamMap.read(xml, tag);
+ else if (tag == "curProgram")
+ readProgram(xml, tag);
+ else if (tag == "geometry")
+ r = readGeometry(xml, tag);
+ else if (AudioTrack::readProperties(xml, tag))
+ xml.unknown("softSynth");
+ break;
+ case Xml::TagEnd:
+ if (tag == "SynthI") {
+ //Synth* s = findSynth(sclass);
+ Synth* s = findSynth(sclass, label);
+ if (s == 0)
+ return;
+ if (initInstance(s, name()))
+ return;
+ song->insertTrack0(this, -1);
+ if (port != -1 && port < MIDI_PORTS)
+ midiPorts[port].setMidiDevice(this);
+
+ // Now that the track has been added to the lists in insertTrack2(),
+ // if it's a dssi synth, OSC can find the synth, and initialize (and show) its native gui.
+ // No, initializing OSC without actually showing the gui doesn't work, at least for
+ // dssi-vst plugins - without showing the gui they exit after ten seconds.
+ //initGui();
+ showGui(startgui);
+ setGeometry(r.x(), r.y(), r.width(), r.height());
+
+ mapRackPluginsToControllers();
+
+ // Now that the track has been added to the lists in insertTrack2(), if it's a dssi synth
+ // OSC can find the track and its plugins, and start their native guis if required...
+ showPendingPluginNativeGuis();
+
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ AudioTrack::mapRackPluginsToControllers();
+ }
+
+//---------------------------------------------------------
+// getPatchName
+//---------------------------------------------------------
+
+const char* MessSynthIF::getPatchName(int channel, int prog, MType type, bool drum)
+ {
+ if (_mess)
+ {
+ //return _mess->getPatchName(channel, prog, type, drum);
+ const char* s = _mess->getPatchName(channel, prog, type, drum);
+ if(s)
+ return s;
+ }
+ return "";
+ }
+
+//---------------------------------------------------------
+// populatePatchPopup
+//---------------------------------------------------------
+
+void MessSynthIF::populatePatchPopup(QMenu* menu, int ch, MType, bool)
+ {
+ menu->clear();
+ const MidiPatch* mp = _mess->getPatchInfo(ch, 0);
+ while (mp) {
+ int id = ((mp->hbank & 0xff) << 16)
+ + ((mp->lbank & 0xff) << 8) + mp->prog;
+ /*
+ int pgid = ((mp->hbank & 0xff) << 8) | (mp->lbank & 0xff) | 0x40000000;
+ int itemnum = menu->indexOf(pgid);
+ if(itemnum == -1)
+ {
+ QPopupMenu* submenu = new QPopupMenu(menu);
+ itemnum =
+ }
+ */
+ QAction *act = menu->addAction(QString(mp->name));
+ act->setData(id);
+ mp = _mess->getPatchInfo(ch, mp);
+ }
+ }
+
+//---------------------------------------------------------
+// preProcessAlways
+//---------------------------------------------------------
+
+void SynthI::preProcessAlways()
+{
+ if(_sif)
+ _sif->preProcessAlways();
+ _processed = false;
+}
+
+void MessSynthIF::preProcessAlways()
+{
+ if(_mess)
+ _mess->processMessages();
+}
+
+//---------------------------------------------------------
+// getData
+//---------------------------------------------------------
+
+bool SynthI::getData(unsigned pos, int ports, unsigned n, float** buffer)
+ {
+ for (int k = 0; k < ports; ++k)
+ memset(buffer[k], 0, n * sizeof(float));
+
+ int p = midiPort();
+ MidiPort* mp = (p != -1) ? &midiPorts[p] : 0;
+ MPEventList* el = playEvents();
+
+ iMPEvent ie = nextPlayEvent();
+
+ ie = _sif->getData(mp, el, ie, pos, ports, n, buffer);
+
+ setNextPlayEvent(ie);
+ return true;
+ }
+
+iMPEvent MessSynthIF::getData(MidiPort* mp, MPEventList* el, iMPEvent i, unsigned pos, int /*ports*/, unsigned n, float** buffer)
+{
+ //prevent compiler warning: comparison of signed/unsigned
+ int curPos = pos;
+ int endPos = pos + n;
+ int off = pos;
+ int frameOffset = audio->getFrameOffset();
+
+ for (; i != el->end(); ++i) {
+ int evTime = i->time();
+ if (evTime == 0) {
+ // printf("MessSynthIF::getData - time is 0!\n");
+ // continue;
+ evTime=frameOffset; // will cause frame to be zero, problem?
+ }
+ int frame = evTime - frameOffset;
+
+//TODO if (frame > 0) // robert: ugly fix, don't really know what is going on here
+// // makes PPC work much better.
+
+ if (frame >= endPos) {
+ printf("frame > endPos!! frame = %d >= endPos %d, i->time() %d, frameOffset %d curPos=%d\n", frame, endPos, i->time(), frameOffset,curPos);
+ continue;
+ }
+
+ if (frame > curPos) {
+ if (frame < pos)
+ printf("should not happen: missed event %d\n", pos -frame);
+ else
+ {
+ if (!_mess)
+ printf("should not happen - no _mess\n");
+ else
+ {
+ _mess->process(buffer, curPos-pos, frame - curPos);
+ }
+ }
+ curPos = frame;
+ }
+ if (mp)
+ mp->sendEvent(*i);
+ else {
+ if (putEvent(*i))
+ break;
+ }
+ }
+ if (endPos - curPos)
+ {
+ if (!_mess)
+ printf("should not happen - no _mess\n");
+ else
+ {
+ _mess->process(buffer, curPos - off, endPos - curPos);
+ }
+ }
+ return i;
+}
+
+//---------------------------------------------------------
+// putEvent
+// return true on error (busy)
+//---------------------------------------------------------
+
+bool MessSynthIF::putEvent(const MidiPlayEvent& ev)
+ {
+ if (midiOutputTrace)
+ ev.dump();
+ if (_mess)
+ return _mess->processEvent(ev);
+ return true;
+ }
diff --git a/attic/muse2-oom/muse2/muse/synth.h b/attic/muse2-oom/muse2/muse/synth.h
new file mode 100644
index 00000000..de400423
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/synth.h
@@ -0,0 +1,294 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: synth.h,v 1.22.2.12 2009/12/06 10:05:00 terminator356 Exp $
+// (C) Copyright 2000-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SYNTH_H__
+#define __SYNTH_H__
+
+#include <string>
+#include <vector>
+#include <map>
+
+#include "globals.h"
+#include "node.h"
+#include "instruments/minstrument.h"
+#include "mididev.h"
+#include "midiport.h"
+#include "track.h"
+#include "stringparam.h"
+
+#include <QFileInfo>
+
+class QMenu;
+
+//class MidiEvent;
+class MidiPlayEvent;
+class Mess;
+struct MESS;
+
+class SynthI;
+class SynthIF;
+
+//---------------------------------------------------------
+// Synth
+// software synthesizer
+//---------------------------------------------------------
+
+class Synth {
+ protected:
+ QFileInfo info;
+ int _instances;
+ QString _name;
+ QString _description;
+ QString _maker;
+ QString _version;
+
+ public:
+ //Synth(const QFileInfo& fi);
+ //Synth(const QFileInfo& fi, QString label);
+ Synth(const QFileInfo& fi, QString label, QString descr, QString maker, QString ver);
+
+ virtual ~Synth() {}
+ //virtual const char* description() const { return ""; }
+ //virtual const char* version() const { return ""; }
+
+ int instances() const { return _instances; }
+ virtual void incInstances(int val) { _instances += val; }
+ QString completeBaseName() /*const*/ { return info.completeBaseName(); } // ddskrjo
+ QString baseName() /*const*/ { return info.baseName(); } // ddskrjo
+ QString name() const { return _name; }
+ QString absolutePath() const { return info.absolutePath(); }
+ QString path() const { return info.path(); }
+ QString filePath() const { return info.filePath(); }
+ QString description() const { return _description; }
+ QString version() const { return _version; }
+ //QString maker() const { return _version; } ??
+ QString maker() const { return _maker; }
+
+ //virtual void* instantiate() = 0;
+
+ //virtual SynthIF* createSIF() const = 0;
+ virtual SynthIF* createSIF(SynthI*) = 0;
+ };
+
+//---------------------------------------------------------
+// MessSynth
+//---------------------------------------------------------
+
+class MessSynth : public Synth {
+ const MESS* _descr;
+
+ public:
+ //MessSynth(const QFileInfo& fi) : Synth(fi) { descr = 0; }
+ //MessSynth(const QFileInfo& fi) : Synth(fi, fi.baseName()) { descr = 0; }
+ MessSynth(const QFileInfo& fi, QString label, QString descr, QString maker, QString ver) :
+ Synth(fi, label, descr, maker, ver) { _descr = 0; }
+
+ virtual ~MessSynth() {}
+ //virtual const char* description() const;
+ //virtual const char* version() const;
+
+ //virtual void* instantiate();
+ virtual void* instantiate(const QString&);
+
+ //virtual SynthIF* createSIF() const;
+ virtual SynthIF* createSIF(SynthI*);
+ };
+
+class Mess;
+
+//---------------------------------------------------------
+// SynthIF
+// synth instance interface
+//---------------------------------------------------------
+
+class SynthIF {
+ protected:
+ SynthI* synti;
+
+ public:
+ //SynthIF() {}
+ SynthIF(SynthI* s) { synti = s; }
+ virtual ~SynthIF() {}
+
+ virtual bool initGui() = 0;
+ virtual void guiHeartBeat() = 0;
+ virtual bool guiVisible() const = 0;
+ virtual void showGui(bool v) = 0;
+ virtual bool hasGui() const = 0;
+ virtual void getGeometry(int*, int*, int*, int*) const = 0;
+ virtual void setGeometry(int, int, int, int) = 0;
+ virtual void preProcessAlways() = 0;
+ virtual iMPEvent getData(MidiPort*, MPEventList*, iMPEvent, unsigned pos, int ports, unsigned n, float** buffer) = 0;
+ virtual bool putEvent(const MidiPlayEvent& ev) = 0;
+ virtual MidiPlayEvent receiveEvent() = 0;
+ virtual int eventsPending() const = 0;
+
+ //virtual bool init(Synth* s) = 0;
+
+ virtual int channels() const = 0;
+ virtual int totalOutChannels() const = 0;
+ virtual int totalInChannels() const = 0;
+ virtual void deactivate3() = 0;
+ virtual const char* getPatchName(int, int, int, bool) const = 0;
+ virtual const char* getPatchName(int, int, MType, bool) = 0;
+ virtual void populatePatchPopup(QMenu*, int, MType, bool) = 0;
+ virtual void write(int level, Xml& xml) const = 0;
+ virtual float getParameter(unsigned long idx) const = 0;
+ virtual void setParameter(unsigned long idx, float value) = 0;
+ virtual int getControllerInfo(int id, const char** name, int* ctrl, int* min, int* max, int* initval) = 0;
+ };
+
+//---------------------------------------------------------
+// SynthI
+// software synthesizer instance
+// Track
+// MidiDevice
+// MidiInstrument
+//---------------------------------------------------------
+
+class SynthI : public AudioTrack, public MidiDevice,
+ public MidiInstrument
+ {
+ SynthIF* _sif;
+
+ protected:
+ Synth* synthesizer;
+ MidiFifo putFifo;
+
+ // List of initial floating point parameters, for synths which use them.
+ // Used once upon song reload, then discarded.
+ std::vector<float> initParams;
+ // List of gui controls to update upon heartbeat.
+ std::vector<bool> _guiUpdateControls;
+ // Update gui program upon heartbeat.
+ bool _guiUpdateProgram;
+ // Initial, and running, string parameters for synths which use them, like dssi.
+ StringParamMap _stringParamMap;
+ // Current bank and program for synths which use them, like dssi.
+ // In cases like dssi which have no 'hi' and 'lo' bank, just use _curBankL.
+ unsigned long _curBankH;
+ unsigned long _curBankL;
+ unsigned long _curProgram;
+
+ void preProcessAlways();
+ bool getData(unsigned a, int b, unsigned c, float** data);
+
+ //bool putEvent(const MidiPlayEvent& ev);
+
+ virtual QString open();
+ virtual void close();
+
+ virtual bool putMidiEvent(const MidiPlayEvent&) {return true;}
+ //bool putMidiEvent(const MidiEvent&);
+
+ virtual Track* newTrack() const { return 0; }
+
+ public:
+ friend class SynthIF;
+ friend class MessSynthIF;
+ friend class DssiSynthIF;
+ friend class VstSynthIF;
+
+ SynthI();
+ virtual ~SynthI();
+ //SynthI* clone() const { return new SynthI(*this); }
+ SynthI* clone(bool /*cloneParts*/) const { return new SynthI(*this); }
+
+ virtual inline int deviceType() { return SYNTH_MIDI; }
+
+ SynthIF* sif() const { return _sif; }
+ bool initInstance(Synth* s, const QString& instanceName);
+
+ void readProgram(Xml&, const QString&);
+ void read(Xml&);
+ virtual void write(int, Xml&) const;
+
+ void setName(const QString& s);
+ QString name() const { return AudioTrack::name(); }
+
+ Synth* synth() const { return synthesizer; }
+ virtual bool isSynti() const { return true; }
+
+ //virtual const char* getPatchName(int ch, int prog, MType t, bool dr) {
+ virtual QString getPatchName(int ch, int prog, MType t, bool dr) {
+ return _sif->getPatchName(ch, prog, t, dr);
+ }
+
+ virtual void populatePatchPopup(QMenu* m, int i, MType t, bool d) {
+ _sif->populatePatchPopup(m, i, t, d);
+ }
+
+ // void setParameter(const char* name, const char* value) const; // Not required
+ //StringParamMap& stringParameters() { return _stringParamMap; } // Not required
+ void currentProg(unsigned long */*prog*/, unsigned long */*bankL*/, unsigned long */*bankH*/);
+
+ void guiHeartBeat() { return _sif->guiHeartBeat(); }
+ bool initGui() const { return _sif->initGui(); }
+ bool guiVisible() const { return _sif->guiVisible(); }
+ void showGui(bool v) { _sif->showGui(v); }
+ bool hasGui() const { return _sif->hasGui(); }
+ void getGeometry(int* x, int* y, int* w, int* h) const {
+ _sif->getGeometry(x, y, w, h);
+ }
+ void setGeometry(int x, int y, int w, int h) {
+ _sif->setGeometry(x, y, w, h);
+ }
+
+ bool putEvent(const MidiPlayEvent& ev);
+
+ MidiPlayEvent receiveEvent() { return _sif->receiveEvent(); }
+ int eventsPending() const { return _sif->eventsPending(); }
+ void deactivate2();
+ void deactivate3();
+ bool isActivated() const { return synthesizer && _sif; }
+ virtual bool hasAuxSend() const { return true; }
+ };
+
+//---------------------------------------------------------
+// MessSynthIF
+// mess synthesizer instance
+//---------------------------------------------------------
+
+class MessSynthIF : public SynthIF {
+ Mess* _mess;
+
+ public:
+ //MessSynthIF() { _mess = 0; }
+ MessSynthIF(SynthI* s) : SynthIF(s) { _mess = 0; }
+ virtual ~MessSynthIF() { }
+
+ virtual bool initGui() { return true; };
+ virtual void guiHeartBeat() { }
+ virtual bool guiVisible() const;
+ virtual void showGui(bool v);
+ virtual bool hasGui() const;
+ virtual void getGeometry(int*, int*, int*, int*) const;
+ virtual void setGeometry(int, int, int, int);
+ virtual void preProcessAlways();
+ virtual iMPEvent getData(MidiPort*, MPEventList*, iMPEvent, unsigned pos, int ports, unsigned n, float** buffer);
+ virtual bool putEvent(const MidiPlayEvent& ev);
+ virtual MidiPlayEvent receiveEvent();
+ virtual int eventsPending() const;
+ //virtual bool init(Synth* s);
+ bool init(Synth* s, SynthI* si);
+
+ virtual int channels() const;
+ virtual int totalOutChannels() const;
+ virtual int totalInChannels() const;
+ virtual void deactivate3();
+ virtual const char* getPatchName(int, int, int, bool) const { return ""; }
+ virtual const char* getPatchName(int, int, MType, bool);
+ virtual void populatePatchPopup(QMenu*, int, MType, bool);
+ virtual void write(int level, Xml& xml) const;
+ virtual float getParameter(unsigned long) const { return 0.0; }
+ virtual void setParameter(unsigned long, float) {}
+ virtual int getControllerInfo(int id, const char** name, int* ctrl, int* min, int* max, int* initval);
+ };
+
+extern std::vector<Synth*> synthis; // array of available synthis
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/tempo.cpp b/attic/muse2-oom/muse2/muse/tempo.cpp
new file mode 100644
index 00000000..418ec031
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/tempo.cpp
@@ -0,0 +1,503 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: tempo.cpp,v 1.7.2.7 2008/05/21 00:28:52 terminator356 Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <errno.h>
+#include <cmath>
+
+#include "tempo.h"
+#include "globals.h"
+#include "gconfig.h"
+#include "xml.h"
+
+TempoList tempomap;
+
+//---------------------------------------------------------
+// TempoList
+//---------------------------------------------------------
+
+TempoList::TempoList()
+ {
+ _tempo = 500000;
+ insert(std::pair<const unsigned, TEvent*> (MAX_TICK+1, new TEvent(_tempo, 0)));
+ _tempoSN = 1;
+ _globalTempo = 100;
+ useList = true;
+ }
+
+//---------------------------------------------------------
+// add
+//---------------------------------------------------------
+
+void TempoList::add(unsigned tick, int tempo)
+ {
+ if (tick > MAX_TICK)
+ tick = MAX_TICK;
+ iTEvent e = upper_bound(tick);
+
+ if (tick == e->second->tick)
+ e->second->tempo = tempo;
+ else {
+ TEvent* ne = e->second;
+ TEvent* ev = new TEvent(ne->tempo, ne->tick);
+ ne->tempo = tempo;
+ ne->tick = tick;
+ insert(std::pair<const unsigned, TEvent*> (tick, ev));
+ }
+ normalize();
+ }
+
+//---------------------------------------------------------
+// TempoList::normalize
+//---------------------------------------------------------
+
+void TempoList::normalize()
+ {
+ int frame = 0;
+ for (iTEvent e = begin(); e != end(); ++e) {
+ e->second->frame = frame;
+ unsigned dtick = e->first - e->second->tick;
+ double dtime = double(dtick) / (config.division * _globalTempo * 10000.0/e->second->tempo);
+ frame += lrint(dtime * sampleRate);
+ }
+ }
+
+//---------------------------------------------------------
+// TempoList::dump
+//---------------------------------------------------------
+
+void TempoList::dump() const
+ {
+ printf("\nTempoList:\n");
+ for (ciTEvent i = begin(); i != end(); ++i) {
+ printf("%6d %06d Tempo %6d Frame %d\n",
+ i->first, i->second->tick, i->second->tempo,
+ i->second->frame);
+ }
+ }
+
+//---------------------------------------------------------
+// clear
+//---------------------------------------------------------
+
+void TempoList::clear()
+ {
+ for (iTEvent i = begin(); i != end(); ++i)
+ delete i->second;
+ TEMPOLIST::clear();
+ insert(std::pair<const unsigned, TEvent*> (MAX_TICK+1, new TEvent(500000, 0)));
+ ++_tempoSN;
+ }
+
+//---------------------------------------------------------
+// tempo
+//---------------------------------------------------------
+
+int TempoList::tempo(unsigned tick) const
+ {
+ if (useList) {
+ ciTEvent i = upper_bound(tick);
+ if (i == end()) {
+ printf("no TEMPO at tick %d,0x%x\n", tick, tick);
+ return 1000;
+ }
+ return i->second->tempo;
+ }
+ else
+ return _tempo;
+ }
+
+//---------------------------------------------------------
+// del
+//---------------------------------------------------------
+
+void TempoList::del(unsigned tick)
+ {
+// printf("TempoList::del(%d)\n", tick);
+ iTEvent e = find(tick);
+ if (e == end()) {
+ printf("TempoList::del(%d): not found\n", tick);
+ return;
+ }
+ del(e);
+ ++_tempoSN;
+ }
+
+void TempoList::del(iTEvent e)
+ {
+ iTEvent ne = e;
+ ++ne;
+ if (ne == end()) {
+ printf("TempoList::del() HALLO\n");
+ return;
+ }
+ ne->second->tempo = e->second->tempo;
+ ne->second->tick = e->second->tick;
+ erase(e);
+ normalize();
+ ++_tempoSN;
+ }
+
+//---------------------------------------------------------
+// change
+//---------------------------------------------------------
+
+void TempoList::change(unsigned tick, int newTempo)
+ {
+ iTEvent e = find(tick);
+ e->second->tempo = newTempo;
+ normalize();
+ ++_tempoSN;
+ }
+
+//---------------------------------------------------------
+// setTempo
+// called from transport window
+// & slave mode tempo changes
+//---------------------------------------------------------
+
+void TempoList::setTempo(unsigned tick, int newTempo)
+ {
+ if (useList)
+ add(tick, newTempo);
+ else
+ _tempo = newTempo;
+ ++_tempoSN;
+ }
+
+//---------------------------------------------------------
+// setGlobalTempo
+//---------------------------------------------------------
+
+void TempoList::setGlobalTempo(int val)
+ {
+ _globalTempo = val;
+ ++_tempoSN;
+ normalize();
+ }
+
+//---------------------------------------------------------
+// addTempo
+//---------------------------------------------------------
+
+void TempoList::addTempo(unsigned t, int tempo)
+ {
+ add(t, tempo);
+ ++_tempoSN;
+ }
+
+//---------------------------------------------------------
+// delTempo
+//---------------------------------------------------------
+
+void TempoList::delTempo(unsigned tick)
+ {
+ del(tick);
+ ++_tempoSN;
+ }
+
+//---------------------------------------------------------
+// changeTempo
+//---------------------------------------------------------
+
+void TempoList::changeTempo(unsigned tick, int newTempo)
+ {
+ change(tick, newTempo);
+ ++_tempoSN;
+ }
+
+//---------------------------------------------------------
+// setMasterFlag
+//---------------------------------------------------------
+
+bool TempoList::setMasterFlag(unsigned /*tick*/, bool val)
+ {
+ if (useList != val) {
+ useList = val;
+ ++_tempoSN;
+ return true;
+ }
+ return false;
+ }
+
+//---------------------------------------------------------
+// tick2frame
+//---------------------------------------------------------
+
+unsigned TempoList::tick2frame(unsigned tick, unsigned frame, int* sn) const
+ {
+ return (*sn == _tempoSN) ? frame : tick2frame(tick, sn);
+ }
+
+//---------------------------------------------------------
+// tick2frame
+//---------------------------------------------------------
+
+unsigned TempoList::tick2frame(unsigned tick, int* sn) const
+ {
+ int f;
+ if (useList) {
+ ciTEvent i = upper_bound(tick);
+ if (i == end()) {
+ printf("tick2frame(%d,0x%x): not found\n", tick, tick);
+ // abort();
+ return 0;
+ }
+ unsigned dtick = tick - i->second->tick;
+ double dtime = double(dtick) / (config.division * _globalTempo * 10000.0/ i->second->tempo);
+ unsigned dframe = lrint(dtime * sampleRate);
+ f = i->second->frame + dframe;
+ }
+ else {
+ double t = (double(tick) * double(_tempo)) / (double(config.division) * _globalTempo * 10000.0);
+ f = lrint(t * sampleRate);
+ }
+ if (sn)
+ *sn = _tempoSN;
+ return f;
+ }
+
+//---------------------------------------------------------
+// frame2tick
+// return cached value t if list did not change
+//---------------------------------------------------------
+
+unsigned TempoList::frame2tick(unsigned frame, unsigned t, int* sn) const
+ {
+ return (*sn == _tempoSN) ? t : frame2tick(frame, sn);
+ }
+
+//---------------------------------------------------------
+// frame2tick
+//---------------------------------------------------------
+
+unsigned TempoList::frame2tick(unsigned frame, int* sn) const
+ {
+ unsigned tick;
+ if (useList) {
+ ciTEvent e;
+ for (e = begin(); e != end();) {
+ ciTEvent ee = e;
+ ++ee;
+ if (ee == end())
+ break;
+ if (frame < ee->second->frame)
+ break;
+ e = ee;
+ }
+ unsigned te = e->second->tempo;
+ int dframe = frame - e->second->frame;
+ double dtime = double(dframe) / double(sampleRate);
+ tick = e->second->tick + lrint(dtime * _globalTempo * config.division * 10000.0 / te);
+ }
+ else
+ tick = lrint((double(frame)/double(sampleRate)) * _globalTempo * config.division * 10000.0 / double(_tempo));
+ if (sn)
+ *sn = _tempoSN;
+ return tick;
+ }
+
+//---------------------------------------------------------
+// deltaTick2frame
+//---------------------------------------------------------
+
+unsigned TempoList::deltaTick2frame(unsigned tick1, unsigned tick2, int* sn) const
+ {
+ int f1, f2;
+ if (useList) {
+ ciTEvent i = upper_bound(tick1);
+ if (i == end()) {
+ printf("TempoList::deltaTick2frame: tick1:%d not found\n", tick1);
+ // abort();
+ return 0;
+ }
+ unsigned dtick = tick1 - i->second->tick;
+ double dtime = double(dtick) / (config.division * _globalTempo * 10000.0/ i->second->tempo);
+ unsigned dframe = lrint(dtime * sampleRate);
+ f1 = i->second->frame + dframe;
+
+ i = upper_bound(tick2);
+ if (i == end()) {
+ return 0;
+ }
+ dtick = tick2 - i->second->tick;
+ dtime = double(dtick) / (config.division * _globalTempo * 10000.0/ i->second->tempo);
+ dframe = lrint(dtime * sampleRate);
+ f2 = i->second->frame + dframe;
+ }
+ else {
+ double t = (double(tick1) * double(_tempo)) / (double(config.division) * _globalTempo * 10000.0);
+ f1 = lrint(t * sampleRate);
+
+ t = (double(tick2) * double(_tempo)) / (double(config.division) * _globalTempo * 10000.0);
+ f2 = lrint(t * sampleRate);
+ }
+ if (sn)
+ *sn = _tempoSN;
+ // FIXME: Caution: This should be rounded off properly somehow, but how to do that?
+ // But it seems to work so far.
+ return f2 - f1;
+ }
+
+
+//---------------------------------------------------------
+// deltaFrame2tick
+//---------------------------------------------------------
+
+unsigned TempoList::deltaFrame2tick(unsigned frame1, unsigned frame2, int* sn) const
+ {
+ unsigned tick1, tick2;
+ if (useList) {
+ ciTEvent e;
+ for (e = begin(); e != end();) {
+ ciTEvent ee = e;
+ ++ee;
+ if (ee == end())
+ break;
+ if (frame1 < ee->second->frame)
+ break;
+ e = ee;
+ }
+ unsigned te = e->second->tempo;
+ int dframe = frame1 - e->second->frame;
+ double dtime = double(dframe) / double(sampleRate);
+ tick1 = e->second->tick + lrint(dtime * _globalTempo * config.division * 10000.0 / te);
+
+ for (e = begin(); e != end();) {
+ ciTEvent ee = e;
+ ++ee;
+ if (ee == end())
+ break;
+ if (frame2 < ee->second->frame)
+ break;
+ e = ee;
+ }
+ te = e->second->tempo;
+ dframe = frame2 - e->second->frame;
+ dtime = double(dframe) / double(sampleRate);
+ tick2 = e->second->tick + lrint(dtime * _globalTempo * config.division * 10000.0 / te);
+ }
+ else
+ {
+ tick1 = lrint((double(frame1)/double(sampleRate)) * _globalTempo * config.division * 10000.0 / double(_tempo));
+ tick2 = lrint((double(frame2)/double(sampleRate)) * _globalTempo * config.division * 10000.0 / double(_tempo));
+ }
+ if (sn)
+ *sn = _tempoSN;
+ // FIXME: Caution: This should be rounded off properly somehow, but how to do that?
+ // But it seems to work so far.
+ return tick2 - tick1;
+ }
+
+//---------------------------------------------------------
+// TempoList::write
+//---------------------------------------------------------
+
+void TempoList::write(int level, Xml& xml) const
+ {
+ xml.put(level++, "<tempolist fix=\"%d\">", _tempo);
+ if (_globalTempo != 100)
+ xml.intTag(level, "globalTempo", _globalTempo);
+ for (ciTEvent i = begin(); i != end(); ++i)
+ i->second->write(level, xml, i->first);
+ xml.tag(level, "/tempolist");
+ }
+
+//---------------------------------------------------------
+// TempoList::read
+//---------------------------------------------------------
+
+void TempoList::read(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "tempo") {
+ TEvent* t = new TEvent();
+ unsigned tick = t->read(xml);
+ iTEvent pos = find(tick);
+ if (pos != end())
+ erase(pos);
+ insert(std::pair<const int, TEvent*> (tick, t));
+ }
+ else if (tag == "globalTempo")
+ _globalTempo = xml.parseInt();
+ else
+ xml.unknown("TempoList");
+ break;
+ case Xml::Attribut:
+ if (tag == "fix")
+ _tempo = xml.s2().toInt();
+ break;
+ case Xml::TagEnd:
+ if (tag == "tempolist") {
+ normalize();
+ ++_tempoSN;
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// TEvent::write
+//---------------------------------------------------------
+
+void TEvent::write(int level, Xml& xml, int at) const
+ {
+ xml.tag(level++, "tempo at=\"%d\"", at);
+ xml.intTag(level, "tick", tick);
+ xml.intTag(level, "val", tempo);
+ xml.tag(level, "/tempo");
+ }
+
+//---------------------------------------------------------
+// TEvent::read
+//---------------------------------------------------------
+
+int TEvent::read(Xml& xml)
+ {
+ int at = 0;
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return 0;
+ case Xml::TagStart:
+ if (tag == "tick")
+ tick = xml.parseInt();
+ else if (tag == "val")
+ tempo = xml.parseInt();
+ else
+ xml.unknown("TEvent");
+ break;
+ case Xml::Attribut:
+ if (tag == "at")
+ at = xml.s2().toInt();
+ break;
+ case Xml::TagEnd:
+ if (tag == "tempo") {
+ return at;
+ }
+ default:
+ break;
+ }
+ }
+ return 0;
+ }
+
+
diff --git a/attic/muse2-oom/muse2/muse/tempo.h b/attic/muse2-oom/muse2/muse/tempo.h
new file mode 100644
index 00000000..61ec50f5
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/tempo.h
@@ -0,0 +1,89 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: tempo.h,v 1.2.2.1 2006/09/19 19:07:09 spamatica Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __TEMPO_H__
+#define __TEMPO_H__
+
+#include <map>
+
+#ifndef MAX_TICK
+#define MAX_TICK (0x7fffffff/100)
+#endif
+
+class Xml;
+
+//---------------------------------------------------------
+// Tempo Event
+//---------------------------------------------------------
+
+struct TEvent {
+ int tempo;
+ unsigned tick; // new tempo at tick
+ unsigned frame; // precomputed time for tick in sec
+
+ int read(Xml&);
+ void write(int, Xml&, int) const;
+
+ TEvent() { }
+ TEvent(unsigned t, unsigned tk) {
+ tempo = t;
+ tick = tk;
+ frame = 0;
+ }
+ };
+
+//---------------------------------------------------------
+// TempoList
+//---------------------------------------------------------
+
+typedef std::map<unsigned, TEvent*, std::less<unsigned> > TEMPOLIST;
+typedef TEMPOLIST::iterator iTEvent;
+typedef TEMPOLIST::const_iterator ciTEvent;
+typedef TEMPOLIST::reverse_iterator riTEvent;
+typedef TEMPOLIST::const_reverse_iterator criTEvent;
+
+class TempoList : public TEMPOLIST {
+ int _tempoSN; // serial no to track tempo changes
+ bool useList;
+ int _tempo; // tempo if not using tempo list
+ int _globalTempo; // %percent 50-200%
+
+ void normalize();
+ void add(unsigned tick, int tempo);
+ void change(unsigned tick, int newTempo);
+ void del(iTEvent);
+ void del(unsigned tick);
+
+ public:
+ TempoList();
+ void clear();
+
+ void read(Xml&);
+ void write(int, Xml&) const;
+ void dump() const;
+
+ int tempo(unsigned tick) const;
+ unsigned tick2frame(unsigned tick, unsigned frame, int* sn) const;
+ unsigned tick2frame(unsigned tick, int* sn = 0) const;
+ unsigned frame2tick(unsigned frame, int* sn = 0) const;
+ unsigned frame2tick(unsigned frame, unsigned tick, int* sn) const;
+ unsigned deltaTick2frame(unsigned tick1, unsigned tick2, int* sn = 0) const;
+ unsigned deltaFrame2tick(unsigned frame1, unsigned frame2, int* sn = 0) const;
+
+ int tempoSN() const { return _tempoSN; }
+ void setTempo(unsigned tick, int newTempo);
+ void addTempo(unsigned t, int tempo);
+ void delTempo(unsigned tick);
+ void changeTempo(unsigned tick, int newTempo);
+ bool setMasterFlag(unsigned tick, bool val);
+ int globalTempo() const { return _globalTempo; }
+ void setGlobalTempo(int val);
+ };
+
+extern TempoList tempomap;
+#endif
diff --git a/attic/muse2-oom/muse2/muse/thread.cpp b/attic/muse2-oom/muse2/muse/thread.cpp
new file mode 100644
index 00000000..444d5219
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/thread.cpp
@@ -0,0 +1,455 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: thread.cpp,v 1.4.2.5 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 2001-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "thread.h"
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/mman.h>
+#include <sys/poll.h>
+#include <fcntl.h>
+
+#include "globals.h"
+#include "errno.h"
+
+//---------------------------------------------------------
+// Thread
+//---------------------------------------------------------
+
+Thread::~Thread()
+ {
+ }
+
+//---------------------------------------------------------
+// serverloop
+//---------------------------------------------------------
+
+static void* loop(void* mops)
+ {
+ Thread* t = (Thread*) mops;
+ t->loop();
+ return 0;
+ }
+
+//---------------------------------------------------------
+// start
+//---------------------------------------------------------
+
+//void Thread::start(void* ptr)
+void Thread::start(int prio, void* ptr)
+ {
+ // Changed by Tim. p3.3.17
+
+ userPtr = ptr;
+ pthread_attr_t* attributes = 0;
+ _realTimePriority = prio;
+
+ /*
+ attributes = (pthread_attr_t*) malloc(sizeof(pthread_attr_t));
+ pthread_attr_init(attributes);
+ */
+
+// pthread_mutexattr_t mutexattr;
+// pthread_mutexattr_init(&mutexattr);
+// pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_TIMED_NP);
+// pthread_mutex_init(&lock, &mutexattr);
+// pthread_cond_init(&ready, 0);
+
+// pthread_mutex_lock(&lock);
+
+
+ if (_realTimePriority) {
+ attributes = (pthread_attr_t*) malloc(sizeof(pthread_attr_t));
+ pthread_attr_init(attributes);
+
+ if (pthread_attr_setschedpolicy(attributes, SCHED_FIFO)) {
+ printf("cannot set FIFO scheduling class for RT thread\n");
+ }
+ if (pthread_attr_setscope (attributes, PTHREAD_SCOPE_SYSTEM)) {
+ printf("Cannot set scheduling scope for RT thread\n");
+ }
+ if (pthread_attr_setinheritsched(attributes, PTHREAD_EXPLICIT_SCHED)) {
+ printf("Cannot set setinheritsched for RT thread\n");
+ }
+
+ struct sched_param rt_param;
+ memset(&rt_param, 0, sizeof(rt_param));
+ rt_param.sched_priority = _realTimePriority;
+ if (pthread_attr_setschedparam (attributes, &rt_param)) {
+ printf("Cannot set scheduling priority %d for RT thread (%s)\n",
+ _realTimePriority, strerror(errno));
+ }
+ }
+
+
+ /*
+ if (pthread_create(&thread, attributes, ::loop, this))
+ perror("creating thread failed:");
+// else
+// {
+// pthread_cond_wait(&ready, &lock);
+// }
+// pthread_mutex_unlock(&lock);
+ */
+
+
+ int rv;
+ if ((rv = pthread_create(&thread, attributes, ::loop, this)))
+ {
+ fprintf(stderr, "creating thread <%s> failed: %s\n",
+ _name, strerror(rv));
+ thread = 0;
+ }
+
+ //undoSetuid();
+ }
+
+//---------------------------------------------------------
+// stop
+//---------------------------------------------------------
+
+void Thread::stop(bool force)
+ {
+ // Changed by Tim. p3.3.17
+
+ if (thread == 0)
+ return;
+ //if (force && thread > 0) {
+ if (force) {
+ pthread_cancel(thread);
+ threadStop();
+ }
+ _running = false;
+ if (thread) {
+ if (pthread_join(thread, 0)) {
+ // perror("Failed to join sequencer thread");
+ }
+ }
+ }
+//---------------------------------------------------------
+// Thread
+// prio = 0 no realtime scheduling
+//---------------------------------------------------------
+
+//Thread::Thread(int prio, const char* s)
+Thread::Thread(const char* s)
+ {
+ // Changed by Tim. p3.3.17
+
+ userPtr = 0;
+ _name = s;
+ //realTimePriority = prio;
+ _realTimePriority = 0;
+
+ pfd = 0;
+ npfd = 0;
+ maxpfd = 0;
+ _running = false;
+ _pollWait = -1;
+ thread = 0;
+
+ //if (debugMsg)
+ // printf("Start thread %s with priority %d\n", s, prio);
+
+ // create message channels
+ int filedes[2]; // 0 - reading 1 - writing
+ if (pipe(filedes) == -1) {
+ perror("thread:creating pipe");
+ exit(-1);
+ }
+ toThreadFdr = filedes[0];
+ toThreadFdw = filedes[1];
+
+ if (pipe(filedes) == -1) {
+ perror("thread: creating pipe");
+ exit(-1);
+ }
+ fromThreadFdr = filedes[0];
+ fromThreadFdw = filedes[1];
+
+// pthread_mutexattr_t mutexattr;
+// pthread_mutexattr_init(&mutexattr);
+// pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_TIMED_NP);
+// pthread_mutex_init(&lock, &mutexattr);
+// pthread_cond_init(&ready, 0);
+ }
+
+//---------------------------------------------------------
+// addPollFd
+//---------------------------------------------------------
+
+void Thread::addPollFd(int fd, int action, void (*handler)(void*,void*), void* p, void* q)
+ {
+ if (fd == -1)
+ return;
+ for (iPoll i = plist.begin(); i != plist.end(); ++i) {
+ if ((i->fd == fd) && (i->action == action))
+ return;
+ }
+
+ plist.push_back(Poll(fd, action, handler, p, q));
+
+ if (npfd == maxpfd) {
+ int n = (maxpfd == 0) ? 4 : maxpfd * 2;
+ //TODO: delete old pfd
+ pfd = new struct pollfd[n];
+ maxpfd = n;
+ }
+ ++npfd;
+ int idx = 0;
+ for (iPoll i = plist.begin(); i != plist.end(); ++i, ++idx) {
+ pfd[idx].fd = i->fd;
+ pfd[idx].events = i->action;
+ }
+ }
+
+//---------------------------------------------------------
+// removePollFd
+//---------------------------------------------------------
+
+void Thread::removePollFd(int fd, int action)
+ {
+ for (iPoll i = plist.begin(); i != plist.end(); ++i) {
+ if (i->fd == fd && i->action == action) {
+ plist.erase(i);
+ --npfd;
+ break;
+ }
+ }
+ int idx = 0;
+ for (iPoll i = plist.begin(); i != plist.end(); ++i, ++idx) {
+ pfd[idx].fd = i->fd;
+ pfd[idx].events = i->action;
+ }
+ }
+
+//---------------------------------------------------------
+// loop
+//---------------------------------------------------------
+
+void Thread::loop()
+ {
+ // Changed by Tim. p3.3.17
+
+ if (!debugMode) {
+ if (mlockall(MCL_CURRENT | MCL_FUTURE))
+ perror("WARNING: Cannot lock memory:");
+ }
+
+/*
+ pthread_attr_t* attributes = 0;
+ attributes = (pthread_attr_t*) malloc(sizeof(pthread_attr_t));
+ pthread_attr_init(attributes);
+
+ if (realTimeScheduling && realTimePriority > 0) {
+
+ doSetuid();
+// if (pthread_attr_setschedpolicy(attributes, SCHED_FIFO)) {
+// printf("cannot set FIFO scheduling class for RT thread\n");
+// }
+// if (pthread_attr_setscope (attributes, PTHREAD_SCOPE_SYSTEM)) {
+// printf("Cannot set scheduling scope for RT thread\n");
+// }
+// struct sched_param rt_param;
+// memset(&rt_param, 0, sizeof(rt_param));
+// rt_param.sched_priority = realTimePriority;
+// if (pthread_attr_setschedparam (attributes, &rt_param)) {
+// printf("Cannot set scheduling priority %d for RT thread (%s)\n",
+// realTimePriority, strerror(errno));
+// }
+
+ // do the SCHED_FIFO stuff _after_ thread creation:
+ struct sched_param *param = new struct sched_param;
+ param->sched_priority = realTimePriority;
+ int error = pthread_setschedparam(pthread_self(), SCHED_FIFO, param);
+ if (error != 0)
+ perror( "error set_schedparam 2:");
+
+// if (!debugMode) {
+// if (mlockall(MCL_CURRENT|MCL_FUTURE))
+// perror("WARNING: Cannot lock memory:");
+// }
+
+ undoSetuid();
+ }
+
+*/
+
+
+/*
+#define BIG_ENOUGH_STACK (1024*1024*1)
+ char buf[BIG_ENOUGH_STACK];
+ for (int i = 0; i < BIG_ENOUGH_STACK; i++)
+ buf[i] = i;
+#undef BIG_ENOUGH_STACK
+*/
+
+#ifdef __APPLE__
+#define BIG_ENOUGH_STACK (1024*256*1)
+#else
+#define BIG_ENOUGH_STACK (1024*1024*1)
+#endif
+ char buf[BIG_ENOUGH_STACK];
+ for (int i = 0; i < BIG_ENOUGH_STACK; i++)
+ buf[i] = i;
+#undef BIG_ENOUGH_STACK
+
+ pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0);
+ pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0);
+
+ int policy = 0;
+ if ((policy = sched_getscheduler (0)) < 0) {
+ printf("Thread: Cannot get current client scheduler: %s\n", strerror(errno));
+ }
+
+ /*
+ if (debugMsg)
+ printf("Thread <%s> set to %s priority %d\n",
+ _name, policy == SCHED_FIFO ? "SCHED_FIFO" : "SCHED_OTHER",
+ realTimePriority);
+ */
+ if (debugMsg)
+ printf("Thread <%s, id %p> has %s priority %d\n",
+ _name, (void *)pthread_self(), policy == SCHED_FIFO ? "SCHED_FIFO" : "SCHED_OTHER",
+ _realTimePriority);
+
+
+// pthread_mutex_lock(&lock);
+ _running = true;
+// pthread_cond_signal(&ready);
+// pthread_mutex_unlock(&lock);
+
+ threadStart(userPtr);
+
+ while (_running) {
+ if (debugMode) // DEBUG
+ _pollWait = 10; // ms
+ else
+ _pollWait = -1;
+
+ int n = poll(pfd, npfd, _pollWait);
+ if (n < 0) {
+ if (errno == EINTR)
+ continue;
+ fprintf(stderr, "poll failed: %s\n", strerror(errno));
+ exit(-1);
+ }
+ if (n == 0) { // timeout
+ defaultTick();
+ continue;
+ }
+
+ struct pollfd* p = &pfd[0];
+ int i = 0;
+ for (iPoll ip = plist.begin(); ip != plist.end(); ++ip, ++p, ++i) {
+ if (ip->action & p->revents) {
+ (ip->handler)(ip->param1, ip->param2);
+ break;
+ }
+ }
+ }
+ threadStop();
+ }
+
+//---------------------------------------------------------
+// send
+// send request from gui to thread
+// wait until request is processed
+//---------------------------------------------------------
+
+bool Thread::sendMsg(const ThreadMsg* m)
+{
+ // Changed by Tim. p3.3.17
+
+ if (_running)
+ {
+ int rv = write(toThreadFdw, &m, sizeof(ThreadMsg*));
+ if (rv != sizeof(ThreadMsg*)) {
+ perror("Thread::sendMessage(): write pipe failed");
+ return true;
+ }
+
+ // wait for sequencer to finish operation
+ char c;
+ rv = read(fromThreadFdr, &c, 1);
+ if (rv != 1)
+ {
+ perror("Thread::sendMessage(): read pipe failed");
+ return true;
+ }
+ //int c;
+ //rv = read(fromThreadFdr, &c, sizeof(c));
+ //if (rv != sizeof(c)) {
+ // perror("Thread::sendMessage(): read pipe failed");
+ // return true;
+ // }
+ }
+ else
+ {
+ // if thread is not running (during initialization)
+ // process commands directly:
+ processMsg(m);
+ }
+ return false;
+}
+
+//---------------------------------------------------------
+// send
+// send request from gui to thread
+// do __not__ wait until request is processed
+//---------------------------------------------------------
+
+bool Thread::sendMsg1(const void* m, int n)
+ {
+ int rv = write(toThreadFdw, m, n);
+ if (rv != n) {
+ perror("Thread::sendMessage1(): write pipe failed");
+ return true;
+ }
+ return false;
+ }
+
+//---------------------------------------------------------
+// readMsg
+//---------------------------------------------------------
+
+void Thread::readMsg()
+ {
+ ThreadMsg* p;
+ if (read(toThreadFdr, &p, sizeof(p)) != sizeof(p)) {
+ perror("Thread::readMessage(): read pipe failed");
+ exit(-1);
+ }
+ processMsg(p);
+ char c = 'x';
+ int rv = write(fromThreadFdw, &c, 1);
+ if (rv != 1)
+ perror("Thread::readMessage(): write pipe failed");
+ //int c = p->serialNo;
+ //int rv = write(fromThreadFdw, &c, sizeof(c));
+ //if (rv != sizeof(c))
+ // perror("Thread::readMsg(): write pipe failed");
+ }
+
+//---------------------------------------------------------
+// readMsg
+// sequencer reads one gui message
+//---------------------------------------------------------
+
+void Thread::readMsg1(int size)
+ {
+ char buffer[size];
+ int n = read(toThreadFdr, buffer, size);
+ if (n != size) {
+ fprintf(stderr, "Thread::readMsg1(): read pipe failed, get %d, expected %d: %s\n",
+ n, size, strerror(errno));
+ exit(-1);
+ }
+ processMsg1(buffer);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/thread.h b/attic/muse2-oom/muse2/muse/thread.h
new file mode 100644
index 00000000..f9642301
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/thread.h
@@ -0,0 +1,104 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: thread.h,v 1.1.1.1.2.2 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __THREAD_H__
+#define __THREAD_H__
+
+#include <pthread.h>
+#include <list>
+
+//---------------------------------------------------------
+// Poll
+//---------------------------------------------------------
+
+struct Poll {
+ int fd;
+ int action;
+ void (*handler)(void*,void*);
+ void* param1;
+ void* param2;
+
+ Poll(int _fd, int _action, void(*_handler)(void*,void*), void* p, void* q) {
+ fd = _fd;
+ action = _action;
+ handler = _handler;
+ param1 = p;
+ param2 = q;
+ }
+ };
+
+typedef std::list<Poll> PollList;
+typedef std::list<Poll>::iterator iPoll;
+
+
+//---------------------------------------------------------
+// ThreadMsg
+//---------------------------------------------------------
+
+struct ThreadMsg {
+ int id;
+ };
+
+//---------------------------------------------------------
+// Thread
+//---------------------------------------------------------
+
+class Thread {
+ const char* _name;
+ volatile bool _running;
+ //int realTimePriority;
+ int _pollWait; // poll timeout in msec (-1 = infinite)
+
+ pthread_t thread;
+
+ int toThreadFdw; // message to thread (app write)
+
+ PollList plist;
+// pthread_mutex_t lock;
+// pthread_cond_t ready;
+ void* userPtr;
+
+ protected:
+ int _realTimePriority;
+ int fromThreadFdr; // message from thread (seq read)
+ int fromThreadFdw; // message from thread (app write)
+ int toThreadFdr; // message to thread (seq read)
+ struct pollfd* pfd; // poll file descriptors
+ int npfd;
+ int maxpfd;
+ virtual void processMsg(const ThreadMsg*) {}
+ virtual void processMsg1(const void *) {}
+ virtual void defaultTick() {}
+
+ public:
+ //Thread(int prio, const char* name);
+ Thread(const char* name);
+
+ virtual ~Thread();
+ const char* name() const { return _name; }
+
+ //virtual void start(void* ptr=0);
+ virtual void start(int priority, void* ptr=0);
+
+ void stop(bool);
+ void clearPollFd() { plist.clear(); npfd = 0; }
+ void addPollFd(int fd, int action, void (*handler)(void*,void*), void*, void*);
+ void removePollFd(int fd, int action);
+ void loop();
+ void readMsg();
+ void readMsg1(int size);
+ bool sendMsg1(const void* m, int n);
+ bool sendMsg(const ThreadMsg* m);
+ bool isRunning() const { return _running; }
+ void setPollWait(int val) { _pollWait = val; }
+ virtual void threadStart(void*){ } // called from loop
+ virtual void threadStop() { } // called from loop before leaving
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/ticksynth.cpp b/attic/muse2-oom/muse2/muse/ticksynth.cpp
new file mode 100644
index 00000000..69f3bf2d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/ticksynth.cpp
@@ -0,0 +1,215 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: ticksynth.cpp,v 1.8.2.7 2009/12/20 05:00:35 terminator356 Exp $
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "audio.h"
+#include "ticksynth.h"
+#include "default_click.h"
+
+#include <QMenu>
+
+// Added by Tim. p3.3.18
+//#define METRONOME_DEBUG
+
+MetronomeSynthI* metronome = 0;
+
+class MetronomeSynth;
+static MetronomeSynth* metronomeSynth = 0;
+
+//---------------------------------------------------------
+// MetronomeSynth
+//---------------------------------------------------------
+
+class MetronomeSynth : public Synth {
+ public:
+ //MetronomeSynth(const QFileInfo& fi) : Synth(fi) {}
+ //MetronomeSynth(const QFileInfo& fi) : Synth(fi, QString("Metronome")) {}
+ MetronomeSynth(const QFileInfo& fi) : Synth(fi, QString("Metronome"), QString("Metronome"), QString(), QString()) {}
+ virtual ~MetronomeSynth() {}
+ virtual void incInstances(int) {}
+ virtual void* instantiate();
+
+ //virtual SynthIF* createSIF() const;
+ virtual SynthIF* createSIF(SynthI*);
+ };
+
+//---------------------------------------------------------
+// instantiate
+//---------------------------------------------------------
+
+void* MetronomeSynth::instantiate()
+ {
+ return 0;
+ }
+
+//---------------------------------------------------------
+// MetronomeSynthIF
+//---------------------------------------------------------
+
+class MetronomeSynthIF : public SynthIF
+ {
+ const float* data;
+ int pos;
+ int len;
+ void process(float** buffer, int offset, int n);
+
+ public:
+ //MetronomeSynthIF() {
+ // data = 0;
+ // }
+ MetronomeSynthIF(SynthI* s) : SynthIF(s) {
+ data = 0;
+ }
+ virtual bool initGui() { return true; };
+ virtual void guiHeartBeat() { }
+ virtual bool guiVisible() const { return false; }
+ virtual void showGui(bool) {}
+ virtual bool hasGui() const { return false; }
+ virtual void getGeometry(int*, int*, int*, int*) const {}
+ virtual void setGeometry(int, int, int, int) {}
+ virtual void preProcessAlways() { };
+ virtual iMPEvent getData(MidiPort*, MPEventList*, iMPEvent, unsigned pos, int ports, unsigned n, float** buffer);
+ virtual bool putEvent(const MidiPlayEvent& ev);
+ virtual MidiPlayEvent receiveEvent() { return MidiPlayEvent(); }
+ virtual int eventsPending() const { return 0; }
+
+ //virtual bool init(Synth*) { return true; }
+
+ virtual int channels() const { return 1; }
+ virtual int totalOutChannels() const { return 1; }
+ virtual int totalInChannels() const { return 0; }
+ virtual void deactivate3() {}
+ virtual const char* getPatchName(int, int, int, bool) const { return ""; }
+ virtual const char* getPatchName(int, int, MType, bool) { return ""; }
+ virtual void populatePatchPopup(QMenu*, int, MType, bool) {};
+ virtual void write(int, Xml&) const {}
+ virtual float getParameter(unsigned long) const { return 0.0; }
+ virtual void setParameter(unsigned long, float) {}
+ virtual int getControllerInfo(int, const char**, int*, int*, int*, int*) { return 0; }
+ };
+
+//---------------------------------------------------------
+// getData
+//---------------------------------------------------------
+
+iMPEvent MetronomeSynthIF::getData(MidiPort*, MPEventList* el, iMPEvent i, unsigned pos, int/*ports*/, unsigned n, float** buffer)
+ {
+ // Added by Tim. p3.3.18
+ #ifdef METRONOME_DEBUG
+ printf("MusE: MetronomeSynthIF::getData\n");
+ #endif
+
+ //set type to unsigned , due to compiler warning: comparison signed/unsigned
+ unsigned int curPos = pos; //prevent compiler warning: comparison signed/unsigned
+ unsigned int endPos = pos + n; //prevent compiler warning: comparison signed/unsigned
+ unsigned int off = pos; //prevent compiler warning: comparison signed/unsigned
+ int frameOffset = audio->getFrameOffset();
+
+ for (; i != el->end(); ++i) {
+ unsigned int frame = i->time() - frameOffset; //prevent compiler warning: comparison signed /unsigned
+ if (frame >= endPos)
+ break;
+ if (frame > curPos) {
+ if (frame < pos)
+ printf("should not happen: missed event %d\n", pos -frame);
+ else
+ process(buffer, curPos-pos, frame - curPos);
+ curPos = frame;
+ }
+ putEvent(*i);
+ }
+ if (endPos - curPos)
+ process(buffer, curPos - off, endPos - curPos);
+ return el->end();
+ }
+
+//---------------------------------------------------------
+// putEvent
+//---------------------------------------------------------
+
+bool MetronomeSynthIF::putEvent(const MidiPlayEvent& ev)
+ {
+ if (ev.dataA() == 0) {
+ data = defaultClickEmphasis;
+ len = defaultClickEmphasisLength;
+ }
+ else {
+ data = defaultClick;
+ len = defaultClickLength;
+ }
+ pos = 0;
+ return false;
+ }
+
+//---------------------------------------------------------
+// createSIF
+//---------------------------------------------------------
+
+//SynthIF* MetronomeSynth::createSIF() const
+// {
+// return new MetronomeSynthIF();
+// }
+SynthIF* MetronomeSynth::createSIF(SynthI* s)
+ {
+ return new MetronomeSynthIF(s);
+ }
+
+//---------------------------------------------------------
+// process
+// synthesize n samples into buffer+offset
+//---------------------------------------------------------
+
+void MetronomeSynthIF::process(float** buffer, int offset, int n)
+ {
+ // Added by Tim. p3.3.18
+ #ifdef METRONOME_DEBUG
+ printf("MusE: MetronomeSynthIF::process data:%p offset:%d n:%d\n", data, offset, n);
+ #endif
+
+ if (data == 0)
+ return;
+
+ const float* s = data + pos;
+ float* d = *buffer + offset;
+ int l = std::min(n, len);
+
+ for (int i = 0; i < l; ++i)
+ *d++ += *s++ * audioClickVolume;
+ pos += l;
+ len -= l;
+ if (len <= 0)
+ data = 0;
+ }
+
+//---------------------------------------------------------
+// initMetronome
+//---------------------------------------------------------
+
+void initMetronome()
+ {
+ QFileInfo fi;
+ metronomeSynth = new MetronomeSynth(fi);
+ metronome = new MetronomeSynthI();
+
+ QString name("metronome");
+ metronome->initInstance(metronomeSynth, name);
+ }
+
+//---------------------------------------------------------
+// exitMetronome
+//---------------------------------------------------------
+
+void exitMetronome()
+{
+ if(metronome)
+ delete metronome;
+ metronome = 0;
+
+ if(metronomeSynth)
+ delete metronomeSynth;
+ metronomeSynth = 0;
+}
+
diff --git a/attic/muse2-oom/muse2/muse/ticksynth.h b/attic/muse2-oom/muse2/muse/ticksynth.h
new file mode 100644
index 00000000..4f467bcd
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/ticksynth.h
@@ -0,0 +1,22 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: ticksynth.h,v 1.1.2.3 2009/12/06 10:05:00 terminator356 Exp $
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __TICKSYNTH_H__
+#define __TICKSYNTH_H__
+
+#include "synth.h"
+extern void initMetronome();
+extern void exitMetronome();
+class MetronomeSynthI : public SynthI
+{
+ virtual bool hasAuxSend() const { return false; }
+
+};
+extern MetronomeSynthI* metronome;
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/track.cpp b/attic/muse2-oom/muse2/muse/track.cpp
new file mode 100644
index 00000000..b4519d8d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/track.cpp
@@ -0,0 +1,982 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: track.cpp,v 1.34.2.11 2009/11/30 05:05:49 terminator356 Exp $
+//
+// (C) Copyright 2000-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "track.h"
+#include "event.h"
+#include "mididev.h"
+#include "midiport.h"
+#include "song.h"
+#include "xml.h"
+#include "plugin.h"
+#include "drummap.h"
+#include "audio.h"
+#include "globaldefs.h"
+#include "route.h"
+
+unsigned int Track::_soloRefCnt = 0;
+Track* Track::_tmpSoloChainTrack = 0;
+bool Track::_tmpSoloChainDoIns = false;
+bool Track::_tmpSoloChainNoDec = false;
+
+const char* Track::_cname[] = {
+ "Midi", "Drum", "Wave", "AudioOut", "AudioIn", "AudioGroup",
+ "AudioAux", "AudioSynth"
+ };
+
+//---------------------------------------------------------
+// addPortCtrlEvents
+//---------------------------------------------------------
+
+void addPortCtrlEvents(MidiTrack* t)
+{
+ const PartList* pl = t->cparts();
+ for(ciPart ip = pl->begin(); ip != pl->end(); ++ip)
+ {
+ Part* part = ip->second;
+ const EventList* el = part->cevents();
+ unsigned len = part->lenTick();
+ for(ciEvent ie = el->begin(); ie != el->end(); ++ie)
+ {
+ const Event& ev = ie->second;
+ // Added by T356. Do not add events which are past the end of the part.
+ if(ev.tick() >= len)
+ break;
+
+ if(ev.type() == Controller)
+ {
+ int tick = ev.tick() + part->tick();
+ int cntrl = ev.dataA();
+ int val = ev.dataB();
+ int ch = t->outChannel();
+
+ MidiPort* mp = &midiPorts[t->outPort()];
+ // Is it a drum controller event, according to the track port's instrument?
+ if(t->type() == Track::DRUM)
+ {
+ MidiController* mc = mp->drumController(cntrl);
+ if(mc)
+ {
+ int note = cntrl & 0x7f;
+ cntrl &= ~0xff;
+ ch = drumMap[note].channel;
+ mp = &midiPorts[drumMap[note].port];
+ cntrl |= drumMap[note].anote;
+ }
+ }
+
+ mp->setControllerVal(ch, tick, cntrl, val, part);
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------
+// removePortCtrlEvents
+//---------------------------------------------------------
+
+void removePortCtrlEvents(MidiTrack* t)
+{
+ const PartList* pl = t->cparts();
+ for(ciPart ip = pl->begin(); ip != pl->end(); ++ip)
+ {
+ Part* part = ip->second;
+ const EventList* el = part->cevents();
+ //unsigned len = part->lenTick();
+ for(ciEvent ie = el->begin(); ie != el->end(); ++ie)
+ {
+ const Event& ev = ie->second;
+ // Added by T356. Do not remove events which are past the end of the part.
+ // No, actually, do remove ALL of them belonging to the part.
+ // Just in case there are stray values left after the part end.
+ //if(ev.tick() >= len)
+ // break;
+
+ if(ev.type() == Controller)
+ {
+ int tick = ev.tick() + part->tick();
+ int cntrl = ev.dataA();
+ int ch = t->outChannel();
+
+ MidiPort* mp = &midiPorts[t->outPort()];
+ // Is it a drum controller event, according to the track port's instrument?
+ if(t->type() == Track::DRUM)
+ {
+ MidiController* mc = mp->drumController(cntrl);
+ if(mc)
+ {
+ int note = cntrl & 0x7f;
+ cntrl &= ~0xff;
+ ch = drumMap[note].channel;
+ mp = &midiPorts[drumMap[note].port];
+ cntrl |= drumMap[note].anote;
+ }
+ }
+
+ mp->deleteController(ch, tick, cntrl, part);
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------
+// y
+//---------------------------------------------------------
+
+int Track::y() const
+ {
+ TrackList* tl = song->tracks();
+ int yy = 0;
+ for (ciTrack it = tl->begin(); it != tl->end(); ++it) {
+ if (this == *it)
+ return yy;
+ yy += (*it)->height();
+ }
+ printf("Track::y(%s): track not in tracklist\n", name().toLatin1().constData());
+ return -1;
+ }
+
+//---------------------------------------------------------
+// Track::init
+//---------------------------------------------------------
+
+void Track::init()
+ {
+ _activity = 0;
+ _lastActivity = 0;
+ _recordFlag = false;
+ _mute = false;
+ _solo = false;
+ _internalSolo = 0;
+ _off = false;
+ _channels = 0; // 1 - mono, 2 - stereo
+
+ _volumeEnCtrl = true;
+ _volumeEn2Ctrl = true;
+ _panEnCtrl = true;
+ _panEn2Ctrl = true;
+
+ _selected = false;
+ _height = 20;
+ _locked = false;
+ for (int i = 0; i < MAX_CHANNELS; ++i) {
+ //_meter[i] = 0;
+ //_peak[i] = 0;
+ _meter[i] = 0.0;
+ _peak[i] = 0.0;
+ }
+ }
+
+Track::Track(Track::TrackType t)
+ {
+ init();
+ _type = t;
+ }
+
+//Track::Track(const Track& t)
+Track::Track(const Track& t, bool cloneParts)
+ {
+ _activity = t._activity;
+ _lastActivity = t._lastActivity;
+ _recordFlag = t._recordFlag;
+ _mute = t._mute;
+ _solo = t._solo;
+ _internalSolo = t._internalSolo;
+ _off = t._off;
+ _channels = t._channels;
+
+ _volumeEnCtrl = t._volumeEnCtrl;
+ _volumeEn2Ctrl = t._volumeEn2Ctrl;
+ _panEnCtrl = t._panEnCtrl;
+ _panEn2Ctrl = t._panEn2Ctrl;
+
+ _selected = t.selected();
+ _y = t._y;
+ _height = t._height;
+ _comment = t.comment();
+ _name = t.name();
+ _type = t.type();
+ _locked = t.locked();
+
+ if(cloneParts)
+ {
+ const PartList* pl = t.cparts();
+ for (ciPart ip = pl->begin(); ip != pl->end(); ++ip) {
+ Part* newPart = ip->second->clone();
+ newPart->setTrack(this);
+ _parts.add(newPart);
+ }
+ }
+ else
+ {
+ _parts = *(t.cparts());
+ // NOTE: We can't do this because of the way clipboard, cloneList, and undoOp::ModifyTrack, work.
+ // A couple of schemes were conceived to deal with cloneList being invalid, but the best way is
+ // to not alter the part list here. It's a big headache because: Either the parts in the cloneList
+ // need to be reliably looked up replaced with the new ones, or the clipboard and cloneList must be cleared.
+ // Fortunately the ONLY part of muse using this function is track rename (in TrackList and TrackInfo).
+ // So we can get away with leaving this out:
+ //for (iPart ip = _parts.begin(); ip != _parts.end(); ++ip)
+ // ip->second->setTrack(this);
+ }
+
+ for (int i = 0; i < MAX_CHANNELS; ++i) {
+ //_meter[i] = 0;
+ //_peak[i] = 0;
+ _meter[i] = 0.0;
+ _peak[i] = 0.0;
+ }
+ }
+
+//---------------------------------------------------------
+// operator =
+// Added by Tim. Parts' track members MUST point to this track,
+// not some other track, so simple assignment operator won't do!
+//---------------------------------------------------------
+
+Track& Track::operator=(const Track& t)
+{
+ _activity = t._activity;
+ _lastActivity = t._lastActivity;
+ _recordFlag = t._recordFlag;
+ _mute = t._mute;
+ _solo = t._solo;
+ _internalSolo = t._internalSolo;
+ _off = t._off;
+ _channels = t._channels;
+
+ _volumeEnCtrl = t._volumeEnCtrl;
+ _volumeEn2Ctrl = t._volumeEn2Ctrl;
+ _panEnCtrl = t._panEnCtrl;
+ _panEn2Ctrl = t._panEn2Ctrl;
+
+ _selected = t.selected();
+ _y = t._y;
+ _height = t._height;
+ _comment = t.comment();
+ _name = t.name();
+ _type = t.type();
+ _locked = t.locked();
+
+ _parts = *(t.cparts());
+ // NOTE: Can't do this. See comments in copy constructor.
+ //for (iPart ip = _parts.begin(); ip != _parts.end(); ++ip)
+ // ip->second->setTrack(this);
+
+ for (int i = 0; i < MAX_CHANNELS; ++i) {
+ _meter[i] = t._meter[i];
+ _peak[i] = t._peak[i];
+ }
+ return *this;
+}
+
+//---------------------------------------------------------
+// setDefaultName
+// generate unique name for track
+//---------------------------------------------------------
+
+void Track::setDefaultName()
+ {
+ QString base;
+ switch(_type) {
+ case MIDI:
+ case DRUM:
+ case WAVE:
+ base = QString("Track");
+ break;
+ case AUDIO_OUTPUT:
+ base = QString("Out");
+ break;
+ case AUDIO_GROUP:
+ base = QString("Group");
+ break;
+ case AUDIO_AUX:
+ base = QString("Aux");
+ break;
+ case AUDIO_INPUT:
+ base = QString("Input");
+ break;
+ case AUDIO_SOFTSYNTH:
+ base = QString("Synth");
+ break;
+ };
+ base += " ";
+ for (int i = 1; true; ++i) {
+ QString n;
+ n.setNum(i);
+ QString s = base + n;
+ Track* track = song->findTrack(s);
+ if (track == 0) {
+ setName(s);
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// clearRecAutomation
+//---------------------------------------------------------
+
+void Track::clearRecAutomation(bool clearList)
+{
+ _volumeEnCtrl = true;
+ _volumeEn2Ctrl = true;
+ _panEnCtrl = true;
+ _panEn2Ctrl = true;
+
+ if(isMidiTrack())
+ return;
+
+ AudioTrack *t = (AudioTrack*)this;
+ Pipeline *pl = t->efxPipe();
+ PluginI *p;
+ for(iPluginI i = pl->begin(); i != pl->end(); ++i)
+ {
+ p = *i;
+ if(!p)
+ continue;
+ p->enableAllControllers(true);
+ }
+
+ if(clearList)
+ t->recEvents()->clear();
+}
+
+//---------------------------------------------------------
+// dump
+//---------------------------------------------------------
+
+void Track::dump() const
+ {
+ printf("Track <%s>: typ %d, parts %zd sel %d\n",
+ _name.toLatin1().constData(), _type, _parts.size(), _selected);
+ }
+
+//---------------------------------------------------------
+// MidiTrack
+//---------------------------------------------------------
+
+MidiTrack::MidiTrack()
+ : Track(MIDI)
+ {
+ init();
+ _events = new EventList;
+ _mpevents = new MPEventList;
+ }
+
+//MidiTrack::MidiTrack(const MidiTrack& mt)
+// : Track(mt)
+MidiTrack::MidiTrack(const MidiTrack& mt, bool cloneParts)
+ : Track(mt, cloneParts)
+ {
+ _outPort = mt.outPort();
+ _outChannel = mt.outChannel();
+ ///_inPortMask = mt.inPortMask();
+ ///_inChannelMask = mt.inChannelMask();
+ _events = new EventList;
+ _mpevents = new MPEventList;
+ transposition = mt.transposition;
+ velocity = mt.velocity;
+ delay = mt.delay;
+ len = mt.len;
+ compression = mt.compression;
+ _recEcho = mt.recEcho();
+ }
+
+MidiTrack::~MidiTrack()
+ {
+ delete _events;
+ delete _mpevents;
+ }
+
+//---------------------------------------------------------
+// init
+//---------------------------------------------------------
+
+void MidiTrack::init()
+ {
+ _outPort = 0;
+ _outChannel = 0;
+ // Changed by Tim. p3.3.8
+ //_inPortMask = 0xffff;
+ ///_inPortMask = 0xffffffff;
+
+ ///_inChannelMask = 0xffff; // "ALL"
+ transposition = 0;
+ velocity = 0;
+ delay = 0;
+ len = 100; // percent
+ compression = 100; // percent
+ _recEcho = true;
+ }
+
+//---------------------------------------------------------
+// setOutChanAndUpdate
+//---------------------------------------------------------
+
+void MidiTrack::setOutChanAndUpdate(int i)
+{
+ if(_outChannel == i)
+ return;
+
+ //removePortCtrlEvents();
+ removePortCtrlEvents(this);
+ _outChannel = i;
+ //addPortCtrlEvents();
+ addPortCtrlEvents(this);
+}
+
+//---------------------------------------------------------
+// setOutPortAndUpdate
+//---------------------------------------------------------
+
+void MidiTrack::setOutPortAndUpdate(int i)
+{
+ if(_outPort == i)
+ return;
+
+ //removePortCtrlEvents();
+ removePortCtrlEvents(this);
+ _outPort = i;
+ //addPortCtrlEvents();
+ addPortCtrlEvents(this);
+}
+
+//---------------------------------------------------------
+// setInPortAndChannelMask
+// For old song files with port mask (max 32 ports) and channel mask (16 channels),
+// before midi routing was added (the iR button). p3.3.48
+//---------------------------------------------------------
+
+void MidiTrack::setInPortAndChannelMask(unsigned int portmask, int chanmask)
+{
+ //if(!portmask || !chanmask)
+ // return;
+
+ //RouteList* rl = inRoutes();
+ bool changed = false;
+
+ for(int port = 0; port < 32; ++port) // 32 is the old maximum number of ports.
+ {
+ // p3.3.50 If the port was not used in the song file to begin with, just ignore it.
+ // This saves from having all of the first 32 ports' channels connected.
+ if(!midiPorts[port].foundInSongFile())
+ continue;
+
+ //if(!(portmask & (1 << port)))
+ // continue;
+
+ // p3.3.50 Removed. Allow to connect to port with no device so user can change device later.
+ //MidiPort* mp = &midiPorts[port];
+ //MidiDevice* md = mp->device();
+ //if(!md)
+ // continue;
+
+ //for(int ch = 0; ch < MIDI_CHANNELS; ++ch) // p3.3.50 Removed.
+ //{
+ //if(!(chanmask & (1 << ch)))
+ // continue;
+
+ //Route aRoute(md, ch);
+ //Route bRoute(this, ch);
+ Route aRoute(port, chanmask); // p3.3.50
+ Route bRoute(this, chanmask);
+
+ // p3.3.50 Removed.
+ //iRoute iir = rl->begin();
+ //for(; iir != rl->end(); ++iir)
+ //{
+ //if(*iir == aRoute)
+ // if(iir->type == Route::MIDI_PORT_ROUTE && iir->midiPort == port) // p3.3.50
+ // break;
+ //}
+
+ // Route wanted?
+ //if((portmask & (1 << port)) && (chanmask & (1 << ch)))
+ if(portmask & (1 << port)) // p3.3.50
+ {
+ // Route already exists?
+ //if(iir != rl->end())
+ // continue;
+ audio->msgAddRoute(aRoute, bRoute);
+ changed = true;
+ }
+ else
+ {
+ // Route does not exist?
+ //if(iir == rl->end())
+ // continue;
+ audio->msgRemoveRoute(aRoute, bRoute);
+ changed = true;
+ }
+ //}
+ }
+
+ if(changed)
+ {
+ audio->msgUpdateSoloStates();
+ song->update(SC_ROUTE);
+ }
+}
+
+/*
+//---------------------------------------------------------
+// addPortCtrlEvents
+//---------------------------------------------------------
+
+void MidiTrack::addPortCtrlEvents()
+{
+ const PartList* pl = cparts();
+ for(ciPart ip = pl->begin(); ip != pl->end(); ++ip)
+ {
+ Part* part = ip->second;
+ const EventList* el = part->cevents();
+ for(ciEvent ie = el->begin(); ie != el->end(); ++ie)
+ {
+ const Event& ev = ie->second;
+ if(ev.type() == Controller)
+ {
+ int tick = ev.tick() + part->tick();
+ int cntrl = ev.dataA();
+ int val = ev.dataB();
+ int ch = _outChannel;
+
+ MidiPort* mp = &midiPorts[_outPort];
+ // Is it a drum controller event, according to the track port's instrument?
+ if(type() == DRUM)
+ {
+ MidiController* mc = mp->drumController(cntrl);
+ if(mc)
+ {
+ int note = cntrl & 0x7f;
+ cntrl &= ~0xff;
+ ch = drumMap[note].channel;
+ mp = &midiPorts[drumMap[note].port];
+ cntrl |= drumMap[note].anote;
+ }
+ }
+
+ mp->setControllerVal(ch, tick, cntrl, val, part);
+ }
+ }
+ }
+}
+
+//---------------------------------------------------------
+// removePortCtrlEvents
+//---------------------------------------------------------
+
+void MidiTrack::removePortCtrlEvents()
+{
+ const PartList* pl = cparts();
+ for(ciPart ip = pl->begin(); ip != pl->end(); ++ip)
+ {
+ Part* part = ip->second;
+ const EventList* el = part->cevents();
+ for(ciEvent ie = el->begin(); ie != el->end(); ++ie)
+ {
+ const Event& ev = ie->second;
+ if(ev.type() == Controller)
+ {
+ int tick = ev.tick() + part->tick();
+ int cntrl = ev.dataA();
+ int ch = _outChannel;
+
+ MidiPort* mp = &midiPorts[_outPort];
+ // Is it a drum controller event, according to the track port's instrument?
+ if(type() == DRUM)
+ {
+ MidiController* mc = mp->drumController(cntrl);
+ if(mc)
+ {
+ int note = cntrl & 0x7f;
+ cntrl &= ~0xff;
+ ch = drumMap[note].channel;
+ mp = &midiPorts[drumMap[note].port];
+ cntrl |= drumMap[note].anote;
+ }
+ }
+
+ mp->deleteController(ch, tick, cntrl, part);
+ }
+ }
+ }
+}
+*/
+
+//---------------------------------------------------------
+// addPart
+//---------------------------------------------------------
+
+iPart Track::addPart(Part* p)
+ {
+ p->setTrack(this);
+ return _parts.add(p);
+ }
+
+//---------------------------------------------------------
+// findPart
+//---------------------------------------------------------
+
+Part* Track::findPart(unsigned tick)
+ {
+ for (iPart i = _parts.begin(); i != _parts.end(); ++i) {
+ Part* part = i->second;
+ if (tick >= part->tick() && tick < (part->tick()+part->lenTick()))
+ return part;
+ }
+ return 0;
+ }
+
+//---------------------------------------------------------
+// newPart
+//---------------------------------------------------------
+
+Part* MidiTrack::newPart(Part*p, bool clone)
+ {
+ MidiPart* part = clone ? new MidiPart(this, p->events()) : new MidiPart(this);
+ if (p) {
+ part->setName(p->name());
+ part->setColorIndex(p->colorIndex());
+
+ *(PosLen*)part = *(PosLen*)p;
+ part->setMute(p->mute());
+ }
+
+ if(clone)
+ //p->chainClone(part);
+ chainClone(p, part);
+
+ return part;
+ }
+
+//---------------------------------------------------------
+// automationType
+//---------------------------------------------------------
+
+AutomationType MidiTrack::automationType() const
+ {
+ MidiPort* port = &midiPorts[outPort()];
+ return port->automationType(outChannel());
+ }
+
+//---------------------------------------------------------
+// setAutomationType
+//---------------------------------------------------------
+
+void MidiTrack::setAutomationType(AutomationType t)
+ {
+ MidiPort* port = &midiPorts[outPort()];
+ port->setAutomationType(outChannel(), t);
+ }
+
+//---------------------------------------------------------
+// Track::writeProperties
+//---------------------------------------------------------
+
+void Track::writeProperties(int level, Xml& xml) const
+ {
+ xml.strTag(level, "name", _name);
+ if (!_comment.isEmpty())
+ xml.strTag(level, "comment", _comment);
+ xml.intTag(level, "record", _recordFlag);
+ xml.intTag(level, "mute", mute());
+ xml.intTag(level, "solo", solo());
+ xml.intTag(level, "off", off());
+ xml.intTag(level, "channels", _channels);
+ xml.intTag(level, "height", _height);
+ xml.intTag(level, "locked", _locked);
+ if (_selected)
+ xml.intTag(level, "selected", _selected);
+ }
+
+//---------------------------------------------------------
+// Track::readProperties
+//---------------------------------------------------------
+
+bool Track::readProperties(Xml& xml, const QString& tag)
+ {
+ if (tag == "name")
+ _name = xml.parse1();
+ else if (tag == "comment")
+ _comment = xml.parse1();
+ else if (tag == "record") {
+ bool recordFlag = xml.parseInt();
+ setRecordFlag1(recordFlag);
+ setRecordFlag2(recordFlag);
+ }
+ else if (tag == "mute")
+ _mute = xml.parseInt();
+ else if (tag == "solo")
+ _solo = xml.parseInt();
+ else if (tag == "off")
+ _off = xml.parseInt();
+ else if (tag == "height")
+ _height = xml.parseInt();
+ else if (tag == "channels")
+ {
+ _channels = xml.parseInt();
+ if(_channels > MAX_CHANNELS)
+ _channels = MAX_CHANNELS;
+ }
+ else if (tag == "locked")
+ _locked = xml.parseInt();
+ else if (tag == "selected")
+ _selected = xml.parseInt();
+ else
+ return true;
+ return false;
+ }
+
+//---------------------------------------------------------
+// writeRouting
+//---------------------------------------------------------
+
+void Track::writeRouting(int level, Xml& xml) const
+{
+ QString s;
+
+ if (type() == Track::AUDIO_INPUT)
+ {
+ const RouteList* rl = &_inRoutes;
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ {
+ if(!r->name().isEmpty())
+ {
+ s = QT_TRANSLATE_NOOP("@default", "Route");
+ if(r->channel != -1)
+ s += QString(QT_TRANSLATE_NOOP("@default", " channel=\"%1\"")).arg(r->channel);
+
+ ///Route dst(name(), true, r->channel);
+ //xml.tag(level++, "Route");
+ xml.tag(level++, s.toAscii().constData());
+
+ // p3.3.38 New routing scheme.
+ ///xml.strTag(level, "srcNode", r->name());
+ //xml.tag(level, "source type=\"%d\" name=\"%s\"/", r->type, r->name().toLatin1().constData());
+ s = QT_TRANSLATE_NOOP("@default", "source");
+ if(r->type != Route::TRACK_ROUTE)
+ s += QString(QT_TRANSLATE_NOOP("@default", " type=\"%1\"")).arg(r->type);
+ //s += QString(QT_TRANSLATE_NOOP("@default", " name=\"%1\"/")).arg(r->name());
+ s += QString(QT_TRANSLATE_NOOP("@default", " name=\"%1\"/")).arg(Xml::xmlString(r->name()));
+ xml.tag(level, s.toAscii().constData());
+
+ ///xml.strTag(level, "dstNode", dst.name());
+
+ //if(r->channel != -1)
+ // xml.tag(level, "dest type=\"%d\" channel=\"%d\" name=\"%s\"/", Route::TRACK_ROUTE, r->channel, name().toLatin1().constData());
+ //else
+ // xml.tag(level, "dest type=\"%d\" name=\"%s\"/", Route::TRACK_ROUTE, name().toLatin1().constData());
+
+ //xml.tag(level, "dest name=\"%s\"/", name().toLatin1().constData());
+ xml.tag(level, "dest name=\"%s\"/", Xml::xmlString(name()).toLatin1().constData());
+
+ xml.etag(level--, "Route");
+ }
+ }
+ }
+
+ const RouteList* rl = &_outRoutes;
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r)
+ {
+ //if(!r->name().isEmpty())
+ if(r->midiPort != -1 || !r->name().isEmpty()) // p3.3.49
+ {
+ ///QString src(name());
+ ///if (type() == Track::AUDIO_OUTPUT)
+ ///{
+ ///Route s(src, false, r->channel);
+ ///src = s.name();
+ ///}
+
+ s = QT_TRANSLATE_NOOP("@default", "Route");
+ if(r->type == Route::MIDI_PORT_ROUTE) // p3.3.50
+ {
+ if(r->channel != -1 && r->channel != 0)
+ s += QString(QT_TRANSLATE_NOOP("@default", " channelMask=\"%1\"")).arg(r->channel); // Use new channel mask.
+ }
+ else
+ {
+ if(r->channel != -1)
+ s += QString(QT_TRANSLATE_NOOP("@default", " channel=\"%1\"")).arg(r->channel);
+ }
+ if(r->channels != -1)
+ s += QString(QT_TRANSLATE_NOOP("@default", " channels=\"%1\"")).arg(r->channels);
+ if(r->remoteChannel != -1)
+ s += QString(QT_TRANSLATE_NOOP("@default", " remch=\"%1\"")).arg(r->remoteChannel);
+
+ //xml.tag(level++, "Route");
+ xml.tag(level++, s.toAscii().constData());
+
+ ///xml.strTag(level, "srcNode", src);
+ //if(r->channel != -1)
+
+ // Allow for a regular mono or stereo track to feed a multi-channel synti.
+ // thisChannel is the 'starting' channel of this source if feeding a regular track.
+ //if(r->type == Route::TRACK_ROUTE && r->track->isSynti() && r->channel != -1)
+ //if(isSynti() && r->thisChannel != -1)
+ //xml.tag(level, "source type=\"%d\" channel=\"%d\" name=\"%s\"/", Route::TRACK_ROUTE, r->channel, name().toLatin1().constData());
+ // xml.tag(level, "source type=\"%d\" channel=\"%d\" name=\"%s\"/", Route::TRACK_ROUTE, r->thisChannel, name().toLatin1().constData());
+ //else
+
+ //if(r->channel != -1)
+ // xml.tag(level, "source type=\"%d\" channel=\"%d\" name=\"%s\"/", Route::TRACK_ROUTE, r->channel, name().toLatin1().constData());
+ //else
+ // xml.tag(level, "source type=\"%d\" name=\"%s\"/", Route::TRACK_ROUTE, name().toLatin1().constData());
+ //xml.tag(level, "source name=\"%s\"/", name().toLatin1().constData());
+ xml.tag(level, "source name=\"%s\"/", Xml::xmlString(name()).toLatin1().constData());
+
+ ///xml.strTag(level, "dstNode", r->name());
+ //if(r->channel != -1)
+ // xml.tag(level, "dest type=\"%d\" channel=\"%d\" name=\"%s\"/", r->type, r->channel, r->name().toLatin1().constData());
+ //else
+ // xml.tag(level, "dest type=\"%d\" name=\"%s\"/", r->type, r->name().toLatin1().constData());
+
+ // Allow for a regular mono or stereo track to feed a multi-channel synti.
+ // Channel is the 'starting' channel of the destination.
+ //if(r->type == Route::TRACK_ROUTE && r->track->isSynti() && r->channel != -1)
+
+ //if(r->type == Route::TRACK_ROUTE && r->track->type() == Track::AUDIO_SOFTSYNTH && r->remoteChannel != -1)
+ // xml.tag(level, "dest type=\"%d\" channel=\"%d\" name=\"%s\"/", r->type, r->remoteChannel, r->name().toLatin1().constData());
+ //else
+ //if(r->type == Route::MIDI_DEVICE_ROUTE)
+ // xml.tag(level, "dest devtype=\"%d\" name=\"%s\"/", r->device->deviceType(), r->name().toLatin1().constData());
+ //else
+ // xml.tag(level, "dest type=\"%d\" name=\"%s\"/", r->type, r->name().toLatin1().constData());
+
+ s = QT_TRANSLATE_NOOP("@default", "dest");
+
+ //if(r->type == Route::MIDI_DEVICE_ROUTE) // p3.3.49 Obsolete since 1.1-RC2
+ // s += QString(QT_TRANSLATE_NOOP("@default", " devtype=\"%1\"")).arg(r->device->deviceType()); //
+ //if(r->type != Route::TRACK_ROUTE) //
+ if(r->type != Route::TRACK_ROUTE && r->type != Route::MIDI_PORT_ROUTE)
+ s += QString(QT_TRANSLATE_NOOP("@default", " type=\"%1\"")).arg(r->type);
+
+ //s += QString(QT_TRANSLATE_NOOP("@default", " name=\"%1\"/")).arg(r->name());
+ if(r->type == Route::MIDI_PORT_ROUTE) // p3.3.49
+ s += QString(QT_TRANSLATE_NOOP("@default", " mport=\"%1\"/")).arg(r->midiPort);
+ else
+ s += QString(QT_TRANSLATE_NOOP("@default", " name=\"%1\"/")).arg(Xml::xmlString(r->name()));
+
+ xml.tag(level, s.toAscii().constData());
+
+ xml.etag(level--, "Route");
+ }
+ }
+}
+
+//---------------------------------------------------------
+// MidiTrack::write
+//---------------------------------------------------------
+
+void MidiTrack::write(int level, Xml& xml) const
+ {
+ const char* tag;
+
+ if (type() == DRUM)
+ tag = "drumtrack";
+ else
+ tag = "miditrack";
+ xml.tag(level++, tag);
+ Track::writeProperties(level, xml);
+
+ xml.intTag(level, "device", outPort());
+ xml.intTag(level, "channel", outChannel());
+ //xml.intTag(level, "inportMap", inPortMask());
+ ///xml.uintTag(level, "inportMap", inPortMask()); // Obsolete
+ ///xml.intTag(level, "inchannelMap", inChannelMask()); // Obsolete
+ xml.intTag(level, "locked", _locked);
+ xml.intTag(level, "echo", _recEcho);
+
+ xml.intTag(level, "transposition", transposition);
+ xml.intTag(level, "velocity", velocity);
+ xml.intTag(level, "delay", delay);
+ xml.intTag(level, "len", len);
+ xml.intTag(level, "compression", compression);
+ xml.intTag(level, "automation", int(automationType()));
+
+ const PartList* pl = cparts();
+ for (ciPart p = pl->begin(); p != pl->end(); ++p)
+ p->second->write(level, xml);
+ xml.etag(level, tag);
+ }
+
+//---------------------------------------------------------
+// MidiTrack::read
+//---------------------------------------------------------
+
+void MidiTrack::read(Xml& xml)
+ {
+ unsigned int portmask = 0;
+ int chanmask = 0;
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "transposition")
+ transposition = xml.parseInt();
+ else if (tag == "velocity")
+ velocity = xml.parseInt();
+ else if (tag == "delay")
+ delay = xml.parseInt();
+ else if (tag == "len")
+ len = xml.parseInt();
+ else if (tag == "compression")
+ compression = xml.parseInt();
+ else if (tag == "part") {
+ //Part* p = newPart();
+ //p->read(xml);
+ Part* p = 0;
+ p = readXmlPart(xml, this);
+ if(p)
+ parts()->add(p);
+ }
+ else if (tag == "device")
+ setOutPort(xml.parseInt());
+ else if (tag == "channel")
+ setOutChannel(xml.parseInt());
+ else if (tag == "inportMap")
+ //setInPortMask(xml.parseInt());
+ ///setInPortMask(xml.parseUInt());
+ //xml.skip(tag); // Obsolete.
+ portmask = xml.parseUInt(); // p3.3.48: Support old files.
+ else if (tag == "inchannelMap")
+ ///setInChannelMask(xml.parseInt());
+ //xml.skip(tag); // Obsolete.
+ chanmask = xml.parseInt(); // p3.3.48: Support old files.
+ else if (tag == "locked")
+ _locked = xml.parseInt();
+ else if (tag == "echo")
+ _recEcho = xml.parseInt();
+ else if (tag == "automation")
+ setAutomationType(AutomationType(xml.parseInt()));
+ else if (Track::readProperties(xml, tag)) {
+ // version 1.0 compatibility:
+ if (tag == "track" && xml.majorVersion() == 1 && xml.minorVersion() == 0)
+ break;
+ xml.unknown("MidiTrack");
+ }
+ break;
+ case Xml::Attribut:
+ break;
+ case Xml::TagEnd:
+ if (tag == "miditrack" || tag == "drumtrack")
+ {
+ setInPortAndChannelMask(portmask, chanmask); // p3.3.48: Support old files.
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/track.h b/attic/muse2-oom/muse2/muse/track.h
new file mode 100644
index 00000000..48c9474e
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/track.h
@@ -0,0 +1,681 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: track.h,v 1.39.2.17 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 1999-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __TRACK_H__
+#define __TRACK_H__
+
+#include <QString>
+
+#include <vector>
+#include <algorithm>
+
+#include "part.h"
+#include "key.h"
+#include "node.h"
+#include "route.h"
+#include "ctrl.h"
+#include "globaldefs.h"
+
+class Pipeline;
+class Xml;
+class SndFile;
+class MPEventList;
+class SynthI;
+class PluginI;
+
+//---------------------------------------------------------
+// Track
+//---------------------------------------------------------
+
+class Track {
+ public:
+ enum TrackType {
+ MIDI=0, DRUM, WAVE, AUDIO_OUTPUT, AUDIO_INPUT, AUDIO_GROUP,
+ AUDIO_AUX, AUDIO_SOFTSYNTH
+ };
+ private:
+ TrackType _type;
+ QString _comment;
+
+ PartList _parts;
+
+ void init();
+
+ protected:
+ static unsigned int _soloRefCnt;
+ static Track* _tmpSoloChainTrack;
+ static bool _tmpSoloChainDoIns;
+ static bool _tmpSoloChainNoDec;
+
+ // p3.3.38
+ RouteList _inRoutes;
+ RouteList _outRoutes;
+
+ QString _name;
+ bool _recordFlag;
+ bool _mute;
+ bool _solo;
+ unsigned int _internalSolo;
+ bool _off;
+ int _channels; // 1 - mono, 2 - stereo
+
+ bool _volumeEnCtrl;
+ bool _volumeEn2Ctrl;
+ bool _panEnCtrl;
+ bool _panEn2Ctrl;
+
+ int _activity;
+ int _lastActivity;
+ //int _meter[MAX_CHANNELS];
+ //int _peak[MAX_CHANNELS];
+ double _meter[MAX_CHANNELS];
+ double _peak[MAX_CHANNELS];
+
+ int _y;
+ int _height; // visual height in arranger
+
+ bool _locked;
+ bool _selected;
+ bool readProperties(Xml& xml, const QString& tag);
+ void writeProperties(int level, Xml& xml) const;
+
+ public:
+ Track(TrackType);
+ //Track(const Track&);
+ Track(const Track&, bool cloneParts);
+ virtual ~Track() {};
+ virtual Track& operator=(const Track& t);
+
+ static const char* _cname[];
+
+ QString comment() const { return _comment; }
+ void setComment(const QString& s) { _comment = s; }
+
+ int y() const;
+ void setY(int n) { _y = n; }
+ int height() const { return _height; }
+ void setHeight(int n) { _height = n; }
+
+ bool selected() const { return _selected; }
+ void setSelected(bool f) { _selected = f; }
+ bool locked() const { return _locked; }
+ void setLocked(bool b) { _locked = b; }
+
+ bool volumeControllerEnabled() const { return _volumeEnCtrl; }
+ bool volumeControllerEnabled2() const { return _volumeEn2Ctrl; }
+ bool panControllerEnabled() const { return _panEnCtrl; }
+ bool panControllerEnabled2() const { return _panEn2Ctrl; }
+ void enableVolumeController(bool b) { _volumeEnCtrl = b; }
+ void enable2VolumeController(bool b) { _volumeEn2Ctrl = b; }
+ void enablePanController(bool b) { _panEnCtrl = b; }
+ void enable2PanController(bool b) { _panEn2Ctrl = b; }
+ void clearRecAutomation(bool clearList);
+
+ const QString& name() const { return _name; }
+ virtual void setName(const QString& s) { _name = s; }
+
+ TrackType type() const { return _type; }
+ void setType(TrackType t) { _type = t; }
+ QString cname() const { int t = type(); return QString(_cname[t]); }
+
+ // routing
+ RouteList* inRoutes() { return &_inRoutes; }
+ RouteList* outRoutes() { return &_outRoutes; }
+ bool noInRoute() const { return _inRoutes.empty(); }
+ bool noOutRoute() const { return _outRoutes.empty(); }
+ void writeRouting(int, Xml&) const;
+
+ PartList* parts() { return &_parts; }
+ const PartList* cparts() const { return &_parts; }
+ Part* findPart(unsigned tick);
+ iPart addPart(Part* p);
+
+ virtual void write(int, Xml&) const = 0;
+
+ virtual Track* newTrack() const = 0;
+ //virtual Track* clone() const = 0;
+ virtual Track* clone(bool CloneParts) const = 0;
+
+ virtual bool setRecordFlag1(bool f) = 0;
+ virtual void setRecordFlag2(bool f) = 0;
+
+ virtual Part* newPart(Part*p=0, bool clone = false) = 0;
+ void dump() const;
+ virtual void splitPart(Part*, int, Part*&, Part*&);
+
+ virtual void setMute(bool val);
+ virtual void setOff(bool val);
+ virtual void updateSoloStates(bool noDec) = 0;
+ virtual void updateInternalSoloStates();
+ void updateSoloState();
+ void setInternalSolo(unsigned int val);
+ static void clearSoloRefCounts();
+ virtual void setSolo(bool val) = 0;
+ virtual bool isMute() const = 0;
+
+ unsigned int internalSolo() const { return _internalSolo; }
+ bool soloMode() const { return _soloRefCnt; }
+ bool solo() const { return _solo; }
+ bool mute() const { return _mute; }
+ bool off() const { return _off; }
+ bool recordFlag() const { return _recordFlag; }
+
+ int activity() { return _activity; }
+ void setActivity(int v) { _activity = v; }
+ int lastActivity() { return _lastActivity; }
+ void setLastActivity(int v) { _lastActivity = v; }
+ void addActivity(int v) { _activity += v; }
+ void resetPeaks();
+ static void resetAllMeter();
+ //int meter(int ch) const { return _meter[ch]; }
+ //int peak(int ch) const { return _peak[ch]; }
+ double meter(int ch) const { return _meter[ch]; }
+ double peak(int ch) const { return _peak[ch]; }
+ void resetMeter();
+
+ bool readProperty(Xml& xml, const QString& tag);
+ void setDefaultName();
+ int channels() const { return _channels; }
+ virtual void setChannels(int n);
+ bool isMidiTrack() const { return type() == MIDI || type() == DRUM; }
+ virtual bool canRecord() const { return false; }
+ virtual AutomationType automationType() const = 0;
+ virtual void setAutomationType(AutomationType t) = 0;
+ };
+
+//---------------------------------------------------------
+// MidiTrack
+//---------------------------------------------------------
+
+class MidiTrack : public Track {
+ //friend class AudioTrack;
+ //static unsigned int _soloRefCnt;
+
+ int _outPort;
+ int _outChannel;
+ //int _inPortMask;
+ ///unsigned int _inPortMask; // bitmask of accepted record ports
+ ///int _inChannelMask; // bitmask of accepted record channels
+ bool _recEcho; // For midi (and audio). Whether to echo incoming record events to output device.
+
+ EventList* _events; // tmp Events during midi import
+ MPEventList* _mpevents; // tmp Events druring recording
+
+ public:
+ MidiTrack();
+ //MidiTrack(const MidiTrack&);
+ MidiTrack(const MidiTrack&, bool cloneParts);
+ virtual ~MidiTrack();
+
+ void init();
+ virtual AutomationType automationType() const;
+ virtual void setAutomationType(AutomationType);
+
+ // play parameter
+ int transposition;
+ int velocity;
+ int delay;
+ int len;
+ int compression;
+
+ virtual bool setRecordFlag1(bool f) { _recordFlag = f; return true;}
+ virtual void setRecordFlag2(bool) {}
+
+ EventList* events() const { return _events; }
+ MPEventList* mpevents() const { return _mpevents; }
+
+ virtual void read(Xml&);
+ virtual void write(int, Xml&) const;
+
+ virtual MidiTrack* newTrack() const { return new MidiTrack(); }
+ //virtual MidiTrack* clone() const { return new MidiTrack(*this); }
+ virtual MidiTrack* clone(bool cloneParts) const { return new MidiTrack(*this, cloneParts); }
+ virtual Part* newPart(Part*p=0, bool clone=false);
+
+ void setOutChannel(int i) { _outChannel = i; }
+ void setOutPort(int i) { _outPort = i; }
+ void setOutChanAndUpdate(int i);
+ void setOutPortAndUpdate(int i);
+
+ //void setInPortMask(int i) { _inPortMask = i; }
+ ///void setInPortMask(unsigned int i) { _inPortMask = i; } // Obsolete
+ ///void setInChannelMask(int i) { _inChannelMask = i; } //
+ // Backward compatibility: For reading old songs.
+ void setInPortAndChannelMask(unsigned int /*portmask*/, int /*chanmask*/);
+
+ void setRecEcho(bool b) { _recEcho = b; }
+ int outPort() const { return _outPort; }
+ //int inPortMask() const { return _inPortMask; }
+ ///unsigned int inPortMask() const { return _inPortMask; }
+ int outChannel() const { return _outChannel; }
+ ///int inChannelMask() const { return _inChannelMask; }
+ bool recEcho() const { return _recEcho; }
+
+ virtual bool isMute() const;
+ virtual void setSolo(bool val);
+ virtual void updateSoloStates(bool noDec);
+ virtual void updateInternalSoloStates();
+
+ //bool soloMode() const { return _soloRefCnt; }
+
+ virtual bool canRecord() const { return true; }
+ };
+
+//---------------------------------------------------------
+// AudioTrack
+// this track can hold audio automation data and can
+// hold tracktypes AUDIO, AUDIO_MASTER, AUDIO_GROUP,
+// AUDIO_INPUT, AUDIO_SOFTSYNTH, AUDIO_AUX
+//---------------------------------------------------------
+
+class AudioTrack : public Track {
+ //friend class MidiTrack;
+ //static unsigned int _soloRefCnt;
+
+ bool _haveData;
+
+ CtrlListList _controller;
+ CtrlRecList _recEvents; // recorded automation events
+
+ bool _prefader; // prefader metering
+ std::vector<double> _auxSend;
+ Pipeline* _efxPipe;
+
+ AutomationType _automationType;
+
+ //RouteList _inRoutes;
+ //RouteList _outRoutes;
+
+ bool _sendMetronome;
+
+ //void readRecfile(Xml& xml);
+ void readAuxSend(Xml& xml);
+
+ protected:
+ float** outBuffers;
+ //float* outBuffers[MAX_CHANNELS];
+ int _totalOutChannels;
+ int _totalInChannels;
+
+ unsigned bufferPos;
+ virtual bool getData(unsigned, int, unsigned, float**);
+ SndFile* _recFile;
+ Fifo fifo; // fifo -> _recFile
+ bool _processed;
+
+ public:
+ AudioTrack(TrackType t);
+ //AudioTrack(TrackType t, int num_out_bufs = MAX_CHANNELS);
+
+ //AudioTrack(const AudioTrack&);
+ AudioTrack(const AudioTrack&, bool cloneParts);
+ virtual ~AudioTrack();
+
+ virtual bool setRecordFlag1(bool f);
+ virtual void setRecordFlag2(bool f);
+ bool prepareRecording();
+
+ bool processed() { return _processed; }
+ //void setProcessed(bool v) { _processed = v; }
+
+ void addController(CtrlList*);
+ void removeController(int id);
+ void swapControllerIDX(int idx1, int idx2);
+
+ bool readProperties(Xml&, const QString&);
+ void writeProperties(int, Xml&) const;
+
+ void mapRackPluginsToControllers();
+ void showPendingPluginNativeGuis();
+
+ //virtual AudioTrack* clone() const = 0;
+ virtual AudioTrack* clone(bool cloneParts) const = 0;
+ virtual Part* newPart(Part*p=0, bool clone=false);
+
+ SndFile* recFile() const { return _recFile; }
+ void setRecFile(SndFile* sf) { _recFile = sf; }
+
+ CtrlListList* controller() { return &_controller; }
+
+ virtual void setChannels(int n);
+ virtual void setTotalOutChannels(int num);
+ virtual int totalOutChannels() { return _totalOutChannels; }
+ virtual void setTotalInChannels(int num);
+ virtual int totalInChannels() { return _totalInChannels; }
+
+ virtual bool isMute() const;
+ virtual void setSolo(bool val);
+ virtual void updateSoloStates(bool noDec);
+ virtual void updateInternalSoloStates();
+
+ //bool soloMode() const { return _soloRefCnt; }
+
+ void putFifo(int channels, unsigned long n, float** bp);
+
+ void record();
+
+ virtual void setMute(bool val);
+ virtual void setOff(bool val);
+
+ void setSendMetronome(bool val) { _sendMetronome = val; }
+ bool sendMetronome() const { return _sendMetronome; }
+
+ double volume() const;
+ void setVolume(double val);
+ double pan() const;
+ void setPan(double val);
+
+ bool prefader() const { return _prefader; }
+ double auxSend(int idx) const;
+ void setAuxSend(int idx, double v);
+ void addAuxSend(int n);
+
+ void setPrefader(bool val);
+ Pipeline* efxPipe() { return _efxPipe; }
+ void deleteAllEfxGuis();
+ void clearEfxList();
+ void addPlugin(PluginI* plugin, int idx);
+
+ double pluginCtrlVal(int ctlID) const;
+ void setPluginCtrlVal(int param, double val);
+
+ void readVolume(Xml& xml);
+ //void writeRouting(int, Xml&) const;
+
+ // routing
+ //RouteList* inRoutes() { return &_inRoutes; }
+ //RouteList* outRoutes() { return &_outRoutes; }
+ //bool noInRoute() const { return _inRoutes.empty(); }
+ //bool noOutRoute() const { return _outRoutes.empty(); }
+
+ virtual void preProcessAlways() { _processed = false; }
+ virtual void addData(unsigned /*samplePos*/, int /*channels*/, int /*srcStartChan*/, int /*srcChannels*/, unsigned /*frames*/, float** /*buffer*/);
+ virtual void copyData(unsigned /*samplePos*/, int /*channels*/, int /*srcStartChan*/, int /*srcChannels*/, unsigned /*frames*/, float** /*buffer*/);
+ virtual bool hasAuxSend() const { return false; }
+
+ // automation
+ virtual AutomationType automationType() const { return _automationType; }
+ virtual void setAutomationType(AutomationType t);
+ void processAutomationEvents();
+ CtrlRecList* recEvents() { return &_recEvents; }
+ void recordAutomation(int n, double v);
+ void startAutoRecord(int, double);
+ void stopAutoRecord(int, double);
+ void setControllerMode(int, CtrlList::Mode m);
+ void clearControllerEvents(int);
+ void seekPrevACEvent(int);
+ void seekNextACEvent(int);
+ void eraseACEvent(int, int);
+ void eraseRangeACEvents(int, int, int);
+ void addACEvent(int, int, double);
+ };
+
+//---------------------------------------------------------
+// AudioInput
+//---------------------------------------------------------
+
+class AudioInput : public AudioTrack {
+ void* jackPorts[MAX_CHANNELS];
+ virtual bool getData(unsigned, int, unsigned, float**);
+
+ public:
+ AudioInput();
+ //AudioInput(const AudioInput&);
+ AudioInput(const AudioInput&, bool cloneParts);
+ virtual ~AudioInput();
+ //AudioInput* clone() const { return new AudioInput(*this); }
+ AudioInput* clone(bool cloneParts) const { return new AudioInput(*this, cloneParts); }
+ virtual AudioInput* newTrack() const { return new AudioInput(); }
+ virtual void read(Xml&);
+ virtual void write(int, Xml&) const;
+ virtual void setName(const QString& s);
+ void* jackPort(int channel) { return jackPorts[channel]; }
+ void setJackPort(int channel, void*p) { jackPorts[channel] = p; }
+ virtual void setChannels(int n);
+ virtual bool hasAuxSend() const { return true; }
+ };
+
+//---------------------------------------------------------
+// AudioOutput
+//---------------------------------------------------------
+
+class AudioOutput : public AudioTrack {
+ void* jackPorts[MAX_CHANNELS];
+ float* buffer[MAX_CHANNELS];
+ float* buffer1[MAX_CHANNELS];
+ unsigned long _nframes;
+
+ float* _monitorBuffer[MAX_CHANNELS];
+
+ public:
+ AudioOutput();
+ //AudioOutput(const AudioOutput&);
+ AudioOutput(const AudioOutput&, bool cloneParts);
+ virtual ~AudioOutput();
+ //AudioOutput* clone() const { return new AudioOutput(*this); }
+ AudioOutput* clone(bool cloneParts) const { return new AudioOutput(*this, cloneParts); }
+ virtual AudioOutput* newTrack() const { return new AudioOutput(); }
+ virtual void read(Xml&);
+ virtual void write(int, Xml&) const;
+ virtual void setName(const QString& s);
+ void* jackPort(int channel) { return jackPorts[channel]; }
+ void setJackPort(int channel, void*p) { jackPorts[channel] = p; }
+ virtual void setChannels(int n);
+// virtual bool isMute() const;
+
+ void processInit(unsigned);
+ void process(unsigned pos, unsigned offset, unsigned);
+ void processWrite();
+ void silence(unsigned);
+ virtual bool canRecord() const { return true; }
+
+ float** monitorBuffer() { return _monitorBuffer; }
+ };
+
+//---------------------------------------------------------
+// AudioGroup
+//---------------------------------------------------------
+
+class AudioGroup : public AudioTrack {
+ public:
+ AudioGroup() : AudioTrack(AUDIO_GROUP) { }
+ //AudioGroup* clone() const { return new AudioGroup(*this); }
+ AudioGroup* clone(bool /*cloneParts*/) const { return new AudioGroup(*this); }
+ virtual AudioGroup* newTrack() const { return new AudioGroup(); }
+ virtual void read(Xml&);
+ virtual void write(int, Xml&) const;
+ virtual bool hasAuxSend() const { return true; }
+ };
+
+//---------------------------------------------------------
+// AudioAux
+//---------------------------------------------------------
+
+class AudioAux : public AudioTrack {
+ float* buffer[MAX_CHANNELS];
+
+ public:
+ AudioAux();
+ //AudioAux* clone() const { return new AudioAux(*this); }
+ AudioAux* clone(bool /*cloneParts*/) const { return new AudioAux(*this); }
+ ~AudioAux();
+ virtual AudioAux* newTrack() const { return new AudioAux(); }
+ virtual void read(Xml&);
+ virtual void write(int, Xml&) const;
+ virtual bool getData(unsigned, int, unsigned, float**);
+ virtual void setChannels(int n);
+ float** sendBuffer() { return buffer; }
+ };
+
+//---------------------------------------------------------
+// WaveTrack
+//---------------------------------------------------------
+
+class WaveTrack : public AudioTrack {
+ Fifo _prefetchFifo; // prefetch Fifo
+
+ public:
+ static bool firstWaveTrack;
+
+ WaveTrack() : AudioTrack(Track::WAVE) { }
+ //WaveTrack(const WaveTrack& wt) : AudioTrack(wt) {}
+ WaveTrack(const WaveTrack& wt, bool cloneParts) : AudioTrack(wt, cloneParts) {}
+
+ //virtual WaveTrack* clone() const { return new WaveTrack(*this); }
+ virtual WaveTrack* clone(bool cloneParts) const { return new WaveTrack(*this, cloneParts); }
+ virtual WaveTrack* newTrack() const { return new WaveTrack(); }
+ virtual Part* newPart(Part*p=0, bool clone=false);
+
+ virtual void read(Xml&);
+ virtual void write(int, Xml&) const;
+
+ //virtual void fetchData(unsigned pos, unsigned frames, float** bp);
+ virtual void fetchData(unsigned pos, unsigned frames, float** bp, bool doSeek);
+
+ virtual bool getData(unsigned, int ch, unsigned, float** bp);
+
+ void clearPrefetchFifo() { _prefetchFifo.clear(); }
+ Fifo* prefetchFifo() { return &_prefetchFifo; }
+ virtual void setChannels(int n);
+ virtual bool hasAuxSend() const { return true; }
+ bool canEnableRecord() const;
+ virtual bool canRecord() const { return true; }
+ };
+
+//---------------------------------------------------------
+// TrackList
+//---------------------------------------------------------
+
+template<class T> class tracklist : public std::vector<Track*> {
+ typedef std::vector<Track*> vlist;
+
+ public:
+ class iterator : public vlist::iterator {
+ public:
+ iterator() : vlist::iterator() {}
+ iterator(vlist::iterator i) : vlist::iterator(i) {}
+
+ T operator*() {
+ return (T)(**((vlist::iterator*)this));
+ }
+ iterator operator++(int) {
+ return iterator ((*(vlist::iterator*)this).operator++(0));
+ }
+ iterator& operator++() {
+ return (iterator&) ((*(vlist::iterator*)this).operator++());
+ }
+ };
+
+ class const_iterator : public vlist::const_iterator {
+ public:
+ const_iterator() : vlist::const_iterator() {}
+ const_iterator(vlist::const_iterator i) : vlist::const_iterator(i) {}
+ const_iterator(vlist::iterator i) : vlist::const_iterator(i) {}
+
+ const T operator*() const {
+ return (T)(**((vlist::const_iterator*)this));
+ }
+ };
+
+ class reverse_iterator : public vlist::reverse_iterator {
+ public:
+ reverse_iterator() : vlist::reverse_iterator() {}
+ reverse_iterator(vlist::reverse_iterator i) : vlist::reverse_iterator(i) {}
+
+ T operator*() {
+ return (T)(**((vlist::reverse_iterator*)this));
+ }
+ };
+
+ tracklist() : vlist() {}
+ virtual ~tracklist() {}
+
+ void push_back(T v) { vlist::push_back(v); }
+ iterator begin() { return vlist::begin(); }
+ iterator end() { return vlist::end(); }
+ const_iterator begin() const { return vlist::begin(); }
+ const_iterator end() const { return vlist::end(); }
+ reverse_iterator rbegin() { return vlist::rbegin(); }
+ reverse_iterator rend() { return vlist::rend(); }
+ T& back() const { return (T&)(vlist::back()); }
+ T& front() const { return (T&)(vlist::front()); }
+ iterator find(const Track* t) {
+ return std::find(begin(), end(), t);
+ }
+ const_iterator find(const Track* t) const {
+ return std::find(begin(), end(), t);
+ }
+ unsigned index(const Track* t) const {
+ unsigned n = 0;
+ for (vlist::const_iterator i = begin(); i != end(); ++i, ++n) {
+ if (*i == t)
+ return n;
+ }
+ return -1;
+ }
+ T index(int k) const { return (*this)[k]; }
+ iterator index2iterator(int k) {
+ if ((unsigned)k >= size())
+ return end();
+ return begin() + k;
+ }
+ void erase(Track* t) { vlist::erase(find(t)); }
+
+ void clearDelete() {
+ for (vlist::iterator i = begin(); i != end(); ++i)
+ delete *i;
+ vlist::clear();
+ }
+ void erase(vlist::iterator i) { vlist::erase(i); }
+ void replace(Track* ot, Track* nt) {
+ for (vlist::iterator i = begin(); i != end(); ++i) {
+ if (*i == ot) {
+ *i = nt;
+ return;
+ }
+ }
+ }
+ };
+
+typedef tracklist<Track*> TrackList;
+typedef TrackList::iterator iTrack;
+typedef TrackList::const_iterator ciTrack;
+
+typedef tracklist<MidiTrack*>::iterator iMidiTrack;
+typedef tracklist<MidiTrack*>::const_iterator ciMidiTrack;
+typedef tracklist<MidiTrack*> MidiTrackList;
+
+typedef tracklist<WaveTrack*>::iterator iWaveTrack;
+typedef tracklist<WaveTrack*>::const_iterator ciWaveTrack;
+typedef tracklist<WaveTrack*> WaveTrackList;
+
+typedef tracklist<AudioInput*>::iterator iAudioInput;
+typedef tracklist<AudioInput*>::const_iterator ciAudioInput;
+typedef tracklist<AudioInput*> InputList;
+
+typedef tracklist<AudioOutput*>::iterator iAudioOutput;
+typedef tracklist<AudioOutput*>::const_iterator ciAudioOutput;
+typedef tracklist<AudioOutput*> OutputList;
+
+typedef tracklist<AudioGroup*>::iterator iAudioGroup;
+typedef tracklist<AudioGroup*>::const_iterator ciAudioGroup;
+typedef tracklist<AudioGroup*> GroupList;
+
+typedef tracklist<AudioAux*>::iterator iAudioAux;
+typedef tracklist<AudioAux*>::const_iterator ciAudioAux;
+typedef tracklist<AudioAux*> AuxList;
+
+typedef tracklist<SynthI*>::iterator iSynthI;
+typedef tracklist<SynthI*>::const_iterator ciSynthI;
+typedef tracklist<SynthI*> SynthIList;
+
+extern void addPortCtrlEvents(MidiTrack* t);
+extern void removePortCtrlEvents(MidiTrack* t);
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/trackview.cpp b/attic/muse2-oom/muse2/muse/trackview.cpp
new file mode 100644
index 00000000..e9d2f127
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/trackview.cpp
@@ -0,0 +1,119 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: $
+//
+// (C) Copyright 2010 Andrew Williams and Christopher Cherrett
+//=========================================================
+
+#include "event.h"
+#include "song.h"
+#include "xml.h"
+#include "globaldefs.h"
+#include "trackview.h"
+#include "track.h"
+
+TrackView::TrackView()
+{
+}
+
+TrackView::~TrackView()
+{
+}
+
+void TrackView::setDefaultName()/*{{{*/
+{
+ QString base;
+ switch(_type) {
+ case Track::MIDI:
+ case Track::DRUM:
+ case Track::WAVE:
+ base = QString("Track View");
+ break;
+ case Track::AUDIO_OUTPUT:
+ base = QString("Out View");
+ break;
+ case Track::AUDIO_GROUP:
+ base = QString("Group View");
+ break;
+ case Track::AUDIO_AUX:
+ base = QString("Aux View");
+ break;
+ case Track::AUDIO_INPUT:
+ base = QString("Input View");
+ break;
+ case Track::AUDIO_SOFTSYNTH:
+ base = QString("Synth View");
+ break;
+ };
+ base += " ";
+ for (int i = 1; true; ++i) {
+ QString n;
+ n.setNum(i);
+ QString s = base + n;
+ TrackView* tv = song->findTrackView(s);
+ if (tv == 0) {
+ setViewName(s);
+ break;
+ }
+ }
+}/*}}}*/
+
+//---------------------------------------------------------
+// addTrack
+//---------------------------------------------------------
+
+void TrackView::addTrack(Track* t)/*{{{*/
+{
+ Track::TrackType type = (Track::TrackType) t->type();
+ if(type == _type)
+ {
+ _tracks.push_back(t);
+ }
+}/*}}}*/
+
+void TrackView::removeTrack(Track* t)
+{
+ _tracks.erase(t);
+ //This needs to fire something so the gui gets updated
+}
+
+//---------------------------------------------------------
+// TrackView::read
+//---------------------------------------------------------
+
+void TrackView::read(Xml& xml)/*{{{*/
+{
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "vtrack") {
+ Track* t = song->findTrack(xml.parse1());
+ if(t != 0)
+ {
+ addTrack(t);
+ }
+ }
+ break;
+ case Xml::Attribut:
+ if (tag == "name")
+ _name = xml.parse1();
+ else if (tag == "comment")
+ _comment = xml.parse1();
+ else if (tag == "selected")
+ _selected = xml.parseInt();
+ else if(tag == "type")
+ _type = (Track::TrackType)xml.parseInt();
+ break;
+ case Xml::TagEnd:
+ break;
+ default:
+ break;
+ }
+ }
+}/*}}}*/
diff --git a/attic/muse2-oom/muse2/muse/trackview.h b/attic/muse2-oom/muse2/muse/trackview.h
new file mode 100644
index 00000000..7ec6295c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/trackview.h
@@ -0,0 +1,178 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: $
+//
+// (C) Copyright 2010 Andrew Williams and Christopher Cherrett
+//=========================================================
+
+#ifndef __TRACKVIEW_H__
+#define __TRACKVIEW_H__
+
+#include <QString>
+#include <QObject>
+
+#include <vector>
+#include <algorithm>
+
+#include "key.h"
+#include "node.h"
+#include "globaldefs.h"
+#include "track.h"
+
+class Xml;
+
+//---------------------------------------------------------
+// TrackView
+//---------------------------------------------------------
+
+class TrackView
+{
+ private:
+ QString _comment;
+ Track::TrackType _type;
+ TrackList _tracks;
+
+
+ protected:
+ QString _name;
+
+ bool _selected;
+ bool readProperties(Xml& xml, const QString& tag);
+ void writeProperties(int level, Xml& xml) const;
+
+ public:
+ TrackView();
+ ~TrackView();
+ TrackView& operator=(const TrackView& g);
+
+ static const char* _cname[];
+
+ QString comment() const { return _comment; }
+ void setComment(const QString& s) { _comment = s; }
+
+ Track::TrackType type() const { return _type; }
+ void setType(const Track::TrackType& t) { _type = t; }
+
+ bool selected() const { return _selected; }
+ void setSelected(bool f) { _selected = f; }
+
+ const QString& viewName() const { return _name; }
+ void setViewName(const QString& s) { _name = s; }
+ void setDefaultName();
+ QString cname() const { int t = type(); return QString(_cname[t]); }
+ void addTrack(Track*);
+ void removeTrack(Track*);
+ TrackList* tracks() { return &_tracks; }
+ virtual void write(int, Xml&) const;
+ void read(Xml&);
+
+ //virtual TrackView* newTrackView() const = 0;
+
+ //void dump() const;
+
+ //bool readProperty(Xml& xml, const QString& tag);
+};
+
+
+//---------------------------------------------------------
+// TrackViewList
+//---------------------------------------------------------
+
+template<class T> class viewlist : public std::vector<TrackView*> {
+ typedef std::vector<TrackView*> vlist;
+
+ public:
+ class iterator : public vlist::iterator {
+ public:
+ iterator() : vlist::iterator() {}
+ iterator(vlist::iterator i) : vlist::iterator(i) {}
+
+ T operator*() {
+ return (T)(**((vlist::iterator*)this));
+ }
+ iterator operator++(int) {
+ return iterator ((*(vlist::iterator*)this).operator++(0));
+ }
+ iterator& operator++() {
+ return (iterator&) ((*(vlist::iterator*)this).operator++());
+ }
+ };
+
+ class const_iterator : public vlist::const_iterator {
+ public:
+ const_iterator() : vlist::const_iterator() {}
+ const_iterator(vlist::const_iterator i) : vlist::const_iterator(i) {}
+ const_iterator(vlist::iterator i) : vlist::const_iterator(i) {}
+
+ const T operator*() const {
+ return (T)(**((vlist::const_iterator*)this));
+ }
+ };
+
+ class reverse_iterator : public vlist::reverse_iterator {
+ public:
+ reverse_iterator() : vlist::reverse_iterator() {}
+ reverse_iterator(vlist::reverse_iterator i) : vlist::reverse_iterator(i) {}
+
+ T operator*() {
+ return (T)(**((vlist::reverse_iterator*)this));
+ }
+ };
+
+ viewlist() : vlist() {}
+ virtual ~viewlist() {}
+
+ void push_back(T v) { vlist::push_back(v); }
+ iterator begin() { return vlist::begin(); }
+ iterator end() { return vlist::end(); }
+ const_iterator begin() const { return vlist::begin(); }
+ const_iterator end() const { return vlist::end(); }
+ reverse_iterator rbegin() { return vlist::rbegin(); }
+ reverse_iterator rend() { return vlist::rend(); }
+ T& back() const { return (T&)(vlist::back()); }
+ T& front() const { return (T&)(vlist::front()); }
+ iterator find(const TrackView* t) {
+ return std::find(begin(), end(), t);
+ }
+ const_iterator find(const TrackView* t) const {
+ return std::find(begin(), end(), t);
+ }
+ unsigned index(const TrackView* t) const {
+ unsigned n = 0;
+ for (vlist::const_iterator i = begin(); i != end(); ++i, ++n) {
+ if (*i == t)
+ return n;
+ }
+ return -1;
+ }
+ T index(int k) const { return (*this)[k]; }
+ iterator index2iterator(int k) {
+ if ((unsigned)k >= size())
+ return end();
+ return begin() + k;
+ }
+ void erase(TrackView* t) { vlist::erase(find(t)); }
+
+ void clearDelete() {
+ for (vlist::iterator i = begin(); i != end(); ++i)
+ delete *i;
+ vlist::clear();
+ }
+ void erase(vlist::iterator i) { vlist::erase(i); }
+ void replace(TrackView* ot, TrackView* nt) {
+ for (vlist::iterator i = begin(); i != end(); ++i) {
+ if (*i == ot) {
+ *i = nt;
+ return;
+ }
+ }
+ }
+};
+
+typedef viewlist<TrackView*> TrackViewList;
+typedef TrackViewList::iterator iTrackView;
+typedef TrackViewList::const_iterator ciTrackView;
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/transport.cpp b/attic/muse2-oom/muse2/muse/transport.cpp
new file mode 100644
index 00000000..30196a4c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/transport.cpp
@@ -0,0 +1,799 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: transport.cpp,v 1.8.2.3 2009/07/01 10:39:42 spamatica Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QAction>
+#include <QComboBox>
+#include <QMouseEvent>
+#include <QSlider>
+#include <QToolButton>
+#include <QHBoxLayout>
+#include <QVBoxLayout>
+
+#include "awl/posedit.h"
+
+#include "song.h"
+#include "transport.h"
+#include "doublelabel.h"
+#include "siglabel.h"
+#include "globals.h"
+#include "icons.h"
+///#include "posedit.h"
+#include "sync.h"
+#include "shortcuts.h"
+#include "gconfig.h"
+#include "app.h"
+
+static const char* recordTransportText = QT_TRANSLATE_NOOP("@default", "Click this button to enable recording");
+static const char* stopTransportText = QT_TRANSLATE_NOOP("@default", "Click this button to stop playback");
+static const char* playTransportText = QT_TRANSLATE_NOOP("@default", "Click this button to start playback");
+static const char* startTransportText = QT_TRANSLATE_NOOP("@default", "Click this button to rewind to start position");
+static const char* frewindTransportText = QT_TRANSLATE_NOOP("@default", "Click this button to rewind");
+static const char* fforwardTransportText = QT_TRANSLATE_NOOP("@default", "Click this button to forward current play position");
+
+//---------------------------------------------------------
+// toolButton
+//---------------------------------------------------------
+
+static QToolButton* newButton(const QString& s, const QString& tt,
+ bool toggle=false, int height=25, QWidget* parent=0)
+ {
+ QToolButton* button = new QToolButton(parent);
+ button->setFixedHeight(height);
+ button->setText(s);
+ button->setCheckable(toggle);
+ button->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Maximum);
+ button->setFocusPolicy(Qt::NoFocus);
+ button->setToolTip(tt);
+ return button;
+ }
+
+static QToolButton* newButton(const QPixmap* pm, const QString& tt,
+ bool toggle=false, QWidget* parent=0)
+ {
+ QToolButton* button = new QToolButton(parent);
+ button->setFixedHeight(25);
+ //button->setIcon(QIcon(*pm));
+ button->setCheckable(toggle);
+ button->setToolTip(tt);
+ button->setFocusPolicy(Qt::NoFocus);
+ return button;
+ }
+
+//---------------------------------------------------------
+// Handle
+// erlaubt das Verschieben eines Root-Windows mit der
+// Maus
+//---------------------------------------------------------
+
+Handle::Handle(QWidget* r, QWidget* parent)
+ : QWidget(parent)
+ {
+ rootWin = r;
+ setFixedWidth(20);
+ setCursor(Qt::PointingHandCursor);
+ QPalette palette;
+ palette.setColor(this->backgroundRole(), config.transportHandleColor);
+ this->setPalette(palette);
+ setAutoFillBackground(true);
+ }
+
+//---------------------------------------------------------
+// mouseMoveEvent
+//---------------------------------------------------------
+
+void Handle::mouseMoveEvent(QMouseEvent* ev)
+ {
+ rootWin->move(ev->globalX()-dx, ev->globalY() - dy);
+ }
+
+//---------------------------------------------------------
+// mousePressEvent
+//---------------------------------------------------------
+
+void Handle::mousePressEvent(QMouseEvent* ev)
+ {
+ rootWin->raise();
+ dx = ev->globalX() - rootWin->x();
+ dy = ev->globalY() - rootWin->y();
+ }
+
+//---------------------------------------------------------
+// TempoSig
+// Widget fÃŊÂŋÂ―r Tempo + Signature
+//---------------------------------------------------------
+
+TempoSig::TempoSig(QWidget* parent)
+ : QWidget(parent)
+ {
+ QBoxLayout* vb1 = new QVBoxLayout;
+ vb1->setContentsMargins(0, 0, 0, 0);
+ vb1->setSpacing(0);
+
+ QBoxLayout* vb2 = new QVBoxLayout;
+ vb2->setContentsMargins(0, 0, 0, 0);
+ vb2->setSpacing(0);
+
+
+ QFrame* f = new QFrame;
+ f->setFrameStyle(QFrame::Panel | QFrame::Sunken);
+ f->setLineWidth(1);
+
+ // ORCAN get rid of l1 l2 last arguments (parent)?
+ l1 = new DoubleLabel(120.0, 20.0, 400.0, 0);
+ l1->setFocusPolicy(Qt::NoFocus);
+ l1->setSpecialText(QString("extern"));
+ vb2->addWidget(l1);
+
+ l2 = new SigLabel(4, 4, 0);
+ l2->setFocusPolicy(Qt::NoFocus);
+ vb2->addWidget(l2);
+
+ f->setLayout(vb2);
+ vb1->addWidget(f);
+
+ l3 = new QLabel(tr("Tempo/Sig"));
+ l3->setFont(config.fonts[2]);
+ vb1->addWidget(l3);
+
+ l1->setBackgroundRole(QPalette::Light);
+ l1->setAlignment(Qt::AlignCenter);
+ l1->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
+ l2->setBackgroundRole(QPalette::Light);
+ l2->setAlignment(Qt::AlignCenter);
+ l2->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
+ l3->setAlignment(Qt::AlignCenter);
+ l3->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
+
+ connect(l1, SIGNAL(valueChanged(double,int)), SLOT(setTempo(double)));
+ ///connect(l2, SIGNAL(valueChanged(int,int)), SIGNAL(sigChanged(int,int)));
+ connect(l2, SIGNAL(valueChanged(const AL::TimeSignature&)), SIGNAL(sigChanged(const AL::TimeSignature&)));
+ connect(muse, SIGNAL(configChanged()), SLOT(configChanged()));
+
+ this->setLayout(vb1);
+ }
+
+//---------------------------------------------------------
+// configChanged
+//---------------------------------------------------------
+
+void TempoSig::configChanged()
+ {
+ l3->setFont(config.fonts[2]);
+ }
+
+//---------------------------------------------------------
+// setTempo
+//---------------------------------------------------------
+
+void TempoSig::setTempo(double t)
+ {
+ int tempo = int ((1000000.0 * 60.0)/t);
+ emit tempoChanged(tempo);
+ }
+
+//---------------------------------------------------------
+// setTempo
+//---------------------------------------------------------
+
+void TempoSig::setTempo(int tempo)
+ {
+ double t;
+ if(tempo == 0)
+ t = l1->off() - 1.0;
+ else
+ t = (1000000.0 * 60.0)/tempo;
+
+ l1->blockSignals(true);
+ l1->setValue(t);
+ l1->blockSignals(false);
+ }
+
+//---------------------------------------------------------
+// setTimesig
+//---------------------------------------------------------
+
+void TempoSig::setTimesig(int a, int b)
+ {
+ l2->setValue(a, b);
+ }
+
+//---------------------------------------------------------
+// setRecord
+//---------------------------------------------------------
+
+void Transport::setRecord(bool flag)
+ {
+ buttons[5]->blockSignals(true);
+ buttons[5]->setChecked(flag);
+ buttons[5]->blockSignals(false);
+ }
+
+//---------------------------------------------------------
+// Transport
+//---------------------------------------------------------
+
+Transport::Transport(QWidget* parent, const char* name)
+ // : QWidget(0, name, WStyle_Customize | WType_TopLevel | WStyle_Tool
+ //| WStyle_NoBorder | WStyle_StaysOnTop)
+ //: QWidget(0, name, Qt::WStyle_Customize | Qt::Window | Qt::WStyle_NoBorder | Qt::WStyle_StaysOnTop)
+ //: QWidget(0, name, Qt::Window | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint ) // Possibly also Qt::X11BypassWindowManagerHint
+ : QWidget(parent, Qt::Window | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint ) // Possibly also Qt::X11BypassWindowManagerHint
+ {
+ setObjectName(name);
+ setWindowTitle(QString("Muse: Transport"));
+ setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum));
+
+ QHBoxLayout* hbox = new QHBoxLayout;
+ hbox->setContentsMargins(2, 2, 2, 2);
+
+ lefthandle = new Handle(this);
+ hbox->addWidget(lefthandle);
+
+ //-----------------------------------------------------
+ // Record & Cycle Mode
+ //-----------------------------------------------------
+
+ QVBoxLayout *box1 = new QVBoxLayout;
+ recMode = new QComboBox;
+ recMode->setFocusPolicy(Qt::NoFocus);
+ recMode->insertItem(Song::REC_OVERDUP, tr("Overdub"));
+ recMode->insertItem(Song::REC_REPLACE, tr("Replace"));
+ recMode->setCurrentIndex(song->recMode());
+
+ box1->addWidget(recMode);
+
+ l2 = new QLabel(tr("Rec Mode"));
+ l2->setFont(config.fonts[2]);
+ l2->setAlignment(Qt::AlignCenter);
+ connect(recMode, SIGNAL(activated(int)), SLOT(setRecMode(int)));
+ box1->addWidget(l2);
+
+ cycleMode = new QComboBox;
+ cycleMode->setFocusPolicy(Qt::NoFocus);
+ cycleMode->insertItem(Song::CYCLE_NORMAL, tr("Normal"));
+ cycleMode->insertItem(Song::CYCLE_MIX, tr("Mix"));
+ cycleMode->insertItem(Song::CYCLE_REPLACE, tr("Replace"));
+ cycleMode->setCurrentIndex(song->cycleMode());
+
+ box1->addWidget(cycleMode);
+
+ l3 = new QLabel(tr("Cycle Rec"));
+ l3->setFont(config.fonts[2]);
+ l3->setAlignment(Qt::AlignCenter);
+ connect(cycleMode, SIGNAL(activated(int)), SLOT(setCycleMode(int)));
+ box1->addWidget(l3);
+
+ box1->setSpacing(0);
+ hbox->addLayout(box1);
+
+ //-----------------------------------------------------
+ // loop flags
+ //-----------------------------------------------------
+
+ QVBoxLayout *button2 = new QVBoxLayout;
+ button2->setSpacing(0);
+
+ QToolButton* b1 = newButton(punchinIcon, tr("punchin"), true);
+ QToolButton* b2 = newButton(loopIcon, tr("loop"), true);
+ b2->setShortcut(shortcuts[SHRT_TOGGLE_LOOP].key);
+
+ QToolButton* b3 = newButton(punchoutIcon, tr("punchout"), true);
+ button2->addWidget(b1);
+ button2->addWidget(b2);
+ button2->addWidget(b3);
+ b1->setToolTip(tr("Punch In"));
+ b2->setToolTip(tr("Loop"));
+ b3->setToolTip(tr("Punch Out"));
+ b1->setWhatsThis(tr("Punch In"));
+ b2->setWhatsThis(tr("Loop"));
+ b3->setWhatsThis(tr("Punch Out"));
+
+ connect(b1, SIGNAL(toggled(bool)), song, SLOT(setPunchin(bool)));
+ connect(b2, SIGNAL(toggled(bool)), song, SLOT(setLoop(bool)));
+ connect(b3, SIGNAL(toggled(bool)), song, SLOT(setPunchout(bool)));
+
+ b1->setChecked(song->punchin());
+ b2->setChecked(song->loop());
+ b3->setChecked(song->punchout());
+
+ connect(song, SIGNAL(punchinChanged(bool)), b1, SLOT(setChecked(bool)));
+ connect(song, SIGNAL(punchoutChanged(bool)), b3, SLOT(setChecked(bool)));
+ connect(song, SIGNAL(loopChanged(bool)), b2, SLOT(setChecked(bool)));
+
+ hbox->addLayout(button2);
+
+ //-----------------------------------------------------
+ // left right mark
+ //-----------------------------------------------------
+
+ // ORCAN: should we change PosEdit constructor so we can call it without a parent argument?
+ QVBoxLayout *marken = new QVBoxLayout;
+ marken->setSpacing(0);
+ marken->setContentsMargins(0, 0, 0, 0);
+
+ ///tl1 = new PosEdit(0);
+ tl1 = new Awl::PosEdit(0);
+ tl1->setMinimumSize(105,0);
+ tl1->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
+ tl1->setFocusPolicy(Qt::NoFocus);
+
+ marken->addWidget(tl1);
+
+ l5 = new QLabel(tr("Left Mark"));
+ l5->setFont(config.fonts[2]);
+ l5->setAlignment(Qt::AlignCenter);
+ marken->addWidget(l5);
+
+ ///tl2 = new PosEdit(0);
+ tl2 = new Awl::PosEdit(0);
+ tl2->setMinimumSize(105,0);
+ tl2->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
+ marken->addWidget(tl2);
+ tl2->setFocusPolicy(Qt::NoFocus);
+
+ l6 = new QLabel(tr("Right Mark"));
+ l6->setFont(config.fonts[2]);
+ l6->setAlignment(Qt::AlignCenter);
+ marken->addWidget(l6);
+
+ hbox->addLayout(marken);
+
+ //-----------------------------------------------------
+ // Transport Buttons
+ //-----------------------------------------------------
+
+ QVBoxLayout *box4 = new QVBoxLayout;
+ box4->setSpacing(0);
+ box4->setContentsMargins(0, 0, 0, 0);
+
+ QHBoxLayout *hbox1 = new QHBoxLayout;
+ hbox1->setContentsMargins(0, 0, 0, 0);
+
+ ///time1 = new PosEdit(0);
+ time1 = new Awl::PosEdit(0);
+ ///time2 = new PosEdit(0);
+ time2 = new Awl::PosEdit(0);
+ time2->setSmpte(true);
+ time1->setMinimumSize(105,0);
+ time2->setMinimumSize(105,0);
+ time1->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
+ time2->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
+ time1->setFocusPolicy(Qt::NoFocus);
+ time2->setFocusPolicy(Qt::NoFocus);
+
+ hbox1->addWidget(time1);
+ hbox1->addWidget(time2);
+ box4->addLayout(hbox1);
+
+ slider = new QSlider;
+ slider->setMinimum(0);
+ slider->setMaximum(200000);
+ slider->setPageStep(1000);
+ slider->setValue(0);
+ slider->setOrientation(Qt::Horizontal);
+ slider->setFocusPolicy(Qt::NoFocus);
+
+ box4->addWidget(slider);
+
+ tb = new QHBoxLayout;
+ tb->setSpacing(0);
+
+ buttons[0] = newButton(startIcon, tr("rewind to start"));
+ buttons[0]->setWhatsThis(tr(startTransportText));
+
+ buttons[1] = newButton(frewindIcon, tr("rewind"));
+ buttons[1]->setAutoRepeat(true);
+ buttons[1]->setWhatsThis(tr(frewindTransportText));
+
+ buttons[2] = newButton(fforwardIcon, tr("forward"));
+ buttons[2]->setAutoRepeat(true);
+ buttons[2]->setWhatsThis(tr(fforwardTransportText));
+
+ buttons[3] = newButton(stopIcon, tr("stop"), true);
+ buttons[3]->setChecked(true); // set STOP
+ buttons[3]->setWhatsThis(tr(stopTransportText));
+
+ buttons[4] = newButton(playIcon, tr("play"), true);
+ buttons[4]->setWhatsThis(tr(playTransportText));
+
+ buttons[5] = newButton(record_on_Icon, tr("record"), true);
+ buttons[5]->setWhatsThis(tr(recordTransportText));
+
+ for (int i = 0; i < 6; ++i)
+ {
+ buttons[i]->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
+ tb->addWidget(buttons[i]);
+ }
+ connect(buttons[3], SIGNAL(toggled(bool)), SLOT(stopToggled(bool)));
+ connect(buttons[4], SIGNAL(toggled(bool)), SLOT(playToggled(bool)));
+
+ connect(buttons[5], SIGNAL(toggled(bool)), song, SLOT(setRecord(bool)));
+ connect(song, SIGNAL(recordChanged(bool)), SLOT(setRecord(bool)));
+ connect(buttons[0], SIGNAL(clicked()), song, SLOT(rewindStart()));
+ connect(buttons[1], SIGNAL(clicked()), song, SLOT(rewind()));
+ connect(buttons[2], SIGNAL(clicked()), song, SLOT(forward()));
+
+ box4->addLayout(tb);
+ hbox->addLayout(box4);
+
+ //-----------------------------------------------------
+ // AQ - Click - Sync
+ //-----------------------------------------------------
+
+ QVBoxLayout *button1 = new QVBoxLayout;
+ button1->setContentsMargins(0, 0, 0, 0);
+ button1->setSpacing(0);
+
+ quantizeButton = newButton(tr("AC"), tr("quantize during record"), true,19);
+
+ clickButton = newButton(tr("Click"), tr("metronom click on/off"), true,19);
+ clickButton->setShortcut(shortcuts[SHRT_TOGGLE_METRO].key);
+
+ syncButton = newButton(tr("Sync"), tr("external sync on/off"), true,19);
+
+ jackTransportButton = newButton(tr("Jack"), tr("Jack transport sync on/off"), true,19);
+
+ quantizeButton->setChecked(song->quantize());
+ clickButton->setChecked(song->click());
+ syncButton->setChecked(extSyncFlag.value());
+ jackTransportButton->setChecked(useJackTransport.value());
+ quantizeButton->setFocusPolicy(Qt::NoFocus);
+ clickButton->setFocusPolicy(Qt::NoFocus);
+ syncButton->setFocusPolicy(Qt::NoFocus);
+ jackTransportButton->setFocusPolicy(Qt::NoFocus);
+
+ button1->addWidget(quantizeButton);
+ button1->addWidget(clickButton);
+ button1->addWidget(syncButton);
+ button1->addWidget(jackTransportButton);
+
+ connect(quantizeButton, SIGNAL(toggled(bool)), song, SLOT(setQuantize(bool)));
+ connect(clickButton, SIGNAL(toggled(bool)), song, SLOT(setClick(bool)));
+
+ connect(syncButton, SIGNAL(toggled(bool)), &extSyncFlag, SLOT(setValue(bool)));
+ connect(jackTransportButton, SIGNAL(toggled(bool)),&useJackTransport, SLOT(setValue(bool)));
+ connect(&extSyncFlag, SIGNAL(valueChanged(bool)), SLOT(syncChanged(bool)));
+ connect(&useJackTransport, SIGNAL(valueChanged(bool)), SLOT(jackSyncChanged(bool)));
+
+ connect(song, SIGNAL(quantizeChanged(bool)), this, SLOT(setQuantizeFlag(bool)));
+ connect(song, SIGNAL(clickChanged(bool)), this, SLOT(setClickFlag(bool)));
+
+ hbox->addLayout(button1);
+
+ //-----------------------------------------------------
+ // Tempo/Sig
+ //-----------------------------------------------------
+
+ QVBoxLayout *box5 = new QVBoxLayout;
+ box5->setSpacing(0);
+ box5->setContentsMargins(0, 0, 0, 0);
+
+
+ tempo = new TempoSig;
+ tempo->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
+ tempo->setFocusPolicy(Qt::NoFocus);
+ box5->addWidget(tempo);
+
+ masterButton = newButton(tr("Master"), tr("use master track"), true);
+ masterButton->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
+ masterButton->setFocusPolicy(Qt::NoFocus);
+ box5->addWidget(masterButton);
+
+ connect(masterButton, SIGNAL(toggled(bool)), song, SLOT(setMasterFlag(bool)));
+
+ hbox->addLayout(box5);
+
+ //-----------------------------------------------------
+
+ connect(tl1, SIGNAL(valueChanged(const Pos&)), SLOT(lposChanged(const Pos&)));
+ connect(tl2, SIGNAL(valueChanged(const Pos&)), SLOT(rposChanged(const Pos&)));
+ connect(time1, SIGNAL(valueChanged(const Pos&)), SLOT(cposChanged(const Pos&)));
+ connect(time2, SIGNAL(valueChanged(const Pos&)), SLOT(cposChanged(const Pos&)));
+
+ connect(slider,SIGNAL(valueChanged(int)), SLOT(cposChanged(int)));
+ connect(song, SIGNAL(posChanged(int, unsigned, bool)), SLOT(setPos(int, unsigned, bool)));
+ connect(tempo, SIGNAL(tempoChanged(int)), song, SLOT(setTempo(int)));
+ ///connect(tempo, SIGNAL(sigChanged(int, int)), song, SLOT(setSig(int, int)));
+ connect(tempo, SIGNAL(sigChanged(const AL::TimeSignature&)), song, SLOT(setSig(const AL::TimeSignature&)));
+ connect(song, SIGNAL(playChanged(bool)), SLOT(setPlay(bool)));
+ connect(song, SIGNAL(songChanged(int)), this, SLOT(songChanged(int)));
+ connect(muse, SIGNAL(configChanged()), SLOT(configChanged()));
+
+
+ this->setLayout(hbox);
+ righthandle = new Handle(this);
+ hbox->addWidget(righthandle);
+ }
+
+Transport::~Transport()
+{
+ //printf("Transport::~Transport\n");
+}
+
+//---------------------------------------------------------
+// configChanged
+//---------------------------------------------------------
+
+void Transport::configChanged()
+ {
+ l2->setFont(config.fonts[2]);
+ l3->setFont(config.fonts[2]);
+ l5->setFont(config.fonts[2]);
+ l6->setFont(config.fonts[2]);
+
+ QPalette pal;
+ pal.setColor(lefthandle->backgroundRole(), config.transportHandleColor);
+ lefthandle->setPalette(pal);
+ righthandle->setPalette(pal);
+ }
+
+//---------------------------------------------------------
+// setTempo
+//---------------------------------------------------------
+
+void Transport::setTempo(int t)
+ {
+ static int tempoVal = -1;
+ if (t != tempoVal) {
+ tempo->setTempo(t);
+ tempoVal = t;
+ }
+ }
+
+//---------------------------------------------------------
+// setHandleColor
+//---------------------------------------------------------
+
+void Transport::setHandleColor(QColor c)
+ {
+ QPalette pal;
+ pal.setColor(lefthandle->backgroundRole(), c);
+ lefthandle->setPalette(pal);
+ righthandle->setPalette(pal);
+ }
+
+//---------------------------------------------------------
+// setTimesig
+//---------------------------------------------------------
+
+void Transport::setTimesig(int z, int n)
+ {
+ tempo->setTimesig(z, n);
+ }
+
+//---------------------------------------------------------
+// setPos
+//---------------------------------------------------------
+
+void Transport::setPos(int idx, unsigned v, bool)
+ {
+ switch (idx) {
+ case 0:
+ time1->setValue(v);
+ time2->setValue(v);
+ if((unsigned) slider->value() != v)
+ {
+ slider->blockSignals(true);
+ slider->setValue(v);
+ slider->blockSignals(false);
+ }
+ if (song->masterFlag())
+ setTempo(tempomap.tempo(v));
+ {
+ int z, n;
+ ///sigmap.timesig(v, z, n);
+ AL::sigmap.timesig(v, z, n);
+ setTimesig(z, n);
+ }
+ break;
+ case 1:
+ tl1->setValue(v);
+ break;
+ case 2:
+ tl2->setValue(v);
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// cposChanged
+//---------------------------------------------------------
+
+void Transport::cposChanged(int tick)
+ {
+ song->setPos(0, tick);
+ }
+
+//---------------------------------------------------------
+// cposChanged
+//---------------------------------------------------------
+
+void Transport::cposChanged(const Pos& pos)
+ {
+ song->setPos(0, pos.tick());
+ }
+
+//---------------------------------------------------------
+// lposChanged
+//---------------------------------------------------------
+
+void Transport::lposChanged(const Pos& pos)
+ {
+ song->setPos(1, pos.tick());
+ }
+
+//---------------------------------------------------------
+// rposChanged
+//---------------------------------------------------------
+
+void Transport::rposChanged(const Pos& pos)
+ {
+ song->setPos(2, pos.tick());
+ }
+
+//---------------------------------------------------------
+// setPlay
+//---------------------------------------------------------
+
+void Transport::setPlay(bool f)
+ {
+ buttons[3]->blockSignals(true);
+ buttons[4]->blockSignals(true);
+ buttons[3]->setChecked(!f);
+ buttons[4]->setChecked(f);
+ buttons[3]->blockSignals(false);
+ buttons[4]->blockSignals(false);
+ }
+
+//---------------------------------------------------------
+// setMasterFlag
+//---------------------------------------------------------
+
+void Transport::setMasterFlag(bool f)
+ {
+ masterButton->setChecked(f);
+ }
+
+//---------------------------------------------------------
+// setClickFlag
+//---------------------------------------------------------
+
+void Transport::setClickFlag(bool f)
+ {
+ clickButton->blockSignals(true);
+ clickButton->setChecked(f);
+ clickButton->blockSignals(false);
+ }
+
+//---------------------------------------------------------
+// setQuantizeFlag
+//---------------------------------------------------------
+
+void Transport::setQuantizeFlag(bool f)
+ {
+ quantizeButton->setChecked(f);
+ }
+
+//---------------------------------------------------------
+// setSyncFlag
+//---------------------------------------------------------
+
+void Transport::setSyncFlag(bool f)
+ {
+ syncButton->setChecked(f);
+ }
+
+//---------------------------------------------------------
+// toggleRecMode
+//---------------------------------------------------------
+
+void Transport::setRecMode(int id)
+ {
+ song->setRecMode(id);
+ }
+
+//---------------------------------------------------------
+// toggleCycleMode
+//---------------------------------------------------------
+
+void Transport::setCycleMode(int id)
+ {
+ song->setCycleMode(id);
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void Transport::songChanged(int flags)
+ {
+ // Is it simply a midi controller value adjustment? Forget it.
+ if(flags == SC_MIDI_CONTROLLER)
+ return;
+
+ slider->setRange(0, song->len());
+ int cpos = song->cpos();
+ int t = tempomap.tempo(cpos);
+ if (flags & (SC_MASTER | SC_TEMPO)) {
+ if (extSyncFlag.value())
+ setTempo(0);
+ else
+ setTempo(t);
+ }
+ if (flags & SC_SIG) {
+ int z, n;
+ ///sigmap.timesig(cpos, z, n);
+ AL::sigmap.timesig(cpos, z, n);
+ setTimesig(z, n);
+ }
+ if (flags & SC_MASTER)
+ masterButton->setChecked(song->masterFlag());
+ }
+
+//---------------------------------------------------------
+// syncChanged
+//---------------------------------------------------------
+
+void Transport::syncChanged(bool flag)
+ {
+ syncButton->setChecked(flag);
+ buttons[0]->setEnabled(!flag); // goto start
+ buttons[1]->setEnabled(!flag); // rewind
+ buttons[2]->setEnabled(!flag); // forward
+ buttons[3]->setEnabled(!flag); // stop
+ buttons[4]->setEnabled(!flag); // play
+ slider->setEnabled(!flag);
+ masterButton->setEnabled(!flag);
+ if (flag) {
+ masterButton->setChecked(false);
+ song->setMasterFlag(false);
+ tempo->setTempo(0); // slave mode: show "extern"
+ }
+ else
+ tempo->setTempo(tempomap.tempo(song->cpos()));
+ playAction->setEnabled(!flag);
+ startAction->setEnabled(!flag);
+ stopAction->setEnabled(!flag);
+ rewindAction->setEnabled(!flag);
+ forwardAction->setEnabled(!flag);
+ }
+
+void Transport::jackSyncChanged(bool flag)
+ {
+ jackTransportButton->setChecked(flag);
+ }
+//---------------------------------------------------------
+// stopToggled
+//---------------------------------------------------------
+
+void Transport::stopToggled(bool val)
+ {
+ if (val)
+ song->setStop(true);
+ else {
+ buttons[3]->blockSignals(true);
+ buttons[3]->setChecked(true);
+ buttons[3]->blockSignals(false);
+ }
+ }
+
+//---------------------------------------------------------
+// playToggled
+//---------------------------------------------------------
+
+void Transport::playToggled(bool val)
+ {
+ if (val)
+ song->setPlay(true);
+ else {
+ buttons[4]->blockSignals(true);
+ buttons[4]->setChecked(true);
+ buttons[4]->blockSignals(false);
+ }
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/transport.h b/attic/muse2-oom/muse2/muse/transport.h
new file mode 100644
index 00000000..b2d3facf
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/transport.h
@@ -0,0 +1,136 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: transport.h,v 1.4 2004/06/28 21:13:16 wschweer Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __TRANSPORT_H__
+#define __TRANSPORT_H__
+
+#include "al/sig.h"
+
+#include <QWidget>
+
+namespace Awl {
+ class PosEdit;
+ };
+
+using Awl::PosEdit;
+
+class QComboBox;
+class QHBoxLayout;
+class QLabel;
+class QSlider;
+class QToolButton;
+
+class DoubleLabel;
+class SigLabel;
+class Pos;
+
+//---------------------------------------------------------
+// TempoSig
+//---------------------------------------------------------
+
+class TempoSig : public QWidget {
+ DoubleLabel* l1;
+ SigLabel* l2;
+ QLabel* l3;
+ Q_OBJECT
+
+ private slots:
+ void configChanged();
+
+ public slots:
+ void setTempo(double);
+ void setTempo(int tempo);
+
+ signals:
+ void tempoChanged(int);
+ void sigChanged(const AL::TimeSignature&);
+
+ public:
+ TempoSig(QWidget* parent=0);
+ void setTimesig(int a, int b);
+ };
+
+//---------------------------------------------------------
+// Handle
+//---------------------------------------------------------
+
+class Handle : public QWidget {
+ QWidget* rootWin;
+ int dx, dy;
+ void mouseMoveEvent(QMouseEvent* ev);
+ void mousePressEvent(QMouseEvent* ev);
+ public:
+ Handle(QWidget* r, QWidget* parent=0);
+ };
+
+class TimeLLabel;
+
+//---------------------------------------------------------
+// Transport
+//---------------------------------------------------------
+
+class Transport : public QWidget
+ {
+ PosEdit* tl1; // left mark
+ PosEdit* tl2; // right mark
+ PosEdit* time1; // tick time
+ PosEdit* time2; // SMPTE
+
+ QSlider* slider;
+ TempoSig* tempo;
+ QHBoxLayout* tb;
+ QToolButton* masterButton;
+ QComboBox* recMode;
+ QComboBox* cycleMode;
+ QToolButton* quantizeButton;
+ QToolButton* clickButton;
+ QToolButton* syncButton;
+ QToolButton* jackTransportButton;
+ QToolButton* buttons[6]; // transport buttons
+ QLabel* l2;
+ QLabel* l3;
+ QLabel* l5;
+ QLabel* l6;
+
+ Handle *lefthandle, *righthandle;
+
+ Q_OBJECT
+
+ private slots:
+ void cposChanged(const Pos&);
+ void cposChanged(int);
+ void lposChanged(const Pos&);
+ void rposChanged(const Pos&);
+ void setRecMode(int);
+ void setCycleMode(int);
+ void songChanged(int);
+ void syncChanged(bool);
+ void jackSyncChanged(bool);
+ void setRecord(bool flag);
+ void stopToggled(bool);
+ void playToggled(bool);
+ void configChanged();
+
+ public slots:
+ void setTempo(int tempo);
+ void setTimesig(int a, int b);
+ void setPos(int,unsigned, bool);
+ void setMasterFlag(bool);
+ void setClickFlag(bool);
+ void setQuantizeFlag(bool);
+ void setSyncFlag(bool);
+ void setPlay(bool f);
+ void setHandleColor(QColor);
+
+ public:
+ Transport(QWidget* parent, const char* name = 0);
+ ~Transport();
+ QColor getHandleColor() const { return lefthandle->palette().color(QPalette::Window); }
+ };
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/transpose.cpp b/attic/muse2-oom/muse2/muse/transpose.cpp
new file mode 100644
index 00000000..9e99c471
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/transpose.cpp
@@ -0,0 +1,100 @@
+
+#include <stdio.h>
+
+#include <QDialog>
+
+#include "transpose.h"
+#include "track.h"
+#include "song.h"
+#include "event.h"
+#include "audio.h"
+
+//---------------------------------------------------------
+// Transpose
+//---------------------------------------------------------
+
+Transpose::Transpose(QWidget* parent)
+ : QDialog(parent)
+ {
+ setupUi(this);
+ setAttribute(Qt::WA_DeleteOnClose);
+ buttonGroup1 = new QButtonGroup(this);
+ buttonGroup1->addButton(time_all);
+ buttonGroup1->addButton(time_selected);
+ buttonGroup2 = new QButtonGroup(this);
+ buttonGroup2->addButton(parts_all);
+ buttonGroup2->addButton(parts_selected);
+
+ if (song->lpos() != song->rpos()) {
+ time_selected->setChecked(true);
+ }
+ else {
+// time_all->setChecked(true);
+ ButtonBox1->setEnabled(false);
+ }
+// parts_all->setSelected(true);
+ }
+
+//---------------------------------------------------------
+// accept
+//---------------------------------------------------------
+
+void Transpose::accept()
+ {
+ int left = 0, right = 0;
+ int dv = delta->value();
+
+ TrackList *tracks = song->tracks();
+
+ if (time_selected->isChecked()) {
+ left = song->lpos();
+ right = song->rpos();
+ }
+ else {
+ left = 0;
+ right = song->len();
+ }
+
+ std::vector< EventList* > doneList;
+ typedef std::vector< EventList* >::iterator iDoneList;
+
+ song->startUndo();
+ for (iTrack t = tracks->begin(); t != tracks->end(); ++t) {
+// if (((*t)->type() == Track::MIDI || (*t)->type() == Track::DRUM)
+ if (((*t)->type() != Track::MIDI)
+ || !(parts_all->isChecked() || (*t)->selected()))
+ continue;
+
+ PartList *pl = (*t)->parts();
+ for (iPart p = pl->begin(); p != pl->end(); ++p) {
+ MidiPart *mp = (MidiPart *) p->second;
+ EventList* el = mp->events();
+
+ // Check if the event list has already been done. Skip repeated clones.
+ iDoneList idl;
+ for(idl = doneList.begin(); idl != doneList.end(); ++idl)
+ if(*idl == el)
+ break;
+ if(idl != doneList.end())
+ break;
+ doneList.push_back(el);
+
+ for (iEvent i = el->begin(); i != el->end(); ++i) {
+ Event oe = i->second;
+ int tick = oe.tick();
+ if (tick > right)
+ break;
+ if (tick < left)
+ continue;
+ Event ne = oe.clone();
+ ne.setA(oe.dataA() + dv );
+ // Indicate no undo, and do not do port controller values and clone parts.
+ //audio->msgChangeEvent(oe, ne, mp, false);
+ audio->msgChangeEvent(oe, ne, mp, false, false, false);
+ }
+ }
+ }
+ song->endUndo(SC_EVENT_MODIFIED);
+ close();
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/transpose.h b/attic/muse2-oom/muse2/muse/transpose.h
new file mode 100644
index 00000000..a5d2a1bb
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/transpose.h
@@ -0,0 +1,26 @@
+
+#ifndef __TRANSPOSE_H__
+#define __TRANSPOSE_H__
+
+#include "ui_transposebase.h"
+
+class QButtonGroup;
+
+//---------------------------------------------------------
+// transpose widget
+//---------------------------------------------------------
+
+class Transpose : public QDialog, public Ui::TransposeDialogBase {
+ Q_OBJECT
+
+ QButtonGroup* buttonGroup1;
+ QButtonGroup* buttonGroup2;
+
+ private slots:
+ virtual void accept();
+
+ public:
+ Transpose(QWidget* parent=0);
+ };
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/undo.cpp b/attic/muse2-oom/muse2/muse/undo.cpp
new file mode 100644
index 00000000..a7df385b
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/undo.cpp
@@ -0,0 +1,976 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: undo.cpp,v 1.12.2.9 2009/05/24 21:43:44 terminator356 Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+///#include "sig.h"
+#include "al/sig.h" // Tim.
+
+#include "undo.h"
+#include "song.h"
+#include "globals.h"
+
+// iundo points to last Undo() in Undo-list
+
+static bool undoMode = false; // for debugging
+
+std::list<QString> temporaryWavFiles;
+
+//---------------------------------------------------------
+// typeName
+//---------------------------------------------------------
+
+const char* UndoOp::typeName()
+ {
+ static const char* name[] = {
+ "AddTrack", "DeleteTrack", "ModifyTrack",
+ "AddPart", "DeletePart", "ModifyPart",
+ "AddEvent", "DeleteEvent", "ModifyEvent",
+ "AddTempo", "DeleteTempo", "AddSig", "DeleteSig",
+ "SwapTrack", "ModifyClip",
+ "AddTrackView", "DeleteTrackView", "ModifyTrackView"
+ };
+ return name[type];
+ }
+
+//---------------------------------------------------------
+// dump
+//---------------------------------------------------------
+
+void UndoOp::dump()
+ {
+ printf("UndoOp: %s\n ", typeName());
+ switch(type) {
+ case AddTrack:
+ case DeleteTrack:
+ printf("%d %s\n", trackno, oTrack->name().toLatin1().constData());
+ break;
+ case ModifyTrack:
+ printf("%d <%s>-<%s>\n", trackno, oTrack->name().toLatin1().constData(), nTrack->name().toLatin1().constData());
+ break;
+ case AddPart:
+ case DeletePart:
+ case ModifyPart:
+ break;
+ case AddEvent:
+ case DeleteEvent:
+ printf("old event:\n");
+ oEvent.dump(5);
+ printf(" new event:\n");
+ nEvent.dump(5);
+ printf(" Part:\n");
+ if (part)
+ part->dump(5);
+ break;
+ case ModifyEvent:
+ case AddTempo:
+ case DeleteTempo:
+ case AddSig:
+ case SwapTrack:
+ case DeleteSig:
+ case ModifyClip:
+ case ModifyMarker:
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// clearDelete
+//---------------------------------------------------------
+
+void UndoList::clearDelete()
+{
+ if(!empty())
+ {
+ for(iUndo iu = begin(); iu != end(); ++iu)
+ {
+ Undo& u = *iu;
+ for(riUndoOp i = u.rbegin(); i != u.rend(); ++i)
+ {
+ switch(i->type)
+ {
+ case UndoOp::DeleteTrack:
+ if(i->oTrack)
+ {
+ delete i->oTrack;
+ iUndo iu2 = iu;
+ ++iu2;
+ for(; iu2 != end(); ++iu2)
+ {
+ Undo& u2 = *iu2;
+ for(riUndoOp i2 = u2.rbegin(); i2 != u2.rend(); ++i2)
+ {
+ if(i2->type == UndoOp::DeleteTrack)
+ {
+ if(i2->oTrack == i->oTrack)
+ i2->oTrack = 0;
+ }
+ }
+ }
+ }
+ break;
+ case UndoOp::ModifyTrack:
+ if(i->oTrack)
+ {
+ // Prevent delete i->oTrack from crashing.
+ switch(i->oTrack->type())
+ {
+ case Track::AUDIO_OUTPUT:
+ {
+ AudioOutput* ao = (AudioOutput*)i->oTrack;
+ for(int ch = 0; ch < ao->channels(); ++ch)
+ ao->setJackPort(ch, 0);
+ }
+ break;
+ case Track::AUDIO_INPUT:
+ {
+ AudioInput* ai = (AudioInput*)i->oTrack;
+ for(int ch = 0; ch < ai->channels(); ++ch)
+ ai->setJackPort(ch, 0);
+ }
+ break;
+ default:
+ break;
+ }
+ if(!i->oTrack->isMidiTrack())
+ ((AudioTrack*)i->oTrack)->clearEfxList();
+ delete i->oTrack;
+
+ iUndo iu2 = iu;
+ ++iu2;
+ for(; iu2 != end(); ++iu2)
+ {
+ Undo& u2 = *iu2;
+ for(riUndoOp i2 = u2.rbegin(); i2 != u2.rend(); ++i2)
+ {
+ if(i2->type == UndoOp::ModifyTrack)
+ {
+ if(i2->oTrack == i->oTrack)
+ i2->oTrack = 0;
+ }
+ }
+ }
+ }
+ break;
+ //case UndoOp::DeletePart:
+ //delete i->oPart;
+ // break;
+ //case UndoOp::DeleteTempo:
+ // break;
+ //case UndoOp::DeleteSig:
+ // break;
+ case UndoOp::ModifyMarker:
+ if (i->copyMarker)
+ delete i->copyMarker;
+ default:
+ break;
+ }
+ }
+ u.clear();
+ }
+ }
+
+ clear();
+}
+
+//---------------------------------------------------------
+// startUndo
+//---------------------------------------------------------
+
+void Song::startUndo()
+ {
+ undoList->push_back(Undo());
+ updateFlags = 0;
+ undoMode = true;
+ }
+
+//---------------------------------------------------------
+// endUndo
+//---------------------------------------------------------
+
+void Song::endUndo(int flags)
+ {
+ updateFlags |= flags;
+ endMsgCmd();
+ undoMode = false;
+ }
+
+//---------------------------------------------------------
+// doUndo2
+// real time part
+//---------------------------------------------------------
+
+void Song::doUndo2()
+ {
+ Undo& u = undoList->back();
+ for (riUndoOp i = u.rbegin(); i != u.rend(); ++i) {
+ switch(i->type) {
+ case UndoOp::AddTrack:
+ removeTrack2(i->oTrack);
+ updateFlags |= SC_TRACK_REMOVED;
+ break;
+ case UndoOp::DeleteTrack:
+ insertTrack2(i->oTrack, i->trackno);
+ // Added by T356.
+ chainTrackParts(i->oTrack, true);
+
+ updateFlags |= SC_TRACK_INSERTED;
+ break;
+ case UndoOp::ModifyTrack:
+ {
+ // Added by Tim. p3.3.6
+ //printf("Song::doUndo2 ModifyTrack #1 oTrack %p %s nTrack %p %s\n", i->oTrack, i->oTrack->name().toLatin1().constData(), i->nTrack, i->nTrack->name().toLatin1().constData());
+
+ // Unchain the track parts, but don't touch the ref counts.
+ unchainTrackParts(i->nTrack, false);
+
+ //Track* track = i->nTrack->clone();
+ Track* track = i->nTrack->clone(false);
+
+ // A Track custom assignment operator was added by Tim.
+ *(i->nTrack) = *(i->oTrack);
+
+ // Added by Tim. p3.3.6
+ //printf("Song::doUndo2 ModifyTrack #2 oTrack %p %s nTrack %p %s\n", i->oTrack, i->oTrack->name().toLatin1().constData(), i->nTrack, i->nTrack->name().toLatin1().constData());
+
+ // Prevent delete i->oTrack from crashing.
+ switch(i->oTrack->type())
+ {
+ case Track::AUDIO_OUTPUT:
+ {
+ AudioOutput* ao = (AudioOutput*)i->oTrack;
+ for(int ch = 0; ch < ao->channels(); ++ch)
+ ao->setJackPort(ch, 0);
+ }
+ break;
+ case Track::AUDIO_INPUT:
+ {
+ AudioInput* ai = (AudioInput*)i->oTrack;
+ for(int ch = 0; ch < ai->channels(); ++ch)
+ ai->setJackPort(ch, 0);
+ }
+ break;
+ default:
+ break;
+ }
+ if(!i->oTrack->isMidiTrack())
+ ((AudioTrack*)i->oTrack)->clearEfxList();
+
+ delete i->oTrack;
+ i->oTrack = track;
+
+ // Chain the track parts, but don't touch the ref counts.
+ chainTrackParts(i->nTrack, false);
+
+ // Added by Tim. p3.3.6
+ //printf("Song::doUndo2 ModifyTrack #3 oTrack %p %s nTrack %p %s\n", i->oTrack, i->oTrack->name().toLatin1().constData(), i->nTrack, i->nTrack->name().toLatin1().constData());
+
+ // Connect and register ports.
+ switch(i->nTrack->type())
+ {
+ case Track::AUDIO_OUTPUT:
+ {
+ AudioOutput* ao = (AudioOutput*)i->nTrack;
+ ao->setName(ao->name());
+ }
+ break;
+ case Track::AUDIO_INPUT:
+ {
+ AudioInput* ai = (AudioInput*)i->nTrack;
+ ai->setName(ai->name());
+ }
+ break;
+ default:
+ break;
+ }
+
+ // Update solo states, since the user may have changed soloing on other tracks.
+ updateSoloStates();
+
+ updateFlags |= SC_TRACK_MODIFIED;
+ }
+ break;
+
+ /*
+ switch(i->nTrack->type())
+ {
+ case Track::AUDIO_OUTPUT:
+ {
+ AudioOutput* ao = (AudioOutput*)i->nTrack;
+ for(int ch = 0; ch < ao->channels(); ++ch)
+ ao->setJackPort(ch, 0);
+ }
+ break;
+ case Track::AUDIO_INPUT:
+ {
+ AudioInput* ai = (AudioInput*)i->nTrack;
+ for(int ch = 0; ch < ai->channels(); ++ch)
+ ai->setJackPort(ch, 0);
+ }
+ break;
+ default:
+ break;
+ }
+ if(!i->nTrack->isMidiTrack())
+ ((AudioTrack*)i->nTrack)->clearEfxList();
+
+ //delete i->oTrack;
+ //i->oTrack = track;
+
+ // Remove the track. removeTrack2 takes care of unchaining the new track.
+ removeTrack2(i->nTrack);
+
+ // Connect and register ports.
+ switch(i->oTrack->type())
+ {
+ case Track::AUDIO_OUTPUT:
+ {
+ AudioOutput* ao = (AudioOutput*)i->oTrack;
+ ao->setName(ao->name());
+ }
+ break;
+ case Track::AUDIO_INPUT:
+ {
+ AudioInput* ai = (AudioInput*)i->oTrack;
+ ai->setName(ai->name());
+ }
+ break;
+ default:
+ break;
+ }
+
+ // Insert the old track.
+ insertTrack2(i->oTrack, i->trackno);
+ // Chain the old track parts. (removeTrack2, above, takes care of unchaining the new track).
+ chainTrackParts(i->oTrack, true);
+
+ // Update solo states, since the user may have changed soloing on other tracks.
+ updateSoloStates();
+
+ updateFlags |= SC_TRACK_MODIFIED;
+ }
+ break;
+ */
+
+ case UndoOp::SwapTrack:
+ {
+ updateFlags |= SC_TRACK_MODIFIED;
+ Track* track = _tracks[i->a];
+ _tracks[i->a] = _tracks[i->b];
+ _tracks[i->b] = track;
+ updateFlags |= SC_TRACK_MODIFIED;
+ }
+ break;
+ case UndoOp::AddPart:
+ {
+ Part* part = i->oPart;
+ removePart(part);
+ updateFlags |= SC_PART_REMOVED;
+ i->oPart->events()->incARef(-1);
+ //i->oPart->unchainClone();
+ unchainClone(i->oPart);
+ }
+ break;
+ case UndoOp::DeletePart:
+ addPart(i->oPart);
+ updateFlags |= SC_PART_INSERTED;
+ i->oPart->events()->incARef(1);
+ //i->oPart->chainClone();
+ chainClone(i->oPart);
+ break;
+ case UndoOp::ModifyPart:
+ if(i->doCtrls)
+ removePortCtrlEvents(i->oPart, i->doClones);
+ changePart(i->oPart, i->nPart);
+ i->oPart->events()->incARef(-1);
+ i->nPart->events()->incARef(1);
+ //i->oPart->replaceClone(i->nPart);
+ replaceClone(i->oPart, i->nPart);
+ if(i->doCtrls)
+ addPortCtrlEvents(i->nPart, i->doClones);
+ updateFlags |= SC_PART_MODIFIED;
+ break;
+ case UndoOp::AddEvent:
+ if(i->doCtrls)
+ removePortCtrlEvents(i->nEvent, i->part, i->doClones);
+ deleteEvent(i->nEvent, i->part);
+ updateFlags |= SC_EVENT_REMOVED;
+ break;
+ case UndoOp::DeleteEvent:
+ addEvent(i->nEvent, i->part);
+ if(i->doCtrls)
+ addPortCtrlEvents(i->nEvent, i->part, i->doClones);
+ updateFlags |= SC_EVENT_INSERTED;
+ break;
+ case UndoOp::ModifyEvent:
+ if(i->doCtrls)
+ removePortCtrlEvents(i->oEvent, i->part, i->doClones);
+ changeEvent(i->oEvent, i->nEvent, i->part);
+ if(i->doCtrls)
+ addPortCtrlEvents(i->nEvent, i->part, i->doClones);
+ updateFlags |= SC_EVENT_MODIFIED;
+ break;
+ case UndoOp::AddTempo:
+ //printf("doUndo2: UndoOp::AddTempo. deleting tempo at: %d\n", i->a);
+ tempomap.delTempo(i->a);
+ updateFlags |= SC_TEMPO;
+ break;
+ case UndoOp::DeleteTempo:
+ //printf("doUndo2: UndoOp::DeleteTempo. adding tempo at: %d, tempo=%d\n", i->a, i->b);
+ tempomap.addTempo(i->a, i->b);
+ updateFlags |= SC_TEMPO;
+ break;
+ case UndoOp::AddSig:
+ ///sigmap.del(i->a);
+ AL::sigmap.del(i->a);
+ updateFlags |= SC_SIG;
+ break;
+ case UndoOp::DeleteSig:
+ ///sigmap.add(i->a, i->b, i->c);
+ AL::sigmap.add(i->a, AL::TimeSignature(i->b, i->c));
+ updateFlags |= SC_SIG;
+ break;
+ case UndoOp::ModifyClip:
+ case UndoOp::ModifyMarker:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// Song::doRedo2
+//---------------------------------------------------------
+
+void Song::doRedo2()
+ {
+ Undo& u = redoList->back();
+ for (iUndoOp i = u.begin(); i != u.end(); ++i) {
+ switch(i->type) {
+ case UndoOp::AddTrack:
+ insertTrack2(i->oTrack, i->trackno);
+ // Added by T356.
+ chainTrackParts(i->oTrack, true);
+
+ updateFlags |= SC_TRACK_INSERTED;
+ break;
+ case UndoOp::DeleteTrack:
+ removeTrack2(i->oTrack);
+ updateFlags |= SC_TRACK_REMOVED;
+ break;
+ case UndoOp::ModifyTrack:
+ {
+ // Unchain the track parts, but don't touch the ref counts.
+ unchainTrackParts(i->nTrack, false);
+
+ //Track* track = i->nTrack->clone();
+ Track* track = i->nTrack->clone(false);
+
+ *(i->nTrack) = *(i->oTrack);
+
+ // Prevent delete i->oTrack from crashing.
+ switch(i->oTrack->type())
+ {
+ case Track::AUDIO_OUTPUT:
+ {
+ AudioOutput* ao = (AudioOutput*)i->oTrack;
+ for(int ch = 0; ch < ao->channels(); ++ch)
+ ao->setJackPort(ch, 0);
+ }
+ break;
+ case Track::AUDIO_INPUT:
+ {
+ AudioInput* ai = (AudioInput*)i->oTrack;
+ for(int ch = 0; ch < ai->channels(); ++ch)
+ ai->setJackPort(ch, 0);
+ }
+ break;
+ default:
+ break;
+ }
+ if(!i->oTrack->isMidiTrack())
+ ((AudioTrack*)i->oTrack)->clearEfxList();
+
+ delete i->oTrack;
+ i->oTrack = track;
+
+ // Chain the track parts, but don't touch the ref counts.
+ chainTrackParts(i->nTrack, false);
+
+ // Connect and register ports.
+ switch(i->nTrack->type())
+ {
+ case Track::AUDIO_OUTPUT:
+ {
+ AudioOutput* ao = (AudioOutput*)i->nTrack;
+ ao->setName(ao->name());
+ }
+ break;
+ case Track::AUDIO_INPUT:
+ {
+ AudioInput* ai = (AudioInput*)i->nTrack;
+ ai->setName(ai->name());
+ }
+ break;
+ default:
+ break;
+ }
+
+ // Update solo states, since the user may have changed soloing on other tracks.
+ updateSoloStates();
+
+ updateFlags |= SC_TRACK_MODIFIED;
+ }
+ break;
+
+ /*
+ // Prevent delete i->oTrack from crashing.
+ switch(i->oTrack->type())
+ {
+ case Track::AUDIO_OUTPUT:
+ {
+ AudioOutput* ao = (AudioOutput*)i->oTrack;
+ for(int ch = 0; ch < ao->channels(); ++ch)
+ ao->setJackPort(ch, 0);
+ }
+ break;
+ case Track::AUDIO_INPUT:
+ {
+ AudioInput* ai = (AudioInput*)i->oTrack;
+ for(int ch = 0; ch < ai->channels(); ++ch)
+ ai->setJackPort(ch, 0);
+ }
+ break;
+ default:
+ break;
+ }
+ if(!i->oTrack->isMidiTrack())
+ ((AudioTrack*)i->oTrack)->clearEfxList();
+
+ //delete i->oTrack;
+ //i->oTrack = track;
+
+ // Remove the track. removeTrack2 takes care of unchaining the old track.
+ removeTrack2(i->oTrack);
+
+ // Connect and register ports.
+ switch(i->nTrack->type())
+ {
+ case Track::AUDIO_OUTPUT:
+ {
+ AudioOutput* ao = (AudioOutput*)i->nTrack;
+ ao->setName(ao->name());
+ }
+ break;
+ case Track::AUDIO_INPUT:
+ {
+ AudioInput* ai = (AudioInput*)i->nTrack;
+ ai->setName(ai->name());
+ }
+ break;
+ default:
+ break;
+ }
+
+ // Insert the new track.
+ insertTrack2(i->nTrack, i->trackno);
+ // Chain the new track parts. (removeTrack2, above, takes care of unchaining the old track).
+ chainTrackParts(i->nTrack, true);
+
+ // Update solo states, since the user may have changed soloing on other tracks.
+ updateSoloStates();
+
+ updateFlags |= SC_TRACK_MODIFIED;
+ }
+ break;
+ */
+
+ case UndoOp::SwapTrack:
+ {
+ Track* track = _tracks[i->a];
+ _tracks[i->a] = _tracks[i->b];
+ _tracks[i->b] = track;
+ updateFlags |= SC_TRACK_MODIFIED;
+ }
+ break;
+ case UndoOp::AddPart:
+ addPart(i->oPart);
+ updateFlags |= SC_PART_INSERTED;
+ i->oPart->events()->incARef(1);
+ //i->oPart->chainClone();
+ chainClone(i->oPart);
+ break;
+ case UndoOp::DeletePart:
+ removePart(i->oPart);
+ updateFlags |= SC_PART_REMOVED;
+ i->oPart->events()->incARef(-1);
+ //i->oPart->unchainClone();
+ unchainClone(i->oPart);
+ break;
+ case UndoOp::ModifyPart:
+ if(i->doCtrls)
+ removePortCtrlEvents(i->nPart, i->doClones);
+ changePart(i->nPart, i->oPart);
+ i->oPart->events()->incARef(1);
+ i->nPart->events()->incARef(-1);
+ //i->nPart->replaceClone(i->oPart);
+ replaceClone(i->nPart, i->oPart);
+ if(i->doCtrls)
+ addPortCtrlEvents(i->oPart, i->doClones);
+ updateFlags |= SC_PART_MODIFIED;
+ break;
+ case UndoOp::AddEvent:
+ addEvent(i->nEvent, i->part);
+ if(i->doCtrls)
+ addPortCtrlEvents(i->nEvent, i->part, i->doClones);
+ updateFlags |= SC_EVENT_INSERTED;
+ break;
+ case UndoOp::DeleteEvent:
+ if(i->doCtrls)
+ removePortCtrlEvents(i->nEvent, i->part, i->doClones);
+ deleteEvent(i->nEvent, i->part);
+ updateFlags |= SC_EVENT_REMOVED;
+ break;
+ case UndoOp::ModifyEvent:
+ if(i->doCtrls)
+ removePortCtrlEvents(i->nEvent, i->part, i->doClones);
+ changeEvent(i->nEvent, i->oEvent, i->part);
+ if(i->doCtrls)
+ addPortCtrlEvents(i->oEvent, i->part, i->doClones);
+ updateFlags |= SC_EVENT_MODIFIED;
+ break;
+ case UndoOp::AddTempo:
+ //printf("doRedo2: UndoOp::AddTempo. adding tempo at: %d with tempo=%d\n", i->a, i->b);
+ tempomap.addTempo(i->a, i->b);
+ updateFlags |= SC_TEMPO;
+ break;
+ case UndoOp::DeleteTempo:
+ //printf("doRedo2: UndoOp::DeleteTempo. deleting tempo at: %d with tempo=%d\n", i->a, i->b);
+ tempomap.delTempo(i->a);
+ updateFlags |= SC_TEMPO;
+ break;
+ case UndoOp::AddSig:
+ ///sigmap.add(i->a, i->b, i->c);
+ AL::sigmap.add(i->a, AL::TimeSignature(i->b, i->c));
+ updateFlags |= SC_SIG;
+ break;
+ case UndoOp::DeleteSig:
+ ///sigmap.del(i->a);
+ AL::sigmap.del(i->a);
+ updateFlags |= SC_SIG;
+ break;
+ case UndoOp::ModifyClip:
+ case UndoOp::ModifyMarker:
+ break;
+ }
+ }
+ }
+
+void Song::undoOp(UndoOp::UndoType type, int a, int b, int c)
+ {
+ UndoOp i;
+ i.type = type;
+ i.a = a;
+ i.b = b;
+ i.c = c;
+ addUndo(i);
+ }
+
+//void Song::undoOp(UndoOp::UndoType type, Track* oldTrack, Track* newTrack)
+void Song::undoOp(UndoOp::UndoType type, int n, Track* oldTrack, Track* newTrack)
+ {
+ UndoOp i;
+ i.type = type;
+ i.trackno = n;
+ i.oTrack = oldTrack;
+ i.nTrack = newTrack;
+ // Added by Tim. p3.3.6
+ //printf("Song::undoOp ModifyTrack oTrack %p %s nTrack %p %s\n", i.oTrack, i.oTrack->name().toLatin1().constData(), i.nTrack, i.nTrack->name().toLatin1().constData());
+
+ addUndo(i);
+ }
+
+void Song::undoOp(UndoOp::UndoType type, int n, Track* track)
+ {
+ UndoOp i;
+ i.type = type;
+ i.trackno = n;
+ i.oTrack = track;
+ if (type == UndoOp::AddTrack)
+ updateFlags |= SC_TRACK_INSERTED;
+ addUndo(i);
+ }
+
+void Song::undoOp(UndoOp::UndoType type, Part* part)
+ {
+ UndoOp i;
+ i.type = type;
+ i.oPart = part;
+ addUndo(i);
+ }
+
+//void Song::undoOp(UndoOp::UndoType type, Event& oev, Event& nev, Part* part)
+void Song::undoOp(UndoOp::UndoType type, Event& oev, Event& nev, Part* part, bool doCtrls, bool doClones)
+ {
+ UndoOp i;
+ i.type = type;
+ i.nEvent = nev;
+ i.oEvent = oev;
+ i.part = part;
+ i.doCtrls = doCtrls;
+ i.doClones = doClones;
+ addUndo(i);
+ }
+
+void Song::undoOp(UndoOp::UndoType type, Event& nev, Part* part, bool doCtrls, bool doClones)
+ {
+ UndoOp i;
+ i.type = type;
+ i.nEvent = nev;
+ i.part = part;
+ i.doCtrls = doCtrls;
+ i.doClones = doClones;
+ addUndo(i);
+ }
+
+//void Song::undoOp(UndoOp::UndoType type, Part* oPart, Part* nPart)
+void Song::undoOp(UndoOp::UndoType type, Part* oPart, Part* nPart, bool doCtrls, bool doClones)
+ {
+ UndoOp i;
+ i.type = type;
+ i.oPart = nPart;
+ i.nPart = oPart;
+ i.doCtrls = doCtrls;
+ i.doClones = doClones;
+ addUndo(i);
+ }
+
+void Song::undoOp(UndoOp::UndoType type, int c, int ctrl, int ov, int nv)
+ {
+ UndoOp i;
+ i.type = type;
+ i.channel = c;
+ i.ctrl = ctrl;
+ i.oVal = ov;
+ i.nVal = nv;
+ addUndo(i);
+ }
+
+void Song::undoOp(UndoOp::UndoType type, SigEvent* oevent, SigEvent* nevent)
+ {
+ UndoOp i;
+ i.type = type;
+ i.oSignature = oevent;
+ i.nSignature = nevent;
+ addUndo(i);
+ }
+
+void Song::undoOp(UndoOp::UndoType type, const char* changedFile, const char* changeData, int startframe, int endframe)
+ {
+ UndoOp i;
+ i.type = type;
+ i.filename = changedFile;
+ i.tmpwavfile = changeData;
+ i.startframe = startframe;
+ i.endframe = endframe;
+ addUndo(i);
+ temporaryWavFiles.push_back(QString(changeData));
+
+ //printf("Adding ModifyClip undo-operation: origfile=%s tmpfile=%s sf=%d ef=%d\n", changedFile, changeData, startframe, endframe);
+ }
+
+void Song::undoOp(UndoOp::UndoType type, Marker* copyMarker, Marker* realMarker)
+ {
+ UndoOp i;
+ i.type = type;
+ i.realMarker = realMarker;
+ i.copyMarker = copyMarker;
+
+ addUndo(i);
+ }
+
+//---------------------------------------------------------
+// addUndo
+//---------------------------------------------------------
+
+void Song::addUndo(UndoOp& i)
+ {
+ if (!undoMode) {
+ printf("internal error: undoOp without startUndo()\n");
+ return;
+ }
+ undoList->back().push_back(i);
+ dirty = true;
+ }
+
+//---------------------------------------------------------
+// doUndo1
+// non realtime context
+// return true if nothing to do
+//---------------------------------------------------------
+
+bool Song::doUndo1()
+ {
+ if (undoList->empty())
+ return true;
+ Undo& u = undoList->back();
+ for (riUndoOp i = u.rbegin(); i != u.rend(); ++i) {
+ switch(i->type) {
+ case UndoOp::AddTrack:
+ removeTrack1(i->oTrack);
+ break;
+ case UndoOp::DeleteTrack:
+ insertTrack1(i->oTrack, i->trackno);
+
+ // FIXME: Would like to put this part in Undo2, but indications
+ // elsewhere are that (dis)connecting jack routes must not be
+ // done in the realtime thread. The result is that we get a few
+ // "PANIC Process init: No buffer from audio device" messages
+ // before the routes are (dis)connected. So far seems to do no harm though...
+ switch(i->oTrack->type())
+ {
+ case Track::AUDIO_OUTPUT:
+ case Track::AUDIO_INPUT:
+ connectJackRoutes((AudioTrack*)i->oTrack, false);
+ break;
+ //case Track::AUDIO_SOFTSYNTH:
+ //SynthI* si = (SynthI*)i->oTrack;
+ //si->synth()->init(
+ // break;
+ default:
+ break;
+ }
+
+ break;
+ case UndoOp::ModifyClip:
+ SndFile::applyUndoFile(i->filename, i->tmpwavfile, i->startframe, i->endframe);
+ break;
+
+ default:
+ break;
+ }
+ }
+ return false;
+ }
+
+//---------------------------------------------------------
+// doUndo3
+// non realtime context
+//---------------------------------------------------------
+
+void Song::doUndo3()
+ {
+ Undo& u = undoList->back();
+ for (riUndoOp i = u.rbegin(); i != u.rend(); ++i) {
+ switch(i->type) {
+ case UndoOp::AddTrack:
+ removeTrack3(i->oTrack);
+ break;
+ case UndoOp::DeleteTrack:
+ insertTrack3(i->oTrack, i->trackno);
+ break;
+ case UndoOp::ModifyTrack:
+ // Not much choice but to do this - Tim.
+ //clearClipboardAndCloneList();
+ break;
+ case UndoOp::ModifyMarker:
+ {
+ //printf("performing undo for one marker at %d\n", i->realMarker->tick());
+ Marker tmpMarker = *i->realMarker;
+ *i->realMarker = *i->copyMarker; // swap them
+ *i->copyMarker = tmpMarker;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ redoList->push_back(u); // put item on redo list
+ undoList->pop_back();
+ dirty = true;
+ }
+
+//---------------------------------------------------------
+// doRedo1
+// non realtime context
+// return true if nothing to do
+//---------------------------------------------------------
+
+bool Song::doRedo1()
+ {
+ if (redoList->empty())
+ return true;
+ Undo& u = redoList->back();
+ for (iUndoOp i = u.begin(); i != u.end(); ++i) {
+ switch(i->type) {
+ case UndoOp::AddTrack:
+ insertTrack1(i->oTrack, i->trackno);
+
+ // FIXME: See comments in Undo1.
+ switch(i->oTrack->type())
+ {
+ case Track::AUDIO_OUTPUT:
+ case Track::AUDIO_INPUT:
+ connectJackRoutes((AudioTrack*)i->oTrack, false);
+ break;
+ //case Track::AUDIO_SOFTSYNTH:
+ //SynthI* si = (SynthI*)i->oTrack;
+ //si->synth()->init(
+ // break;
+ default:
+ break;
+ }
+
+ break;
+ case UndoOp::DeleteTrack:
+ removeTrack1(i->oTrack);
+ break;
+ case UndoOp::ModifyClip:
+ SndFile::applyUndoFile(i->filename, i->tmpwavfile, i->startframe, i->endframe);
+ break;
+ default:
+ break;
+ }
+ }
+ return false;
+ }
+
+//---------------------------------------------------------
+// doRedo3
+// non realtime context
+//---------------------------------------------------------
+
+void Song::doRedo3()
+ {
+ Undo& u = redoList->back();
+ for (iUndoOp i = u.begin(); i != u.end(); ++i) {
+ switch(i->type) {
+ case UndoOp::AddTrack:
+ insertTrack3(i->oTrack, i->trackno);
+ break;
+ case UndoOp::DeleteTrack:
+ removeTrack3(i->oTrack);
+ break;
+ case UndoOp::ModifyTrack:
+ // Not much choice but to do this - Tim.
+ //clearClipboardAndCloneList();
+ break;
+ case UndoOp::ModifyMarker:
+ {
+ //printf("performing redo for one marker at %d\n", i->realMarker->tick());
+ Marker tmpMarker = *i->realMarker;
+ *i->realMarker = *i->copyMarker; // swap them
+ *i->copyMarker = tmpMarker;
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ undoList->push_back(u); // put item on undo list
+ redoList->pop_back();
+ dirty = true;
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/undo.h b/attic/muse2-oom/muse2/muse/undo.h
new file mode 100644
index 00000000..896b8a94
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/undo.h
@@ -0,0 +1,110 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: undo.h,v 1.6.2.5 2009/05/24 21:43:44 terminator356 Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __UNDO_H__
+#define __UNDO_H__
+
+#include <list>
+
+#include "event.h"
+#include "marker/marker.h"
+
+class QString;
+
+class Track;
+class TEvent;
+class SigEvent;
+class Part;
+
+extern std::list<QString> temporaryWavFiles; //!< Used for storing all tmp-files, for cleanup on shutdown
+//---------------------------------------------------------
+// UndoOp
+//---------------------------------------------------------
+
+struct UndoOp {
+ enum UndoType {
+ AddTrack, DeleteTrack, ModifyTrack,
+ AddPart, DeletePart, ModifyPart,
+ AddEvent, DeleteEvent, ModifyEvent,
+ AddTempo, DeleteTempo,
+ AddSig, DeleteSig,
+ SwapTrack,
+ ModifyClip,
+ ModifyMarker,
+ AddTrackView, DeleteTrackView, ModifyTrackView
+ };
+ UndoType type;
+
+ union {
+ struct {
+ int a;
+ int b;
+ int c;
+ };
+ struct {
+ Track* oTrack;
+ Track* nTrack;
+ int trackno;
+ };
+ struct {
+ Part* oPart;
+ Part* nPart;
+ };
+ struct {
+ Part* part;
+ };
+ struct {
+ SigEvent* nSignature;
+ SigEvent* oSignature;
+ };
+ struct {
+ int channel;
+ int ctrl;
+ int oVal;
+ int nVal;
+ };
+ struct {
+ int startframe; //!< Start frame of changed data
+ int endframe; //!< End frame of changed data
+ const char* filename; //!< The file that is changed
+ const char* tmpwavfile; //!< The file with the changed data
+ };
+ struct {
+ Marker* realMarker;
+ Marker* copyMarker;
+ };
+ struct {
+ int d;
+ int e;
+ int f;
+ };
+ };
+ Event oEvent;
+ Event nEvent;
+ bool doCtrls;
+ bool doClones;
+ const char* typeName();
+ void dump();
+ };
+
+class Undo : public std::list<UndoOp> {
+ void undoOp(UndoOp::UndoType, int data);
+ };
+
+typedef Undo::iterator iUndoOp;
+typedef Undo::reverse_iterator riUndoOp;
+
+class UndoList : public std::list<Undo> {
+ public:
+ void clearDelete();
+ };
+
+typedef UndoList::iterator iUndo;
+
+
+#endif // __UNDO_H__
diff --git a/attic/muse2-oom/muse2/muse/value.cpp b/attic/muse2-oom/muse2/muse/value.cpp
new file mode 100644
index 00000000..dfdbe1ad
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/value.cpp
@@ -0,0 +1,62 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: value.cpp,v 1.2 2004/02/28 14:58:21 wschweer Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "value.h"
+#include "xml.h"
+
+
+IValue::IValue(QObject* parent, const char* name)
+ : QObject(parent)
+ {
+ setObjectName(name);
+ }
+BValue::BValue(QObject* parent, const char* name)
+ : QObject(parent)
+ {
+ setObjectName(name);
+ }
+
+//---------------------------------------------------------
+// save
+//---------------------------------------------------------
+
+void BValue::save(int level, Xml& xml)
+ {
+ xml.intTag(level, objectName().toLatin1().constData(), val);
+ }
+
+//---------------------------------------------------------
+// save
+//---------------------------------------------------------
+
+void IValue::save(int level, Xml& xml)
+ {
+ xml.intTag(level, objectName().toLatin1().constData(), val);
+ }
+
+//---------------------------------------------------------
+// setValue
+//---------------------------------------------------------
+
+void BValue::setValue(bool v)
+ {
+ if (val != v) {
+ val = v;
+ emit valueChanged(val);
+ emit valueChanged(int(val));
+ }
+ }
+
+void IValue::setValue(int v)
+ {
+ if (val != v) {
+ val = v;
+ emit valueChanged(val);
+ }
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/value.h b/attic/muse2-oom/muse2/muse/value.h
new file mode 100644
index 00000000..22aa9b5a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/value.h
@@ -0,0 +1,61 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: value.h,v 1.1.1.1 2003/10/27 18:51:53 wschweer Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __VALUE_H__
+#define __VALUE_H__
+
+#include <QObject>
+
+class Xml;
+
+//---------------------------------------------------------
+// IValue
+//---------------------------------------------------------
+
+class IValue : public QObject {
+ int val;
+
+ Q_OBJECT
+
+ signals:
+ void valueChanged(int);
+
+ public slots:
+ void setValue(int v);
+
+ public:
+ IValue(QObject* parent=0, const char* name=0);
+ int value() const { return val; }
+ void save(int level, Xml& xml);
+ };
+
+//---------------------------------------------------------
+// BValue
+//---------------------------------------------------------
+
+class BValue : public QObject {
+ bool val;
+
+ Q_OBJECT
+
+ signals:
+ void valueChanged(bool);
+ void valueChanged(int);
+
+ public slots:
+ void setValue(bool v);
+ void setValue(int v) { setValue(bool(v)); }
+
+ public:
+ BValue(QObject* parent=0, const char* name=0);
+ bool value() const { return val; }
+ void save(int level, Xml& xml);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/vst.cpp b/attic/muse2-oom/muse2/muse/vst.cpp
new file mode 100644
index 00000000..b34b71ca
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/vst.cpp
@@ -0,0 +1,633 @@
+//===================================================================
+// MusE
+// Linux Music Editor
+// $Id: vst.cpp,v 1.5.2.6 2009/12/06 10:05:00 terminator356 Exp $
+//
+// This code is based on jack_fst:
+// Copyright (C) 2004 Paul Davis <paul@linuxaudiosystems.com>
+// Torben Hohn <torbenh@informatik.uni-bremen.de>
+//
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//===================================================================
+
+#include "config.h"
+
+#ifdef VST_SUPPORT
+
+#include <QDir>
+#include <QMenu>
+
+#include <cmath>
+#include <fst.h>
+#include <vst/aeffectx.h>
+#include <jack/jack.h>
+
+#include "vst.h"
+#include "globals.h"
+#include "synth.h"
+#include "jackaudio.h"
+#include "midi.h"
+#include "xml.h"
+
+extern "C" void fst_error(const char *fmt, ...);
+extern long vstHostCallback (AEffect*, long, long, long, void*, float);
+
+extern JackAudioDevice* jackAudio;
+
+//---------------------------------------------------------
+// vstHostCallback
+//---------------------------------------------------------
+
+long vstHostCallback(AEffect* effect,
+ long opcode, long index, long value, void* ptr, float opt)
+ {
+ static VstTimeInfo _timeInfo;
+
+// JackVST* jackvst = effect ? ((JackVST*) effect->user) : NULL;
+ jack_position_t jack_pos;
+ jack_transport_state_t tstate;
+
+ switch (opcode) {
+ case audioMasterAutomate:
+ // index, value, returns 0
+ effect->setParameter (effect, index, opt);
+ return 0;
+
+ case audioMasterVersion:
+ // vst version, currently 2 (0 for older)
+ return 2;
+
+ case audioMasterCurrentId:
+ // returns the unique id of a plug that's currently
+ // loading
+ return 0;
+
+ case audioMasterIdle:
+ // call application idle routine (this will
+ // call effEditIdle for all open editors too)
+ effect->dispatcher(effect, effEditIdle, 0, 0, NULL, 0.0f);
+ return 0;
+
+ case audioMasterPinConnected:
+ // inquire if an input or output is beeing connected;
+ // index enumerates input or output counting from zero:
+ // value is 0 for input and != 0 otherwise. note: the
+ // return value is 0 for <true> such that older versions
+ // will always return true.
+ return 1;
+
+ case audioMasterWantMidi:
+ // <value> is a filter which is currently ignored
+ return 0;
+
+ case audioMasterGetTime:
+ // returns const VstTimeInfo* (or 0 if not supported)
+ // <value> should contain a mask indicating which fields are required
+ // (see valid masks above), as some items may require extensive
+ // conversions
+
+ memset(&_timeInfo, 0, sizeof(_timeInfo));
+
+ if (effect) {
+ tstate = jackAudio->transportQuery(&jack_pos);
+
+ _timeInfo.samplePos = jack_pos.frame;
+ _timeInfo.sampleRate = jack_pos.frame_rate;
+ _timeInfo.flags = 0;
+
+ if ((value & (kVstBarsValid|kVstTempoValid)) && (jack_pos.valid & JackPositionBBT)) {
+ _timeInfo.tempo = jack_pos.beats_per_minute;
+ _timeInfo.timeSigNumerator = (long) floor (jack_pos.beats_per_bar);
+ _timeInfo.timeSigDenominator = (long) floor (jack_pos.beat_type);
+ _timeInfo.flags |= (kVstBarsValid|kVstTempoValid);
+ }
+ if (tstate == JackTransportRolling) {
+ _timeInfo.flags |= kVstTransportPlaying;
+ }
+ }
+ else {
+ _timeInfo.samplePos = 0;
+ _timeInfo.sampleRate = sampleRate;
+ }
+ return (long)&_timeInfo;
+
+ case audioMasterProcessEvents:
+ // VstEvents* in <ptr>
+ return 0;
+
+ case audioMasterSetTime:
+ // VstTimenfo* in <ptr>, filter in <value>, not supported
+
+ case audioMasterTempoAt:
+ // returns tempo (in bpm * 10000) at sample frame location passed in <value>
+ return 0;
+
+ case audioMasterGetNumAutomatableParameters:
+ return 0;
+
+ case audioMasterGetParameterQuantization:
+ // returns the integer value for +1.0 representation,
+ // or 1 if full single float precision is maintained
+ // in automation. parameter index in <value> (-1: all, any)
+ return 0;
+
+ case audioMasterIOChanged:
+ // numInputs and/or numOutputs has changed
+ return 0;
+
+ case audioMasterNeedIdle:
+ // plug needs idle calls (outside its editor window)
+ return 0;
+
+ case audioMasterSizeWindow:
+ // index: width, value: height
+ return 0;
+
+ case audioMasterGetSampleRate:
+ return 0;
+
+ case audioMasterGetBlockSize:
+ return 0;
+
+ case audioMasterGetInputLatency:
+ return 0;
+
+ case audioMasterGetOutputLatency:
+ return 0;
+
+ case audioMasterGetPreviousPlug:
+ // input pin in <value> (-1: first to come), returns cEffect*
+ return 0;
+
+ case audioMasterGetNextPlug:
+ // output pin in <value> (-1: first to come), returns cEffect*
+
+ case audioMasterWillReplaceOrAccumulate:
+ // returns: 0: not supported, 1: replace, 2: accumulate
+ return 0;
+
+ case audioMasterGetCurrentProcessLevel:
+ // returns: 0: not supported,
+ // 1: currently in user thread (gui)
+ // 2: currently in audio thread (where process is called)
+ // 3: currently in 'sequencer' thread (midi, timer etc)
+ // 4: currently offline processing and thus in user thread
+ // other: not defined, but probably pre-empting user thread.
+ return 0;
+
+ case audioMasterGetAutomationState:
+ // returns 0: not supported, 1: off, 2:read, 3:write, 4:read/write
+ // offline
+ return 0;
+
+ case audioMasterOfflineStart:
+ case audioMasterOfflineRead:
+ // ptr points to offline structure, see below. return 0: error, 1 ok
+ return 0;
+
+ case audioMasterOfflineWrite:
+ // same as read
+ return 0;
+
+ case audioMasterOfflineGetCurrentPass:
+ case audioMasterOfflineGetCurrentMetaPass:
+ return 0;
+
+ case audioMasterSetOutputSampleRate:
+ // for variable i/o, sample rate in <opt>
+ return 0;
+
+ case audioMasterGetSpeakerArrangement:
+ // (long)input in <value>, output in <ptr>
+ return 0;
+
+ case audioMasterGetVendorString:
+ // fills <ptr> with a string identifying the vendor (max 64 char)
+ strcpy ((char*) ptr, "LAD");
+ return 0;
+
+ case audioMasterGetProductString:
+ // fills <ptr> with a string with product name (max 64 char)
+ strcpy ((char*) ptr, "FreeST");
+
+ case audioMasterGetVendorVersion:
+ // returns vendor-specific version
+ return 1000;
+
+ case audioMasterVendorSpecific:
+ // no definition, vendor specific handling
+ return 0;
+
+ case audioMasterSetIcon:
+ // void* in <ptr>, format not defined yet
+ return 0;
+
+ case audioMasterCanDo:
+ // string in ptr, see below
+ return 0;
+
+ case audioMasterGetLanguage:
+ // see enum
+ return 0;
+
+ case audioMasterOpenWindow:
+ // returns platform specific ptr
+ return 0;
+
+ case audioMasterCloseWindow:
+ // close window, platform specific handle in <ptr>
+ return 0;
+
+ case audioMasterGetDirectory:
+ // get plug directory, FSSpec on MAC, else char*
+ return 0;
+
+ case audioMasterUpdateDisplay:
+ // something has changed, update 'multi-fx' display
+ effect->dispatcher(effect, effEditIdle, 0, 0, NULL, 0.0f);
+ return 0;
+
+ case audioMasterBeginEdit:
+ // begin of automation session (when mouse down), parameter index in <index>
+ return 0;
+
+ case audioMasterEndEdit:
+ // end of automation session (when mouse up), parameter index in <index>
+ return 0;
+
+ case audioMasterOpenFileSelector:
+ // open a fileselector window with VstFileSelect* in <ptr>
+ return 0;
+
+ default:
+ break;
+ }
+ return 0;
+ }
+
+//---------------------------------------------------------
+// scanVstDir
+//---------------------------------------------------------
+
+static void scanVstDir(const QString& s)
+ {
+ if (debugMsg)
+ printf("scan vst plugin dir <%s>\n", s.toLatin1());
+ QDir pluginDir(s, QString("*.dll"), QDir::Files);
+ if (pluginDir.exists()) {
+ const QFileInfoList* list = pluginDir.entryInfoList();
+ QFileInfoListIterator it(*list);
+ QFileInfo* fi;
+ while((fi = it.current())) {
+ char* path = strdup(fi->filePath().toLatin1());
+ FSTInfo* info = fst_get_info(path);
+ if (info) {
+ if (info->numInputs == 0 && info->numOutputs)
+ //synthis.push_back(new VstSynth(*fi));
+ synthis.push_back(new VstSynth(*fi, fi->baseName(), QString(), QString(), QString()));
+ fst_free_info(info);
+ }
+ free(path);
+ ++it;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// fstSignalHandler
+//---------------------------------------------------------
+
+static void fstSignalHandler(int sig, siginfo_t* /*info*/, void* /*context*/)
+ {
+ fst_error("fst signal handler %d, thread = 0x%x", sig, pthread_self ());
+ if (sig == SIGSEGV || sig == SIGABRT) {
+ char*p = 0;
+ *p = 0;
+ }
+ exit(-1);
+ }
+
+void jfst_reserve_mem (int bufsize)
+{
+ char buf [bufsize];
+ int i;
+
+ fprintf (stderr, "Reserving memory: base=%p, size=%d, end=%p\n",
+ buf, sizeof(buf), buf+sizeof(buf));
+ for (i=0; i<bufsize; i++)
+ {
+ buf[i] = (char) (i % 256);
+ }
+}
+
+//---------------------------------------------------------
+// initVST
+//---------------------------------------------------------
+
+void initVST()
+ {
+ jfst_reserve_mem(1000000);
+
+ if (fst_init(fstSignalHandler)) {
+ printf("initVST failed\n");
+ return;
+ }
+
+ char* vstPath = getenv("VST_PATH");
+ if (vstPath == 0)
+ vstPath = "/usr/lib/vst:/usr/local/lib/vst";
+
+ char* p = vstPath;
+ while (*p != '\0') {
+ char* pe = p;
+ while (*pe != ':' && *pe != '\0')
+ pe++;
+
+ int n = pe - p;
+ if (n) {
+ char* buffer = new char[n + 1];
+ strncpy(buffer, p, n);
+ buffer[n] = '\0';
+ scanVstDir(QString(buffer));
+ delete[] buffer;
+ }
+ p = pe;
+ if (*p == ':')
+ p++;
+ }
+ }
+
+//---------------------------------------------------------
+// guiVisible
+//---------------------------------------------------------
+
+bool VstSynthIF::guiVisible() const
+ {
+ return _guiVisible;
+ }
+
+
+//---------------------------------------------------------
+// showGui
+//---------------------------------------------------------
+
+void VstSynthIF::showGui(bool v)
+ {
+ if (v == guiVisible())
+ return;
+ if (v)
+ fst_run_editor(_fst);
+ else
+ fst_destroy_editor(_fst);
+ _guiVisible = v;
+ }
+
+//---------------------------------------------------------
+// receiveEvent
+//---------------------------------------------------------
+
+MidiPlayEvent VstSynthIF::receiveEvent()
+ {
+ return MidiPlayEvent();
+ }
+
+//---------------------------------------------------------
+// hasGui
+//---------------------------------------------------------
+
+bool VstSynthIF::hasGui() const
+ {
+ return _fst->plugin->flags & effFlagsHasEditor;
+ }
+
+//---------------------------------------------------------
+// incInstances
+//---------------------------------------------------------
+
+void VstSynth::incInstances(int val)
+ {
+ _instances += val;
+ if (_instances == 0 && fstHandle) {
+ fst_unload(fstHandle);
+ fstHandle = 0;
+ }
+ }
+
+//---------------------------------------------------------
+// instantiate
+//---------------------------------------------------------
+
+void* VstSynth::instantiate()
+ {
+ ++_instances;
+ QString n;
+ n.setNum(_instances);
+ QString instanceName = baseName() + "-" + n;
+ doSetuid();
+ QByteArray ba = info.filePath().toLatin1();
+ const char* path = ba.constData();
+
+ fstHandle = fst_load(path);
+ if (fstHandle == 0) {
+ printf("Synth::instantiate: cannot load vst plugin %s\n", path);
+ undoSetuid();
+ return 0;
+ }
+ FST* fst = fst_instantiate(fstHandle, vstHostCallback, 0);
+ if (fst == 0) {
+ printf("Synth::instantiate:: cannot instantiate plugin %s\n", path);
+ undoSetuid();
+ return 0;
+ }
+ AEffect* plugin = fst->plugin;
+ plugin->dispatcher (plugin, effMainsChanged, 0, 1, 0, 0.0f);
+
+ /* set program to zero */
+
+ plugin->dispatcher (plugin, effSetProgram, 0, 0, NULL, 0.0f);
+
+ if (fst_run_editor(fst)) {
+ printf("Synth::instantiate: cannot create gui");
+ undoSetuid();
+ return 0;
+ }
+// int vst_version = plugin->dispatcher (plugin, effGetVstVersion, 0, 0, NULL, 0.0f);
+ undoSetuid();
+ return fst;
+ }
+
+//---------------------------------------------------------
+// init
+//---------------------------------------------------------
+
+bool VstSynthIF::init(Synth* s)
+ {
+ _fst = (FST*)((VstSynth*)s)->instantiate();
+ return (_fst == 0);
+ }
+
+//---------------------------------------------------------
+// channels
+//---------------------------------------------------------
+
+int VstSynthIF::channels() const
+ {
+ AEffect* plugin = _fst->plugin;
+ return plugin->numOutputs;
+ }
+
+int VstSynthIF::totalOutChannels() const
+ {
+ AEffect* plugin = _fst->plugin;
+ return plugin->numOutputs;
+ }
+
+int VstSynthIF::totalInChannels() const
+ {
+ AEffect* plugin = _fst->plugin;
+ return plugin->numInputs;
+ }
+
+//---------------------------------------------------------
+// createSIF
+//---------------------------------------------------------
+
+//SynthIF* VstSynth::createSIF() const
+SynthIF* VstSynth::createSIF(SynthI* s)
+ {
+ //return new VstSynthIF();
+
+ VstSynthIF* sif = new VstSynthIF(s);
+ sif->init(this, s);
+ return sif;
+ }
+
+//---------------------------------------------------------
+// deactivate3
+//---------------------------------------------------------
+
+void VstSynthIF::deactivate3()
+ {
+ if (_fst) {
+ if (_guiVisible)
+ fst_destroy_editor(_fst);
+ fst_close(_fst);
+ _fst = 0;
+ }
+ }
+
+//---------------------------------------------------------
+// getParameter
+//---------------------------------------------------------
+
+float VstSynthIF::getParameter(unsigned long idx) const
+ {
+ return _fst->plugin->getParameter(_fst->plugin, idx);
+ }
+
+//---------------------------------------------------------
+// setParameter
+//---------------------------------------------------------
+
+void VstSynthIF::setParameter(unsigned long idx, float value)
+ {
+ _fst->plugin->setParameter(_fst->plugin, idx, value);
+ }
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+void VstSynthIF::write(int level, Xml& xml) const
+ {
+ //---------------------------------------------
+ // dump current state of synth
+ //---------------------------------------------
+
+ int len = 0;
+ const unsigned char* p;
+ AEffect* plugin = _fst->plugin;
+ int params = plugin->numParams;
+ for (int i = 0; i < params; ++i) {
+ float f = plugin->getParameter(plugin, i);
+ xml.floatTag(level, "param", f);
+ }
+ }
+
+//---------------------------------------------------------
+// getData
+//---------------------------------------------------------
+
+iMPEvent VstSynthIF::getData(MidiPort* mp, MPEventList* el, iMPEvent i, unsigned pos, int ports, unsigned n, float** buffer)
+ {
+ AEffect* plugin = _fst->plugin;
+ for (; i != el->end(); ++i) {
+ if (mp)
+ mp->sendEvent(*i);
+ else {
+ if (putEvent(*i))
+ break;
+ }
+ }
+ if (plugin->flags & effFlagsCanReplacing) {
+ plugin->processReplacing(plugin, 0, buffer, n);
+ }
+ else {
+ plugin->process(plugin, 0, buffer, n);
+ }
+ return el->end();
+ }
+
+//---------------------------------------------------------
+// putEvent
+//---------------------------------------------------------
+
+bool VstSynthIF::putEvent(const MidiPlayEvent& ev)
+ {
+ if (midiOutputTrace)
+ ev.dump();
+ AEffect* plugin = _fst->plugin;
+ static struct VstEvents events;
+ static struct VstMidiEvent event;
+ events.numEvents = 1;
+ events.reserved = 0;
+ events.events[0] = (VstEvent*)(&event);
+
+ event.type = kVstMidiType;
+ event.byteSize = 24;
+ event.deltaFrames = 0;
+ event.flags = 0;
+ event.detune = 0;
+ event.noteLength = 0;
+ event.noteOffset = 0;
+ event.reserved1 = 0;
+ event.reserved2 = 0;
+ event.noteOffVelocity = 0;
+ switch (ev.type()) {
+ case ME_PITCHBEND:
+ {
+ int a = ev.dataA() + 8192;
+ int b = a >> 7;
+ event.midiData[0] = (ev.type() | ev.channel()) & 0xff;
+ event.midiData[1] = a & 0x7f;
+ event.midiData[2] = b & 0x7f;
+ event.midiData[3] = 0;
+ }
+ break;
+
+ case ME_CONTROLLER:
+ case ME_NOTEON:
+ default:
+ event.midiData[0] = (ev.type() | ev.channel()) & 0xff;
+ event.midiData[1] = ev.dataA() & 0xff;
+ event.midiData[2] = ev.dataB() & 0xff;
+ event.midiData[3] = 0;
+ break;
+ }
+ int rv = plugin->dispatcher(plugin, effProcessEvents, 0, 0, &events, 0.0f);
+ return false;
+ }
+#else
+void initVST() {}
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/vst.h b/attic/muse2-oom/muse2/muse/vst.h
new file mode 100644
index 00000000..93012093
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/vst.h
@@ -0,0 +1,83 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: vst.h,v 1.11.2.3 2009/11/25 09:09:44 terminator356 Exp $
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __VST_H__
+#define __VST_H__
+
+#include "synth.h"
+
+class QMenu;
+
+struct _FSTHandle;
+struct _FST;
+
+//---------------------------------------------------------
+// VstSynth
+//---------------------------------------------------------
+
+class VstSynth : public Synth {
+ _FSTHandle* fstHandle;
+
+ public:
+ //VstSynth(const QFileInfo& fi) : Synth(fi) { fstHandle = 0; }
+ VstSynth(const QFileInfo& fi) : Synth(fi, fi->baseName()) {
+ fstHandle = 0;
+ }
+
+ virtual ~VstSynth() {}
+ virtual void incInstances(int val);
+ virtual void* instantiate();
+ //virtual SynthIF* createSIF() const;
+ virtual SynthIF* createSIF(SynthI*) const;
+ };
+
+//---------------------------------------------------------
+// VstSynthIF
+// VSTi synthesizer instance
+//---------------------------------------------------------
+
+class VstSynthIF : public SynthIF
+ {
+ _FST* _fst;
+ bool _guiVisible;
+
+ public:
+ //VstSynthIF() { _fst = 0; _guiVisible = false; }
+ VstSynthIF(SynthI* s) : SynthIF(s) {
+ _fst = 0;
+ _guiVisible = false;
+ }
+
+ virtual bool initGui() { return true; };
+ virtual void guiHeartBeat() { }
+ virtual bool guiVisible() const;
+ virtual void showGui(bool v);
+ virtual bool hasGui() const;
+ virtual void getGeometry(int*, int*, int*, int*) const {}
+ virtual void setGeometry(int, int, int, int) {}
+ virtual void preProcessAlways() { };
+ virtual iMPEvent getData(MidiPort*, MPEventList*, iMPEvent, unsigned pos, int ports, unsigned n, float** buffer) ;
+ virtual bool putEvent(const MidiPlayEvent& ev);
+ virtual MidiPlayEvent receiveEvent();
+ virtual int eventsPending() const { return 0; }
+ virtual bool init(Synth*);
+ virtual int channels() const;
+ virtual int totalOutChannels() const;
+ virtual int totalInChannels() const;
+ virtual void deactivate3();
+ virtual const char* getPatchName(int, int, int, bool) const { return ""; }
+ virtual const char* getPatchName(int, int, MType, bool) { return ""; }
+ virtual void populatePatchPopup(QMenu*, int, MType, bool) {};
+ virtual void write(int level, Xml& xml) const;
+ virtual float getParameter(unsigned long idx) const;
+ virtual void setParameter(unsigned long idx, float value);
+ virtual int getControllerInfo(int, const char**, int*, int*, int*, int*) { return 0; }
+ };
+
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/wave.cpp b/attic/muse2-oom/muse2/muse/wave.cpp
new file mode 100644
index 00000000..b519ca70
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/wave.cpp
@@ -0,0 +1,1176 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: wave.cpp,v 1.19.2.20 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 2000-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <cmath>
+
+#include <QDateTime>
+#include <QFileInfo>
+#include <QMessageBox>
+#include <QProgressDialog>
+
+#include "xml.h"
+#include "song.h"
+#include "wave.h"
+#include "app.h"
+#include "filedialog.h"
+#include "arranger/arranger.h"
+#include "globals.h"
+#include "event.h"
+#include "audio.h"
+///#include "sig.h"
+#include "al/sig.h"
+
+//#define WAVE_DEBUG
+//#define WAVE_DEBUG_PRC
+
+/*
+const char* audioFilePattern[] = {
+ "Wave/Binary (*.wav *.ogg *.bin)",
+ "Wave (*.wav *.ogg)",
+ "Binary (*.bin)",
+ "All Files (*)",
+ 0
+ };
+*/
+const int cacheMag = 128;
+
+// ClipList* waveClips;
+
+SndFileList SndFile::sndFiles;
+
+//---------------------------------------------------------
+// SndFile
+//---------------------------------------------------------
+
+SndFile::SndFile(const QString& name)
+ {
+ finfo = new QFileInfo(name);
+ sf = 0;
+ sfUI = 0;
+ csize = 0;
+ cache = 0;
+ openFlag = false;
+ sndFiles.push_back(this);
+ refCount=0;
+ }
+
+SndFile::~SndFile()
+ {
+ if (openFlag)
+ close();
+ for (iSndFile i = sndFiles.begin(); i != sndFiles.end(); ++i) {
+ if (*i == this) {
+ sndFiles.erase(i);
+ break;
+ }
+ }
+ delete finfo;
+ if (cache) {
+ for (unsigned i = 0; i < channels(); ++i)
+ delete cache[i];
+ delete[] cache;
+ cache = 0;
+ }
+ }
+
+//---------------------------------------------------------
+// openRead
+//---------------------------------------------------------
+
+bool SndFile::openRead()
+ {
+ if (openFlag) {
+ printf("SndFile:: alread open\n");
+ return false;
+ }
+ QString p = path();
+ sfinfo.format = 0;
+ sf = sf_open(p.toLatin1().constData(), SFM_READ, &sfinfo);
+ sfinfo.format = 0;
+ sfUI = sf_open(p.toLatin1().constData(), SFM_READ, &sfinfo);
+ if (sf == 0 || sfUI == 0)
+ return true;
+
+ writeFlag = false;
+ openFlag = true;
+ QString cacheName = finfo->absolutePath() + QString("/") + finfo->completeBaseName() + QString(".wca");
+ readCache(cacheName, true);
+ return false;
+ }
+
+//---------------------------------------------------------
+// update
+// called after recording to file
+//---------------------------------------------------------
+
+void SndFile::update()
+ {
+ close();
+
+ // force recreation of wca data
+ QString cacheName = finfo->absolutePath() +
+ QString("/") + finfo->completeBaseName() + QString(".wca");
+ ::remove(cacheName.toLatin1().constData());
+ if (openRead()) {
+ printf("SndFile::update openRead(%s) failed: %s\n", path().toLatin1().constData(), strerror().toLatin1().constData());
+ }
+ }
+
+//---------------------------------------------------------
+// readCache
+//---------------------------------------------------------
+
+void SndFile::readCache(const QString& path, bool showProgress)
+ {
+// printf("readCache %s for %d samples channel %d\n",
+// path.toLatin1().constData(), samples(), channels());
+
+ if (cache) {
+ for (unsigned i = 0; i < channels(); ++i)
+ delete cache[i];
+ delete[] cache;
+ }
+ if (samples() == 0) {
+// printf("SndFile::readCache: file empty\n");
+ return;
+ }
+ csize = (samples() + cacheMag - 1)/cacheMag;
+ cache = new SampleV*[channels()];
+ for (unsigned ch = 0; ch < channels(); ++ch)
+ cache[ch] = new SampleV[csize];
+
+ FILE* cfile = fopen(path.toLatin1().constData(), "r");
+ if (cfile) {
+ for (unsigned ch = 0; ch < channels(); ++ch)
+ fread(cache[ch], csize * sizeof(SampleV), 1, cfile);
+ fclose(cfile);
+ return;
+ }
+
+ //---------------------------------------------------
+ // create cache
+ //---------------------------------------------------
+ QProgressDialog* progress = 0;
+ if (showProgress) {
+ QString label(QWidget::tr("create peakfile for "));
+ label += basename();
+ progress = new QProgressDialog(label,
+ QString::null, 0, csize, 0);
+ progress->setMinimumDuration(0);
+ progress->show();
+ }
+ float data[channels()][cacheMag];
+ float* fp[channels()];
+ for (unsigned k = 0; k < channels(); ++k)
+ fp[k] = &data[k][0];
+ int interval = csize / 10;
+
+ if(!interval)
+ interval = 1;
+ for (int i = 0; i < csize; i++) {
+ if (showProgress && ((i % interval) == 0))
+ progress->setValue(i);
+ seek(i * cacheMag, 0);
+ read(channels(), fp, cacheMag);
+ for (unsigned ch = 0; ch < channels(); ++ch) {
+ float rms = 0.0;
+ cache[ch][i].peak = 0;
+ for (int n = 0; n < cacheMag; n++) {
+ float fd = data[ch][n];
+ rms += fd * fd;
+ int idata = int(fd * 255.0);
+ if (idata < 0)
+ idata = -idata;
+ if (cache[ch][i].peak < idata)
+ cache[ch][i].peak = idata;
+ }
+ // amplify rms value +12dB
+ int rmsValue = int((sqrt(rms/cacheMag) * 255.0));
+ if (rmsValue > 255)
+ rmsValue = 255;
+ cache[ch][i].rms = rmsValue;
+ }
+ }
+ if (showProgress)
+ progress->setValue(csize);
+ writeCache(path);
+ if (showProgress)
+ delete progress;
+ }
+
+//---------------------------------------------------------
+// writeCache
+//---------------------------------------------------------
+
+void SndFile::writeCache(const QString& path)
+ {
+ FILE* cfile = fopen(path.toLatin1().constData(), "w");
+ if (cfile == 0)
+ return;
+ for (unsigned ch = 0; ch < channels(); ++ch)
+ fwrite(cache[ch], csize * sizeof(SampleV), 1, cfile);
+ fclose(cfile);
+ }
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+void SndFile::read(SampleV* s, int mag, unsigned pos, bool overwrite)
+ {
+ if(overwrite)
+ for (unsigned ch = 0; ch < channels(); ++ch) {
+ s[ch].peak = 0;
+ s[ch].rms = 0;
+ }
+
+ if (pos > samples()) {
+// printf("%p pos %d > samples %d\n", this, pos, samples());
+ return;
+ }
+
+ if (mag < cacheMag) {
+ float data[channels()][mag];
+ float* fp[channels()];
+ for (unsigned i = 0; i < channels(); ++i)
+ fp[i] = &data[i][0];
+
+ sf_count_t ret = 0;
+ if(sfUI)
+ ret = sf_seek(sfUI, pos, SEEK_SET);
+ else
+ ret = sf_seek(sf, pos, SEEK_SET);
+ if(ret == -1)
+ return;
+ {
+ int srcChannels = channels();
+ int dstChannels = sfinfo.channels;
+ size_t n = mag;
+ float** dst = fp;
+ float buffer[n * dstChannels];
+
+ size_t rn = 0;
+ if(sfUI)
+ rn = sf_readf_float(sfUI, buffer, n);
+ else
+ rn = sf_readf_float(sf, buffer, n);
+ if(rn != n)
+ return;
+ float* src = buffer;
+
+ if (srcChannels == dstChannels) {
+ for (size_t i = 0; i < rn; ++i) {
+ for (int ch = 0; ch < srcChannels; ++ch)
+ *(dst[ch]+i) = *src++;
+ }
+ }
+ else if ((srcChannels == 1) && (dstChannels == 2)) {
+ // stereo to mono
+ for (size_t i = 0; i < rn; ++i)
+ *(dst[0] + i) = src[i + i] + src[i + i + 1];
+ }
+ else if ((srcChannels == 2) && (dstChannels == 1)) {
+ // mono to stereo
+ for (size_t i = 0; i < rn; ++i) {
+ float data = *src++;
+ *(dst[0]+i) = data;
+ *(dst[1]+i) = data;
+ }
+ }
+ }
+
+ for (unsigned ch = 0; ch < channels(); ++ch) {
+
+ if(overwrite)
+ s[ch].peak = 0;
+
+ float rms = 0.0;
+ for (int i = 0; i < mag; i++) {
+ float fd = data[ch][i];
+ rms += fd;
+ int idata = int(fd * 255.0);
+ if (idata < 0)
+ idata = -idata;
+ if (s[ch].peak < idata)
+ s[ch].peak = idata;
+ }
+
+ s[ch].rms = 0; // TODO rms / mag;
+ }
+ }
+ else {
+ mag /= cacheMag;
+ int rest = csize - (pos/cacheMag);
+ int end = mag;
+ if (rest < mag)
+ end = rest;
+
+ for (unsigned ch = 0; ch < channels(); ++ch) {
+ int rms = 0;
+ int off = pos/cacheMag;
+ for (int offset = off; offset < off+end; offset++) {
+ rms += cache[ch][offset].rms;
+ if (s[ch].peak < cache[ch][offset].peak)
+ s[ch].peak = cache[ch][offset].peak;
+ }
+
+ if(overwrite)
+ s[ch].rms = rms / mag;
+
+ else
+ s[ch].rms += rms / mag;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// openWrite
+//---------------------------------------------------------
+
+bool SndFile::openWrite()
+ {
+ if (openFlag) {
+ printf("SndFile:: alread open\n");
+ return false;
+ }
+ QString p = path();
+ sf = sf_open(p.toLatin1().constData(), SFM_RDWR, &sfinfo);
+ sfUI = 0;
+ if (sf) {
+ openFlag = true;
+ writeFlag = true;
+ QString cacheName = finfo->absolutePath() +
+ QString("/") + finfo->completeBaseName() + QString(".wca");
+ readCache(cacheName, true);
+ }
+ return sf == 0;
+ }
+
+//---------------------------------------------------------
+// close
+//---------------------------------------------------------
+
+void SndFile::close()
+ {
+ if (!openFlag) {
+ printf("SndFile:: alread closed\n");
+ return;
+ }
+ sf_close(sf);
+ if (sfUI)
+ sf_close(sfUI);
+ openFlag = false;
+ }
+
+//---------------------------------------------------------
+// remove
+//---------------------------------------------------------
+
+void SndFile::remove()
+ {
+ if (openFlag)
+ close();
+ QFile::remove(finfo->filePath());
+ }
+
+QString SndFile::basename() const
+ {
+ return finfo->completeBaseName();
+ }
+
+QString SndFile::path() const
+ {
+ return finfo->filePath();
+ }
+
+QString SndFile::dirPath() const
+ {
+ return finfo->absolutePath();
+ }
+
+QString SndFile::name() const
+ {
+ return finfo->fileName();
+ }
+
+//---------------------------------------------------------
+// samples
+//---------------------------------------------------------
+
+unsigned SndFile::samples() const
+ {
+ if (!writeFlag) // if file is read only sfinfo is reliable
+ return sfinfo.frames;
+ sf_count_t curPos = sf_seek(sf, 0, SEEK_CUR);
+ int frames = sf_seek(sf, 0, SEEK_END);
+ sf_seek(sf, curPos, SEEK_SET);
+ return frames;
+ }
+
+//---------------------------------------------------------
+// channels
+//---------------------------------------------------------
+
+unsigned SndFile::channels() const
+ {
+ return sfinfo.channels;
+ }
+
+unsigned SndFile::samplerate() const
+ {
+ return sfinfo.samplerate;
+ }
+
+unsigned SndFile::format() const
+ {
+ return sfinfo.format;
+ }
+
+void SndFile::setFormat(int fmt, int ch, int rate)
+ {
+ sfinfo.samplerate = rate;
+ sfinfo.channels = ch;
+ sfinfo.format = fmt;
+ sfinfo.seekable = true;
+ sfinfo.frames = 0;
+ }
+
+//---------------------------------------------------------
+// readWithHeap
+// not as realtime friendly but can retrieve bigger data
+//---------------------------------------------------------
+size_t SndFile::readWithHeap(int srcChannels, float** dst, size_t n, bool overwrite)
+ {
+ float *buffer = new float[n * sfinfo.channels];
+ int rn = readInternal(srcChannels,dst,n,overwrite, buffer);
+ delete buffer;
+ return rn;
+ }
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+size_t SndFile::read(int srcChannels, float** dst, size_t n, bool overwrite)
+ {
+ float buffer[n * sfinfo.channels];
+ int rn = readInternal(srcChannels,dst,n,overwrite, buffer);
+ return rn;
+ }
+
+size_t SndFile::readInternal(int srcChannels, float** dst, size_t n, bool overwrite, float *buffer)
+{
+ size_t rn = sf_readf_float(sf, buffer, n);
+
+ float* src = buffer;
+ int dstChannels = sfinfo.channels;
+ if (srcChannels == dstChannels) {
+ if(overwrite)
+ for (size_t i = 0; i < rn; ++i) {
+ for (int ch = 0; ch < srcChannels; ++ch)
+ *(dst[ch]+i) = *src++;
+ }
+ else
+ for (size_t i = 0; i < rn; ++i) {
+ for (int ch = 0; ch < srcChannels; ++ch)
+ *(dst[ch]+i) += *src++;
+ }
+ }
+ else if ((srcChannels == 1) && (dstChannels == 2)) {
+ // stereo to mono
+ if(overwrite)
+ for (size_t i = 0; i < rn; ++i)
+ *(dst[0] + i) = src[i + i] + src[i + i + 1];
+ else
+ for (size_t i = 0; i < rn; ++i)
+ *(dst[0] + i) += src[i + i] + src[i + i + 1];
+ }
+ else if ((srcChannels == 2) && (dstChannels == 1)) {
+ // mono to stereo
+ if(overwrite)
+ for (size_t i = 0; i < rn; ++i) {
+ float data = *src++;
+ *(dst[0]+i) = data;
+ *(dst[1]+i) = data;
+ }
+ else
+ for (size_t i = 0; i < rn; ++i) {
+ float data = *src++;
+ *(dst[0]+i) += data;
+ *(dst[1]+i) += data;
+ }
+ }
+ else {
+ printf("SndFile:read channel mismatch %d -> %d\n",
+ srcChannels, dstChannels);
+ }
+
+ return rn;
+
+}
+
+
+//---------------------------------------------------------
+// write
+//
+// A hardcoded limiter was added that limits the output at 0.99/-0.99
+// libsndfile handles signal betwee -1.0/1.0 with current setting
+// outside these values there will be heavy distortion
+//
+//---------------------------------------------------------
+
+size_t SndFile::write(int srcChannels, float** src, size_t n)
+ {
+ int dstChannels = sfinfo.channels;
+ //float buffer[n * dstChannels];
+ float *buffer = new float[n * dstChannels];
+ float *dst = buffer;
+
+ const float limitValue=0.9999;
+
+
+ if (srcChannels == dstChannels) {
+ for (size_t i = 0; i < n; ++i) {
+ for (int ch = 0; ch < dstChannels; ++ch)
+ //*dst++ = *(src[ch]+i); // < limitValue ? *(src[ch]+i) : limitValue;
+ if (*(src[ch]+i) > 0)
+ *dst++ = *(src[ch]+i) < limitValue ? *(src[ch]+i) : limitValue;
+ else
+ *dst++ = *(src[ch]+i) > -limitValue ? *(src[ch]+i) : -limitValue;
+ }
+ }
+ else if ((srcChannels == 1) && (dstChannels == 2)) {
+ // mono to stereo
+ for (size_t i = 0; i < n; ++i) {
+ float data = *(src[0]+i);
+ if (data > 0) {
+ *dst++ = data < limitValue ? data : limitValue;
+ *dst++ = data < limitValue ? data : limitValue;
+ }
+ else {
+ *dst++ = data > -limitValue ? data : -limitValue;
+ *dst++ = data > -limitValue ? data : -limitValue;
+ }
+ }
+ }
+ else if ((srcChannels == 2) && (dstChannels == 1)) {
+ // stereo to mono
+ for (size_t i = 0; i < n; ++i)
+ if (*(src[0]+i) + *(src[1]+i) > 0)
+ *dst++ = (*(src[0]+i) + *(src[1]+i)) < limitValue ? (*(src[0]+i) + *(src[1]+i)) : limitValue;
+ else
+ *dst++ = (*(src[0]+i) + *(src[1]+i)) > -limitValue ? (*(src[0]+i) + *(src[1]+i)) : -limitValue;
+ }
+ else {
+ printf("SndFile:write channel mismatch %d -> %d\n",
+ srcChannels, dstChannels);
+ delete buffer;
+ return 0;
+ }
+ int nbr = sf_writef_float(sf, buffer, n) ;
+ delete buffer;
+ return nbr;
+ }
+
+//---------------------------------------------------------
+// seek
+//---------------------------------------------------------
+
+off_t SndFile::seek(off_t frames, int whence)
+ {
+ return sf_seek(sf, frames, whence);
+ }
+
+//---------------------------------------------------------
+// strerror
+//---------------------------------------------------------
+
+QString SndFile::strerror() const
+ {
+ char buffer[128];
+ buffer[0] = 0;
+ sf_error_str(sf, buffer, 128);
+ return QString(buffer);
+ }
+
+//---------------------------------------------------------
+// search
+//---------------------------------------------------------
+
+SndFile* SndFileList::search(const QString& name)
+ {
+ for (iSndFile i = begin(); i != end(); ++i) {
+ if ((*i)->path() == name)
+ return *i;
+ }
+ return 0;
+ }
+
+//---------------------------------------------------------
+// getSnd
+//---------------------------------------------------------
+
+SndFile* getWave(const QString& inName, bool readOnlyFlag)
+ {
+ QString name = inName;
+
+ if (QFileInfo(name).isRelative()) {
+ name = museProject + QString("/") + name;
+ }
+ else {
+ if (!QFile::exists(name)) {
+ if (QFile::exists(museProject + QString("/") + name)) {
+ name = museProject + QString("/") + name;
+ }
+ }
+ }
+// printf("=====%s %s\n", inName.toLatin1().constData(), name.toLatin1().constData());
+
+ // only open one instance of wave file
+ SndFile* f = SndFile::sndFiles.search(name);
+ if (f == 0) {
+ if (!QFile::exists(name)) {
+ fprintf(stderr, "wave file <%s> not found\n",
+ name.toLatin1().constData());
+ return 0;
+ }
+ f = new SndFile(name);
+ bool error;
+ if (readOnlyFlag)
+ error = f->openRead();
+ else {
+ error = f->openWrite();
+ // if peak cache is older than wave file we reaquire the cache
+ QFileInfo wavinfo(name);
+ QString cacheName = wavinfo.absolutePath() + QString("/") + wavinfo.completeBaseName() + QString(".wca");
+ QFileInfo wcainfo(cacheName);
+ if (!wcainfo.exists() || wcainfo.lastModified() < wavinfo.lastModified()) {
+ //printf("wcafile is older or does not exist!\n");
+ QFile(cacheName).remove();
+ f->readCache(cacheName,true);
+ }
+
+ }
+ if (error) {
+ fprintf(stderr, "open wave file(%s) for %s failed: %s\n",
+ name.toLatin1().constData(),
+ readOnlyFlag ? "writing" : "reading",
+ f->strerror().toLatin1().constData());
+ QMessageBox::critical(NULL, "MusE import error.",
+ "MusE failed to import the file.\n"
+ "Possibly this wasn't a sound file?\n"
+ "If it was check the permissions, MusE\n"
+ "sometimes requires write access to the file.");
+
+ delete f;
+ f = 0;
+ }
+ }
+ else {
+ if (!readOnlyFlag && ! f->isWritable()) {
+ if (f->isOpen())
+ f->close();
+ f->openWrite();
+ }
+ else {
+ // if peak cache is older than wave file we reaquire the cache
+ QFileInfo wavinfo(name);
+ QString cacheName = wavinfo.absolutePath() + QString("/") + wavinfo.completeBaseName() + QString(".wca");
+ QFileInfo wcainfo(cacheName);
+ if (!wcainfo.exists() || wcainfo.lastModified() < wavinfo.lastModified()) {
+ //printf("wcafile is older or does not exist!\n");
+ QFile(cacheName).remove();
+ f->readCache(cacheName,true);
+ }
+
+ }
+ }
+ return f;
+ }
+
+//---------------------------------------------------------
+// applyUndoFile
+//---------------------------------------------------------
+void SndFile::applyUndoFile(const QString& original, const QString& tmpfile, unsigned startframe, unsigned endframe)
+ {
+ // This one is called on both undo and redo of a wavfile
+ // For redo to be called, undo must have been called first, and we don't store both the original data and the modified data in separate
+ // files. Thus, each time this function is called the data in the "original"-file will be written to the tmpfile, after the data
+ // from the tmpfile has been applied.
+ //
+ // F.ex. if mute has been made on part of a wavfile, the unmuted data is stored in the tmpfile when
+ // the undo operation occurs. The unmuted data is then written back to the original file, and the mute data will be
+ // put in the tmpfile, and when redo is eventually called the data is switched again (causing the muted data to be written to the "original"
+ // file. The data is merely switched.
+
+ //printf("Applying undofile: orig=%s tmpfile=%s startframe=%d endframe=%d\n", original.toLatin1().constData(), tmpfile.toLatin1().constData(), startframe, endframe);
+ SndFile* orig = sndFiles.search(original);
+ SndFile tmp = SndFile(tmpfile);
+ if (!orig) {
+ printf("Internal error: could not find original file: %s in filelist - Aborting\n", original.toLatin1().constData());
+ return;
+ }
+
+ if (!orig->isOpen()) {
+ if (orig->openRead()) {
+ printf("Cannot open original file %s for reading - cannot undo! Aborting\n", original.toLatin1().constData());
+ return;
+ }
+ }
+
+ if (!tmp.isOpen()) {
+ if (tmp.openRead()) {
+ printf("Could not open temporary file %s for writing - cannot undo! Aborting\n", tmpfile.toLatin1().constData());
+ return;
+ }
+ }
+
+ audio->msgIdle(true);
+ tmp.setFormat(orig->format(), orig->channels(), orig->samplerate());
+
+ // Read data in original file to memory before applying tmpfile to original
+ unsigned file_channels = orig->channels();
+ unsigned tmpdatalen = endframe - startframe;
+ float* data2beoverwritten[file_channels];
+
+ for (unsigned i=0; i<file_channels; i++) {
+ data2beoverwritten[i] = new float[tmpdatalen];
+ }
+ orig->seek(startframe, 0);
+ orig->readWithHeap(file_channels, data2beoverwritten, tmpdatalen);
+
+ orig->close();
+
+ // Read data from temporary file to memory
+ float* tmpfiledata[file_channels];
+ for (unsigned i=0; i<file_channels; i++) {
+ tmpfiledata[i] = new float[tmpdatalen];
+ }
+ tmp.seek(0, 0);
+ tmp.readWithHeap(file_channels, tmpfiledata, tmpdatalen);
+ tmp.close();
+
+ // Write temporary data to original file:
+ if (orig->openWrite()) {
+ printf("Cannot open orig for write - aborting.\n");
+ return;
+ }
+
+ orig->seek(startframe, 0);
+ orig->write(file_channels, tmpfiledata, tmpdatalen);
+
+ // Delete dataholder for temporary file
+ for (unsigned i=0; i<file_channels; i++) {
+ delete[] tmpfiledata[i];
+ }
+
+ // Write the overwritten data to the tmpfile
+ if (tmp.openWrite()) {
+ printf("Cannot open tmpfile for writing - redo operation of this file won't be possible. Aborting.\n");
+ audio->msgIdle(false);
+ return;
+ }
+ tmp.seek(0, 0);
+ tmp.write(file_channels, data2beoverwritten, tmpdatalen);
+ tmp.close();
+
+ // Delete dataholder for replaced original file
+ for (unsigned i=0; i<file_channels; i++) {
+ delete[] data2beoverwritten[i];
+ }
+
+ orig->close();
+ orig->openRead();
+ orig->update();
+ audio->msgIdle(false);
+ }
+
+//---------------------------------------------------------
+// importAudio
+//---------------------------------------------------------
+
+void MusE::importWave()
+ {
+ Track* track = arranger->curTrack();
+ if (track == 0 || track->type() != Track::WAVE) {
+ QMessageBox::critical(this, QString("MusE"),
+ tr("to import an audio file you have first to select"
+ "a wave track"));
+ return;
+ }
+ //QString fn = getOpenFileName(lastWavePath, audioFilePattern, this,
+ QString fn = getOpenFileName(lastWavePath, audio_file_pattern, this,
+ tr("Import Wave File"), 0);
+ if (!fn.isEmpty()) {
+ lastWavePath = fn;
+ importWaveToTrack(fn);
+ }
+ }
+
+//---------------------------------------------------------
+// importWaveToTrack
+//---------------------------------------------------------
+
+bool MusE::importWaveToTrack(QString& name, unsigned tick, Track* track)
+ {
+ if (track==NULL)
+ track = (WaveTrack*)(arranger->curTrack());
+
+ SndFile* f = getWave(name, true);
+
+ if (f == 0) {
+ printf("import audio file failed\n");
+ return true;
+ }
+ int samples = f->samples();
+ if ((unsigned)sampleRate !=f->samplerate()) {
+ if(QMessageBox::question(this, tr("Import Wavefile"),
+ tr("This wave file has a samplerate of %1,\n"
+ "as opposed to current setting %2.\n"
+ "Do you still want to import it?").arg(f->samplerate()).arg(sampleRate),
+ tr("&Yes"), tr("&No"),
+ QString::null, 0, 1 ))
+ {
+ //printf("why won't muse let me delete the file object? %d\n", f->getRefCount());
+ if (f->getRefCount() == 0)
+ delete f;
+ return true;
+ }
+ }
+ track->setChannels(f->channels());
+
+ WavePart* part = new WavePart((WaveTrack *)track);
+ if (tick)
+ part->setTick(tick);
+ else
+ part->setTick(song->cpos());
+ part->setLenFrame(samples);
+
+ Event event(Wave);
+ SndFileR sf(f);
+ event.setSndFile(sf);
+ event.setSpos(0);
+ event.setLenFrame(samples);
+ part->addEvent(event);
+
+ part->setName(QFileInfo(name).completeBaseName());
+ audio->msgAddPart(part);
+ unsigned endTick = part->tick() + part->lenTick();
+ if (song->len() < endTick)
+ song->setLen(endTick);
+ return false;
+ }
+#if 0
+//---------------------------------------------------------
+// Clip
+//---------------------------------------------------------
+
+ClipBase::ClipBase(const SndFileR& file, int start, int l)
+ : f(file)
+ {
+ refCount = 0;
+ for (int i = 1; true; ++i) {
+ _name.sprintf("%s.%d", f.basename().toLatin1().constData(), i);
+ ciClip ic = waveClips->begin();
+ for (; ic != waveClips->end(); ++ic) {
+ if ((*ic)->name() == _name)
+ break;
+ }
+ if (ic == waveClips->end())
+ break;
+ // try another name
+ }
+ _spos = start;
+ len = l;
+ deleted = false;
+ lrefs = 0;
+ waveClips->add(this);
+ }
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+void ClipBase::read(unsigned srcOffset, float** buffer, int channel, unsigned n)
+ {
+ if (f.isNull())
+ return;
+ f.seek(srcOffset + _spos, 0);
+ f.read(channel, buffer, n);
+ }
+
+ClipBase::~ClipBase()
+ {
+ waveClips->remove(this);
+ }
+
+//---------------------------------------------------------
+// ClipList::write(level, xml)
+//---------------------------------------------------------
+
+void ClipList::write(int level, Xml& xml) const
+ {
+ for (ciClip i = begin(); i != end(); ++i) {
+ ClipBase* clip = *i;
+ // only write visible clips
+ if (clip->references())
+ (*i)->write(level, xml);
+ }
+ }
+
+//---------------------------------------------------------
+// ClipBase::write(level, xml)
+//---------------------------------------------------------
+
+void ClipBase::write(int level, Xml& xml) const
+ {
+ xml.tag(level++, "clip");
+ QString path = f.dirPath();
+
+ //
+ // waves in the project dirctory are stored
+ // with relative path name, others with absolute path
+ //
+ if (path == museProject)
+ xml.strTag(level, "file", f.name());
+ else
+ xml.strTag(level, "file", f.path());
+
+ xml.strTag(level, "name", _name);
+ xml.intTag(level, "tick", _spos);
+ xml.intTag(level, "len", len);
+ xml.etag(level, "clip");
+ }
+
+//---------------------------------------------------------
+// ClipBase::read
+//---------------------------------------------------------
+
+ClipBase* readClip(Xml& xml)
+ {
+ SndFile* f = 0;
+ QString name;
+ unsigned spos = 0;
+ int len = 0;
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return 0;
+ case Xml::TagStart:
+ if (tag == "file")
+ f = getWave(xml.parse1(), false);
+ else if (tag == "name")
+ name = xml.parse1();
+ else if (tag == "tick")
+ spos = xml.parseInt();
+ else if (tag == "len")
+ len = xml.parseInt();
+ else
+ xml.unknown("Clip");
+ break;
+ case Xml::TagEnd:
+ if (tag == "clip") {
+ if (!f)
+ printf("clip: file not found\n");
+ ClipBase* clip = new ClipBase(f, spos, len);
+ clip->setName(name);
+ return clip;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// search
+//---------------------------------------------------------
+
+Clip ClipList::search(const QString& name) const
+ {
+ for (ciClip i = begin(); i != end(); ++i)
+ if ((*i)->name() == name)
+ return Clip(*i);
+ fprintf(stderr, "ClipList: clip <%s> not found\n",
+ name.toLatin1().constData());
+ return Clip();
+ }
+
+//---------------------------------------------------------
+// remove
+//---------------------------------------------------------
+
+void ClipList::remove(ClipBase* clip)
+ {
+ for (iClip i = begin(); i != end(); ++i) {
+ if (*i == clip) {
+ erase(i);
+ return;
+ }
+ }
+ printf("ClipList:remove: clip not found\n");
+ }
+
+//---------------------------------------------------------
+// idx
+//---------------------------------------------------------
+
+int ClipList::idx(const Clip& clip) const
+ {
+ int n = 0;
+ for (ciClip i = begin(); i != end(); ++i, ++n) {
+ if (clip == *i)
+ return n;
+ }
+ return -1;
+ }
+#endif
+
+//---------------------------------------------------------
+// cmdAddRecordedWave
+//---------------------------------------------------------
+
+//void Song::cmdAddRecordedWave(WaveTrack* track, const Pos& s, const Pos& e)
+void Song::cmdAddRecordedWave(WaveTrack* track, Pos s, Pos e)
+ {
+ SndFile* f = track->recFile();
+ if (f == 0) {
+ printf("cmdAddRecordedWave: no snd file for track <%s>\n",
+ track->name().toLatin1().constData());
+ return;
+ }
+
+ // Removed by Tim. p3.3.8
+ //unsigned startTick = roundDownBar(s.tick());
+ //unsigned endTick = roundUpBar(e.tick());
+
+ // Added by Tim. p3.3.8
+
+ if((audio->loopCount() > 0 && s.tick() > lPos().tick()) || (punchin() && s.tick() < lPos().tick()))
+ s.setTick(lPos().tick());
+ // If we are looping, just set the end to the right marker, since we don't know how many loops have occurred.
+ // (Fixed: Added Audio::loopCount)
+ // Otherwise if punchout is on, limit the end to the right marker.
+ //if(loop() || (punchout() && e.tick() > rPos().tick()) )
+ if((audio->loopCount() > 0) || (punchout() && e.tick() > rPos().tick()) )
+ e.setTick(rPos().tick());
+ // No part to be created? Delete the rec sound file.
+ if(s.tick() >= e.tick())
+ {
+ QString s = f->path();
+ delete f;
+ // The function which calls this function already does this immediately after. But do it here anyway.
+ track->setRecFile(0);
+ remove(s.toLatin1().constData());
+ if(debugMsg)
+ printf("Song::cmdAddRecordedWave: remove file %s\n", s.toLatin1().constData());
+ return;
+ }
+ // Round the start down using the Arranger part snap raster value.
+ unsigned startTick = AL::sigmap.raster1(s.tick(), song->arrangerRaster());
+ // Round the end up using the Arranger part snap raster value.
+ unsigned endTick = AL::sigmap.raster2(e.tick(), song->arrangerRaster());
+
+ f->update();
+
+ WavePart* part = new WavePart(track);
+ part->setTick(startTick);
+ part->setLenTick(endTick - startTick);
+ part->setName(track->name());
+
+ // create Event
+ Event event(Wave);
+ SndFileR sf(f);
+ event.setSndFile(sf);
+ // We are done with the _recFile member. Set to zero. The function which
+ // calls this function already does this immediately after. But do it here anyway.
+ track->setRecFile(0);
+
+ event.setSpos(0);
+
+ // Since the part start was snapped down, we must apply the difference so that the
+ // wave event tick lines up with when the user actually started recording.
+ // Added by Tim. p3.3.8
+ event.setTick(s.tick() - startTick);
+
+
+ event.setLenFrame(e.frame() - s.frame());
+ part->addEvent(event);
+
+ song->cmdAddPart(part);
+
+ if (song->len() < endTick)
+ song->setLen(endTick);
+ }
+
+//---------------------------------------------------------
+// cmdChangeWave
+// called from GUI context
+//---------------------------------------------------------
+void Song::cmdChangeWave(QString original, QString tmpfile, unsigned sx, unsigned ex)
+ {
+ char* original_charstr = new char[original.length() + 1];
+ char* tmpfile_charstr = new char[tmpfile.length() + 1];
+ strcpy(original_charstr, original.toLatin1().constData());
+ strcpy(tmpfile_charstr, tmpfile.toLatin1().constData());
+ song->undoOp(UndoOp::ModifyClip, original_charstr, tmpfile_charstr, sx, ex);
+ }
+
+//---------------------------------------------------------
+// SndFileR
+//---------------------------------------------------------
+
+SndFileR::SndFileR(SndFile* _sf)
+ {
+ sf = _sf;
+ if (sf)
+ (sf->refCount)++;
+ }
+
+SndFileR::SndFileR(const SndFileR& ed)
+ {
+ sf = ed.sf;
+ if (sf)
+ (sf->refCount)++;
+ }
+
+//---------------------------------------------------------
+// operator=
+//---------------------------------------------------------
+
+SndFileR& SndFileR::operator=(const SndFileR& ed)
+ {
+ if (sf == ed.sf)
+ return *this;
+ if (sf && --(sf->refCount) == 0) {
+ delete sf;
+ }
+ sf = ed.sf;
+ if (sf)
+ (sf->refCount)++;
+ return *this;
+ }
+
+//---------------------------------------------------------
+// ~SndFileR
+//---------------------------------------------------------
+
+SndFileR::~SndFileR()
+ {
+ if (sf)
+ if (--(sf->refCount) == 0) {
+ delete sf;
+ sf=NULL;
+ }
+ }
diff --git a/attic/muse2-oom/muse2/muse/wave.h b/attic/muse2-oom/muse2/muse/wave.h
new file mode 100644
index 00000000..c2a0d38a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/wave.h
@@ -0,0 +1,265 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: wave.h,v 1.5.2.7 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 1999/2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __WAVE_H__
+#define __WAVE_H__
+
+#include <list>
+#include <sndfile.h>
+
+#include <QString>
+
+class QFileInfo;
+class Xml;
+
+//---------------------------------------------------------
+// SampleV
+// peak file value
+//---------------------------------------------------------
+
+struct SampleV {
+ unsigned char peak;
+ unsigned char rms;
+ };
+
+//---------------------------------------------------------
+// SndFileList
+//---------------------------------------------------------
+
+class SndFile;
+class SndFileList : public std::list<SndFile*> {
+ public:
+ SndFile* search(const QString& name);
+ };
+
+typedef SndFileList::iterator iSndFile;
+typedef SndFileList::const_iterator ciSndFile;
+
+//---------------------------------------------------------
+// SndFile
+//---------------------------------------------------------
+
+class SndFile {
+ //static SndFileList _sndFiles;
+ QFileInfo* finfo;
+ SNDFILE* sf;
+ SNDFILE* sfUI;
+ SF_INFO sfinfo;
+ SampleV** cache;
+ int csize; //!< frames in cache
+
+ void writeCache(const QString& path);
+
+ bool openFlag;
+ bool writeFlag;
+ size_t readInternal(int srcChannels, float** dst, size_t n, bool overwrite, float *buffer);
+
+ protected:
+ int refCount;
+
+ public:
+ SndFile(const QString& name);
+ ~SndFile();
+ int getRefCount() { return refCount; }
+
+ static SndFileList sndFiles;
+ static void applyUndoFile(const QString& original, const QString& tmpfile, unsigned sx, unsigned ex);
+
+ void readCache(const QString& path, bool progress);
+
+ bool openRead(); //!< returns true on error
+ bool openWrite(); //!< returns true on error
+ void close();
+ void remove();
+
+ bool isOpen() const { return openFlag; }
+ bool isWritable() const { return writeFlag; }
+ void update();
+
+ QString basename() const; //!< filename without extension
+ QString dirPath() const; //!< path
+ QString path() const; //!< path with filename
+ QString name() const; //!< filename
+
+ unsigned samples() const;
+ unsigned channels() const;
+ unsigned samplerate() const;
+ unsigned format() const;
+ int sampleBits() const;
+ void setFormat(int fmt, int ch, int rate);
+
+ size_t read(int channel, float**, size_t, bool overwrite = true);
+ size_t readWithHeap(int channel, float**, size_t, bool overwrite = true);
+ size_t readDirect(float* buf, size_t n) { return sf_readf_float(sf, buf, n); }
+ size_t write(int channel, float**, size_t);
+
+ off_t seek(off_t frames, int whence);
+ void read(SampleV* s, int mag, unsigned pos, bool overwrite = true);
+ QString strerror() const;
+
+ static SndFile* search(const QString& name);
+ friend class SndFileR;
+ };
+
+//---------------------------------------------------------
+// SndFileR
+// SndFile with reference count
+//---------------------------------------------------------
+
+class SndFileR {
+ SndFile* sf;
+
+ public:
+ SndFileR() { sf = 0; }
+ SndFileR(SndFile* _sf);
+ SndFileR(const SndFileR& ed);
+ SndFileR& operator=(const SndFileR& ed);
+ bool operator==(const SndFileR& c) const { return sf == c.sf; }
+ bool operator==(SndFile* c) const { return sf == c; }
+ ~SndFileR();
+ int getRefCount() const { return sf->refCount; }
+ bool isNull() const { return sf == 0; }
+
+ bool openRead() { return sf->openRead(); }
+ bool openWrite() { return sf->openWrite(); }
+ void close() { sf->close(); }
+ void remove() { sf->remove(); }
+
+ bool isOpen() const { return sf->isOpen(); }
+ bool isWritable() const { return sf->isWritable(); }
+ void update() { sf->update(); }
+
+ QString basename() const { return sf->basename(); }
+ QString dirPath() const { return sf->dirPath(); }
+ QString path() const { return sf->path(); }
+ QString name() const { return sf->name(); }
+
+ unsigned samples() const { return sf->samples(); }
+ unsigned channels() const { return sf->channels(); }
+ unsigned samplerate() const { return sf->samplerate(); }
+ unsigned format() const { return sf->format(); }
+ int sampleBits() const { return sf->sampleBits(); }
+ void setFormat(int fmt, int ch, int rate) {
+ sf->setFormat(fmt, ch, rate);
+ }
+ size_t readWithHeap(int channel, float** f, size_t n, bool overwrite = true) {
+ return sf->readWithHeap(channel, f, n, overwrite);
+ }
+ size_t read(int channel, float** f, size_t n, bool overwrite = true) {
+ return sf->read(channel, f, n, overwrite);
+ }
+ size_t readDirect(float* f, size_t n) { return sf->readDirect(f, n); }
+
+ size_t write(int channel, float** f, size_t n) {
+ return sf->write(channel, f, n);
+ }
+ off_t seek(off_t frames, int whence) {
+ return sf->seek(frames, whence);
+ }
+ void read(SampleV* s, int mag, unsigned pos, bool overwrite = true) {
+ sf->read(s, mag, pos, overwrite);
+ }
+ QString strerror() const { return sf->strerror(); }
+ };
+
+
+#if 0
+
+class Clip;
+//---------------------------------------------------------
+// ClipBase
+//---------------------------------------------------------
+
+class ClipBase {
+ protected:
+ QString _name;
+ SndFileR f;
+ int _spos; // start sample position in WaveFile
+ int len; // len of clip
+ int lrefs; // logical references
+ bool deleted;
+ int refCount;
+
+ public:
+ ClipBase(const SndFileR& f, int start, int len);
+ ~ClipBase();
+ const QString& name() const { return _name; }
+ void setName(const QString& s) { _name = s; }
+ int spos() const { return _spos; }
+ void setSpos(int s) { _spos = s; }
+ SndFileR file1() const { return f; }
+
+ void read(unsigned, float**, int, unsigned);
+ void write(int, Xml&) const;
+ int samples() const { return len; }
+ void setSamples(int s) { len = s; }
+ int getRefCount() const { return refCount; }
+ int references() const { return lrefs; }
+ void incRefs() { ++lrefs; }
+ void decRefs() { --lrefs; }
+ friend class WaveEvent;
+ };
+
+//---------------------------------------------------------
+// Clip
+//---------------------------------------------------------
+
+class Clip {
+ ClipBase* clip;
+
+ public:
+ Clip();
+ Clip(ClipBase* clip);
+ Clip(const SndFileR& f, int start, int len);
+ Clip(const Clip&);
+ Clip& operator=(const Clip&);
+ bool operator==(const Clip& c) const { return clip == c.clip; }
+ bool operator==(ClipBase* c) const { return clip == c; }
+ ~Clip();
+
+ // ClipBase* clipBase() const { return clip; }
+ bool isNull() const { return clip == 0; }
+ int getRefCount() const { return clip->getRefCount(); }
+
+ const QString& name() const { return clip->name(); }
+ void setName(const QString& s) { clip->setName(s); }
+ int spos() const { return clip->spos(); }
+ void setSpos(int s) { clip->setSpos(s); }
+ SndFileR file1() const { return clip->file1(); }
+
+ void read(unsigned off, float** f, int ch, unsigned nn) {
+ clip->read(off, f, ch, nn);
+ }
+ int samples() const { return clip->samples(); }
+ void setSamples(int s) { clip->setSamples(s); }
+ int references() const { return clip->references(); }
+ void incRefs() { clip->incRefs(); }
+ void decRefs() { clip->decRefs(); }
+ };
+
+//---------------------------------------------------------
+// ClipList
+//---------------------------------------------------------
+
+class ClipList : public std::list<ClipBase*> {
+ public:
+ int idx(const Clip&) const;
+ Clip search(const QString&) const;
+ void write(int, Xml&) const;
+ void add(ClipBase* clip) { push_back(clip); }
+ void remove(ClipBase*);
+ };
+
+typedef ClipList::iterator iClip;
+typedef ClipList::const_iterator ciClip;
+extern ClipBase* readClip(Xml& xml);
+#endif
+
+extern SndFile* getWave(const QString& name, bool readOnlyFlag);
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/waveedit/CMakeLists.txt b/attic/muse2-oom/muse2/muse/waveedit/CMakeLists.txt
new file mode 100644
index 00000000..24696887
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/waveedit/CMakeLists.txt
@@ -0,0 +1,87 @@
+#=============================================================================
+# MusE
+# Linux Music Editor
+# $Id:$
+#
+# Copyright (C) 2002-2006 by Werner Schweer and others
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#=============================================================================
+
+##
+## Expand Qt macros in source files
+##
+QT4_WRAP_CPP ( waveedit_mocs
+ editgain.h
+ waveedit.h
+ waveview.h
+ )
+
+##
+## UI files
+##
+file (GLOB waveedit_ui_files
+ editgainbase.ui
+ )
+QT4_WRAP_UI (waveedit_ui_headers ${waveedit_ui_files} )
+
+##
+## List of source files to compile
+##
+file (GLOB waveedit_source_files
+ editgain.cpp
+ waveedit.cpp
+ waveview.cpp
+ )
+
+##
+## Define target
+##
+add_library ( waveedit SHARED
+ ${waveedit_source_files}
+ ${waveedit_ui_headers}
+ ${waveedit_mocs}
+ )
+
+##
+## Append to the list of translations
+##
+set (FILES_TO_TRANSLATE
+ ${FILES_TO_TRANSLATE}
+ ${waveedit_source_files}
+ ${waveedit_ui_files}
+ CACHE INTERNAL ""
+ )
+
+##
+## Compilation flags and target name
+##
+set_target_properties( waveedit
+ PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h -fPIC"
+ OUTPUT_NAME muse_waveedit
+ )
+
+##
+## Linkage
+##
+target_link_libraries( waveedit
+ ${QT_LIBRARIES}
+ widgets
+ )
+
+##
+## Install location
+##
+install(TARGETS waveedit
+ DESTINATION ${MusE_MODULES_DIR}
+ )
diff --git a/attic/muse2-oom/muse2/muse/waveedit/editgain.cpp b/attic/muse2-oom/muse2/muse/waveedit/editgain.cpp
new file mode 100644
index 00000000..c36df603
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/waveedit/editgain.cpp
@@ -0,0 +1,91 @@
+//
+// C++ Implementation: editgain
+//
+// Description:
+//
+//
+// Author: Mathias Lundgren <lunar_shuttle@users.sf.net>, (C) 2005
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#include <QDialog>
+
+#include "editgain.h"
+
+EditGain::EditGain(QWidget* parent, int initGainValue)
+ : QDialog(parent)
+ {
+ setupUi(this);
+ sliderGain->setValue(sliderGain->maximum() - initGainValue);
+ connect(buttonReset, SIGNAL(pressed()), this, SLOT(resetPressed()));
+ connect(buttonApply, SIGNAL(pressed()), this, SLOT(applyPressed()));
+ connect(buttonCancel,SIGNAL(pressed()), this, SLOT(cancelPressed()));
+ connect(sliderGain, SIGNAL(valueChanged(int)), this, SLOT(gainChanged(int)));
+ if (sliderGain->value() != 100)
+ buttonReset->setEnabled(true);
+ }
+
+
+EditGain::~EditGain()
+ {
+ }
+
+
+/*!
+ \fn EditGain::resetPressed
+ */
+void EditGain::resetPressed()
+ {
+ sliderGain->blockSignals(true);
+ sliderGain->setValue(100);
+ sliderGain->blockSignals(false);
+ buttonReset->setEnabled(false);
+ buttonApply->setEnabled(false);
+ }
+
+
+/*!
+ \fn EditGain::applyPressed()
+ */
+void EditGain::applyPressed()
+ {
+ done(QDialog::Accepted);
+ }
+
+
+/*!
+ \fn EditGain::cancelPressed()
+ */
+void EditGain::cancelPressed()
+ {
+ done(QDialog::Rejected);
+ }
+
+
+
+/*!
+ \fn EditGain::gainChanged(int value)
+ */
+void EditGain::gainChanged(int value)
+ {
+ gain = sliderGain->maximum() - value;
+ if (sliderGain->value() != 100) {
+ buttonReset->setEnabled(true);
+ buttonApply->setEnabled(true);
+ }
+ else {
+ buttonReset->setEnabled(false);
+ buttonApply->setEnabled(false);
+ }
+ }
+
+
+/*!
+ \fn EditGain::getGain()
+ */
+int EditGain::getGain()
+ {
+ return gain;
+ }
diff --git a/attic/muse2-oom/muse2/muse/waveedit/editgain.h b/attic/muse2-oom/muse2/muse/waveedit/editgain.h
new file mode 100644
index 00000000..9cbc1d79
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/waveedit/editgain.h
@@ -0,0 +1,39 @@
+//
+// C++ Interface: editgain
+//
+// Description:
+//
+//
+// Author: Mathias Lundgren <lunar_shuttle@users.sf.net>, (C) 2005
+//
+// Copyright: See COPYING file that comes with this distribution
+//
+//
+
+#ifndef EDITGAIN_H
+#define EDITGAIN_H
+
+#include "ui_editgainbase.h"
+
+class QDialog;
+
+class EditGain : public QDialog, public Ui::EditGainBase
+{
+ Q_OBJECT
+public:
+ EditGain(QWidget* parent = 0, int initGainValue=100);
+
+ ~EditGain();
+ int getGain();
+
+private:
+ int gain;
+
+private slots:
+ void resetPressed();
+ void applyPressed();
+ void cancelPressed();
+ void gainChanged(int value);
+};
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/waveedit/editgainbase.ui b/attic/muse2-oom/muse2/muse/waveedit/editgainbase.ui
new file mode 100644
index 00000000..6d7f4716
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/waveedit/editgainbase.ui
@@ -0,0 +1,262 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>EditGainBase</class>
+ <widget class="QDialog" name="EditGainBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>284</width>
+ <height>367</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Modify gain</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QGroupBox" name="groupBox2">
+ <property name="title">
+ <string>Gain</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <spacer name="spacer6">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>90</width>
+ <height>41</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QSlider" name="sliderGain">
+ <property name="minimumSize">
+ <size>
+ <width>40</width>
+ <height>150</height>
+ </size>
+ </property>
+ <property name="maximum">
+ <number>200</number>
+ </property>
+ <property name="value">
+ <number>100</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="tickPosition">
+ <enum>QSlider::TicksBothSides</enum>
+ </property>
+ <property name="tickInterval">
+ <number>10</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QLabel" name="textLabel2">
+ <property name="text">
+ <string>200%</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer4">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>30</width>
+ <height>109</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="textLabel1">
+ <property name="text">
+ <string>100%</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>30</width>
+ <height>108</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLabel" name="textLabel3">
+ <property name="text">
+ <string>0%</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="spacer7">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>51</width>
+ <height>31</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <spacer name="spacer11">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>70</width>
+ <height>31</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonReset">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Reset</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+R</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer12">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>71</width>
+ <height>31</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="buttonGroup2">
+ <property name="title">
+ <string/>
+ </property>
+ <layout class="QVBoxLayout">
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QPushButton" name="buttonApply">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Apply</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+A</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer5">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>61</width>
+ <height>31</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonCancel">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+C</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/waveedit/waveedit.cpp b/attic/muse2-oom/muse2/muse/waveedit/waveedit.cpp
new file mode 100644
index 00000000..a6251503
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/waveedit/waveedit.cpp
@@ -0,0 +1,462 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: waveedit.cpp,v 1.5.2.12 2009/04/06 01:24:54 terminator356 Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "app.h"
+#include "xml.h"
+#include "waveedit.h"
+#include "mtscale.h"
+#include "scrollscale.h"
+#include "waveview.h"
+#include "ttoolbar.h"
+#include "globals.h"
+#include "audio.h"
+#include "utils.h"
+#include "song.h"
+#include "poslabel.h"
+#include "gconfig.h"
+#include "icons.h"
+#include "shortcuts.h"
+
+#include <QMenu>
+#include <QSignalMapper>
+#include <QToolBar>
+#include <QToolButton>
+#include <QLayout>
+#include <QSizeGrip>
+#include <QScrollBar>
+#include <QLabel>
+#include <QSlider>
+#include <QMenuBar>
+#include <QAction>
+#include <QCloseEvent>
+#include <QResizeEvent>
+#include <QKeyEvent>
+
+extern QColor readColor(Xml& xml);
+
+int WaveEdit::_widthInit = 600;
+int WaveEdit::_heightInit = 400;
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void WaveEdit::closeEvent(QCloseEvent* e)
+ {
+ emit deleted((unsigned long)this);
+ e->accept();
+ }
+
+//---------------------------------------------------------
+// WaveEdit
+//---------------------------------------------------------
+
+WaveEdit::WaveEdit(PartList* pl)
+ : MidiEditor(1, 1, pl)
+ {
+ resize(_widthInit, _heightInit);
+
+ QSignalMapper* mapper = new QSignalMapper(this);
+ QAction* act;
+
+ //---------Pulldown Menu----------------------------
+ // We probably don't need an empty menu - Orcan
+ //QMenu* menuFile = menuBar()->addMenu(tr("&File"));
+ QMenu* menuEdit = menuBar()->addMenu(tr("&Edit"));
+
+ menuFunctions = menuBar()->addMenu(tr("Func&tions"));
+
+ menuGain = menuFunctions->addMenu(tr("&Gain"));
+
+ act = menuGain->addAction(tr("200%"));
+ mapper->setMapping(act, CMD_GAIN_200);
+ connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ act = menuGain->addAction(tr("150%"));
+ mapper->setMapping(act, CMD_GAIN_150);
+ connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ act = menuGain->addAction(tr("75%"));
+ mapper->setMapping(act, CMD_GAIN_75);
+ connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ act = menuGain->addAction(tr("50%"));
+ mapper->setMapping(act, CMD_GAIN_50);
+ connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ act = menuGain->addAction(tr("25%"));
+ mapper->setMapping(act, CMD_GAIN_25);
+ connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ act = menuGain->addAction(tr("Other"));
+ mapper->setMapping(act, CMD_GAIN_FREE);
+ connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ connect(mapper, SIGNAL(mapped(int)), this, SLOT(cmd(int)));
+
+ menuFunctions->addSeparator();
+
+ act = menuEdit->addAction(tr("Edit in E&xternal Editor"));
+ mapper->setMapping(act, CMD_EDIT_EXTERNAL);
+ connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ act = menuFunctions->addAction(tr("Mute Selection"));
+ mapper->setMapping(act, CMD_MUTE);
+ connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ act = menuFunctions->addAction(tr("Normalize Selection"));
+ mapper->setMapping(act, CMD_NORMALIZE);
+ connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ act = menuFunctions->addAction(tr("Fade In Selection"));
+ mapper->setMapping(act, CMD_FADE_IN);
+ connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ act = menuFunctions->addAction(tr("Fade Out Selection"));
+ mapper->setMapping(act, CMD_FADE_OUT);
+ connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ act = menuFunctions->addAction(tr("Reverse Selection"));
+ mapper->setMapping(act, CMD_REVERSE);
+ connect(act, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ select = menuEdit->addMenu(QIcon(*selectIcon), tr("Select"));
+
+ selectAllAction = select->addAction(QIcon(*select_allIcon), tr("Select &All"));
+ mapper->setMapping(selectAllAction, CMD_SELECT_ALL);
+ connect(selectAllAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ selectNoneAction = select->addAction(QIcon(*select_allIcon), tr("&Deselect All"));
+ mapper->setMapping(selectNoneAction, CMD_SELECT_NONE);
+ connect(selectNoneAction, SIGNAL(triggered()), mapper, SLOT(map()));
+
+ //---------ToolBar----------------------------------
+ tools = addToolBar(tr("Wave edit tools"));
+ tools->addActions(undoRedo->actions());
+
+ connect(muse, SIGNAL(configChanged()), SLOT(configChanged()));
+
+ //--------------------------------------------------
+ // Transport Bar
+ QToolBar* transport = addToolBar(tr("transport"));
+ transport->addActions(transportAction->actions());
+
+ //--------------------------------------------------
+ // ToolBar: Solo Cursor1 Cursor2
+
+ addToolBarBreak();
+ tb1 = addToolBar(tr("Pianoroll tools"));
+
+ //tb1->setLabel(tr("weTools"));
+ solo = new QToolButton();
+ solo->setText(tr("Solo"));
+ solo->setCheckable(true);
+ tb1->addWidget(solo);
+ connect(solo, SIGNAL(toggled(bool)), SLOT(soloChanged(bool)));
+
+ QLabel* label = new QLabel(tr("Cursor"));
+ tb1->addWidget(label);
+ label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+ label->setIndent(3);
+ pos1 = new PosLabel(0);
+ pos1->setFixedHeight(22);
+ tb1->addWidget(pos1);
+ pos2 = new PosLabel(0);
+ pos2->setFixedHeight(22);
+ pos2->setSmpte(true);
+ tb1->addWidget(pos2);
+
+ //---------------------------------------------------
+ // Rest
+ //---------------------------------------------------
+
+ int yscale = 256;
+ int xscale;
+
+ if (!parts()->empty()) { // Roughly match total size of part
+ Part* firstPart = parts()->begin()->second;
+ xscale = 0 - firstPart->lenFrame()/_widthInit;
+ }
+ else {
+ xscale = -8000;
+ }
+
+ hscroll = new ScrollScale(1, -32768, xscale, 10000, Qt::Horizontal, mainw, 0, true, 10000.0);
+ view = new WaveView(this, mainw, xscale, yscale);
+ wview = view; // HACK!
+
+ QSizeGrip* corner = new QSizeGrip(mainw);
+ ymag = new QSlider(Qt::Vertical, mainw);
+ ymag->setMinimum(1);
+ ymag->setMaximum(256);
+ ymag->setPageStep(256);
+ ymag->setValue(yscale);
+
+ time = new MTScale(&_raster, mainw, xscale, true);
+ ymag->setFixedWidth(16);
+ connect(view, SIGNAL(mouseWheelMoved(int)), this, SLOT(moveVerticalSlider(int)));
+ connect(ymag, SIGNAL(valueChanged(int)), view, SLOT(setYScale(int)));
+ time->setOrigin(0, 0);
+
+ mainGrid->setRowStretch(0, 100);
+ mainGrid->setColumnStretch(0, 100);
+
+ mainGrid->addWidget(time, 0, 0, 1, 2);
+ mainGrid->addWidget(hLine(mainw), 1, 0, 1, 2);
+ mainGrid->addWidget(view, 2, 0);
+ mainGrid->addWidget(ymag, 2, 1);
+ mainGrid->addWidget(hscroll, 3, 0);
+ mainGrid->addWidget(corner, 3, 1, Qt::AlignBottom | Qt::AlignRight);
+
+ view->setFocus(); // Tim.
+
+ connect(hscroll, SIGNAL(scrollChanged(int)), view, SLOT(setXPos(int)));
+ connect(hscroll, SIGNAL(scaleChanged(int)), view, SLOT(setXMag(int)));
+ setWindowTitle(view->getCaption());
+ connect(view, SIGNAL(followEvent(int)), hscroll, SLOT(setOffset(int)));
+
+ connect(hscroll, SIGNAL(scrollChanged(int)), time, SLOT(setXPos(int)));
+ connect(hscroll, SIGNAL(scaleChanged(int)), time, SLOT(setXMag(int)));
+// connect(time, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
+ connect(view, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
+
+ connect(hscroll, SIGNAL(scaleChanged(int)), SLOT(updateHScrollRange()));
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged1(int)));
+
+ updateHScrollRange();
+ configChanged();
+
+ if(!parts()->empty())
+ {
+ WavePart* part = (WavePart*)(parts()->begin()->second);
+ solo->setChecked(part->track()->solo());
+ }
+ }
+
+//---------------------------------------------------------
+// configChanged
+//---------------------------------------------------------
+
+void WaveEdit::configChanged()
+ {
+ view->setBg(config.waveEditBackgroundColor);
+ selectAllAction->setShortcut(shortcuts[SHRT_SELECT_ALL].key);
+ selectNoneAction->setShortcut(shortcuts[SHRT_SELECT_NONE].key);
+ }
+
+//---------------------------------------------------------
+// updateHScrollRange
+//---------------------------------------------------------
+void WaveEdit::updateHScrollRange()
+{
+ int s, e;
+ wview->range(&s, &e);
+ // Show one more measure.
+ e += AL::sigmap.ticksMeasure(e);
+ // Show another quarter measure due to imprecise drawing at canvas end point.
+ e += AL::sigmap.ticksMeasure(e) / 4;
+ // Compensate for the vscroll width.
+ //e += wview->rmapxDev(-vscroll->width());
+ int s1, e1;
+ hscroll->range(&s1, &e1);
+ if(s != s1 || e != e1)
+ hscroll->setRange(s, e);
+}
+
+//---------------------------------------------------------
+// setTime
+//---------------------------------------------------------
+
+void WaveEdit::setTime(unsigned samplepos)
+ {
+// printf("setTime %d %x\n", samplepos, samplepos);
+ unsigned tick = tempomap.frame2tick(samplepos);
+ pos1->setValue(tick);
+ //pos2->setValue(tick);
+ pos2->setValue(samplepos);
+ time->setPos(3, tick, false);
+ }
+
+//---------------------------------------------------------
+// ~WaveEdit
+//---------------------------------------------------------
+
+WaveEdit::~WaveEdit()
+ {
+ // undoRedo->removeFrom(tools); // p4.0.6 Removed
+ }
+
+//---------------------------------------------------------
+// cmd
+//---------------------------------------------------------
+
+void WaveEdit::cmd(int n)
+ {
+ view->cmd(n);
+ }
+
+//---------------------------------------------------------
+// loadConfiguration
+//---------------------------------------------------------
+
+void WaveEdit::readConfiguration(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::TagStart:
+ if (tag == "bgcolor")
+ config.waveEditBackgroundColor = readColor(xml);
+ else if (tag == "width")
+ _widthInit = xml.parseInt();
+ else if (tag == "height")
+ _heightInit = xml.parseInt();
+ else
+ xml.unknown("WaveEdit");
+ break;
+ case Xml::TagEnd:
+ if (tag == "waveedit")
+ return;
+ default:
+ break;
+ case Xml::Error:
+ case Xml::End:
+ return;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// saveConfiguration
+//---------------------------------------------------------
+
+void WaveEdit::writeConfiguration(int level, Xml& xml)
+ {
+ xml.tag(level++, "waveedit");
+ xml.colorTag(level, "bgcolor", config.waveEditBackgroundColor);
+ xml.intTag(level, "width", _widthInit);
+ xml.intTag(level, "height", _heightInit);
+ xml.tag(level, "/waveedit");
+ }
+
+//---------------------------------------------------------
+// writeStatus
+//---------------------------------------------------------
+
+void WaveEdit::writeStatus(int level, Xml& xml) const
+ {
+ writePartList(level, xml);
+ xml.tag(level++, "waveedit");
+ MidiEditor::writeStatus(level, xml);
+ xml.intTag(level, "xpos", hscroll->pos());
+ xml.intTag(level, "xmag", hscroll->mag());
+ xml.intTag(level, "ymag", ymag->value());
+ xml.tag(level, "/waveedit");
+ }
+
+//---------------------------------------------------------
+// readStatus
+//---------------------------------------------------------
+
+void WaveEdit::readStatus(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ if (token == Xml::Error || token == Xml::End)
+ break;
+ QString tag = xml.s1();
+ switch (token) {
+ case Xml::TagStart:
+ if (tag == "midieditor")
+ MidiEditor::readStatus(xml);
+ else if (tag == "xmag")
+ hscroll->setMag(xml.parseInt());
+ else if (tag == "ymag")
+ ymag->setValue(xml.parseInt());
+ else if (tag == "xpos")
+ hscroll->setPos(xml.parseInt());
+ else
+ xml.unknown("WaveEdit");
+ break;
+ case Xml::TagEnd:
+ if (tag == "waveedit")
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// resizeEvent
+//---------------------------------------------------------
+
+void WaveEdit::resizeEvent(QResizeEvent* ev)
+ {
+ QWidget::resizeEvent(ev);
+ _widthInit = ev->size().width();
+ _heightInit = ev->size().height();
+ }
+
+//---------------------------------------------------------
+// songChanged1
+// signal from "song"
+//---------------------------------------------------------
+
+void WaveEdit::songChanged1(int bits)
+ {
+
+ if (bits & SC_SOLO)
+ {
+ WavePart* part = (WavePart*)(parts()->begin()->second);
+ solo->blockSignals(true);
+ solo->setChecked(part->track()->solo());
+ solo->blockSignals(false);
+ }
+
+ songChanged(bits);
+ }
+
+
+//---------------------------------------------------------
+// soloChanged
+// signal from solo button
+//---------------------------------------------------------
+
+void WaveEdit::soloChanged(bool flag)
+ {
+ WavePart* part = (WavePart*)(parts()->begin()->second);
+ audio->msgSetSolo(part->track(), flag);
+ song->update(SC_SOLO);
+ }
+
+//---------------------------------------------------------
+// viewKeyPressEvent
+//---------------------------------------------------------
+
+void WaveEdit::keyPressEvent(QKeyEvent* event)
+ {
+ int key = event->key();
+ if (key == Qt::Key_Escape) {
+ close();
+ return;
+ }
+ else {
+ event->ignore();
+ }
+ }
+
+//---------------------------------------------------------
+// moveVerticalSlider
+//---------------------------------------------------------
+
+void WaveEdit::moveVerticalSlider(int val)
+ {
+ ymag->setValue(ymag->value() + val);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/waveedit/waveedit.h b/attic/muse2-oom/muse2/muse/waveedit/waveedit.h
new file mode 100644
index 00000000..79102410
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/waveedit/waveedit.h
@@ -0,0 +1,83 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: waveedit.h,v 1.3.2.8 2008/01/26 07:23:21 terminator356 Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __WAVE_EDIT_H__
+#define __WAVE_EDIT_H__
+
+#include <QMenu>
+
+#include <QWidget>
+#include <QResizeEvent>
+#include <QKeyEvent>
+#include <QCloseEvent>
+#include "midieditor.h"
+
+class QToolButton;
+class PartList;
+class WaveView;
+class ScrollScale;
+class QSlider;
+class PosLabel;
+class QResizeEvent;
+class SNode;
+class QAction;
+
+//---------------------------------------------------------
+// WaveEdit
+//---------------------------------------------------------
+
+class WaveEdit : public MidiEditor {
+ WaveView* view;
+ QSlider* ymag;
+ QToolBar* tools;
+ QToolBar* tb1;
+ QToolButton* solo;
+ PosLabel* pos1;
+ PosLabel* pos2;
+ QAction* selectAllAction;
+ QAction* selectNoneAction;
+
+ static int _widthInit, _heightInit;
+
+ Q_OBJECT
+ virtual void closeEvent(QCloseEvent*);
+ virtual void resizeEvent(QResizeEvent* ev);
+ virtual void keyPressEvent(QKeyEvent*);
+
+ QMenu* menuFunctions, *select, *menuGain;
+
+ private slots:
+ void cmd(int);
+ void setTime(unsigned t);
+ void songChanged1(int);
+ void soloChanged(bool flag);
+ void moveVerticalSlider(int val);
+
+ public slots:
+ void configChanged();
+
+ virtual void updateHScrollRange();
+
+ signals:
+ void deleted(unsigned long);
+
+ public:
+ WaveEdit(PartList*);
+ ~WaveEdit();
+ virtual void readStatus(Xml&);
+ virtual void writeStatus(int, Xml&) const;
+ static void readConfiguration(Xml&);
+ static void writeConfiguration(int, Xml&);
+
+ enum { CMD_MUTE=0, CMD_NORMALIZE, CMD_FADE_IN, CMD_FADE_OUT, CMD_REVERSE,
+ CMD_GAIN_FREE, CMD_GAIN_200, CMD_GAIN_150, CMD_GAIN_75, CMD_GAIN_50, CMD_GAIN_25,
+ CMD_EDIT_EXTERNAL,
+ CMD_SELECT_ALL, CMD_SELECT_NONE };
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/waveedit/waveview.cpp b/attic/muse2-oom/muse2/muse/waveedit/waveview.cpp
new file mode 100644
index 00000000..668d8bea
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/waveedit/waveview.cpp
@@ -0,0 +1,946 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: waveview.cpp,v 1.10.2.16 2009/11/14 03:37:48 terminator356 Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <values.h>
+#include <sys/wait.h>
+
+#include <QPainter>
+#include <QDir>
+#include <QFileInfo>
+#include <QMessageBox>
+#include <QMouseEvent>
+
+#include "editgain.h"
+#include "globals.h"
+#include "wave.h"
+#include "waveview.h"
+#include "song.h"
+#include "event.h"
+#include "waveedit.h"
+#include "audio.h"
+#include "gconfig.h"
+
+bool modifyWarnedYet = false;
+//---------------------------------------------------------
+// WaveView
+//---------------------------------------------------------
+
+WaveView::WaveView(MidiEditor* pr, QWidget* parent, int xscale, int yscale)
+ : View(parent, xscale, 1)
+ {
+ editor = pr;
+ setVirt(true);
+ pos[0] = tempomap.tick2frame(song->cpos());
+ pos[1] = tempomap.tick2frame(song->lpos());
+ pos[2] = tempomap.tick2frame(song->rpos());
+ yScale = yscale;
+ mode = NORMAL;
+ selectionStart = 0;
+ selectionStop = 0;
+ lastGainvalue = 100;
+
+ setFocusPolicy(Qt::StrongFocus); // Tim.
+
+ setMouseTracking(true);
+ setBg(QColor(192, 208, 255));
+
+ if (editor->parts()->empty()) {
+ curPart = 0;
+ curPartId = -1;
+ }
+ else {
+ curPart = (WavePart*)(editor->parts()->begin()->second);
+ curPartId = curPart->sn();
+ }
+
+
+ connect(song, SIGNAL(posChanged(int,unsigned,bool)), SLOT(setPos(int,unsigned,bool)));
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+ songChanged(SC_SELECTION);
+ }
+
+//---------------------------------------------------------
+// setYScale
+//---------------------------------------------------------
+
+void WaveView::setYScale(int val)
+ {
+ yScale = val;
+ redraw();
+ }
+
+//---------------------------------------------------------
+// draw
+//---------------------------------------------------------
+
+void WaveView::pdraw(QPainter& p, const QRect& rr)
+ {
+ int x1 = rr.x();
+ int x2 = rr.right() + 1;
+ if (x1 < 0)
+ x1 = 0;
+ if (x2 > width())
+ x2 = width();
+ int hh = height();
+ int h = hh/2;
+ int y = rr.y() + h;
+
+ // Added by T356.
+ int xScale = xmag;
+ if (xScale < 0)
+ xScale = -xScale;
+
+ for (iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip) {
+ WavePart* wp = (WavePart*)(ip->second);
+ int channels = wp->track()->channels();
+ int px = wp->frame();
+
+ EventList* el = wp->events();
+ for (iEvent e = el->begin(); e != el->end(); ++e) {
+ Event event = e->second;
+ if (event.empty())
+ continue;
+ SndFileR f = event.sndFile();
+ if (f.isNull())
+ continue;
+
+ unsigned peoffset = px + event.frame() - event.spos();
+ int sx, ex;
+
+ sx = event.frame() + px + xScale/2;
+ ex = sx + event.lenFrame();
+ sx = sx / xScale - xpos;
+ ex = ex / xScale - xpos;
+
+ if (sx < x1)
+ sx = x1;
+ if (ex > x2)
+ ex = x2;
+
+ int pos = (xpos + sx) * xScale + event.spos() - event.frame() - px;
+
+ //printf("pos=%d xpos=%d sx=%d ex=%d xScale=%d event.spos=%d event.frame=%d px=%d\n",
+ // pos, xpos, sx, ex, xScale, event.spos(), event.frame(), px);
+
+ h = hh / (channels * 2);
+ int cc = hh % (channels * 2) ? 0 : 1;
+
+ for (int i = sx; i < ex; i++) {
+ y = rr.y() + h;
+ SampleV sa[f.channels()];
+ f.read(sa, xScale, pos);
+ pos += xScale;
+ if (pos < event.spos())
+ continue;
+
+ int selectionStartPos = selectionStart - peoffset; // Offset transformed to event coords
+ int selectionStopPos = selectionStop - peoffset;
+
+ for (int k = 0; k < channels; ++k) {
+ int kk = k % f.channels();
+ int peak = (sa[kk].peak * (h - 1)) / yScale;
+ int rms = (sa[kk].rms * (h - 1)) / yScale;
+ if (peak > h)
+ peak = h;
+ if (rms > h)
+ rms = h;
+ QColor peak_color = QColor(Qt::darkGray);
+ QColor rms_color = QColor(Qt::black);
+
+ // Changed by T356. Reduces (but not eliminates) drawing artifacts.
+ //if (pos > selectionStartPos && pos < selectionStopPos) {
+ if (pos > selectionStartPos && pos <= selectionStopPos) {
+
+ peak_color = QColor(Qt::lightGray);
+ rms_color = QColor(Qt::white);
+ // Draw inverted
+ p.setPen(QColor(Qt::black));
+ p.drawLine(i, y - h + cc, i, y + h - cc );
+ }
+ p.setPen(peak_color);
+ p.drawLine(i, y - peak - cc, i, y + peak);
+ p.setPen(rms_color);
+ p.drawLine(i, y - rms - cc, i, y + rms);
+ y += 2 * h;
+ }
+ }
+ }
+ }
+ View::pdraw(p, rr);
+ }
+
+//---------------------------------------------------------
+// draw
+//---------------------------------------------------------
+
+void WaveView::draw(QPainter& p, const QRect& r)
+ {
+ unsigned x = r.x() < 0 ? 0 : r.x();
+ unsigned y = r.y() < 0 ? 0 : r.y();
+ int w = r.width();
+ int h = r.height();
+
+ unsigned x2 = x + w;
+ unsigned y2 = y + h;
+
+ //
+ // draw marker & centerline
+ //
+ p.setPen(Qt::red);
+ if (pos[0] >= x && pos[0] < x2) {
+ p.drawLine(pos[0], y, pos[0], y2);
+ }
+ p.setPen(Qt::blue);
+ if (pos[1] >= x && pos[1] < x2) {
+ p.drawLine(pos[1], y, pos[1], y2);
+ }
+ if (pos[2] >= x && pos[2] < x2)
+ p.drawLine(pos[2], y, pos[2], y2);
+
+ // Changed by T356. Support multiple (or none) selected parts.
+ //int n = curPart->track()->channels();
+ int n = 1;
+ if(curPart)
+ n = curPart->track()->channels();
+
+ int hn = h / n;
+ int hh = hn / 2;
+ for (int i = 0; i < n; ++i) {
+ int h2 = hn * i;
+ int center = hh + h2;
+ p.setPen(QColor(i & i ? Qt::red : Qt::blue));
+ p.drawLine(x, center, x2, center);
+ p.setPen(QColor(Qt::black));
+ p.drawLine(x, h2, x2, h2);
+ }
+ }
+
+//---------------------------------------------------------
+// getCaption
+//---------------------------------------------------------
+
+QString WaveView::getCaption() const
+ {
+
+ // Changed by T356. Support multiple (or none) selected parts.
+ //return QString("Part ") + curPart->name();
+ if(curPart)
+ return QString("Part ") + curPart->name();
+ else
+ return QString("Part ");
+
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void WaveView::songChanged(int flags)
+ {
+ // Is it simply a midi controller value adjustment? Forget it.
+ if(flags == SC_MIDI_CONTROLLER)
+ return;
+
+ if (flags & SC_SELECTION) {
+ startSample = MAXINT;
+ endSample = 0;
+ curPart = 0;
+ for (iPart p = editor->parts()->begin(); p != editor->parts()->end(); ++p) {
+ WavePart* part = (WavePart*)(p->second);
+ if (part->sn() == curPartId)
+ curPart = part;
+ int ssample = part->frame();
+ int esample = ssample + part->lenFrame();
+ if (ssample < startSample) {
+ startSample = ssample;
+ //printf("startSample = %d\n", startSample);
+ }
+ if (esample > endSample) {
+ endSample = esample;
+ //printf("endSample = %d\n", endSample);
+ }
+ }
+ }
+ if (flags & SC_CLIP_MODIFIED) {
+ redraw(); // Boring, but the only thing possible to do
+ }
+ if (flags & SC_TEMPO) {
+ setPos(0, song->cpos(), false);
+ setPos(1, song->lpos(), false);
+ setPos(2, song->rpos(), false);
+ }
+ redraw();
+ }
+
+//---------------------------------------------------------
+// setPos
+// set one of three markers
+// idx - 0-cpos 1-lpos 2-rpos
+// flag - emit followEvent()
+//---------------------------------------------------------
+
+void WaveView::setPos(int idx, unsigned val, bool adjustScrollbar)
+ {
+ val = tempomap.tick2frame(val);
+ if (pos[idx] == val)
+ return;
+ int opos = mapx(pos[idx]);
+ int npos = mapx(val);
+
+ if (adjustScrollbar && idx == 0) {
+ switch (song->follow()) {
+ case Song::NO:
+ break;
+ case Song::JUMP:
+ if (npos >= width()) {
+ int ppos = val - xorg - rmapxDev(width()/4);
+ if (ppos < 0)
+ ppos = 0;
+ emit followEvent(ppos);
+ opos = mapx(pos[idx]);
+ npos = mapx(val);
+ }
+ else if (npos < 0) {
+ int ppos = val - xorg - rmapxDev(width()*3/4);
+ if (ppos < 0)
+ ppos = 0;
+ emit followEvent(ppos);
+ opos = mapx(pos[idx]);
+ npos = mapx(val);
+ }
+ break;
+ case Song::CONTINUOUS:
+ if (npos > (width()*5)/8) {
+ int ppos = pos[idx] - xorg - rmapxDev(width()*5/8);
+ if (ppos < 0)
+ ppos = 0;
+ emit followEvent(ppos);
+ opos = mapx(pos[idx]);
+ npos = mapx(val);
+ }
+ else if (npos < (width()*3)/8) {
+ int ppos = pos[idx] - xorg - rmapxDev(width()*3/8);
+ if (ppos < 0)
+ ppos = 0;
+ emit followEvent(ppos);
+ opos = mapx(pos[idx]);
+ npos = mapx(val);
+ }
+ break;
+ }
+ }
+
+ int x;
+ int w = 1;
+ if (opos > npos) {
+ w += opos - npos;
+ x = npos;
+ }
+ else {
+ w += npos - opos;
+ x = opos;
+ }
+ pos[idx] = val;
+ redraw(QRect(x, 0, w, height()));
+ }
+
+//---------------------------------------------------------
+// viewMousePressEvent
+//---------------------------------------------------------
+
+void WaveView::viewMousePressEvent(QMouseEvent* event)
+ {
+ button = event->button();
+ unsigned x = event->x();
+
+ switch (button) {
+ case Qt::LeftButton:
+ if (mode == NORMAL) {
+ // redraw and reset:
+ if (selectionStart != selectionStop) {
+ selectionStart = selectionStop = 0;
+ redraw();
+ }
+ mode = DRAG;
+ dragstartx = x;
+ selectionStart = selectionStop = x;
+ }
+ break;
+
+ case Qt::MidButton:
+ case Qt::RightButton:
+ default:
+ break;
+ }
+ viewMouseMoveEvent(event);
+ }
+
+
+//---------------------------------------------------------
+// wheelEvent
+//---------------------------------------------------------
+void WaveView::wheelEvent(QWheelEvent* event)
+ {
+ emit mouseWheelMoved(event->delta() / 10);
+ }
+
+//---------------------------------------------------------
+// viewMouseReleaseEvent
+//---------------------------------------------------------
+void WaveView::viewMouseReleaseEvent(QMouseEvent* /*event*/)
+ {
+ button = Qt::NoButton;
+
+ if (mode == DRAG) {
+ mode = NORMAL;
+ //printf("selectionStart=%d selectionStop=%d\n", selectionStart, selectionStop);
+ }
+ }
+
+//---------------------------------------------------------
+// viewMouseMoveEvent
+//---------------------------------------------------------
+
+void WaveView::viewMouseMoveEvent(QMouseEvent* event)
+ {
+ unsigned x = event->x();
+ emit timeChanged(x);
+
+ int i;
+ switch (button) {
+ case Qt::LeftButton:
+ i = 0;
+ if (mode == DRAG) {
+ if (x < dragstartx) {
+ selectionStart = x;
+ selectionStop = dragstartx;
+ }
+ else {
+ selectionStart = dragstartx;
+ selectionStop = x;
+ }
+ }
+ break;
+ case Qt::MidButton:
+ i = 1;
+ break;
+ case Qt::RightButton:
+ i = 2;
+ break;
+ default:
+ return;
+ }
+ Pos p(tempomap.frame2tick(x), true);
+ song->setPos(i, p);
+ }
+
+//---------------------------------------------------------
+// range
+// returns range in samples
+//---------------------------------------------------------
+
+void WaveView::range(int* s, int *e)
+ {
+
+ PartList* lst = editor->parts();
+ if(lst->empty())
+ {
+ *s = 0;
+ *e = tempomap.tick2frame(song->len());
+ return;
+ }
+ int ps = song->len(), pe = 0;
+ int tps, tpe;
+ for(iPart ip = lst->begin(); ip != lst->end(); ++ip)
+ {
+ tps = ip->second->tick();
+ if(tps < ps)
+ ps = tps;
+ tpe = tps + ip->second->lenTick();
+ if(tpe > pe)
+ pe = tpe;
+ }
+ *s = tempomap.tick2frame(ps);
+ *e = tempomap.tick2frame(pe);
+ }
+
+//---------------------------------------------------------
+// cmd
+//---------------------------------------------------------
+void WaveView::cmd(int n)
+ {
+ int modifyoperation = -1;
+ double paramA = 0.0;
+
+ switch(n) {
+ case WaveEdit::CMD_SELECT_ALL:
+ if (!editor->parts()->empty()) {
+ iPart iBeg = editor->parts()->begin();
+ iPart iEnd = editor->parts()->end();
+ iEnd--;
+ WavePart* beg = (WavePart*) iBeg->second;
+ WavePart* end = (WavePart*) iEnd->second;
+ selectionStart = beg->frame();
+ selectionStop = end->frame() + end->lenFrame();
+ redraw();
+ }
+ break;
+
+ case WaveEdit::CMD_EDIT_EXTERNAL:
+ modifyoperation = EDIT_EXTERNAL;
+ break;
+
+ case WaveEdit::CMD_SELECT_NONE:
+ selectionStart = selectionStop = 0;
+ redraw();
+ break;
+
+ case WaveEdit::CMD_MUTE:
+ modifyoperation = MUTE;
+ break;
+
+ case WaveEdit::CMD_NORMALIZE:
+ modifyoperation = NORMALIZE;
+ break;
+
+ case WaveEdit::CMD_FADE_IN:
+ modifyoperation = FADE_IN;
+ break;
+
+ case WaveEdit::CMD_FADE_OUT:
+ modifyoperation = FADE_OUT;
+ break;
+
+ case WaveEdit::CMD_REVERSE:
+ modifyoperation = REVERSE;
+ break;
+
+ case WaveEdit::CMD_GAIN_FREE: {
+ EditGain* editGain = new EditGain(this, lastGainvalue);
+ if (editGain->exec() == QDialog::Accepted) {
+ lastGainvalue = editGain->getGain();
+ modifyoperation = GAIN;
+ paramA = (double)lastGainvalue / 100.0;
+ }
+ delete editGain;
+ }
+ break;
+
+ case WaveEdit::CMD_GAIN_200:
+ modifyoperation = GAIN;
+ paramA = 2.0;
+ break;
+
+ case WaveEdit::CMD_GAIN_150:
+ modifyoperation = GAIN;
+ paramA = 1.5;
+ break;
+
+ case WaveEdit::CMD_GAIN_75:
+ modifyoperation = GAIN;
+ paramA = 0.75;
+ break;
+
+ case WaveEdit::CMD_GAIN_50:
+ modifyoperation = GAIN;
+ paramA = 0.5;
+ break;
+
+ case WaveEdit::CMD_GAIN_25:
+ modifyoperation = GAIN;
+ paramA = 0.25;
+ break;
+
+ default:
+ break;
+ }
+
+ if (modifyoperation != -1) {
+ if (selectionStart == selectionStop) {
+ printf("No selection. Ignoring\n"); //@!TODO: Disable menu options when no selection
+ QMessageBox::information(this,
+ QString("MusE"),
+ QWidget::tr("No selection. Ignoring"));
+
+ return;
+ }
+
+ //if(!modifyWarnedYet)
+ //{
+ // modifyWarnedYet = true;
+ // if(QMessageBox::warning(this, QString("Muse"),
+ // tr("Warning! Muse currently operates directly on the sound file.\n"
+ // "Undo is supported, but NOT after exit, WITH OR WITHOUT A SAVE!\n"
+ // "If you are stuck, try deleting the associated .wca file and reloading."), tr("&Ok"), tr("&Cancel"),
+ // QString::null, 0, 1 ) != 0)
+ // return;
+ //}
+ modifySelection(modifyoperation, selectionStart, selectionStop, paramA);
+ }
+ }
+
+
+//---------------------------------------------------------
+// getSelection
+//---------------------------------------------------------
+WaveSelectionList WaveView::getSelection(unsigned startpos, unsigned stoppos)
+ {
+ WaveSelectionList selection;
+
+ for (iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip) {
+ WavePart* wp = (WavePart*)(ip->second);
+ unsigned part_offset = wp->frame();
+
+ EventList* el = wp->events();
+ //printf("eventlist length=%d\n",el->size());
+
+ for (iEvent e = el->begin(); e != el->end(); ++e) {
+ Event event = e->second;
+ if (event.empty())
+ continue;
+ SndFileR file = event.sndFile();
+ if (file.isNull())
+ continue;
+
+ unsigned event_offset = event.frame() + part_offset;
+ unsigned event_startpos = event.spos();
+ unsigned event_length = event.lenFrame() + event.spos();
+ unsigned event_end = event_offset + event_length;
+ //printf("startpos=%d stoppos=%d part_offset=%d event_offset=%d event_startpos=%d event_length=%d event_end=%d\n", startpos, stoppos, part_offset, event_offset, event_startpos, event_length, event_end);
+
+ if (!(event_end <= startpos || event_offset > stoppos)) {
+ int tmp_sx = startpos - event_offset + event_startpos;
+ int tmp_ex = stoppos - event_offset + event_startpos;
+ unsigned sx;
+ unsigned ex;
+
+ tmp_sx < (int)event_startpos ? sx = event_startpos : sx = tmp_sx;
+ tmp_ex > (int)event_length ? ex = event_length : ex = tmp_ex;
+
+ //printf("Event data affected: %d->%d filename:%s\n", sx, ex, file.name().toLatin1().constData());
+ WaveEventSelection s;
+ s.file = file;
+ s.startframe = sx;
+ s.endframe = ex+1;
+ //printf("sx=%d ex=%d\n",sx,ex);
+ selection.push_back(s);
+ }
+ }
+ }
+
+ return selection;
+ }
+
+//---------------------------------------------------------
+// modifySelection
+//---------------------------------------------------------
+void WaveView::modifySelection(int operation, unsigned startpos, unsigned stoppos, double paramA)
+ {
+ song->startUndo();
+
+ WaveSelectionList selection = getSelection(startpos, stoppos);
+ for (iWaveSelection i = selection.begin(); i != selection.end(); i++) {
+ WaveEventSelection w = *i;
+ SndFileR& file = w.file;
+ unsigned sx = w.startframe;
+ unsigned ex = w.endframe;
+ unsigned file_channels = file.channels();
+
+ QString tmpWavFile = QString::null;
+ if (!getUniqueTmpfileName(tmpWavFile)) {
+ break;
+ }
+
+ audio->msgIdle(true); // Not good with playback during operations
+ SndFile tmpFile(tmpWavFile);
+ tmpFile.setFormat(file.format(), file_channels, file.samplerate());
+ if (tmpFile.openWrite()) {
+ audio->msgIdle(false);
+ printf("Could not open temporary file...\n");
+ break;
+ }
+
+ //
+ // Write out data that will be changed to temp file
+ //
+ unsigned tmpdatalen = ex - sx;
+ off_t tmpdataoffset = sx;
+ float* tmpdata[file_channels];
+
+ for (unsigned i=0; i<file_channels; i++) {
+ tmpdata[i] = new float[tmpdatalen];
+ }
+ file.seek(tmpdataoffset, 0);
+ file.readWithHeap(file_channels, tmpdata, tmpdatalen);
+ file.close();
+ tmpFile.write(file_channels, tmpdata, tmpdatalen);
+ tmpFile.close();
+
+ switch(operation)
+ {
+ case MUTE:
+ muteSelection(file_channels, tmpdata, tmpdatalen);
+ break;
+
+ case NORMALIZE:
+ normalizeSelection(file_channels, tmpdata, tmpdatalen);
+ break;
+
+ case FADE_IN:
+ fadeInSelection(file_channels, tmpdata, tmpdatalen);
+ break;
+
+ case FADE_OUT:
+ fadeOutSelection(file_channels, tmpdata, tmpdatalen);
+ break;
+
+ case REVERSE:
+ reverseSelection(file_channels, tmpdata, tmpdatalen);
+ break;
+
+ case GAIN:
+ applyGain(file_channels, tmpdata, tmpdatalen, paramA);
+ break;
+
+ case EDIT_EXTERNAL:
+ editExternal(file.format(), file.samplerate(), file_channels, tmpdata, tmpdatalen);
+ break;
+
+ default:
+ printf("Error: Default state reached in modifySelection\n");
+ break;
+
+ }
+
+ file.openWrite();
+ file.seek(tmpdataoffset, 0);
+ file.write(file_channels, tmpdata, tmpdatalen);
+ file.update();
+ file.close();
+ file.openRead();
+
+ for (unsigned i=0; i<file_channels; i++) {
+ delete[] tmpdata[i];
+ }
+
+ // Undo handling
+ song->cmdChangeWave(file.dirPath() + "/" + file.name(), tmpWavFile, sx, ex);
+ audio->msgIdle(false); // Not good with playback during operations
+ }
+ song->endUndo(SC_CLIP_MODIFIED);
+ redraw();
+ }
+
+//---------------------------------------------------------
+// muteSelection
+//---------------------------------------------------------
+void WaveView::muteSelection(unsigned channels, float** data, unsigned length)
+ {
+ // Set everything to 0!
+ for (unsigned i=0; i<channels; i++) {
+ for (unsigned j=0; j<length; j++) {
+ data[i][j] = 0;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// normalizeSelection
+//---------------------------------------------------------
+void WaveView::normalizeSelection(unsigned channels, float** data, unsigned length)
+ {
+ float loudest = 0.0;
+
+ for (unsigned i=0; i<channels; i++) {
+ for (unsigned j=0; j<length; j++) {
+ if (data[i][j] > loudest)
+ loudest = data[i][j];
+ }
+ }
+
+ double scale = 0.99 / (double)loudest;
+
+ for (unsigned i=0; i<channels; i++) {
+ for (unsigned j=0; j<length; j++) {
+ data[i][j] = (float) ((double)data[i][j] * scale);
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// fadeInSelection
+//---------------------------------------------------------
+void WaveView::fadeInSelection(unsigned channels, float** data, unsigned length)
+ {
+ for (unsigned i=0; i<channels; i++) {
+ for (unsigned j=0; j<length; j++) {
+ double scale = (double) j / (double)length ;
+ data[i][j] = (float) ((double)data[i][j] * scale);
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// fadeOutSelection
+//---------------------------------------------------------
+void WaveView::fadeOutSelection(unsigned channels, float** data, unsigned length)
+ {
+ for (unsigned i=0; i<channels; i++) {
+ for (unsigned j=0; j<length; j++) {
+ double scale = (double) (length - j) / (double)length ;
+ data[i][j] = (float) ((double)data[i][j] * scale);
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// reverseSelection
+//---------------------------------------------------------
+void WaveView::reverseSelection(unsigned channels, float** data, unsigned length)
+ {
+ if(length <= 1)
+ return;
+ for (unsigned i=0; i<channels; i++) {
+ for (unsigned j=0; j<length/2; j++) {
+ float tmpl = data[i][j];
+ float tmpr = data[i][length - j - 1];
+ data[i][j] = tmpr;
+ data[i][length - j - 1] = tmpl;
+ }
+ }
+ }
+//---------------------------------------------------------
+// applyGain
+//---------------------------------------------------------
+void WaveView::applyGain(unsigned channels, float** data, unsigned length, double gain)
+ {
+ for (unsigned i=0; i<channels; i++) {
+ for (unsigned j=0; j<length; j++) {
+ data[i][j] = (float) ((double)data[i][j] * gain);
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// editExternal
+//---------------------------------------------------------
+void WaveView::editExternal(unsigned file_format, unsigned file_samplerate, unsigned file_channels, float** tmpdata, unsigned tmpdatalen)
+ {
+ // Create yet another tmp-file
+ QString exttmpFileName;
+ if (!getUniqueTmpfileName(exttmpFileName)) {
+ printf("Could not create temp file - aborting...\n");
+ return;
+ }
+
+ SndFile exttmpFile(exttmpFileName);
+ exttmpFile.setFormat(file_format, file_channels, file_samplerate);
+ if (exttmpFile.openWrite()) {
+ printf("Could not open temporary file...\n");
+ return;
+ }
+ // Write out change-data to this file:
+ exttmpFile.write(file_channels, tmpdata, tmpdatalen);
+ exttmpFile.close();
+
+ // Forkaborkabork
+ int pid = fork();
+ if (pid == 0) {
+ if (execlp(config.externalWavEditor.toLatin1().constData(), config.externalWavEditor.toLatin1().constData(), exttmpFileName.toLatin1().constData(), NULL) == -1) {
+ perror("Failed to launch external editor");
+ // Get out of here
+
+
+ // cannot report error through gui, we are in another fork!
+ //@!TODO: Handle unsuccessful attempts
+ exit(99);
+ }
+ exit(0);
+ }
+ else if (pid == -1) {
+ perror("fork failed");
+ }
+ else {
+ int status;
+ waitpid(pid, &status, 0);
+ //printf ("status=%d\n",status);
+ if( WEXITSTATUS(status) != 0 ){
+ QMessageBox::warning(this, tr("MusE - external editor failed"),
+ tr("MusE was unable to launch the external editor\ncheck if the editor setting in:\n"
+ "Global Settings->Audio:External Waveditor\nis set to a valid editor."));
+ }
+
+ if (exttmpFile.openRead()) {
+ printf("Could not reopen temporary file!\n");
+ }
+ else {
+ // Re-read file again
+ exttmpFile.seek(0, 0);
+ size_t sz = exttmpFile.readWithHeap(file_channels, tmpdata, tmpdatalen);
+ if (sz != tmpdatalen) {
+ // File must have been shrunken - not good. Alert user.
+ QMessageBox::critical(this, tr("MusE - file size changed"),
+ tr("When editing in external editor - you should not change the filesize\nsince it must fit the selected region.\n\nMissing data is muted"));
+ for (unsigned i=0; i<file_channels; i++) {
+ for (unsigned j=sz; j<tmpdatalen; j++) {
+ tmpdata[i][j] = 0;
+ }
+ }
+ }
+ }
+ QDir dir = exttmpFile.dirPath();
+ dir.remove(exttmpFileName);
+ dir.remove(exttmpFile.basename() + ".wca");
+ }
+ }
+
+//---------------------------------------------------------
+// getUniqueTmpfileName
+//---------------------------------------------------------
+bool WaveView::getUniqueTmpfileName(QString& newFilename)
+ {
+ // Check if tmp-directory exists under project path
+ QString tmpWavDir = museProject + "/tmp_musewav"; //!@TODO: Don't hardcode like this
+ QFileInfo tmpdirfi(tmpWavDir);
+ if (!tmpdirfi.isDir()) {
+ // Try to create a tmpdir
+ QDir projdir(museProject);
+ if (!projdir.mkdir("tmp_musewav")) {
+ printf("Could not create undo dir!\n");
+ return false;
+ }
+ }
+
+
+ tmpdirfi.setFile(tmpWavDir);
+
+ if (!tmpdirfi.isWritable()) {
+ printf("Temp directory is not writable - aborting\n");
+ return false;
+ }
+
+ QDir tmpdir = tmpdirfi.dir();
+
+ // Find a new filename
+ for (int i=0; i<10000; i++) {
+ QString filename = "muse_tmp";
+ filename.append(QString::number(i));
+ filename.append(".wav");
+
+ if (!tmpdir.exists(tmpWavDir +"/" + filename)) {
+ newFilename = tmpWavDir + "/" + filename;
+ return true;
+ }
+
+ }
+
+ printf("Could not find a suitable tmpfilename (more than 10000 tmpfiles in tmpdir - clean up!\n");
+ return false;
+ }
+
+
diff --git a/attic/muse2-oom/muse2/muse/waveedit/waveview.h b/attic/muse2-oom/muse2/muse/waveedit/waveview.h
new file mode 100644
index 00000000..d1f247b3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/waveedit/waveview.h
@@ -0,0 +1,99 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: waveview.h,v 1.3.2.6 2009/02/02 21:38:01 terminator356 Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef WAVE_VIEW_H
+#define WAVE_VIEW_H
+
+#include "view.h"
+#include <QWidget>
+#include <QMouseEvent>
+#include "wave.h"
+
+class PartList;
+class QPainter;
+class QRect;
+class WavePart;
+class MidiEditor;
+class SndFileR;
+
+struct WaveEventSelection {
+ SndFileR file;
+ unsigned startframe;
+ unsigned endframe;
+ };
+
+typedef std::list<WaveEventSelection> WaveSelectionList;
+typedef std::list<WaveEventSelection>::iterator iWaveSelection;
+
+//---------------------------------------------------------
+// WaveView
+//---------------------------------------------------------
+
+class WaveView : public View {
+ MidiEditor* editor;
+ unsigned pos[3];
+ int yScale;
+ int button;
+ int startSample;
+ int endSample;
+
+ WavePart* curPart;
+ int curPartId;
+
+ enum { NORMAL, DRAG } mode;
+ enum { MUTE = 0, NORMALIZE, FADE_IN, FADE_OUT, REVERSE, GAIN, EDIT_EXTERNAL }; //!< Modify operations
+
+ unsigned selectionStart, selectionStop, dragstartx;
+
+ Q_OBJECT
+ virtual void pdraw(QPainter&, const QRect&);
+ virtual void draw(QPainter&, const QRect&);
+ virtual void viewMousePressEvent(QMouseEvent*);
+ virtual void viewMouseMoveEvent(QMouseEvent*);
+ virtual void viewMouseReleaseEvent(QMouseEvent*);
+ virtual void wheelEvent(QWheelEvent*);
+
+ bool getUniqueTmpfileName(QString& newFilename); //!< Generates unique filename for temporary SndFile
+ WaveSelectionList getSelection(unsigned startpos, unsigned stoppos);
+
+ int lastGainvalue; //!< Stores the last used gainvalue when specifiying gain value in the editgain dialog
+ void modifySelection(int operation, unsigned startpos, unsigned stoppos, double paramA); //!< Modifies selection
+
+ void muteSelection(unsigned channels, float** data, unsigned length); //!< Mutes selection
+ void normalizeSelection(unsigned channels, float** data, unsigned length); //!< Normalizes selection
+ void fadeInSelection(unsigned channels, float** data, unsigned length); //!< Linear fade in of selection
+ void fadeOutSelection(unsigned channels, float** data, unsigned length); //!< Linear fade out of selection
+ void reverseSelection(unsigned channels, float** data, unsigned length); //!< Reverse selection
+ void applyGain(unsigned channels, float** data, unsigned length, double gain); //!< Apply gain to selection
+
+ void editExternal(unsigned file_format, unsigned file_samplerate, unsigned channels, float** data, unsigned length);
+
+ //void applyLadspa(unsigned channels, float** data, unsigned length); //!< Apply LADSPA plugin on selection
+
+
+ private slots:
+ void setPos(int idx, unsigned val, bool adjustScrollbar);
+
+ public slots:
+ void setYScale(int);
+ void songChanged(int type);
+
+ signals:
+ void followEvent(int);
+ void timeChanged(unsigned);
+ void mouseWheelMoved(int);
+
+ public:
+ WaveView(MidiEditor*, QWidget* parent, int xscale, int yscale);
+ QString getCaption() const;
+ void range(int*, int*);
+ void cmd(int n);
+ WavePart* part() { return curPart; }
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/waveevent.cpp b/attic/muse2-oom/muse2/muse/waveevent.cpp
new file mode 100644
index 00000000..867ce5c8
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/waveevent.cpp
@@ -0,0 +1,453 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: waveevent.cpp,v 1.9.2.6 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 2000-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "audioconvert.h"
+#include "globals.h"
+#include "event.h"
+#include "waveevent.h"
+#include "xml.h"
+#include "wave.h"
+#include <iostream>
+#include <math.h>
+
+// Added by Tim. p3.3.18
+//#define USE_SAMPLERATE
+//
+//#define WAVEEVENT_DEBUG
+//#define WAVEEVENT_DEBUG_PRC
+
+//---------------------------------------------------------
+// WaveEvent
+//---------------------------------------------------------
+
+WaveEventBase::WaveEventBase(EventType t)
+ : EventBase(t)
+ {
+ deleted = false;
+ }
+
+//---------------------------------------------------------
+// WaveEventBase::clone
+//---------------------------------------------------------
+
+EventBase* WaveEventBase::clone()
+{
+ return new WaveEventBase(*this);
+}
+
+//---------------------------------------------------------
+// WaveEvent::mid
+//---------------------------------------------------------
+
+EventBase* WaveEventBase::mid(unsigned b, unsigned e)
+ {
+ WaveEventBase* ev = new WaveEventBase(*this);
+ unsigned fr = frame();
+ unsigned start = fr - b;
+ if(b > fr)
+ {
+ start = 0;
+ ev->setSpos(spos() + b - fr);
+ }
+ unsigned end = endFrame();
+
+ if (e < end)
+ end = e;
+
+ ev->setFrame(start);
+ ev->setLenFrame(end - b - start);
+ return ev;
+ }
+
+//---------------------------------------------------------
+// dump
+//---------------------------------------------------------
+
+void WaveEventBase::dump(int n) const
+ {
+ EventBase::dump(n);
+ }
+
+//---------------------------------------------------------
+// WaveEventBase::read
+//---------------------------------------------------------
+
+void WaveEventBase::read(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ case Xml::Attribut:
+ return;
+ case Xml::TagStart:
+ if (tag == "poslen")
+ PosLen::read(xml, "poslen");
+ else if (tag == "frame")
+ _spos = xml.parseInt();
+ else if (tag == "file") {
+ SndFile* wf = getWave(xml.parse1(), true);
+ if (wf) {
+ f = SndFileR(wf);
+ }
+ }
+ else
+ xml.unknown("Event");
+ break;
+ case Xml::TagEnd:
+ if (tag == "event") {
+ Pos::setType(FRAMES); // DEBUG
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+//void WaveEventBase::write(int level, Xml& xml, const Pos& offset) const
+void WaveEventBase::write(int level, Xml& xml, const Pos& offset, bool forcePath) const
+ {
+ if (f.isNull())
+ return;
+ xml.tag(level++, "event");
+ PosLen wpos(*this);
+ wpos += offset;
+// if (offset)
+// wpos.setTick(wpos.tick() + offset);
+ wpos.write(level, xml, "poslen");
+ xml.intTag(level, "frame", _spos); // offset in wave file
+
+ //
+ // waves in the project dirctory are stored
+ // with relative path name, others with absolute path
+ //
+ QString path = f.dirPath();
+
+ //if (path.contains(museProject)) {
+ if (!forcePath && path.contains(museProject)) {
+ // extract museProject.
+ QString newName = f.path().remove(museProject+"/");
+ xml.strTag(level, "file", newName);
+ }
+ else
+ xml.strTag(level, "file", f.path());
+ xml.etag(level, "event");
+ }
+
+//void WaveEventBase::read(unsigned offset, float** buffer, int channel, int n, bool overwrite)
+//void WaveEventBase::readAudio(unsigned offset, float** buffer, int channel, int n, bool doSeek, bool overwrite)
+//off_t WaveEventBase::readAudio(SRC_STATE* src_state, off_t sfCurFrame, unsigned offset, float** buffer, int channel, int n, bool doSeek, bool overwrite)
+//off_t WaveEventBase::readAudio(AudioConverter* audConv, off_t sfCurFrame, unsigned offset, float** buffer, int channel, int n, bool doSeek, bool overwrite)
+// p3.3.33
+void WaveEventBase::readAudio(WavePart* part, unsigned offset, float** buffer, int channel, int n, bool doSeek, bool overwrite)
+{
+ // Added by Tim. p3.3.17
+ #ifdef WAVEEVENT_DEBUG_PRC
+ printf("WaveEventBase::readAudio audConv:%p sfCurFrame:%ld offset:%u channel:%d n:%d\n", audConv, sfCurFrame, offset, channel, n);
+ #endif
+
+ // Changed by Tim. p3.3.18
+ #ifdef USE_SAMPLERATE
+
+ // TODO:
+ >>>>>>>>>>>+++++++++++++++++++++++++++++
+ // If we have a valid audio converter then use it to do the processing. Otherwise just a normal seek + read.
+ if(audConv)
+ //sfCurFrame = audConv->process(f, sfCurFrame, offset + _spos, buffer, channel, n, doSeek, overwrite);
+ sfCurFrame = audConv->readAudio(f, sfCurFrame, offset, buffer, channel, n, doSeek, overwrite);
+ else
+ {
+ if(!f.isNull())
+ {
+ sfCurFrame = f.seek(offset + _spos, 0);
+ sfCurFrame += f.read(channel, buffer, n, overwrite);
+ }
+ }
+ //return sfCurFrame;
+ return;
+
+ /*
+ unsigned fsrate = f.samplerate();
+ int fchan = f.channels();
+ off_t frame = offset + _spos;
+ //bool resample = src_state && ((unsigned)sampleRate != fsrate);
+ bool resample = audConv && audConv->isValid() && ((unsigned)sampleRate != fsrate);
+
+ // Is a 'transport' seek requested? (Not to be requested with every read! Should only be for 'first read' seeks, or positional 'transport' seeks.)
+ // Due to the support of sound file references in MusE, seek must ALWAYS be done before read, as before,
+ // except now we alter the seek position if sample rate conversion is being used and remember the seek positions.
+ if(doSeek)
+ {
+ if(!resample)
+ {
+ // Sample rates are the same. Just a regular seek, no conversion.
+ sfCurFrame = f.seek(frame, 0);
+ }
+ else
+ {
+ // Sample rates are different. Seek to a calculated 'sample rate ratio factored' position.
+
+ double srcratio = (double)fsrate / (double)sampleRate;
+ //long inSize = long((double)frames * _src_ratio) + 1 // From MusE-2 file converter.
+ off_t newfr = (off_t)floor(((double)frame * srcratio)); // From simplesynth.
+
+ //_sfCurFrame = sf_seek(sf, newfr, 0);
+ sfCurFrame = f.seek(newfr, 0);
+
+ // Added by Tim. p3.3.17
+ #ifdef WAVEEVENT_DEBUG_PRC
+ printf("WaveEventBase::readAudio Seek frame:%ld converted to frame:%ld _sfCurFrame:%ld\n", frame, newfr, sfCurFrame);
+ #endif
+
+ // Reset the src converter. It's current state is meaningless now.
+ //int srcerr = src_reset(src_state);
+ int srcerr = audConv->reset();
+ if(srcerr != 0)
+ printf("WaveEventBase::readAudio Converter reset failed: %s\n", src_strerror(srcerr));
+ }
+ }
+ else
+ {
+ // No seek requested. Are the rates the same?
+ if(!resample)
+ // Sample rates are the same. Just a regular seek, no conversion.
+ sfCurFrame = f.seek(frame, 0);
+ else
+ {
+ // Added by Tim. p3.3.17
+ #ifdef WAVEEVENT_DEBUG_PRC
+ printf("WaveEventBase::readAudio No 'transport' seek, rates different. Seeking to _sfCurFrame:%ld\n", sfCurFrame);
+ #endif
+
+ // Sample rates are different. We can't just tell seek to go to an absolute calculated position,
+ // since the last position can vary - it might not be what the calculated position is.
+ // We must use the last position left by SRC conversion, ie. let the file position progress on its own.
+ sfCurFrame = f.seek(sfCurFrame, 0);
+ }
+ }
+
+ // Do we not need to resample?
+ if(!resample)
+ {
+ return sfCurFrame + f.read(channel, buffer, n, overwrite);
+ }
+
+ size_t rn;
+
+ if((sampleRate == 0) || (fsrate == 0))
+ {
+ if(debugMsg)
+ printf("WaveEventBase::readAudio Using SRC: Error: sampleRate or file samplerate is zero!\n");
+ return sfCurFrame;
+ }
+
+ // Ratio is defined as output sample rate over input samplerate.
+ double srcratio = (double)sampleRate / (double)fsrate;
+ long outFrames = n;
+ //long outSize = outFrames * channel;
+ long outSize = outFrames * fchan;
+
+ //long inSize = long(outSize * srcratio) + 1 // From MusE-2 file converter.
+ //long inSize = (long)floor(((double)outSize / srcratio)); // From simplesynth.
+ //long inFrames = (long)floor(((double)outFrames / srcratio)); // From simplesynth.
+ long inFrames = (long)ceil(((double)outFrames / srcratio)); // From simplesynth.
+ //long inFrames = (long)floor(double(outFrames * sfinfo.samplerate) / double(sampleRate)); // From simplesynth.
+
+ // Extra input compensation - sometimes src requires more input frames than expected in order to
+ // always get a reliable number of used out frames !
+ //inFrames = inFrames / (srcratio / 2.0);
+ long inComp = 10;
+ inFrames += inComp;
+
+ long inSize = inFrames * fchan;
+ //long inSize = inFrames * channel;
+
+ float inbuffer[inSize];
+ float outbuffer[outSize];
+
+ //float* poutbuf;
+
+ // If the number of file channels is the same as the process channels AND we want overwrite, we can get away with direct copying.
+ //if(overwrite && channel == fchan)
+ // Point the out buffer directly at the return buffers.
+ // poutbuf = buffer;
+ //else
+ // Point the out buffer at our local buffers.
+ // poutbuf = &outbuffer[0];
+
+ // Converter channels are fixed at creation time! Can't change them on the fly. Can't use 'channel' paramter.
+ //rn = f.read(inbuffer, inFrames);
+ rn = f.readDirect(inbuffer, inFrames);
+
+ // convert
+ SRC_DATA srcdata;
+ srcdata.data_in = inbuffer;
+ srcdata.data_out = outbuffer;
+ //srcdata.data_out = poutbuf;
+ //srcdata.input_frames = inSize;
+ srcdata.input_frames = rn;
+ srcdata.output_frames = outFrames;
+ srcdata.end_of_input = ((long)rn != inFrames);
+ srcdata.src_ratio = srcratio;
+
+ #ifdef WAVEEVENT_DEBUG_PRC
+ printf("WaveEventBase::readAudio %s processing converter... inFrames:%ld inSize:%ld outFrames:%ld outSize:%ld rn:%d",
+ f.name().toLatin1(), inFrames, inSize, outFrames, outSize, rn);
+ #endif
+
+ //int srcerr = src_process(src_state, &srcdata);
+ int srcerr = audConv->process(&srcdata);
+ if(srcerr != 0)
+ {
+ printf("\nWaveEventBase::readAudio SampleRate converter process failed: %s\n", src_strerror(srcerr));
+ return sfCurFrame += rn;
+ }
+
+ #ifdef WAVEEVENT_DEBUG_PRC
+ printf(" frames used in:%ld out:%ld\n", srcdata.input_frames_used, srcdata.output_frames_gen);
+ #endif
+
+ // If the number of frames read by the soundfile equals the input frames, go back.
+ // Otherwise we have reached the end of the file, so going back is useless since
+ // there shouldn't be any further calls. (Definitely get buffer underruns if further calls!)
+ if((long)rn == inFrames)
+ {
+ // Go back by the amount of unused frames.
+ sf_count_t seekn = inFrames - srcdata.input_frames_used;
+ if(seekn != 0)
+ {
+ #ifdef WAVEEVENT_DEBUG_PRC
+ printf("WaveEventBase::readAudio Seek-back by:%d\n", seekn);
+ #endif
+ sfCurFrame = f.seek(-seekn, SEEK_CUR);
+ }
+ else
+ sfCurFrame += rn;
+ }
+ else
+ sfCurFrame += rn;
+
+ if(debugMsg)
+ {
+ if(srcdata.output_frames_gen != outFrames)
+ printf("WaveEventBase::readAudio %s output_frames_gen:%ld != outFrames:%ld outSize:%ld inFrames:%ld srcdata.input_frames_used:%ld inSize:%ld rn:%d\n",
+ f.name().toLatin1(), srcdata.output_frames_gen, outFrames, outSize, inFrames, srcdata.input_frames_used, inSize, rn);
+ }
+
+ if(inFrames != (long)rn)
+ {
+ if(debugMsg)
+ printf("WaveEventBase::readAudio %s rn:%zd != inFrames:%ld output_frames_gen:%ld outFrames:%ld outSize:%ld srcdata.input_frames_used:%ld inSize:%ld\n",
+ f.name().toLatin1(), rn, inFrames, srcdata.output_frames_gen, outFrames, outSize, srcdata.input_frames_used, inSize);
+
+ // We've reached the end of the file. Convert the number of frames read.
+ //rn = (double)rn * srcratio + 1;
+ rn = (long)floor((double)rn * srcratio);
+ if(rn > (size_t)outFrames)
+ rn = outFrames;
+ }
+ else
+ if(srcdata.output_frames_gen != outFrames)
+ {
+ // SRC didn't give us the number of frames we requested.
+ // This can occasionally be radically different from the requested frames, or zero,
+ // even when ample excess input frames are supplied.
+ // We're not done converting yet - we haven't reached the end of the file.
+ // We must do something with the buffer. So let's zero whatever SRC didn't fill.
+ // FIXME: Instead of zeroing, try processing more input data until the out buffer is full.
+ long b = srcdata.output_frames_gen * channel;
+ long e = outFrames * channel;
+ for(long i = b; i < e; ++i)
+ outbuffer[i] = 0.0f;
+ //poutbuf[i] = 0.0f;
+ rn = outFrames;
+ }
+ else
+ rn = outFrames;
+
+ float* poutbuf = &outbuffer[0];
+ if(fchan == channel)
+ {
+ if(overwrite)
+ for (size_t i = 0; i < rn; ++i)
+ {
+ for(int ch = 0; ch < channel; ++ch)
+ *(buffer[ch] + i) = *poutbuf++;
+ }
+ else
+ for(size_t i = 0; i < rn; ++i)
+ {
+ for(int ch = 0; ch < channel; ++ch)
+ *(buffer[ch] + i) += *poutbuf++;
+ }
+ }
+ else if((fchan == 2) && (channel == 1))
+ {
+ // stereo to mono
+ if(overwrite)
+ for(size_t i = 0; i < rn; ++i)
+ *(buffer[0] + i) = poutbuf[i + i] + poutbuf[i + i + 1];
+ else
+ for(size_t i = 0; i < rn; ++i)
+ *(buffer[0] + i) += poutbuf[i + i] + poutbuf[i + i + 1];
+ }
+ else if((fchan == 1) && (channel == 2))
+ {
+ // mono to stereo
+ if(overwrite)
+ for(size_t i = 0; i < rn; ++i)
+ {
+ float data = *poutbuf++;
+ *(buffer[0]+i) = data;
+ *(buffer[1]+i) = data;
+ }
+ else
+ for(size_t i = 0; i < rn; ++i)
+ {
+ float data = *poutbuf++;
+ *(buffer[0]+i) += data;
+ *(buffer[1]+i) += data;
+ }
+ }
+ else
+ {
+ if(debugMsg)
+ printf("WaveEventBase::readAudio Channel mismatch: source chans:%d -> dst chans:%d\n", fchan, channel);
+ }
+
+ return sfCurFrame;
+ */
+
+
+ #else
+ if(f.isNull())
+ return;
+ //return sfCurFrame;
+
+ //sfCurFrame = f.seek(offset + _spos, 0);
+ //sfCurFrame += f.read(channel, buffer, n, overwrite);
+ f.seek(offset + _spos, 0);
+ f.read(channel, buffer, n, overwrite);
+
+ // p3.3.41
+ //fprintf(stderr, "WaveEventBase::readAudio data: n:%ld %e %e %e %e\n", n, buffer[0][0], buffer[0][1], buffer[0][2], buffer[0][3]);
+
+
+ //return sfCurFrame;
+ return;
+ #endif
+
+}
+
diff --git a/attic/muse2-oom/muse2/muse/waveevent.h b/attic/muse2-oom/muse2/muse/waveevent.h
new file mode 100644
index 00000000..4ea4918b
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/waveevent.h
@@ -0,0 +1,64 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: waveevent.h,v 1.6.2.4 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 1999-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __WAVE_EVENT_H__
+#define __WAVE_EVENT_H__
+
+//#include <samplerate.h>
+#include <sys/types.h>
+
+#include "eventbase.h"
+
+class AudioConverter;
+class WavePart;
+
+//---------------------------------------------------------
+// WaveEvent
+//---------------------------------------------------------
+
+class WaveEventBase : public EventBase {
+ QString _name;
+ SndFileR f;
+ int _spos; // start sample position in WaveFile
+ bool deleted;
+
+ // p3.3.31
+ //virtual EventBase* clone() { return new WaveEventBase(*this); }
+ virtual EventBase* clone();
+
+ public:
+ WaveEventBase(EventType t);
+ virtual ~WaveEventBase() {}
+
+ virtual void read(Xml&);
+ //virtual void write(int, Xml&, const Pos& offset) const;
+ virtual void write(int, Xml&, const Pos& offset, bool forcePath = false) const;
+ virtual EventBase* mid(unsigned, unsigned);
+
+ virtual void dump(int n = 0) const;
+
+ virtual const QString name() const { return _name; }
+ virtual void setName(const QString& s) { _name = s; }
+ virtual int spos() const { return _spos; }
+ virtual void setSpos(int s) { _spos = s; }
+ virtual SndFileR sndFile() const { return f; }
+ virtual void setSndFile(SndFileR& sf) { f = sf; }
+
+ // Changed by Tim. p3.3.17
+ //virtual void read(unsigned offset, float** bpp, int channels, int nn, bool overwrite = true);
+ //virtual void readAudio(unsigned /*offset*/, float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/);
+ //virtual off_t readAudio(SRC_STATE* /*src_state*/, off_t /*sfCurFrame*/, unsigned /*offset*/,
+ // float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/);
+ //virtual off_t readAudio(AudioConverter* /*audConv*/, off_t /*sfCurFrame*/, unsigned /*offset*/,
+ // float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/);
+ virtual void readAudio(WavePart* /*part*/, unsigned /*offset*/,
+ float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/wavetrack.cpp b/attic/muse2-oom/muse2/muse/wavetrack.cpp
new file mode 100644
index 00000000..fdebc8b8
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/wavetrack.cpp
@@ -0,0 +1,360 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: wavetrack.cpp,v 1.15.2.12 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "track.h"
+#include "event.h"
+#include "audio.h"
+#include "wave.h"
+#include "xml.h"
+#include "song.h"
+#include "globals.h"
+#include "gconfig.h"
+#include "al/dsp.h"
+
+// Added by Tim. p3.3.18
+//#define WAVETRACK_DEBUG
+
+//---------------------------------------------------------
+// fetchData
+// called from prefetch thread
+//---------------------------------------------------------
+
+//void WaveTrack::fetchData(unsigned pos, unsigned samples, float** bp)
+void WaveTrack::fetchData(unsigned pos, unsigned samples, float** bp, bool doSeek)
+ {
+ // Added by Tim. p3.3.17
+ #ifdef WAVETRACK_DEBUG
+ printf("WaveTrack::fetchData %s samples:%lu pos:%u\n", name().toLatin1().constData(), samples, pos);
+ #endif
+
+ // reset buffer to zero
+ for (int i = 0; i < channels(); ++i)
+ memset(bp[i], 0, samples * sizeof(float));
+
+ // p3.3.29
+ // Process only if track is not off.
+ if(!off())
+ {
+
+ PartList* pl = parts();
+ unsigned n = samples;
+ for (iPart ip = pl->begin(); ip != pl->end(); ++ip) {
+ WavePart* part = (WavePart*)(ip->second);
+ // Changed by Tim. p3.3.17
+ //if (part->mute() || isMute())
+ if (part->mute())
+ continue;
+
+ unsigned p_spos = part->frame();
+ unsigned p_epos = p_spos + part->lenFrame();
+ if (pos + n < p_spos)
+ break;
+ if (pos >= p_epos)
+ continue;
+
+ EventList* events = part->events();
+ for (iEvent ie = events->begin(); ie != events->end(); ++ie) {
+ Event& event = ie->second;
+ unsigned e_spos = event.frame() + p_spos;
+ unsigned nn = event.lenFrame();
+ unsigned e_epos = e_spos + nn;
+
+ if (pos + n < e_spos)
+ break;
+ if (pos >= e_epos)
+ continue;
+
+ int offset = e_spos - pos;
+
+ unsigned srcOffset, dstOffset;
+ if (offset > 0) {
+ nn = n - offset;
+ srcOffset = 0;
+ dstOffset = offset;
+ }
+ else {
+ srcOffset = -offset;
+ dstOffset = 0;
+
+ nn += offset;
+ if (nn > n)
+ nn = n;
+ }
+ float* bpp[channels()];
+ for (int i = 0; i < channels(); ++i)
+ bpp[i] = bp[i] + dstOffset;
+
+ // By T356. Allow overlapping parts or events to mix together !
+ // Since the buffers are cleared above, just read and add (don't overwrite) the samples.
+ //event.read(srcOffset, bpp, channels(), nn);
+ //event.read(srcOffset, bpp, channels(), nn, false);
+ //event.readAudio(srcOffset, bpp, channels(), nn, doSeek, false);
+ // p3.3.33
+ event.readAudio(part, srcOffset, bpp, channels(), nn, doSeek, false);
+
+ }
+ }
+ }
+
+ if(config.useDenormalBias) {
+ // add denormal bias to outdata
+ for (int i = 0; i < channels(); ++i)
+ for (unsigned int j = 0; j < samples; ++j)
+ {
+ bp[i][j] +=denormalBias;
+
+ /*
+ // p3.3.41
+ if(j & 1)
+ bp[i][j] -=denormalBias;
+ else
+ bp[i][j] +=denormalBias;
+ */
+ }
+ }
+
+ // p3.3.41
+ //fprintf(stderr, "WaveTrack::fetchData data: samples:%ld %e %e %e %e\n", samples, bp[0][0], bp[0][1], bp[0][2], bp[0][3]);
+
+ _prefetchFifo.add();
+ }
+
+//---------------------------------------------------------
+// write
+//---------------------------------------------------------
+
+void WaveTrack::write(int level, Xml& xml) const
+ {
+ xml.tag(level++, "wavetrack");
+ AudioTrack::writeProperties(level, xml);
+ const PartList* pl = cparts();
+ for (ciPart p = pl->begin(); p != pl->end(); ++p)
+ p->second->write(level, xml);
+ xml.etag(level, "wavetrack");
+ }
+
+//---------------------------------------------------------
+// read
+//---------------------------------------------------------
+
+void WaveTrack::read(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ if (tag == "part") {
+ //Part* p = newPart();
+ //p->read(xml);
+ Part* p = 0;
+ p = readXmlPart(xml, this);
+ if(p)
+ parts()->add(p);
+ }
+ else if (AudioTrack::readProperties(xml, tag))
+ xml.unknown("WaveTrack");
+ break;
+ case Xml::Attribut:
+ break;
+ case Xml::TagEnd:
+ if (tag == "wavetrack") {
+ mapRackPluginsToControllers();
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// newPart
+//---------------------------------------------------------
+
+Part* WaveTrack::newPart(Part*p, bool clone)
+ {
+ WavePart* part = clone ? new WavePart(this, p->events()) : new WavePart(this);
+ if (p) {
+ part->setName(p->name());
+ part->setColorIndex(p->colorIndex());
+
+ *(PosLen*)part = *(PosLen*)p;
+ part->setMute(p->mute());
+ }
+
+ if(clone)
+ //p->chainClone(part);
+ chainClone(p, part);
+
+ return part;
+ }
+
+//---------------------------------------------------------
+// getData
+//---------------------------------------------------------
+
+bool WaveTrack::getData(unsigned framePos, int channels, unsigned nframe, float** bp)
+ {
+ //if(debugMsg)
+ // printf("WaveTrack::getData framePos:%u channels:%d nframe:%u processed?:%d\n", framePos, channels, nframe, processed());
+
+ if ((song->bounceTrack != this) && !noInRoute()) {
+ RouteList* irl = inRoutes();
+ iRoute i = irl->begin();
+ if(i->track->isMidiTrack())
+ {
+ if(debugMsg)
+ printf("WaveTrack::getData: Error: First route is a midi track route!\n");
+ return false;
+ }
+ // p3.3.38
+ //((AudioTrack*)i->track)->copyData(framePos, channels, nframe, bp);
+ ((AudioTrack*)i->track)->copyData(framePos, channels,
+ //(i->track->type() == Track::AUDIO_SOFTSYNTH && i->channel != -1) ? i->channel : 0,
+ i->channel,
+ i->channels,
+ nframe, bp);
+
+ ++i;
+ for (; i != irl->end(); ++i)
+ {
+ if(i->track->isMidiTrack())
+ {
+ if(debugMsg)
+ printf("WaveTrack::getData: Error: Route is a midi track route!\n");
+ //return false;
+ continue;
+ }
+ // p3.3.38
+ //((AudioTrack*)i->track)->addData(framePos, channels, nframe, bp);
+ ((AudioTrack*)i->track)->addData(framePos, channels,
+ //(i->track->type() == Track::AUDIO_SOFTSYNTH && i->channel != -1) ? i->channel : 0,
+ i->channel,
+ i->channels,
+ nframe, bp);
+
+ }
+ if (recordFlag()) {
+ if (audio->isRecording() && recFile()) {
+ if (audio->freewheel()) {
+ }
+ else {
+ if (fifo.put(channels, nframe, bp, audio->pos().frame()))
+ printf("WaveTrack::getData(%d, %d, %d): fifo overrun\n",
+ framePos, channels, nframe);
+ }
+ }
+ return true;
+ }
+ }
+ if (!audio->isPlaying())
+ return false;
+
+ // Removed by T356. Multiple out route cacheing now handled by AudioTrack::copyData and ::addData.
+ /*
+ if (outRoutes()->size() > 1) {
+ if (bufferPos != framePos) {
+ // Added by Tim. p3.3.16
+ printf("WaveTrack::getData bufferPos:%d != framePos\n", bufferPos);
+
+ bufferPos = framePos;
+ if (audio->freewheel()) {
+ // when freewheeling, read data direct from file:
+ fetchData(bufferPos, nframe, outBuffers);
+ }
+ else {
+ unsigned pos;
+ if (_prefetchFifo.get(channels, nframe, outBuffers, &pos)) {
+ printf("WaveTrack::getData(%s) fifo underrun\n",
+ name().toLatin1().constData());
+ return false;
+ }
+ if (pos != framePos) {
+ printf("fifo get error expected %d, got %d\n",
+ framePos, pos);
+ if (debugMsg)
+ printf("fifo get error expected %d, got %d\n",
+ framePos, pos);
+ while (pos < framePos) {
+ if (_prefetchFifo.get(channels, nframe, bp, &pos)) {
+ printf("WaveTrack::getData(%s) fifo underrun\n",
+ name().toLatin1().constData());
+ return false;
+ }
+ }
+ }
+ }
+ }
+ for (int i = 0; i < channels; ++i)
+ //memcpy(bp[i], outBuffers[i], nframe * sizeof(float));
+ AL::dsp->cpy(bp[i], outBuffers[i], nframe);
+ }
+ else {
+ */
+
+ //printf("WaveTrack::getData no out routes\n");
+
+ if (audio->freewheel()) {
+
+ // when freewheeling, read data direct from file:
+ // Indicate do not seek file before each read.
+ // Changed by Tim. p3.3.17
+ //fetchData(framePos, nframe, bp);
+ fetchData(framePos, nframe, bp, false);
+
+ }
+ else {
+ unsigned pos;
+ if (_prefetchFifo.get(channels, nframe, bp, &pos)) {
+ printf("WaveTrack::getData(%s) fifo underrun\n",
+ name().toLatin1().constData());
+ return false;
+ }
+ if (pos != framePos) {
+ if (debugMsg)
+ printf("fifo get error expected %d, got %d\n",
+ framePos, pos);
+ while (pos < framePos) {
+ if (_prefetchFifo.get(channels, nframe, bp, &pos)) {
+ printf("WaveTrack::getData(%s) fifo underrun\n",
+ name().toLatin1().constData());
+ return false;
+ }
+ }
+ }
+
+ // p3.3.41
+ //fprintf(stderr, "WaveTrack::getData %s data: nframe:%ld %e %e %e %e\n", name().toLatin1().constData(), nframe, bp[0][0], bp[0][1], bp[0][2], bp[0][3]);
+
+ }
+ //}
+ return true;
+ }
+
+//---------------------------------------------------------
+// setChannels
+//---------------------------------------------------------
+
+void WaveTrack::setChannels(int n)
+ {
+ AudioTrack::setChannels(n);
+ SndFile* sf = recFile();
+ if (sf) {
+ if (sf->samples() == 0) {
+ sf->remove();
+ sf->setFormat(sf->format(), _channels,
+ sf->samplerate());
+ sf->openWrite();
+ }
+ }
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/CMakeLists.txt b/attic/muse2-oom/muse2/muse/widgets/CMakeLists.txt
new file mode 100644
index 00000000..1feb1ae4
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/CMakeLists.txt
@@ -0,0 +1,236 @@
+#=============================================================================
+# MusE
+# Linux Music Editor
+# $Id:$
+#
+# Copyright (C) 2002-2006 by Werner Schweer and others
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License version 2.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#=============================================================================
+
+##
+## Expand Qt macros in source files
+##
+QT4_WRAP_CPP (widget_mocs
+ aboutbox_impl.h
+ action.h
+ bigtime.h
+ canvas.h
+ checkbox.h
+ comboQuant.h
+ combobox.h
+ comment.h
+ ctrlcombo.h
+ dentry.h
+ didyouknow.h
+ doublelabel.h
+ filedialog.h
+ gatetime.h
+ genset.h
+ header.h
+ hitscale.h
+ intlabel.h
+ knob.h
+ lcombo.h
+ metronome.h
+ midisyncimpl.h
+ mixdowndialog.h
+ mlabel.h
+ mtscale.h
+ pcscale.h
+ tvieweditor.h
+ pctablemodel.h
+ pctable.h
+ mtrackinfo.h
+ nentry.h
+ noteinfo.h
+ pitchedit.h
+ pitchlabel.h
+ popupmenu.h
+ # posedit.h
+ poslabel.h
+ projectcreateimpl.h
+ scrollscale.h
+ shortcutcapturedialog.h
+ shortcutconfig.h
+ # sigedit.h
+ siglabel.h
+ sigscale.h
+ slider.h
+ sliderbase.h
+ songinfo.h
+ spinbox.h
+ spinboxFP.h
+ splitter.h
+ swidget.h
+ tb1.h
+ tempolabel.h
+ tools.h
+ # ttoolbar.h
+ ttoolbutton.h
+ velocity.h
+ view.h
+ vscale.h
+ )
+
+##
+## UI files
+##
+file (GLOB widgets_ui_files
+ aboutbox.ui
+ appearancebase.ui
+ cliplisteditorbase.ui
+ commentbase.ui
+ configmidifilebase.ui
+ didyouknow.ui
+ editnotedialogbase.ui
+ editsysexdialogbase.ui
+ fdialogbuttons.ui
+ gatetimebase.ui
+ gensetbase.ui
+ itransformbase.ui
+ metronomebase.ui
+ midisync.ui
+ mittransposebase.ui
+ mixdowndialogbase.ui
+ mtrackinfobase.ui
+ projectcreate.ui
+ shortcutcapturedialogbase.ui
+ shortcutconfigbase.ui
+ songinfo.ui
+ synthconfigbase.ui
+ transformbase.ui
+ transposebase.ui
+ velocitybase.ui
+ trackvieweditorbase.ui
+ )
+QT4_WRAP_UI (widget_ui_headers ${widgets_ui_files})
+
+##
+## List of source files to compile
+##
+file (GLOB widgets_source_files
+ aboutbox_impl.cpp
+ bigtime.cpp
+ canvas.cpp
+ checkbox.cpp
+ citem.cpp
+ comboQuant.cpp
+ combobox.cpp
+ comment.cpp
+ ctrlcombo.cpp
+ dentry.cpp
+ dimap.cpp
+ doublelabel.cpp
+ drange.cpp
+ filedialog.cpp
+ gatetime.cpp
+ genset.cpp
+ header.cpp
+ hitscale.cpp
+ intlabel.cpp
+ knob.cpp
+ lcombo.cpp
+ metronome.cpp
+ midisyncimpl.cpp
+ mixdowndialog.cpp
+ mlabel.cpp
+ mmath.cpp
+ mtrackinfo.cpp
+ tvieweditor.cpp
+ mtscale.cpp
+ pcscale.cpp
+ pctablemodel.cpp
+ pctable.cpp
+ nentry.cpp
+ noteinfo.cpp
+ pitchedit.cpp
+ pitchlabel.cpp
+ popupmenu.cpp
+ # posedit.cpp
+ poslabel.cpp
+ projectcreateimpl.cpp
+ scldiv.cpp
+ scldraw.cpp
+ sclif.cpp
+ scrollscale.cpp
+ shortcutcapturedialog.cpp
+ shortcutconfig.cpp
+ # sigedit.cpp
+ siglabel.cpp
+ sigscale.cpp
+ slider.cpp
+ sliderbase.cpp
+ spinbox.cpp
+ spinboxFP.cpp
+ splitter.cpp
+ swidget.cpp
+ tb1.cpp
+ tempolabel.cpp
+ tools.cpp
+ ttoolbar.cpp
+ ttoolbutton.cpp
+ utils.cpp
+ velocity.cpp
+ view.cpp
+ vscale.cpp
+ )
+
+##
+## Define target
+##
+add_library ( widgets SHARED
+ ${widget_ui_headers}
+ ${widget_mocs}
+ ${widgets_source_files}
+ )
+
+##
+## Append to the list of translations
+##
+set (FILES_TO_TRANSLATE
+ ${FILES_TO_TRANSLATE}
+ ${widgets_source_files}
+ ${widgets_ui_files}
+ CACHE INTERNAL ""
+ )
+
+##
+## Compilation flags and target name
+##
+set_target_properties( widgets
+ # PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h ${MUSECXXFLAGS} -I../ -I${PROJECT_SOURCE_DIR}/synti "
+ PROPERTIES COMPILE_FLAGS "-include ${PROJECT_BINARY_DIR}/all.h ${MUSECXXFLAGS} -I../ -I${PROJECT_SOURCE_DIR}/synti -fPIC"
+ OUTPUT_NAME muse_widgets
+ )
+
+##
+## Linkage
+##
+target_link_libraries ( widgets
+ ${QT_LIBRARIES}
+ icons
+ )
+
+##
+## Install location
+##
+install(TARGETS widgets
+ DESTINATION
+ ${MusE_MODULES_DIR}
+ )
+
+
+
+
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/aboutbox.ui b/attic/muse2-oom/muse2/muse/widgets/aboutbox.ui
new file mode 100644
index 00000000..250f656f
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/aboutbox.ui
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>AboutBox</class>
+ <widget class="QDialog" name="AboutBox">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>350</width>
+ <height>160</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>AboutBox</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QFrame" name="imageFrame">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::NoFrame</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout1">
+ <item>
+ <widget class="QLabel" name="imageLabel">
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <property name="lineWidth">
+ <number>4</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="versionLabel">
+ <property name="text">
+ <string>Version 2 pre-alpha</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="textLabel1">
+ <property name="text">
+ <string>(C) Copyright 1999-2010 Werner Schweer and others.
+See http://www.muse-sequencer.org for new versions and
+more information.
+
+Published under the GNU Public License</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="doneHere">
+ <property name="text">
+ <string>&amp;Keep On Rocking!</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+K</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ <zorder>versionLabel</zorder>
+ <zorder>textLabel1</zorder>
+ <zorder>doneHere</zorder>
+ <zorder>imageFrame</zorder>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>doneHere</sender>
+ <signal>clicked()</signal>
+ <receiver>AboutBox</receiver>
+ <slot>close()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/aboutbox_impl.cpp b/attic/muse2-oom/muse2/muse/widgets/aboutbox_impl.cpp
new file mode 100644
index 00000000..bf370ab7
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/aboutbox_impl.cpp
@@ -0,0 +1,12 @@
+#include "aboutbox_impl.h"
+#include "config.h"
+#include "icons.h"
+
+AboutBoxImpl::AboutBoxImpl()
+{
+ setupUi(this);
+ imageLabel->setPixmap(*aboutMuseImage);
+ QString version(VERSION);
+ QString svnrevision(SVNVERSION);
+ versionLabel->setText("Version: " + version + " (svn revision: "+ svnrevision +")");
+}
diff --git a/attic/muse2-oom/muse2/muse/widgets/aboutbox_impl.h b/attic/muse2-oom/muse2/muse/widgets/aboutbox_impl.h
new file mode 100644
index 00000000..de75bfc9
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/aboutbox_impl.h
@@ -0,0 +1,16 @@
+#ifndef ABOUTBOXIMPL_H
+#define ABOUTBOXIMPL_H
+
+#include "ui_aboutbox.h"
+
+class AboutBoxImpl : public QDialog, public Ui::AboutBox
+{
+ Q_OBJECT
+
+public:
+ AboutBoxImpl();
+
+
+};
+
+#endif // ABOUTBOXIMPL_H
diff --git a/attic/muse2-oom/muse2/muse/widgets/action.h b/attic/muse2-oom/muse2/muse/widgets/action.h
new file mode 100644
index 00000000..7fa040c4
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/action.h
@@ -0,0 +1,33 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: action.h,v 1.1.1.1.2.1 2008/01/19 13:33:46 wschweer Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __ACTION_H__
+#define __ACTION_H__
+
+#include <QAction>
+
+//---------------------------------------------------------
+// Action
+//---------------------------------------------------------
+
+class Action : public QAction {
+ Q_OBJECT
+ int _id;
+
+ public:
+ Action(QObject* parent, int i, const char* name = 0, bool toggle = false)
+ : QAction(name, parent) {
+ _id = i;
+ setCheckable(toggle);
+ }
+ void setId(int i) { _id = i; }
+ int id() const { return _id; }
+ };
+
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/appearancebase.ui b/attic/muse2-oom/muse2/muse/widgets/appearancebase.ui
new file mode 100644
index 00000000..92ab0c84
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/appearancebase.ui
@@ -0,0 +1,1890 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>AppearanceDialogBase</class>
+ <widget class="QDialog" name="AppearanceDialogBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>538</width>
+ <height>531</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Appearance settings</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QTabWidget" name="TabWidget2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="tab1">
+ <attribute name="title">
+ <string>Arranger</string>
+ </attribute>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QGroupBox" name="ButtonGroup3">
+ <property name="title">
+ <string>Parts</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QCheckBox" name="partShownames">
+ <property name="text">
+ <string>show names</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="partShowevents">
+ <property name="text">
+ <string>show events</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="partShowCakes">
+ <property name="text">
+ <string>show Cakewalk Style</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QGroupBox" name="eventButtonGroup">
+ <property name="title">
+ <string>Events</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="eventNoteon">
+ <property name="text">
+ <string>note on</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QCheckBox" name="eventPolypressure">
+ <property name="text">
+ <string>poly pressure</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QCheckBox" name="eventController">
+ <property name="text">
+ <string>controller</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QCheckBox" name="eventAftertouch">
+ <property name="text">
+ <string>aftertouch</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QCheckBox" name="eventPitchbend">
+ <property name="text">
+ <string>pitch bend</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QCheckBox" name="eventProgramchange">
+ <property name="text">
+ <string>program change</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QCheckBox" name="eventSpecial">
+ <property name="text">
+ <string>special</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <widget class="QGroupBox" name="GroupBox2">
+ <property name="title">
+ <string>Background picture</string>
+ </property>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QTreeWidget" name="backgroundTree">
+ <property name="uniformRowHeights">
+ <bool>true</bool>
+ </property>
+ <property name="itemsExpandable">
+ <bool>true</bool>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <attribute name="headerVisible">
+ <bool>false</bool>
+ </attribute>
+ <column>
+ <property name="text">
+ <string notr="true">1</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QPushButton" name="addBgButton">
+ <property name="text">
+ <string>add</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="removeBgButton">
+ <property name="text">
+ <string>remove</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="clearBgButton">
+ <property name="text">
+ <string>clear</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <widget class="QCheckBox" name="arrGrid">
+ <property name="text">
+ <string>show snap grid</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab2" >
+ <attribute name="title">
+ <string>Colors</string>
+ </attribute>
+ <layout class="QGridLayout" name="gridLayout_2">
+ <item row="0" column="0" rowspan="2">
+ <widget class="QTreeWidget" name="itemList">
+ <property name="rootIsDecorated">
+ <bool>true</bool>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <column>
+ <property name="text">
+ <string>Items</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QGroupBox" name="aPaletteBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="focusPolicy">
+ <enum>Qt::NoFocus</enum>
+ </property>
+ <property name="title">
+ <string>Palette</string>
+ </property>
+ <property name="selectedId" stdset="0">
+ <number>0</number>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_1">
+ <item row="0" column="0">
+ <widget class="QPushButton" name="palette0">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QPushButton" name="palette1">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QPushButton" name="palette2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QPushButton" name="palette3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QPushButton" name="palette4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QPushButton" name="palette5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QPushButton" name="palette6">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QPushButton" name="palette7">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QPushButton" name="palette8">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QPushButton" name="palette9">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QPushButton" name="palette10">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QPushButton" name="palette11">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QPushButton" name="palette12">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QPushButton" name="palette13">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QPushButton" name="palette14">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="3">
+ <widget class="QPushButton" name="palette15">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>25</width>
+ <height>25</height>
+ </size>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QFrame" name="colorframe">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Sunken</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="addToPalette">
+ <property name="text">
+ <string>add to palette</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="1" colspan="2">
+ <layout class="QGridLayout">
+ <item row="0" column="1">
+ <widget class="QSpinBox" name="rval">
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QSlider" name="hslider">
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="textLabel3_2">
+ <property name="text">
+ <string>B</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="textLabel5_2">
+ <property name="text">
+ <string>S</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="textLabel4_2">
+ <property name="text">
+ <string>H</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QSpinBox" name="bval">
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="2">
+ <widget class="QSlider" name="vslider">
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="textLabel6_2">
+ <property name="text">
+ <string>V</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="textLabel2_2">
+ <property name="text">
+ <string>G</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QSpinBox" name="sval">
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QSlider" name="gslider">
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="2">
+ <widget class="QSlider" name="sslider">
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QSlider" name="bslider">
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="gval">
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QSlider" name="rslider">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="tracking">
+ <bool>true</bool>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="tickPosition">
+ <enum>QSlider::NoTicks</enum>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QSpinBox" name="vval">
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QSpinBox" name="hval">
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="textLabel1">
+ <property name="text">
+ <string>R</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Color name:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="colorNameLineEdit"/>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="1" colspan="2">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLabel" name="textLabel1_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Global opacity</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="globalAlphaVal">
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSlider" name="globalAlphaSlider">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>255</number>
+ </property>
+ <property name="tracking">
+ <bool>true</bool>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="tickPosition">
+ <enum>QSlider::NoTicks</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab3">
+ <attribute name="title">
+ <string>Style/Fonts</string>
+ </attribute>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QGroupBox" name="GroupBox18">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>QT Theme</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <spacer name="Spacer2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>190</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QLabel" name="label_41">
+ <property name="text">
+ <string>Style Sheet:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="styleSheetPath"/>
+ </item>
+ <item>
+ <widget class="QToolButton" name="openStyleSheet">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="defaultStyleSheet">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="spacer3">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="GroupBox6">
+ <property name="title">
+ <string>Fonts</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="0" column="1">
+ <widget class="QLabel" name="textLabel2">
+ <property name="text">
+ <string>Family</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLabel" name="TextLabel1_1">
+ <property name="text">
+ <string>Size</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="textLabel4">
+ <property name="text">
+ <string>Font 1</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="textLabel5">
+ <property name="text">
+ <string>Font 2</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="textLabel6">
+ <property name="text">
+ <string>Font 3</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLineEdit" name="fontName0">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="fontName1">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLineEdit" name="fontName2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QLineEdit" name="fontName3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="textLabel3">
+ <property name="text">
+ <string>Font 0</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QSpinBox" name="fontSize0">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QSpinBox" name="fontSize1">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QSpinBox" name="fontSize2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="2">
+ <widget class="QSpinBox" name="fontSize3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QCheckBox" name="bold1">
+ <property name="text">
+ <string>Bold</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="3">
+ <widget class="QCheckBox" name="bold2">
+ <property name="text">
+ <string>Bold</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="3">
+ <widget class="QCheckBox" name="bold3">
+ <property name="text">
+ <string>Bold</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QCheckBox" name="bold0">
+ <property name="text">
+ <string>Bold</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="4">
+ <widget class="QCheckBox" name="italic2">
+ <property name="text">
+ <string>Italic</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="4">
+ <widget class="QCheckBox" name="italic3">
+ <property name="text">
+ <string>Italic</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="4">
+ <widget class="QCheckBox" name="italic1">
+ <property name="text">
+ <string>Italic</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="4">
+ <widget class="QCheckBox" name="italic0">
+ <property name="text">
+ <string>Italic</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="5">
+ <widget class="QToolButton" name="fontBrowse0">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="5">
+ <widget class="QToolButton" name="fontBrowse1">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="5">
+ <widget class="QToolButton" name="fontBrowse2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="5">
+ <widget class="QToolButton" name="fontBrowse3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="textLabel7">
+ <property name="text">
+ <string>Font 4</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QLineEdit" name="fontName4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="textLabel7_2">
+ <property name="text">
+ <string>Font 5</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1">
+ <widget class="QLineEdit" name="fontName5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="0">
+ <widget class="QLabel" name="textLabel7_3">
+ <property name="text">
+ <string>Font 6</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="1">
+ <widget class="QLineEdit" name="fontName6">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="2">
+ <widget class="QSpinBox" name="fontSize6">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="3">
+ <widget class="QCheckBox" name="bold6">
+ <property name="text">
+ <string>Bold</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="4">
+ <widget class="QCheckBox" name="italic6">
+ <property name="text">
+ <string>Italic</string>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="5">
+ <widget class="QToolButton" name="fontBrowse6">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="2">
+ <widget class="QSpinBox" name="fontSize4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="2">
+ <widget class="QSpinBox" name="fontSize5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="3">
+ <widget class="QCheckBox" name="bold4">
+ <property name="text">
+ <string>Bold</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="3">
+ <widget class="QCheckBox" name="bold5">
+ <property name="text">
+ <string>Bold</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="4">
+ <widget class="QCheckBox" name="italic4">
+ <property name="text">
+ <string>Italic</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="4">
+ <widget class="QCheckBox" name="italic5">
+ <property name="text">
+ <string>Italic</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="5">
+ <widget class="QToolButton" name="fontBrowse4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="5">
+ <widget class="QToolButton" name="fontBrowse5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <spacer name="Spacer1">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="applyButton">
+ <property name="text">
+ <string>Apply</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton">
+ <property name="text">
+ <string>Ok</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <tabstops>
+ <tabstop>TabWidget2</tabstop>
+ <tabstop>itemList</tabstop>
+ <tabstop>palette0</tabstop>
+ <tabstop>palette1</tabstop>
+ <tabstop>palette2</tabstop>
+ <tabstop>palette3</tabstop>
+ <tabstop>palette4</tabstop>
+ <tabstop>palette5</tabstop>
+ <tabstop>palette6</tabstop>
+ <tabstop>palette7</tabstop>
+ <tabstop>palette8</tabstop>
+ <tabstop>palette9</tabstop>
+ <tabstop>palette10</tabstop>
+ <tabstop>palette11</tabstop>
+ <tabstop>palette12</tabstop>
+ <tabstop>palette13</tabstop>
+ <tabstop>palette14</tabstop>
+ <tabstop>palette15</tabstop>
+ <tabstop>addToPalette</tabstop>
+ <tabstop>rval</tabstop>
+ <tabstop>rslider</tabstop>
+ <tabstop>gval</tabstop>
+ <tabstop>gslider</tabstop>
+ <tabstop>bval</tabstop>
+ <tabstop>bslider</tabstop>
+ <tabstop>hval</tabstop>
+ <tabstop>hslider</tabstop>
+ <tabstop>sval</tabstop>
+ <tabstop>sslider</tabstop>
+ <tabstop>vval</tabstop>
+ <tabstop>vslider</tabstop>
+ <tabstop>applyButton</tabstop>
+ <tabstop>okButton</tabstop>
+ <tabstop>cancelButton</tabstop>
+ <tabstop>partShownames</tabstop>
+ <tabstop>partShowevents</tabstop>
+ <tabstop>partShowCakes</tabstop>
+ <tabstop>eventNoteon</tabstop>
+ <tabstop>eventPolypressure</tabstop>
+ <tabstop>eventController</tabstop>
+ <tabstop>eventAftertouch</tabstop>
+ <tabstop>eventPitchbend</tabstop>
+ <tabstop>eventProgramchange</tabstop>
+ <tabstop>eventSpecial</tabstop>
+ <tabstop>arrGrid</tabstop>
+ <tabstop>themeComboBox</tabstop>
+ <tabstop>styleSheetPath</tabstop>
+ <tabstop>openStyleSheet</tabstop>
+ <tabstop>fontName0</tabstop>
+ <tabstop>fontName1</tabstop>
+ <tabstop>fontName2</tabstop>
+ <tabstop>fontName3</tabstop>
+ <tabstop>fontSize0</tabstop>
+ <tabstop>fontSize1</tabstop>
+ <tabstop>fontSize2</tabstop>
+ <tabstop>fontSize3</tabstop>
+ <tabstop>bold1</tabstop>
+ <tabstop>bold2</tabstop>
+ <tabstop>bold3</tabstop>
+ <tabstop>bold0</tabstop>
+ <tabstop>italic2</tabstop>
+ <tabstop>italic3</tabstop>
+ <tabstop>italic1</tabstop>
+ <tabstop>italic0</tabstop>
+ <tabstop>fontName4</tabstop>
+ <tabstop>fontName5</tabstop>
+ <tabstop>fontSize4</tabstop>
+ <tabstop>fontSize5</tabstop>
+ <tabstop>bold4</tabstop>
+ <tabstop>bold5</tabstop>
+ <tabstop>italic4</tabstop>
+ <tabstop>italic5</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>rslider</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>rval</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>gslider</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>gval</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>bslider</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>bval</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>hslider</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>hval</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>sslider</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>sval</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>vslider</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>vval</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>rval</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>rslider</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>gval</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>gslider</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>bval</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>bslider</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>hval</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>hslider</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>sval</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>sslider</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>vval</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>vslider</receiver>
+ <slot>setValue(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/bigtime.cpp b/attic/muse2-oom/muse2/muse/widgets/bigtime.cpp
new file mode 100644
index 00000000..479f4103
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/bigtime.cpp
@@ -0,0 +1,448 @@
+#include <stdio.h>
+#include <values.h>
+
+#include <QCheckBox>
+#include <QLabel>
+#include <QResizeEvent>
+
+#include "globals.h"
+#include "bigtime.h"
+#include "song.h"
+#include "app.h"
+#include "gconfig.h"
+
+extern int mtcType;
+
+//
+// the bigtime widget
+// display is split into several parts to avoid flickering.
+//
+
+//---------------------------------------------------------
+// BigTime
+//---------------------------------------------------------
+
+BigTime::BigTime(QWidget* parent)
+ : QWidget(parent, Qt::Window | Qt::WindowStaysOnTopHint) // Possibly also Qt::X11BypassWindowManagerHint
+ {
+
+ tickmode = true;
+ dwin = new QWidget(this, Qt::WindowStaysOnTopHint); // Possibly also Qt::X11BypassWindowManagerHint
+ dwin->setObjectName("bigtime-dwin");
+ dwin->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
+ fmtButton = new QCheckBox(QString(""), this);
+ fmtButton->resize(18,18);
+ fmtButton->setChecked(true);
+ fmtButton->setToolTip(tr("format display"));
+ fmtButton->setFocusPolicy(Qt::NoFocus);
+ barLabel = new QLabel(dwin);
+ beatLabel = new QLabel(dwin);
+ tickLabel = new QLabel(dwin);
+ //hourLabel = new QLabel(dwin);
+ minLabel = new QLabel(dwin);
+ secLabel = new QLabel(dwin);
+ frameLabel = new QLabel(dwin);
+ subFrameLabel = new QLabel(dwin);
+ sep1 = new QLabel(QString("."), dwin);
+ sep2 = new QLabel(QString("."), dwin);
+ sep3 = new QLabel(QString(":"), dwin);
+ sep4 = new QLabel(QString(":"), dwin);
+ sep5 = new QLabel(QString(":"), dwin);
+ absTickLabel = new QLabel(dwin);
+ absFrameLabel = new QLabel(dwin);
+ barLabel->setToolTip(tr("bar"));
+ beatLabel->setToolTip(tr("beat"));
+ tickLabel->setToolTip(tr("tick"));
+ //hourLabel->setToolTip(tr("hour"));
+ minLabel->setToolTip(tr("minute"));
+ secLabel->setToolTip(tr("second"));
+ frameLabel->setToolTip(tr("frame"));
+ subFrameLabel->setToolTip(tr("subframe"));
+ absTickLabel->setToolTip(tr("tick"));
+ absFrameLabel->setToolTip(tr("frame"));
+ fmtButtonToggled(true);
+ connect(fmtButton, SIGNAL(toggled(bool)), SLOT(fmtButtonToggled(bool)));
+ //oldbar = oldbeat = oldtick = oldhour = oldmin = oldsec = oldframe = -1;
+ oldbar = oldbeat = oldtick = oldmin = oldsec = oldframe = oldsubframe = -1;
+ oldAbsTick = oldAbsFrame = -1;
+ setString(MAXINT);
+
+ dwin->setStyleSheet("font-size:10px; font-family:'Courier'; "); // Tim p4.0.8
+
+ configChanged();
+
+ //QFont f(QString("Courier"));
+ //f.setPixelSize(10);
+ //dwin->setFont(f);
+
+ setWindowTitle(tr("MusE: Bigtime"));
+ }
+
+
+//---------------------------------------------------------
+// fmtButtonToggled
+//---------------------------------------------------------
+
+void BigTime::fmtButtonToggled(bool v)
+{
+ if(v)
+ {
+ tickmode = true;
+
+ barLabel->setEnabled(true);
+ beatLabel->setEnabled(true);
+ tickLabel->setEnabled(true);
+ //hourLabel->setEnabled(true);
+ minLabel->setEnabled(true);
+ secLabel->setEnabled(true);
+ frameLabel->setEnabled(true);
+ subFrameLabel->setEnabled(true);
+ sep1->setEnabled(true);
+ sep2->setEnabled(true);
+ sep3->setEnabled(true);
+ sep4->setEnabled(true);
+ sep5->setEnabled(true);
+ absTickLabel->setEnabled(false);
+ absFrameLabel->setEnabled(false);
+
+ barLabel->show();
+ beatLabel->show();
+ tickLabel->show();
+ //hourLabel->show();
+ minLabel->show();
+ secLabel->show();
+ frameLabel->show();
+ subFrameLabel->show();
+ sep1->show();
+ sep2->show();
+ sep3->show();
+ sep4->show();
+ sep5->show();
+ absTickLabel->hide();
+ absFrameLabel->hide();
+ }
+ else
+ {
+ tickmode = false;
+
+ barLabel->setEnabled(false);
+ beatLabel->setEnabled(false);
+ tickLabel->setEnabled(false);
+ //hourLabel->setEnabled(false);
+ minLabel->setEnabled(false);
+ secLabel->setEnabled(false);
+ frameLabel->setEnabled(false);
+ subFrameLabel->setEnabled(false);
+ sep1->setEnabled(false);
+ sep2->setEnabled(false);
+ sep3->setEnabled(false);
+ sep4->setEnabled(false);
+ sep5->setEnabled(false);
+ absTickLabel->setEnabled(true);
+ absFrameLabel->setEnabled(true);
+
+ barLabel->hide();
+ beatLabel->hide();
+ tickLabel->hide();
+ //hourLabel->hide();
+ minLabel->hide();
+ secLabel->hide();
+ frameLabel->hide();
+ subFrameLabel->hide();
+ sep1->hide();
+ sep2->hide();
+ sep3->hide();
+ sep4->hide();
+ sep5->hide();
+ absTickLabel->show();
+ absFrameLabel->show();
+ }
+}
+
+//---------------------------------------------------------
+// configChanged
+//---------------------------------------------------------
+
+void BigTime::configChanged()
+ {
+ setBgColor(config.bigTimeBackgroundColor);
+ setFgColor(config.bigTimeForegroundColor);
+ }
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void BigTime::closeEvent(QCloseEvent *ev)
+ {
+ emit closed();
+ QWidget::closeEvent(ev);
+ }
+
+//---------------------------------------------------------
+// setString
+//---------------------------------------------------------
+
+bool BigTime::setString(unsigned v)
+ {
+ if (v == MAXINT) {
+ barLabel->setText(QString("----"));
+ beatLabel->setText(QString("--"));
+ tickLabel->setText(QString("---"));
+ //hourLabel->setText(QString("--"));
+ //minLabel->setText(QString("--"));
+ minLabel->setText(QString("---"));
+ secLabel->setText(QString("--"));
+ frameLabel->setText(QString("--"));
+ subFrameLabel->setText(QString("--"));
+
+ absTickLabel->setText(QString("----------"));
+ absFrameLabel->setText(QString("----------"));
+ oldAbsTick = oldAbsFrame = -1;
+ //oldbar = oldbeat = oldtick = oldhour = oldmin = oldsec = oldframe = -1;
+ oldbar = oldbeat = oldtick = oldmin = oldsec = oldframe = oldsubframe = -1;
+ return true;
+ }
+
+ unsigned absFrame = tempomap.tick2frame(v);
+ int bar, beat;
+ unsigned tick;
+ AL::sigmap.tickValues(v, &bar, &beat, &tick);
+ double time = double(absFrame)/double(sampleRate);
+ //int hour = int(time) / 3600;
+ //int min = (int(time) / 60) % 60;
+ int min = int(time) / 60;
+ int sec = int(time) % 60;
+ double rest = time - (min * 60 + sec);
+ switch(mtcType) {
+ case 0: // 24 frames sec
+ rest *= 24;
+ break;
+ case 1: // 25
+ rest *= 25;
+ break;
+ case 2: // 30 drop frame
+ rest *= 30;
+ break;
+ case 3: // 30 non drop frame
+ rest *= 30;
+ break;
+ }
+ int frame = int(rest);
+ int subframe = int((rest-frame)*100);
+
+ QString s;
+
+ if(oldAbsTick != v) {
+ s.sprintf("%010d", v);
+ absTickLabel->setText(s);
+ oldAbsTick = v;
+ }
+ if(oldAbsFrame != absFrame) {
+ s.sprintf("%010d", absFrame);
+ absFrameLabel->setText(s);
+ oldAbsFrame = absFrame;
+ }
+ if(oldbar != bar) {
+ s.sprintf("%04d", bar+1);
+ barLabel->setText(s);
+ oldbar = bar;
+ }
+ if(oldbeat != beat) {
+ s.sprintf("%02d", beat+1);
+ beatLabel->setText(s);
+ oldbeat = beat;
+ }
+
+ if(oldtick != tick) {
+ s.sprintf("%03d", tick);
+ tickLabel->setText(s);
+ oldtick = tick;
+ }
+
+ //if(oldhour != hour) {
+ // s.sprintf("%02d", hour);
+ // hourLabel->setText(s);
+ // oldhour = hour;
+ //}
+
+ if(oldmin != min) {
+ //s.sprintf("%02d", min);
+ s.sprintf("%03d", min);
+ minLabel->setText(s);
+ oldmin = min;
+ }
+
+ if(oldsec != sec) {
+ s.sprintf("%02d", sec);
+ secLabel->setText(s);
+ oldsec = sec;
+ }
+
+ if(oldframe != frame) {
+ s.sprintf("%02d", frame);
+ frameLabel->setText(s);
+ oldframe = frame;
+ }
+
+ if(oldsubframe != subframe) {
+ s.sprintf("%02u", subframe);
+ subFrameLabel->setText(s);
+ oldsubframe = subframe;
+ }
+
+ return false;
+ }
+
+//---------------------------------------------------------
+// setPos
+//---------------------------------------------------------
+
+void BigTime::setPos(int idx, unsigned v, bool)
+ {
+ if (idx == 0)
+ setString(v);
+ }
+
+//---------------------------------------------------------
+// resizeEvent
+//---------------------------------------------------------
+
+void BigTime::resizeEvent(QResizeEvent *ev)
+ {
+ dwin->resize(ev->size());
+ QFont f = dwin->font();
+ QFontMetrics fm(f);
+ int fs = f.pixelSize();
+ int hspace = 20;
+ //int tw = fm.width(QString("00:00:00:00"));
+ int tw = fm.width(QString("000:00:00:00"));
+
+ fs = ((ev->size().width() - hspace*2)*fs) / tw;
+
+ // set min/max
+ if (fs < 10)
+ fs = 10;
+ else if (fs > 256)
+ fs = 256;
+
+ //if(debugMsg)
+ // printf("resize BigTime: Font name:%s CurSize:%d NewSize:%d, NewWidth:%d\n",
+ // f.family().toLatin1().constData(), fs, nfs, ev->size().width());
+
+ //f.setPixelSize(fs);
+
+ //dwin->setFont(f);
+ QString fstr = QString("font-size:%1px; font-family:'Courier'; ").arg(fs); // Tim p4.0.8
+ dwin->setStyleSheet(fstr);
+ setBgColor(config.bigTimeBackgroundColor);
+ setFgColor(config.bigTimeForegroundColor);
+
+ int digitWidth = dwin->fontMetrics().width(QString("0"));
+ int vspace = (ev->size().height() - (fs*2)) / 3;
+ int tickY = vspace;
+
+ int timeY = vspace*2 + fs;
+ int absTickY = tickY;
+ int absFrameY = timeY;
+ barLabel->resize(digitWidth*4, fs);
+ beatLabel->resize(digitWidth*2, fs);
+ tickLabel->resize(digitWidth*3, fs);
+ //hourLabel->resize(digitWidth*2, fs);
+ //minLabel->resize(digitWidth*2, fs);
+ minLabel->resize(digitWidth*3, fs);
+ secLabel->resize(digitWidth*2, fs);
+ frameLabel->resize(digitWidth*2, fs);
+ subFrameLabel->resize(digitWidth*2, fs);
+
+ absTickLabel->resize(digitWidth*10, fs);
+ absFrameLabel->resize(digitWidth*10, fs);
+ sep1->resize(digitWidth, fs);
+ sep2->resize(digitWidth, fs);
+ sep3->resize(digitWidth, fs);
+ sep4->resize(digitWidth, fs);
+ sep5->resize(digitWidth, fs);
+
+ barLabel->move( hspace + (digitWidth*0), tickY);
+ sep1->move( hspace + (digitWidth*4), tickY);
+ beatLabel->move( hspace + (digitWidth*5), tickY);
+ sep2->move( hspace + (digitWidth*7), tickY);
+ tickLabel->move( hspace + (digitWidth*8), tickY);
+
+ //hourLabel->move( hspace + (digitWidth*0), timeY);
+ //sep3->move( hspace + (digitWidth*2), timeY);
+ //minLabel->move( hspace + (digitWidth*3), timeY);
+ //sep4->move( hspace + (digitWidth*5), timeY);
+ //secLabel->move( hspace + (digitWidth*6), timeY);
+ //sep5->move( hspace + (digitWidth*8), timeY);
+ //frameLabel->move( hspace + (digitWidth*9), timeY);
+ minLabel->move( hspace + (digitWidth*0), timeY);
+ sep3->move( hspace + (digitWidth*3), timeY);
+ secLabel->move( hspace + (digitWidth*4), timeY);
+ sep4->move( hspace + (digitWidth*6), timeY);
+ frameLabel->move( hspace + (digitWidth*7), timeY);
+ sep5->move( hspace + (digitWidth*9), timeY);
+ subFrameLabel->move( hspace + (digitWidth*10), timeY);
+
+ absTickLabel->move( hspace + (digitWidth*0), absTickY);
+ absFrameLabel->move( hspace + (digitWidth*0), absFrameY);
+ }
+
+//---------------------------------------------------------
+// setForegroundColor
+//---------------------------------------------------------
+
+void BigTime::setFgColor(QColor c)
+ {
+ QPalette newpalette(palette());
+ newpalette.setColor(QPalette::Foreground, c);
+ setPalette(newpalette);
+
+ barLabel->setPalette(newpalette);
+ beatLabel->setPalette(newpalette);
+ tickLabel->setPalette(newpalette);
+ //hourLabel->setPalette(newpalette);
+ minLabel->setPalette(newpalette);
+ secLabel->setPalette(newpalette);
+ frameLabel->setPalette(newpalette);
+ subFrameLabel->setPalette(newpalette);
+
+ absTickLabel->setPalette(newpalette);
+ absFrameLabel->setPalette(newpalette);
+ sep1->setPalette(newpalette);
+ sep2->setPalette(newpalette);
+ sep3->setPalette(newpalette);
+ sep4->setPalette(newpalette);
+ sep5->setPalette(newpalette);
+ }
+
+//---------------------------------------------------------
+// setBackgroundColor
+//---------------------------------------------------------
+
+void BigTime::setBgColor(QColor c)
+ {
+ QPalette newpalette(palette());
+ newpalette.setColor(QPalette::Window, c);
+ setPalette(newpalette);
+
+ barLabel->setPalette(newpalette);
+ beatLabel->setPalette(newpalette);
+ tickLabel->setPalette(newpalette);
+ //hourLabel->setPalette(newpalette);
+ minLabel->setPalette(newpalette);
+ secLabel->setPalette(newpalette);
+ frameLabel->setPalette(newpalette);
+ subFrameLabel->setPalette(newpalette);
+
+ absTickLabel->setPalette(newpalette);
+ absFrameLabel->setPalette(newpalette);
+ sep1->setPalette(newpalette);
+ sep2->setPalette(newpalette);
+ sep3->setPalette(newpalette);
+ sep4->setPalette(newpalette);
+ sep5->setPalette(newpalette);
+
+ setPalette(newpalette);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/bigtime.h b/attic/muse2-oom/muse2/muse/widgets/bigtime.h
new file mode 100644
index 00000000..bb32cedc
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/bigtime.h
@@ -0,0 +1,53 @@
+#ifndef __BIGTIME_H__
+#define __BIGTIME_H__
+
+#include <QWidget>
+
+class QCheckBox;
+class QLabel;
+
+class MusE;
+
+//---------------------------------------------------------
+// BigTime
+//---------------------------------------------------------
+
+class BigTime : public QWidget {
+ bool tickmode;
+ MusE* seq;
+ Q_OBJECT
+
+ bool setString(unsigned);
+
+ QWidget *dwin;
+ QCheckBox *fmtButton;
+ QLabel *absTickLabel;
+ QLabel *absFrameLabel;
+ QLabel *barLabel, *beatLabel, *tickLabel,
+ //*hourLabel, *minLabel, *secLabel, *frameLabel,
+ *minLabel, *secLabel, *frameLabel, *subFrameLabel,
+ *sep1, *sep2, *sep3, *sep4, *sep5;
+
+ //int oldbar, oldbeat, oldhour, oldmin, oldsec, oldframe;
+ int oldbar, oldbeat, oldmin, oldsec, oldframe, oldsubframe;
+ unsigned oldtick;
+ unsigned oldAbsTick, oldAbsFrame;
+ void setFgColor(QColor c);
+ void setBgColor(QColor c);
+
+ protected:
+ virtual void resizeEvent(QResizeEvent*);
+ virtual void closeEvent(QCloseEvent*);
+
+ public slots:
+ void setPos(int, unsigned, bool);
+ void configChanged();
+ void fmtButtonToggled(bool);
+ signals:
+ void closed();
+
+ public:
+ BigTime(QWidget* parent);
+ };
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/canvas.cpp b/attic/muse2-oom/muse2/muse/widgets/canvas.cpp
new file mode 100644
index 00000000..4ea5f568
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/canvas.cpp
@@ -0,0 +1,1463 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: canvas.cpp,v 1.10.2.17 2009/05/03 04:14:01 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+
+#include "canvas.h"
+
+#include <QApplication>
+#include <QMenu>
+#include <QPainter>
+#include <QCursor>
+#include <QTimer>
+#include <QKeyEvent>
+#include <QMouseEvent>
+#include <QWheelEvent>
+
+#include "song.h"
+#include "event.h"
+#include "citem.h"
+#include "icons.h"
+#include "../marker/marker.h"
+#include "part.h"
+
+#define ABS(x) ((x) < 0) ? -(x) : (x)
+
+//---------------------------------------------------------
+// Canvas
+//---------------------------------------------------------
+
+Canvas::Canvas(QWidget* parent, int sx, int sy, const char* name)
+ : View(parent, sx, sy, name)
+ {
+ canvasTools = 0;
+ itemPopupMenu = 0;
+
+ button = Qt::NoButton;
+ keyState = 0;
+
+ canScrollLeft = true;
+ canScrollRight = true;
+ canScrollUp = true;
+ canScrollDown = true;
+ hscrollDir = HSCROLL_NONE;
+ vscrollDir = VSCROLL_NONE;
+ scrollTimer=NULL;
+
+ scrollSpeed=10; // hardcoded scroll jump
+
+ drag = DRAG_OFF;
+ _tool = PointerTool;
+ pos[0] = song->cpos();
+ pos[1] = song->lpos();
+ pos[2] = song->rpos();
+ curPart = NULL;
+ curPartId = -1;
+ curItem = NULL;
+ connect(song, SIGNAL(posChanged(int, unsigned, bool)), this, SLOT(setPos(int, unsigned, bool)));
+ }
+
+//---------------------------------------------------------
+// setPos
+// set one of three markers
+// idx - 0-cpos 1-lpos 2-rpos
+// flag - emit followEvent()
+//---------------------------------------------------------
+
+void Canvas::setPos(int idx, unsigned val, bool adjustScrollbar)
+ {
+ //if (pos[idx] == val) // Seems to be some refresh problems here, pos[idx] might be val but the gui not updated.
+ // return; // skipping this return forces update even if values match. Matching values only seem
+ // to occur when initializing
+ int opos = mapx(pos[idx]);
+ int npos = mapx(val);
+
+ if (adjustScrollbar && idx == 0) {
+ switch (song->follow()) {
+ case Song::NO:
+ break;
+ case Song::JUMP:
+ if (npos >= width()) {
+ int ppos = val - xorg - rmapxDev(width()/8);
+ if (ppos < 0)
+ ppos = 0;
+ emit followEvent(ppos);
+ opos = mapx(pos[idx]);
+ npos = mapx(val);
+ }
+ else if (npos < 0) {
+ int ppos = val - xorg - rmapxDev(width()*3/4);
+ if (ppos < 0)
+ ppos = 0;
+ emit followEvent(ppos);
+ opos = mapx(pos[idx]);
+ npos = mapx(val);
+ }
+ break;
+ case Song::CONTINUOUS:
+ if (npos > (width()/2)) {
+ int ppos = pos[idx] - xorg - rmapxDev(width()/2);
+ if (ppos < 0)
+ ppos = 0;
+ emit followEvent(ppos);
+ opos = mapx(pos[idx]);
+ npos = mapx(val);
+ }
+ else if (npos < (width()/2)) {
+ int ppos = pos[idx] - xorg - rmapxDev(width()/2);
+ if (ppos < 0)
+ ppos = 0;
+ emit followEvent(ppos);
+ opos = mapx(pos[idx]);
+ npos = mapx(val);
+ }
+ break;
+ }
+ }
+
+ int x;
+ int w = 1;
+ if (opos > npos) {
+ w += opos - npos;
+ x = npos;
+ }
+ else {
+ w += npos - opos;
+ x = opos;
+ }
+ pos[idx] = val;
+ redraw(QRect(x-1, 0, w+2, height()));
+ }
+
+//---------------------------------------------------------
+// draw
+//---------------------------------------------------------
+
+void Canvas::draw(QPainter& p, const QRect& rect)
+{
+// printf("draw canvas %x virt %d\n", this, virt());
+
+ int x = rect.x();
+ int y = rect.y();
+ int w = rect.width();
+ int h = rect.height();
+ int x2 = x + w;
+
+ if (virt()) {
+ drawCanvas(p, rect);
+
+ //---------------------------------------------------
+ // draw Canvas Items
+ //---------------------------------------------------
+
+ iCItem to(items.lower_bound(x2));
+
+ // Draw items from other parts behind all others.
+ // Only for items with events (not arranger parts).
+ for(iCItem i = items.begin(); i != to; ++i)
+ {
+ CItem* ci = i->second;
+ if(!ci->event().empty() && ci->part() != curPart)
+ {
+ drawItem(p, ci, rect);
+ }
+ }
+
+ for (iCItem i = items.begin(); i != to; ++i)
+ {
+ CItem* ci = i->second;
+ // Draw unselected parts behind selected.
+ if(!ci->isSelected() && !ci->isMoving() && (ci->event().empty() || ci->part() == curPart))
+ {
+ drawItem(p, ci, rect);
+ }
+ }
+
+ // Draw selected parts in front of unselected.
+ for (iCItem i = items.begin(); i != to; ++i)
+ {
+ CItem* ci = i->second;
+ if(ci->isSelected() && !ci->isMoving() && (ci->event().empty() || ci->part() == curPart))
+ {
+ drawItem(p, ci, rect);
+ }
+ }
+ to = moving.lower_bound(x2);
+ for (iCItem i = moving.begin(); i != to; ++i)
+ {
+ drawItem(p, i->second, rect);
+ }
+ }
+ else {
+ p.save();
+ setPainter(p);
+
+ if (xmag <= 0) {
+ x -= 1;
+ w += 2;
+ x = (x + xpos + rmapx(xorg)) * (-xmag);
+ w = w * (-xmag);
+ }
+ else {
+ x = (x + xpos + rmapx(xorg)) / xmag;
+ w = (w + xmag - 1) / xmag;
+ x -= 1;
+ w += 2;
+ }
+ if (ymag <= 0) {
+ y -= 1;
+ h += 2;
+ y = (y + ypos + rmapy(yorg)) * (-ymag);
+ h = h * (-ymag);
+ }
+ else {
+ y = (rect.y() + ypos + rmapy(yorg))/ymag;
+ h = (rect.height()+ymag-1)/ymag;
+ y -= 1;
+ h += 2;
+ }
+
+ if (x < 0)
+ x = 0;
+ if (y < 0)
+ y = 0;
+ x2 = x + w;
+
+ drawCanvas(p, QRect(x, y, w, h));
+ p.restore();
+
+ //---------------------------------------------------
+ // draw Canvas Items
+ //---------------------------------------------------
+
+ // Draw items from other parts behind all others.
+ // Only for items with events (not arranger parts).
+ for(iCItem i = items.begin(); i != items.end(); ++i)
+ {
+ CItem* ci = i->second;
+ if(!ci->event().empty() && ci->part() != curPart)
+ {
+ drawItem(p, ci, rect);
+ }
+ }
+
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ CItem* ci = i->second;
+ // Draw unselected parts behind selected.
+ if(!ci->isSelected() && !ci->isMoving() && (ci->event().empty() || ci->part() == curPart))
+ {
+ drawItem(p, ci, rect);
+ }
+ }
+
+ // Draw selected parts in front of unselected.
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ CItem* ci = i->second;
+ if(ci->isSelected() && !ci->isMoving() && (ci->event().empty() || ci->part() == curPart))
+ {
+ drawItem(p, ci, rect);
+ }
+ }
+ for (iCItem i = moving.begin(); i != moving.end(); ++i)
+ {
+ drawItem(p, i->second, rect);
+ }
+ p.save();
+ setPainter(p);
+ }
+
+ //---------------------------------------------------
+ // draw marker
+ //---------------------------------------------------
+
+ int y2 = y + h;
+ MarkerList* marker = song->marker();
+ for (iMarker m = marker->begin(); m != marker->end(); ++m) {
+ int xp = m->second.tick();
+ if (xp >= x && xp < x+w) {
+ p.setPen(Qt::green);
+ p.drawLine(xp, y, xp, y2);
+ }
+ }
+
+ // //---------------------------------------------------
+ // // draw location marker
+ // //---------------------------------------------------
+
+ // p.setPen(Qt::blue);
+ // if (pos[1] >= unsigned(x) && pos[1] < unsigned(x2))
+ // {
+ // p.drawLine(pos[1], y, pos[1], y2);
+ // }
+ // if (pos[2] >= unsigned(x) && pos[2] < unsigned(x2))
+ // p.drawLine(pos[2], y, pos[2], y2);
+ //
+ // QPen playbackPen(QColor(51,56,55), 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin);
+ // p.setPen(playbackPen);
+ // //p.setPen(Qt::red);
+
+ // if (pos[0] >= unsigned(x) && pos[0] < unsigned(x2))
+ // {
+ // p.drawLine(pos[0], y, pos[0], y2);
+ // }
+ //
+
+ //---------------------------------------------------
+ // draw lasso
+ //---------------------------------------------------
+
+ if (drag == DRAG_LASSO)
+ {
+ p.setPen(QColor(181,109,16));
+ p.setBrush(Qt::NoBrush);
+ p.drawRect(lasso);
+ }
+
+ //---------------------------------------------------
+ // draw moving items
+ //---------------------------------------------------
+
+ if(virt())
+ {
+ for(iCItem i = moving.begin(); i != moving.end(); ++i)
+ drawMoving(p, i->second, rect);
+ }
+ else
+ {
+ p.restore();
+ for(iCItem i = moving.begin(); i != moving.end(); ++i)
+ drawMoving(p, i->second, rect);
+ setPainter(p);
+ }
+ //---------------------------------------------------
+ // draw location marker
+ //---------------------------------------------------
+
+ //p.setPen(Qt::blue);
+ p.setPen(QColor(139,225,69));
+ if (pos[1] >= unsigned(x) && pos[1] < unsigned(x2))
+ {
+ p.drawLine(pos[1], y, pos[1], y2);
+ }
+ if (pos[2] >= unsigned(x) && pos[2] < unsigned(x2))
+ p.drawLine(pos[2], y, pos[2], y2);
+
+ //QPen playbackPen(QColor(8,193,156), 1);
+ //p.setPen(playbackPen);
+ //p.setPen(Qt::green);
+ p.setPen(QColor(0,186,255));
+
+ if (pos[0] >= unsigned(x) && pos[0] < unsigned(x2))
+ {
+ p.drawLine(pos[0], y, pos[0], y2);
+ }
+
+}
+
+#define WHEEL_STEPSIZE 40
+#define WHEEL_DELTA 120
+
+//---------------------------------------------------------
+// wheelEvent
+//---------------------------------------------------------
+void Canvas::wheelEvent(QWheelEvent* ev)
+ {
+ int delta = ev->delta() / WHEEL_DELTA;
+ int ypixelscale = rmapyDev(1);
+
+ if (ypixelscale <= 0)
+ ypixelscale = 1;
+
+ int scrollstep = WHEEL_STEPSIZE * (-delta);
+ ///if (ev->state() == Qt::ShiftModifier)
+ if (((QInputEvent*)ev)->modifiers() == Qt::ShiftModifier)
+ scrollstep = scrollstep / 10;
+
+ int newYpos = ypos + ypixelscale * scrollstep;
+
+ if (newYpos < 0)
+ newYpos = 0;
+
+ //setYPos(newYpos);
+ emit verticalScroll((unsigned)newYpos);
+
+}
+
+void Canvas::redirectedWheelEvent(QWheelEvent* ev)
+{
+ wheelEvent(ev);
+}
+
+//---------------------------------------------------------
+// deselectAll
+//---------------------------------------------------------
+
+void Canvas::deselectAll()
+{
+ for (iCItem i = items.begin(); i != items.end(); ++i)
+ i->second->setSelected(false);
+}
+
+//---------------------------------------------------------
+// selectItem
+//---------------------------------------------------------
+
+void Canvas::selectItem(CItem* e, bool flag)
+{
+ e->setSelected(flag);
+}
+
+//---------------------------------------------------------
+// startMoving
+// copy selection-List to moving-List
+//---------------------------------------------------------
+
+void Canvas::startMoving(const QPoint& pos, DragType)
+{
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ if (i->second->isSelected()) {
+ i->second->setMoving(true);
+ moving.add(i->second);
+ }
+ }
+ moveItems(pos, 0);
+}
+
+//---------------------------------------------------------
+// moveItems
+// dir = 0 move in all directions
+// 1 move only horizontal
+// 2 move only vertical
+//---------------------------------------------------------
+
+void Canvas::moveItems(const QPoint& pos, int dir = 0, bool rasterize)
+{
+ int dp;
+ if(rasterize)
+ dp = y2pitch(pos.y()) - y2pitch(start.y());
+ else
+ dp = pos.y() - start.y();
+ int dx = pos.x() - start.x();
+ if (dir == 1)
+ dp = 0;
+ else if (dir == 2)
+ dx = 0;
+ for (iCItem i = moving.begin(); i != moving.end(); ++i) {
+ int x = i->second->pos().x();
+ int y = i->second->pos().y();
+ int nx = x + dx;
+ int ny;
+ QPoint mp;
+ if(rasterize)
+ {
+ ny = pitch2y(y2pitch(y) + dp);
+ mp = raster(QPoint(nx, ny));
+ }
+ else
+ {
+ ny = y + dp;
+ mp = QPoint(nx, ny);
+ }
+ if (i->second->mp() != mp)
+ {
+ i->second->setMp(mp);
+ itemMoved(i->second, mp);
+ }
+ }
+ redraw();
+}
+
+//---------------------------------------------------------
+// viewKeyPressEvent
+//---------------------------------------------------------
+
+void Canvas::viewKeyPressEvent(QKeyEvent* event)
+ {
+ keyPress(event);
+ }
+
+//---------------------------------------------------------
+// viewMousePressEvent
+//---------------------------------------------------------
+
+void Canvas::viewMousePressEvent(QMouseEvent* event)
+ {
+ ///keyState = event->state();
+ keyState = ((QInputEvent*)event)->modifiers();
+ button = event->button();
+
+ //printf("viewMousePressEvent buttons:%x mods:%x button:%x\n", (int)event->buttons(), (int)keyState, event->button());
+
+ // special events if right button is clicked while operations
+ // like moving or drawing lasso is performed.
+ ///if (event->stateAfter() & Qt::RightButton) {
+ if (event->buttons() & Qt::RightButton & ~(event->button())) {
+ //printf("viewMousePressEvent special buttons:%x mods:%x button:%x\n", (int)event->buttons(), (int)keyState, event->button());
+ switch (drag) {
+ case DRAG_LASSO:
+ drag = DRAG_OFF;
+ redraw();
+ return;
+ case DRAG_MOVE:
+ drag = DRAG_OFF;
+ endMoveItems (start, MOVE_MOVE, 0);
+ return;
+ default:
+ break;
+ }
+ }
+
+ // ignore event if (another) button is already active:
+ ///if (keyState & (Qt::LeftButton|Qt::RightButton|Qt::MidButton)) {
+ if (event->buttons() & (Qt::LeftButton|Qt::RightButton|Qt::MidButton) & ~(event->button())) {
+ //printf("viewMousePressEvent ignoring buttons:%x mods:%x button:%x\n", (int)event->buttons(), (int)keyState, event->button());
+ return;
+ }
+ bool shift = keyState & Qt::ShiftModifier;
+ bool alt = keyState & Qt::AltModifier;
+ bool ctrl = keyState & Qt::ControlModifier;
+ start = event->pos();
+
+ //---------------------------------------------------
+ // set curItem to item mouse is pointing
+ // (if any)
+ //---------------------------------------------------
+
+ if (virt())
+ curItem = items.find(start);
+ else {
+ curItem = 0;
+ iCItem ius;
+ bool usfound = false;
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ QRect box = i->second->bbox();
+ int x = rmapxDev(box.x());
+ int y = rmapyDev(box.y());
+ int w = rmapxDev(box.width());
+ int h = rmapyDev(box.height());
+ QRect r(x, y, w, h);
+ ///r.moveBy(i->second->pos().x(), i->second->pos().y());
+ r.translate(i->second->pos().x(), i->second->pos().y());
+ if (r.contains(start)) {
+ if(i->second->isSelected())
+ {
+ curItem = i->second;
+ break;
+ }
+ else
+ if(!usfound)
+ {
+ ius = i;
+ usfound = true;
+ }
+ }
+ }
+ if(!curItem && usfound)
+ curItem = ius->second;
+ }
+
+ if (curItem && (event->button() == Qt::MidButton)) {
+ if (!curItem->isSelected()) {
+ selectItem(curItem, true);
+ updateSelection();
+ redraw();
+ }
+ startDrag(curItem, shift);
+ }
+ else if (event->button() == Qt::RightButton) {
+ if (curItem) {
+ if (shift) {
+ drag = DRAG_RESIZE;
+ setCursor();
+ int dx = start.x() - curItem->x();
+ curItem->setWidth(dx);
+ start.setX(curItem->x());
+ deselectAll();
+ selectItem(curItem, true);
+ updateSelection();
+ redraw();
+ }
+ else {
+ itemPopupMenu = genItemPopup(curItem);
+ if (itemPopupMenu) {
+ QAction *act = itemPopupMenu->exec(QCursor::pos());
+ if (act)
+ itemPopup(curItem, act->data().toInt(), start);
+ delete itemPopupMenu;
+ }
+ }
+ }
+ else {
+ canvasPopupMenu = genCanvasPopup();
+ if (canvasPopupMenu) {
+ QAction *act = canvasPopupMenu->exec(QCursor::pos(), 0);
+ if (act)
+ canvasPopup(act->data().toInt());
+ delete canvasPopupMenu;
+ }
+ }
+ }
+ else if (event->button() == Qt::LeftButton) {
+ switch (_tool) {
+ case PointerTool:
+ if (curItem) {
+ if (curItem->part() != curPart) {
+ curPart = curItem->part();
+ curPartId = curPart->sn();
+ curPartChanged();
+ }
+ itemPressed(curItem);
+ // Changed by T356. Alt is default reserved for moving the whole window in KDE. Changed to Shift-Alt.
+ // Hmm, nope, shift-alt is also reserved sometimes. Must find a way to bypass,
+ // why make user turn off setting? Left alone for now...
+ if (shift)
+ drag = DRAG_COPY_START;
+ else if (alt) {
+ drag = DRAG_CLONE_START;
+ }
+ //
+ //if (shift)
+ //{
+ // if (alt)
+ // drag = DRAG_CLONE_START;
+ // else
+ // drag = DRAG_COPY_START;
+ //}
+ else if (ctrl) { //Select all on the same pitch (e.g. same y-value)
+ deselectAll();
+ //printf("Yes, ctrl and press\n");
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ if (i->second->y() == curItem->y() )
+ selectItem(i->second, true);
+ }
+ updateSelection();
+ redraw();
+ }
+ else
+ drag = DRAG_MOVE_START;
+ }
+ else
+ drag = DRAG_LASSO_START;
+ setCursor();
+ break;
+
+ case RubberTool:
+ deleteItem(start);
+ drag = DRAG_DELETE;
+ setCursor();
+ break;
+
+ case PencilTool:
+ if (curItem) {
+ drag = DRAG_RESIZE;
+ setCursor();
+ int dx = start.x() - curItem->x();
+ curItem->setWidth(dx);
+ start.setX(curItem->x());
+ }
+ else {
+ drag = DRAG_NEW;
+ setCursor();
+ curItem = newItem(start, event->modifiers());
+ if (curItem)
+ items.add(curItem);
+ else {
+ drag = DRAG_OFF;
+ setCursor();
+ }
+ }
+ deselectAll();
+ if (curItem)
+ selectItem(curItem, true);
+ updateSelection();
+ redraw();
+ break;
+
+ default:
+ break;
+ }
+ }
+ mousePress(event);
+ }
+
+void Canvas::scrollTimerDone()
+{
+ //printf("Canvas::scrollTimerDone drag:%d doScroll:%d\n", drag, doScroll);
+
+ if (drag != DRAG_OFF && doScroll)
+ {
+ //printf("Canvas::scrollTimerDone drag != DRAG_OFF && doScroll\n");
+
+ bool doHMove = false;
+ bool doVMove = false;
+ int hoff = rmapx(xOffset())+mapx(xorg)-1;
+ int curxpos;
+ switch(hscrollDir)
+ {
+ case HSCROLL_RIGHT:
+ hoff += scrollSpeed;
+ switch(drag)
+ {
+ case DRAG_NEW:
+ case DRAG_RESIZE:
+ case DRAGX_MOVE:
+ case DRAGX_COPY:
+ case DRAGX_CLONE:
+ case DRAGY_MOVE:
+ case DRAGY_COPY:
+ case DRAGY_CLONE:
+ case DRAG_MOVE:
+ case DRAG_COPY:
+ case DRAG_CLONE:
+ emit horizontalScrollNoLimit(hoff);
+ canScrollLeft = true;
+ ev_pos.setX(rmapxDev(rmapx(ev_pos.x()) + scrollSpeed));
+ doHMove = true;
+ break;
+ default:
+ if(canScrollRight)
+ {
+ curxpos = xpos;
+ emit horizontalScroll(hoff);
+ if(xpos <= curxpos)
+ {
+ canScrollRight = false;
+ }
+ else
+ {
+ canScrollLeft = true;
+ ev_pos.setX(rmapxDev(rmapx(ev_pos.x()) + scrollSpeed));
+ doHMove = true;
+ }
+ }
+ else
+ {
+ }
+ break;
+ }
+ break;
+ case HSCROLL_LEFT:
+ if(canScrollLeft)
+ {
+ curxpos = xpos;
+ hoff -= scrollSpeed;
+ emit horizontalScroll(hoff);
+ if(xpos >= curxpos)
+ {
+ canScrollLeft = false;
+ }
+ else
+ {
+ canScrollRight = true;
+ ev_pos.setX(rmapxDev(rmapx(ev_pos.x()) - scrollSpeed));
+ doHMove = true;
+ }
+ }
+ else
+ {
+ }
+ break;
+ default:
+ break;
+ }
+ int voff = rmapy(yOffset())+mapy(yorg);
+ int curypos;
+ switch(vscrollDir)
+ {
+ case VSCROLL_DOWN:
+ if(canScrollDown)
+ {
+ curypos = ypos;
+ voff += scrollSpeed;
+ emit verticalScroll(voff);
+ if(ypos <= curypos)
+ {
+ canScrollDown = false;
+ }
+ else
+ {
+ canScrollUp = true;
+ ev_pos.setY(rmapyDev(rmapy(ev_pos.y()) + scrollSpeed));
+ doVMove = true;
+ }
+ }
+ else
+ {
+ }
+ break;
+ case VSCROLL_UP:
+ if(canScrollUp)
+ {
+ curypos = ypos;
+ voff -= scrollSpeed;
+ emit verticalScroll(voff);
+ if(ypos >= curypos)
+ {
+ canScrollUp = false;
+ }
+ else
+ {
+ canScrollDown = true;
+ ev_pos.setY(rmapyDev(rmapy(ev_pos.y()) - scrollSpeed));
+ doVMove = true;
+ }
+ }
+ else
+ {
+ }
+ break;
+ default:
+ break;
+ }
+
+ //printf("Canvas::scrollTimerDone doHMove:%d doVMove:%d\n", doHMove, doVMove);
+
+ if(!doHMove && !doVMove)
+ {
+ delete scrollTimer;
+ scrollTimer=NULL;
+ doScroll = false;
+ return;
+ }
+ QPoint dist = ev_pos - start;
+ switch(drag)
+ {
+ case DRAG_MOVE:
+ case DRAG_COPY:
+ case DRAG_CLONE:
+ moveItems(ev_pos, 0, false);
+ break;
+ case DRAGX_MOVE:
+ case DRAGX_COPY:
+ case DRAGX_CLONE:
+ moveItems(ev_pos, 1, false);
+ break;
+ case DRAGY_MOVE:
+ case DRAGY_COPY:
+ case DRAGY_CLONE:
+ moveItems(ev_pos, 2, false);
+ break;
+ case DRAG_LASSO:
+ lasso = QRect(start.x(), start.y(), dist.x(), dist.y());
+ redraw();
+ break;
+ case DRAG_NEW:
+ case DRAG_RESIZE:
+ if (dist.x()) {
+ if (dist.x() < 1)
+ curItem->setWidth(1);
+ else
+ curItem->setWidth(dist.x());
+ redraw();
+ }
+ break;
+ default:
+ break;
+ }
+ //printf("Canvas::scrollTimerDone starting scrollTimer: Currently active?%d\n", scrollTimer->isActive());
+
+ // p3.3.43 Make sure to yield to other events (for up to 3 seconds), otherwise other events
+ // take a long time to reach us, causing scrolling to take a painfully long time to stop.
+ // FIXME: Didn't help at all.
+ //qApp->processEvents();
+ // No, try up to 100 ms for each yield.
+ //qApp->processEvents(100);
+ //
+ //scrollTimer->start( 40, TRUE ); // X ms single-shot timer
+ // OK, changing the timeout from 40 to 80 helped.
+ //scrollTimer->start( 80, TRUE ); // X ms single-shot timer
+ scrollTimer->setSingleShot(true);
+ scrollTimer->start(80);
+ }
+ else
+ {
+ //printf("Canvas::scrollTimerDone !(drag != DRAG_OFF && doScroll) deleting scrollTimer\n");
+
+ delete scrollTimer;
+ scrollTimer=NULL;
+ }
+}
+
+
+//---------------------------------------------------------
+// viewMouseMoveEvent
+//---------------------------------------------------------
+
+void Canvas::viewMouseMoveEvent(QMouseEvent* event)
+ {
+
+ ev_pos = event->pos();
+ QPoint dist = ev_pos - start;
+ int ax = ABS(rmapx(dist.x()));
+ int ay = ABS(rmapy(dist.y()));
+ bool moving = (ax >= 2) || (ay > 2);
+
+ // set scrolling variables: doScroll, scrollRight
+ if (drag != DRAG_OFF) {
+
+
+ int ex = rmapx(event->x())+mapx(0);
+ if(ex < 40 && canScrollLeft)
+ hscrollDir = HSCROLL_LEFT;
+ else
+ if(ex > (width() - 40))
+ switch(drag)
+ {
+ case DRAG_NEW:
+ case DRAG_RESIZE:
+ case DRAGX_MOVE:
+ case DRAGX_COPY:
+ case DRAGX_CLONE:
+ case DRAGY_MOVE:
+ case DRAGY_COPY:
+ case DRAGY_CLONE:
+ case DRAG_MOVE:
+ case DRAG_COPY:
+ case DRAG_CLONE:
+ hscrollDir = HSCROLL_RIGHT;
+ break;
+ default:
+ if(canScrollRight)
+ hscrollDir = HSCROLL_RIGHT;
+ else
+ hscrollDir = HSCROLL_NONE;
+ break;
+ }
+ else
+ hscrollDir = HSCROLL_NONE;
+ int ey = rmapy(event->y())+mapy(0);
+ if(ey < 15 && canScrollUp)
+ vscrollDir = VSCROLL_UP;
+ else
+ if(ey > (height() - 15) && canScrollDown)
+ vscrollDir = VSCROLL_DOWN;
+ else
+ vscrollDir = VSCROLL_NONE;
+ if(hscrollDir != HSCROLL_NONE || vscrollDir != VSCROLL_NONE)
+ {
+ doScroll=true;
+ if (!scrollTimer)
+ {
+ scrollTimer= new QTimer(this);
+ connect( scrollTimer, SIGNAL(timeout()), SLOT(scrollTimerDone()) );
+ //scrollTimer->start( 0, TRUE ); // single-shot timer
+ scrollTimer->setSingleShot(true); // single-shot timer
+ scrollTimer->start(0);
+ }
+ }
+ else
+ doScroll=false;
+
+ }
+ else
+ {
+ doScroll=false;
+
+ canScrollLeft = true;
+ canScrollRight = true;
+ canScrollUp = true;
+ canScrollDown = true;
+ }
+
+ switch (drag) {
+ case DRAG_LASSO_START:
+ if (!moving)
+ break;
+ drag = DRAG_LASSO;
+ setCursor();
+ // proceed with DRAG_LASSO:
+
+ case DRAG_LASSO:
+ {
+ lasso = QRect(start.x(), start.y(), dist.x(), dist.y());
+
+ // printf("xorg=%d xmag=%d event->x=%d, mapx(xorg)=%d rmapx0=%d xOffset=%d rmapx(xOffset()=%d\n",
+ // xorg, xmag, event->x(),mapx(xorg), rmapx(0), xOffset(),rmapx(xOffset()));
+
+ }
+ redraw();
+ break;
+
+ case DRAG_MOVE_START:
+ case DRAG_COPY_START:
+ case DRAG_CLONE_START:
+ if (!moving)
+ break;
+ if (keyState & Qt::ControlModifier) {
+ if (ax > ay) {
+ if (drag == DRAG_MOVE_START)
+ drag = DRAGX_MOVE;
+ else if (drag == DRAG_COPY_START)
+ drag = DRAGX_COPY;
+ else
+ drag = DRAGX_CLONE;
+ }
+ else {
+ if (drag == DRAG_MOVE_START)
+ drag = DRAGY_MOVE;
+ else if (drag == DRAG_COPY_START)
+ drag = DRAGY_COPY;
+ else
+ drag = DRAGY_CLONE;
+ }
+ }
+ else {
+ if (drag == DRAG_MOVE_START)
+ drag = DRAG_MOVE;
+ else if (drag == DRAG_COPY_START)
+ drag = DRAG_COPY;
+ else
+ drag = DRAG_CLONE;
+ }
+ setCursor();
+ if (!curItem->isSelected()) {
+ if (drag == DRAG_MOVE)
+ deselectAll();
+ selectItem(curItem, true);
+ updateSelection();
+ redraw();
+ }
+ DragType dt;
+ if (drag == DRAG_MOVE)
+ dt = MOVE_MOVE;
+ else if (drag == DRAG_COPY)
+ dt = MOVE_COPY;
+ else
+ dt = MOVE_CLONE;
+
+ startMoving(ev_pos, dt);
+ break;
+
+ case DRAG_MOVE:
+ case DRAG_COPY:
+ case DRAG_CLONE:
+
+ if(!scrollTimer)
+ moveItems(ev_pos, 0);
+ break;
+
+ case DRAGX_MOVE:
+ case DRAGX_COPY:
+ case DRAGX_CLONE:
+ if(!scrollTimer)
+ moveItems(ev_pos, 1);
+ break;
+
+ case DRAGY_MOVE:
+ case DRAGY_COPY:
+ case DRAGY_CLONE:
+ if(!scrollTimer)
+ moveItems(ev_pos, 2);
+ break;
+
+ case DRAG_NEW:
+ case DRAG_RESIZE:
+ if (dist.x()) {
+ if (dist.x() < 1)
+ curItem->setWidth(1);
+ else
+ curItem->setWidth(dist.x());
+ redraw();
+ }
+ break;
+ case DRAG_DELETE:
+ deleteItem(ev_pos);
+ break;
+
+ case DRAG_OFF:
+ break;
+ }
+
+ mouseMove(ev_pos);
+ }
+
+//---------------------------------------------------------
+// viewMouseReleaseEvent
+//---------------------------------------------------------
+
+void Canvas::viewMouseReleaseEvent(QMouseEvent* event)
+ {
+// printf("release %x %x\n", event->state(), event->button());
+
+ doScroll = false;
+ canScrollLeft = true;
+ canScrollRight = true;
+ canScrollUp = true;
+ canScrollDown = true;
+ ///if (event->state() & (Qt::LeftButton|Qt::RightButton|Qt::MidButton) & ~(event->button())) {
+ if (event->buttons() & (Qt::LeftButton|Qt::RightButton|Qt::MidButton) & ~(event->button())) {
+ ///printf("ignore %x %x\n", keyState, event->button());
+ //printf("viewMouseReleaseEvent ignore buttons:%x mods:%x button:%x\n", (int)event->buttons(), (int)keyState, event->button());
+ return;
+ }
+
+ QPoint pos = event->pos();
+ ///bool shift = event->state() & Qt::ShiftModifier;
+ bool shift = ((QInputEvent*)event)->modifiers() & Qt::ShiftModifier;
+ bool redrawFlag = false;
+
+ switch (drag) {
+ case DRAG_MOVE_START:
+ case DRAG_COPY_START:
+ case DRAG_CLONE_START:
+ if (!shift)
+ deselectAll();
+ selectItem(curItem, !(shift && curItem->isSelected()));
+ updateSelection();
+ redrawFlag = true;
+ itemReleased(curItem, curItem->pos());
+ break;
+ case DRAG_COPY:
+ endMoveItems(pos, MOVE_COPY, 0);
+ break;
+ case DRAGX_COPY:
+ endMoveItems(pos, MOVE_COPY, 1);
+ break;
+ case DRAGY_COPY:
+ endMoveItems(pos, MOVE_COPY, 2);
+ break;
+ case DRAG_MOVE:
+ endMoveItems(pos, MOVE_MOVE, 0);
+ break;
+ case DRAGX_MOVE:
+ endMoveItems(pos, MOVE_MOVE, 1);
+ break;
+ case DRAGY_MOVE:
+ endMoveItems(pos, MOVE_MOVE, 2);
+ break;
+ case DRAG_CLONE:
+ endMoveItems(pos, MOVE_CLONE, 0);
+ break;
+ case DRAGX_CLONE:
+ endMoveItems(pos, MOVE_CLONE, 1);
+ break;
+ case DRAGY_CLONE:
+ endMoveItems(pos, MOVE_CLONE, 2);
+ break;
+ case DRAG_OFF:
+ break;
+ case DRAG_RESIZE:
+ resizeItem(curItem, false);
+ break;
+ case DRAG_NEW:
+ newItem(curItem, false);
+ redrawFlag = true;
+ break;
+ case DRAG_LASSO_START:
+ lasso.setRect(-1, -1, -1, -1);
+ if (!shift)
+ deselectAll();
+ updateSelection();
+ redrawFlag = true;
+ break;
+
+ case DRAG_LASSO:
+ if (!shift)
+ deselectAll();
+ lasso = lasso.normalized();
+ selectLasso(shift);
+ updateSelection();
+ redrawFlag = true;
+ break;
+
+ case DRAG_DELETE:
+ break;
+ }
+ //printf("Canvas::viewMouseReleaseEvent setting drag to DRAG_OFF\n");
+
+ drag = DRAG_OFF;
+ if (redrawFlag)
+ redraw();
+ setCursor();
+ }
+
+//---------------------------------------------------------
+// selectLasso
+//---------------------------------------------------------
+
+void Canvas::selectLasso(bool toggle)
+ {
+ int n = 0;
+ if (virt()) {
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ if (i->second->intersects(lasso)) {
+ selectItem(i->second, !(toggle && i->second->isSelected()));
+ ++n;
+ }
+ }
+ }
+ else {
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ QRect box = i->second->bbox();
+ int x = rmapxDev(box.x());
+ int y = rmapyDev(box.y());
+ int w = rmapxDev(box.width());
+ int h = rmapyDev(box.height());
+ QRect r(x, y, w, h);
+ ///r.moveBy(i->second->pos().x(), i->second->pos().y());
+ r.translate(i->second->pos().x(), i->second->pos().y());
+ if (r.intersects(lasso)) {
+ selectItem(i->second, !(toggle && i->second->isSelected()));
+ ++n;
+ }
+ }
+ }
+
+
+
+ if (n) {
+ updateSelection();
+ redraw();
+ }
+ }
+
+//---------------------------------------------------------
+// endMoveItems
+// dir = 0 move in all directions
+// 1 move only horizontal
+// 2 move only vertical
+//---------------------------------------------------------
+
+void Canvas::endMoveItems(const QPoint& pos, DragType dragtype, int dir)
+ {
+ startUndo(dragtype);
+
+ int dp = y2pitch(pos.y()) - y2pitch(start.y());
+ int dx = pos.x() - start.x();
+
+ if (dir == 1)
+ dp = 0;
+ else if (dir == 2)
+ dx = 0;
+
+
+
+ int modified = 0;
+
+ // Removed by T356.
+ /*
+ for (iCItem i = moving.begin(); i != moving.end(); ++i) {
+ int x = i->second->pos().x();
+ int y = i->second->pos().y();
+ int nx = x + dx;
+ int ny = pitch2y(y2pitch(y) + dp);
+ QPoint newpos = raster(QPoint(nx, ny));
+ selectItem(i->second, true);
+
+ if (moveItem(i->second, newpos, dragtype, &modified))
+ i->second->move(newpos);
+ if (moving.size() == 1) {
+ itemReleased(curItem, newpos);
+ }
+ if (dragtype == MOVE_COPY || dragtype == MOVE_CLONE)
+ selectItem(i->second, false);
+ }
+ */
+
+ moveCanvasItems(moving, dp, dx, dragtype, &modified);
+
+ endUndo(dragtype, modified);
+ moving.clear();
+ updateSelection();
+ redraw();
+ }
+
+//---------------------------------------------------------
+// getCurrentDrag
+// returns 0 if there is no drag operation
+//---------------------------------------------------------
+
+int Canvas::getCurrentDrag()
+ {
+ //printf("getCurrentDrag=%d\n", drag);
+ return drag;
+ }
+
+//---------------------------------------------------------
+// deleteItem
+//---------------------------------------------------------
+
+void Canvas::deleteItem(const QPoint& p)
+ {
+ if (virt()) {
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ if (i->second->contains(p)) {
+ selectItem(i->second, false);
+ if (!deleteItem(i->second)) {
+ if (drag == DRAG_DELETE)
+ drag = DRAG_OFF;
+ }
+ break;
+ }
+ }
+ }
+ else {
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ QRect box = i->second->bbox();
+ int x = rmapxDev(box.x());
+ int y = rmapyDev(box.y());
+ int w = rmapxDev(box.width());
+ int h = rmapyDev(box.height());
+ QRect r(x, y, w, h);
+ ///r.moveBy(i->second->pos().x(), i->second->pos().y());
+ r.translate(i->second->pos().x(), i->second->pos().y());
+ if (r.contains(p)) {
+ if (deleteItem(i->second)) {
+ selectItem(i->second, false);
+ }
+ break;
+ }
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// setTool
+//---------------------------------------------------------
+
+void Canvas::setTool(int t)
+ {
+ if (_tool == Tool(t))
+ return;
+ _tool = Tool(t);
+ setCursor();
+ }
+
+//---------------------------------------------------------
+// setCursor
+//---------------------------------------------------------
+
+void Canvas::setCursor()
+ {
+ switch (drag) {
+ case DRAGX_MOVE:
+ case DRAGX_COPY:
+ case DRAGX_CLONE:
+ QWidget::setCursor(QCursor(Qt::SizeHorCursor));
+ break;
+
+ case DRAGY_MOVE:
+ case DRAGY_COPY:
+ case DRAGY_CLONE:
+ QWidget::setCursor(QCursor(Qt::SizeVerCursor));
+ break;
+
+ case DRAG_MOVE:
+ case DRAG_COPY:
+ case DRAG_CLONE:
+ QWidget::setCursor(QCursor(Qt::SizeAllCursor));
+ break;
+
+ case DRAG_RESIZE:
+ QWidget::setCursor(QCursor(Qt::SizeHorCursor));
+ break;
+
+ case DRAG_DELETE:
+ case DRAG_COPY_START:
+ case DRAG_CLONE_START:
+ case DRAG_MOVE_START:
+ case DRAG_NEW:
+ case DRAG_LASSO_START:
+ case DRAG_LASSO:
+ case DRAG_OFF:
+ switch(_tool) {
+ case PencilTool:
+ QWidget::setCursor(QCursor(*pencilIcon, 4, 15));
+ break;
+ case RubberTool:
+ QWidget::setCursor(QCursor(*deleteIcon, 4, 15));
+ break;
+ case GlueTool:
+ QWidget::setCursor(QCursor(*glueIcon, 4, 15));
+ break;
+ case CutTool:
+ QWidget::setCursor(QCursor(*cutIcon, 4, 15));
+ break;
+ case MuteTool:
+ QWidget::setCursor(QCursor(*editmuteIcon, 4, 15));
+ break;
+ default:
+ QWidget::setCursor(QCursor(Qt::ArrowCursor));
+ break;
+ }
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// keyPress
+//---------------------------------------------------------
+
+void Canvas::keyPress(QKeyEvent* event)
+ {
+ event->ignore();
+ }
+
+//---------------------------------------------------------
+// isSingleSelection
+//---------------------------------------------------------
+
+bool Canvas::isSingleSelection()
+ {
+ return selectionSize() == 1;
+ }
+
+//---------------------------------------------------------
+// selectionSize
+//---------------------------------------------------------
+
+int Canvas::selectionSize()
+ {
+ int n = 0;
+ for (iCItem i = items.begin(); i != items.end(); ++i) {
+ if (i->second->isSelected())
+ ++n;
+ }
+ return n;
+ }
+
+//---------------------------------------------------------
+// genCanvasPopup
+//---------------------------------------------------------
+
+QMenu* Canvas::genCanvasPopup()
+ {
+ if (canvasTools == 0)
+ return 0;
+ QMenu* canvasPopup = new QMenu(this);
+ QAction* act0 = 0;
+
+ for (unsigned i = 0; i < 9; ++i) {
+ if ((canvasTools & (1 << i))==0)
+ continue;
+ QAction* act = canvasPopup->addAction(QIcon(**toolList[i].icon), tr(toolList[i].tip));
+ act->setData(1<<i); // ddskrjo
+ if (!act0)
+ act0 = act;
+ }
+ canvasPopup->setActiveAction(act0);
+ return canvasPopup;
+ }
+
+//---------------------------------------------------------
+// canvasPopup
+//---------------------------------------------------------
+
+void Canvas::canvasPopup(int n)
+ {
+ setTool(n);
+ emit toolChanged(n);
+ }
+
+void Canvas::setCurrentPart(Part* part)
+{
+ curItem = NULL;
+ deselectAll();
+ curPart = part;
+ curPartId = curPart->sn();
+ curPartChanged();
+}
diff --git a/attic/muse2-oom/muse2/muse/widgets/canvas.h b/attic/muse2-oom/muse2/muse/widgets/canvas.h
new file mode 100644
index 00000000..595fe04e
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/canvas.h
@@ -0,0 +1,185 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: canvas.h,v 1.3.2.8 2009/02/02 21:38:01 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __CANVAS_H__
+#define __CANVAS_H__
+
+#include "citem.h"
+#include "view.h"
+#include "tools.h"
+
+#include <QWheelEvent>
+#include <QMouseEvent>
+#include <QKeyEvent>
+
+class QMenu;
+
+//---------------------------------------------------------
+// Canvas
+//---------------------------------------------------------
+
+class Canvas : public View {
+ Q_OBJECT
+ int canvasTools;
+ QTimer *scrollTimer;
+
+ bool doScroll;
+ int scrollSpeed;
+
+ QPoint ev_pos;
+ bool canScrollLeft;
+ bool canScrollRight;
+ bool canScrollUp;
+ bool canScrollDown;
+ protected:
+ enum DragMode {
+ DRAG_OFF, DRAG_NEW,
+ DRAG_MOVE_START, DRAG_MOVE,
+ DRAG_COPY_START, DRAG_COPY,
+ DRAG_CLONE_START, DRAG_CLONE,
+ DRAGX_MOVE, DRAGY_MOVE,
+ DRAGX_COPY, DRAGY_COPY,
+ DRAGX_CLONE, DRAGY_CLONE,
+ DRAG_DELETE,
+ DRAG_RESIZE, DRAG_LASSO_START, DRAG_LASSO,
+ };
+
+ enum DragType {
+ MOVE_MOVE, MOVE_COPY, MOVE_CLONE
+ };
+
+ enum HScrollDir {
+ HSCROLL_NONE, HSCROLL_LEFT, HSCROLL_RIGHT
+ };
+ enum VScrollDir {
+ VSCROLL_NONE, VSCROLL_UP, VSCROLL_DOWN
+ };
+
+ CItemList items;
+ CItemList moving;
+ CItem* curItem;
+ Part* curPart;
+ int curPartId;
+
+ DragMode drag;
+ QRect lasso;
+ QPoint start;
+ Tool _tool;
+ unsigned pos[3];
+
+ HScrollDir hscrollDir;
+ VScrollDir vscrollDir;
+ int button;
+ Qt::KeyboardModifiers keyState;
+ QMenu* itemPopupMenu;
+ QMenu* canvasPopupMenu;
+
+ void setCursor();
+ virtual void viewKeyPressEvent(QKeyEvent* event);
+ virtual void viewMousePressEvent(QMouseEvent* event);
+ virtual void viewMouseMoveEvent(QMouseEvent*);
+ virtual void viewMouseReleaseEvent(QMouseEvent*);
+ virtual void draw(QPainter&, const QRect&);
+ virtual void wheelEvent(QWheelEvent* e);
+
+ virtual void mousePress(QMouseEvent*) {}
+ virtual void keyPress(QKeyEvent*);
+ virtual void mouseMove(const QPoint&) = 0;
+ virtual void mouseRelease(const QPoint&) {}
+ virtual void drawCanvas(QPainter&, const QRect&) = 0;
+ virtual void drawItem(QPainter&, const CItem*, const QRect&) = 0;
+ virtual void drawMoving(QPainter&, const CItem*, const QRect&) = 0;
+ virtual void updateSelection() = 0;
+ virtual QPoint raster(const QPoint&) const = 0;
+ virtual int y2pitch(int) const = 0; //CDW
+ virtual int pitch2y(int) const = 0; //CDW
+
+ virtual void moveCanvasItems(CItemList&, int, int, DragType, int*) = 0;
+ // Changed by T356.
+ //virtual bool moveItem(CItem*, const QPoint&, DragType, int*) = 0;
+ virtual bool moveItem(CItem*, const QPoint&, DragType) = 0;
+ virtual CItem* newItem(const QPoint&, int state) = 0;
+ virtual void resizeItem(CItem*, bool noSnap=false) = 0;
+ virtual void newItem(CItem*, bool noSnap=false) = 0;
+ virtual bool deleteItem(CItem*) = 0;
+ virtual void startUndo(DragType) = 0;
+
+ virtual void endUndo(DragType, int flags) = 0;
+ int getCurrentDrag();
+
+ /*!
+ \brief Virtual member
+
+ Implementing class is responsible for creating a popup to be shown when the user rightclicks an item on the Canvas
+ \param item The canvas item that is rightclicked
+ \return A QPopupMenu*
+ */
+ virtual QMenu* genItemPopup(CItem* /*item*/) { return 0; }
+
+ /*!
+ \brief Pure virtual member
+
+ Implementing class is responsible for creating a popup to be shown when the user rightclicks an empty region of the canvas
+ \return A QPopupMenu*
+ */
+ QMenu* genCanvasPopup();
+
+ /*!
+ \brief Virtual member
+
+ This is the function called when the user has selected an option in the popupmenu generated by genItemPopup()
+ \param item the canvas item the whole thing is about
+ \param n Command type
+ \param pt I think this is the position of the pointer when right mouse button was pressed
+ */
+ virtual void itemPopup(CItem* /*item */, int /*n*/, const QPoint& /*pt*/) {}
+ void canvasPopup(int);
+
+ virtual void startDrag(CItem*, bool) {}
+
+ // selection
+ virtual void deselectAll();
+ virtual void selectItem(CItem* e, bool);
+
+ virtual void deleteItem(const QPoint&);
+
+ // moving
+ void startMoving(const QPoint&, DragType);
+
+ void moveItems(const QPoint&, int dir, bool rasterize = true);
+ void endMoveItems(const QPoint&, DragType, int dir);
+
+ virtual void selectLasso(bool toggle);
+
+ virtual void itemPressed(const CItem*) {}
+ virtual void itemReleased(const CItem*, const QPoint&) {}
+ virtual void itemMoved(const CItem*, const QPoint&) {}
+ virtual void curPartChanged() {}
+
+ public slots:
+ void setTool(int t);
+ void setPos(int, unsigned, bool adjustScrollbar);
+ void scrollTimerDone(void);
+ void redirectedWheelEvent(QWheelEvent*);
+
+ signals:
+ void followEvent(int);
+ void toolChanged(int);
+ void verticalScroll(unsigned);
+ void horizontalScroll(unsigned);
+ void horizontalScrollNoLimit(unsigned);
+ public:
+ Canvas(QWidget* parent, int sx, int sy, const char* name = 0);
+ bool isSingleSelection();
+ int selectionSize();
+ Tool tool() const { return _tool; }
+ Part* part() const { return curPart; }
+ void setCurrentPart(Part*);
+ void setCanvasTools(int n) { canvasTools = n; }
+ };
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/checkbox.cpp b/attic/muse2-oom/muse2/muse/widgets/checkbox.cpp
new file mode 100644
index 00000000..8f706361
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/checkbox.cpp
@@ -0,0 +1,59 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: checkbox.cpp,v 1.2.2.2 2006/10/29 07:54:52 terminator356 Exp $
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "checkbox.h"
+
+#include <QMouseEvent>
+
+//---------------------------------------------------------
+// CheckBox
+//---------------------------------------------------------
+
+CheckBox::CheckBox(QWidget* parent, int i, const char* name)
+ : QCheckBox(parent)
+ {
+ setObjectName(name);
+ _id = i;
+ connect(this, SIGNAL(toggled(bool)), SLOT(hasToggled(bool)));
+ }
+
+void CheckBox::hasToggled(bool val)
+ {
+ emit toggleChanged(val, _id);
+ }
+
+//------------------------------------------------------------
+// mousePressEvent
+//------------------------------------------------------------
+
+void CheckBox::mousePressEvent(QMouseEvent *e)
+{
+ if(e->button() == Qt::RightButton)
+ emit checkboxRightClicked(e->globalPos(), _id);
+ else
+ {
+ if(isChecked())
+ setChecked(false);
+ else
+ setChecked(true);
+ emit checkboxPressed(_id);
+ }
+}
+
+//------------------------------------------------------------
+// mouseReleaseEvent
+//------------------------------------------------------------
+
+void CheckBox::mouseReleaseEvent(QMouseEvent *e)
+{
+ if(e->button() == Qt::RightButton)
+ return;
+
+ emit checkboxReleased(_id);
+}
+
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/checkbox.h b/attic/muse2-oom/muse2/muse/widgets/checkbox.h
new file mode 100644
index 00000000..f9b58ad1
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/checkbox.h
@@ -0,0 +1,44 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: checkbox.h,v 1.2.2.2 2006/10/29 07:54:52 terminator356 Exp $
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __CHECKBOX_H__
+#define __CHECKBOX_H__
+
+#include <QCheckBox>
+
+
+//---------------------------------------------------------
+// CheckBox
+//---------------------------------------------------------
+
+class CheckBox : public QCheckBox {
+ Q_OBJECT
+ Q_PROPERTY( int id READ id WRITE setId )
+
+ int _id;
+
+ protected:
+ void mousePressEvent(QMouseEvent *e);
+ void mouseReleaseEvent(QMouseEvent *e);
+
+ private slots:
+ void hasToggled(bool val);
+
+ signals:
+ void toggleChanged(bool, int);
+ void checkboxPressed(int);
+ void checkboxReleased(int);
+ void checkboxRightClicked(const QPoint &, int);
+
+ public:
+ CheckBox(QWidget* parent, int i, const char* name = 0);
+ int id() const { return _id; }
+ void setId(int i) { _id = i; }
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/citem.cpp b/attic/muse2-oom/muse2/muse/widgets/citem.cpp
new file mode 100644
index 00000000..2974196d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/citem.cpp
@@ -0,0 +1,93 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: citem.cpp,v 1.2.2.3 2008/01/26 07:23:21 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "part.h"
+#include "citem.h"
+#include <stdio.h>
+
+//---------------------------------------------------------
+// CItem
+//---------------------------------------------------------
+
+CItem::CItem()
+ {
+ _isMoving = false;
+ }
+
+CItem::CItem(const QPoint&p, const QRect& r)
+ {
+ _pos = p;
+ _bbox = r;
+ _isMoving = false;
+ }
+
+// Changed by Tim. p3.3.20
+//CItem::CItem(Event e, Part* p)
+CItem::CItem(const Event& e, Part* p)
+ {
+ _event = e;
+ _part = p;
+ _isMoving = false;
+ }
+
+//---------------------------------------------------------
+// isSelected
+//---------------------------------------------------------
+
+bool CItem::isSelected() const
+ {
+ return _event.empty() ? _part->selected() : _event.selected();
+ }
+
+//---------------------------------------------------------
+// setSelected
+//---------------------------------------------------------
+
+void CItem::setSelected(bool f)
+ {
+ _event.empty() ? _part->setSelected(f) : _event.setSelected(f);
+ }
+
+//---------------------------------------------------------
+// CItemList
+//---------------------------------------------------------
+
+CItem* CItemList::find(const QPoint& pos) const
+ {
+ rciCItem ius;
+ bool usfound = false;
+ for (rciCItem i = rbegin(); i != rend(); ++i) {
+ if (i->second->contains(pos))
+ {
+ if(i->second->isSelected())
+ return i->second;
+
+ else
+ {
+ if(!usfound)
+ {
+ ius = i;
+ usfound = true;
+ }
+ }
+ }
+ }
+ if(usfound)
+ return ius->second;
+ else
+ return 0;
+ }
+
+//---------------------------------------------------------
+// CItemList
+//---------------------------------------------------------
+
+void CItemList::add(CItem* item)
+ {
+ std::multimap<int, CItem*, std::less<int> >::insert(std::pair<const int, CItem*> (item->bbox().x(), item));
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/citem.h b/attic/muse2-oom/muse2/muse/widgets/citem.h
new file mode 100644
index 00000000..cd77f51d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/citem.h
@@ -0,0 +1,90 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: citem.h,v 1.2.2.1 2006/10/04 18:45:35 spamatica Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __CITEM_H__
+#define __CITEM_H__
+
+#include <map>
+#include <QPoint>
+#include <QRect>
+
+#include "event.h"
+
+class Event;
+class Part;
+
+//---------------------------------------------------------
+// CItem
+// virtuelle Basisklasse fr alle Canvas Item's
+//---------------------------------------------------------
+
+class CItem {
+ private:
+ Event _event;
+ Part* _part;
+
+ protected:
+ bool _isMoving;
+ QPoint moving;
+ QRect _bbox;
+ QPoint _pos;
+
+ public:
+ CItem(const QPoint& p, const QRect& r);
+ CItem();
+ // Changed by Tim. p3.3.20
+ //CItem(Event e, Part* p);
+ CItem(const Event& e, Part* p);
+
+ bool isMoving() const { return _isMoving; }
+ void setMoving(bool f) { _isMoving = f; }
+ bool isSelected() const;
+ void setSelected(bool f);
+
+ int width() const { return _bbox.width(); }
+ void setWidth(int l) { _bbox.setWidth(l); }
+ void setHeight(int l) { _bbox.setHeight(l); }
+ void setMp(const QPoint&p) { moving = p; }
+ const QPoint mp() const { return moving; }
+ int x() const { return _pos.x(); }
+ int y() const { return _pos.y(); }
+ void setY(int y) { _bbox.setY(y); }
+ QPoint pos() const { return _pos; }
+ void setPos(const QPoint& p) { _pos = p; }
+ int height() const { return _bbox.height(); }
+ const QRect& bbox() const { return _bbox; }
+ void setBBox(const QRect& r) { _bbox = r; }
+ void move(const QPoint& tl) {
+ _bbox.moveTopLeft(tl);
+ _pos = tl;
+ }
+ bool contains(const QPoint& p) const { return _bbox.contains(p); }
+ bool intersects(const QRect& r) const { return r.intersects(_bbox); }
+
+ Event event() const { return _event; }
+ void setEvent(Event& e) { _event = e; }
+ Part* part() const { return _part; }
+ void setPart(Part* p) { _part = p; }
+ };
+
+typedef std::multimap<int, CItem*, std::less<int> >::iterator iCItem;
+//typedef std::multimap<int, CItem*, std::less<int> >::const_iterator ciCItem;
+typedef std::multimap<int, CItem*, std::less<int> >::const_reverse_iterator rciCItem;
+
+//---------------------------------------------------------
+// CItemList
+// Canvas Item List
+//---------------------------------------------------------
+
+class CItemList: public std::multimap<int, CItem*, std::less<int> > {
+ public:
+ void add(CItem*);
+ CItem* find(const QPoint& pos) const;
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/cliplisteditorbase.ui b/attic/muse2-oom/muse2/muse/widgets/cliplisteditorbase.ui
new file mode 100644
index 00000000..c07e722f
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/cliplisteditorbase.ui
@@ -0,0 +1,167 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0" stdsetdef="1">
+ <author></author>
+ <comment></comment>
+ <exportmacro></exportmacro>
+ <class>ClipListEditorBase</class>
+ <widget class="QWidget" name="ClipListEditorBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>600</width>
+ <height>480</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: ClipList</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QTreeWidget" name="view">
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <property name="rootIsDecorated">
+ <bool>true</bool>
+ </property>
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Refs</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Start</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Len</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Data</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizeable">
+ <bool>true</bool>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="GroupBox1">
+ <property name="title">
+ <string>Clip Properties</string>
+ </property>
+ <layout class="QHBoxLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="TextLabel1">
+ <property name="text">
+ <string>Pos:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="Awl::PosEdit" name="start">
+ <property name="smpte">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="TextLabel2">
+ <property name="text">
+ <string>Len:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="Awl::PosEdit" name="len">
+ <property name="smpte">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="Spacer1">
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <customwidgets>
+ <customwidget>
+ <class>Awl::PosEdit</class>
+ <extends>QWidget</extends>
+ <header>awl/posedit.h</header>
+ <container>0</container>
+ </customwidget>
+ </customwidgets>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/comboQuant.cpp b/attic/muse2-oom/muse2/muse/widgets/comboQuant.cpp
new file mode 100644
index 00000000..87d88fca
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/comboQuant.cpp
@@ -0,0 +1,94 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: comboQuant.cpp,v 1.1.1.1 2003/10/27 18:54:52 wschweer Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+
+#include <QTableWidget>
+#include <QTableWidgetItem>
+#include <QHeaderView>
+
+#include "comboQuant.h"
+
+static int quantTable[] = {
+ 1, 16, 32, 64, 128, 256, 512, 1024,
+ 1, 24, 48, 96, 192, 384, 768, 1536,
+ 1, 36, 72, 144, 288, 576, 1152, 2304
+ };
+
+static const char* quantStrings[] = {
+ QT_TRANSLATE_NOOP("@default", "Off"), "64T", "32T", "16T", "8T", "4T", "2T", "1T",
+ QT_TRANSLATE_NOOP("@default", "Off"), "64", "32", "16", "8", "4", "2", "1",
+ QT_TRANSLATE_NOOP("@default", "Off"), "64.", "32.", "16.", "8.", "4.", "2.", "1."
+ };
+
+//---------------------------------------------------------
+// ComboQuant
+//---------------------------------------------------------
+
+ComboQuant::ComboQuant(QWidget* parent)
+ : QComboBox(parent)
+ {
+ ///Q3ListBox* qlist = new Q3ListBox(this);
+ ///qlist->setMinimumWidth(95);
+ //setListBox(qlist); ddskrjo
+ ///qlist->setColumnMode(3);
+
+
+ qlist = new QTableWidget(8, 3);
+ qlist->verticalHeader()->setDefaultSectionSize(22);
+ qlist->horizontalHeader()->setDefaultSectionSize(32);
+ qlist->setSelectionMode(QAbstractItemView::SingleSelection);
+ qlist->verticalHeader()->hide();
+ qlist->horizontalHeader()->hide();
+
+ qlist->setMinimumWidth(96);
+
+ setView(qlist);
+
+ ///for (int i = 0; i < 24; i++)
+ /// qlist->insertItem(tr(quantStrings[i]), i);
+ for (int j = 0; j < 3; j++)
+ for (int i = 0; i < 8; i++)
+ qlist->setItem(i, j, new QTableWidgetItem(tr(quantStrings[i + j * 8])));
+
+
+ connect(this, SIGNAL(activated(int)), SLOT(activated(int)));
+ }
+
+//---------------------------------------------------------
+// activated
+//---------------------------------------------------------
+
+void ComboQuant::activated(int /*index*/)
+ {
+ ///emit valueChanged(quantTable[index]);
+ emit valueChanged(quantTable[qlist->currentRow() + qlist->currentColumn() * 8]);
+ }
+
+//---------------------------------------------------------
+// setQuant
+//---------------------------------------------------------
+
+void ComboQuant::setValue(int val)
+ {
+ for (int i = 0; i < 24; i++) {
+ if (val == quantTable[i]) {
+ setCurrentIndex(i);
+ return;
+ }
+ }
+
+ for (unsigned i = 0; i < sizeof(quantTable)/sizeof(*quantTable); i++) {
+ if (val == quantTable[i]) {
+ setCurrentIndex(i);
+ return;
+ }
+ }
+ printf("ComboQuant::setValue(%d) not defined\n", val);
+ setCurrentIndex(0);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/comboQuant.h b/attic/muse2-oom/muse2/muse/widgets/comboQuant.h
new file mode 100644
index 00000000..501f0a14
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/comboQuant.h
@@ -0,0 +1,39 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: comboQuant.h,v 1.1.1.1 2003/10/27 18:54:30 wschweer Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __COMBOQUANT_H__
+#define __COMBOQUANT_H__
+
+#include <QComboBox>
+//#include <QWidget>
+//#include <QTableWidget>
+
+class QWidget;
+class QTableWidget;
+
+//---------------------------------------------------------
+// ComboQuant
+//---------------------------------------------------------
+
+class ComboQuant : public QComboBox {
+ Q_OBJECT
+
+ QTableWidget* qlist;
+
+ private slots:
+ void activated(int);
+
+ signals:
+ void valueChanged(int);
+
+ public:
+ ComboQuant(QWidget* parent = 0);
+ void setValue(int val);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/combobox.cpp b/attic/muse2-oom/muse2/muse/widgets/combobox.cpp
new file mode 100644
index 00000000..9e278376
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/combobox.cpp
@@ -0,0 +1,80 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: combobox.cpp,v 1.4 2004/05/06 15:08:07 wschweer Exp $
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QMenu>
+
+#include "combobox.h"
+
+//---------------------------------------------------------
+// ComboBox
+//---------------------------------------------------------
+
+ComboBox::ComboBox(QWidget* parent, const char* name)
+ : QLabel(parent)
+ {
+ setObjectName(name);
+ _currentItem = 0;
+ _id = -1;
+ list = new QMenu(0);
+ connect(list, SIGNAL(triggered(QAction*)), SLOT(activatedIntern(QAction*)));
+ setFrameStyle(QFrame::Panel | QFrame::Raised);
+ setLineWidth(2);
+ }
+
+ComboBox::~ComboBox()
+ {
+ delete list;
+ }
+
+//---------------------------------------------------------
+// mousePressEvent
+//---------------------------------------------------------
+
+void ComboBox::mousePressEvent(QMouseEvent*)
+ {
+ list->exec(QCursor::pos());
+ }
+
+//---------------------------------------------------------
+// activated
+//---------------------------------------------------------
+
+void ComboBox::activatedIntern(QAction* act)
+ {
+ _currentItem = act->data().toInt();
+ emit activated(_currentItem, _id);
+ setText(act->text());
+ }
+
+//---------------------------------------------------------
+// setCurrentItem
+//---------------------------------------------------------
+
+void ComboBox::setCurrentItem(int i)
+ {
+ _currentItem = i;
+ // ORCAN - CHECK
+ QList<QAction *> actions = list->actions();
+ for (QList<QAction *>::iterator it = actions.begin(); it != actions.end(); ++it) {
+ QAction* act = *it;
+ if (act->data().toInt() == i) {
+ setText(act->text());
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// insertItem
+//---------------------------------------------------------
+
+void ComboBox::insertItem(const QString& s, int id)
+ {
+ QAction *act = list->addAction(s);
+ act->setData(id);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/combobox.h b/attic/muse2-oom/muse2/muse/widgets/combobox.h
new file mode 100644
index 00000000..305ad0b3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/combobox.h
@@ -0,0 +1,46 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: combobox.h,v 1.3 2004/02/29 12:12:36 wschweer Exp $
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __COMBOBOX_H__
+#define __COMBOBOX_H__
+
+#include <QLabel>
+
+class QMenu;
+
+//---------------------------------------------------------
+// ComboBox
+//---------------------------------------------------------
+
+class ComboBox : public QLabel {
+ Q_OBJECT
+ Q_PROPERTY( int id READ id WRITE setId )
+
+ int _id;
+ int _currentItem;
+ QMenu* list;
+ virtual void mousePressEvent(QMouseEvent*);
+
+ private slots:
+ void activatedIntern(QAction*);
+
+ signals:
+ void activated(int val, int id);
+
+ public:
+ ComboBox(QWidget* parent, const char* name = 0);
+ ~ComboBox();
+ void setCurrentItem(int);
+ void insertItem(const QString& s, int id = -1);
+ int id() const { return _id; }
+ void setId(int i) { _id = i; }
+ };
+
+#endif
+
+
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/comment.cpp b/attic/muse2-oom/muse2/muse/widgets/comment.cpp
new file mode 100644
index 00000000..36298330
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/comment.cpp
@@ -0,0 +1,89 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: comment.cpp,v 1.2 2004/02/08 18:30:00 wschweer Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "comment.h"
+#include "song.h"
+#include "track.h"
+
+#include <QWidget>
+
+//---------------------------------------------------------
+// Comment
+//---------------------------------------------------------
+
+Comment::Comment(QWidget* parent)
+ : QWidget(parent)
+ {
+ setupUi(this);
+ }
+
+//---------------------------------------------------------
+// textChanged
+//---------------------------------------------------------
+
+void Comment::textChanged()
+ {
+ setText(textentry->toPlainText());
+ }
+
+//---------------------------------------------------------
+// TrackComment
+//---------------------------------------------------------
+
+TrackComment::TrackComment(Track* t, QWidget* parent)
+ : Comment(parent)
+ {
+ setAttribute(Qt::WA_DeleteOnClose);
+ setWindowTitle(tr("MusE: Track Comment"));
+ track = t;
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+ textentry->setText(track->comment());
+ textentry->moveCursor(QTextCursor::End);
+ connect(textentry, SIGNAL(textChanged()), SLOT(textChanged()));
+ label1->setText(tr("Track Comment:"));
+ label2->setText(track->name());
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void TrackComment::songChanged(int flags)
+ {
+ if ((flags & (SC_TRACK_INSERTED|SC_TRACK_REMOVED|SC_TRACK_MODIFIED)) == 0)
+ return;
+
+ // check if track still exists:
+ TrackList* tl = song->tracks();
+ iTrack it;
+ for (it = tl->begin(); it != tl->end(); ++it) {
+ if (track == *it)
+ break;
+ }
+ if (it == tl->end()) {
+ close();
+ return;
+ }
+ label2->setText(track->name());
+ if (track->comment() != textentry->toPlainText()) {
+ disconnect(textentry, SIGNAL(textChanged()), this, SLOT(textChanged()));
+ textentry->setText(track->comment());
+ textentry->moveCursor(QTextCursor::End);
+ connect(textentry, SIGNAL(textChanged()), this, SLOT(textChanged()));
+ }
+ }
+
+//---------------------------------------------------------
+// setText
+//---------------------------------------------------------
+
+void TrackComment::setText(const QString& s)
+ {
+ track->setComment(s);
+ song->update(SC_TRACK_MODIFIED);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/comment.h b/attic/muse2-oom/muse2/muse/widgets/comment.h
new file mode 100644
index 00000000..688d7b2f
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/comment.h
@@ -0,0 +1,53 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: comment.h,v 1.2 2004/02/08 18:30:00 wschweer Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __COMMENT_H__
+#define __COMMENT_H__
+
+#include "ui_commentbase.h"
+
+class Xml;
+class Track;
+class QWidget;
+
+//---------------------------------------------------------
+// Comment
+//---------------------------------------------------------
+
+class Comment : public QWidget, public Ui::CommentBase {
+ Q_OBJECT
+
+ private:
+ virtual void setText(const QString& s) = 0;
+
+ private slots:
+ void textChanged();
+
+ public:
+ Comment(QWidget* parent);
+ };
+
+//---------------------------------------------------------
+// TrackComment
+//---------------------------------------------------------
+
+class TrackComment : public Comment {
+ Track* track;
+ Q_OBJECT
+
+ private:
+ virtual void setText(const QString& s);
+
+ private slots:
+ void songChanged(int);
+
+ public:
+ TrackComment(Track*, QWidget*);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/commentbase.ui b/attic/muse2-oom/muse2/muse/widgets/commentbase.ui
new file mode 100644
index 00000000..dc82585d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/commentbase.ui
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>CommentBase</class>
+ <widget class="QWidget" name="CommentBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>387</width>
+ <height>205</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Form1</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="hbox">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="label1">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Track Comment</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="label2">
+ <property name="font">
+ <font>
+ <pointsize>12</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::Box</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Sunken</enum>
+ </property>
+ <property name="midLineWidth">
+ <number>1</number>
+ </property>
+ <property name="text">
+ <string>Track 1</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="textentry" native="true">
+ <property name="font">
+ <font>
+ <pointsize>12</pointsize>
+ <weight>75</weight>
+ <bold>true</bold>
+ </font>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/configmidifilebase.ui b/attic/muse2-oom/muse2/muse/widgets/configmidifilebase.ui
new file mode 100644
index 00000000..920596ec
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/configmidifilebase.ui
@@ -0,0 +1,238 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0" stdsetdef="1">
+ <author></author>
+ <comment></comment>
+ <exportmacro></exportmacro>
+ <class>ConfigMidiFileBase</class>
+ <widget class="QDialog" name="ConfigMidiFileBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>548</width>
+ <height>353</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Config Midi File Import/Export</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QGroupBox" name="midiImportGroupBox">
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>1</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Import:</string>
+ </property>
+ <layout class="QGridLayout">
+ <item row="0" column="0">
+ <widget class="QCheckBox" name="splitPartsCheckBox">
+ <property name="text">
+ <string>Split tracks into &amp;parts</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+P</string>
+ </property>
+ <property name="toolTip" stdset="0">
+ <string>Split tracks into parts, or one single part</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="midiExportGroupBox">
+ <property name="sizePolicy">
+ <sizepolicy>
+ <hsizetype>5</hsizetype>
+ <vsizetype>7</vsizetype>
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Export:</string>
+ </property>
+ <layout class="QGridLayout">
+ <item row="2" column="1">
+ <widget class="QLineEdit" name="copyrightEdit"/>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="divisionCombo">
+ <item>
+ <property name="text">
+ <string>96</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>192</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>384</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="3" column="0" rowspan="1" colspan="2">
+ <widget class="QCheckBox" name="extendedFormat">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="text">
+ <string>Enable extended smf format (currently not implemented)</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0" rowspan="1" colspan="2">
+ <widget class="QCheckBox" name="twoByteTimeSigs">
+ <property name="text">
+ <string>Use &amp;2-byte time signatures instead of standard 4</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+2</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="textLabel2">
+ <property name="text">
+ <string>Copyright:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="textLabel3">
+ <property name="text">
+ <string>Format:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="textLabel1">
+ <property name="text">
+ <string>Division:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0" rowspan="1" colspan="2">
+ <widget class="QCheckBox" name="optNoteOffs">
+ <property name="text">
+ <string>Save space by replacing note-offs with &amp;zero velocity note-ons</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+Z</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="formatCombo">
+ <item>
+ <property name="text">
+ <string>0 (single track)</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>1 (multiple tracks)</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item>
+ <spacer name="Horizontal Spacing2">
+ <property name="sizeHint">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonOk">
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="shortcut">
+ <string/>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonCancel">
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="shortcut">
+ <string/>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <connections>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>ConfigMidiFileBase</receiver>
+ <slot>accept()</slot>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>ConfigMidiFileBase</receiver>
+ <slot>reject()</slot>
+ </connection>
+ </connections>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/ctrlcombo.cpp b/attic/muse2-oom/muse2/muse/widgets/ctrlcombo.cpp
new file mode 100644
index 00000000..911357ee
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/ctrlcombo.cpp
@@ -0,0 +1,56 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: ctrlcombo.cpp,v 1.1.1.1 2003/10/27 18:55:02 wschweer Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "ctrlcombo.h"
+
+//---------------------------------------------------------
+// CtrlComboBox
+//---------------------------------------------------------
+
+CtrlComboBox::CtrlComboBox(QWidget* parent)
+ : QComboBox(parent)
+ {
+ const char* ctxt[] = {
+ "No Ctrl", "BankSelMSB", "Modulation", "BreathCtrl",
+ "Control 3", "Foot Ctrl", "Porta Time", "DataEntMSB",
+ "MainVolume", "Balance", "Control 9", "Pan",
+ "Expression", "Control 12", "Control 13", "Control 14",
+ "Control 15", "Gen.Purp.1", "Gen.Purp.2", "Gen.Purp.3",
+ "Gen.Purp.4", "Control 20", "Control 21", "Control 22",
+ "Control 23", "Control 24", "Control 25", "Control 26",
+ "Control 27", "Control 28", "Control 29", "Control 30",
+ "Control 31", "BankSelLSB", "Modul. LSB", "BrthCt.LSB",
+ "Control 35", "FootCt.LSB", "Port.T LSB", "DataEntLSB",
+ "MainVolLSB", "BalanceLSB", "Control 41", "Pan LSB",
+ "Expr. LSB", "Control 44", "Control 45", "Control 46",
+ "Control 47", "Gen.P.1LSB", "Gen.P.2LSB", "Gen.P.3LSB",
+ "Gen.P.4LSB", "Control 52", "Control 53", "Control 54",
+ "Control 55", "Control 56", "Control 57", "Control 58",
+ "Control 59", "Control 60", "Control 61", "Control 62",
+ "Control 63", "Sustain", "Porta Ped", "Sostenuto",
+ "Soft Pedal", "Control 68", "Hold 2", "Control 70",
+ "HarmonicCo", "ReleaseTime", "Attack Time", "Brightness",
+ "Control 75", "Control 76", "Control 77", "Control 78",
+ "Control 79", "Gen.Purp.5", "Gen.Purp.6", "Gen.Purp.7",
+ "Gen.Purp.8", "Porta Ctrl", "Control 85", "Control 86",
+ "Control 87", "Control 88", "Control 89", "Control 90",
+ "Effect1Dep", "Effect2Dep", "Effect3Dep", "Effect4Dep",
+ "Phaser Dep", "Data Incr", "Data Decr", "NRPN LSB",
+ "NRPN MSB", "RPN LSB", "RPN MSB", "Control102",
+ "Control103", "Control104", "Control105", "Control106",
+ "Control107", "Control108", "Control109", "Control110",
+ "Control111", "Control112", "Control113", "Control114",
+ "Control115", "Control116", "Control117", "Control118",
+ "Control119", "AllSndOff", "Reset Ctrl", "Local Ctrl",
+ "AllNoteOff", "OmniModOff", "OmniModeOn", "MonoModeOn",
+ "PolyModeOn"
+ };
+ for (unsigned int i = 0; i < sizeof(ctxt)/sizeof(*ctxt); ++i)
+ insertItem(i, QString(ctxt[i]));
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/ctrlcombo.cw b/attic/muse2-oom/muse2/muse/widgets/ctrlcombo.cw
new file mode 100644
index 00000000..f4f5b2ac
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/ctrlcombo.cw
@@ -0,0 +1,22 @@
+<!DOCTYPE CW><CW>
+<customwidgets>
+ <customwidget>
+ <class>CtrlComboBox</class>
+ <header location="global">ctrlcombo.h</header>
+ <sizehint>
+ <width>50</width>
+ <height>20</height>
+ </sizehint>
+ <container>0</container>
+ <sizepolicy>
+ <hordata>5</hordata>
+ <verdata>5</verdata>
+ </sizepolicy>
+ <pixmap>
+ <data format="XPM.GZ" length="646">789c6dd2c10ac2300c00d07bbf2234b7229d1be245fc04c5a3201e4615f430059d0711ff5ddb2e6bb236ec90eed134cb5a19d8ef36602af5ecdbfeeac05dda0798d3abebde87e3faa374d3807fa0d633a52d38d8de6f679fe33fc776e196f53cd010188256a3600a292882096246517815ca99884606e18044a3a40d91824820924265a7923a2e8bcd05f33db1173e002913175f2a6be6d3294871a2d95fa00e8a94ee017b69d339d90df1e77c57ea072ede6758</data>
+ </pixmap>
+ <signal>activated(int index)</signal>
+ <signal>activated(const QString&amp;)</signal>
+ </customwidget>
+</customwidgets>
+</CW>
diff --git a/attic/muse2-oom/muse2/muse/widgets/ctrlcombo.h b/attic/muse2-oom/muse2/muse/widgets/ctrlcombo.h
new file mode 100644
index 00000000..2feff096
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/ctrlcombo.h
@@ -0,0 +1,22 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: ctrlcombo.h,v 1.1.1.1 2003/10/27 18:54:30 wschweer Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __CTRLGRP_H__
+#define __CTRLGRP_H__
+
+#include <QComboBox>
+
+class CtrlComboBox : public QComboBox {
+ Q_OBJECT
+ public:
+ CtrlComboBox(QWidget* parent);
+ };
+
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/dentry.cpp b/attic/muse2-oom/muse2/muse/widgets/dentry.cpp
new file mode 100644
index 00000000..c7aa3c1b
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/dentry.cpp
@@ -0,0 +1,242 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: dentry.cpp,v 1.1.1.1.2.3 2008/08/18 00:15:26 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+
+#include <QContextMenuEvent>
+#include <QTimer>
+
+#include "dentry.h"
+#include "globals.h"
+
+#define TIMER1 400
+#define TIMER2 200
+#define TIMEC 7
+#define TIMER3 100
+#define TIMEC2 20
+#define TIMER4 50
+
+//---------------------------------------------------------
+// Dentry
+// lineedit double values
+//---------------------------------------------------------
+
+Dentry::Dentry(QWidget* parent, const char* name) : QLineEdit(parent)
+ {
+ setObjectName(name);
+ _slider = 0;
+ _id = -1;
+ drawFrame = false;
+ QLineEdit::setFrame(drawFrame);
+ timer = new QTimer(this);
+ connect(timer, SIGNAL(timeout()), SLOT(repeat()));
+ val = 0.01;
+ connect(this, SIGNAL(returnPressed()), SLOT(endEdit()));
+ setCursor(QCursor(Qt::ArrowCursor));
+ evx = 1.0;
+ }
+
+//---------------------------------------------------------
+// contextMenuEvent
+//---------------------------------------------------------
+
+void Dentry::contextMenuEvent(QContextMenuEvent * e)
+{
+ e->accept();
+}
+
+//---------------------------------------------------------
+// setFrame
+//---------------------------------------------------------
+
+void Dentry::setFrame(bool flag)
+ {
+ drawFrame = flag;
+ QLineEdit::setFrame(drawFrame);
+ update();
+ }
+
+//---------------------------------------------------------
+// endEdit
+//---------------------------------------------------------
+
+void Dentry::endEdit()
+ {
+ if (isModified()) {
+ if (setSValue(text())) {
+ setString(val);
+ return;
+ }
+ }
+ setString(val);
+ clearFocus();
+ if (!drawFrame)
+ QLineEdit::setFrame(false);
+ }
+
+//---------------------------------------------------------
+// mousePressEvent
+//---------------------------------------------------------
+
+void Dentry::mousePressEvent(QMouseEvent* event)
+ {
+ button = event->button();
+ starty = event->y();
+ evx = double(event->x());
+ timecount = 0;
+ repeat();
+ timer->start(TIMER1);
+ }
+
+//---------------------------------------------------------
+// wheelEvent
+//---------------------------------------------------------
+
+void Dentry::wheelEvent(QWheelEvent* event)
+ {
+ // Avoid unwanted wheel events from outside the control.
+ // Tested: No go, can't seem to determine where event came from.
+ /*
+ const QPoint gp = mapToGlobal(event->pos());
+ const QRect gr = QRect(mapToGlobal(rect().topLeft()), mapToGlobal(rect().bottomRight()));
+ if(!gr.contains(gp))
+ */
+ //if(sender() != this)
+ //{
+ // event->ignore();
+ // return;
+ //}
+
+ event->accept();
+
+ int delta = event->delta();
+
+ if (delta < 0)
+ {
+ if(_slider)
+ _slider->stepPages(-1);
+ else
+ decValue(-1.0);
+ }
+ else if (delta > 0)
+ {
+ if(_slider)
+ _slider->stepPages(1);
+ else
+ incValue(1.0);
+ }
+ }
+
+//---------------------------------------------------------
+// repeat
+//---------------------------------------------------------
+
+void Dentry::repeat()
+ {
+ if (timecount == 1) {
+ ++timecount;
+ timer->stop();
+ timer->start(TIMER2);
+ return;
+ }
+ ++timecount;
+ if (timecount == TIMEC) {
+ timer->stop();
+ timer->start(TIMER3);
+ }
+ if (timecount == TIMEC2) {
+ timer->stop();
+ timer->start(TIMER4);
+ }
+
+ switch (button) {
+ case Qt::LeftButton:
+ return;
+ case Qt::MidButton:
+ if(_slider)
+ _slider->stepPages(-1);
+ else
+ decValue(evx);
+ break;
+ case Qt::RightButton:
+ if(_slider)
+ _slider->stepPages(1);
+ else
+ incValue(evx);
+ break;
+ default:
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// mouseReleaseEvent
+//---------------------------------------------------------
+
+void Dentry::mouseReleaseEvent(QMouseEvent*)
+ {
+ button = Qt::NoButton;
+ timer->stop();
+ }
+
+//---------------------------------------------------------
+// mouseMoveEvent
+//---------------------------------------------------------
+
+void Dentry::mouseMoveEvent(QMouseEvent*)
+ {
+ switch (button) {
+ case Qt::LeftButton:
+ break;
+ case Qt::MidButton:
+ break;
+ case Qt::RightButton:
+ break;
+ default:
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// mouseDoubleClickEvent
+//---------------------------------------------------------
+
+void Dentry::mouseDoubleClickEvent(QMouseEvent* event)
+ {
+ if (event->button() != Qt::LeftButton) {
+ mousePressEvent(event);
+ return;
+ }
+ setFocus();
+ QLineEdit::setFrame(true);
+ update();
+ emit doubleClicked(_id);
+ }
+
+//---------------------------------------------------------
+// setValue
+//---------------------------------------------------------
+
+void Dentry::setValue(double v)
+ {
+ if (v == val)
+ return;
+ setString(v);
+#if 0
+ if (setString(v)) {
+ clearFocus();
+ if (!drawFrame)
+ QLineEdit::setFrame(false);
+ setEnabled(false);
+ }
+ else {
+ setEnabled(true);
+ }
+#endif
+ val = v;
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/dentry.h b/attic/muse2-oom/muse2/muse/widgets/dentry.h
new file mode 100644
index 00000000..21c9ff38
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/dentry.h
@@ -0,0 +1,73 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: dentry.h,v 1.1.1.1.2.3 2008/08/18 00:15:26 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __DENTRY_H__
+#define __DENTRY_H__
+
+#include <QLineEdit>
+
+#include "sliderbase.h"
+
+//---------------------------------------------------------
+// Dentry
+//---------------------------------------------------------
+
+class Dentry : public QLineEdit {
+ Q_OBJECT
+
+ Q_PROPERTY( int id READ id WRITE setId )
+ Q_PROPERTY( double value READ value WRITE setValue )
+ Q_PROPERTY( bool frame READ frame WRITE setFrame )
+
+ SliderBase* _slider;
+ int button;
+ int starty;
+ bool drawFrame;
+ QTimer* timer;
+ double evx;
+ int timecount;
+
+ virtual void wheelEvent(QWheelEvent*);
+ virtual void mousePressEvent(QMouseEvent*);
+ virtual void mouseMoveEvent(QMouseEvent*);
+ virtual void mouseDoubleClickEvent(QMouseEvent*);
+ virtual void mouseReleaseEvent(QMouseEvent*);
+ void contextMenuEvent(QContextMenuEvent*);
+
+ protected:
+ int _id;
+ double val;
+
+ virtual void incValue(double x) = 0;
+ virtual void decValue(double x) = 0;
+ virtual bool setString(double) = 0;
+ virtual bool setSValue(const QString&) = 0;
+
+ private slots:
+ void repeat();
+
+ protected slots:
+ void endEdit();
+
+ signals:
+ void valueChanged(double, int);
+ void doubleClicked(int);
+
+ public slots:
+ virtual void setValue(double);
+
+ public:
+ Dentry(QWidget*, const char* name=0);
+ double value() const { return val; }
+ bool frame() const { return drawFrame; }
+ void setFrame(bool);
+ int id() const { return _id; }
+ void setId(int i) { _id = i; }
+ SliderBase* slider() const { return _slider; }
+ void setSlider(SliderBase* s) { _slider = s; }
+ };
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/didyouknow.h b/attic/muse2-oom/muse2/muse/widgets/didyouknow.h
new file mode 100644
index 00000000..7dbc03c5
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/didyouknow.h
@@ -0,0 +1,37 @@
+//=============================================================================
+// MusE
+// Linux Music Editor
+// $Id: didyouknow.h,v 1.0.0.0 2010/11/21 01:01:01 ogetbilo Exp $
+//
+// Copyright (C) 1999-2010 by Werner Schweer and others
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//=============================================================================
+
+#include "ui_didyouknow.h"
+
+class QDialog;
+
+
+//---------------------------------------------------------
+// DidYouKnowWidget
+// Wrapper around Ui::DidYouKnow
+//---------------------------------------------------------
+
+class DidYouKnowWidget : public QDialog, public Ui::DidYouKnow
+{
+ Q_OBJECT
+
+ public:
+ DidYouKnowWidget(QDialog *parent = 0) : QDialog(parent) { setupUi(this); }
+};
diff --git a/attic/muse2-oom/muse2/muse/widgets/didyouknow.ui b/attic/muse2-oom/muse2/muse/widgets/didyouknow.ui
new file mode 100644
index 00000000..5051ad3c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/didyouknow.ui
@@ -0,0 +1,91 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>DidYouKnow</class>
+ <widget class="QDialog" name="DidYouKnow">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>494</width>
+ <height>249</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Did you know?</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <item>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QTextEdit" name="tipText">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QCheckBox" name="dontShowCheckBox">
+ <property name="text">
+ <string>Don't show on startup</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer7">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>121</width>
+ <height>31</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="nextButton">
+ <property name="text">
+ <string>Next tip</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="closeButton">
+ <property name="text">
+ <string>Close</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>closeButton</sender>
+ <signal>clicked()</signal>
+ <receiver>DidYouKnow</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/dimap.cpp b/attic/muse2-oom/muse2/muse/widgets/dimap.cpp
new file mode 100644
index 00000000..1f87358c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/dimap.cpp
@@ -0,0 +1,308 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: dimap.cpp,v 1.1.1.1 2003/10/27 18:55:11 wschweer Exp $
+
+// Copyright (C) 1997 Josef Wilgen
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2,
+// as published by the Free Software Foundation.
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <cmath>
+#include "dimap.h"
+#include "mmath.h"
+
+const double DiMap::LogMin = 1.0e-150;
+const double DiMap::LogMax = 1.0e150;
+
+// DiMap - Map a double interval into an integer interval
+//
+// The DiMap class maps an interval of type double into an interval of
+// type integer. It consists
+// of two intervals D = [d1, d2] (double) and I = [i1, i2] (int), which are
+// specified with the @DiMap::setDblRange@ and @DiMap::setIntRange@
+// members. The point d1 is mapped to the point i1, and d2 is mapped to i2.
+// Any point inside or outside D can be mapped to a point inside or outside
+// I using @DiMap::transform@ or @DiMap::limTransform@ or vice versa
+// using @QwtPlot::invTransform@. D can be scaled linearly or
+// logarithmically, as specified with @DiMap::setDblRange@.
+
+//------------------------------------------------------------
+//.F DiMap::DiMap (1)
+// Construct a DiMap instance.
+//
+//.u Syntax
+//.f DiMap::DiMap()
+//
+//.u Description
+// The double and integer intervals are both set to [0,1].
+//------------------------------------------------------------
+
+DiMap::DiMap()
+ {
+ d_x1 = 0.0;
+ d_x2 = 1.0;
+ d_y1 = 0;
+ d_y2 = 1;
+ d_cnv = 1.0;
+ }
+
+//------------------------------------------------------------
+//.F DiMap::DiMap (2)
+// Construct a DiMap instance with initial integer
+// and double intervals
+//
+//.u Syntax
+//.f DiMap::DiMap(int i1, int i2, double d1, double d2, bool logarithmic)
+//
+//.u Parameters
+//.p int i1 -- first border of integer interval
+// int i2 -- second border of integer interval
+// double d1 -- first border of double interval
+// double d2 -- second border of double interval
+// bool logarithmic -- logarithmic mapping, TRUE or FALSE. Defaults
+// to FALSE.
+//------------------------------------------------------------
+
+DiMap::DiMap(int i1, int i2, double d1, double d2, bool logarithmic)
+ {
+ d_log = logarithmic;
+ setIntRange(i1,i2);
+ setDblRange(d1, d2);
+ }
+
+//------------------------------------------------------------
+//.F DiMap::~DiMap
+// Destroy a DiMap instance.
+//
+//.u Syntax
+//.f DiMap::~DiMap()
+//------------------------------------------------------------
+
+DiMap::~DiMap()
+ {
+ }
+
+//------------------------------------------------------------
+//.F DiMap::contains (1)
+// Returns TRUE if a value x lies inside or at the border of the
+// map's double range.
+//
+//.u Syntax
+//.f bool DiMap::contains(double x)
+//
+//.u Parameters
+//.p double x -- value
+//------------------------------------------------------------
+
+bool DiMap::contains(double x) const
+ {
+ return ( (x >= qwtMin(d_x1, d_x1)) && (x <= qwtMax(d_x1, d_x2)));
+ }
+
+//------------------------------------------------------------
+//.F DiMap::contains (2)
+// Returns TRUE if a value x lies inside or at the border of the
+// map's integer range
+//
+//.u Syntax
+//.f bool DiMap::contains(int x)
+//
+//.u Parameters
+//.p int x -- value
+//------------------------------------------------------------
+
+bool DiMap::contains(int x) const
+ {
+ return ( (x >= qwtMin(d_y1, d_y1)) && (x <= qwtMax(d_y1, d_y2)));
+ }
+
+//------------------------------------------------------------
+//.F DiMap::setDblRange
+// Specify the borders of the double interval
+//
+//.u Syntax
+//.f void DiMap::setDblRange(double d1, double d2, bool lg = FALSE)
+//
+//.u Parameters
+//.p double d1 -- first border
+// double d2 -- second border
+// bool lg -- logarithmic (TRUE) or linear (FALSE)
+// scaling. Defaults to FALSE.
+//------------------------------------------------------------
+
+void DiMap::setDblRange(double d1, double d2, bool lg)
+ {
+ if (lg) {
+ d_log = true;
+ if (d1 < LogMin)
+ d1 = LogMin;
+ else if (d1 > LogMax)
+ d1 = LogMax;
+
+ if (d2 < LogMin)
+ d2 = LogMin;
+ else if (d2 > LogMax)
+ d2 = LogMax;
+
+ d_x1 = log(d1);
+ d_x2 = log(d2);
+ }
+ else {
+ d_log = FALSE;
+ d_x1 = d1;
+ d_x2 = d2;
+ }
+ newFactor();
+ }
+
+//------------------------------------------------------------
+//.F DiMap::setIntRange
+// Specify the borders of the integer interval
+//
+//.u Syntax
+//.f void DiMap::setIntRange(int i1, int i2)
+//
+//.u Parameters
+//.p int i1 -- first border
+// int i2 -- second border
+//------------------------------------------------------------
+
+void DiMap::setIntRange(int i1, int i2)
+ {
+ d_y1 = i1;
+ d_y2 = i2;
+ newFactor();
+ }
+
+//------------------------------------------------------------
+//.F DiMap::transform
+// Transform a point in double interval into an point in the
+// integer interval
+//
+//.u Syntax
+//.f int DiMap::transform(double x)
+//
+//.u Parameters
+//.p double x
+//
+//.u Return Value
+//.t
+// linear mapping: -- rint(i1 + (i2 - i1) / (d2 - d1) * (x - d1))
+// logarithmic mapping: -- rint(i1 + (i2 - i1) / log(d2 / d1) * log(x / d1))
+//
+//.u Note
+// The specified point is allowed to lie outside the intervals. If you
+// want to limit the returned value, use @DiMap::limTransform@.
+//------------------------------------------------------------
+
+int DiMap::transform(double x) const
+ {
+ if (d_log)
+ return (d_y1 + int(rint( (log(x) - d_x1) * d_cnv )));
+ else
+ return (d_y1 + int(rint( (x - d_x1) * d_cnv )));
+ }
+
+//------------------------------------------------------------
+//.F DiMap::invTransform
+// Transform an integer value into a double value
+//
+//.u Syntax
+//.f double DiMap::invTransform(int y)
+//
+//.u Parameters
+//.p int y -- integer value to be transformed
+//
+//.u Return Value
+//.t
+// linear mapping: -- d1 + (d2 - d1) / (i2 - i1) * (y - i1)
+// logarithmic mapping: -- d1 + (d2 - d1) / log(i2 / i1) * log(y / i1)
+//------------------------------------------------------------
+
+double DiMap::invTransform(int y) const
+ {
+ if (d_cnv == 0.0)
+ return 0.0;
+ else {
+ if (d_log)
+ return exp(d_x1 + double(y - d_y1) / d_cnv );
+ else
+ return ( d_x1 + double(y - d_y1) / d_cnv );
+ }
+ }
+
+//------------------------------------------------------------
+//.F DiMap::limTransform
+// Transform and limit
+//
+//.u Syntax
+//.f int DiMap::limTransform(double x)
+//
+//.u Parameters
+//.p double x
+//
+//.u Return Value
+// transformed value
+//
+//.u Description
+// The function is similar to @DiMap::transform@, but limits the input value
+// to the nearest border of the map's double interval if it lies outside
+// that interval.
+//------------------------------------------------------------
+
+int DiMap::limTransform(double x) const
+ {
+ if ( x > qwtMax(d_x1, d_x2) )
+ x = qwtMax(d_x1, d_x2);
+ else if ( x < qwtMin(d_x1, d_x2))
+ x = qwtMin(d_x1, d_x2);
+ return transform(x);
+ }
+
+//------------------------------------------------------------
+//.F DiMap::xTransform
+// Exact transformation
+//
+//.u Syntax
+//.f double DiMap::dTransform(double x)
+//
+//.u Parameters
+//.p double x -- value to be transformed
+//
+//.u Return Value
+//.t
+// linear mapping: -- i1 + (i2 - i1) / (d2 - d1) * (x - d1)
+// logarithmic mapping: -- i1 + (i2 - i1) / log(d2 / d1) * log(x / d1)
+//
+//.u Description
+// This function is similar to @DiMap::transform@, but
+// makes the integer interval appear to be double.
+//------------------------------------------------------------
+
+double DiMap::xTransform(double x) const
+ {
+ double rv;
+
+ if (d_log)
+ rv = double(d_y1) + (log(x) - d_x1) * d_cnv;
+ else
+ rv = double(d_y1) + (x - d_x1) * d_cnv;
+ return rv;
+ }
+
+//------------------------------------------------------------
+//.F DiMap::newFactor
+// Re-calculate the conversion factor.
+//------------------------------------------------------------
+
+void DiMap::newFactor()
+ {
+ if (d_x2 != d_x1)
+ d_cnv = double(d_y2 - d_y1) / (d_x2 - d_x1);
+ else
+ d_cnv = 0.0;
+ }
diff --git a/attic/muse2-oom/muse2/muse/widgets/dimap.h b/attic/muse2-oom/muse2/muse/widgets/dimap.h
new file mode 100644
index 00000000..cf51dee2
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/dimap.h
@@ -0,0 +1,55 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: dimap.h,v 1.1.1.1 2003/10/27 18:54:28 wschweer Exp $
+//
+// Copyright (C) 1997 Josef Wilgen
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2,
+// as published by the Free Software Foundation.
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __DIMAP_H__
+#define __DIMAP_H__
+
+#include <QtGlobal>
+
+class DiMap
+ {
+ double d_x1, d_x2; // double interval boundaries
+ int d_y1,d_y2; // integer interval boundaries
+ double d_cnv; // conversion factor
+ bool d_log; // logarithmic scale?
+
+ void newFactor();
+
+ public:
+ static const double LogMin;
+ static const double LogMax;
+
+ DiMap();
+ DiMap(int, int, double, double, bool lg = FALSE);
+ ~DiMap();
+
+
+ bool contains(double x) const;
+ bool contains(int x) const;
+
+ void setIntRange(int i1, int i2);
+ void setDblRange(double d1, double d2, bool lg = FALSE);
+
+ int transform(double x) const;
+ double invTransform(int i) const;
+ int limTransform(double x) const;
+ double xTransform(double x) const;
+
+ double d1() const { return d_x1;}
+ double d2() const { return d_x2;}
+ int i1() const { return d_y1;}
+ int i2() const { return d_y2;}
+ bool logarithmic() const { return d_log;}
+ };
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/doublelabel.cpp b/attic/muse2-oom/muse2/muse/widgets/doublelabel.cpp
new file mode 100644
index 00000000..fe2bfc6a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/doublelabel.cpp
@@ -0,0 +1,193 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: doublelabel.cpp,v 1.1.1.1.2.2 2008/08/18 00:15:26 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <cmath>
+
+#include "doublelabel.h"
+
+//---------------------------------------------------------
+// DoubleLabel
+//---------------------------------------------------------
+
+DoubleLabel::DoubleLabel(QWidget* parent, const char* name)
+ : Dentry(parent, name), _specialText("---")
+ {
+ min = 0.0;
+ max = 1.0;
+ _off = -1.0;
+ _precision = 3;
+ setValue(0.0);
+ }
+
+DoubleLabel::DoubleLabel(double _val, double m, double mx, QWidget* parent)
+ : Dentry(parent), _specialText("---")
+ {
+ min = m;
+ max = mx;
+ _off = m - 1.0;
+ _precision = 3;
+ setValue(_val);
+ }
+
+//---------------------------------------------------------
+// setOff
+//---------------------------------------------------------
+
+void DoubleLabel::setOff(double v)
+{
+ _off = v;
+ setString(val);
+}
+
+//---------------------------------------------------------
+// calcIncrement()
+//---------------------------------------------------------
+
+double DoubleLabel::calcIncrement() const
+{
+ double dif;
+ if(max - min > 0)
+ dif = max - min;
+ else
+ dif = min - max;
+
+ if(dif <= 10.0)
+ return 0.1;
+ else
+ if(dif <= 100.0)
+ return 1.0;
+ else
+ return 10.0;
+}
+
+//---------------------------------------------------------
+// setString
+//---------------------------------------------------------
+
+bool DoubleLabel::setString(double v)
+ {
+ if(v <= _off || v > max)
+ {
+ setText(_specialText);
+ return true;
+ }
+ else
+ if(v < min)
+ {
+ setText(QString("---"));
+ return true;
+ }
+ else
+ {
+ QString s;
+ s.setNum(v, 'f', _precision);
+ if (!_suffix.isEmpty()) {
+ s += " ";
+ s += _suffix;
+ }
+
+ setText(s);
+ }
+ return false;
+ }
+
+//---------------------------------------------------------
+// setSValue
+//---------------------------------------------------------
+
+bool DoubleLabel::setSValue(const QString& s)
+ {
+ bool ok;
+ double v = s.toDouble(&ok);
+ if (ok && (v != val)) {
+ if (v < min)
+ v = min;
+ if (v > max)
+ v = max;
+ setValue(v);
+ emit valueChanged(val, _id);
+ }
+ return false;
+ }
+
+//---------------------------------------------------------
+// incValue
+//---------------------------------------------------------
+
+void DoubleLabel::incValue(double)
+ {
+ if(val >= max)
+ return;
+ double inc = calcIncrement();
+ if(val + inc >= max)
+ setValue(max);
+ else
+ setValue(val + inc);
+ emit valueChanged(val, _id);
+ }
+
+//---------------------------------------------------------
+// decValue
+//---------------------------------------------------------
+
+void DoubleLabel::decValue(double)
+ {
+ if(val <= min)
+ return;
+ double inc = calcIncrement();
+ if(val - inc <= min)
+ setValue(min);
+ else
+ setValue(val - inc);
+ emit valueChanged(val, _id);
+ }
+
+//---------------------------------------------------------
+// setPrecision
+//---------------------------------------------------------
+
+void DoubleLabel::setPrecision(int v)
+ {
+ _precision = v;
+ setString(val);
+ }
+
+//---------------------------------------------------------
+// sizeHint
+//---------------------------------------------------------
+
+QSize DoubleLabel::sizeHint() const
+ {
+ QFontMetrics fm = fontMetrics();
+ int h = fm.height() + 4;
+ int n = _precision;
+
+ ++n; // For some reason I have to add one digit. Shouldn't have to.
+ double aval = fmax(fabs(max), fabs(min));
+ if (aval >= 10.0)
+ ++n;
+ if (aval >= 100.0)
+ ++n;
+ if (aval >= 1000.0)
+ ++n;
+ if (aval >= 10000.0)
+ ++n;
+ if (aval >= 100000.0)
+ ++n;
+
+ int w = fm.width(QString("-0.")) + fm.width('0') * n + 6;
+ if(!_suffix.isEmpty())
+ {
+ w += fm.width(QString(" ")) + fm.width(_suffix);
+ }
+ return QSize(w, h);
+ }
+
+QSize DoubleLabel::minimumSizeHint() const
+{
+ return sizeHint();
+}
diff --git a/attic/muse2-oom/muse2/muse/widgets/doublelabel.h b/attic/muse2-oom/muse2/muse/widgets/doublelabel.h
new file mode 100644
index 00000000..b5e40597
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/doublelabel.h
@@ -0,0 +1,61 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: doublelabel.h,v 1.2.2.3 2008/08/18 00:15:26 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __DOUBLELABEL_H__
+#define __DOUBLELABEL_H__
+
+#include "dentry.h"
+
+//---------------------------------------------------------
+// DoubleLabel
+//---------------------------------------------------------
+
+class DoubleLabel : public Dentry {
+ Q_OBJECT
+
+ Q_PROPERTY( double minValue READ minValue WRITE setMinValue )
+ Q_PROPERTY( double maxValue READ maxValue WRITE setMaxValue )
+ Q_PROPERTY( QString specialText READ specialText WRITE setSpecialText )
+ Q_PROPERTY( QString suffix READ suffix WRITE setSuffix )
+ Q_PROPERTY( int precision READ precision WRITE setPrecision )
+
+ double min, max, _off;
+ QString _specialText; // text to show if value outside min,max
+ QString _suffix;
+ int _precision;
+
+ double calcIncrement() const;
+
+ virtual bool setSValue(const QString&);
+ virtual bool setString(double val);
+ virtual void incValue(double);
+ virtual void decValue(double);
+
+ public:
+ DoubleLabel(QWidget* parent = 0, const char* name = 0);
+ DoubleLabel(double val, double min, double max, QWidget* parent = 0);
+ virtual QSize sizeHint() const;
+ virtual QSize minimumSizeHint () const;
+ double minValue() const { return min; }
+ double maxValue() const { return max; }
+ double off() const { return _off; }
+ void setMinValue(double v) { min = v; }
+ void setMaxValue(double v) { max = v; }
+ void setRange(double a, double b) { _off = a - (min - _off); min = a; max = b; }
+ void setOff(double v);
+ int precision() const { return _precision; }
+ void setPrecision(int val);
+ QString specialText() const { return _specialText; }
+ void setSpecialText(const QString& s) {
+ _specialText = s;
+ update();
+ }
+ QString suffix() const { return _suffix; }
+ void setSuffix(const QString& s) { _suffix = s; }
+ };
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/drange.cpp b/attic/muse2-oom/muse2/muse/widgets/drange.cpp
new file mode 100644
index 00000000..e144dfea
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/drange.cpp
@@ -0,0 +1,265 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: drange.cpp,v 1.2.2.1 2009/03/09 02:05:18 terminator356 Exp $
+//
+// Copyright (C) 1997 Josef Wilgen
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2,
+// as published by the Free Software Foundation.
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <cmath>
+
+#include <QtGlobal>
+
+#include "mmath.h"
+#include "drange.h"
+
+const double DoubleRange::MinRelStep = 1.0e-10;
+const double DoubleRange::DefaultRelStep = 1.0e-2;
+const double DoubleRange::MinEps = 1.0e-10;
+
+//-----------------------------------------------------------
+// This class is useful as a base class or a member for sliders.
+// It represents an interval of type double within which a value can
+// be moved. The value can be either an arbitrary point inside
+// the interval (see @DoubleRange::setValue@), or it can be fitted
+// into a step raster (see @DoubleRange::fitValue@ and
+// @DoubleRange::incValue@).
+//
+// As a special case, a DoubleRange can be periodic, which means that
+// a value outside the interval will be mapped to a value inside the
+// interval when @DoubleRange::setValue@, @DoubleRange::fitValue@,
+// @DoubleRange::incValue@ or @DoubleRange::incPages@ are called.
+//------------------------------------------------------------
+
+//---------------------------------------------------------
+// doubleRange
+//---------------------------------------------------------
+
+DoubleRange::DoubleRange()
+ {
+ d_minValue = 0;
+ d_maxValue = 100.0;
+ d_prevValue = 0.0;
+ d_exactPrevValue = 0.0;
+ d_exactValue = 0.0;
+ d_value = 0.0;
+ d_step = 0.1;
+ d_periodic = FALSE;
+ }
+
+//---------------------------------------------------------
+// setNewValue
+//---------------------------------------------------------
+
+void DoubleRange::setNewValue(double x, bool align)
+ {
+ d_prevValue = d_value;
+
+ double vmin = qwtMin(d_minValue, d_maxValue);
+ double vmax = qwtMax(d_minValue, d_maxValue);
+
+ // Range check
+
+ if (x < vmin) {
+ if ((d_periodic) && (vmin != vmax))
+ d_value = x + ceil((vmin - x) / (vmax - vmin))
+ * (vmax - vmin);
+ else
+ d_value = vmin;
+ }
+ else if (x > vmax) {
+ if ((d_periodic) && (vmin != vmax))
+ d_value = x - ceil( ( x - vmax) / (vmax - vmin ))
+ * (vmax - vmin);
+ else
+ d_value = vmax;
+ }
+ else
+ d_value = x;
+
+ d_exactPrevValue = d_exactValue;
+ d_exactValue = d_value;
+
+ // align to grid
+ if (align) {
+ if (d_step != 0.0)
+ d_value = d_minValue + rint((d_value - d_minValue) / d_step ) * d_step;
+ else
+ d_value = d_minValue;
+
+ // correct rounding error at the border
+ if (fabs(d_value - d_maxValue) < MinEps * qwtAbs(d_step))
+ d_value = d_maxValue;
+
+ // correct rounding error if value = 0
+ if (fabs(d_value) < MinEps * qwtAbs(d_step))
+ d_value = 0.0;
+ }
+ if (d_prevValue != d_value)
+ valueChange();
+ }
+
+//---------------------------------------------------------
+// fitValue
+// Adjust the value to the closest point in the step
+// raster.
+// The value is clipped when it lies outside the range.
+// When the range is @DoubleRange::periodic@, it will
+// be mapped to a point in the interval such that
+//---------------------------------------------------------
+
+void DoubleRange::fitValue(double x)
+ {
+ setNewValue(x, true);
+ }
+
+//---------------------------------------------------------
+// setValue
+// Set a new value without adjusting to the step raster
+// The value is clipped when it lies outside the range.
+// When the range is @DoubleRange::periodic@, it will
+// be mapped to a point in the interval such that
+//
+// new value := x + n * (max. value - min. value)
+//
+// with an integer number n.
+//---------------------------------------------------------
+
+void DoubleRange::setValue(double x)
+ {
+ setNewValue(x, false);
+ }
+
+//---------------------------------------------------------
+// setRange
+// Specify range and step size
+// - A change of the range changes the value if it lies outside the
+// new range. The current value
+// will *not* be adjusted to the new step raster.
+// - vmax < vmin is allowed.
+// - If the step size is left out or set to zero, it will be
+// set to 1/100 of the interval length.
+// - If the step size has an absurd value, it will be corrected
+// to a better one.
+//---------------------------------------------------------
+
+void DoubleRange::setRange(double vmin, double vmax, double vstep, int pageSize)
+ {
+ bool rchg = ((d_maxValue != vmax) || (d_minValue != vmin));
+
+ if (rchg) {
+ d_minValue = vmin;
+ d_maxValue = vmax;
+ }
+
+ //
+ // look if the step width has an acceptable
+ // value or otherwise change it.
+ //
+ setStep(vstep);
+
+ //
+ // limit page size
+ //
+ d_pageSize = qwtLim(pageSize,0, int(qwtAbs((d_maxValue - d_minValue) / d_step)));
+
+ //
+ // If the value lies out of the range, it
+ // will be changed. Note that it will not be adjusted to
+ // the new step width.
+ setNewValue(d_value, false);
+
+ // call notifier after the step width has been
+ // adjusted.
+ if (rchg)
+ rangeChange();
+ }
+
+//---------------------------------------------------------
+// setStep
+// Change the step raster
+//
+// The value will *not* be adjusted to the new step raster.
+//---------------------------------------------------------
+
+void DoubleRange::setStep(double vstep)
+ {
+ double newStep,intv;
+
+ intv = d_maxValue - d_minValue;
+
+ if (vstep == 0.0)
+ newStep = intv * DefaultRelStep;
+ else {
+ if (((intv > 0) && (vstep < 0)) || ((intv < 0) && (vstep > 0)))
+ newStep = -vstep;
+ else
+ newStep = vstep;
+
+ if ( fabs(newStep) < fabs(MinRelStep * intv) )
+ newStep = MinRelStep * intv;
+ }
+
+ if (newStep != d_step) {
+ d_step = newStep;
+ stepChange();
+ }
+ }
+
+//---------------------------------------------------------
+// setPeriodic
+// Make the range periodic
+//
+// When the range is periodic, the value will be set to a point
+// inside the interval such that
+//
+// point = value + n * width
+//
+// if the user tries to set a new value which is outside the range.
+// If the range is nonperiodic (the default), values outside the
+// range will be clipped.
+//---------------------------------------------------------
+
+void DoubleRange::setPeriodic(bool tf)
+ {
+ d_periodic = tf;
+ }
+
+//------------------------------------------------------------
+// incValue
+// Increment the value by a specified number of steps
+//
+// As a result of this operation, the new value will always be
+// adjusted to the step raster.
+//------------------------------------------------------------
+
+void DoubleRange::incValue(int nSteps)
+ {
+ setNewValue(d_value + double(nSteps) * d_step, true);
+ }
+
+//---------------------------------------------------------
+// incPages
+// Increment the value by a specified number of pages
+//---------------------------------------------------------
+
+void DoubleRange::incPages(int nPages)
+ {
+ setNewValue(d_value + double(nPages) * double(d_pageSize)
+ * d_step, true);
+ }
+
+//---------------------------------------------------------
+// step
+//---------------------------------------------------------
+
+double DoubleRange::step() const
+ {
+ return qwtAbs(d_step);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/drange.h b/attic/muse2-oom/muse2/muse/widgets/drange.h
new file mode 100644
index 00000000..d0931e86
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/drange.h
@@ -0,0 +1,69 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: drange.h,v 1.1.1.1.2.1 2007/01/27 14:52:43 spamatica Exp $
+//
+// Copyright (C) 1997 Josef Wilgen
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2,
+// as published by the Free Software Foundation.
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __DOUBLE_RANGE_H__
+#define __DOUBLE_RANGE_H__
+
+//---------------------------------------------------------
+// DoubleRange
+//---------------------------------------------------------
+
+class DoubleRange
+ {
+ static const double MinRelStep;
+ static const double DefaultRelStep;
+ static const double MinEps;
+
+ double d_minValue;
+ double d_maxValue;
+ double d_step;
+ int d_pageSize;
+ double d_value;
+ double d_exactValue;
+ double d_exactPrevValue;
+ double d_prevValue;
+ bool d_periodic;
+
+ void setNewValue(double x, bool align = false);
+
+ protected:
+ double exactValue() const { return d_exactValue; }
+ double exactPrevValue() const { return d_exactPrevValue; }
+ double prevValue() const { return d_prevValue; }
+ virtual void valueChange() {}
+ virtual void stepChange() {}
+ virtual void rangeChange() {}
+
+ public:
+ DoubleRange();
+ virtual ~DoubleRange(){};
+
+ double value() const { return d_value; }
+ virtual void setValue(double);
+
+ virtual void fitValue(double);
+ virtual void incValue(int);
+ virtual void incPages(int);
+ void setPeriodic(bool tf);
+ void setRange(double vmin, double vmax, double vstep = 0.0,
+ int pagesize = 1);
+ void setStep(double);
+
+ double maxValue() const { return d_maxValue; }
+ double minValue() const { return d_minValue; }
+ bool periodic() const { return d_periodic; }
+ int pageSize() const { return d_pageSize; }
+ double step() const;
+ };
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/editnotedialogbase.ui b/attic/muse2-oom/muse2/muse/widgets/editnotedialogbase.ui
new file mode 100644
index 00000000..b19efc49
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/editnotedialogbase.ui
@@ -0,0 +1,223 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>EditNoteDialogBase</class>
+ <widget class="QDialog" name="EditNoteDialogBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>231</width>
+ <height>182</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Enter Note</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="5" column="0" colspan="2">
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <spacer name="Horizontal Spacing2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonOk">
+ <property name="text">
+ <string>OK</string>
+ </property>
+ <property name="shortcut">
+ <number>0</number>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonCancel">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ <property name="shortcut">
+ <number>0</number>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="TextLabel2">
+ <property name="text">
+ <string>Length:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="TextLabel1">
+ <property name="text">
+ <string>Time Position:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="TextLabel3">
+ <property name="text">
+ <string>Pitch:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="TextLabel4">
+ <property name="text">
+ <string>Velocity On:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="TextLabel5">
+ <property name="text">
+ <string>Velocity Off:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="Awl::PosEdit" name="epos"/>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="il1">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>1000000</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QSpinBox" name="il2">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QSpinBox" name="il3">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="PitchEdit" name="pl" native="true"/>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <customwidgets>
+ <customwidget>
+ <class>Awl::PosEdit</class>
+ <extends>QWidget</extends>
+ <header>awl/posedit.h</header>
+ <container>0</container>
+ </customwidget>
+ <customwidget>
+ <class>PitchEdit</class>
+ <extends>QWidget</extends>
+ <header>pitchedit.h</header>
+ </customwidget>
+ </customwidgets>
+ <tabstops>
+ <tabstop>il1</tabstop>
+ <tabstop>pl</tabstop>
+ <tabstop>il2</tabstop>
+ <tabstop>il3</tabstop>
+ <tabstop>buttonOk</tabstop>
+ <tabstop>buttonCancel</tabstop>
+ </tabstops>
+ <includes>
+ <include location="local">pitchedit.h</include>
+ </includes>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>EditNoteDialogBase</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>EditNoteDialogBase</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/editsysexdialogbase.ui b/attic/muse2-oom/muse2/muse/widgets/editsysexdialogbase.ui
new file mode 100644
index 00000000..adf5b186
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/editsysexdialogbase.ui
@@ -0,0 +1,196 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>EditSysexDialogBase</class>
+ <widget class="QDialog" name="EditSysexDialogBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>433</width>
+ <height>330</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Enter SysEx</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="TextLabel1">
+ <property name="text">
+ <string>TimePosition:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="Awl::PosEdit" name="epos"/>
+ </item>
+ <item>
+ <spacer name="Spacer2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QToolButton" name="saveButton">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="loadButton">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="edit"/>
+ </item>
+ <item>
+ <widget class="QLabel" name="TextLabel2">
+ <property name="text">
+ <string>Comment:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="comment"/>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <spacer name="Horizontal Spacing2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonOk">
+ <property name="text">
+ <string>OK</string>
+ </property>
+ <property name="shortcut">
+ <number>0</number>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonCancel">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ <property name="shortcut">
+ <number>0</number>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <customwidgets>
+ <customwidget>
+ <class>Awl::PosEdit</class>
+ <extends>QWidget</extends>
+ <header>awl/posedit.h</header>
+ <container>0</container>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>EditSysexDialogBase</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>EditSysexDialogBase</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/fdialogbuttons.ui b/attic/muse2-oom/muse2/muse/widgets/fdialogbuttons.ui
new file mode 100644
index 00000000..24f58e1f
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/fdialogbuttons.ui
@@ -0,0 +1,159 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>FileDialogButtons</class>
+ <widget class="QWidget" name="FileDialogButtons">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>145</width>
+ <height>438</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>fdialogbuttons</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QFrame" name="pathGroup">
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <property name="lineWidth">
+ <number>0</number>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QToolButton" name="globalButton">
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Global</string>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>48</width>
+ <height>48</height>
+ </size>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="toolButtonStyle">
+ <enum>Qt::ToolButtonTextUnderIcon</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="userButton">
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>User</string>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>48</width>
+ <height>48</height>
+ </size>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="toolButtonStyle">
+ <enum>Qt::ToolButtonTextUnderIcon</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="projectButton">
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>80</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Project</string>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>48</width>
+ <height>48</height>
+ </size>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="toolButtonStyle">
+ <enum>Qt::ToolButtonTextUnderIcon</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <spacer name="Spacer1">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>245</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QFrame" name="loadAllGroup">
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <widget class="QRadioButton" name="loadAllButton">
+ <property name="text">
+ <string>Songdata +
+Configuration</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="loadSongButton">
+ <property name="text">
+ <string>only
+Songdata</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/filedialog.cpp b/attic/muse2-oom/muse2/muse/widgets/filedialog.cpp
new file mode 100644
index 00000000..d2b189b6
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/filedialog.cpp
@@ -0,0 +1,546 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: filedialog.cpp,v 1.3.2.3 2005/06/19 06:32:07 lunar_shuttle Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <errno.h>
+
+#include <QIcon>
+#include <QMessageBox>
+#include <QPixmap>
+#include <QSplitter>
+#include <QStringList>
+
+#include "icons.h"
+#include "filedialog.h"
+#include "../globals.h"
+#include "gconfig.h"
+
+MFileDialog::ViewType MFileDialog::lastViewUsed = GLOBAL_VIEW;
+QString MFileDialog::lastUserDir = "";
+QString MFileDialog::lastGlobalDir = "";
+
+//---------------------------------------------------------
+// createDir
+// return true if dir could not created
+//---------------------------------------------------------
+
+static bool createDir(const QString& s)
+ {
+ QString sl("/");
+ QStringList l = s.split(sl, QString::SkipEmptyParts);
+ QString path(sl);
+ QDir dir;
+ for (QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
+ dir.setPath(path);
+ if (!QDir(path + sl + *it).exists()) {
+ if (!dir.mkdir(*it)) {
+ printf("mkdir failed: %s %s\n",
+ path.toLatin1().constData(), (*it).toLatin1().constData());
+ return true;
+ }
+ }
+ path += sl;
+ path += *it;
+ }
+ return false;
+ }
+
+//---------------------------------------------------------
+// testDirCreate
+// return true if dir does not exist
+//---------------------------------------------------------
+
+static bool testDirCreate(QWidget* parent, const QString& path)
+{
+ QDir dir(path);
+ if (!dir.exists())
+ {
+ if(QMessageBox::information(parent,
+ QWidget::tr("MusE: get file name"),
+ QWidget::tr("The directory\n") + path
+ + QWidget::tr("\ndoes not exist.\nCreate it?"),
+ QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok) != QMessageBox::Ok)
+ return true;
+
+ if (createDir(path))
+ {
+ QMessageBox::critical(parent,
+ QWidget::tr("MusE: create directory"),
+ QWidget::tr("creating dir failed"));
+ return true;
+ }
+ }
+ return false;
+}
+
+//---------------------------------------------------------
+// globalToggled
+//---------------------------------------------------------
+
+void MFileDialog::globalToggled(bool flag)
+ {
+ if (flag) {
+ buttons.userButton->setChecked(!flag);
+ buttons.projectButton->setChecked(!flag);
+ if (lastGlobalDir.isEmpty())
+ lastGlobalDir = museGlobalShare + QString("/") + baseDir; // Initialize if first time
+ QString dir = lastGlobalDir;
+ setDirectory(dir);
+ lastViewUsed = GLOBAL_VIEW;
+ }
+ }
+
+//---------------------------------------------------------
+// userToggled
+//---------------------------------------------------------
+
+void MFileDialog::userToggled(bool flag)
+ {
+ if (flag) {
+ buttons.globalButton->setChecked(!flag);
+ buttons.projectButton->setChecked(!flag);
+
+
+ if (lastUserDir.isEmpty()) {
+ lastUserDir = museUser + QString("/") + baseDir; // Initialize if first time
+ }
+
+ if (testDirCreate(this, lastUserDir))
+ setDirectory(museUser);
+ else
+ setDirectory(lastUserDir);
+
+ lastViewUsed = USER_VIEW;
+ }
+ }
+
+//---------------------------------------------------------
+// projectToggled
+//---------------------------------------------------------
+
+void MFileDialog::projectToggled(bool flag)
+ {
+ if (flag) {
+ buttons.globalButton->setChecked(!flag);
+ buttons.userButton->setChecked(!flag);
+
+ QString s;
+ if (museProject == museProjectInitPath ) {
+ // if project path is uninitialized, meaning it is still set to museProjectInitPath.
+ // then project path is set to current pwd instead.
+ //s = QString(getcwd(0,0)) + QString("/");
+ s = config.projectBaseFolder;
+ }
+ else
+ s = museProject + QString("/"); // + baseDir;
+
+ if (testDirCreate(this, s))
+ setDirectory(museProject);
+ else
+ setDirectory(s);
+ lastViewUsed = PROJECT_VIEW;
+ }
+ }
+
+
+//---------------------------------------------------------
+// MFileDialog
+//---------------------------------------------------------
+
+MFileDialog::MFileDialog(const QString& dir,
+ const QString& filter, QWidget* parent, bool writeFlag)
+ : QFileDialog(parent, QString(), QString("."), filter)
+ {
+ showButtons = false;
+ if (dir.length() > 0 && dir[0] == QChar('/')) {
+ setDirectory(dir);
+ }
+ else {
+ // We replace the original sidebar widget with our 3-button widget
+ QLayout* mainlayout = this->layout();
+ QSplitter* spl = (QSplitter*)mainlayout->itemAt(2)->widget();
+ QWidget* original_sidebarwidget = spl->widget(0);
+ original_sidebarwidget->setVisible(false);
+
+ baseDir = dir;
+ showButtons = true;
+
+ spl->insertWidget(0,&buttons);
+
+ // Qt >= 4.6 allows us to select icons from the theme
+#if QT_VERSION >= 0x040600
+ buttons.globalButton->setIcon(*globalIcon);
+ buttons.userButton->setIcon(*userIcon);
+ buttons.projectButton->setIcon(*projectIcon);
+#else
+ buttons.globalButton->setIcon(style()->standardIcon(QStyle::SP_DirIcon));
+ buttons.userButton->setIcon(style()->standardIcon(QStyle::SP_DirHomeIcon));
+ buttons.projectButton->setIcon(style()->standardIcon(QStyle::SP_DirOpenIcon));
+#endif
+
+ connect(buttons.globalButton, SIGNAL(toggled(bool)), this, SLOT(globalToggled(bool)));
+ connect(buttons.userButton, SIGNAL(toggled(bool)), this, SLOT(userToggled(bool)));
+ connect(buttons.projectButton, SIGNAL(toggled(bool)), this, SLOT(projectToggled(bool)));
+ connect(this, SIGNAL(directoryEntered(const QString&)), SLOT(directoryChanged(const QString&)));
+
+ if (writeFlag) {
+ setAcceptMode(QFileDialog::AcceptSave);
+ buttons.globalButton->setEnabled(false);
+ switch (lastViewUsed) {
+ case GLOBAL_VIEW:
+ case PROJECT_VIEW:
+ buttons.projectButton->setChecked(true);
+ break;
+
+ case USER_VIEW:
+ buttons.userButton->setChecked(true);
+ break;
+ }
+ }
+ else {
+ switch (lastViewUsed) {
+ case GLOBAL_VIEW:
+ buttons.globalButton->setChecked(true);
+ break;
+
+ case PROJECT_VIEW:
+ buttons.projectButton->setChecked(true);
+ break;
+
+ case USER_VIEW:
+ buttons.userButton->setChecked(true);
+ break;
+ }
+
+ }
+ buttons.loadAllGroup->setVisible(false);
+ }
+ }
+
+//---------------------------------------------------------
+// MFileDialog::directoryChanged
+//---------------------------------------------------------
+void MFileDialog::directoryChanged(const QString&)
+ {
+ ViewType currentView = GLOBAL_VIEW;
+ QDir ndir = directory();
+ ///QString newdir = ndir.absolutePath().toLatin1();
+ QString newdir = ndir.absolutePath();
+ if (buttons.projectButton->isChecked())
+ currentView = PROJECT_VIEW;
+ else if (buttons.userButton->isChecked())
+ currentView = USER_VIEW;
+
+ switch (currentView) {
+ case GLOBAL_VIEW:
+ lastGlobalDir = newdir;
+ break;
+
+ case USER_VIEW:
+ lastUserDir = newdir;
+ break;
+
+ case PROJECT_VIEW: // Do nothing
+ default:
+ break;
+ }
+ }
+
+
+//---------------------------------------------------------
+// getFilterExtension
+//---------------------------------------------------------
+
+QString getFilterExtension(const QString &filter)
+{
+ //
+ // Return the first extension found. Must contain at least one * character.
+ //
+
+ int pos = filter.indexOf('*');
+ if(pos == -1)
+ return QString();
+
+ QString filt;
+ int len = filter.length();
+ ++pos;
+ for( ; pos < len; ++pos)
+ {
+ QChar c = filter[pos];
+ if((c == ')') || (c == ';') || (c == ',') || (c == ' '))
+ break;
+ filt += filter[pos];
+ }
+ return filt;
+}
+
+//---------------------------------------------------------
+// getOpenFileName
+//---------------------------------------------------------
+QString getOpenFileName(const QString &startWith,
+ const QStringList& filters, QWidget* parent, const QString& name, bool* all, MFileDialog::ViewType viewType)
+ {
+ QString initialSelection; // FIXME Tim.
+ MFileDialog *dlg = new MFileDialog(startWith, QString::null, parent, false);
+ dlg->setNameFilters(filters);
+ dlg->setWindowTitle(name);
+ if (viewType == MFileDialog::GLOBAL_VIEW)
+ dlg->globalToggled(true);
+ else if (viewType == MFileDialog::PROJECT_VIEW)
+ dlg->projectToggled(true);
+ else if (viewType == MFileDialog::USER_VIEW)
+ dlg->userToggled(true);
+ if (all) {
+ dlg->buttons.loadAllGroup->setVisible(true);
+ //dlg->buttons.globalButton->setVisible(false);
+ }
+ if (!initialSelection.isEmpty())
+ dlg->selectFile(initialSelection);
+ dlg->setFileMode(QFileDialog::ExistingFile);
+ QStringList files;
+ QString result;
+ if (dlg->exec() == QDialog::Accepted) {
+ files = dlg->selectedFiles();
+ if (!files.isEmpty())
+ result = files[0];
+ if (all) {
+ *all = dlg->buttons.loadAllButton->isChecked();
+ }
+ }
+ delete dlg;
+ return result;
+ }
+
+//---------------------------------------------------------
+// getSaveFileName
+//---------------------------------------------------------
+
+QString getSaveFileName(const QString &startWith,
+ //const char** filters, QWidget* parent, const QString& name)
+ const QStringList& filters, QWidget* parent, const QString& name)
+ {
+ MFileDialog *dlg = new MFileDialog(startWith, QString::null, parent, true);
+ dlg->setNameFilters(filters);
+ dlg->setWindowTitle(name);
+ dlg->setFileMode(QFileDialog::AnyFile);
+ QStringList files;
+ QString result;
+ if (dlg->exec() == QDialog::Accepted) {
+ files = dlg->selectedFiles();
+ if (!files.isEmpty())
+ result = files[0];
+ }
+
+ // Added by T356.
+ if(!result.isEmpty())
+ {
+ QString filt = dlg->selectedNameFilter();
+ filt = getFilterExtension(filt);
+ // Do we have a valid extension?
+ if(!filt.isEmpty())
+ {
+ // If the rightmost characters of the filename do not already contain
+ // the extension, add the extension to the filename.
+ //if(result.right(filt.length()) != filt)
+ if(!result.endsWith(filt))
+ result += filt;
+ }
+ else
+ {
+ // No valid extension, or just * was given. Although it would be nice to allow no extension
+ // or any desired extension by commenting this section out, it's probably not a good idea to do so.
+ //
+ // NOTE: Most calls to this routine getSaveFileName() are followed by fileOpen(),
+ // which can tack on its own extension, but only if the *complete* extension is blank.
+ // So there is some overlap going on. Enabling this actually stops that action,
+ // but only if there are no errors in the list of filters. fileOpen() will act as a 'catchall'.
+ //
+ // Force the filter list to the first one (the preferred one), and then get the filter.
+ dlg->selectNameFilter(dlg->nameFilters().at(0));
+ filt = dlg->selectedNameFilter();
+ filt = getFilterExtension(filt);
+
+ // Do we have a valid extension?
+ if(!filt.isEmpty())
+ {
+ // If the rightmost characters of the filename do not already contain
+ // the extension, add the extension to the filename.
+ //if(result.right(filt.length()) != filt)
+ if(!result.endsWith(filt))
+ result += filt;
+ }
+ }
+ }
+
+ delete dlg;
+ return result;
+ }
+
+//---------------------------------------------------------
+// getImageFileName
+//---------------------------------------------------------
+
+QString getImageFileName(const QString& startWith,
+ //const char** filters, QWidget* parent, const QString& name)
+ const QStringList& filters, QWidget* parent, const QString& name)
+ {
+ QString initialSelection;
+ QString* workingDirectory = new QString(QDir::currentPath());
+ if (!startWith.isEmpty() ) {
+ QFileInfo fi(startWith);
+ if (fi.exists() && fi.isDir()) {
+ *workingDirectory = startWith;
+ }
+ else if (fi.exists() && fi.isFile()) {
+ *workingDirectory = fi.absolutePath();
+ initialSelection = fi.absoluteFilePath();
+ }
+ }
+ MFileDialog *dlg = new MFileDialog(*workingDirectory, QString::null,
+ parent);
+
+ /* ORCAN - disable preview for now. It is not available in qt4. We will
+ need to implement it ourselves.
+ dlg->setContentsPreviewEnabled(true);
+ ContentsPreview* preview = new ContentsPreview(dlg);
+ dlg->setContentsPreview(preview, preview);
+ dlg->setPreviewMode(QFileDialog::Contents);
+ */
+ dlg->setWindowTitle(name);
+ dlg->setNameFilters(filters);
+ dlg->setFileMode(QFileDialog::ExistingFile);
+ QStringList files;
+ QString result;
+ if (!initialSelection.isEmpty())
+ dlg->selectFile( initialSelection);
+ if (dlg->exec() == QDialog::Accepted) {
+ files = dlg->selectedFiles();
+ if (!files.isEmpty())
+ result = files[0];
+ }
+ delete dlg;
+ return result;
+ }
+
+//---------------------------------------------------------
+// fileOpen
+// opens file "name" with extension "ext" in mode "mode"
+// handles "name.ext.bz2" and "name.ext.gz"
+//
+// mode = "r" or "w"
+// popenFlag set to true on return if file was opened
+// with popen() (and therefore must be closed
+// with pclose())
+// noError show no error if file was not found in "r"
+// mode. Has no effect in "w" mode
+// overwriteWarning
+// warn in "w" mode, if file exists
+//---------------------------------------------------------
+
+FILE* fileOpen(QWidget* parent, QString name, const QString& ext,
+ const char* mode, bool& popenFlag, bool noError,
+ bool overwriteWarning)
+ {
+ QFileInfo info(name);
+ QString zip;
+
+ popenFlag = false;
+ if (info.completeSuffix() == "") {
+ name += ext;
+ info.setFile(name);
+ }
+ else if (info.suffix() == "gz") {
+ popenFlag = true;
+ zip = QString("gzip");
+ }
+ else if (info.suffix() == "bz2") {
+ popenFlag = true;
+ zip = QString("bzip2");
+ }
+
+ if (strcmp(mode,"w") == 0 && overwriteWarning && info.exists()) {
+ QString s(QWidget::tr("File\n") + name + QWidget::tr("\nexists. Overwrite?"));
+ /*
+ int rv = QMessageBox::warning(parent,
+ QWidget::tr("MusE: write"),
+ s,
+ QMessageBox::Save | QMessageBox::Cancel, QMessageBox::Save);
+ switch(rv) {
+ case 0: // overwrite
+ break;
+ case 1: // quit
+ return 0;
+ }
+ */
+ if(QMessageBox::warning(parent,
+ QWidget::tr("MusE: write"), s,
+ QMessageBox::Save | QMessageBox::Cancel, QMessageBox::Save)
+ != QMessageBox::Save)
+ return 0;
+
+ }
+ FILE* fp = 0;
+ if (popenFlag) {
+ if (strcmp(mode, "r") == 0)
+ zip += QString(" -d < ");
+ else
+ zip += QString(" > ");
+ zip += name;
+ fp = popen(zip.toAscii().data(), mode);
+ }
+ else {
+ fp = fopen(name.toAscii().data(), mode);
+ }
+ if (fp == 0 && !noError) {
+ QString s(QWidget::tr("Open File\n") + name + QWidget::tr("\nfailed: ")
+ + QString(strerror(errno)));
+ QMessageBox::critical(parent, QWidget::tr("MusE: Open File"), s);
+ return 0;
+ }
+ return fp;
+ }
+
+//---------------------------------------------------------
+// MFile
+//---------------------------------------------------------
+
+MFile::MFile(const QString& _path, const QString& _ext)
+ : path(_path), ext(_ext)
+ {
+ f = 0;
+ isPopen = false;
+ }
+
+MFile::~MFile()
+ {
+ if (f) {
+ if (isPopen)
+ pclose(f);
+ else
+ fclose(f);
+ }
+ }
+
+//---------------------------------------------------------
+// open
+//---------------------------------------------------------
+
+//FILE* MFile::open(const char* mode, const char** pattern,
+FILE* MFile::open(const char* mode, const QStringList& pattern,
+ QWidget* parent, bool noError, bool warnIfOverwrite, const QString& caption)
+ {
+ QString name;
+ if (strcmp(mode, "r") == 0)
+ name = getOpenFileName(path, pattern, parent, caption, 0);
+ else
+ name = getSaveFileName(path, pattern, parent, caption);
+ if (name.isEmpty())
+ return 0;
+ f = fileOpen(parent, name, ext, mode, isPopen, noError,
+ warnIfOverwrite);
+ return f;
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/filedialog.h b/attic/muse2-oom/muse2/muse/widgets/filedialog.h
new file mode 100644
index 00000000..0d3dfc8c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/filedialog.h
@@ -0,0 +1,110 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: filedialog.h,v 1.2.2.2 2008/01/19 13:33:46 wschweer Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QFileDialog>
+
+#include "ui_fdialogbuttons.h"
+
+class QStringList;
+
+//---------------------------------------------------------
+// FileDialogButtonsWidget
+// Wrapper around Ui::FileDialogButtons
+//---------------------------------------------------------
+
+class FileDialogButtonsWidget : public QWidget, public Ui::FileDialogButtons
+{
+ Q_OBJECT
+
+ public:
+ FileDialogButtonsWidget(QWidget *parent = 0)
+ : QWidget(parent)
+ { setupUi(this); }
+};
+
+//---------------------------------------------------------
+// MFileDialog
+//---------------------------------------------------------
+
+class MFileDialog : public QFileDialog {
+ Q_OBJECT
+
+ static QString lastUserDir, lastGlobalDir;
+ bool showButtons;
+ QString baseDir;
+
+ private slots:
+ void directoryChanged(const QString& directory);
+ public slots:
+ void globalToggled(bool);
+ void userToggled(bool);
+ void projectToggled(bool);
+
+ public:
+ enum ViewType { GLOBAL_VIEW, PROJECT_VIEW, USER_VIEW }; //!< The three different viewtypes
+ static ViewType lastViewUsed;
+ FileDialogButtonsWidget buttons;
+ MFileDialog(const QString& dir, const QString& filter = QString::null,
+ QWidget* parent = 0, bool writeFlag = false);
+ };
+
+/* ORCAN - Disable previeww for now. It is not available in qt4. We will
+ need to implement it ourselves.
+//---------------------------------------------------------
+// ContentsPreview
+//---------------------------------------------------------
+
+class ContentsPreview : public QWidget, public Q3FilePreview {
+ Q_OBJECT
+
+ virtual void previewUrl(const Q3Url &url);
+ QString path;
+ QPixmap* bg;
+
+ public:
+ ContentsPreview(QWidget* parent, const char* name=0)
+ : QWidget(parent, name) {
+ bg = 0;
+ }
+ ~ContentsPreview();
+ };
+*/
+
+//QString getSaveFileName(const QString& startWidth, const char** filter,
+QString getSaveFileName(const QString& startWidth, const QStringList& filters,
+ QWidget* parent, const QString& name);
+//QString getOpenFileName(const QString& startWidth, const char** filter,
+QString getOpenFileName(const QString& startWidth, const QStringList& filters,
+ QWidget* parent, const QString& name, bool* openAll, MFileDialog::ViewType viewType = MFileDialog::PROJECT_VIEW);
+//QString getImageFileName(const QString& startWith, const char** filters,
+QString getImageFileName(const QString& startWith, const QStringList& filters,
+ QWidget* parent, const QString& name);
+
+FILE* fileOpen(QWidget*, QString, const QString&,
+ const char*, bool&, bool = false, bool = false);
+
+
+//---------------------------------------------------------
+// MFile
+// "Muse" File
+//---------------------------------------------------------
+
+class MFile {
+ bool isPopen;
+ FILE* f;
+ QString path;
+ QString ext;
+
+ public:
+ MFile(const QString& path, const QString& ext);
+ ~MFile();
+ //FILE* open(const char* mode, const char** pattern,
+ FILE* open(const char* mode, const QStringList& pattern,
+ QWidget* parent, bool noError,
+ bool warnIfOverwrite, const QString& caption);
+ };
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/gatetime.cpp b/attic/muse2-oom/muse2/muse/widgets/gatetime.cpp
new file mode 100644
index 00000000..f1804c35
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/gatetime.cpp
@@ -0,0 +1,51 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: gatetime.cpp,v 1.1.1.1 2003/10/27 18:54:37 wschweer Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QButtonGroup>
+#include <QDialog>
+
+#include "gatetime.h"
+
+#include "song.h"
+
+//---------------------------------------------------------
+// GateTime
+//---------------------------------------------------------
+
+GateTime::GateTime(QWidget* parent)
+ : QDialog(parent)
+ {
+ setupUi(this);
+ rangeGroup = new QButtonGroup(rangeBox);
+ rangeGroup->addButton(allButton, 0);
+ rangeGroup->addButton(selButton, 1);
+ rangeGroup->addButton(loopButton, 2);
+ rangeGroup->addButton(sloopButton, 3);
+ rangeGroup->setExclusive(true);
+ }
+
+//---------------------------------------------------------
+// accept
+//---------------------------------------------------------
+
+void GateTime::accept()
+ {
+ _range = rangeGroup->checkedId();
+ _rateVal = rate->value();
+ _offsetVal = offset->value();
+ QDialog::accept();
+ }
+
+//---------------------------------------------------------
+// setRange
+//---------------------------------------------------------
+
+void GateTime::setRange(int id)
+ {
+ rangeGroup->button(id)->setChecked(true);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/gatetime.h b/attic/muse2-oom/muse2/muse/widgets/gatetime.h
new file mode 100644
index 00000000..dcb1827c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/gatetime.h
@@ -0,0 +1,40 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: gatetime.h,v 1.1.1.1.2.1 2008/01/19 13:33:47 wschweer Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __GATETIME_H__
+#define __GATETIME_H__
+
+#include "ui_gatetimebase.h"
+
+class QButtonGroup;
+class QDialog;
+
+//---------------------------------------------------------
+// GateTime
+//---------------------------------------------------------
+
+class GateTime : public QDialog, public Ui::GateTimeBase {
+ Q_OBJECT
+
+ int _range;
+ int _rateVal;
+ int _offsetVal;
+ QButtonGroup *rangeGroup;
+
+ protected slots:
+ void accept();
+
+ public:
+ GateTime(QWidget* parent=0);
+ void setRange(int id);
+ int range() const { return _range; }
+ int rateVal() const { return _rateVal; }
+ int offsetVal() const { return _offsetVal; }
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/gatetimebase.ui b/attic/muse2-oom/muse2/muse/widgets/gatetimebase.ui
new file mode 100644
index 00000000..babf5f02
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/gatetimebase.ui
@@ -0,0 +1,213 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>GateTimeBase</class>
+ <widget class="QDialog" name="GateTimeBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>275</width>
+ <height>316</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Modify Gate Time</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QGroupBox" name="rangeBox">
+ <property name="title">
+ <string>Range</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QRadioButton" name="allButton">
+ <property name="text">
+ <string>All Events</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="selButton">
+ <property name="text">
+ <string>Selected Events</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="loopButton">
+ <property name="text">
+ <string>Looped Events</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="sloopButton">
+ <property name="text">
+ <string>Selected &amp; Looped</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="GroupBox3">
+ <property name="title">
+ <string>Values</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="TextLabel3">
+ <property name="text">
+ <string>Rate:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="TextLabel4">
+ <property name="text">
+ <string>Offset:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QSpinBox" name="rate">
+ <property name="suffix">
+ <string>%</string>
+ </property>
+ <property name="maximum">
+ <number>200</number>
+ </property>
+ <property name="value">
+ <number>100</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="offset">
+ <property name="minimum">
+ <number>-999</number>
+ </property>
+ <property name="maximum">
+ <number>999</number>
+ </property>
+ <property name="singleStep">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <spacer name="spacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton">
+ <property name="text">
+ <string>OK</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>okButton</sender>
+ <signal>clicked()</signal>
+ <receiver>GateTimeBase</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>cancelButton</sender>
+ <signal>clicked()</signal>
+ <receiver>GateTimeBase</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/genset.cpp b/attic/muse2-oom/muse2/muse/widgets/genset.cpp
new file mode 100644
index 00000000..0d81d846
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/genset.cpp
@@ -0,0 +1,464 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: genset.cpp,v 1.7.2.8 2009/12/01 03:52:40 terminator356 Exp $
+//
+// (C) Copyright 2001-2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+
+#include <QFileDialog>
+#include <QRect>
+#include <QShowEvent>
+
+#include "genset.h"
+#include "app.h"
+#include "gconfig.h"
+#include "midiseq.h"
+#include "globals.h"
+#include "icons.h"
+
+static int rtcResolutions[] = {
+ 1024, 2048, 4096, 8192, 16384, 32768
+ };
+static int divisions[] = {
+ 48, 96, 192, 384, 768, 1536, 3072, 6144, 12288
+ };
+static int dummyAudioBufSizes[] = {
+ 16, 32, 64, 128, 256, 512, 1024, 2048
+ };
+
+//---------------------------------------------------------
+// GlobalSettingsConfig
+//---------------------------------------------------------
+
+GlobalSettingsConfig::GlobalSettingsConfig(QWidget* parent)
+ : QDialog(parent)
+ {
+ setupUi(this);
+ startSongGroup = new QButtonGroup(this);
+ startSongGroup->addButton(startLastButton, 0);
+ startSongGroup->addButton(startEmptyButton, 1);
+ startSongGroup->addButton(startSongButton, 2);
+ for (unsigned i = 0; i < sizeof(rtcResolutions)/sizeof(*rtcResolutions); ++i) {
+ if (rtcResolutions[i] == config.rtcTicks) {
+ rtcResolutionSelect->setCurrentIndex(i);
+ break;
+ }
+ }
+ for (unsigned i = 0; i < sizeof(divisions)/sizeof(*divisions); ++i) {
+ if (divisions[i] == config.division) {
+ midiDivisionSelect->setCurrentIndex(i);
+ break;
+ }
+ }
+ for (unsigned i = 0; i < sizeof(divisions)/sizeof(*divisions); ++i) {
+ if (divisions[i] == config.guiDivision) {
+ guiDivisionSelect->setCurrentIndex(i);
+ break;
+ }
+ }
+ for (unsigned i = 0; i < sizeof(dummyAudioBufSizes)/sizeof(*dummyAudioBufSizes); ++i) {
+ if (dummyAudioBufSizes[i] == config.dummyAudioBufSize) {
+ dummyAudioSize->setCurrentIndex(i);
+ break;
+ }
+ }
+
+ userInstrumentsPath->setText(config.userInstrumentsDir);
+ selectInstrumentsDirButton->setIcon(*openIcon);
+ defaultInstrumentsDirButton->setIcon(*undoIcon);
+ connect(selectInstrumentsDirButton, SIGNAL(clicked()), SLOT(selectInstrumentsPath()));
+ connect(defaultInstrumentsDirButton, SIGNAL(clicked()), SLOT(defaultInstrumentsPath()));
+
+ guiRefreshSelect->setValue(config.guiRefresh);
+ minSliderSelect->setValue(int(config.minSlider));
+ minMeterSelect->setValue(config.minMeter);
+ freewheelCheckBox->setChecked(config.freewheelMode);
+ denormalCheckBox->setChecked(config.useDenormalBias);
+ outputLimiterCheckBox->setChecked(config.useOutputLimiter);
+ vstInPlaceCheckBox->setChecked(config.vstInPlace);
+ dummyAudioRate->setValue(config.dummyAudioSampleRate);
+
+ //DummyAudioDevice* dad = dynamic_cast<DummyAudioDevice*>(audioDevice);
+ //dummyAudioRealRate->setText(dad ? QString().setNum(sampleRate) : "---");
+ dummyAudioRealRate->setText(QString().setNum(sampleRate));
+
+ startSongEntry->setText(config.startSong);
+ startSongGroup->button(config.startMode)->setChecked(true);
+
+ showTransport->setChecked(config.transportVisible);
+ showBigtime->setChecked(config.bigTimeVisible);
+ //showMixer->setChecked(config.mixerVisible);
+ showMixer->setChecked(config.mixer1Visible);
+ showMixer2->setChecked(config.mixer2Visible);
+
+ arrangerX->setValue(config.geometryMain.x());
+ arrangerY->setValue(config.geometryMain.y());
+ arrangerW->setValue(config.geometryMain.width());
+ arrangerH->setValue(config.geometryMain.height());
+
+ transportX->setValue(config.geometryTransport.x());
+ transportY->setValue(config.geometryTransport.y());
+
+ bigtimeX->setValue(config.geometryBigTime.x());
+ bigtimeY->setValue(config.geometryBigTime.y());
+ bigtimeW->setValue(config.geometryBigTime.width());
+ bigtimeH->setValue(config.geometryBigTime.height());
+
+ //mixerX->setValue(config.geometryMixer.x());
+ //mixerY->setValue(config.geometryMixer.y());
+ //mixerW->setValue(config.geometryMixer.width());
+ //mixerH->setValue(config.geometryMixer.height());
+ mixerX->setValue(config.mixer1.geometry.x());
+ mixerY->setValue(config.mixer1.geometry.y());
+ mixerW->setValue(config.mixer1.geometry.width());
+ mixerH->setValue(config.mixer1.geometry.height());
+ mixer2X->setValue(config.mixer2.geometry.x());
+ mixer2Y->setValue(config.mixer2.geometry.y());
+ mixer2W->setValue(config.mixer2.geometry.width());
+ mixer2H->setValue(config.mixer2.geometry.height());
+
+ //setMixerCurrent->setEnabled(muse->mixerWindow());
+ setMixerCurrent->setEnabled(muse->mixer1Window());
+ setMixer2Current->setEnabled(muse->mixer2Window());
+
+ setBigtimeCurrent->setEnabled(muse->bigtimeWindow());
+ setTransportCurrent->setEnabled(muse->transportWindow());
+
+ showSplash->setChecked(config.showSplashScreen);
+ showDidYouKnow->setChecked(config.showDidYouKnow);
+ externalWavEditorSelect->setText(config.externalWavEditor);
+ oldStyleStopCheckBox->setChecked(config.useOldStyleStopShortCut);
+ moveArmedCheckBox->setChecked(config.moveArmedCheckBox);
+
+ //updateSettings(); // TESTING
+
+ connect(applyButton, SIGNAL(clicked()), SLOT(apply()));
+ connect(okButton, SIGNAL(clicked()), SLOT(ok()));
+ connect(cancelButton, SIGNAL(clicked()), SLOT(cancel()));
+ connect(setMixerCurrent, SIGNAL(clicked()), SLOT(mixerCurrent()));
+ connect(setMixer2Current, SIGNAL(clicked()), SLOT(mixer2Current()));
+ connect(setBigtimeCurrent, SIGNAL(clicked()), SLOT(bigtimeCurrent()));
+ connect(setArrangerCurrent, SIGNAL(clicked()), SLOT(arrangerCurrent()));
+ connect(setTransportCurrent, SIGNAL(clicked()), SLOT(transportCurrent()));
+ }
+
+//---------------------------------------------------------
+// updateSettings
+//---------------------------------------------------------
+
+void GlobalSettingsConfig::updateSettings()
+{
+ for (unsigned i = 0; i < sizeof(rtcResolutions)/sizeof(*rtcResolutions); ++i) {
+ if (rtcResolutions[i] == config.rtcTicks) {
+ rtcResolutionSelect->setCurrentIndex(i);
+ break;
+ }
+ }
+ for (unsigned i = 0; i < sizeof(divisions)/sizeof(*divisions); ++i) {
+ if (divisions[i] == config.division) {
+ midiDivisionSelect->setCurrentIndex(i);
+ break;
+ }
+ }
+ for (unsigned i = 0; i < sizeof(divisions)/sizeof(*divisions); ++i) {
+ if (divisions[i] == config.guiDivision) {
+ guiDivisionSelect->setCurrentIndex(i);
+ break;
+ }
+ }
+ for (unsigned i = 0; i < sizeof(dummyAudioBufSizes)/sizeof(*dummyAudioBufSizes); ++i) {
+ if (dummyAudioBufSizes[i] == config.dummyAudioBufSize) {
+ dummyAudioSize->setCurrentIndex(i);
+ break;
+ }
+ }
+
+ guiRefreshSelect->setValue(config.guiRefresh);
+ minSliderSelect->setValue(int(config.minSlider));
+ minMeterSelect->setValue(config.minMeter);
+ freewheelCheckBox->setChecked(config.freewheelMode);
+ denormalCheckBox->setChecked(config.useDenormalBias);
+ outputLimiterCheckBox->setChecked(config.useOutputLimiter);
+ vstInPlaceCheckBox->setChecked(config.vstInPlace);
+ dummyAudioRate->setValue(config.dummyAudioSampleRate);
+
+ //DummyAudioDevice* dad = dynamic_cast<DummyAudioDevice*>(audioDevice);
+ //dummyAudioRealRate->setText(dad ? QString().setNum(sampleRate) : "---");
+ dummyAudioRealRate->setText(QString().setNum(sampleRate));
+
+ startSongEntry->setText(config.startSong);
+ startSongGroup->button(config.startMode)->setChecked(true);
+
+ showTransport->setChecked(config.transportVisible);
+ showBigtime->setChecked(config.bigTimeVisible);
+ //showMixer->setChecked(config.mixerVisible);
+ showMixer->setChecked(config.mixer1Visible);
+ showMixer2->setChecked(config.mixer2Visible);
+
+ arrangerX->setValue(config.geometryMain.x());
+ arrangerY->setValue(config.geometryMain.y());
+ arrangerW->setValue(config.geometryMain.width());
+ arrangerH->setValue(config.geometryMain.height());
+
+ transportX->setValue(config.geometryTransport.x());
+ transportY->setValue(config.geometryTransport.y());
+
+ bigtimeX->setValue(config.geometryBigTime.x());
+ bigtimeY->setValue(config.geometryBigTime.y());
+ bigtimeW->setValue(config.geometryBigTime.width());
+ bigtimeH->setValue(config.geometryBigTime.height());
+
+ //mixerX->setValue(config.geometryMixer.x());
+ //mixerY->setValue(config.geometryMixer.y());
+ //mixerW->setValue(config.geometryMixer.width());
+ //mixerH->setValue(config.geometryMixer.height());
+ mixerX->setValue(config.mixer1.geometry.x());
+ mixerY->setValue(config.mixer1.geometry.y());
+ mixerW->setValue(config.mixer1.geometry.width());
+ mixerH->setValue(config.mixer1.geometry.height());
+ mixer2X->setValue(config.mixer2.geometry.x());
+ mixer2Y->setValue(config.mixer2.geometry.y());
+ mixer2W->setValue(config.mixer2.geometry.width());
+ mixer2H->setValue(config.mixer2.geometry.height());
+
+ //setMixerCurrent->setEnabled(muse->mixerWindow());
+ setMixerCurrent->setEnabled(muse->mixer1Window());
+ setMixer2Current->setEnabled(muse->mixer2Window());
+
+ setBigtimeCurrent->setEnabled(muse->bigtimeWindow());
+ setTransportCurrent->setEnabled(muse->transportWindow());
+
+ showSplash->setChecked(config.showSplashScreen);
+ showDidYouKnow->setChecked(config.showDidYouKnow);
+ externalWavEditorSelect->setText(config.externalWavEditor);
+ oldStyleStopCheckBox->setChecked(config.useOldStyleStopShortCut);
+ moveArmedCheckBox->setChecked(config.moveArmedCheckBox);
+}
+
+//---------------------------------------------------------
+// showEvent
+//---------------------------------------------------------
+
+void GlobalSettingsConfig::showEvent(QShowEvent* e)
+{
+ QDialog::showEvent(e);
+ //updateSettings(); // TESTING
+}
+
+//---------------------------------------------------------
+// apply
+//---------------------------------------------------------
+
+void GlobalSettingsConfig::apply()
+ {
+ int rtcticks = rtcResolutionSelect->currentIndex();
+ config.guiRefresh = guiRefreshSelect->value();
+ config.minSlider = minSliderSelect->value();
+ config.minMeter = minMeterSelect->value();
+ config.freewheelMode = freewheelCheckBox->isChecked();
+ config.useDenormalBias = denormalCheckBox->isChecked();
+ config.useOutputLimiter = outputLimiterCheckBox->isChecked();
+ config.vstInPlace = vstInPlaceCheckBox->isChecked();
+ config.rtcTicks = rtcResolutions[rtcticks];
+ config.userInstrumentsDir = userInstrumentsPath->text();
+ config.startSong = startSongEntry->text();
+ config.startMode = startSongGroup->checkedId();
+ int das = dummyAudioSize->currentIndex();
+ config.dummyAudioBufSize = dummyAudioBufSizes[das];
+ config.dummyAudioSampleRate = dummyAudioRate->value();
+
+ int div = midiDivisionSelect->currentIndex();
+ config.division = divisions[div];
+ div = guiDivisionSelect->currentIndex();
+ config.guiDivision = divisions[div];
+
+ config.transportVisible = showTransport->isChecked();
+ config.bigTimeVisible = showBigtime->isChecked();
+ //config.mixerVisible = showMixer->isChecked();
+ config.mixer1Visible = showMixer->isChecked();
+ config.mixer2Visible = showMixer2->isChecked();
+
+ config.geometryMain.setX(arrangerX->value());
+ config.geometryMain.setY(arrangerY->value());
+ config.geometryMain.setWidth(arrangerW->value());
+ config.geometryMain.setHeight(arrangerH->value());
+
+ config.geometryTransport.setX(transportX->value());
+ config.geometryTransport.setY(transportY->value());
+ config.geometryTransport.setWidth(0);
+ config.geometryTransport.setHeight(0);
+
+ config.geometryBigTime.setX(bigtimeX->value());
+ config.geometryBigTime.setY(bigtimeY->value());
+ config.geometryBigTime.setWidth(bigtimeW->value());
+ config.geometryBigTime.setHeight(bigtimeH->value());
+
+ //config.geometryMixer.setX(mixerX->value());
+ //config.geometryMixer.setY(mixerY->value());
+ //config.geometryMixer.setWidth(mixerW->value());
+ //config.geometryMixer.setHeight(mixerH->value());
+ config.mixer1.geometry.setX(mixerX->value());
+ config.mixer1.geometry.setY(mixerY->value());
+ config.mixer1.geometry.setWidth(mixerW->value());
+ config.mixer1.geometry.setHeight(mixerH->value());
+ config.mixer2.geometry.setX(mixer2X->value());
+ config.mixer2.geometry.setY(mixer2Y->value());
+ config.mixer2.geometry.setWidth(mixer2W->value());
+ config.mixer2.geometry.setHeight(mixer2H->value());
+
+ config.showSplashScreen = showSplash->isChecked();
+ config.showDidYouKnow = showDidYouKnow->isChecked();
+ config.externalWavEditor = externalWavEditorSelect->text();
+ config.useOldStyleStopShortCut = oldStyleStopCheckBox->isChecked();
+ config.moveArmedCheckBox = moveArmedCheckBox->isChecked();
+ //muse->showMixer(config.mixerVisible);
+ muse->showMixer1(config.mixer1Visible);
+ muse->showMixer2(config.mixer2Visible);
+
+ muse->showBigtime(config.bigTimeVisible);
+ muse->showTransport(config.transportVisible);
+ QWidget* w = muse->transportWindow();
+ if (w) {
+ w->resize(config.geometryTransport.size());
+ w->move(config.geometryTransport.topLeft());
+ }
+ //w = muse->mixerWindow();
+ //if (w) {
+ // w->resize(config.geometryMixer.size());
+ // w->move(config.geometryMixer.topLeft());
+ // }
+ w = muse->mixer1Window();
+ if (w) {
+ w->resize(config.mixer1.geometry.size());
+ w->move(config.mixer1.geometry.topLeft());
+ }
+ w = muse->mixer2Window();
+ if (w) {
+ w->resize(config.mixer2.geometry.size());
+ w->move(config.mixer2.geometry.topLeft());
+ }
+ w = muse->bigtimeWindow();
+ if (w) {
+ w->resize(config.geometryBigTime.size());
+ w->move(config.geometryBigTime.topLeft());
+ }
+ muse->resize(config.geometryMain.size());
+ muse->move(config.geometryMain.topLeft());
+
+ museUserInstruments = config.userInstrumentsDir;
+
+ muse->setHeartBeat(); // set guiRefresh
+ midiSeq->msgSetRtc(); // set midi tick rate
+ muse->changeConfig(true); // save settings
+ }
+
+//---------------------------------------------------------
+// ok
+//---------------------------------------------------------
+
+void GlobalSettingsConfig::ok()
+ {
+ apply();
+ close();
+ }
+
+//---------------------------------------------------------
+// cancel
+//---------------------------------------------------------
+
+void GlobalSettingsConfig::cancel()
+ {
+ close();
+ }
+
+//---------------------------------------------------------
+// mixerCurrent
+//---------------------------------------------------------
+
+void GlobalSettingsConfig::mixerCurrent()
+ {
+ QWidget* w = muse->mixer1Window();
+ if (!w)
+ return;
+ QRect r(w->frameGeometry());
+ mixerX->setValue(r.x());
+ mixerY->setValue(r.y());
+ mixerW->setValue(r.width());
+ mixerH->setValue(r.height());
+ }
+
+//---------------------------------------------------------
+// mixer2Current
+//---------------------------------------------------------
+
+void GlobalSettingsConfig::mixer2Current()
+ {
+ QWidget* w = muse->mixer2Window();
+ if (!w)
+ return;
+ QRect r(w->frameGeometry());
+ mixer2X->setValue(r.x());
+ mixer2Y->setValue(r.y());
+ mixer2W->setValue(r.width());
+ mixer2H->setValue(r.height());
+ }
+
+//---------------------------------------------------------
+// bigtimeCurrent
+//---------------------------------------------------------
+
+void GlobalSettingsConfig::bigtimeCurrent()
+ {
+ QWidget* w = muse->bigtimeWindow();
+ if (!w)
+ return;
+ QRect r(w->frameGeometry());
+ bigtimeX->setValue(r.x());
+ bigtimeY->setValue(r.y());
+ bigtimeW->setValue(r.width());
+ bigtimeH->setValue(r.height());
+ }
+
+//---------------------------------------------------------
+// arrangerCurrent
+//---------------------------------------------------------
+
+void GlobalSettingsConfig::arrangerCurrent()
+ {
+ QRect r(muse->frameGeometry());
+ arrangerX->setValue(r.x());
+ arrangerY->setValue(r.y());
+ arrangerW->setValue(r.width());
+ arrangerH->setValue(r.height());
+ }
+
+//---------------------------------------------------------
+// transportCurrent
+//---------------------------------------------------------
+
+void GlobalSettingsConfig::transportCurrent()
+ {
+ QWidget* w = muse->transportWindow();
+ if (!w)
+ return;
+ QRect r(w->frameGeometry());
+ transportX->setValue(r.x());
+ transportY->setValue(r.y());
+ }
+
+void GlobalSettingsConfig::selectInstrumentsPath()
+ {
+ QString dir = QFileDialog::getExistingDirectory(this,
+ tr("Selects instruments directory"),
+ config.userInstrumentsDir);
+ userInstrumentsPath->setText(dir);
+ }
+
+void GlobalSettingsConfig::defaultInstrumentsPath()
+ {
+ QString dir = configPath + "/instruments";
+ userInstrumentsPath->setText(dir);
+ }
diff --git a/attic/muse2-oom/muse2/muse/widgets/genset.h b/attic/muse2-oom/muse2/muse/widgets/genset.h
new file mode 100644
index 00000000..ea094296
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/genset.h
@@ -0,0 +1,44 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: genset.h,v 1.3 2004/01/25 09:55:17 wschweer Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __GENSET_H__
+#define __GENSET_H__
+
+#include "ui_gensetbase.h"
+
+#include <QShowEvent>
+
+//---------------------------------------------------------
+// GlobalSettingsConfig
+//---------------------------------------------------------
+
+class GlobalSettingsConfig : public QDialog, public Ui::GlobalSettingsDialogBase {
+ Q_OBJECT
+
+ private slots:
+ void updateSettings();
+ void apply();
+ void ok();
+ void cancel();
+ void mixerCurrent();
+ void mixer2Current();
+ void bigtimeCurrent();
+ void arrangerCurrent();
+ void transportCurrent();
+ void selectInstrumentsPath();
+ void defaultInstrumentsPath();
+
+ protected:
+ void showEvent(QShowEvent*);
+ QButtonGroup *startSongGroup;
+
+ public:
+ GlobalSettingsConfig(QWidget* parent=0);
+ };
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/gensetbase.ui b/attic/muse2-oom/muse2/muse/widgets/gensetbase.ui
new file mode 100644
index 00000000..44261c87
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/gensetbase.ui
@@ -0,0 +1,1268 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>GlobalSettingsDialogBase</class>
+ <widget class="QDialog" name="GlobalSettingsDialogBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>522</width>
+ <height>518</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Global Settings</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QTabWidget" name="TabWidget2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="currentIndex">
+ <number>0</number>
+ </property>
+ <widget class="QWidget" name="TabPage">
+ <attribute name="title">
+ <string>Application</string>
+ </attribute>
+ <layout class="QGridLayout">
+ <item row="1" column="0">
+ <widget class="QGroupBox" name="groupBox4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Views</string>
+ </property>
+ <layout class="QGridLayout">
+ <item row="1" column="3">
+ <widget class="QSpinBox" name="transportY">
+ <property name="toolTip">
+ <string>y-pos</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QCheckBox" name="showTransport">
+ <property name="text">
+ <string>show</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QSpinBox" name="transportX">
+ <property name="toolTip">
+ <string>x-pos</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="5">
+ <widget class="QSpinBox" name="arrangerH">
+ <property name="toolTip">
+ <string>height</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <widget class="QSpinBox" name="arrangerW">
+ <property name="toolTip">
+ <string>width</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QSpinBox" name="arrangerY">
+ <property name="toolTip">
+ <string>y-pos</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QSpinBox" name="arrangerX">
+ <property name="toolTip">
+ <string>x-pos</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QCheckBox" name="showBigtime">
+ <property name="text">
+ <string>show</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QSpinBox" name="bigtimeX">
+ <property name="toolTip">
+ <string>x-pos</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QSpinBox" name="bigtimeY">
+ <property name="toolTip">
+ <string>y-pos</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="4">
+ <widget class="QSpinBox" name="bigtimeW">
+ <property name="toolTip">
+ <string>width</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="5">
+ <widget class="QSpinBox" name="bigtimeH">
+ <property name="toolTip">
+ <string>height</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QCheckBox" name="showMixer">
+ <property name="text">
+ <string>show</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QCheckBox" name="showMixer2">
+ <property name="text">
+ <string>show</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="textLabel4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Mixer A</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="textLabel4_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Mixer B</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="textLabel3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Big Time</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="textLabel1_3">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Arranger</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="textLabel2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Transport</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="5">
+ <widget class="QSpinBox" name="mixerH">
+ <property name="toolTip">
+ <string>height</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="4">
+ <widget class="QSpinBox" name="mixerW">
+ <property name="toolTip">
+ <string>width</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="3">
+ <widget class="QSpinBox" name="mixerY">
+ <property name="toolTip">
+ <string>y-pos</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QSpinBox" name="mixerX">
+ <property name="toolTip">
+ <string>x-pos</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="6">
+ <widget class="QPushButton" name="setMixerCurrent">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>set current values</string>
+ </property>
+ <property name="text">
+ <string>Cur</string>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="5">
+ <widget class="QSpinBox" name="mixer2H">
+ <property name="toolTip">
+ <string>height</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="4">
+ <widget class="QSpinBox" name="mixer2W">
+ <property name="toolTip">
+ <string>width</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="3">
+ <widget class="QSpinBox" name="mixer2Y">
+ <property name="toolTip">
+ <string>y-pos</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="2">
+ <widget class="QSpinBox" name="mixer2X">
+ <property name="toolTip">
+ <string>x-pos</string>
+ </property>
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="6">
+ <widget class="QPushButton" name="setMixer2Current">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>set current values</string>
+ </property>
+ <property name="text">
+ <string>Cur</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="6">
+ <widget class="QPushButton" name="setBigtimeCurrent">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>set current values</string>
+ </property>
+ <property name="text">
+ <string>Cur</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="6">
+ <widget class="QPushButton" name="setArrangerCurrent">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>set current values</string>
+ </property>
+ <property name="text">
+ <string>Cur</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="6">
+ <widget class="QPushButton" name="setTransportCurrent">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>set current values</string>
+ </property>
+ <property name="text">
+ <string>Cur</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QGroupBox" name="groupBox3">
+ <property name="title">
+ <string>Start Muse</string>
+ </property>
+ <layout class="QGridLayout">
+ <item row="0" column="0">
+ <layout class="QGridLayout">
+ <item row="1" column="0">
+ <spacer name="spacer7_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>51</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QLabel" name="textLabel1_2">
+ <property name="text">
+ <string>start song:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="startSongEntry"/>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="0">
+ <widget class="QGroupBox" name="startSongBox">
+ <property name="title">
+ <string>Start song</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QRadioButton" name="startLastButton">
+ <property name="text">
+ <string>start with last song</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="startEmptyButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>start with template: default.med</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="startSongButton">
+ <property name="text">
+ <string>start with song</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QGroupBox" name="startUpBox">
+ <property name="title">
+ <string>On Launch</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <widget class="QCheckBox" name="showSplash">
+ <property name="text">
+ <string>show splash screen</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="showDidYouKnow">
+ <property name="text">
+ <string>show &quot;Did you know?&quot; dialog</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <spacer name="verticalSpacer">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab">
+ <attribute name="title">
+ <string>Audio</string>
+ </attribute>
+ <layout class="QGridLayout">
+ <item row="0" column="0">
+ <widget class="QGroupBox" name="GroupBox4">
+ <property name="title">
+ <string>Mixer</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="0" column="1">
+ <widget class="QSpinBox" name="minSliderSelect">
+ <property name="suffix">
+ <string>dB</string>
+ </property>
+ <property name="minimum">
+ <number>-100</number>
+ </property>
+ <property name="maximum">
+ <number>0</number>
+ </property>
+ <property name="singleStep">
+ <number>10</number>
+ </property>
+ <property name="value">
+ <number>-60</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="TextLabel3_2">
+ <property name="text">
+ <string>min. Meter Value</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="TextLabel2_2">
+ <property name="text">
+ <string>min. Slider Val</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="minMeterSelect">
+ <property name="suffix">
+ <string>dB</string>
+ </property>
+ <property name="minimum">
+ <number>-100</number>
+ </property>
+ <property name="maximum">
+ <number>0</number>
+ </property>
+ <property name="singleStep">
+ <number>10</number>
+ </property>
+ <property name="value">
+ <number>-60</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="freewheelLabel">
+ <property name="text">
+ <string>Use Jack freewheel mode if possible.
+(Speeds up bounce operations).</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QCheckBox" name="denormalCheckBox">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QCheckBox" name="freewheelCheckBox">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="textLabel1_5">
+ <property name="text">
+ <string>Enable denormal protection</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QLabel" name="textLabel1_5_2">
+ <property name="text">
+ <string>Enable output limiter</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="1">
+ <widget class="QCheckBox" name="outputLimiterCheckBox">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="vstInPlaceTextLabel">
+ <property name="text">
+ <string>Enable in-place processing for VST plugins.
+(Requires restart.)</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QCheckBox" name="vstInPlaceCheckBox">
+ <property name="whatsThis">
+ <string>Turn this off if VST Ladspa effect rack plugins do not work or feedback loudly, even if they are supposed to be in-place capable.</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QGroupBox" name="groupBox13">
+ <property name="title">
+ <string>External Waveditor</string>
+ </property>
+ <layout class="QGridLayout">
+ <item row="0" column="0">
+ <layout class="QGridLayout">
+ <item row="0" column="0">
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QLabel" name="textLabel2_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>External Waveditor command</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer13">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>60</width>
+ <height>23</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="externalWavEditorSelect">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>2</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="textLabel1_6">
+ <property name="font">
+ <font>
+ <pointsize>8</pointsize>
+ </font>
+ </property>
+ <property name="text">
+ <string>Note: External editor opened from the internal editor.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QGroupBox" name="dummyAudioGroupBox">
+ <property name="title">
+ <string>Dummy Audio Driver (settings require restart)</string>
+ </property>
+ <layout class="QGridLayout">
+ <item row="0" column="0">
+ <widget class="QLabel" name="dummyAudioRateLabel">
+ <property name="text">
+ <string>Preferred sample rate</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QSpinBox" name="dummyAudioRate">
+ <property name="whatsThis">
+ <string>Actual rate used depends on limitations of
+ timer used. If a high rate timer is available,
+ short periods can be used with high sample rates.
+Period affects midi playback resolution.
+Shorter periods are desirable.</string>
+ </property>
+ <property name="suffix">
+ <string>Hz</string>
+ </property>
+ <property name="minimum">
+ <number>3000</number>
+ </property>
+ <property name="maximum">
+ <number>200000</number>
+ </property>
+ <property name="singleStep">
+ <number>10</number>
+ </property>
+ <property name="value">
+ <number>44100</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="dummyAudioRealRateLabel">
+ <property name="text">
+ <string>Actual rate used now (dummy or not):</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="dummyAudioRealRate">
+ <property name="text">
+ <string>---</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="dummyAudioSizeLabel">
+ <property name="text">
+ <string>Period size (Frames per period):</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QComboBox" name="dummyAudioSize">
+ <item>
+ <property name="text">
+ <string>16</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>32</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>64</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>128</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>256</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>512</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>1024</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>2048</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab2">
+ <attribute name="title">
+ <string>Midi</string>
+ </attribute>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QGroupBox" name="GroupBox2">
+ <property name="title">
+ <string>Ticks</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout9">
+ <item row="0" column="0">
+ <widget class="QLabel" name="TextLabel3">
+ <property name="text">
+ <string>RTC Resolution
+(Ticks/Sec)</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="rtcResolutionSelect">
+ <item>
+ <property name="text">
+ <string>1024</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>2048</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>4096</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>8192</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>16384</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>32768</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="midiResLabel">
+ <property name="text">
+ <string>Midi Resolution
+(Ticks/Quarternote)</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="midiDivisionSelect">
+ <property name="currentIndex">
+ <number>3</number>
+ </property>
+ <item>
+ <property name="text">
+ <string>48</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>96</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>192</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>384</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>768</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>1536</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>3072</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>6144</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>12288</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="TextLabel4">
+ <property name="text">
+ <string>Displayed Resolution
+(Ticks/Quarternote)</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QComboBox" name="guiDivisionSelect">
+ <property name="currentIndex">
+ <number>3</number>
+ </property>
+ <item>
+ <property name="text">
+ <string>48</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>96</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>192</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>384</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>768</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>1536</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>3072</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>6144</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>12288</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="TextLabel3_4">
+ <property name="text">
+ <string>Instruments Directory</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLineEdit" name="userInstrumentsPath"/>
+ </item>
+ <item row="3" column="2">
+ <widget class="QPushButton" name="selectInstrumentsDirButton">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="3">
+ <widget class="QPushButton" name="defaultInstrumentsDirButton">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <widget class="QWidget" name="tab3">
+ <attribute name="title">
+ <string>GUI</string>
+ </attribute>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QGroupBox" name="groupBox">
+ <property name="title">
+ <string>Behavior</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout_2" columnminimumwidth="280,0,0">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="TextLabel1">
+ <property name="text">
+ <string>GUI Refresh Rate</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="2">
+ <widget class="QSpinBox" name="guiRefreshSelect">
+ <property name="suffix">
+ <string>/sec</string>
+ </property>
+ <property name="minimum">
+ <number>2</number>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="value">
+ <number>20</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="textLabel1_4">
+ <property name="text">
+ <string>Use old-style stop shortcut:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="textLabel1_4_2">
+ <property name="text">
+ <string>Move single armed track with selection</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QCheckBox" name="moveArmedCheckBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QCheckBox" name="oldStyleStopCheckBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <spacer name="Spacer1">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="applyButton">
+ <property name="text">
+ <string>&amp;Apply</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton">
+ <property name="text">
+ <string>&amp;Ok</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton">
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/header.cpp b/attic/muse2-oom/muse2/muse/widgets/header.cpp
new file mode 100644
index 00000000..16cc374b
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/header.cpp
@@ -0,0 +1,111 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: header.cpp,v 1.1.1.1 2003/10/27 18:55:05 wschweer Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "header.h"
+#include "xml.h"
+
+#include <QStringList>
+#include <QStandardItemModel>
+
+//---------------------------------------------------------
+// readStatus
+//---------------------------------------------------------
+
+void Header::readStatus(Xml& xml)
+ {
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::Text:
+ {
+ //QStringList l = QStringList::split(QString(" "), tag);
+ QStringList l = tag.split(QString(" "), QString::SkipEmptyParts);
+ int index = count() -1;
+ for (QStringList::Iterator it = l.begin(); it != l.end(); ++it) {
+ int section = visualIndex((*it).toInt());
+ moveSection(section, index);
+ --index;
+ }
+ }
+ break;
+ case Xml::TagStart:
+ xml.unknown("Header");
+ break;
+ case Xml::TagEnd:
+ if (tag ==objectName())
+ return;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// writeStatus
+//---------------------------------------------------------
+
+void Header::writeStatus(int level, Xml& xml) const
+ {
+ //xml.nput(level, "<%s> ", name());
+ xml.nput(level, "<%s> ", Xml::xmlString(objectName()).toLatin1().constData());
+ int n = count() - 1;
+ for (int i = n; i >= 0; --i)
+ xml.nput("%d ", logicalIndex(i));
+ //xml.put("</%s>", name());
+ xml.put("</%s>", Xml::xmlString(objectName()).toLatin1().constData());
+ }
+
+//---------------------------------------------------------
+// Header
+//---------------------------------------------------------
+
+Header::Header(QWidget* parent, const char* name)
+ : QHeaderView(Qt::Horizontal, parent)
+ {
+ setObjectName(name);
+ itemModel = new QStandardItemModel;
+ setModel(itemModel);
+ //setResizeMode(QHeaderView::ResizeToContents);
+ setDefaultSectionSize(30);
+ }
+
+//---------------------------------------------------------
+// setColumnLabel
+//---------------------------------------------------------
+
+void Header::setColumnLabel(const QString & text, int col, int width )
+ {
+ QStandardItem *sitem = new QStandardItem(text );
+ itemModel->setHorizontalHeaderItem(col, sitem);
+ if (width > -1)
+ resizeSection(col, width);
+ }
+
+//---------------------------------------------------------
+// setToolTip
+//---------------------------------------------------------
+
+void Header::setToolTip(int col, const QString &text)
+ {
+ QStandardItem *item = itemModel->horizontalHeaderItem(col);
+ item->setToolTip(text);
+ }
+
+//---------------------------------------------------------
+// setWhatsThis
+//---------------------------------------------------------
+
+void Header::setWhatsThis(int col, const QString &text)
+ {
+ QStandardItem *item = itemModel->horizontalHeaderItem(col);
+ item->setWhatsThis(text);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/header.h b/attic/muse2-oom/muse2/muse/widgets/header.h
new file mode 100644
index 00000000..83680f8a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/header.h
@@ -0,0 +1,32 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: header.h,v 1.1.1.1 2003/10/27 18:55:03 wschweer Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __HEADER_H__
+#define __HEADER_H__
+
+#include <QHeaderView>
+
+class QStandardItemModel;
+
+class Xml;
+
+class Header : public QHeaderView {
+ Q_OBJECT
+
+ QStandardItemModel *itemModel;
+
+ public:
+ Header(QWidget* parent=0, const char* name=0);
+ void writeStatus(int level, Xml&) const;
+ void readStatus(Xml&);
+ void setColumnLabel( const QString & s, int col, int width = -1 );
+ void setToolTip(int col, const QString &text);
+ void setWhatsThis(int col, const QString &text);
+};
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/hitscale.cpp b/attic/muse2-oom/muse2/muse/widgets/hitscale.cpp
new file mode 100644
index 00000000..feba5920
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/hitscale.cpp
@@ -0,0 +1,133 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: hitscale.cpp,v 1.3.2.1 2007/01/27 14:52:43 spamatica Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "hitscale.h"
+#include "midieditor.h"
+
+#include <QMouseEvent>
+#include <QPainter>
+
+#include "song.h"
+
+//---------------------------------------------------------
+// HitScale
+//---------------------------------------------------------
+
+HitScale::HitScale(int* r, QWidget* parent, int xs)
+ : View(parent, xs, 1)
+ {
+ raster = r;
+ pos[0] = song->cpos();
+ pos[1] = song->lpos();
+ pos[2] = song->rpos();
+ button = Qt::NoButton;
+ setMouseTracking(true);
+ connect(song, SIGNAL(posChanged(int, unsigned, bool)), this, SLOT(setPos(int, unsigned, bool)));
+ setFixedHeight(18);
+ }
+
+//---------------------------------------------------------
+// setPos
+//---------------------------------------------------------
+
+void HitScale::setPos(int idx, unsigned val, bool)
+ {
+ if (val == pos[idx])
+ return;
+ unsigned int opos = mapx(pos[idx]); // in order preventing comparison of sigend & unsigned int ??is this OK?
+ pos[idx] = val;
+ if (!isVisible())
+ return;
+ val = mapx(val);
+ int x = -9;
+ int w = 18;
+ if (opos > val) { //here would be the comparison signed/unsigned
+ w += opos - val;
+ x += val;
+ }
+ else {
+ w += val - opos;
+ x += opos;
+ }
+ paint(QRect(x, 0, w, height()));
+ }
+
+void HitScale::viewMousePressEvent(QMouseEvent* event)
+ {
+ button = event->button();
+ viewMouseMoveEvent(event);
+ }
+
+void HitScale::viewMouseReleaseEvent(QMouseEvent*)
+ {
+ button = Qt::NoButton;
+ }
+
+void HitScale::viewMouseMoveEvent(QMouseEvent* event)
+ {
+ int x = AL::sigmap.raster(event->x(), *raster);
+ emit timeChanged(x);
+ int i;
+ switch (button) {
+ case Qt::LeftButton:
+ i = 0;
+ break;
+ case Qt::MidButton:
+ i = 1;
+ break;
+ case Qt::RightButton:
+ i = 2;
+ break;
+ default:
+ return;
+ }
+ Pos p(x, true);
+ song->setPos(i, p);
+ }
+
+//---------------------------------------------------------
+// leaveEvent
+//---------------------------------------------------------
+
+void HitScale::leaveEvent(QEvent*)
+ {
+ emit timeChanged(-1);
+ }
+
+//---------------------------------------------------------
+// draw
+//---------------------------------------------------------
+
+void HitScale::pdraw(QPainter& p, const QRect& r)
+ {
+ int x = r.x();
+ int w = r.width();
+
+// x -= 10;
+// w += 20;
+
+ if (x < 0)
+ x = 0;
+
+ //---------------------------------------------------
+ // draw location marker
+ //---------------------------------------------------
+
+ p.setPen(Qt::red);
+ int xp = mapx(pos[0]);
+ if (xp >= x && xp < x+w)
+ p.drawLine(xp, 0, xp, height());
+ p.setPen(Qt::blue);
+ xp = mapx(pos[1]);
+ if (xp >= x && xp < x+w)
+ p.drawLine(xp, 0, xp, height());
+ xp = mapx(pos[2]);
+ if (xp >= x && xp < x+w)
+ p.drawLine(xp, 0, xp, height());
+ }
+
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/hitscale.h b/attic/muse2-oom/muse2/muse/widgets/hitscale.h
new file mode 100644
index 00000000..0eaae399
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/hitscale.h
@@ -0,0 +1,46 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: hitscale.h,v 1.2 2004/01/11 18:55:37 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __HITSCALE_H__
+#define __HITSCALE_H__
+
+#include "view.h"
+
+class MidiEditor;
+
+//---------------------------------------------------------
+// HitScale
+// scale for midi track
+//---------------------------------------------------------
+
+class HitScale : public View {
+ Q_OBJECT
+ int* raster;
+ unsigned pos[3];
+ int button;
+
+ signals:
+// void posChanged(int, int);
+
+ protected:
+ virtual void pdraw(QPainter&, const QRect&);
+ virtual void viewMousePressEvent(QMouseEvent* event);
+ virtual void viewMouseMoveEvent(QMouseEvent* event);
+ virtual void viewMouseReleaseEvent(QMouseEvent* event);
+ virtual void leaveEvent(QEvent*e);
+
+ signals:
+ void timeChanged(int);
+
+ public slots:
+ void setPos(int, unsigned, bool);
+
+ public:
+ HitScale(int* raster, QWidget* parent, int xscale);
+ };
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/intlabel.cpp b/attic/muse2-oom/muse2/muse/widgets/intlabel.cpp
new file mode 100644
index 00000000..355f4510
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/intlabel.cpp
@@ -0,0 +1,140 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: intlabel.cpp,v 1.1.1.1.2.1 2008/08/18 00:15:26 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+
+#include "intlabel.h"
+#include "utils.h"
+
+//---------------------------------------------------------
+// IntLabel
+//---------------------------------------------------------
+
+IntLabel::IntLabel(int _val, int _min, int _max, QWidget* parent,
+ int _off, const QString& str, int lPos)
+ : Nentry(parent, str, lPos)
+ {
+ specialValue = "off";
+ min = _min;
+ max = _max;
+ val = _val+1; // dont optimize away
+ off = _off;
+ setValue(_val);
+ int len = num2cols(min, max);
+ setSize(len);
+ }
+
+void IntLabel::setSpecialValueText(const QString& s)
+ {
+ specialValue = s;
+ setString(val);
+ }
+
+//---------------------------------------------------------
+// setRange
+//---------------------------------------------------------
+
+void IntLabel::setRange(int mn, int mx)
+{
+ min = mn;
+ max = mx;
+ setSize(num2cols(min, max));
+ int v = val;
+ if(val < mn)
+ v = mn;
+ else
+ if(val > mx)
+ v = mx;
+ setValue(v);
+}
+
+//---------------------------------------------------------
+// setString
+//---------------------------------------------------------
+
+bool IntLabel::setString(int v, bool editable)
+ {
+ if (v < min || v > max) {
+ setText(QString("---"));
+ return true;
+ }
+ else if (v == off) {
+ if (editable)
+ setText(QString(""));
+ else
+ setText(specialValue);
+ }
+ else {
+ QString s;
+ s.setNum(v);
+ if (!editable)
+ s += suffix;
+ setText(s);
+ }
+ return false;
+ }
+
+//---------------------------------------------------------
+// setSValue
+//---------------------------------------------------------
+
+bool IntLabel::setSValue(const QString& s)
+ {
+ int v;
+ if (s == specialValue)
+ v = off;
+ else {
+ bool ok;
+ v = s.toInt(&ok);
+ if (!ok)
+ return true;
+ if (v < min)
+ v = min;
+ if (v > max)
+ v = max;
+ }
+ if (v != val) {
+ setValue(v);
+ emit valueChanged(val);
+ }
+ return false;
+ }
+
+//---------------------------------------------------------
+// incValue
+//---------------------------------------------------------
+
+void IntLabel::incValue(int)
+ {
+ if (val < max) {
+ setValue(val+1);
+ emit valueChanged(val);
+ }
+ }
+
+//---------------------------------------------------------
+// decValue
+//---------------------------------------------------------
+
+void IntLabel::decValue(int)
+ {
+ if (val > min) {
+ setValue(val-1);
+ emit valueChanged(val);
+ }
+ }
+
+//---------------------------------------------------------
+// setOff
+//---------------------------------------------------------
+
+void IntLabel::setOff(int v)
+ {
+ off = v;
+ setString(val);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/intlabel.h b/attic/muse2-oom/muse2/muse/widgets/intlabel.h
new file mode 100644
index 00000000..df452891
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/intlabel.h
@@ -0,0 +1,46 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: intlabel.h,v 1.1.1.1.2.2 2008/08/18 00:15:26 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __INTLABEL_H__
+#define __INTLABEL_H__
+
+#include <values.h>
+#include "nentry.h"
+
+class QString;
+
+//---------------------------------------------------------
+// IntLabel
+//---------------------------------------------------------
+
+class IntLabel : public Nentry {
+ Q_OBJECT
+
+ int min, max, off;
+ QString suffix;
+ QString specialValue;
+
+ void init();
+
+ virtual bool setSValue(const QString&);
+ virtual bool setString(int val, bool editable = false);
+ virtual void incValue(int);
+ virtual void decValue(int);
+
+ signals:
+ void valueChanged(int);
+
+ public:
+ IntLabel(int, int, int, QWidget*, int _off = MAXINT,
+ const QString& = QString(""), int lpos = 0);
+ void setOff(int v);
+ void setSuffix(const QString& s) { suffix = s; }
+ void setSpecialValueText(const QString& s);
+ void setRange(int, int);
+ };
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/itransformbase.ui b/attic/muse2-oom/muse2/muse/widgets/itransformbase.ui
new file mode 100644
index 00000000..51280e56
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/itransformbase.ui
@@ -0,0 +1,1170 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MidiInputTransformDialogBase</class>
+ <widget class="QDialog" name="MidiInputTransformDialogBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>832</width>
+ <height>587</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Midi Input Transformator</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="0" column="1" colspan="3">
+ <widget class="QGroupBox" name="GroupBox3">
+ <property name="title">
+ <string>Filter</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="1" column="0">
+ <widget class="QComboBox" name="selEventOp">
+ <item>
+ <property name="text">
+ <string>All</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Equal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Unequal</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QComboBox" name="selType">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <item>
+ <property name="text">
+ <string>Note</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Poly Pressure</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Control Change</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Aftertouch</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Pitch Bend</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>NRPN</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>RPN</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLabel" name="TextLabel3">
+ <property name="text">
+ <string>Value 2</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="TextLabel2">
+ <property name="text">
+ <string>Value 1</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="TextLabel1">
+ <property name="text">
+ <string>Event Type</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="selVal1Op">
+ <item>
+ <property name="text">
+ <string>Ignore</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Equal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Unequal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Higher</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Lower</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Inside</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Outside</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QSpinBox" name="selVal1b">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QSpinBox" name="selVal2b">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QSpinBox" name="selVal1a">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QComboBox" name="selVal2Op">
+ <item>
+ <property name="text">
+ <string>Ignore</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Equal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Unequal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Higher</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Lower</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Inside</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Outside</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QComboBox" name="selPortOp">
+ <item>
+ <property name="text">
+ <string>Ignore</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Equal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Unequal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Higher</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Lower</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Inside</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Outside</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="4">
+ <widget class="QComboBox" name="selChannelOp">
+ <item>
+ <property name="text">
+ <string>Ignore</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Equal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Unequal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Higher</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Lower</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Inside</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Outside</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <widget class="QLabel" name="TextLabel2_2">
+ <property name="text">
+ <string>Channel</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QLabel" name="TextLabel1_3">
+ <property name="text">
+ <string>Port</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QSpinBox" name="selVal2a">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="4">
+ <widget class="QSpinBox" name="selChannelVala">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QSpinBox" name="selPortVala">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="4">
+ <widget class="QSpinBox" name="selChannelValb">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="3">
+ <widget class="QSpinBox" name="selPortValb">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="1" colspan="3">
+ <widget class="QGroupBox" name="GroupBox5">
+ <property name="title">
+ <string>Processing</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="TextLabel5">
+ <property name="text">
+ <string>Event Type</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QComboBox" name="procEventOp">
+ <item>
+ <property name="text">
+ <string>Keep</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Fix</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QComboBox" name="procType">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <item>
+ <property name="text">
+ <string>Poly Pressure</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Control Change</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Aftertouch</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Pitch Bend</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>NRPN</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>RPN</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="procVal1Op">
+ <item>
+ <property name="text">
+ <string>Keep</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Plus</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Minus</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Multiply</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Divide</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Fix</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Value 2</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Invert</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>ScaleMap</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Flip</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Dyn</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Random</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="TextLabel6">
+ <property name="text">
+ <string>Value 1</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLabel" name="TextLabel7">
+ <property name="text">
+ <string>Value 2</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QSpinBox" name="procVal1b">
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QSpinBox" name="procVal2b">
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="SpinBoxFP" name="procVal1a">
+ <property name="maximum" stdset="0">
+ <number>99999999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="4">
+ <widget class="QSpinBox" name="procChannelValb">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="3">
+ <widget class="QSpinBox" name="procPortValb">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QLabel" name="TextLabel1_3_2">
+ <property name="text">
+ <string>Port</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QComboBox" name="procVal2Op">
+ <item>
+ <property name="text">
+ <string>Keep</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Plus</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Minus</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Multiply</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Divide</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Fix</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Value 1</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Invert</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Dyn</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Random</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="4">
+ <widget class="QComboBox" name="procChannelOp">
+ <item>
+ <property name="text">
+ <string>Keep</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Plus</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Minus</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Multiply</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Divide</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Fix</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Value 1</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Invert</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Dyn</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Random</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QComboBox" name="procPortOp">
+ <item>
+ <property name="text">
+ <string>Keep</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Plus</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Minus</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Multiply</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Divide</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Fix</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Value 1</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Invert</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Dyn</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Random</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <widget class="QLabel" name="TextLabel2_2_2">
+ <property name="text">
+ <string>Channel</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="SpinBoxFP" name="procVal2a">
+ <property name="maximum" stdset="0">
+ <number>99999999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="SpinBoxFP" name="procPortVala">
+ <property name="maximum" stdset="0">
+ <number>99999999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="4">
+ <widget class="SpinBoxFP" name="procChannelVala">
+ <property name="maximum" stdset="0">
+ <number>99999999</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QGroupBox" name="GroupBox5_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Modules</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="0" column="0" rowspan="4">
+ <widget class="QGroupBox" name="modulBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string/>
+ </property>
+ <property name="flat">
+ <bool>true</bool>
+ </property>
+ <property name="lineWidth" stdset="0">
+ <number>0</number>
+ </property>
+ <property name="exclusive" stdset="0">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QToolButton" name="modul1select">
+ <property name="text">
+ <string>1</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="modul2select">
+ <property name="text">
+ <string>2</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="modul3select">
+ <property name="text">
+ <string>3</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="modul4select">
+ <property name="text">
+ <string>4</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QCheckBox" name="modul1enable">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>enable modul 1</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QCheckBox" name="modul2enable">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>enable modul 2</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QCheckBox" name="modul3enable">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>enable modul 3</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QCheckBox" name="modul4enable">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="toolTip">
+ <string>enable modul 4</string>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QGroupBox" name="GroupBox6_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Preset</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="TextLabel13_2">
+ <property name="text">
+ <string>Name:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="nameEntry">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="TextLabel14_2">
+ <property name="text">
+ <string>Comment:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="commentEntry">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QGroupBox" name="GroupBox7_2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Maximum" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="title">
+ <string>Function</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QComboBox" name="funcOp"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="3" column="0" colspan="4">
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="buttonNew">
+ <property name="toolTip">
+ <string>create new preset</string>
+ </property>
+ <property name="text">
+ <string>&amp;New</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonDelete">
+ <property name="toolTip">
+ <string>delete preset</string>
+ </property>
+ <property name="text">
+ <string>&amp;Delete</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="Horizontal Spacing2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonOk">
+ <property name="text">
+ <string>&amp;Dismiss</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="0" rowspan="3">
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="TextLabel1_2">
+ <property name="text">
+ <string>PresetList</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QListWidget" name="presetList">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <customwidgets>
+ <customwidget>
+ <class>SpinBoxFP</class>
+ <extends>QDoubleSpinBox</extends>
+ <header>spinboxFP.h</header>
+ </customwidget>
+ </customwidgets>
+ <tabstops>
+ <tabstop>selEventOp</tabstop>
+ <tabstop>selType</tabstop>
+ <tabstop>selVal1Op</tabstop>
+ <tabstop>selVal1a</tabstop>
+ <tabstop>selVal1b</tabstop>
+ <tabstop>selVal2Op</tabstop>
+ <tabstop>selVal2a</tabstop>
+ <tabstop>selVal2b</tabstop>
+ <tabstop>selPortOp</tabstop>
+ <tabstop>selPortVala</tabstop>
+ <tabstop>selPortValb</tabstop>
+ <tabstop>selChannelOp</tabstop>
+ <tabstop>selChannelVala</tabstop>
+ <tabstop>selChannelValb</tabstop>
+ <tabstop>procEventOp</tabstop>
+ <tabstop>procType</tabstop>
+ <tabstop>procVal1Op</tabstop>
+ <tabstop>procVal1b</tabstop>
+ <tabstop>procVal2Op</tabstop>
+ <tabstop>procVal2b</tabstop>
+ <tabstop>procPortOp</tabstop>
+ <tabstop>procPortValb</tabstop>
+ <tabstop>procChannelOp</tabstop>
+ <tabstop>procChannelValb</tabstop>
+ <tabstop>modul1enable</tabstop>
+ <tabstop>modul2enable</tabstop>
+ <tabstop>modul3enable</tabstop>
+ <tabstop>modul4enable</tabstop>
+ <tabstop>funcOp</tabstop>
+ <tabstop>nameEntry</tabstop>
+ <tabstop>commentEntry</tabstop>
+ <tabstop>presetList</tabstop>
+ <tabstop>buttonNew</tabstop>
+ <tabstop>buttonDelete</tabstop>
+ <tabstop>buttonOk</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>MidiInputTransformDialogBase</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/knob.cpp b/attic/muse2-oom/muse2/muse/widgets/knob.cpp
new file mode 100644
index 00000000..950888a3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/knob.cpp
@@ -0,0 +1,540 @@
+//======================================================================
+// MusE
+// Linux Music Editor
+// $Id: knob.cpp,v 1.3.2.3 2009/03/09 02:05:18 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//
+// Adapted from Qwt Lib:
+// Copyright (C) 1997 Josef Wilgen
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2,
+// as published by the Free Software Foundation.
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//=========================================================
+
+#include <stdio.h>
+#include "knob.h"
+#include <cmath>
+#include "mmath.h"
+
+#include <QPainter>
+#include <QPalette>
+#include <QPaintEvent>
+#include <QResizeEvent>
+
+//---------------------------------------------------------
+// The QwtKnob widget imitates look and behaviour of a volume knob on a radio.
+// It contains
+// a scale around the knob which is set up automatically or can
+// be configured manually (see @^QwtScaleIf@).
+// Automatic scrolling is enabled when the user presses a mouse
+// button on the scale. For a description of signals, slots and other
+// members, see QwtSliderBase@.
+//---------------------------------------------------------
+
+
+//---------------------------------------------------------
+// Knob
+//---------------------------------------------------------
+
+Knob::Knob(QWidget* parent, const char* name)
+ : SliderBase(parent, name)
+ {
+ hasScale = false;
+
+ d_borderWidth = 2;
+ d_borderDist = 4;
+ d_totalAngle = 270.0;
+ d_scaleDist = 1;
+ d_symbol = Line;
+ d_maxScaleTicks = 11;
+ d_knobWidth = 30;
+ _faceColSel = FALSE;
+ d_faceColor = palette().color(QPalette::Window);
+ d_curFaceColor = d_faceColor;
+ d_altFaceColor = d_faceColor;
+ d_markerColor = palette().color(QPalette::WindowText);
+ d_dotWidth = 8;
+
+ setMinimumSize(30,30);
+ setUpdateTime(50);
+ }
+
+//------------------------------------------------------------
+// QwtKnob::setTotalAngle
+// Set the total angle by which the knob can be turned
+//
+// Syntax
+// void QwtKnob::setTotalAngle(double angle)
+//
+// Parameters
+// double angle -- angle in degrees.
+//
+// Description
+// The default angle is 270 degrees. It is possible to specify
+// an angle of more than 360 degrees so that the knob can be
+// turned several times around its axis.
+//------------------------------------------------------------
+
+void Knob::setTotalAngle (double angle)
+ {
+ if (angle < 10.0)
+ d_totalAngle = 10.0;
+ else
+ d_totalAngle = angle;
+ d_scale.setAngleRange( -0.5 * d_totalAngle, 0.5 * d_totalAngle);
+ }
+
+//------------------------------------------------------------
+// QwtKnob::drawKnob
+// const QRect &r -- borders of the knob
+//------------------------------------------------------------
+
+void Knob::drawKnob(QPainter* p, const QRect& r)
+ {
+ QRect aRect;
+
+ const QPalette& pal = palette();
+ QPen pn;
+ int bw2 = d_borderWidth / 2;
+
+ aRect.setRect(r.x() + bw2,
+ r.y() + bw2,
+ r.width() - 2*bw2,
+ r.height() - 2*bw2);
+
+ //
+ // draw button face
+ //
+ // p->setPen(Qt::NoPen);
+ // p->setBrush(d_curFaceColor);
+ // p->drawEllipse(aRect);
+
+ //
+ // draw button shades
+ //
+ // pn.setWidth(d_borderWidth);
+
+
+ // pn.setColor(pal.color(QPalette::Light));
+ // p->setPen(pn);
+ // p->drawArc(aRect, 45*16,180*16);
+
+ // pn.setColor(pal.color(QPalette::Dark));
+ // p->setPen(pn);
+ // p->drawArc(aRect, 225*16,180*16);
+ QPixmap dial;
+ bool loaded;
+ if(!knobImage.isEmpty())
+ {
+ loaded = dial.load(knobImage);
+ }
+ else
+ {
+ loaded = dial.load(":images/knob.png");
+ }
+ if(loaded)
+ p->drawPixmap(aRect, dial);
+
+ //printf("\n\n\nButton size is X:%d : Y:%d : W:%d : H:%d \n\n\n\n",aRect.x(), aRect.y(), aRect.width(), aRect.height());
+
+ //
+ // draw marker
+ //
+ //drawMarker(p, d_angle, isEnabled() ? d_markerColor : Qt::gray);
+ drawMarker(p, d_angle, pal.currentColorGroup() == QPalette::Disabled ?
+ pal.color(QPalette::Disabled, QPalette::WindowText) : d_markerColor);
+ }
+
+//------------------------------------------------------------
+//.F QwtSliderBase::valueChange
+// Notify change of value
+//
+//.u Parameters
+// double x -- new value
+//
+//.u Description
+// Sets the slider's value to the nearest multiple
+// of the step size.
+//------------------------------------------------------------
+
+void Knob::valueChange()
+ {
+ recalcAngle();
+ d_newVal++;
+ repaint(kRect);
+ SliderBase::valueChange();
+ }
+
+//------------------------------------------------------------
+//.F QwtKnob::getValue
+// Determine the value corresponding to a specified position
+//
+//.u Parameters:
+// const QPoint &p -- point
+//
+//.u Description:
+// Called by QwtSliderBase
+//------------------------------------------------------------
+
+double Knob::getValue(const QPoint &p)
+ {
+ double newValue;
+ double oneTurn;
+ double eqValue;
+ double arc;
+
+ const QRect& r = rect();
+
+ double dx = double((r.x() + r.width() / 2) - p.x() );
+ double dy = double((r.y() + r.height() / 2) - p.y() );
+
+ arc = atan2(-dx,dy) * 180.0 / M_PI;
+
+ newValue = 0.5 * (minValue() + maxValue())
+ + (arc + d_nTurns * 360.0) * (maxValue() - minValue())
+ / d_totalAngle;
+
+ oneTurn = fabs(maxValue() - minValue()) * 360.0 / d_totalAngle;
+ eqValue = value() + d_mouseOffset;
+
+ if (fabs(newValue - eqValue) > 0.5 * oneTurn)
+ {
+ if (newValue < eqValue)
+ newValue += oneTurn;
+ else
+ newValue -= oneTurn;
+ }
+
+ return newValue;
+
+}
+
+
+
+//------------------------------------------------------------
+//.-
+//.F QwtKnob::setScrollMode
+// Determine the scrolling mode and direction
+// corresponding to a specified position
+//
+//.u Parameters
+// const QPoint &p -- point in question
+//
+//.u Description
+// Called by QwtSliderBase
+//------------------------------------------------------------
+void Knob::getScrollMode( QPoint &p, const Qt::MouseButton &/*button*/, int &scrollMode, int &direction)// prevent compiler warning : unsused parameter
+{
+ int dx, dy, r;
+ double arc;
+
+ /*Qt::ButtonState but= button ;*/ // prevent compiler warning : unsused variable
+ r = kRect.width() / 2;
+
+ dx = kRect.x() + r - p.x();
+ dy = kRect.y() + r - p.y();
+
+ if ( (dx * dx) + (dy * dy) <= (r * r)) // point is inside the knob
+ {
+ scrollMode = ScrMouse;
+ direction = 0;
+ }
+ else // point lies outside
+ {
+ scrollMode = ScrTimer;
+ arc = atan2(double(-dx),double(dy)) * 180.0 / M_PI;
+ if ( arc < d_angle)
+ direction = -1;
+ else if (arc > d_angle)
+ direction = 1;
+ else
+ direction = 0;
+ }
+ return;
+}
+
+
+
+//------------------------------------------------------------
+//.F QwtKnob::rangeChange
+// Notify a change of the range
+//
+//.u Description
+// Called by QwtSliderBase
+//------------------------------------------------------------
+
+void Knob::rangeChange()
+{
+ if (!hasUserScale())
+ {
+ d_scale.setScale(minValue(), maxValue(),
+ d_maxMajor, d_maxMinor);
+ }
+ recalcAngle();
+ resize(size());
+ repaint();
+}
+
+//---------------------------------------------------------
+// resizeEvent
+//---------------------------------------------------------
+
+void Knob::resizeEvent(QResizeEvent *)
+ {
+ int width, width_2;
+
+ const QRect& r = rect();
+
+// printf("resize %d %d %d\n", r.height(), r.width(), d_knobWidth);
+
+// width = qwtMin(qwtMin(r.height(), r.width()), d_knobWidth);
+ width = qwtMin(r.height(), r.width());
+ width_2 = width / 2;
+
+ int x = r.x() + r.width() / 2 - width_2;
+ int y = r.y() + r.height() / 2 - width_2;
+
+ kRect.setRect(x, y, width, width);
+
+ x = kRect.x() - d_scaleDist;
+ y = kRect.y() - d_scaleDist;
+ int w = width + 2 * d_scaleDist;
+
+ d_scale.setGeometry(x, y, w, ScaleDraw::Round);
+ }
+
+//------------------------------------------------------------
+// paintEvent
+//------------------------------------------------------------
+
+void Knob::paintEvent(QPaintEvent*)
+ {
+/* QPainter p(this);
+ const QRect &r = e->rect();
+
+ if ((r == kRect) && d_newVal ) { // event from valueChange()
+ if (d_newVal > 1) // lost paintEvents()?
+ drawKnob(&p, kRect);
+ else {
+ drawMarker(&p, d_oldAngle, d_curFaceColor);
+ drawMarker(&p, d_angle, d_markerColor);
+ }
+ }
+ else {
+ p.eraseRect(rect());
+ if (hasScale)
+ d_scale.draw(&p);
+ drawKnob(&p, kRect);
+ }
+ d_newVal = 0;
+*/
+
+ QPainter p(this);
+ p.setRenderHint(QPainter::Antialiasing, true);
+ if(hasScale)
+ d_scale.draw(&p);
+ drawKnob(&p, kRect);
+ //drawMarker(&p, d_oldAngle, d_curFaceColor);
+ //drawMarker(&p, d_angle, d_markerColor);
+
+ d_newVal = 0;
+ }
+
+//------------------------------------------------------------
+//.-
+//.F QwtKnob::drawMarker
+// Draw the marker at the knob's front
+//
+//.u Parameters
+//.p QPainter *p -- painter
+// double arc -- angle of the marker
+// const QColor &c -- marker color
+//
+//.u Syntax
+// void QwtKnob::drawMarker(QPainter *p)
+//
+//------------------------------------------------------------
+void Knob::drawMarker(QPainter *p, double arc, const QColor &c)
+{
+
+ QPen pn;
+ int radius;
+ double rb,re;
+ double rarc;
+
+ rarc = arc * M_PI / 180.0;
+ double ca = cos(rarc);
+ double sa = - sin(rarc);
+ radius = kRect.width() / 2 - d_borderWidth;
+ if (radius < 3) radius = 3;
+ int ym = kRect.y() + radius + d_borderWidth;
+ int xm = kRect.x() + radius + d_borderWidth;
+
+ switch (d_symbol)
+ {
+ case Dot:
+
+ p->setBrush(c);
+ p->setPen(Qt::NoPen);
+ rb = double(qwtMax(radius - 4 - d_dotWidth / 2, 0));
+ p->drawEllipse(xm - int(rint(sa * rb)) - d_dotWidth / 2,
+ ym - int(rint(ca * rb)) - d_dotWidth / 2,
+ d_dotWidth, d_dotWidth);
+
+ break;
+
+ case Line:
+
+ pn.setColor(c);
+ pn.setWidth(2);
+ p->setPen(pn);
+
+ rb = qwtMax(double((radius - 4) / 3.0), 0.0);
+ re = qwtMax(double(radius - 4), 0.0);
+
+ p->drawLine( xm - int(rint(sa * rb)),
+ ym - int(rint(ca * rb)),
+ xm - int(rint(sa * re)),
+ ym - int(rint(ca * re)));
+
+ break;
+ }
+
+
+}
+
+//------------------------------------------------------------
+//
+//.F QwtKnob::setKnobWidth
+// Change the knob's width.
+//
+//.u Syntax
+//.f void QwtKnob::setKnobWidth(int w)
+//
+//.u Parameters
+//.p int w -- new width
+//
+//.u Description
+// The specified width must be >= 5, or it will be clipped.
+//
+//------------------------------------------------------------
+void Knob::setKnobWidth(int w)
+{
+ d_knobWidth = qwtMax(w,5);
+ resize(size());
+ repaint();
+}
+
+//------------------------------------------------------------
+//
+//.F QwtKnob::setBorderWidth
+// Set the knob's border width
+//
+//.u Syntax
+//.f void QwtKnob::setBorderWidth(int bw)
+//
+//.u Parameters
+//.p int bw -- new border width
+//
+//------------------------------------------------------------
+void Knob::setBorderWidth(int bw)
+{
+ d_borderWidth = qwtMax(bw, 0);
+ resize(size());
+ repaint();
+}
+
+//------------------------------------------------------------
+//.-
+//.F QwtKnob::recalcAngle
+// Recalculate the marker angle corresponding to the
+// current value
+//
+//.u Syntax
+//.f void QwtKnob::recalcAngle()
+//
+//------------------------------------------------------------
+void Knob::recalcAngle()
+{
+ d_oldAngle = d_angle;
+
+ //
+ // calculate the angle corresponding to the value
+ //
+ if (maxValue() == minValue())
+ {
+ d_angle = 0;
+ d_nTurns = 0;
+ }
+ else
+ {
+ d_angle = (value() - 0.5 * (minValue() + maxValue()))
+ / (maxValue() - minValue()) * d_totalAngle;
+ d_nTurns = floor((d_angle + 180.0) / 360.0);
+ d_angle = d_angle - d_nTurns * 360.0;
+
+ }
+
+}
+
+//------------------------------------------------------------
+// setFaceColor
+//------------------------------------------------------------
+void Knob::setFaceColor(const QColor c)
+{
+ d_faceColor = c;
+ if(!_faceColSel)
+ //update(FALSE);
+ repaint();
+}
+
+//------------------------------------------------------------
+// setAltFaceColor
+//------------------------------------------------------------
+void Knob::setAltFaceColor(const QColor c)
+{
+ d_altFaceColor = c;
+ if(_faceColSel)
+ //update(FALSE);
+ repaint();
+}
+
+//------------------------------------------------------------
+// selectFaceColor
+//------------------------------------------------------------
+void Knob::selectFaceColor(bool alt)
+{
+ _faceColSel = alt;
+ if(alt)
+ d_curFaceColor = d_altFaceColor;
+ else
+ d_curFaceColor = d_faceColor;
+ //update(FALSE);
+ repaint();
+}
+
+//------------------------------------------------------------
+// setKnobImage
+//------------------------------------------------------------
+void Knob::setKnobImage(const QString img)
+{
+ knobImage = img;
+}
+
+//------------------------------------------------------------
+// setMarkerColor
+//------------------------------------------------------------
+void Knob::setMarkerColor(const QColor c)
+{
+ d_markerColor = c;
+ //update(FALSE);
+ repaint();
+}
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/knob.h b/attic/muse2-oom/muse2/muse/widgets/knob.h
new file mode 100644
index 00000000..ce43f2ad
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/knob.h
@@ -0,0 +1,79 @@
+#ifndef QWT_KNOB_H
+#define QWT_KNOB_H
+
+#include "sliderbase.h"
+#include "sclif.h"
+#include <QColor>
+#include <QResizeEvent>
+#include <QPaintEvent>
+
+
+//---------------------------------------------------------
+// Knob
+//---------------------------------------------------------
+
+class Knob : public SliderBase, public ScaleIf
+ {
+ Q_OBJECT
+
+ public:
+ enum Symbol { Line, Dot };
+
+ private:
+ bool hasScale;
+
+ int d_borderWidth;
+ int d_borderDist;
+ int d_scaleDist;
+ int d_maxScaleTicks;
+ int d_newVal;
+ int d_knobWidth;
+ int d_dotWidth;
+
+ Symbol d_symbol;
+ double d_angle;
+ double d_oldAngle;
+ double d_totalAngle;
+ double d_nTurns;
+
+ QRect kRect;
+ bool _faceColSel;
+ QColor d_faceColor;
+ QColor d_curFaceColor;
+ QColor d_altFaceColor;
+ QColor d_markerColor;
+ QString knobImage;
+
+ void recalcAngle();
+ void valueChange();
+ void rangeChange();
+ void drawKnob(QPainter *p, const QRect &r);
+ void drawMarker(QPainter *p, double arc, const QColor &c);
+
+ void paintEvent(QPaintEvent *);
+ void resizeEvent(QResizeEvent *e);
+ double getValue(const QPoint &p);
+ void getScrollMode( QPoint &p, const Qt::MouseButton &button, int &scrollMode, int &direction );
+ void scaleChange() { repaint(); }
+ void fontChange(const QFont &) { repaint(); }
+
+ public:
+ Knob(QWidget* parent = 0, const char *name = 0);
+ ~Knob() {}
+
+ void setKnobWidth(int w);
+ void setTotalAngle (double angle);
+ void setBorderWidth(int bw);
+ void selectFaceColor(bool alt);
+ bool selectedFaceColor() { return _faceColSel; }
+ QColor faceColor() { return d_faceColor; }
+ void setFaceColor(const QColor c);
+ QColor altFaceColor() { return d_altFaceColor; }
+ void setAltFaceColor(const QColor c);
+ QColor markerColor() { return d_markerColor; }
+ void setMarkerColor(const QColor c);
+ void setKnobImage(const QString img);
+ };
+
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/lcombo.cpp b/attic/muse2-oom/muse2/muse/widgets/lcombo.cpp
new file mode 100644
index 00000000..e4bdf00c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/lcombo.cpp
@@ -0,0 +1,51 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: lcombo.cpp,v 1.1.1.1.2.3 2009/07/01 22:14:56 spamatica Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "lcombo.h"
+
+#include <QHBoxLayout>
+#include <QLabel>
+
+
+//---------------------------------------------------------
+// LabelCombo
+//---------------------------------------------------------
+
+LabelCombo::LabelCombo(const QString& txt, QWidget* parent,
+ const char* name) : QWidget(parent)
+ {
+ setObjectName(name);
+// setFixedHeight(20);
+ QHBoxLayout* layout = new QHBoxLayout(this);
+ QLabel* label = new QLabel(txt, this);
+ //box = new QComboBox(false, this);
+ box = new QComboBox(this);
+ box->setEditable(false);
+ ///layout->addStretch();
+ layout->addSpacing(5);
+ layout->addWidget(label);
+ layout->addSpacing(5);
+ layout->addWidget(box);
+ layout->addSpacing(5);
+ ///layout->addStretch();
+ connect(box, SIGNAL(activated(int)), SIGNAL(activated(int)));
+ }
+
+void LabelCombo::setCurrentIndex(int i)
+{
+ int rc = box->model()->rowCount();
+ if(rc == 0)
+ return;
+ int r = i % rc;
+ int c = i / rc;
+ if(c >= box->model()->columnCount())
+ return;
+ if(box->modelColumn() != c)
+ box->setModelColumn(c);
+ if(box->currentIndex() != r)
+ box->setCurrentIndex(r);
+}
diff --git a/attic/muse2-oom/muse2/muse/widgets/lcombo.h b/attic/muse2-oom/muse2/muse/widgets/lcombo.h
new file mode 100644
index 00000000..b125fce5
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/lcombo.h
@@ -0,0 +1,43 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: lcombo.h,v 1.1.1.1.2.3 2009/07/01 22:14:56 spamatica Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __LCOMBO_H__
+#define __LCOMBO_H__
+
+#include <QAbstractItemView>
+#include <QComboBox>
+#include <QVariant>
+
+class QString;
+
+
+//---------------------------------------------------------
+// LabelCombo
+//---------------------------------------------------------
+
+class LabelCombo : public QWidget {
+ QComboBox* box;
+ Q_OBJECT
+
+ signals:
+ void activated(int);
+
+ public slots:
+ void clearFocus() { box->clearFocus(); }
+ void setCurrentIndex(int i);
+
+ public:
+ LabelCombo(const QString& label, QWidget* parent,
+ const char* name=0);
+ void addItem(const QString& txt, const QVariant & userData = QVariant()) { box->addItem(txt, userData); }
+ void insertItem(int index, const QString& txt, const QVariant & userData = QVariant()) { box->insertItem(index, txt, userData); }
+ //void setListBox(Q3ListBox* lb) { box->setListBox(lb); } // ddskrjo
+ void setView(QAbstractItemView* v) { box->setModel(v->model()); box->setView(v); } // p4.0.3
+ void setFocusPolicy ( Qt::FocusPolicy fp ) { box->setFocusPolicy(fp); }
+ };
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/menutitleitem.h b/attic/muse2-oom/muse2/muse/widgets/menutitleitem.h
new file mode 100644
index 00000000..016d4663
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/menutitleitem.h
@@ -0,0 +1,25 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: menutitleitem.h,v 1.1.2.1 2009/06/10 00:34:59 terminator356 Exp $
+// (C) Copyright 1999-2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MENU_TITLE_ITEM_H__
+#define __MENU_TITLE_ITEM_H__
+
+#include <QWidgetAction>
+
+//---------------------------------------------------------
+// MenuTitleItem
+//---------------------------------------------------------
+
+class MenuTitleItem : public QWidgetAction {
+ QString s;
+
+ public:
+ MenuTitleItem(const QString&, QWidget* /*parent*/);
+ QWidget* createWidget(QWidget* /*parent*/);
+ };
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/metronome.cpp b/attic/muse2-oom/muse2/muse/widgets/metronome.cpp
new file mode 100644
index 00000000..08c8abac
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/metronome.cpp
@@ -0,0 +1,183 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: metronome.cpp,v 1.2.2.1 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include "metronome.h"
+
+#include <QMenu>
+#include "globals.h"
+#include "song.h"
+#include "track.h"
+#include "audio.h"
+
+//---------------------------------------------------------
+// MetronomeConfig
+//---------------------------------------------------------
+
+MetronomeConfig::MetronomeConfig(QDialog* parent)
+ : QDialog(parent)
+ {
+ setupUi(this);
+ connect(buttonApply, SIGNAL(clicked()), SLOT(apply()));
+ connect(midiClick, SIGNAL(toggled(bool)), SLOT(midiClickChanged(bool)));
+ connect(precountEnable, SIGNAL(toggled(bool)), SLOT(precountEnableChanged(bool)));
+ connect(precountFromMastertrack, SIGNAL(toggled(bool)),
+ SLOT(precountFromMastertrackChanged(bool)));
+ connect(audioBeepRoutesButton, SIGNAL(clicked()), SLOT(audioBeepRoutesClicked()));
+ connect(volumeSlider, SIGNAL(valueChanged(int)), SLOT(beepVolumeChanged(int)));
+
+ measureNote->setValue(measureClickNote);
+ measureVelocity->setValue(measureClickVelo);
+ beatNote->setValue(beatClickNote);
+ beatVelocity->setValue(beatClickVelo);
+ midiChannel->setValue(clickChan+1);
+ midiPort->setValue(clickPort+1);
+
+ /*
+ precountBars->setValue(preMeasures);
+ precountEnable->setChecked(precountEnableFlag);
+ precountFromMastertrack->setChecked(precountFromMastertrackFlag);
+ precountSigZ->setValue(::precountSigZ);
+ precountSigN->setValue(::precountSigN);
+ precountPrerecord->setChecked(::precountPrerecord);
+ precountPreroll->setChecked(::precountPreroll);
+ */
+
+ midiClick->setChecked(midiClickFlag);
+ audioBeep->setChecked(audioClickFlag);
+ }
+
+//---------------------------------------------------------
+// audioBeepRoutesClicked
+//---------------------------------------------------------
+
+void MetronomeConfig::audioBeepRoutesClicked()
+{
+ if(song->outputs()->size() == 0)
+ return;
+
+ QMenu* pup = new QMenu;
+
+ OutputList* ol = song->outputs();
+
+ int nn = 0;
+ for(iAudioOutput iao = ol->begin(); iao != ol->end(); ++iao)
+ {
+ QAction* action = pup->addAction(QT_TRANSLATE_NOOP("@default", (*iao)->name()));
+ action->setCheckable(true);
+ action->setData(nn);
+ if((*iao)->sendMetronome())
+ action->setChecked(true);
+ ++nn;
+ }
+
+ QAction* clickaction = pup->exec(QCursor::pos());
+ if (clickaction)
+ {
+ //QString s(pup->text(n));
+ nn = 0;
+ for(iAudioOutput iao = ol->begin(); iao != ol->end(); ++iao)
+ {
+ //if(((*iao)->name() == s) && (n == nn))
+ if (nn == clickaction->data())
+ {
+ //(*iao)->setSendMetronome();
+ audio->msgSetSendMetronome(*iao, clickaction->isChecked());
+ //song->update(SC_ROUTE);
+ break;
+ }
+ ++nn;
+ }
+ }
+
+ delete pup;
+ audioBeepRoutesButton->setDown(false); // pup->exec() catches mouse release event
+}
+
+//---------------------------------------------------------
+// accept
+//---------------------------------------------------------
+
+void MetronomeConfig::accept()
+ {
+ apply();
+ QDialog::accept();
+ }
+
+//---------------------------------------------------------
+// apply
+//---------------------------------------------------------
+
+void MetronomeConfig::apply()
+ {
+ measureClickNote = measureNote->value();
+ measureClickVelo = measureVelocity->value();
+ beatClickNote = beatNote->value();
+ beatClickVelo = beatVelocity->value();
+ clickChan = midiChannel->value() - 1;
+ clickPort = midiPort->value() - 1;
+ preMeasures = precountBars->value();
+ /*
+ precountEnableFlag = precountEnable->isChecked();
+ precountFromMastertrackFlag = precountFromMastertrack->isChecked();
+ ::precountSigZ = precountSigZ->value();
+ ::precountSigN = precountSigN->value();
+ ::precountPrerecord = precountPrerecord->isChecked();
+ ::precountPreroll = precountPreroll->isChecked();
+ */
+ midiClickFlag = midiClick->isChecked();
+ audioClickFlag = audioBeep->isChecked();
+ //audioVolumeChanged = volumeSlider->value();
+ }
+
+//---------------------------------------------------------
+// reject
+//---------------------------------------------------------
+
+void MetronomeConfig::reject()
+ {
+ QDialog::reject();
+ }
+
+//---------------------------------------------------------
+// midiClickChanged
+//---------------------------------------------------------
+
+void MetronomeConfig::midiClickChanged(bool flag)
+ {
+ measureNote->setEnabled(flag);
+ measureVelocity->setEnabled(flag);
+ beatNote->setEnabled(flag);
+ beatVelocity->setEnabled(flag);
+ midiChannel->setEnabled(flag);
+ midiPort->setEnabled(flag);
+ }
+
+void MetronomeConfig::precountEnableChanged(bool /*flag*/)
+ {
+ /*
+ precountBars->setEnabled(flag);
+ precountFromMastertrack->setEnabled(flag);
+ precountSigZ->setEnabled(flag && !precountFromMastertrack->isChecked());
+ precountSigN->setEnabled(flag && !precountFromMastertrack->isChecked());
+ */
+ }
+
+void MetronomeConfig::precountFromMastertrackChanged(bool /*flag*/)
+ {
+ /*
+ precountSigZ->setEnabled(!flag);
+ precountSigN->setEnabled(!flag);
+ */
+ }
+
+void MetronomeConfig::beepVolumeChanged(int volume)
+ {
+ // this value is directly applied, not using th Apply button, it just seems more usable this way.
+ audioClickVolume=volume/100.0;
+ }
diff --git a/attic/muse2-oom/muse2/muse/widgets/metronome.h b/attic/muse2-oom/muse2/muse/widgets/metronome.h
new file mode 100644
index 00000000..976dfcd0
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/metronome.h
@@ -0,0 +1,36 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: metronome.h,v 1.1.1.1.2.1 2009/12/20 05:00:35 terminator356 Exp $
+//
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __METRONOME_H__
+#define __METRONOME_H__
+
+#include "ui_metronomebase.h"
+
+class QDialog;
+
+//---------------------------------------------------------
+// MetronomeConfig
+//---------------------------------------------------------
+
+class MetronomeConfig : public QDialog, public Ui::MetronomeConfigBase {
+ Q_OBJECT
+
+ private slots:
+ virtual void accept();
+ void apply();
+ virtual void reject();
+ virtual void audioBeepRoutesClicked();
+ void midiClickChanged(bool);
+ void precountEnableChanged(bool);
+ void precountFromMastertrackChanged(bool);
+ void beepVolumeChanged(int);
+
+ public:
+ MetronomeConfig(QDialog* parent=0);
+ };
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/metronomebase.ui b/attic/muse2-oom/muse2/muse/widgets/metronomebase.ui
new file mode 100644
index 00000000..18a2d2f6
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/metronomebase.ui
@@ -0,0 +1,568 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MetronomeConfigBase</class>
+ <widget class="QDialog" name="MetronomeConfigBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>557</width>
+ <height>363</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Metronome Config</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="0" column="0">
+ <layout class="QGridLayout">
+ <item row="0" column="0">
+ <widget class="QGroupBox" name="GroupBox1">
+ <property name="title">
+ <string>Metronome</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="0" column="0">
+ <layout class="QVBoxLayout">
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QCheckBox" name="audioBeep">
+ <property name="text">
+ <string>Audio Beep</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="audioBeepRoutesButton">
+ <property name="text">
+ <string>Choose outputs...</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QSlider" name="volumeSlider">
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ <property name="singleStep">
+ <number>1</number>
+ </property>
+ <property name="pageStep">
+ <number>10</number>
+ </property>
+ <property name="value">
+ <number>50</number>
+ </property>
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="volumeLabel">
+ <property name="text">
+ <string>50</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="textLabel1">
+ <property name="text">
+ <string>% Audio volume</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="midiClick">
+ <property name="text">
+ <string>MIDI Click</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="4" column="1">
+ <widget class="QLabel" name="TextLabel5">
+ <property name="text">
+ <string>Midi Channel</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="TextLabel1">
+ <property name="text">
+ <string>Measure Note</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="4" column="0">
+ <widget class="QSpinBox" name="midiChannel">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>16</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QLabel" name="TextLabel2">
+ <property name="text">
+ <string>Measure Velocity</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QLabel" name="TextLabel4">
+ <property name="text">
+ <string>Beat Velocity</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QSpinBox" name="midiPort">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>16</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QLabel" name="TextLabel3">
+ <property name="text">
+ <string>Beat Note</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QSpinBox" name="beatNote"/>
+ </item>
+ <item row="1" column="0">
+ <widget class="QSpinBox" name="measureVelocity">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QSpinBox" name="measureNote"/>
+ </item>
+ <item row="5" column="1">
+ <widget class="QLabel" name="TextLabel6">
+ <property name="text">
+ <string>Midi Port</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QSpinBox" name="beatVelocity">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <spacer name="Spacer10">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QGroupBox" name="GroupBox2">
+ <property name="title">
+ <string>Precount</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QCheckBox" name="precountEnable">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>enable</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QSpinBox" name="precountBars">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>10</number>
+ </property>
+ <property name="value">
+ <number>2</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="TextLabel7">
+ <property name="text">
+ <string>Bars</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="precountFromMastertrack">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>From Mastertrack</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QSpinBox" name="precountSigZ">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>32</number>
+ </property>
+ <property name="value">
+ <number>4</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="TextLabel8">
+ <property name="text">
+ <string>/</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="precountSigN">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="minimum">
+ <number>2</number>
+ </property>
+ <property name="maximum">
+ <number>64</number>
+ </property>
+ <property name="value">
+ <number>4</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="TextLabel9">
+ <property name="text">
+ <string>Signature</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="precountPrerecord">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Prerecord</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="precountPreroll">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>Preroll</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QLabel" name="textLabel3">
+ <property name="text">
+ <string>Hint: Enable metronome in Transportpanel</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="Horizontal Spacing2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>8</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonApply">
+ <property name="text">
+ <string>&amp;Apply</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+A</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonOk">
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+O</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonCancel">
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+C</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <tabstops>
+ <tabstop>audioBeep</tabstop>
+ <tabstop>audioBeepRoutesButton</tabstop>
+ <tabstop>midiClick</tabstop>
+ <tabstop>measureNote</tabstop>
+ <tabstop>measureVelocity</tabstop>
+ <tabstop>beatNote</tabstop>
+ <tabstop>beatVelocity</tabstop>
+ <tabstop>midiChannel</tabstop>
+ <tabstop>midiPort</tabstop>
+ <tabstop>precountEnable</tabstop>
+ <tabstop>precountBars</tabstop>
+ <tabstop>precountFromMastertrack</tabstop>
+ <tabstop>precountSigZ</tabstop>
+ <tabstop>precountPrerecord</tabstop>
+ <tabstop>precountPreroll</tabstop>
+ <tabstop>precountSigN</tabstop>
+ <tabstop>buttonApply</tabstop>
+ <tabstop>buttonOk</tabstop>
+ <tabstop>buttonCancel</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>MetronomeConfigBase</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>MetronomeConfigBase</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>volumeSlider</sender>
+ <signal>valueChanged(int)</signal>
+ <receiver>volumeLabel</receiver>
+ <slot>setNum(int)</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/midisync.ui b/attic/muse2-oom/muse2/muse/widgets/midisync.ui
new file mode 100644
index 00000000..8fc6248a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/midisync.ui
@@ -0,0 +1,409 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <author>werner schweer</author>
+ <comment>midi sync
+configuration dialog</comment>
+ <class>MidiSyncConfigBase</class>
+ <widget class="QDialog" name="MidiSyncConfigBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>655</width>
+ <height>419</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Midi Sync</string>
+ </property>
+ <layout class="QGridLayout">
+ <item row="2" column="0">
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <spacer name="Spacer1_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="applyButton">
+ <property name="text">
+ <string>Apply</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton">
+ <property name="text">
+ <string>Ok</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="0">
+ <widget class="QGroupBox" name="GroupBox13">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="title">
+ <string>MTC</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QLabel" name="textLabel2">
+ <property name="text">
+ <string>Type:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="mtcSyncType">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <item>
+ <property name="text">
+ <string>24</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>25</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>30D</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>30N</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer4">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QLabel" name="textLabel1">
+ <property name="text">
+ <string>Offset:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="mtcOffH">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>hour</string>
+ </property>
+ <property name="maximum">
+ <number>23</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="TextLabel2">
+ <property name="text">
+ <string>h</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="mtcOffM">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>minute</string>
+ </property>
+ <property name="maximum">
+ <number>59</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="TextLabel3">
+ <property name="text">
+ <string>m</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="mtcOffS">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>second</string>
+ </property>
+ <property name="maximum">
+ <number>59</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="TextLabel4">
+ <property name="text">
+ <string>s</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="mtcOffF">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>frame</string>
+ </property>
+ <property name="maximum">
+ <number>30</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="TextLabel5">
+ <property name="text">
+ <string>f</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QSpinBox" name="mtcOffSf">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="toolTip">
+ <string>subframe</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QGroupBox" name="syncGen">
+ <property name="title">
+ <string>Sync receiving and sending</string>
+ </property>
+ <layout class="QGridLayout">
+ <item row="0" column="0" colspan="2">
+ <widget class="QCheckBox" name="useJackTransportCheckbox">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip">
+ <string>Send and receive Jack transport</string>
+ </property>
+ <property name="whatsThis">
+ <string>Send and receive Jack transport information,
+ including stop, start and position.</string>
+ </property>
+ <property name="text">
+ <string>Use Jack transport</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0" colspan="2">
+ <widget class="QCheckBox" name="jackTransportMasterCheckbox">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip">
+ <string>Make MusE the Jack transport Timebase Master</string>
+ </property>
+ <property name="whatsThis">
+ <string>Make MusE the Jack transport Timebase Master.
+Allows Jack to show time as
+ MusE Bars, Beats, and Ticks.
+MusE will try to become master, but other
+ Jack clients can also take over later.
+You can always click here again for Master.</string>
+ </property>
+ <property name="text">
+ <string>Jack transport Timebase Master</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0" colspan="2">
+ <widget class="QCheckBox" name="extSyncCheckbox">
+ <property name="enabled">
+ <bool>true</bool>
+ </property>
+ <property name="toolTip">
+ <string>Control MusE timing by external midi clock or MTC sync</string>
+ </property>
+ <property name="whatsThis">
+ <string>When in slave mode, tempo is
+ controlled externally.
+MusE can sync to midi clock, or MTC quarter frame sync.
+Enabled inputs in the list will
+ be in effect (RMC, RMMC, RMTC).</string>
+ </property>
+ <property name="text">
+ <string>Slave to external sync</string>
+ </property>
+ <property name="checked">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QSpinBox" name="syncDelaySpinBox">
+ <property name="toolTip">
+ <string>Send start to first clock delay</string>
+ </property>
+ <property name="whatsThis">
+ <string>Allows 'slow sync' devices time
+ to synchronize to MusE. This value is the
+ delay from sending start to sending
+ the first clock.</string>
+ </property>
+ <property name="suffix">
+ <string>ms</string>
+ </property>
+ <property name="minimum">
+ <number>0</number>
+ </property>
+ <property name="maximum">
+ <number>60000</number>
+ </property>
+ <property name="singleStep">
+ <number>1</number>
+ </property>
+ <property name="value">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="syncDelayLabel">
+ <property name="text">
+ <string>Send sync delay</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="4" column="0">
+ <widget class="QTreeWidget" name="devicesListView">
+ <column>
+ <property name="text">
+ <string notr="true">1</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <tabstops>
+ <tabstop>mtcOffH</tabstop>
+ <tabstop>mtcOffM</tabstop>
+ <tabstop>mtcOffS</tabstop>
+ <tabstop>mtcOffF</tabstop>
+ <tabstop>mtcOffSf</tabstop>
+ <tabstop>applyButton</tabstop>
+ <tabstop>okButton</tabstop>
+ <tabstop>cancelButton</tabstop>
+ </tabstops>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/midisyncimpl.cpp b/attic/muse2-oom/muse2/muse/widgets/midisyncimpl.cpp
new file mode 100644
index 00000000..75d21ac0
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/midisyncimpl.cpp
@@ -0,0 +1,1252 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midisyncimpl.cpp,v 1.1.1.1.2.4 2009/05/03 04:14:01 terminator356 Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QCloseEvent>
+#include <QInputDialog>
+#include <QMessageBox>
+#include <QStringList>
+#include <QTimer>
+#include <QTreeWidgetItem>
+
+#include "app.h"
+#include "song.h"
+#include "midiport.h"
+#include "midiseq.h"
+#include "mididev.h"
+#include "icons.h"
+#include "sync.h"
+#include "globals.h"
+#include "midisyncimpl.h"
+#include "driver/audiodev.h"
+#include "audio.h"
+
+enum { DEVCOL_NO = 0, DEVCOL_NAME, DEVCOL_IN, DEVCOL_TICKIN, DEVCOL_MRTIN, DEVCOL_MMCIN, DEVCOL_MTCIN, DEVCOL_MTCTYPE,
+ DEVCOL_RID, DEVCOL_RCLK, DEVCOL_RMRT, DEVCOL_RMMC, DEVCOL_RMTC, DEVCOL_RREWSTART,
+ DEVCOL_TID, DEVCOL_TCLK, DEVCOL_TMRT, DEVCOL_TMMC, DEVCOL_TMTC, /* DEVCOL_TREWSTART, */ };
+
+//MidiSyncInfo tmpMidiSyncPorts[MIDI_PORTS];
+
+//---------------------------------------------------------
+// MidiSyncConfig::setToolTips
+//---------------------------------------------------------
+
+void MidiSyncConfig::setToolTips(QTreeWidgetItem *item)
+{
+ item->setToolTip(DEVCOL_NO, tr("Port Number"));
+ item->setToolTip(DEVCOL_NAME, tr("Name of the midi device associated with"
+ " this port number"));
+ item->setToolTip(DEVCOL_IN, tr("Midi clock input detected"));
+ item->setToolTip(DEVCOL_TICKIN, tr("Midi tick input detected"));
+ item->setToolTip(DEVCOL_MRTIN, tr("Midi real time input detected"));
+ item->setToolTip(DEVCOL_MMCIN, tr("MMC input detected"));
+ item->setToolTip(DEVCOL_MTCIN, tr("MTC input detected"));
+ item->setToolTip(DEVCOL_MTCTYPE, tr("Detected SMPTE format"));
+ item->setToolTip(DEVCOL_RID, tr("Receive id number. 127 = Global. Double click to edit."));
+ item->setToolTip(DEVCOL_RCLK, tr("Accept midi clock input"));
+ item->setToolTip(DEVCOL_RMRT, tr("Accept midi real time input"));
+ item->setToolTip(DEVCOL_RMMC, tr("Accept MMC input"));
+ item->setToolTip(DEVCOL_RMTC, tr("Accept MTC input"));
+ item->setToolTip(DEVCOL_RREWSTART, tr("Receive start rewinds before playing"));
+ item->setToolTip(DEVCOL_TID, tr("Transmit id number. 127 = Global. Double click to edit."));
+ item->setToolTip(DEVCOL_TCLK, tr("Send midi clock output"));
+ item->setToolTip(DEVCOL_TMRT, tr("Send midi realtime output"));
+ item->setToolTip(DEVCOL_TMMC, tr("Send MMC output"));
+ item->setToolTip(DEVCOL_TMTC, tr("Send MTC output"));
+ //item->setToolTip(DEVCOL_TREWSTART, tr("Send continue instead of start"));
+}
+
+//---------------------------------------------------------
+// MidiSyncConfig::setWhatsThis
+//---------------------------------------------------------
+
+void MidiSyncConfig::setWhatsThis(QTreeWidgetItem *item)
+{
+ item->setWhatsThis(DEVCOL_NO, tr("Port Number"));
+ item->setWhatsThis(DEVCOL_NAME, tr("Name of the midi device associated with this port number"));
+ item->setWhatsThis(DEVCOL_IN, tr("Midi clock input detected.\n"
+ "Current port actually used is red.\nClick to force a port to be used."));
+ item->setWhatsThis(DEVCOL_TICKIN, tr("Midi tick input detected"));
+ item->setWhatsThis(DEVCOL_MRTIN, tr("Midi realtime input detected, including\n start/stop/continue, and song position."));
+ item->setWhatsThis(DEVCOL_MMCIN, tr("MMC input detected, including stop/play/deferred play, and locate."));
+ //"Current port actually used is red. Click to force a port to be current."));
+ item->setWhatsThis(DEVCOL_MTCIN, tr("MTC input detected, including forward quarter-frame sync and full-frame locate.\n"
+ "Current port actually used is red. Click to force a port to be current."));
+ item->setWhatsThis(DEVCOL_MTCTYPE, tr("Detected SMPTE format: 24fps, 25fps, 30fps drop frame, or 30fps non-drop\n"
+ "Detects format of MTC quarter and full frame, and MMC locate."));
+ item->setWhatsThis(DEVCOL_RID, tr("Receive id number. 127 = global receive all, even if not global."));
+ item->setWhatsThis(DEVCOL_RCLK, tr("Accept midi clock input. Only one input is used for clock.\n"
+ "Auto-acquire: If two or more port realtime inputs are enabled,\n"
+ " the first clock detected is used, until clock is lost,\n"
+ " then another can take over. Best if each turns off its clock\n"
+ " at stop, so MusE can re-acquire the clock from another port.\n"
+ "Click on detect indicator to force another."));
+ item->setWhatsThis(DEVCOL_RMRT, tr("Accept midi realtime input, including\n start/stop/continue, and song position.\n"
+ "Non-clock events (start,stop etc) are\n accepted by ALL enabled ports.\n"
+ "This means you may have several master\n devices connected, and muse will accept\n"
+ " input from them."));
+ item->setWhatsThis(DEVCOL_RMMC, tr("Accept MMC input, including stop/play/deferred play, and locate."));
+ item->setWhatsThis(DEVCOL_RMTC, tr("Accept MTC input, including forward quarter-frame sync and full-frame locate.\n"
+ "See 'rc' column for more help."));
+ item->setWhatsThis(DEVCOL_RREWSTART, tr("When start is received, rewind before playing.\n"
+ "Note: It may be impossible to rewind fast\n"
+ " enough to synchronize with the external device."));
+ item->setWhatsThis(DEVCOL_TID, tr("Transmit id number. 127 = global transmit to all."));
+ item->setWhatsThis(DEVCOL_TCLK, tr("Send midi clock output. If 'Slave to External Sync' is chosen,\n"
+ " muse can re-transmit clock to any other chosen ports."));
+ item->setWhatsThis(DEVCOL_TMRT, tr("Send midi realtime output, including start/stop/continue,\n"
+ " and song position. If 'Slave to external sync' is chosen,\n"
+ " muse can re-transmit midi realtime input messages to any\n"
+ " other chosen ports. This means you may have several slave\n"
+ " devices connected, and muse can re-send realtime messages\n"
+ " to any or all of them."));
+ item->setWhatsThis(DEVCOL_TMMC, tr("Send MMC output"));
+ item->setWhatsThis(DEVCOL_TMTC, tr("Send MTC output"));
+ // item->setWhatsThis(DEVCOL_TREWSTART, tr("When transport is starting, send continue instead of start.\n"));
+}
+
+//---------------------------------------------------------
+// MidiSyncConfig::addDevice
+//---------------------------------------------------------
+
+void MidiSyncConfig::addDevice(QTreeWidgetItem *item, QTreeWidget *tree)
+{
+ setWhatsThis(item);
+ tree->addTopLevelItem(item);
+}
+
+/*
+//---------------------------------------------------------
+// MidiSyncLViewItem
+// setDevice
+//---------------------------------------------------------
+
+void MidiSyncLViewItem::setDevice(MidiDevice* d)
+{
+ _device = d;
+ if(_device)
+ _syncInfo.copyParams(_device->syncInfo());
+}
+*/
+
+//---------------------------------------------------------
+// MidiSyncLViewItem
+// setPort
+//---------------------------------------------------------
+
+void MidiSyncLViewItem::setPort(int port)
+{
+ _port = port;
+ if(_port < 0 || port > MIDI_PORTS)
+ return;
+
+ //_syncInfo.copyParams(midiPorts[port].syncInfo());
+ copyFromSyncInfo(midiPorts[port].syncInfo());
+}
+
+//---------------------------------------------------------
+// MidiSyncLViewItem
+// copyFromSyncInfo
+//---------------------------------------------------------
+
+void MidiSyncLViewItem::copyFromSyncInfo(const MidiSyncInfo &sp)
+{
+ _idOut = sp.idOut();
+ _idIn = sp.idIn();
+ _sendMC = sp.MCOut();
+ _sendMRT = sp.MRTOut();
+ _sendMMC = sp.MMCOut();
+ _sendMTC = sp.MTCOut();
+ _recMC = sp.MCIn();
+ _recMRT = sp.MRTIn();
+ _recMMC = sp.MMCIn();
+ _recMTC = sp.MTCIn();
+ _recRewOnStart = sp.recRewOnStart();
+ //_sendContNotStart = sp.sendContNotStart();
+}
+
+//---------------------------------------------------------
+// MidiSyncLViewItem
+// copyToSyncInfo
+//---------------------------------------------------------
+
+void MidiSyncLViewItem::copyToSyncInfo(MidiSyncInfo &sp)
+{
+ sp.setIdOut(_idOut);
+ sp.setIdIn(_idIn);
+ sp.setMCOut(_sendMC);
+ sp.setMRTOut(_sendMRT);
+ sp.setMMCOut(_sendMMC);
+ sp.setMTCOut(_sendMTC);
+ sp.setMCIn(_recMC);
+ sp.setMRTIn(_recMRT);
+ sp.setMMCIn(_recMMC);
+ sp.setMTCIn(_recMTC);
+ sp.setRecRewOnStart(_recRewOnStart);
+ //sp.setSendContNotStart(_sendContNotStart);
+}
+
+//---------------------------------------------------------
+// MidiSyncConfig
+// Midi Sync Config
+//---------------------------------------------------------
+
+MidiSyncConfig::MidiSyncConfig(QWidget* parent)
+ : QDialog(parent)
+{
+ setupUi(this);
+
+ _dirty = false;
+ applyButton->setEnabled(false);
+
+ //inHeartBeat = true;
+
+ //for(int i = 0; i < MIDI_PORTS; ++i)
+ // tmpMidiSyncPorts[i] = midiSyncPorts[i];
+
+ //bool ext = extSyncFlag.value();
+ //syncMode->setButton(int(ext));
+ //syncChanged(ext);
+// extSyncCheckbox->setChecked(extSyncFlag.value());
+
+// dstDevId->setValue(txDeviceId);
+// srcDevId->setValue(rxDeviceId);
+// srcSyncPort->setValue(rxSyncPort + 1);
+// dstSyncPort->setValue(txSyncPort + 1);
+
+// mtcSync->setChecked(genMTCSync);
+// mcSync->setChecked(genMCSync);
+// midiMachineControl->setChecked(genMMC);
+
+// acceptMTCCheckbox->setChecked(acceptMTC);
+ //acceptMTCCheckbox->setChecked(false);
+// acceptMCCheckbox->setChecked(acceptMC);
+// acceptMMCCheckbox->setChecked(acceptMMC);
+
+// mtcSyncType->setCurrentItem(mtcType);
+
+// mtcOffH->setValue(mtcOffset.h());
+// mtcOffM->setValue(mtcOffset.m());
+// mtcOffS->setValue(mtcOffset.s());
+// mtcOffF->setValue(mtcOffset.f());
+// mtcOffSf->setValue(mtcOffset.sf());
+
+
+
+
+ devicesListView->setAllColumnsShowFocus(true);
+ QStringList columnnames;
+ columnnames << tr("Port")
+ << tr("Device Name")
+ << tr("c")
+ << tr("k")
+ << tr("r")
+ << tr("m")
+ << tr("t")
+ << tr("type")
+ << tr("rid") // Receive
+ << tr("rc") // Receive
+ << tr("rr") // Receive
+ << tr("rm") // Receive
+ << tr("rt") // Receive
+ << tr("rw") // Receive
+ << tr("tid") // Transmit
+ << tr("tc") // Transmit
+ << tr("tr") // Transmit
+ << tr("tm") // Transmit
+ << tr("tt"); // Transmit
+
+ devicesListView->setColumnCount(columnnames.size());
+ devicesListView->setHeaderLabels(columnnames);
+ setWhatsThis(devicesListView->headerItem());
+ setToolTips(devicesListView->headerItem());
+ devicesListView->setFocusPolicy(Qt::NoFocus);
+
+ //MSyncHeaderTip::add(devicesListView->header(), QString("Midi sync ports"));
+
+// updateSyncInfoLV();
+
+ songChanged(-1);
+
+ //connect(devicesListView, SIGNAL(pressed(QListViewItem*,const QPoint&,int)),
+ // this, SLOT(dlvClicked(QListViewItem*,const QPoint&,int)));
+ connect(devicesListView, SIGNAL(itemClicked(QTreeWidgetItem*, int)),
+ this, SLOT(dlvClicked(QTreeWidgetItem*, int)));
+ connect(devicesListView, SIGNAL(itemDoubleClicked(QTreeWidgetItem*, int)),
+ this, SLOT(dlvDoubleClicked(QTreeWidgetItem*, int)));
+ //connect(devicesListView, SIGNAL(itemRenamed(QListViewItem*, int, const QString&)),
+ // this, SLOT(renameOk(QListViewItem*, int, const QString&)));
+
+ connect(okButton, SIGNAL(clicked()), SLOT(ok()));
+ connect(applyButton, SIGNAL(clicked()), SLOT(apply()));
+ connect(cancelButton, SIGNAL(clicked()), SLOT(cancel()));
+
+ //connect(syncMode, SIGNAL(clicked(int)), SLOT(syncChanged(int)));
+ connect(extSyncCheckbox, SIGNAL(clicked()), SLOT(syncChanged()));
+ connect(mtcSyncType, SIGNAL(activated(int)), SLOT(syncChanged()));
+ connect(useJackTransportCheckbox, SIGNAL(clicked()), SLOT(syncChanged()));
+ connect(jackTransportMasterCheckbox, SIGNAL(clicked()), SLOT(syncChanged()));
+ connect(&extSyncFlag, SIGNAL(valueChanged(bool)), SLOT(extSyncChanged(bool)));
+ connect(syncDelaySpinBox, SIGNAL(valueChanged(int)), SLOT(syncChanged()));
+
+ // Done in show().
+ //connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+ //connect(heartBeatTimer, SIGNAL(timeout()), SLOT(heartBeat()));
+
+ //inHeartBeat = false;
+}
+
+MidiSyncConfig::~MidiSyncConfig()
+{
+}
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void MidiSyncConfig::songChanged(int flags)
+{
+ // Is it simply a midi controller value adjustment? Forget it. Otherwise, it's mainly midi port/device changes we want.
+ if(flags == SC_MIDI_CONTROLLER ||
+ !(flags & (SC_CONFIG | SC_MASTER | SC_TEMPO | SC_SIG | SC_TRACK_INSERTED | SC_TRACK_REMOVED | SC_TRACK_MODIFIED |
+ SC_PART_INSERTED | SC_PART_REMOVED | SC_PART_MODIFIED | SC_EVENT_INSERTED | SC_EVENT_REMOVED | SC_EVENT_MODIFIED |
+ SC_MIDI_CONTROLLER_ADD)))
+ return;
+
+ // Reset dirty flag, since we're loading new values.
+ _dirty = false;
+ if(applyButton->isEnabled())
+ applyButton->setEnabled(false);
+
+ //for(int i = 0; i < MIDI_PORTS; ++i)
+ // tmpMidiSyncPorts[i] = midiSyncPorts[i];
+
+ extSyncCheckbox->blockSignals(true);
+ useJackTransportCheckbox->blockSignals(true);
+ jackTransportMasterCheckbox->blockSignals(true);
+ syncDelaySpinBox->blockSignals(true);
+ extSyncCheckbox->setChecked(extSyncFlag.value());
+ useJackTransportCheckbox->setChecked(useJackTransport.value());
+ jackTransportMasterCheckbox->setChecked(jackTransportMaster);
+ //jackTransportMasterCheckbox->setEnabled(useJackTransport);
+ syncDelaySpinBox->setValue(syncSendFirstClockDelay);
+ syncDelaySpinBox->blockSignals(false);
+ jackTransportMasterCheckbox->blockSignals(false);
+ useJackTransportCheckbox->blockSignals(false);
+ extSyncCheckbox->blockSignals(false);
+
+ mtcSyncType->setCurrentIndex(mtcType);
+
+ mtcOffH->blockSignals(true);
+ mtcOffM->blockSignals(true);
+ mtcOffS->blockSignals(true);
+ mtcOffF->blockSignals(true);
+ mtcOffSf->blockSignals(true);
+ mtcOffH->setValue(mtcOffset.h());
+ mtcOffM->setValue(mtcOffset.m());
+ mtcOffS->setValue(mtcOffset.s());
+ mtcOffF->setValue(mtcOffset.f());
+ mtcOffSf->setValue(mtcOffset.sf());
+ mtcOffH->blockSignals(false);
+ mtcOffM->blockSignals(false);
+ mtcOffS->blockSignals(false);
+ mtcOffF->blockSignals(false);
+ mtcOffSf->blockSignals(false);
+
+ updateSyncInfoLV();
+
+ //selectionChanged();
+}
+
+//---------------------------------------------------------
+// heartBeat
+//---------------------------------------------------------
+
+void MidiSyncConfig::heartBeat()
+{
+ //inHeartBeat = true;
+ for (int i = MIDI_PORTS-1; i >= 0; --i)
+ {
+ MidiSyncLViewItem* lvi = (MidiSyncLViewItem*)devicesListView->topLevelItem(i);
+ int port = lvi->port();
+ if(port >= 0 && port < MIDI_PORTS)
+ {
+ bool sdet = midiPorts[port].syncInfo().MCSyncDetect();
+ if(sdet)
+ {
+ if(port == curMidiSyncInPort)
+ {
+ if(!lvi->_curDet)
+ {
+ // Added by Tim. p3.3.6
+ //printf("MidiSyncConfig::heartBeat setting current red icon\n");
+
+ lvi->_curDet = true;
+ lvi->_inDet = false;
+ lvi->setIcon(DEVCOL_IN, QIcon( *record1_Icon));
+ }
+ }
+ else
+ if(!lvi->_inDet)
+ {
+ // Added by Tim. p3.3.6
+ //printf("MidiSyncConfig::heartBeat setting non-current green icon\n");
+
+ lvi->_inDet = true;
+ lvi->_curDet = false;
+ lvi->setIcon(DEVCOL_IN, QIcon( *dotIcon));
+ }
+ }
+ else
+ {
+ if(lvi->_curDet || lvi->_inDet)
+ {
+ // Added by Tim. p3.3.6
+ //printf("MidiSyncConfig::heartBeat setting off icon\n");
+
+ lvi->_curDet = false;
+ lvi->_inDet = false;
+ lvi->setIcon(DEVCOL_IN, QIcon( *dothIcon));
+ }
+ }
+
+ sdet = midiPorts[port].syncInfo().tickDetect();
+ if(sdet)
+ {
+ if(!lvi->_tickDet)
+ {
+ // Added by Tim. p3.3.6
+ //printf("MidiSyncConfig::heartBeat setting tick on icon\n");
+
+ lvi->_tickDet = true;
+ lvi->setIcon(DEVCOL_TICKIN, QIcon( *dotIcon));
+ }
+ }
+ else
+ {
+ if(lvi->_tickDet)
+ {
+ // Added by Tim. p3.3.6
+ //printf("MidiSyncConfig::heartBeat setting tick off icon\n");
+
+ lvi->_tickDet = false;
+ lvi->setIcon(DEVCOL_TICKIN, QIcon( *dothIcon));
+ }
+ }
+
+ sdet = midiPorts[port].syncInfo().MRTDetect();
+ if(sdet)
+ {
+ if(!lvi->_MRTDet)
+ {
+ // Added by Tim. p3.3.6
+ //printf("MidiSyncConfig::heartBeat setting MRT on icon\n");
+
+ lvi->_MRTDet = true;
+ lvi->setIcon(DEVCOL_MRTIN, QIcon( *dotIcon));
+ }
+ }
+ else
+ {
+ if(lvi->_MRTDet)
+ {
+ // Added by Tim. p3.3.6
+ //printf("MidiSyncConfig::heartBeat setting MRT off icon\n");
+
+ lvi->_MRTDet = false;
+ lvi->setIcon(DEVCOL_MRTIN, QIcon( *dothIcon));
+ }
+ }
+
+ int type = midiPorts[port].syncInfo().recMTCtype();
+ sdet = midiPorts[port].syncInfo().MMCDetect();
+ bool mtcdet = midiPorts[port].syncInfo().MTCDetect();
+ if(sdet)
+ {
+ if(!lvi->_MMCDet)
+ {
+ // Added by Tim. p3.3.6
+ //printf("MidiSyncConfig::heartBeat setting MMC on icon\n");
+
+ lvi->_MMCDet = true;
+ lvi->setIcon(DEVCOL_MMCIN, QIcon( *dotIcon));
+ }
+ // MMC locate command can contain SMPTE format type. Update now.
+ if(!mtcdet && lvi->_recMTCtype != type)
+ {
+ lvi->_recMTCtype = type;
+ switch(type)
+ {
+ case 0:
+ lvi->setText(DEVCOL_MTCTYPE, "24");
+ break;
+ case 1:
+ lvi->setText(DEVCOL_MTCTYPE, "25");
+ break;
+ case 2:
+ lvi->setText(DEVCOL_MTCTYPE, "30D");
+ break;
+ case 3:
+ lvi->setText(DEVCOL_MTCTYPE, "30N");
+ break;
+ default:
+ lvi->setText(DEVCOL_MTCTYPE, "??");
+ break;
+ }
+ }
+ }
+ else
+ {
+ if(lvi->_MMCDet)
+ {
+ // Added by Tim. p3.3.6
+ //printf("MidiSyncConfig::heartBeat setting MMC off icon\n");
+
+ lvi->_MMCDet = false;
+ lvi->setIcon(DEVCOL_MMCIN, QIcon( *dothIcon));
+ }
+ }
+
+ if(mtcdet)
+ {
+ if(port == curMidiSyncInPort)
+ {
+ if(!lvi->_curMTCDet)
+ {
+ // Added by Tim. p3.3.6
+ //printf("MidiSyncConfig::heartBeat setting current red icon\n");
+
+ lvi->_curMTCDet = true;
+ lvi->_MTCDet = false;
+ lvi->setIcon(DEVCOL_MTCIN, QIcon( *record1_Icon));
+ }
+ }
+ else
+ if(!lvi->_MTCDet)
+ {
+ // Added by Tim. p3.3.6
+ //printf("MidiSyncConfig::heartBeat setting MTC on icon\n");
+
+ lvi->_MTCDet = true;
+ lvi->_curMTCDet = false;
+ lvi->setIcon(DEVCOL_MTCIN, QIcon( *dotIcon));
+ }
+
+ if(lvi->_recMTCtype != type)
+ {
+ lvi->_recMTCtype = type;
+ switch(type)
+ {
+ case 0:
+ lvi->setText(DEVCOL_MTCTYPE, "24");
+ break;
+ case 1:
+ lvi->setText(DEVCOL_MTCTYPE, "25");
+ break;
+ case 2:
+ lvi->setText(DEVCOL_MTCTYPE, "30D");
+ break;
+ case 3:
+ lvi->setText(DEVCOL_MTCTYPE, "30N");
+ break;
+ default:
+ lvi->setText(DEVCOL_MTCTYPE, "??");
+ break;
+ }
+ }
+ }
+ else
+ {
+ if(lvi->_curMTCDet || lvi->_MTCDet)
+ {
+ // Added by Tim. p3.3.6
+ //printf("MidiSyncConfig::heartBeat setting MTC off icon\n");
+
+ lvi->_MTCDet = false;
+ lvi->_curMTCDet = false;
+ lvi->setIcon(DEVCOL_MTCIN, QIcon( *dothIcon));
+ }
+ }
+ }
+
+ //MidiDevice* dev = lvi->device();
+ //bool sdet = dev->syncInfo().MCSyncDetect();
+ //if(lvi->pixmap(DEVCOL_IN) != (sdet ? *dotIcon : *dothIcon))
+ // lvi->setIcon(DEVCOL_IN, QIcon( sdet ? *dotIcon : *dothIcon));
+
+ }
+
+ //inHeartBeat = false;
+}
+
+//---------------------------------------------------------
+// syncChanged
+// val = 1 - Master Mode
+// 0 - Slave Mode
+//---------------------------------------------------------
+
+void MidiSyncConfig::syncChanged()
+ {
+ setDirty();
+
+ //jackTransportMasterCheckbox->setEnabled(useJackTransport);
+
+ //acceptMTCCheckbox->setEnabled(val);
+// acceptMTCCheckbox->setEnabled(false);
+// acceptMCCheckbox->setEnabled(val);
+// acceptMMCCheckbox->setEnabled(val);
+ }
+
+//---------------------------------------------------------
+// extSyncChanged
+//---------------------------------------------------------
+
+void MidiSyncConfig::extSyncChanged(bool v)
+ {
+ extSyncCheckbox->blockSignals(true);
+ extSyncCheckbox->setChecked(v);
+// if(v)
+// song->setMasterFlag(false);
+ extSyncCheckbox->blockSignals(false);
+ }
+
+//---------------------------------------------------------
+// ok Pressed
+//---------------------------------------------------------
+
+void MidiSyncConfig::ok()
+ {
+ apply();
+ cancel();
+ }
+
+//---------------------------------------------------------
+// cancel Pressed
+//---------------------------------------------------------
+
+void MidiSyncConfig::cancel()
+ {
+ _dirty = false;
+ if(applyButton->isEnabled())
+ applyButton->setEnabled(false);
+
+ close();
+ }
+
+//---------------------------------------------------------
+// show
+//---------------------------------------------------------
+
+void MidiSyncConfig::show()
+{
+ songChanged(-1);
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+ connect(heartBeatTimer, SIGNAL(timeout()), SLOT(heartBeat()));
+ QDialog::show();
+}
+
+//---------------------------------------------------------
+// closeEvent
+//---------------------------------------------------------
+
+void MidiSyncConfig::closeEvent(QCloseEvent* e)
+ {
+ if(_dirty)
+ {
+ int n = QMessageBox::warning(this, tr("MusE"),
+ tr("Settings have changed\n"
+ "Apply sync settings?"),
+ tr("&Apply"), tr("&No"), tr("&Abort"), 0, 2);
+
+ if(n == 2)
+ {
+ e->ignore();
+ return;
+ }
+
+ if(n == 0)
+ apply();
+ }
+
+ //emit deleted((unsigned long)this);
+
+ disconnect(heartBeatTimer, SIGNAL(timeout()), this, SLOT(heartBeat()));
+ disconnect(song, SIGNAL(songChanged(int)), this, SLOT(songChanged(int)));
+
+ e->accept();
+ }
+
+//---------------------------------------------------------
+// apply Pressed
+//---------------------------------------------------------
+
+void MidiSyncConfig::apply()
+{
+// txDeviceId = dstDevId->value();
+// rxDeviceId = srcDevId->value();
+// rxSyncPort = srcSyncPort->value() - 1;
+// txSyncPort = dstSyncPort->value() - 1;
+
+// genMTCSync = mtcSync->isChecked();
+// genMCSync = mcSync->isChecked();
+// genMMC = midiMachineControl->isChecked();
+
+ syncSendFirstClockDelay = syncDelaySpinBox->value();
+
+ mtcType = mtcSyncType->currentIndex();
+ //extSyncFlag.setValue(syncMode->id(syncMode->selected()));
+ //extSyncFlag.blockSignals(true);
+ extSyncFlag.setValue(extSyncCheckbox->isChecked());
+// if(extSyncFlag.value())
+// song->setMasterFlag(false);
+ //extSyncFlag.blockSignals(false);
+ useJackTransport.setValue(useJackTransportCheckbox->isChecked());
+// if(useJackTransport)
+ jackTransportMaster = jackTransportMasterCheckbox->isChecked();
+// else
+// jackTransportMaster = false;
+// jackTransportMasterCheckbox->setEnabled(useJackTransport);
+ if(audioDevice)
+ audioDevice->setMaster(jackTransportMaster);
+
+ mtcOffset.setH(mtcOffH->value());
+ mtcOffset.setM(mtcOffM->value());
+ mtcOffset.setS(mtcOffS->value());
+ mtcOffset.setF(mtcOffF->value());
+ mtcOffset.setSf(mtcOffSf->value());
+
+// acceptMC = acceptMCCheckbox->isChecked();
+// acceptMMC = acceptMMCCheckbox->isChecked();
+// acceptMTC = acceptMTCCheckbox->isChecked();
+
+
+ //MidiSyncLViewItem* lvi = (MidiSyncLViewItem*)devicesListView->firstChild();
+ //while(lvi)
+ for (int i = MIDI_PORTS-1; i >= 0; --i)
+ {
+ MidiSyncLViewItem* lvi = (MidiSyncLViewItem*)devicesListView->topLevelItem(i);
+ //MidiDevice* dev = lvi->device();
+ // Does the device really exist?
+ //if(midiDevices.find(dev) != midiDevices.end())
+ // dev->syncInfo().copyParams(lvi->syncInfo());
+ int port = lvi->port();
+ if(port >= 0 && port < MIDI_PORTS)
+ //midiPorts[port].syncInfo().copyParams(lvi->syncInfo());
+ lvi->copyToSyncInfo(midiPorts[port].syncInfo());
+
+ }
+
+ //muse->changeConfig(true); // save settings
+
+ _dirty = false;
+ if(applyButton->isEnabled())
+ applyButton->setEnabled(false);
+
+ // Do not call this. Causes freeze sometimes. Only will be needed if extra pollfds are used by midi seq thread.
+ //midiSeq->msgUpdatePollFd();
+}
+
+//---------------------------------------------------------
+// updateSyncInfoLV
+//---------------------------------------------------------
+
+void MidiSyncConfig::updateSyncInfoLV()
+ {
+ devicesListView->clear();
+ for(int i = 0; i < MIDI_PORTS; ++i)
+ {
+ MidiPort* port = &midiPorts[i];
+ MidiDevice* dev = port->device();
+ // p3.3.31
+ // Don't show if it is a synthesizer device.
+ // Hmm, some synths might support transport commands or even sync?
+ // If anything, the DSSI or VST synths just might...
+ // TODO: Must test to see if it screws any of them up, especially clock out.
+ // Also, if we do this, we must prevent such messages from reaching
+ // those ports at several other places in the code.
+ //if(dev && dev->isSynti())
+ // continue;
+
+ QString s;
+ s.setNum(i+1);
+ MidiSyncLViewItem* lvi = new MidiSyncLViewItem(devicesListView);
+ lvi->setPort(i); // setPort will copy parameters.
+ //MidiSyncInfo& si = lvi->syncInfo();
+ //si.copyParams(port->syncInfo());
+ //lvi.copyFromSyncInfo(port->syncInfo());
+ MidiSyncInfo& portsi = port->syncInfo();
+
+ lvi->setText(DEVCOL_NO, s);
+
+ if (dev)
+ lvi->setText(DEVCOL_NAME, dev->name());
+ else
+ lvi->setText(DEVCOL_NAME, tr("<none>"));
+
+ if(portsi.MCSyncDetect())
+ {
+ if(i == curMidiSyncInPort)
+ {
+ lvi->_curDet = true;
+ lvi->_inDet = false;
+ lvi->setIcon(DEVCOL_IN, QIcon( *record1_Icon));
+ }
+ else
+ {
+ lvi->_curDet = false;
+ lvi->_inDet = true;
+ lvi->setIcon(DEVCOL_IN, QIcon( *dotIcon));
+ }
+ }
+ else
+ {
+ lvi->_curDet = false;
+ lvi->_inDet = false;
+ lvi->setIcon(DEVCOL_IN, QIcon( *dothIcon));
+ }
+
+ if(portsi.tickDetect())
+ {
+ lvi->_tickDet = true;
+ lvi->setIcon(DEVCOL_TICKIN, QIcon( *dotIcon));
+ }
+ else
+ {
+ lvi->_tickDet = false;
+ lvi->setIcon(DEVCOL_TICKIN, QIcon( *dothIcon));
+ }
+
+ if(portsi.MRTDetect())
+ {
+ lvi->_MRTDet = true;
+ lvi->setIcon(DEVCOL_MRTIN, QIcon( *dotIcon));
+ }
+ else
+ {
+ lvi->_MRTDet = false;
+ lvi->setIcon(DEVCOL_MRTIN, QIcon( *dothIcon));
+ }
+
+ if(portsi.MMCDetect())
+ {
+ lvi->_MMCDet = true;
+ lvi->setIcon(DEVCOL_MMCIN, QIcon( *dotIcon));
+ // MMC locate command can have SMPTE format bits...
+ if(lvi->_recMTCtype != portsi.recMTCtype())
+ {
+ switch(portsi.recMTCtype())
+ {
+ case 0:
+ lvi->setText(DEVCOL_MTCTYPE, "24");
+ break;
+ case 1:
+ lvi->setText(DEVCOL_MTCTYPE, "25");
+ break;
+ case 2:
+ lvi->setText(DEVCOL_MTCTYPE, "30D");
+ break;
+ case 3:
+ lvi->setText(DEVCOL_MTCTYPE, "30N");
+ break;
+ default:
+ lvi->setText(DEVCOL_MTCTYPE, "??");
+ break;
+ }
+ }
+ }
+ else
+ {
+ lvi->_MMCDet = false;
+ lvi->setIcon(DEVCOL_MMCIN, QIcon( *dothIcon));
+ }
+
+ if(portsi.MTCDetect())
+ {
+ if(i == curMidiSyncInPort)
+ {
+ lvi->_curMTCDet = true;
+ lvi->_MTCDet = false;
+ lvi->setIcon(DEVCOL_MTCIN, QIcon( *record1_Icon));
+ }
+ else
+ {
+ lvi->_curMTCDet = false;
+ lvi->_MTCDet = true;
+ lvi->setIcon(DEVCOL_MTCIN, QIcon( *dotIcon));
+ }
+
+ if(lvi->_recMTCtype != portsi.recMTCtype())
+ {
+ switch(portsi.recMTCtype())
+ {
+ case 0:
+ lvi->setText(DEVCOL_MTCTYPE, "24");
+ break;
+ case 1:
+ lvi->setText(DEVCOL_MTCTYPE, "25");
+ break;
+ case 2:
+ lvi->setText(DEVCOL_MTCTYPE, "30D");
+ break;
+ case 3:
+ lvi->setText(DEVCOL_MTCTYPE, "30N");
+ break;
+ default:
+ lvi->setText(DEVCOL_MTCTYPE, "??");
+ break;
+ }
+ }
+ }
+ else
+ {
+ lvi->_curMTCDet = false;
+ lvi->_MTCDet = false;
+ lvi->setIcon(DEVCOL_MTCIN, QIcon( *dothIcon));
+ //lvi->setText(DEVCOL_MTCTYPE, "--");
+ }
+
+ //lvi->setText(DEVCOL_RID, QString().setNum(si.idIn()) );
+ //lvi->setRenameEnabled(DEVCOL_RID, true);
+ //lvi->setIcon(DEVCOL_RCLK, QIcon( si.MCIn() ? *dotIcon : *dothIcon));
+ //lvi->setIcon(DEVCOL_RMMC, QIcon( si.MMCIn() ? *dotIcon : *dothIcon));
+ //lvi->setIcon(DEVCOL_RMTC, QIcon( si.MTCIn() ? *dotIcon : *dothIcon));
+ lvi->setText(DEVCOL_RID, QString().setNum(lvi->_idIn) );
+ lvi->setIcon(DEVCOL_RCLK, QIcon( lvi->_recMC ? *dotIcon : *dothIcon));
+ lvi->setIcon(DEVCOL_RMRT, QIcon( lvi->_recMRT ? *dotIcon : *dothIcon));
+ lvi->setIcon(DEVCOL_RMMC, QIcon( lvi->_recMMC ? *dotIcon : *dothIcon));
+ lvi->setIcon(DEVCOL_RMTC, QIcon( lvi->_recMTC ? *dotIcon : *dothIcon));
+ lvi->setIcon(DEVCOL_RREWSTART, QIcon( lvi->_recRewOnStart ? *dotIcon : *dothIcon));
+
+ //lvi->setText(DEVCOL_TID, QString().setNum(si.idOut()) );
+ //lvi->setRenameEnabled(DEVCOL_TID, true);
+ //lvi->setIcon(DEVCOL_TCLK, QIcon( si.MCOut() ? *dotIcon : *dothIcon));
+ //lvi->setIcon(DEVCOL_TMMC, QIcon( si.MMCOut() ? *dotIcon : *dothIcon));
+ //lvi->setIcon(DEVCOL_TMTC, QIcon( si.MTCOut() ? *dotIcon : *dothIcon));
+ lvi->setText(DEVCOL_TID, QString().setNum(lvi->_idOut) );
+ lvi->setIcon(DEVCOL_TCLK, QIcon(lvi->_sendMC ? *dotIcon : *dothIcon));
+ lvi->setIcon(DEVCOL_TMRT, QIcon(lvi->_sendMRT ? *dotIcon : *dothIcon));
+ lvi->setIcon(DEVCOL_TMMC, QIcon(lvi->_sendMMC ? *dotIcon : *dothIcon));
+ lvi->setIcon(DEVCOL_TMTC, QIcon(lvi->_sendMTC ? *dotIcon : *dothIcon));
+ //lvi->setIcon(DEVCOL_TREWSTART, QIcon( lvi->_sendContNotStart ? *dotIcon : *dothIcon));
+
+ addDevice(lvi, devicesListView);
+ }
+ devicesListView->resizeColumnToContents(DEVCOL_NO);
+ //devicesListView->resizeColumnToContents(DEVCOL_NAME);
+ devicesListView->header()->resizeSection(DEVCOL_NAME, 120);
+ devicesListView->resizeColumnToContents(DEVCOL_IN);
+ devicesListView->resizeColumnToContents(DEVCOL_TICKIN);
+ devicesListView->resizeColumnToContents(DEVCOL_MRTIN);
+ devicesListView->resizeColumnToContents(DEVCOL_MMCIN);
+ devicesListView->resizeColumnToContents(DEVCOL_MTCIN);
+ devicesListView->resizeColumnToContents(DEVCOL_MTCTYPE);
+ devicesListView->resizeColumnToContents(DEVCOL_RID);
+ devicesListView->resizeColumnToContents(DEVCOL_RCLK);
+ devicesListView->resizeColumnToContents(DEVCOL_RMRT);
+ devicesListView->resizeColumnToContents(DEVCOL_RMMC);
+ devicesListView->resizeColumnToContents(DEVCOL_RMTC);
+ devicesListView->resizeColumnToContents(DEVCOL_RREWSTART);
+ devicesListView->resizeColumnToContents(DEVCOL_TID);
+ devicesListView->resizeColumnToContents(DEVCOL_TCLK);
+ devicesListView->resizeColumnToContents(DEVCOL_TMRT);
+ devicesListView->resizeColumnToContents(DEVCOL_TMMC);
+ devicesListView->resizeColumnToContents(DEVCOL_TMTC);
+
+ devicesListView->header()->setResizeMode(DEVCOL_NO, QHeaderView::Fixed);
+ devicesListView->header()->setResizeMode(DEVCOL_IN, QHeaderView::Fixed);
+ devicesListView->header()->setResizeMode(DEVCOL_TICKIN, QHeaderView::Fixed);
+ devicesListView->header()->setResizeMode(DEVCOL_MRTIN, QHeaderView::Fixed);
+ devicesListView->header()->setResizeMode(DEVCOL_MMCIN, QHeaderView::Fixed);
+ devicesListView->header()->setResizeMode(DEVCOL_MTCIN, QHeaderView::Fixed);
+ devicesListView->header()->setResizeMode(DEVCOL_RCLK, QHeaderView::Fixed);
+ devicesListView->header()->setResizeMode(DEVCOL_RMRT, QHeaderView::Fixed);
+ devicesListView->header()->setResizeMode(DEVCOL_RMMC, QHeaderView::Fixed);
+ devicesListView->header()->setResizeMode(DEVCOL_RMTC, QHeaderView::Fixed);
+ devicesListView->header()->setResizeMode(DEVCOL_RMTC, QHeaderView::Fixed);
+ devicesListView->header()->setResizeMode(DEVCOL_RREWSTART, QHeaderView::Fixed);
+ devicesListView->header()->setResizeMode(DEVCOL_TCLK, QHeaderView::Fixed);
+ devicesListView->header()->setResizeMode(DEVCOL_TMRT, QHeaderView::Fixed);
+ devicesListView->header()->setResizeMode(DEVCOL_TMMC, QHeaderView::Fixed);
+
+
+ /*
+ for(iMidiDevice id = midiDevices.begin(); id != midiDevices.end(); ++id)
+ {
+ MidiDevice* dev = *id;
+
+ //MidiPort* port = &midiPorts[i];
+ //MidiDevice* dev = port->device();
+ MidiSyncLViewItem* lvi = new MidiSyncLViewItem(devicesListView);
+ //lvi->setPort(i);
+ // setDevice will copy parameters.
+ lvi->setDevice(dev);
+ MidiSyncInfo& si = lvi->syncInfo();
+ //si.copyParams(dev->syncInfo());
+
+ lvi->setText(DEVCOL_NAME, dev->name());
+
+ lvi->setIcon(DEVCOL_IN, QIcon( si.MCSyncDetect() ? *dotIcon : *dothIcon));
+
+ lvi->setText(DEVCOL_RID, QString().setNum(si.idIn()) );
+ lvi->setIcon(DEVCOL_RCLK, QIcon( si.MCIn() ? *dotIcon : *dothIcon));
+ lvi->setIcon(DEVCOL_RMMC, QIcon( si.MMCIn() ? *dotIcon : *dothIcon));
+ lvi->setIcon(DEVCOL_RMTC, QIcon( si.MTCIn() ? *dotIcon : *dothIcon));
+
+ lvi->setText(DEVCOL_TID, QString().setNum(si.idOut()) );
+ lvi->setIcon(DEVCOL_TCLK, QIcon( si.MCOut() ? *dotIcon : *dothIcon));
+ lvi->setIcon(DEVCOL_TMMC, QIcon( si.MMCOut() ? *dotIcon : *dothIcon));
+ lvi->setIcon(DEVCOL_TMTC, QIcon( si.MTCOut() ? *dotIcon : *dothIcon));
+
+ devicesListView->insertItem(lvi);
+ }
+ */
+ }
+
+
+//---------------------------------------------------------
+// dlvClicked
+//---------------------------------------------------------
+
+//void MidiSyncConfig::dlvClicked(QListViewItem* item, const QPoint&, int col)
+void MidiSyncConfig::dlvClicked(QTreeWidgetItem* item, int col)
+{
+ if (item == 0)
+ return;
+
+ MidiSyncLViewItem* lvi = (MidiSyncLViewItem*)item;
+ int no = lvi->port();
+ if (no < 0 || no >= MIDI_PORTS)
+ return;
+ //MidiDevice* dev = lvi->device();
+ // Does the device really exist?
+ //if(midiDevices.find(dev) == midiDevices.end())
+ // return;
+
+ //int n;
+ //MidiPort* port = &midiPorts[no];
+ //MidiDevice* dev = port->device();
+ //int rwFlags = dev ? dev->rwFlags() : 0;
+ //int openFlags = dev ? dev->openFlags() : 0;
+ //MidiSyncInfo& si = lvi->syncInfo();
+ //MidiSyncInfo& portsi = midiPorts[no].syncInfo();
+
+ switch (col)
+ {
+ case DEVCOL_NO:
+ break;
+ case DEVCOL_NAME:
+ break;
+ case DEVCOL_IN:
+ // If this is not the current midi sync in port, and sync in from this port is enabled,
+ // and sync is in fact detected on this port, allow the user to force this port to now be the
+ // current sync in port.
+ //if(no != curMidiSyncInPort && si.MCIn() && midiPorts[no].syncInfo().MCSyncDetect())
+ //if(no != curMidiSyncInPort && lvi->_recMC && midiPorts[no].syncInfo().MCSyncDetect())
+ if(no != curMidiSyncInPort)
+ {
+ if(lvi->_recMC && midiPorts[no].syncInfo().MCSyncDetect())
+ {
+ curMidiSyncInPort = no;
+ lvi->setIcon(DEVCOL_IN, QIcon( *record1_Icon));
+ }
+ if(lvi->_recMTC && midiPorts[no].syncInfo().MTCDetect())
+ {
+ curMidiSyncInPort = no;
+ lvi->setIcon(DEVCOL_MTCIN, QIcon( *record1_Icon));
+ }
+ }
+ break;
+ case DEVCOL_TICKIN:
+ break;
+ case DEVCOL_MMCIN:
+ break;
+ case DEVCOL_MTCIN:
+ // If this is not the current midi sync in port, and sync in from this port is enabled,
+ // and sync is in fact detected on this port, allow the user to force this port to now be the
+ // current sync in port.
+ //if(no != curMidiSyncInPort && si.MTCIn() && midiPorts[no].syncInfo().MTCDetect())
+ //if(no != curMidiSyncInPort && lvi->_recMTC && midiPorts[no].syncInfo().MTCDetect())
+ if(no != curMidiSyncInPort)
+ {
+ if(lvi->_recMTC && midiPorts[no].syncInfo().MTCDetect())
+ {
+ curMidiSyncInPort = no;
+ lvi->setIcon(DEVCOL_MTCIN, QIcon( *record1_Icon));
+ }
+ if(lvi->_recMC && midiPorts[no].syncInfo().MCSyncDetect())
+ {
+ curMidiSyncInPort = no;
+ lvi->setIcon(DEVCOL_IN, QIcon( *record1_Icon));
+ }
+ }
+ break;
+ case DEVCOL_MTCTYPE:
+ break;
+ case DEVCOL_RID:
+ break;
+ case DEVCOL_RCLK:
+ //si.setMCIn(si.MCIn() ? false : true);
+ //lvi->setIcon(DEVCOL_RCLK, QIcon( si.MCIn() ? *dotIcon : *dothIcon));
+ lvi->_recMC = (lvi->_recMC ? false : true);
+ lvi->setIcon(DEVCOL_RCLK, QIcon( lvi->_recMC ? *dotIcon : *dothIcon));
+ setDirty();
+ break;
+ case DEVCOL_RMRT:
+ lvi->_recMRT = (lvi->_recMRT ? false : true);
+ lvi->setIcon(DEVCOL_RMRT, QIcon( lvi->_recMRT ? *dotIcon : *dothIcon));
+ setDirty();
+ break;
+ case DEVCOL_RMMC:
+ //si.setMMCIn(si.MMCIn() ? false : true);
+ //lvi->setIcon(DEVCOL_RMMC, QIcon( si.MMCIn() ? *dotIcon : *dothIcon));
+ lvi->_recMMC = (lvi->_recMMC ? false : true);
+ lvi->setIcon(DEVCOL_RMMC, QIcon( lvi->_recMMC ? *dotIcon : *dothIcon));
+ setDirty();
+ break;
+ case DEVCOL_RMTC:
+ //si.setMTCIn(si.MTCIn() ? false : true);
+ //lvi->setIcon(DEVCOL_RMTC, QIcon( si.MTCIn() ? *dotIcon : *dothIcon));
+ lvi->_recMTC = (lvi->_recMTC ? false : true);
+ lvi->setIcon(DEVCOL_RMTC, QIcon( lvi->_recMTC ? *dotIcon : *dothIcon));
+ setDirty();
+ break;
+ case DEVCOL_RREWSTART:
+ lvi->_recRewOnStart = (lvi->_recRewOnStart ? false : true);
+ lvi->setIcon(DEVCOL_RREWSTART, QIcon( lvi->_recRewOnStart ? *dotIcon : *dothIcon));
+ setDirty();
+ break;
+ case DEVCOL_TID:
+ break;
+ case DEVCOL_TCLK:
+ //si.setMCOut(si.MCOut() ? false : true);
+ //lvi->setIcon(DEVCOL_TCLK, QIcon( si.MCOut() ? *dotIcon : *dothIcon));
+ lvi->_sendMC = (lvi->_sendMC ? false : true);
+ lvi->setIcon(DEVCOL_TCLK, QIcon( lvi->_sendMC ? *dotIcon : *dothIcon));
+ setDirty();
+ break;
+ case DEVCOL_TMRT:
+ lvi->_sendMRT = (lvi->_sendMRT ? false : true);
+ lvi->setIcon(DEVCOL_TMRT, QIcon( lvi->_sendMRT ? *dotIcon : *dothIcon));
+ setDirty();
+ break;
+ case DEVCOL_TMMC:
+ //si.setMMCOut(si.MMCOut() ? false : true);
+ //lvi->setIcon(DEVCOL_TMMC, QIcon( si.MMCOut() ? *dotIcon : *dothIcon));
+ lvi->_sendMMC = (lvi->_sendMMC ? false : true);
+ lvi->setIcon(DEVCOL_TMMC, QIcon( lvi->_sendMMC ? *dotIcon : *dothIcon));
+ setDirty();
+ break;
+ case DEVCOL_TMTC:
+ //si.setMTCOut(si.MTCOut() ? false : true);
+ //lvi->setIcon(DEVCOL_TMTC, QIcon( si.MTCOut() ? *dotIcon : *dothIcon));
+ lvi->_sendMTC = (lvi->_sendMTC ? false : true);
+ lvi->setIcon(DEVCOL_TMTC, QIcon( lvi->_sendMTC ? *dotIcon : *dothIcon));
+ setDirty();
+ break;
+ //case DEVCOL_TREWSTART:
+ // lvi->_sendContNotStart = (lvi->_sendContNotStart ? false : true);
+ // lvi->setIcon(DEVCOL_TREWSTART, QIcon( lvi->_sendContNotStart ? *dotIcon : *dothIcon));
+ // setDirty();
+ // break;
+ }
+ //songChanged(-1);
+}
+
+//---------------------------------------------------------
+// dlvDoubleClicked
+//---------------------------------------------------------
+
+void MidiSyncConfig::dlvDoubleClicked(QTreeWidgetItem* item, int col)
+{
+ if(!item)
+ return;
+
+ MidiSyncLViewItem* lvi = (MidiSyncLViewItem*)item;
+
+ //if(col == DEVCOL_RID)
+ // lvi->startRename(DEVCOL_RID);
+ //else
+ //if(col == DEVCOL_TID)
+ // lvi->startRename(DEVCOL_TID);
+
+ bool ok = false;
+ if(col == DEVCOL_RID)
+ {
+ //int val = lvi->syncInfo().idIn();
+ int val = lvi->_idIn;
+ int newval = QInputDialog::getInteger(this, "Muse: Sync info" , "Enter new id number (127 = all):", val, 0, 127, 1, &ok);
+ if(ok)
+ {
+ //lvi->syncInfo().setIdIn(newval);
+ lvi->_idIn = newval;
+ lvi->setText(DEVCOL_RID, QString().setNum(newval));
+ }
+ }
+ else
+ if(col == DEVCOL_TID)
+ {
+ //int val = lvi->syncInfo().idOut();
+ int val = lvi->_idOut;
+ int newval = QInputDialog::getInteger(this, "Muse: Sync info" , "Enter new id number (127 = global):", val, 0, 127, 1, &ok);
+ if(ok)
+ {
+ //lvi->syncInfo().setIdOut(newval);
+ lvi->_idOut = newval;
+ lvi->setText(DEVCOL_TID, QString().setNum(newval));
+ }
+ }
+
+ if(ok)
+ setDirty();
+}
+
+/*
+//---------------------------------------------------------
+// renameOk
+//---------------------------------------------------------
+//void MidiSyncConfig::renameOk(QListViewItem* item, int col)
+void MidiSyncConfig::renameOk(QListViewItem* item, int col, const QString & text)
+{
+ if(!item)
+ return;
+
+ MidiSyncLViewItem* lvi = (MidiSyncLViewItem*)item;
+ QString t = text;
+ bool ok;
+ int id = text.toInt(&ok);
+ if(!ok)
+ {
+ lvi->setText(t);
+ return;
+ }
+ if(col == DEVCOL_RID)
+ {
+ //lvi->syncInfo().setIdIn(id);
+ lvi->_idIn = id;
+ setDirty();
+ }
+ else
+ if(col == DEVCOL_TID)
+ {
+ //lvi->syncInfo().setIdOut(id);
+ lvi->_idOut = id;
+ setDirty();
+ }
+}
+*/
+
+//---------------------------------------------------------
+// MidiSyncConfig::setDirty
+//---------------------------------------------------------
+
+void MidiSyncConfig::setDirty()
+{
+ _dirty = true;
+ if(!applyButton->isEnabled())
+ applyButton->setEnabled(true);
+}
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/midisyncimpl.h b/attic/muse2-oom/muse2/muse/widgets/midisyncimpl.h
new file mode 100644
index 00000000..3eb33451
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/midisyncimpl.h
@@ -0,0 +1,119 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: midisyncimpl.h,v 1.1.1.1.2.3 2009/05/03 04:14:01 terminator356 Exp $
+//
+// (C) Copyright 1999/2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MIDISYNCIMPL_H__
+#define __MIDISYNCIMPL_H__
+
+#include "ui_midisync.h"
+#include "sync.h"
+
+class QCloseEvent;
+class QDialog;
+class QTreeWidgetItem;
+
+//----------------------------------------------------------
+// MidiSyncLViewItem
+//----------------------------------------------------------
+
+class MidiSyncLViewItem : public QTreeWidgetItem
+{
+ //MidiSyncInfo _syncInfo;
+ //MidiDevice* _device;
+ int _port;
+
+ //protected:
+ //int _port;
+
+ public:
+ MidiSyncLViewItem(QTreeWidget* parent)
+ : QTreeWidgetItem(parent) { _port = -1; _inDet = _curDet = _tickDet = false; }
+ //: QListViewItem(parent) { _device = 0; }
+
+ //MidiSyncLViewItem(QListView* parent, QListViewItem* after)
+ // : QListViewItem(parent, after) { _port = -1; }
+
+ //virtual QString text(int column) const;
+ //virtual unsigned tick() = 0;
+
+ //int _port;
+ bool _inDet;
+ bool _curDet;
+ bool _curMTCDet;
+ bool _tickDet;
+ bool _MRTDet;
+ bool _MMCDet;
+ bool _MTCDet;
+ int _recMTCtype;
+
+ int _idOut;
+ int _idIn;
+
+ bool _sendMC;
+ bool _sendMRT;
+ bool _sendMMC;
+ bool _sendMTC;
+ bool _recMC;
+ bool _recMRT;
+ bool _recMMC;
+ bool _recMTC;
+
+ bool _recRewOnStart;
+ //bool _sendContNotStart;
+
+ int port() const { return _port; }
+ void setPort(int port);
+ //MidiDevice* device() const { return _device; }
+ //void setDevice(MidiDevice* d);
+
+ //MidiSyncInfo& syncInfo() { return _syncInfo; }
+ void copyFromSyncInfo(const MidiSyncInfo &sp);
+ void copyToSyncInfo(MidiSyncInfo &sp);
+};
+
+//---------------------------------------------------------
+// MSConfig
+//---------------------------------------------------------
+
+class MidiSyncConfig : public QDialog, public Ui::MidiSyncConfigBase {
+ Q_OBJECT
+
+ bool inHeartBeat;
+ bool _dirty;
+
+ void updateSyncInfoLV();
+ void closeEvent(QCloseEvent*);
+ void setToolTips(QTreeWidgetItem *item);
+ void setWhatsThis(QTreeWidgetItem *item);
+ void addDevice(QTreeWidgetItem *item, QTreeWidget *tree);
+
+ private slots:
+ void heartBeat();
+ void syncChanged();
+ void extSyncChanged(bool v);
+ void ok();
+ void cancel();
+ void apply();
+ //void dlvClicked(QListViewItem*, const QPoint&, int);
+ void dlvClicked(QTreeWidgetItem*, int);
+ void dlvDoubleClicked(QTreeWidgetItem*, int);
+ //void renameOk(QListViewItem*, int, const QString&);
+ void songChanged(int);
+
+ //signals:
+ // void deleted(unsigned long);
+
+ public:
+ MidiSyncConfig(QWidget* parent=0);
+ //MidiSyncConfig();
+ ~MidiSyncConfig();
+ void show();
+ void setDirty();
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/mittransposebase.ui b/attic/muse2-oom/muse2/muse/widgets/mittransposebase.ui
new file mode 100644
index 00000000..b29e34ed
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/mittransposebase.ui
@@ -0,0 +1,114 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MITTransposeBase</class>
+ <widget class="QWidget" name="MITTransposeBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>423</width>
+ <height>50</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Midi Input Plugin: Transpose</string>
+ </property>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QCheckBox" name="onCheckBox">
+ <property name="text">
+ <string>On</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="TextLabel1">
+ <property name="text">
+ <string>TriggerKey</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="indent">
+ <number>5</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="PitchEdit" name="triggerKeySpinBox" native="true"/>
+ </item>
+ <item>
+ <widget class="QLabel" name="TextLabel2">
+ <property name="text">
+ <string>Transpose:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="indent">
+ <number>5</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="transposeLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::Panel</enum>
+ </property>
+ <property name="lineWidth">
+ <number>2</number>
+ </property>
+ <property name="midLineWidth">
+ <number>2</number>
+ </property>
+ <property name="text">
+ <string>+0</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="margin">
+ <number>2</number>
+ </property>
+ <property name="indent">
+ <number>5</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <customwidgets>
+ <customwidget>
+ <class>PitchEdit</class>
+ <extends>QWidget</extends>
+ <header>pitchedit.h</header>
+ </customwidget>
+ </customwidgets>
+ <includes>
+ <include location="local">pitchedit.h</include>
+ </includes>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/mixdowndialog.cpp b/attic/muse2-oom/muse2/muse/widgets/mixdowndialog.cpp
new file mode 100644
index 00000000..8ab26859
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/mixdowndialog.cpp
@@ -0,0 +1,105 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mixdowndialog.cpp,v 1.1.1.1 2003/10/27 18:55:02 wschweer Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QFileDialog>
+
+#include "globals.h"
+#include "mixdowndialog.h"
+#include "wave.h"
+
+//---------------------------------------------------------
+// sndFileOpen
+// sf - old soundfile, used to preset file parameters
+//---------------------------------------------------------
+
+SndFile* getSndFile(const SndFile* sf, QWidget* parent)
+ {
+ MixdownFileDialog* dialog = new MixdownFileDialog(sf, parent);
+ dialog->exec();
+ SndFile* sndFile = dialog->sndFile();
+ delete dialog;
+ return sndFile;
+ }
+
+//---------------------------------------------------------
+// MixdownFileDialog
+//---------------------------------------------------------
+
+MixdownFileDialog::MixdownFileDialog(const SndFile* _sf,
+ QWidget* parent, Qt::WFlags fl)
+ : QDialog(parent, fl)
+ {
+ setupUi(this);
+ sf = 0;
+ connect(buttonPath, SIGNAL(clicked()), SLOT(fdialog()));
+ if (_sf) {
+ int channels = _sf->channels();
+ int format = _sf->format();
+ switch(channels) {
+ case 1: channels = 1; break;
+ case 2: channels = 0; break;
+ case 6: channels = 2; break;
+ }
+ editPath->setText(_sf->path());
+ comboChannel->setCurrentIndex(channels);
+ comboFormat->setCurrentIndex(format);
+ }
+ }
+
+//---------------------------------------------------------
+// accept
+//---------------------------------------------------------
+
+void MixdownFileDialog::accept()
+ {
+ QString oldpath;
+ unsigned channel = comboChannel->currentIndex();
+ unsigned format = comboFormat->currentIndex();
+ switch (channel) {
+ case 0: channel = 2; break;
+ case 1: channel = 1; break;
+ case 2: channel = 6; break; // not implemented!
+ }
+ switch (format) {
+ case 0: // 16 bit wave
+ format = SF_FORMAT_WAV | SF_FORMAT_PCM_16;
+ break;
+ case 1: // 24 bit wave
+ format = SF_FORMAT_WAV | SF_FORMAT_PCM_24;
+ break;
+ case 2: // 32 bit float wave
+ format = SF_FORMAT_WAV | SF_FORMAT_FLOAT;
+ break;
+ }
+ QString path = editPath->text();
+ if (path.isEmpty()) {
+ sf = 0;
+ reject();
+ return;
+ }
+ if (path.right(4) != ".wav")
+ path += ".wav";
+ sf = new SndFile(path);
+ sf->setFormat(format, channel, sampleRate);
+ done(1);
+ }
+
+//---------------------------------------------------------
+// fdialog
+//---------------------------------------------------------
+
+void MixdownFileDialog::fdialog()
+ {
+ QString oldpath;
+ if (sf)
+ oldpath = sf->path();
+ QString path = QFileDialog::getSaveFileName(
+ this, 0, oldpath, tr("Wave Files (*.wav);;All Files (*)"));
+ if (!path.isEmpty())
+ editPath->setText(path);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/mixdowndialog.h b/attic/muse2-oom/muse2/muse/widgets/mixdowndialog.h
new file mode 100644
index 00000000..750acd28
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/mixdowndialog.h
@@ -0,0 +1,38 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mixdowndialog.h,v 1.1.1.1 2003/10/27 18:54:28 wschweer Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MIXDOWNDIALOG_H__
+#define __MIXDOWNDIALOG_H__
+
+#include "ui_mixdowndialogbase.h"
+
+class QWidget;
+
+class SndFile;
+
+extern SndFile* getSndFile(const SndFile* sf, QWidget* parent);
+
+//---------------------------------------------------------
+// MixdownFileDialog
+//---------------------------------------------------------
+
+class MixdownFileDialog : public QDialog, public Ui::MixdownFileDialogBase {
+ Q_OBJECT
+ SndFile* sf;
+
+ private slots:
+ void fdialog();
+ virtual void accept();
+
+ public:
+ MixdownFileDialog(const SndFile* f, QWidget* parent = 0,
+ Qt::WFlags fl = 0);
+ SndFile* sndFile() { return sf; }
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/mixdowndialogbase.ui b/attic/muse2-oom/muse2/muse/widgets/mixdowndialogbase.ui
new file mode 100644
index 00000000..486518fb
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/mixdowndialogbase.ui
@@ -0,0 +1,217 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MixdownFileDialogBase</class>
+ <widget class="QDialog" name="MixdownFileDialogBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>381</width>
+ <height>116</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Set Mixdown Wavefile</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="2" column="0" colspan="5">
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <spacer name="Horizontal Spacing2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonOk">
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonCancel">
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="TextLabel1">
+ <property name="text">
+ <string>File Path</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="TextLabel2">
+ <property name="text">
+ <string>Channel</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="4">
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLineEdit" name="editPath"/>
+ </item>
+ <item>
+ <widget class="QToolButton" name="buttonPath">
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="comboChannel">
+ <item>
+ <property name="text">
+ <string>Stereo</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Mono</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>5.1</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="4">
+ <widget class="QComboBox" name="comboFormat">
+ <item>
+ <property name="text">
+ <string>wav,16 Bit</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>wav, 24 Bit</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>wav, 32 Bit (float)</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QLabel" name="TextLabel3">
+ <property name="text">
+ <string>Format</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <spacer name="Spacer1">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>MixdownFileDialogBase</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>MixdownFileDialogBase</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/mktest b/attic/muse2-oom/muse2/muse/widgets/mktest
new file mode 100644
index 00000000..08738898
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/mktest
@@ -0,0 +1,5 @@
+CPPFLAGS = -I/usr/qt/include -I..
+
+mops: mops.o musewidgetsplug.o
+ g++ -o mops mops.o musewidgetsplug.o -L . -l musewidgetsplugin -L /usr/qt/lib -l qt-mt
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/mlabel.cpp b/attic/muse2-oom/muse2/muse/widgets/mlabel.cpp
new file mode 100644
index 00000000..2b9526d4
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/mlabel.cpp
@@ -0,0 +1,15 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mlabel.cpp,v 1.1.1.1 2003/10/27 18:55:03 wschweer Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "mlabel.h"
+
+
+void MLabel::mousePressEvent(QMouseEvent*)
+ {
+ emit mousePressed();
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/mlabel.h b/attic/muse2-oom/muse2/muse/widgets/mlabel.h
new file mode 100644
index 00000000..01bfa788
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/mlabel.h
@@ -0,0 +1,37 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mlabel.h,v 1.1.1.1 2003/10/27 18:55:03 wschweer Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MLABEL_H__
+#define __MLABEL_H__
+
+#include <QLabel>
+
+//---------------------------------------------------------
+// MLabel
+// label widged which sends signal mousePressed
+// on mousePressEvent
+//---------------------------------------------------------
+
+class MLabel : public QLabel {
+
+ Q_OBJECT
+
+ protected:
+ virtual void mousePressEvent(QMouseEvent*);
+
+ signals:
+ void mousePressed();
+
+ public:
+ MLabel(const QString& txt, QWidget* parent, const char* name = 0)
+ : QLabel(txt, parent) {setObjectName(name);};
+
+ MLabel(QWidget* parent, const char* name = 0)
+ : QLabel(parent) {setObjectName(name);};
+ };
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/mmath.cpp b/attic/muse2-oom/muse2/muse/widgets/mmath.cpp
new file mode 100644
index 00000000..acc8e25a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/mmath.cpp
@@ -0,0 +1,300 @@
+#include <cmath>
+#include "mmath.h"
+
+// QwtMath - a set of mathematical routines
+//
+// qwtGetMin -- Find the smallest value in an array
+// qwtGetMax -- Find the largest value in an array
+// qwtTwistArray -- invert the order of an array
+// qwtFloor125 -- Find the largest value fitting in a 1-2-5 pattern
+// qwtCeil125 -- Find the smallest value fitting in a 1-2-5 pattern
+// qwtChkMono -- Check for monotony
+// qwtLinSpace -- construct an array of equally spaced values
+// qwtLogSpace -- construct an array of logarithmically equally spaced values
+// qwtMax -- Return the largest of two values
+// qwtMin -- Return the smallest of two values
+// qwtAbs -- return the absolute value
+// qwtSign -- Return the sign of a number
+// qwtSqr -- Return the square of a number
+// qwtCopyArray -- Copy an array into another
+// qwtShiftArray -- Shift an array
+// qwtSwap -- Swap two values
+// qwtSort (1) -- Sort two values
+// qwtSort (2) -- Sort two values
+// qwtInt -- Return nearest integer
+// qwtLim -- Limit a values
+
+
+//------------------------------------------------------------
+//.F qwtGetMin
+// Find the smallest value in an array
+//
+//.u Syntax
+//.f double qwtGetMin(double *array, int size)
+//
+//.u Parameters
+//.p double *array, int size
+//
+//------------------------------------------------------------
+
+double qwtGetMin(double *array, int size)
+{
+ double rv;
+ int i;
+
+ if (size > 0)
+ {
+ rv = array[0];
+ for (i=1; i< size; i++)
+ rv = qwtMin(rv, array[i]);
+ return rv;
+ }
+ else
+ return 0.0;
+
+}
+
+
+//------------------------------------------------------------
+//
+//.F qwtGetMax
+// Find the largest value in an array
+//
+//.u Syntax
+//.f double qwtGetMax(double *array, int size)
+//
+//.u Parameters
+//.p double *array, int size
+//
+//------------------------------------------------------------
+double qwtGetMax(double *array, int size)
+{
+ double rv;
+ int i;
+
+ if (size > 0)
+ {
+ rv = array[0];
+ for (i=1; i< size; i++)
+ rv = qwtMax(rv, array[i]);
+ return rv;
+ }
+ else
+ return 0.0;
+
+}
+
+
+//------------------------------------------------------------
+//
+//.F qwtCeil125
+// Find the smallest value out of {1,2,5}*10^n with an integer number n
+// which is greater than or equal to x
+//
+//.u Syntax
+//.f double qwtCeil125(double x)
+//
+//.u Parameters
+//.p double x
+//
+//------------------------------------------------------------
+double qwtCeil125( double x)
+{
+ double lx, rv;
+ double p10, fr;
+ double sign = ( x > 0) ? 1.0 : -1.0;
+
+ if (x == 0.0) return 0.0;
+
+ lx = log10(fabs(x));
+ p10 = floor(lx);
+ fr = pow(10.0,lx - p10);
+ if (fr <=1.0)
+ fr = 1.0;
+ else if (fr <= 2.0)
+ fr = 2.0;
+ else if (fr <= 5.0)
+ fr = 5.0;
+ else
+ fr = 10.0;
+ rv = fr * pow(10.0,p10);
+ return sign * rv;
+}
+
+
+//------------------------------------------------------------
+//
+//.F qwtFloor125
+// Find the largest value out of {1,2,5}*10^n with an integer number n
+// which is smaller than or equal to x
+//
+//.u Syntax
+//.f double qwtFloor125(double x)
+//
+//.u Parameters
+//.p double x
+//
+//------------------------------------------------------------
+double qwtFloor125( double x)
+{
+ double lx, rv;
+ double p10, fr;
+ double sign = ( x > 0) ? 1.0 : -1.0;
+
+ if (x == 0.0) return 0.0;
+
+ lx = log10(fabs(x));
+ p10 = floor(lx);
+ fr = pow(10.0,lx - p10);
+ if (fr >= 10.0)
+ fr = 10.0;
+ else if (fr >= 5.0)
+ fr = 5.0;
+ else if (fr >= 2.0)
+ fr = 2.0;
+ else
+ fr = 1.0;
+ rv = fr * pow(10.0,p10);
+ return sign * rv;
+}
+
+
+//------------------------------------------------------------
+//
+//.F qwtChkMono
+// Checks if an array is a strictly monotonic sequence
+//
+//.u Syntax
+//.f int qwtChkMono(double *array, int size)
+//
+//.u Parameters
+//.p double *array -- pointer to a double array
+// int size -- size of the array
+//
+//.u Return Value
+//.t 0 -- sequence is not strictly monotonic
+// 1 -- sequence is strictly monotonically increasing
+// -1 -- sequence is strictly monotonically decreasing
+//
+//------------------------------------------------------------
+int qwtChkMono(double *array, int size)
+{
+ int rv, i;
+
+ if (size < 2) return 0;
+
+ rv = qwtSign(array[1] - array[0]);
+ for (i=1;i<size-1;i++)
+ {
+ if ( qwtSign(array[i+1] - array[i]) != rv )
+ {
+ rv = 0;
+ break;
+ }
+ }
+ return rv;
+
+}
+
+//------------------------------------------------------------
+//
+//.F qwtTwistArray
+// Invert the order of array elements
+//
+//.u Syntax
+//.f void qwtTwistArray(double *array, int size)
+//
+//.u Parameters
+//.p double *array, int size
+//
+//------------------------------------------------------------
+void qwtTwistArray(double *array, int size)
+{
+ int itmp;
+ int i, s2;
+ double dtmp;
+
+ s2 = size / 2;
+
+ for (i=0; i < s2; i++)
+ {
+ itmp = size - 1 - i;
+ dtmp = array[i];
+ array[i] = array[itmp];
+ array[itmp] = dtmp;
+ }
+
+}
+
+
+//------------------------------------------------------------
+//
+//.F qwtLinSpace
+// Create an array of equally spaced values
+//
+//.u Syntax
+//.f void qwtLinSpace(double *array, int size, double xmin, double xmax)
+//
+//.u Parameters
+//.p double *array -- where to put the values
+// int size -- size of the array
+// double xmin -- value associated with index 0
+// double xmax -- value associated with index (size-1)
+//
+//------------------------------------------------------------
+void qwtLinSpace(double *array, int size, double xmin, double xmax)
+{
+ int i, imax;
+ imax = size -1;
+ double step;
+
+ if (size > 0)
+ {
+ array[0] = xmin;
+ array[imax] = xmax;
+ step = (xmax - xmin) / double(imax);
+
+ for (i=1;i<imax;i++)
+ array[i] = xmin + double(i) * step;
+ }
+
+}
+
+
+//------------------------------------------------------------
+//
+//.F qwtLogSpace
+// Create an array of logarithmically equally spaced values
+//
+//.u Syntax
+//.f void qwtLogSpace(double *array, int size, double xmin, double xmax)
+//
+//.u Parameters
+//.p double *array -- where to put the values
+// int size -- size of the array
+// double xmin -- value associated with index 0
+// double xmax -- value associated with index (size-1)
+//------------------------------------------------------------
+void qwtLogSpace(double *array, int size, double xmin, double xmax)
+{
+ int i, imax;
+
+ double lxmin,lxmax;
+ double lstep;
+
+ imax = size -1;
+
+ if ((xmin <= 0.0) || (xmax <= 0.0) || (size <= 0))
+ return;
+
+ array[0] = xmin;
+ array[imax] = xmax;
+ lxmin = log(xmin);
+ lxmax = log(xmax);
+
+ lstep = (lxmax - lxmin) / double(imax);
+
+ for (i=1; i<imax;i++)
+ array[i] = exp(lxmin + double(i) * lstep);
+
+}
diff --git a/attic/muse2-oom/muse2/muse/widgets/mmath.h b/attic/muse2-oom/muse2/muse/widgets/mmath.h
new file mode 100644
index 00000000..51381047
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/mmath.h
@@ -0,0 +1,77 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mmath.h,v 1.1.1.1 2003/10/27 18:54:47 wschweer Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MATH_H__
+#define __MATH_H__
+
+#define LOG_MIN 1.0e-100
+#define LOG_MAX 1.0e100
+
+double qwtCeil125(double x);
+double qwtFloor125(double x);
+void qwtTwistArray(double *array, int size);
+int qwtChkMono(double *array, int size);
+void qwtLinSpace(double *array, int size, double xmin, double xmax);
+void qwtLogSpace(double *array, int size, double xmin, double xmax);
+
+template <class T>
+inline int qwtSign(const T& x)
+{
+ if (x > T(0))
+ return 1;
+ else if (x < T(0))
+ return (-1);
+ else
+ return 0;
+}
+
+inline int qwtInt(double x)
+{
+ return int(rint(x));
+}
+
+template <class T>
+inline T qwtAbs (const T& x)
+{
+ return( x > T(0) ? x : -x );
+}
+
+template <class T>
+inline const T& qwtMax (const T& x, const T& y)
+{
+ return ( x > y ? x : y );
+}
+
+template <class T>
+inline const T& qwtMin ( const T& x, const T& y)
+{
+ return ( x < y ? x : y );
+}
+
+
+template <class T>
+T qwtLim(const T& x, const T& x1, const T& x2)
+{
+ T rv;
+ T xmin, xmax;
+
+ xmin = qwtMin(x1, x2);
+ xmax = qwtMax(x1, x2);
+
+ if ( x < xmin )
+ rv = xmin;
+ else if ( x > xmax )
+ rv = xmax;
+ else
+ rv = x;
+
+ return rv;
+}
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/moc_ttoolbar.cpp b/attic/muse2-oom/muse2/muse/widgets/moc_ttoolbar.cpp
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/moc_ttoolbar.cpp
diff --git a/attic/muse2-oom/muse2/muse/widgets/mtrackinfo.cpp b/attic/muse2-oom/muse2/muse/widgets/mtrackinfo.cpp
new file mode 100644
index 00000000..38d02735
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/mtrackinfo.cpp
@@ -0,0 +1,1831 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// (C) Copyright 2010 Werner Schweer and others (ws@seh.de)
+//=========================================================
+
+#include <QTimer>
+#include <QMessageBox>
+#include <QStandardItemModel>
+#include <QStandardItem>
+
+#include <math.h>
+#include <string.h>
+
+#include "mtrackinfo.h"
+#include "song.h"
+#include "globals.h"
+#include "config.h"
+#include "gconfig.h"
+#include "midiport.h"
+#include "minstrument.h"
+#include "mididev.h"
+#include "utils.h"
+#include "audio.h"
+#include "midi.h"
+#include "midictrl.h"
+#include "icons.h"
+#include "app.h"
+#include "route.h"
+#include "popupmenu.h"
+#include "pctable.h"
+
+//---------------------------------------------------------
+// setTrack
+//---------------------------------------------------------
+
+void MidiTrackInfo::setTrack(Track* t)
+{
+ if(!t)
+ {
+ selected = 0;
+ return;
+ }
+
+ if(!t->isMidiTrack())
+ return;
+ selected = t;
+
+ QPalette pal;
+ if(selected->type() == Track::DRUM)
+ pal.setColor(trackNameLabel->backgroundRole(), config.drumTrackLabelBg);
+ else
+ pal.setColor(trackNameLabel->backgroundRole(), config.midiTrackLabelBg);
+ trackNameLabel->setPalette(pal);
+
+ updateTrackInfo(-1);
+}
+
+//---------------------------------------------------------
+// midiTrackInfo
+//---------------------------------------------------------
+
+MidiTrackInfo::MidiTrackInfo(QWidget* parent, Track* sel_track) : QFrame(parent)//QWidget(parent)
+{
+ setupUi(this);
+ _midiDetect = false;
+ _progRowNum = 0;
+ editing = false;
+ _matrix = new QList<int>;
+ _tableModel = new ProgramChangeTableModel(this);
+ tableView = new ProgramChangeTable(this);
+ tableView->setMinimumHeight(150);
+ tableView->horizontalHeader()->setStretchLastSection(true);//setResizeMode(1,QHeaderView::Stretch);
+ tableBox->addWidget(tableView);
+ selected = sel_track;
+
+ // Since program covers 3 controls at once, it is in 'midi controller' units rather than 'gui control' units.
+ //program = -1;
+ program = CTRL_VAL_UNKNOWN;
+ pan = -65;
+ volume = -1;
+
+ setFont(config.fonts[2]);
+
+ //iChanDetectLabel->setPixmap(*darkgreendotIcon);
+ iChanDetectLabel->setPixmap(*darkRedLedIcon);
+
+ QIcon recEchoIconSet;
+ recEchoIconSet.addPixmap(*midiThruOnIcon, QIcon::Normal, QIcon::On);
+ recEchoIconSet.addPixmap(*midiThruOffIcon, QIcon::Normal, QIcon::Off);
+ recEchoButton->setIcon(recEchoIconSet);
+ recEchoButton->setIconSize(midiThruOnIcon->size());
+
+ // MusE-2: AlignCenter and WordBreak are set in the ui(3) file, but not supported by QLabel. Turn them on here.
+ trackNameLabel->setAlignment(Qt::AlignCenter);
+ //Qt::TextWordWrap is not available for alignment in Qt4 - Orcan
+ // MusE-2 Tested: TextWrapAnywhere actually works, but in fact it takes precedence
+ // over word wrap, so I found it is not really desirable. Maybe with a user setting...
+ //trackNameLabel->setAlignment(Qt::AlignCenter | Qt::TextWordWrap | Qt::TextWrapAnywhere);
+ //trackNameLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum));
+
+ if(selected)
+ {
+ trackNameLabel->setObjectName(selected->cname());
+ QPalette pal;
+ //pal.setColor(trackNameLabel->backgroundRole(), QColor(0, 160, 255)); // Med blue
+ if(selected->type() == Track::DRUM)
+ pal.setColor(trackNameLabel->backgroundRole(), config.drumTrackLabelBg);
+ else
+ pal.setColor(trackNameLabel->backgroundRole(), config.midiTrackLabelBg);
+ trackNameLabel->setPalette(pal);
+ }
+ //else
+ //{
+ // pal.setColor(trackNameLabel->backgroundRole(), config.midiTrackLabelBg);
+ // trackNameLabel->setPalette(pal);
+ //}
+
+ //trackNameLabel->setStyleSheet(QString("background-color: ") + QColor(0, 160, 255).name()); // Med blue
+ trackNameLabel->setWordWrap(true);
+ trackNameLabel->setAutoFillBackground(true);
+ trackNameLabel->setTextFormat(Qt::PlainText);
+ trackNameLabel->setLineWidth(2);
+ trackNameLabel->setFrameStyle(QFrame::Sunken | QFrame::StyledPanel);
+ trackNameLabel->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum));
+
+ setLabelText();
+ setLabelFont();
+
+ QStandardItem* hid = new QStandardItem(tr("I"));
+ QStandardItem* hstat = new QStandardItem(true);
+ hstat->setCheckable(true);
+ hstat->setCheckState(Qt::Unchecked);
+ QStandardItem* hpatch = new QStandardItem(tr("Patch"));
+ _tableModel->setHorizontalHeaderItem(0, hid);
+ _tableModel->setHorizontalHeaderItem(1, hstat);
+ _tableModel->setHorizontalHeaderItem(2, hpatch);
+
+ tableView->setModel(_tableModel);
+ tableView->setColumnWidth(1, 20);
+ tableView->setColumnHidden(0, true);
+
+ btnUp->setIcon(*upPCIcon);
+ btnDown->setIcon(*downPCIcon);
+ btnDelete->setIcon(*garbagePCIcon);
+ btnUp->setIconSize(upPCIcon->size());
+ btnDown->setIconSize(downPCIcon->size());
+ btnDelete->setIconSize(garbagePCIcon->size());
+
+ connect(tableView, SIGNAL(rowOrderChanged()), SLOT(rebuildMatrix()));
+ connect(_tableModel, SIGNAL(itemChanged(QStandardItem*)), SLOT(matrixItemChanged(QStandardItem*)));
+ connect(chkAdvanced, SIGNAL(stateChanged(int)), SLOT(toggleAdvanced(int)));
+ connect(btnDelete, SIGNAL(clicked(bool)), SLOT(deleteSelectedPatches(bool)));
+ connect(btnUp, SIGNAL(clicked(bool)), SLOT(movePatchUp(bool)));
+ connect(btnDown, SIGNAL(clicked(bool)), SLOT(movePatchDown(bool)));
+
+ //setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding));
+
+ connect(iPatch, SIGNAL(released()), SLOT(instrPopup()));
+
+ ///pop = new QMenu(iPatch);
+ //pop->setCheckable(false); // not needed in Qt4
+
+ // Removed by Tim. p3.3.9
+ //connect(iName, SIGNAL(returnPressed()), SLOT(iNameChanged()));
+
+ connect(iOutputChannel, SIGNAL(valueChanged(int)), SLOT(iOutputChannelChanged(int)));
+ ///connect(iInputChannel, SIGNAL(textChanged(const QString&)), SLOT(iInputChannelChanged(const QString&)));
+ connect(iHBank, SIGNAL(valueChanged(int)), SLOT(iProgHBankChanged()));
+ connect(iLBank, SIGNAL(valueChanged(int)), SLOT(iProgLBankChanged()));
+ connect(iProgram, SIGNAL(valueChanged(int)), SLOT(iProgramChanged()));
+ connect(iHBank, SIGNAL(doubleClicked()), SLOT(iProgramDoubleClicked()));
+ connect(iLBank, SIGNAL(doubleClicked()), SLOT(iProgramDoubleClicked()));
+ connect(iProgram, SIGNAL(doubleClicked()), SLOT(iProgramDoubleClicked()));
+ connect(iLautst, SIGNAL(valueChanged(int)), SLOT(iLautstChanged(int)));
+ connect(iLautst, SIGNAL(doubleClicked()), SLOT(iLautstDoubleClicked()));
+ connect(iTransp, SIGNAL(valueChanged(int)), SLOT(iTranspChanged(int)));
+ connect(iAnschl, SIGNAL(valueChanged(int)), SLOT(iAnschlChanged(int)));
+ connect(iVerz, SIGNAL(valueChanged(int)), SLOT(iVerzChanged(int)));
+ connect(iLen, SIGNAL(valueChanged(int)), SLOT(iLenChanged(int)));
+ connect(iKompr, SIGNAL(valueChanged(int)), SLOT(iKomprChanged(int)));
+ connect(iPan, SIGNAL(valueChanged(int)), SLOT(iPanChanged(int)));
+ connect(iPan, SIGNAL(doubleClicked()), SLOT(iPanDoubleClicked()));
+ connect(iOutput, SIGNAL(activated(int)), SLOT(iOutputPortChanged(int)));
+ ///connect(iInput, SIGNAL(textChanged(const QString&)), SLOT(iInputPortChanged(const QString&)));
+ connect(recordButton, SIGNAL(clicked()), SLOT(recordClicked()));
+ connect(progRecButton, SIGNAL(clicked()), SLOT(progRecClicked()));
+ connect(volRecButton, SIGNAL(clicked()), SLOT(volRecClicked()));
+ connect(panRecButton, SIGNAL(clicked()), SLOT(panRecClicked()));
+ connect(recEchoButton, SIGNAL(toggled(bool)), SLOT(recEchoToggled(bool)));
+ connect(iRButton, SIGNAL(pressed()), SLOT(inRoutesPressed()));
+
+ // TODO: Works OK, but disabled for now, until we figure out what to do about multiple out routes and display values...
+ //oRButton->setEnabled(false);
+ //oRButton->setVisible(false);
+ //connect(oRButton, SIGNAL(pressed()), SLOT(outRoutesPressed()));
+
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+ connect(muse, SIGNAL(configChanged()), SLOT(configChanged()));
+
+ connect(heartBeatTimer, SIGNAL(timeout()), SLOT(heartBeat()));
+}
+
+//---------------------------------------------------------
+// heartBeat
+//---------------------------------------------------------
+
+void MidiTrackInfo::heartBeat()
+{
+ ///if(!showTrackinfoFlag || !selected)
+ if(!isVisible() || !isEnabled() || !selected)
+ return;
+ switch(selected->type())
+ {
+ case Track::MIDI:
+ case Track::DRUM:
+ {
+ MidiTrack* track = (MidiTrack*)selected;
+
+ int outChannel = track->outChannel();
+ int outPort = track->outPort();
+ ///int ichMask = track->inChannelMask();
+ //int iptMask = track->inPortMask();
+ ///unsigned int iptMask = track->inPortMask();
+
+ MidiPort* mp = &midiPorts[outPort];
+
+ // Set record echo.
+ //if(recEchoButton->isChecked() != track->recEcho())
+ //{
+ // recEchoButton->blockSignals(true);
+ // recEchoButton->setChecked(track->recEcho());
+ // recEchoButton->blockSignals(false);
+ //}
+
+ // Check for detection of midi general activity on chosen channels...
+ int mpt = 0;
+ //int mch = 0;
+ RouteList* rl = track->inRoutes();
+
+ ciRoute r = rl->begin();
+ //for( ; mpt < MIDI_PORTS; ++mpt)
+ for( ; r != rl->end(); ++r)
+ {
+ //if(!r->isValid() || ((r->type != Route::ALSA_MIDI_ROUTE) && (r->type != Route::JACK_MIDI_ROUTE)))
+ //if(!r->isValid() || (r->type != Route::MIDI_DEVICE_ROUTE))
+ if(!r->isValid() || (r->type != Route::MIDI_PORT_ROUTE)) // p3.3.49
+ continue;
+
+ // NOTE: TODO: Code for channelless events like sysex, ** IF we end up using the 'special channel 17' method.
+ //if(r->channel == -1)
+ if(r->channel == -1 || r->channel == 0) // p3.3.50
+ continue;
+
+ // No port assigned to the device?
+ //mpt = r->device->midiPort();
+ mpt = r->midiPort; // p3.3.49
+ if(mpt < 0 || mpt >= MIDI_PORTS)
+ continue;
+
+ //for(; mch < MIDI_CHANNELS; ++mch)
+ //{
+ //if(midiPorts[mpt].syncInfo().actDetect(mch) && (iptMask & (1 << mpt)) && (ichMask & (1 << mch)) )
+ //if((iptMask & bitShiftLU[mpt]) && (midiPorts[mpt].syncInfo().actDetectBits() & ichMask) )
+ //if(midiPorts[mpt].syncInfo().actDetectBits() & bitShiftLU[r->channel])
+ if(midiPorts[mpt].syncInfo().actDetectBits() & r->channel) // p3.3.50 Use new channel mask.
+ {
+ //if(iChanTextLabel->paletteBackgroundColor() != green)
+ // iChanTextLabel->setPaletteBackgroundColor(green);
+ //if(iChanDetectLabel->pixmap() != greendotIcon)
+ if(!_midiDetect)
+ {
+ //printf("Arranger::midiTrackInfoHeartBeat setting green icon\n");
+
+ _midiDetect = true;
+ //iChanDetectLabel->setPixmap(*greendotIcon);
+ iChanDetectLabel->setPixmap(*redLedIcon);
+ }
+ break;
+ }
+ //}
+ }
+ // No activity detected?
+ //if(mch == MIDI_CHANNELS)
+ //if(mpt == MIDI_PORTS)
+ if(r == rl->end())
+ {
+ //if(iChanTextLabel->paletteBackgroundColor() != darkGreen)
+ // iChanTextLabel->setPaletteBackgroundColor(darkGreen);
+ //if(iChanDetectLabel->pixmap() != darkgreendotIcon)
+ if(_midiDetect)
+ {
+ //printf("Arranger::midiTrackInfoHeartBeat setting darkgreen icon\n");
+
+ _midiDetect = false;
+ //iChanDetectLabel->setPixmap(*darkgreendotIcon);
+ iChanDetectLabel->setPixmap(*darkRedLedIcon);
+ }
+ }
+
+ int nprogram = mp->hwCtrlState(outChannel, CTRL_PROGRAM);
+ if(nprogram == CTRL_VAL_UNKNOWN)
+ {
+ if(program != CTRL_VAL_UNKNOWN)
+ {
+ //printf("Arranger::midiTrackInfoHeartBeat setting program to unknown\n");
+
+ program = CTRL_VAL_UNKNOWN;
+ if(iHBank->value() != 0)
+ {
+ iHBank->blockSignals(true);
+ iHBank->setValue(0);
+ iHBank->blockSignals(false);
+ }
+ if(iLBank->value() != 0)
+ {
+ iLBank->blockSignals(true);
+ iLBank->setValue(0);
+ iLBank->blockSignals(false);
+ }
+ if(iProgram->value() != 0)
+ {
+ iProgram->blockSignals(true);
+ iProgram->setValue(0);
+ iProgram->blockSignals(false);
+ }
+ }
+
+ nprogram = mp->lastValidHWCtrlState(outChannel, CTRL_PROGRAM);
+ if(nprogram == CTRL_VAL_UNKNOWN)
+ {
+ //const char* n = "<unknown>";
+ const QString n(tr("Select Patch"));
+ //if(strcmp(iPatch->text().toLatin1().constData(), n) != 0)
+ if(iPatch->text() != n)
+ {
+ //printf("Arranger::midiTrackInfoHeartBeat setting patch <unknown>\n");
+
+ iPatch->setText(n);
+ }
+ }
+ else
+ {
+ MidiInstrument* instr = mp->instrument();
+ QString name = instr->getPatchName(outChannel, nprogram, song->mtype(), track->type() == Track::DRUM);
+ if(name.isEmpty())
+ {
+ const QString n("???");
+ if(iPatch->text() != n)
+ iPatch->setText(n);
+ }
+ else
+ if(iPatch->text() != name)
+ {
+ //printf("Arranger::midiTrackInfoHeartBeat setting patch name\n");
+
+ iPatch->setText(name);
+ }
+ }
+ }
+ else
+ if(program != nprogram)
+ {
+ program = nprogram;
+
+ //int hb, lb, pr;
+ //if (program == CTRL_VAL_UNKNOWN) {
+ // hb = lb = pr = 0;
+ // iPatch->setText("---");
+ // }
+ //else
+ //{
+ MidiInstrument* instr = mp->instrument();
+ QString name = instr->getPatchName(outChannel, program, song->mtype(), track->type() == Track::DRUM);
+ if(iPatch->text() != name)
+ iPatch->setText(name);
+
+ int hb = ((program >> 16) & 0xff) + 1;
+ if (hb == 0x100)
+ hb = 0;
+ int lb = ((program >> 8) & 0xff) + 1;
+ if (lb == 0x100)
+ lb = 0;
+ int pr = (program & 0xff) + 1;
+ if (pr == 0x100)
+ pr = 0;
+ //}
+
+ //printf("Arranger::midiTrackInfoHeartBeat setting program\n");
+
+ if(iHBank->value() != hb)
+ {
+ iHBank->blockSignals(true);
+ iHBank->setValue(hb);
+ iHBank->blockSignals(false);
+ }
+ if(iLBank->value() != lb)
+ {
+ iLBank->blockSignals(true);
+ iLBank->setValue(lb);
+ iLBank->blockSignals(false);
+ }
+ if(iProgram->value() != pr)
+ {
+ iProgram->blockSignals(true);
+ iProgram->setValue(pr);
+ iProgram->blockSignals(false);
+ }
+
+ }
+
+ MidiController* mc = mp->midiController(CTRL_VOLUME);
+ int mn = mc->minVal();
+ int v = mp->hwCtrlState(outChannel, CTRL_VOLUME);
+ if(v == CTRL_VAL_UNKNOWN)
+ //{
+ //v = mc->initVal();
+ //if(v == CTRL_VAL_UNKNOWN)
+ // v = 0;
+ v = mn - 1;
+ //}
+ else
+ // Auto bias...
+ v -= mc->bias();
+ if(volume != v)
+ {
+ volume = v;
+ if(iLautst->value() != v)
+ {
+ //printf("Arranger::midiTrackInfoHeartBeat setting volume\n");
+
+ iLautst->blockSignals(true);
+ //iLautst->setRange(mn - 1, mc->maxVal());
+ iLautst->setValue(v);
+ iLautst->blockSignals(false);
+ }
+ }
+
+ mc = mp->midiController(CTRL_PANPOT);
+ mn = mc->minVal();
+ v = mp->hwCtrlState(outChannel, CTRL_PANPOT);
+ if(v == CTRL_VAL_UNKNOWN)
+ //{
+ //v = mc->initVal();
+ //if(v == CTRL_VAL_UNKNOWN)
+ // v = 0;
+ v = mn - 1;
+ //}
+ else
+ // Auto bias...
+ v -= mc->bias();
+ if(pan != v)
+ {
+ pan = v;
+ if(iPan->value() != v)
+ {
+ //printf("Arranger::midiTrackInfoHeartBeat setting pan\n");
+
+ iPan->blockSignals(true);
+ //iPan->setRange(mn - 1, mc->maxVal());
+ iPan->setValue(v);
+ iPan->blockSignals(false);
+ }
+ }
+
+ // Does it include a midi controller value adjustment? Then handle it...
+ //if(flags & SC_MIDI_CONTROLLER)
+ // seek();
+
+ /*
+ if(iTransp->value() != track->transposition)
+ iTransp->setValue(track->transposition);
+ if(iAnschl->value() != track->velocity)
+ iAnschl->setValue(track->velocity);
+ if(iVerz->value() != track->delay)
+ iVerz->setValue(track->delay);
+ if(iLen->value() != track->len)
+ iLen->setValue(track->len);
+ if(iKompr->value() != track->compression)
+ iKompr->setValue(track->compression);
+ */
+ }
+ break;
+
+ case Track::WAVE:
+ case Track::AUDIO_OUTPUT:
+ case Track::AUDIO_INPUT:
+ case Track::AUDIO_GROUP:
+ case Track::AUDIO_AUX:
+ case Track::AUDIO_SOFTSYNTH:
+ break;
+ }
+}
+
+//---------------------------------------------------------
+// configChanged
+//---------------------------------------------------------
+
+void MidiTrackInfo::configChanged()
+ {
+ //printf("MidiTrackInfo::configChanged\n");
+
+ //if (config.canvasBgPixmap.isEmpty()) {
+ // canvas->setBg(config.partCanvasBg);
+ // canvas->setBg(QPixmap());
+ //}
+ //else {
+ // canvas->setBg(QPixmap(config.canvasBgPixmap));
+ //}
+
+ setFont(config.fonts[2]);
+ //updateTrackInfo(type);
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void MidiTrackInfo::songChanged(int type)
+{
+ // Is it simply a midi controller value adjustment? Forget it.
+ if(type == SC_MIDI_CONTROLLER)
+ return;
+ if(type == SC_SELECTION)
+ return;
+ if(!isVisible())
+ return;
+ updateTrackInfo(type);
+}
+
+//---------------------------------------------------------
+// setLabelText
+//---------------------------------------------------------
+
+void MidiTrackInfo::setLabelText()
+{
+ MidiTrack* track = (MidiTrack*)selected;
+ if(track)
+ trackNameLabel->setText(track->name());
+ else
+ trackNameLabel->setText(QString());
+}
+
+//---------------------------------------------------------
+// setLabelFont
+//---------------------------------------------------------
+
+void MidiTrackInfo::setLabelFont()
+{
+ //if(!selected)
+ // return;
+ //MidiTrack* track = (MidiTrack*)selected;
+
+ // Use the new font #6 I created just for these labels (so far).
+ // Set the label's font.
+ trackNameLabel->setFont(config.fonts[6]);
+ // Dealing with a horizontally constrained label. Ignore vertical. Use a minimum readable point size.
+ autoAdjustFontSize(trackNameLabel, trackNameLabel->text(), false, true, config.fonts[6].pointSize(), 5);
+}
+
+//---------------------------------------------------------
+// iOutputChannelChanged
+//---------------------------------------------------------
+
+void MidiTrackInfo::iOutputChannelChanged(int channel)
+ {
+ --channel;
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ if (channel != track->outChannel()) {
+ // Changed by T356.
+ //track->setOutChannel(channel);
+ audio->msgIdle(true);
+ //audio->msgSetTrackOutChannel(track, channel);
+ track->setOutChanAndUpdate(channel);
+ audio->msgIdle(false);
+
+ // may result in adding/removing mixer strip:
+ //song->update(-1);
+ song->update(SC_MIDI_TRACK_PROP);
+ }
+ }
+
+//---------------------------------------------------------
+// iOutputPortChanged
+//---------------------------------------------------------
+
+void MidiTrackInfo::iOutputPortChanged(int index)
+ {
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ if (index == track->outPort())
+ return;
+ // Changed by T356.
+ //track->setOutPort(index);
+ audio->msgIdle(true);
+ //audio->msgSetTrackOutPort(track, index);
+ track->setOutPortAndUpdate(index);
+ _tableModel->clear();
+ rebuildMatrix();
+ audio->msgIdle(false);
+
+ song->update(SC_MIDI_TRACK_PROP);
+ }
+
+//---------------------------------------------------------
+// routingPopupMenuActivated
+//---------------------------------------------------------
+
+//void MidiTrackInfo::routingPopupMenuActivated(int n)
+void MidiTrackInfo::routingPopupMenuActivated(QAction* act)
+{
+ ///if(!midiTrackInfo || gRoutingPopupMenuMaster != midiTrackInfo || !selected || !selected->isMidiTrack())
+ if((gRoutingPopupMenuMaster != this) || !selected || !selected->isMidiTrack())
+ return;
+ muse->routingPopupMenuActivated(selected, act->data().toInt());
+}
+
+#if 0
+//---------------------------------------------------------
+// routingPopupViewActivated
+//---------------------------------------------------------
+
+void MidiTrackInfo::routingPopupViewActivated(const QModelIndex& mdi)
+{
+ ///if(!midiTrackInfo || gRoutingPopupMenuMaster != midiTrackInfo || !selected || !selected->isMidiTrack())
+ if(gRoutingPopupMenuMaster != this || !selected || !selected->isMidiTrack())
+ return;
+ muse->routingPopupMenuActivated(selected, mdi.data().toInt());
+}
+#endif
+
+//---------------------------------------------------------
+// inRoutesPressed
+//---------------------------------------------------------
+
+void MidiTrackInfo::inRoutesPressed()
+{
+ if(!selected)
+ return;
+ if(!selected->isMidiTrack())
+ return;
+
+ PopupMenu* pup = muse->prepareRoutingPopupMenu(selected, false);
+ //PopupView* pup = muse->prepareRoutingPopupView(selected, false);
+
+ if(!pup) {
+ int ret = QMessageBox::warning(this, tr("No inputs"),
+ tr("There are no midi inputs.\n"
+ "Do you want to open the midi configuration dialog?"),
+ QMessageBox::Ok | QMessageBox::Cancel,
+ QMessageBox::Ok);
+ if (ret == QMessageBox::Ok) {
+ // printf("open config midi ports\n");
+ muse->configMidiPorts();
+ }
+ return;
+ }
+
+ ///gRoutingPopupMenuMaster = midiTrackInfo;
+ gRoutingPopupMenuMaster = this;
+ connect(pup, SIGNAL(triggered(QAction*)), SLOT(routingPopupMenuActivated(QAction*)));
+ //connect(pup, SIGNAL(activated(const QModelIndex&)), SLOT(routingPopupViewActivated(const QModelIndex&)));
+ connect(pup, SIGNAL(aboutToHide()), muse, SLOT(routingPopupMenuAboutToHide()));
+ //connect(pup, SIGNAL(aboutToHide()), muse, SLOT(routingPopupViewAboutToHide()));
+ pup->popup(QCursor::pos());
+ //pup->setVisible(true);
+ iRButton->setDown(false);
+ return;
+}
+
+//---------------------------------------------------------
+// outRoutesPressed
+//---------------------------------------------------------
+
+void MidiTrackInfo::outRoutesPressed()
+{
+ if(!selected)
+ return;
+ if(!selected->isMidiTrack())
+ return;
+
+ PopupMenu* pup = muse->prepareRoutingPopupMenu(selected, true);
+ if(!pup)
+ return;
+
+ ///gRoutingPopupMenuMaster = midiTrackInfo;
+ gRoutingPopupMenuMaster = this;
+ connect(pup, SIGNAL(triggered(QAction*)), SLOT(routingPopupMenuActivated(QAction*)));
+ connect(pup, SIGNAL(aboutToHide()), muse, SLOT(routingPopupMenuAboutToHide()));
+ pup->popup(QCursor::pos());
+ ///oRButton->setDown(false);
+ return;
+}
+
+//---------------------------------------------------------
+// iProgHBankChanged
+//---------------------------------------------------------
+
+void MidiTrackInfo::iProgHBankChanged()
+ {
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ int channel = track->outChannel();
+ int port = track->outPort();
+ int hbank = iHBank->value();
+ int lbank = iLBank->value();
+ int prog = iProgram->value();
+
+ if (hbank > 0 && hbank < 129)
+ hbank -= 1;
+ else
+ hbank = 0xff;
+ if (lbank > 0 && lbank < 129)
+ lbank -= 1;
+ else
+ lbank = 0xff;
+ if (prog > 0 && prog < 129)
+ prog -= 1;
+ else
+ prog = 0xff;
+
+ MidiPort* mp = &midiPorts[port];
+ if(prog == 0xff && hbank == 0xff && lbank == 0xff)
+ {
+ program = CTRL_VAL_UNKNOWN;
+ if(mp->hwCtrlState(channel, CTRL_PROGRAM) != CTRL_VAL_UNKNOWN)
+ audio->msgSetHwCtrlState(mp, channel, CTRL_PROGRAM, CTRL_VAL_UNKNOWN);
+ return;
+ }
+
+ int np = mp->hwCtrlState(channel, CTRL_PROGRAM);
+ if(np == CTRL_VAL_UNKNOWN)
+ {
+ np = mp->lastValidHWCtrlState(channel, CTRL_PROGRAM);
+ if(np != CTRL_VAL_UNKNOWN)
+ {
+ lbank = (np & 0xff00) >> 8;
+ prog = np & 0xff;
+ if(prog == 0xff)
+ prog = 0;
+ int ilbnk = lbank;
+ int iprog = prog;
+ if(ilbnk == 0xff)
+ ilbnk = -1;
+ ++ilbnk;
+ ++iprog;
+ iLBank->blockSignals(true);
+ iProgram->blockSignals(true);
+ iLBank->setValue(ilbnk);
+ iProgram->setValue(iprog);
+ iLBank->blockSignals(false);
+ iProgram->blockSignals(false);
+ }
+ }
+
+ if(prog == 0xff && (hbank != 0xff || lbank != 0xff))
+ {
+ prog = 0;
+ iProgram->blockSignals(true);
+ iProgram->setValue(1);
+ iProgram->blockSignals(false);
+ }
+ program = (hbank << 16) + (lbank << 8) + prog;
+ MidiPlayEvent ev(0, port, channel, ME_CONTROLLER, CTRL_PROGRAM, program);
+ audio->msgPlayMidiEvent(&ev);
+
+ MidiInstrument* instr = mp->instrument();
+ iPatch->setText(instr->getPatchName(channel, program, song->mtype(), track->type() == Track::DRUM));
+// updateTrackInfo();
+ }
+
+//---------------------------------------------------------
+// iProgLBankChanged
+//---------------------------------------------------------
+
+void MidiTrackInfo::iProgLBankChanged()
+ {
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ int channel = track->outChannel();
+ int port = track->outPort();
+ int hbank = iHBank->value();
+ int lbank = iLBank->value();
+ int prog = iProgram->value();
+
+ if (hbank > 0 && hbank < 129)
+ hbank -= 1;
+ else
+ hbank = 0xff;
+ if (lbank > 0 && lbank < 129)
+ lbank -= 1;
+ else
+ lbank = 0xff;
+ if (prog > 0 && prog < 129)
+ prog -= 1;
+ else
+ prog = 0xff;
+
+ MidiPort* mp = &midiPorts[port];
+ if(prog == 0xff && hbank == 0xff && lbank == 0xff)
+ {
+ program = CTRL_VAL_UNKNOWN;
+ if(mp->hwCtrlState(channel, CTRL_PROGRAM) != CTRL_VAL_UNKNOWN)
+ audio->msgSetHwCtrlState(mp, channel, CTRL_PROGRAM, CTRL_VAL_UNKNOWN);
+ return;
+ }
+
+ int np = mp->hwCtrlState(channel, CTRL_PROGRAM);
+ if(np == CTRL_VAL_UNKNOWN)
+ {
+ np = mp->lastValidHWCtrlState(channel, CTRL_PROGRAM);
+ if(np != CTRL_VAL_UNKNOWN)
+ {
+ hbank = (np & 0xff0000) >> 16;
+ prog = np & 0xff;
+ if(prog == 0xff)
+ prog = 0;
+ int ihbnk = hbank;
+ int iprog = prog;
+ if(ihbnk == 0xff)
+ ihbnk = -1;
+ ++ihbnk;
+ ++iprog;
+ iHBank->blockSignals(true);
+ iProgram->blockSignals(true);
+ iHBank->setValue(ihbnk);
+ iProgram->setValue(iprog);
+ iHBank->blockSignals(false);
+ iProgram->blockSignals(false);
+ }
+ }
+
+ if(prog == 0xff && (hbank != 0xff || lbank != 0xff))
+ {
+ prog = 0;
+ iProgram->blockSignals(true);
+ iProgram->setValue(1);
+ iProgram->blockSignals(false);
+ }
+ program = (hbank << 16) + (lbank << 8) + prog;
+ MidiPlayEvent ev(0, port, channel, ME_CONTROLLER, CTRL_PROGRAM, program);
+ audio->msgPlayMidiEvent(&ev);
+
+ MidiInstrument* instr = mp->instrument();
+ iPatch->setText(instr->getPatchName(channel, program, song->mtype(), track->type() == Track::DRUM));
+// updateTrackInfo();
+ }
+
+//---------------------------------------------------------
+// iProgramChanged
+//---------------------------------------------------------
+
+void MidiTrackInfo::iProgramChanged()
+ {
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ int channel = track->outChannel();
+ int port = track->outPort();
+ int hbank = iHBank->value();
+ int lbank = iLBank->value();
+ int prog = iProgram->value();
+
+ if (hbank > 0 && hbank < 129)
+ hbank -= 1;
+ else
+ hbank = 0xff;
+ if (lbank > 0 && lbank < 129)
+ lbank -= 1;
+ else
+ lbank = 0xff;
+ if (prog > 0 && prog < 129)
+ prog -= 1;
+ else
+ prog = 0xff;
+
+ MidiPort *mp = &midiPorts[port];
+ if(prog == 0xff)
+ {
+ program = CTRL_VAL_UNKNOWN;
+ iHBank->blockSignals(true);
+ iLBank->blockSignals(true);
+ iHBank->setValue(0);
+ iLBank->setValue(0);
+ iHBank->blockSignals(false);
+ iLBank->blockSignals(false);
+
+ if(mp->hwCtrlState(channel, CTRL_PROGRAM) != CTRL_VAL_UNKNOWN)
+ audio->msgSetHwCtrlState(mp, channel, CTRL_PROGRAM, CTRL_VAL_UNKNOWN);
+ return;
+ }
+ else
+ {
+ int np = mp->hwCtrlState(channel, CTRL_PROGRAM);
+ if(np == CTRL_VAL_UNKNOWN)
+ {
+ np = mp->lastValidHWCtrlState(channel, CTRL_PROGRAM);
+ if(np != CTRL_VAL_UNKNOWN)
+ {
+ hbank = (np & 0xff0000) >> 16;
+ lbank = (np & 0xff00) >> 8;
+ int ihbnk = hbank;
+ int ilbnk = lbank;
+ if(ihbnk == 0xff)
+ ihbnk = -1;
+ if(ilbnk == 0xff)
+ ilbnk = -1;
+ ++ihbnk;
+ ++ilbnk;
+ iHBank->blockSignals(true);
+ iLBank->blockSignals(true);
+ iHBank->setValue(ihbnk);
+ iLBank->setValue(ilbnk);
+ iHBank->blockSignals(false);
+ iLBank->blockSignals(false);
+ }
+ }
+ program = (hbank << 16) + (lbank << 8) + prog;
+ MidiPlayEvent ev(0, port, channel, ME_CONTROLLER, CTRL_PROGRAM, program);
+ audio->msgPlayMidiEvent(&ev);
+
+ MidiInstrument* instr = mp->instrument();
+ iPatch->setText(instr->getPatchName(channel, program, song->mtype(), track->type() == Track::DRUM));
+ }
+
+// updateTrackInfo();
+ }
+
+//---------------------------------------------------------
+// iLautstChanged
+//---------------------------------------------------------
+
+void MidiTrackInfo::iLautstChanged(int val)
+ {
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ int outPort = track->outPort();
+ int chan = track->outChannel();
+ MidiPort* mp = &midiPorts[outPort];
+ MidiController* mctl = mp->midiController(CTRL_VOLUME);
+ if((val < mctl->minVal()) || (val > mctl->maxVal()))
+ {
+ if(mp->hwCtrlState(chan, CTRL_VOLUME) != CTRL_VAL_UNKNOWN)
+ audio->msgSetHwCtrlState(mp, chan, CTRL_VOLUME, CTRL_VAL_UNKNOWN);
+ }
+ else
+ {
+ val += mctl->bias();
+
+ MidiPlayEvent ev(0, outPort, chan,
+ ME_CONTROLLER, CTRL_VOLUME, val);
+ audio->msgPlayMidiEvent(&ev);
+ }
+ song->update(SC_MIDI_CONTROLLER);
+ }
+
+//---------------------------------------------------------
+// iTranspChanged
+//---------------------------------------------------------
+
+void MidiTrackInfo::iTranspChanged(int val)
+ {
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ track->transposition = val;
+ song->update(SC_MIDI_TRACK_PROP);
+ }
+
+//---------------------------------------------------------
+// iAnschlChanged
+//---------------------------------------------------------
+
+void MidiTrackInfo::iAnschlChanged(int val)
+ {
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ track->velocity = val;
+ song->update(SC_MIDI_TRACK_PROP);
+ }
+
+//---------------------------------------------------------
+// iVerzChanged
+//---------------------------------------------------------
+
+void MidiTrackInfo::iVerzChanged(int val)
+ {
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ track->delay = val;
+ song->update(SC_MIDI_TRACK_PROP);
+ }
+
+//---------------------------------------------------------
+// iLenChanged
+//---------------------------------------------------------
+
+void MidiTrackInfo::iLenChanged(int val)
+ {
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ track->len = val;
+ song->update(SC_MIDI_TRACK_PROP);
+ }
+
+//---------------------------------------------------------
+// iKomprChanged
+//---------------------------------------------------------
+
+void MidiTrackInfo::iKomprChanged(int val)
+ {
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ track->compression = val;
+ song->update(SC_MIDI_TRACK_PROP);
+ }
+
+//---------------------------------------------------------
+// iPanChanged
+//---------------------------------------------------------
+
+void MidiTrackInfo::iPanChanged(int val)
+ {
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ int port = track->outPort();
+ int chan = track->outChannel();
+ MidiPort* mp = &midiPorts[port];
+ MidiController* mctl = mp->midiController(CTRL_PANPOT);
+ if((val < mctl->minVal()) || (val > mctl->maxVal()))
+ {
+ if(mp->hwCtrlState(chan, CTRL_PANPOT) != CTRL_VAL_UNKNOWN)
+ audio->msgSetHwCtrlState(mp, chan, CTRL_PANPOT, CTRL_VAL_UNKNOWN);
+ }
+ else
+ {
+ val += mctl->bias();
+
+ // Realtime Change:
+ MidiPlayEvent ev(0, port, chan,
+ ME_CONTROLLER, CTRL_PANPOT, val);
+ audio->msgPlayMidiEvent(&ev);
+ }
+ song->update(SC_MIDI_CONTROLLER);
+ }
+
+//---------------------------------------------------------
+// instrPopup
+//---------------------------------------------------------
+
+void MidiTrackInfo::instrPopup()
+{
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ int channel = track->outChannel();
+ int port = track->outPort();
+ MidiInstrument* instr = midiPorts[port].instrument();
+ QMenu* pup = new QMenu;
+ ///instr->populatePatchPopup(pop, channel, song->mtype(), track->type() == Track::DRUM);
+ instr->populatePatchPopup(pup, channel, song->mtype(), track->type() == Track::DRUM);
+
+ ///if(pop->actions().count() == 0)
+ /// return;
+ if(pup->actions().count() == 0)
+ {
+ delete pup;
+ return;
+ }
+
+ ///QAction *act = pop->exec(iPatch->mapToGlobal(QPoint(10,5)));
+ QAction *act = pup->exec(iPatch->mapToGlobal(QPoint(10,5)));
+ if (act) {
+ //int rv = act->data().toInt();
+ QVariant _data = act->data();
+ QStringList lst = _data.toStringList();
+ if(!lst.isEmpty())
+ {
+ QString str = lst.at(0);
+ QString pg = "";//lst.at(1);
+ int rv = str.toInt();
+
+ MidiPlayEvent ev(0, port, channel, ME_CONTROLLER, CTRL_PROGRAM, rv);
+ audio->msgPlayMidiEvent(&ev);
+ updateTrackInfo(-1);
+
+ //At this point we add the event to the list.
+ if(lst.size() > 1)
+ {
+ pg = lst.at(1);
+ }
+ //QLabel label;
+ //label.setText(pg);
+ QString label = " " + pg + (pg.isEmpty() ? "" : ":\n ") + act->text();
+ //QList<QStandardItem*> found = _tableModel->findItems(label, Qt::MatchExactly, 1);
+ //if(found.size() == 0)
+ //{
+ QList<QStandardItem*> rowData;
+ QStandardItem* chk = new QStandardItem(true);
+ chk->setCheckable(true);
+ chk->setCheckState(Qt::Checked);
+ chk->setToolTip(tr("Add to patch sequence"));
+ //_tableModel->setItem(row, 0, chk);
+ QStandardItem* patch = new QStandardItem(label);
+ patch->setToolTip(label);
+ patch->setEditable(false);
+ rowData.append(new QStandardItem(str));
+ rowData.append(chk);
+ rowData.append(patch);
+ //_tableModel->setItem(row, 1, patch);
+ //_tableModel->setItem(row, 2, new QStandardItem(str));
+ for(int i=0; i < _tableModel->rowCount(); ++i)
+ {
+ QStandardItem* item = _tableModel->item(i, 1);
+ item->setCheckState(Qt::Unchecked);
+ }
+ _tableModel->insertRow(0, rowData);
+ tableView->resizeRowToContents(0);
+ tableView->selectRow(0);
+ _matrix->append(0);
+ tableView->setColumnWidth(1, 20);
+ tableView->setColumnWidth(0, 1);
+ /* tableView->setColumnHidden(0, true);
+ if(_tableModel->rowCount() == 1)
+ {
+ QStringList headers;
+ headers.append(tr("I"));
+ headers.append(tr("M"));
+ headers.append(tr("Patch"));
+ _tableModel->setHorizontalHeaderLabels(headers);
+ }*/
+ /*}
+ else
+ {
+ for(int i=0; i < _tableModel->rowCount(); ++i)
+ {
+ QStandardItem* item = _tableModel->item(i, 0);
+ item->setCheckState(Qt::Unchecked);
+ }
+ //Select the patch that was a duplicate only
+ QStandardItem* dup = found.at(0);
+ QStandardItem* dchk = _tableModel->item(dup->row(), 0);
+ dchk->setCheckState(Qt::Checked);
+ }*/
+ }
+ }
+
+ delete pup;
+}
+
+//---------------------------------------------------------
+// recEchoToggled
+//---------------------------------------------------------
+
+void MidiTrackInfo::recEchoToggled(bool v)
+{
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ track->setRecEcho(v);
+ song->update(SC_MIDI_TRACK_PROP);
+}
+
+//---------------------------------------------------------
+// iProgramDoubleClicked
+//---------------------------------------------------------
+
+void MidiTrackInfo::iProgramDoubleClicked()
+{
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ int port = track->outPort();
+ int chan = track->outChannel();
+ MidiPort* mp = &midiPorts[port];
+ MidiController* mctl = mp->midiController(CTRL_PROGRAM);
+
+ if(!track || !mctl)
+ return;
+
+ int lastv = mp->lastValidHWCtrlState(chan, CTRL_PROGRAM);
+ int curv = mp->hwCtrlState(chan, CTRL_PROGRAM);
+
+ if(curv == CTRL_VAL_UNKNOWN)
+ {
+ // If no value has ever been set yet, use the current knob value
+ // (or the controller's initial value?) to 'turn on' the controller.
+ if(lastv == CTRL_VAL_UNKNOWN)
+ {
+ int kiv = mctl->initVal();
+ //int kiv = lrint(_knob->value());
+ if(kiv == CTRL_VAL_UNKNOWN)
+ kiv = 0;
+ //else
+ //{
+ //if(kiv < mctrl->minVal())
+ // kiv = mctrl->minVal();
+ //if(kiv > mctrl->maxVal())
+ // kiv = mctrl->maxVal();
+ //kiv += mctrl->bias();
+ //}
+
+ //MidiPlayEvent ev(0, port, chan, ME_CONTROLLER, num, kiv);
+ MidiPlayEvent ev(0, port, chan, ME_CONTROLLER, CTRL_PROGRAM, kiv);
+ audio->msgPlayMidiEvent(&ev);
+ }
+ else
+ {
+ MidiPlayEvent ev(0, port, chan, ME_CONTROLLER, CTRL_PROGRAM, lastv);
+ audio->msgPlayMidiEvent(&ev);
+ }
+ }
+ else
+ {
+ if(mp->hwCtrlState(chan, CTRL_PROGRAM) != CTRL_VAL_UNKNOWN)
+ audio->msgSetHwCtrlState(mp, chan, CTRL_PROGRAM, CTRL_VAL_UNKNOWN);
+ }
+
+ song->update(SC_MIDI_CONTROLLER);
+}
+
+//---------------------------------------------------------
+// iLautstDoubleClicked
+//---------------------------------------------------------
+
+void MidiTrackInfo::iLautstDoubleClicked()
+{
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ int port = track->outPort();
+ int chan = track->outChannel();
+ MidiPort* mp = &midiPorts[port];
+ MidiController* mctl = mp->midiController(CTRL_VOLUME);
+
+ if(!track || !mctl)
+ return;
+
+ int lastv = mp->lastValidHWCtrlState(chan, CTRL_VOLUME);
+ int curv = mp->hwCtrlState(chan, CTRL_VOLUME);
+
+ if(curv == CTRL_VAL_UNKNOWN)
+ {
+ // If no value has ever been set yet, use the current knob value
+ // (or the controller's initial value?) to 'turn on' the controller.
+ if(lastv == CTRL_VAL_UNKNOWN)
+ {
+ int kiv = mctl->initVal();
+ //int kiv = lrint(_knob->value());
+ if(kiv == CTRL_VAL_UNKNOWN)
+ // Set volume to 78% of range, so that if range is 0 - 127, then value is 100.
+ kiv = lround(double(mctl->maxVal() - mctl->minVal()) * 0.7874);
+ else
+ {
+ if(kiv < mctl->minVal())
+ kiv = mctl->minVal();
+ if(kiv > mctl->maxVal())
+ kiv = mctl->maxVal();
+ kiv += mctl->bias();
+ }
+
+ MidiPlayEvent ev(0, port, chan, ME_CONTROLLER, CTRL_VOLUME, kiv);
+ audio->msgPlayMidiEvent(&ev);
+ }
+ else
+ {
+ MidiPlayEvent ev(0, port, chan, ME_CONTROLLER, CTRL_VOLUME, lastv);
+ audio->msgPlayMidiEvent(&ev);
+ }
+ }
+ else
+ {
+ if(mp->hwCtrlState(chan, CTRL_VOLUME) != CTRL_VAL_UNKNOWN)
+ audio->msgSetHwCtrlState(mp, chan, CTRL_VOLUME, CTRL_VAL_UNKNOWN);
+ }
+
+ song->update(SC_MIDI_CONTROLLER);
+}
+
+//---------------------------------------------------------
+// iPanDoubleClicked
+//---------------------------------------------------------
+
+void MidiTrackInfo::iPanDoubleClicked()
+{
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ int port = track->outPort();
+ int chan = track->outChannel();
+ MidiPort* mp = &midiPorts[port];
+ MidiController* mctl = mp->midiController(CTRL_PANPOT);
+
+ if(!track || !mctl)
+ return;
+
+ int lastv = mp->lastValidHWCtrlState(chan, CTRL_PANPOT);
+ int curv = mp->hwCtrlState(chan, CTRL_PANPOT);
+
+ if(curv == CTRL_VAL_UNKNOWN)
+ {
+ // If no value has ever been set yet, use the current knob value
+ // (or the controller's initial value?) to 'turn on' the controller.
+ if(lastv == CTRL_VAL_UNKNOWN)
+ {
+ int kiv = mctl->initVal();
+ //int kiv = lrint(_knob->value());
+ if(kiv == CTRL_VAL_UNKNOWN)
+ // Set volume to 50% of range, so that if range is 0 - 127, then value is 64.
+ kiv = lround(double(mctl->maxVal() - mctl->minVal()) * 0.5);
+ else
+ {
+ if(kiv < mctl->minVal())
+ kiv = mctl->minVal();
+ if(kiv > mctl->maxVal())
+ kiv = mctl->maxVal();
+ kiv += mctl->bias();
+ }
+
+ MidiPlayEvent ev(0, port, chan, ME_CONTROLLER, CTRL_PANPOT, kiv);
+ audio->msgPlayMidiEvent(&ev);
+ }
+ else
+ {
+ MidiPlayEvent ev(0, port, chan, ME_CONTROLLER, CTRL_PANPOT, lastv);
+ audio->msgPlayMidiEvent(&ev);
+ }
+ }
+ else
+ {
+ if(mp->hwCtrlState(chan, CTRL_PANPOT) != CTRL_VAL_UNKNOWN)
+ audio->msgSetHwCtrlState(mp, chan, CTRL_PANPOT, CTRL_VAL_UNKNOWN);
+ }
+
+ song->update(SC_MIDI_CONTROLLER);
+}
+
+
+//---------------------------------------------------------
+// updateTrackInfo
+//---------------------------------------------------------
+
+void MidiTrackInfo::updateTrackInfo(int flags)
+{
+ // Is it simply a midi controller value adjustment? Forget it.
+ if(flags == SC_MIDI_CONTROLLER)
+ return;
+ if(flags == SC_SELECTION)
+ return;
+
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+
+ // p3.3.47 Update the routing popup menu if anything relevant changes.
+ //if(gRoutingPopupMenuMaster == midiTrackInfo && selected && (flags & (SC_ROUTE | SC_CHANNELS | SC_CONFIG)))
+ if(flags & (SC_ROUTE | SC_CHANNELS | SC_CONFIG)) // p3.3.50
+ // Use this handy shared routine.
+ //muse->updateRouteMenus(selected);
+ ///muse->updateRouteMenus(selected, midiTrackInfo); // p3.3.50
+ muse->updateRouteMenus(selected, this);
+
+ // Added by Tim. p3.3.9
+ setLabelText();
+ setLabelFont();
+
+ if(flags & (SC_MIDI_TRACK_PROP))
+ {
+ iTransp->blockSignals(true);
+ iAnschl->blockSignals(true);
+ iVerz->blockSignals(true);
+ iLen->blockSignals(true);
+ iKompr->blockSignals(true);
+ iTransp->setValue(track->transposition);
+ iAnschl->setValue(track->velocity);
+ iVerz->setValue(track->delay);
+ iLen->setValue(track->len);
+ iKompr->setValue(track->compression);
+ iTransp->blockSignals(false);
+ iAnschl->blockSignals(false);
+ iVerz->blockSignals(false);
+ iLen->blockSignals(false);
+ iKompr->blockSignals(false);
+
+ int outChannel = track->outChannel();
+ ///int inChannel = track->inChannelMask();
+ int outPort = track->outPort();
+ //int inPort = track->inPortMask();
+ ///unsigned int inPort = track->inPortMask();
+
+ iOutput->blockSignals(true);
+ //iInput->clear();
+ iOutput->clear();
+
+ for (int i = 0; i < MIDI_PORTS; ++i) {
+ QString name;
+ name.sprintf("%d:%s", i+1, midiPorts[i].portname().toLatin1().constData());
+ iOutput->insertItem(i, name);
+ if (i == outPort)
+ iOutput->setCurrentIndex(i);
+ }
+ iOutput->blockSignals(false);
+
+ //iInput->setText(bitmap2String(inPort));
+ ///iInput->setText(u32bitmap2String(inPort));
+
+ //iInputChannel->setText(bitmap2String(inChannel));
+
+ // Removed by Tim. p3.3.9
+ //if (iName->text() != selected->name()) {
+ // iName->setText(selected->name());
+ // iName->home(false);
+ // }
+
+ iOutputChannel->blockSignals(true);
+ iOutputChannel->setValue(outChannel+1);
+ iOutputChannel->blockSignals(false);
+ ///iInputChannel->setText(bitmap2String(inChannel));
+
+ // Set record echo.
+ if(recEchoButton->isChecked() != track->recEcho())
+ {
+ recEchoButton->blockSignals(true);
+ recEchoButton->setChecked(track->recEcho());
+ recEchoButton->blockSignals(false);
+ }
+ }
+
+ int outChannel = track->outChannel();
+ int outPort = track->outPort();
+ MidiPort* mp = &midiPorts[outPort];
+ int nprogram = mp->hwCtrlState(outChannel, CTRL_PROGRAM);
+ if(nprogram == CTRL_VAL_UNKNOWN)
+ {
+ iHBank->blockSignals(true);
+ iLBank->blockSignals(true);
+ iProgram->blockSignals(true);
+ iHBank->setValue(0);
+ iLBank->setValue(0);
+ iProgram->setValue(0);
+ iHBank->blockSignals(false);
+ iLBank->blockSignals(false);
+ iProgram->blockSignals(false);
+
+ program = CTRL_VAL_UNKNOWN;
+ nprogram = mp->lastValidHWCtrlState(outChannel, CTRL_PROGRAM);
+ if(nprogram == CTRL_VAL_UNKNOWN)
+ //iPatch->setText(QString("<unknown>"));
+ iPatch->setText(tr("Select Patch"));
+ else
+ {
+ MidiInstrument* instr = mp->instrument();
+ iPatch->setText(instr->getPatchName(outChannel, nprogram, song->mtype(), track->type() == Track::DRUM));
+ }
+ }
+ else
+ //if (program != nprogram)
+ {
+ program = nprogram;
+
+ //int hb, lb, pr;
+ //if (program == CTRL_VAL_UNKNOWN) {
+ // hb = lb = pr = 0;
+ // iPatch->setText("---");
+ // }
+ //else
+ //{
+ MidiInstrument* instr = mp->instrument();
+ iPatch->setText(instr->getPatchName(outChannel, program, song->mtype(), track->type() == Track::DRUM));
+
+ int hb = ((program >> 16) & 0xff) + 1;
+ if (hb == 0x100)
+ hb = 0;
+ int lb = ((program >> 8) & 0xff) + 1;
+ if (lb == 0x100)
+ lb = 0;
+ int pr = (program & 0xff) + 1;
+ if (pr == 0x100)
+ pr = 0;
+ //}
+ iHBank->blockSignals(true);
+ iLBank->blockSignals(true);
+ iProgram->blockSignals(true);
+
+ iHBank->setValue(hb);
+ iLBank->setValue(lb);
+ iProgram->setValue(pr);
+
+ iHBank->blockSignals(false);
+ iLBank->blockSignals(false);
+ iProgram->blockSignals(false);
+ }
+
+ MidiController* mc = mp->midiController(CTRL_VOLUME);
+ int mn = mc->minVal();
+ int v = mp->hwCtrlState(outChannel, CTRL_VOLUME);
+ volume = v;
+ if(v == CTRL_VAL_UNKNOWN)
+ //{
+ //v = mc->initVal();
+ //if(v == CTRL_VAL_UNKNOWN)
+ // v = 0;
+ v = mn - 1;
+ //}
+ else
+ // Auto bias...
+ v -= mc->bias();
+ iLautst->blockSignals(true);
+ iLautst->setRange(mn - 1, mc->maxVal());
+ iLautst->setValue(v);
+ iLautst->blockSignals(false);
+
+ mc = mp->midiController(CTRL_PANPOT);
+ mn = mc->minVal();
+ v = mp->hwCtrlState(outChannel, CTRL_PANPOT);
+ pan = v;
+ if(v == CTRL_VAL_UNKNOWN)
+ //{
+ //v = mc->initVal();
+ //if(v == CTRL_VAL_UNKNOWN)
+ // v = 0;
+ v = mn - 1;
+ //}
+ else
+ // Auto bias...
+ v -= mc->bias();
+ iPan->blockSignals(true);
+ iPan->setRange(mn - 1, mc->maxVal());
+ iPan->setValue(v);
+ iPan->blockSignals(false);
+ //}
+
+}
+
+//---------------------------------------------------------
+// progRecClicked
+//---------------------------------------------------------
+
+void MidiTrackInfo::progRecClicked()
+ {
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ int portno = track->outPort();
+ int channel = track->outChannel();
+ MidiPort* port = &midiPorts[portno];
+ int program = port->hwCtrlState(channel, CTRL_PROGRAM);
+ if(program == CTRL_VAL_UNKNOWN || program == 0xffffff)
+ return;
+
+ unsigned tick = song->cpos();
+ Event a(Controller);
+ a.setTick(tick);
+ a.setA(CTRL_PROGRAM);
+ a.setB(program);
+
+ song->recordEvent(track, a);
+ }
+
+//---------------------------------------------------------
+// volRecClicked
+//---------------------------------------------------------
+
+void MidiTrackInfo::volRecClicked()
+ {
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ int portno = track->outPort();
+ int channel = track->outChannel();
+ MidiPort* port = &midiPorts[portno];
+ int volume = port->hwCtrlState(channel, CTRL_VOLUME);
+ if(volume == CTRL_VAL_UNKNOWN)
+ return;
+
+ unsigned tick = song->cpos();
+ Event a(Controller);
+ a.setTick(tick);
+ a.setA(CTRL_VOLUME);
+ a.setB(volume);
+
+ song->recordEvent(track, a);
+ }
+
+//---------------------------------------------------------
+// panRecClicked
+//---------------------------------------------------------
+
+void MidiTrackInfo::panRecClicked()
+ {
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ int portno = track->outPort();
+ int channel = track->outChannel();
+ MidiPort* port = &midiPorts[portno];
+ int pan = port->hwCtrlState(channel, CTRL_PANPOT);
+ if(pan == CTRL_VAL_UNKNOWN)
+ return;
+
+ unsigned tick = song->cpos();
+ Event a(Controller);
+ a.setTick(tick);
+ a.setA(CTRL_PANPOT);
+ a.setB(pan);
+
+ song->recordEvent(track, a);
+ }
+
+//---------------------------------------------------------
+// recordClicked
+//---------------------------------------------------------
+
+void MidiTrackInfo::recordClicked()
+ {
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ int portno = track->outPort();
+ int channel = track->outChannel();
+ MidiPort* port = &midiPorts[portno];
+ unsigned tick = song->cpos();
+
+ int program = port->hwCtrlState(channel, CTRL_PROGRAM);
+ if(program != CTRL_VAL_UNKNOWN && program != 0xffffff)
+ {
+ Event a(Controller);
+ a.setTick(tick);
+ a.setA(CTRL_PROGRAM);
+ a.setB(program);
+ song->recordEvent(track, a);
+ }
+ int volume = port->hwCtrlState(channel, CTRL_VOLUME);
+ if(volume != CTRL_VAL_UNKNOWN)
+ {
+ Event a(Controller);
+ a.setTick(tick);
+ a.setA(CTRL_VOLUME);
+ a.setB(volume);
+ song->recordEvent(track, a);
+ }
+ int pan = port->hwCtrlState(channel, CTRL_PANPOT);
+ if(pan != CTRL_VAL_UNKNOWN)
+ {
+ Event a(Controller);
+ a.setTick(tick);
+ a.setA(CTRL_PANPOT);
+ a.setB(pan);
+ song->recordEvent(track, a);
+ }
+ }
+
+void MidiTrackInfo::toggleAdvanced(int checked)
+{
+ if(checked == Qt::Checked)
+ {
+ frame->show();
+ }
+ else
+ {
+ frame->hide();
+ }
+}
+
+
+void MidiTrackInfo::rebuildMatrix()
+{
+ //Clear the matrix
+ _matrix->erase(_matrix->begin(), _matrix->end());
+ //Rebuild from order of selected table items
+ for(int i=0; i < _tableModel->rowCount(); ++i)
+ {
+ QStandardItem* item = _tableModel->item(i, 1);
+ if(item->checkState() == Qt::Checked)
+ _matrix->append(item->row());
+ }
+ tableView->resizeRowsToContents();
+}
+
+void MidiTrackInfo::matrixItemChanged(QStandardItem* item)
+{
+ rebuildMatrix();
+ //if(item->column() != -1 && item->column() == 0 && item->isCheckable())
+ //{
+ // if(item->checkState() == Qt::Checked)
+ // {
+ // printf("Adding item to matrix %d\n", item->row());
+ // _matrix->append(item->row());
+ // }
+ // else
+ // {
+ // int ind = _matrix->indexOf(item->row());
+ // if(ind != -1)
+ // {
+ // printf("Removing item from matrix %d\n",ind);
+ // _matrix->removeAt(ind);
+ // }
+ // }
+ //}
+}
+
+void MidiTrackInfo::insertMatrixEvent()
+{
+ if(!selected)
+ return;
+ MidiTrack* track = (MidiTrack*)selected;
+ int channel = track->outChannel();
+ int port = track->outPort();
+ if(_matrix->size() == 1)
+ {
+ //Get the QStandardItem in the hidden third column
+ //This column contains the ID of the Patch
+ int row = _matrix->at(0);
+ QStandardItem* item = _tableModel->item(row, 0);
+ int id = item->text().toInt();
+ MidiPlayEvent ev(0, port, channel, ME_CONTROLLER, CTRL_PROGRAM, id);
+ audio->msgPlayMidiEvent(&ev);
+ updateTrackInfo(-1);
+ tableView->selectRow(item->row());
+ progRecClicked();
+ }
+ else if(_matrix->size() > 1)
+ {
+ int row = _matrix->takeFirst();
+ tableView->selectRow(_matrix->at(0));
+ //printf("Adding Program Change for row: %d\n", row);
+ if(row != -1 && row < _tableModel->rowCount())
+ {
+ QStandardItem* item = _tableModel->item(row, 0);
+ int id = item->text().toInt();
+ MidiPlayEvent ev(0, port, channel, ME_CONTROLLER, CTRL_PROGRAM, id);
+ audio->msgPlayMidiEvent(&ev);
+ updateTrackInfo(-1);
+ progRecClicked();
+ }
+ _matrix->push_back(row);
+ }
+}
+
+void MidiTrackInfo::deleteSelectedPatches(bool b)
+{
+ QList<int> rows = tableView->getSelectedRows();
+ if(!rows.isEmpty())
+ {
+ int id = rows.at(0);
+ if(!_matrix->isEmpty())
+ {
+ int mid = _matrix->indexOf(0);
+ if(mid != -1)
+ _matrix->takeAt(mid);
+ }
+ _tableModel->removeRow(id);
+ _tableModel->emit_layoutChanged();
+ tableView->resizeRowsToContents();
+ int c = _tableModel->rowCount();
+ //printf("Row Count: %d - Deleted Row:%d\n",c ,id);
+ if(c > id)
+ tableView->selectRow(id);
+ else
+ {
+ tableView->selectRow(0);
+ }
+ }
+/* for(int i =0; i < rows.size(); ++i)
+ {
+ if(!_matrix->isEmpty())
+ {
+ int mid = _matrix->indexOf(i);
+ if(mid != -1)
+ _matrix->takeAt(mid);
+ }
+ _tableModel->removeRow(i);
+ }
+ */
+}
+
+void MidiTrackInfo::movePatchDown(bool b)
+{
+ QList<int> rows = tableView->getSelectedRows();
+ if(!rows.isEmpty())
+ {
+ int id = rows.at(0);
+ if((id + 1) >= _tableModel->rowCount())
+ return;
+ int row = (id + 1);
+ QList<QStandardItem*> item = _tableModel->takeRow(id);
+ QStandardItem* txt = item.at(2);
+ txt->setEditable(false);
+ _tableModel->insertRow(row, item);
+ tableView->resizeRowsToContents();
+ tableView->setColumnWidth(1, 20);
+ tableView->setColumnWidth(0, 1);
+ tableView->selectRow(row);
+ }
+}
+
+void MidiTrackInfo::movePatchUp(bool clicked)
+{
+ QList<int> rows = tableView->getSelectedRows();
+ if(!rows.isEmpty())
+ {
+ int id = rows.at(0);
+ if((id - 1) < 0)
+ return;
+ int row = (id - 1);
+ QList<QStandardItem*> item = _tableModel->takeRow(id);
+ QStandardItem* txt = item.at(2);
+ txt->setEditable(false);
+ _tableModel->insertRow(row, item);
+ tableView->resizeRowsToContents();
+ tableView->setColumnWidth(1, 20);
+ tableView->setColumnWidth(0, 1);
+ tableView->selectRow(row);
+ }
+}
+
+void MidiTrackInfo::updateSize()
+{
+ tableView->resizeRowsToContents();
+}
diff --git a/attic/muse2-oom/muse2/muse/widgets/mtrackinfo.h b/attic/muse2-oom/muse2/muse/widgets/mtrackinfo.h
new file mode 100644
index 00000000..a1303786
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/mtrackinfo.h
@@ -0,0 +1,91 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// (C) Copyright 2010 Werner Schweer and others (ws@seh.de)
+//=========================================================
+
+#ifndef __MTRACKINFO_H__
+#define __MTRACKINFO_H__
+
+#include "ui_mtrackinfobase.h"
+#include "pctablemodel.h"
+#include "pctable.h"
+
+class Track;
+class QTableView;
+class QStandardItem;
+
+//---------------------------------------------------------
+// MidiTrackInfo
+//---------------------------------------------------------
+
+class MidiTrackInfo : public QFrame/*QWidget*/, public Ui::MidiTrackInfoBase
+{
+ Q_OBJECT
+ Track* selected;
+ bool _midiDetect;
+ int program, pan, volume;
+ int _progRowNum;
+ ProgramChangeTable* tableView;
+ QList<int>* _matrix;
+ ProgramChangeTableModel* _tableModel;
+ bool editing;
+
+ private slots:
+ void iOutputChannelChanged(int);
+ void iOutputPortChanged(int);
+ void iProgHBankChanged();
+ void iProgLBankChanged();
+ void iProgramChanged();
+ void iProgramDoubleClicked();
+ void iLautstChanged(int);
+ void iLautstDoubleClicked();
+ void iTranspChanged(int);
+ void iAnschlChanged(int);
+ void iVerzChanged(int);
+ void iLenChanged(int);
+ void iKomprChanged(int);
+ void iPanChanged(int);
+ void iPanDoubleClicked();
+ void recordClicked();
+ void volRecClicked();
+ void panRecClicked();
+ void recEchoToggled(bool);
+ void inRoutesPressed();
+ void outRoutesPressed();
+ void routingPopupMenuActivated(QAction*);
+ //void routingPopupViewActivated(const QModelIndex&);
+ void toggleAdvanced(int);
+ void matrixItemChanged(QStandardItem*);
+ void rebuildMatrix();
+ void deleteSelectedPatches(bool);
+ void movePatchUp(bool);
+ void movePatchDown(bool);
+
+ protected slots:
+ virtual void heartBeat();
+
+ public slots:
+ void setTrack(Track*);
+ void configChanged();
+ void instrPopup();
+ void progRecClicked();
+ void songChanged(int);
+ void insertMatrixEvent();
+ void updateSize();
+
+ signals:
+ void outputPortChanged(int);
+
+ public:
+ MidiTrackInfo(QWidget*, Track* = 0);
+ Track* track() const { return selected; }
+ void setLabelText();
+ void setLabelFont();
+ void updateTrackInfo(int);
+};
+
+
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/mtrackinfobase.ui b/attic/muse2-oom/muse2/muse/widgets/mtrackinfobase.ui
new file mode 100644
index 00000000..2ffa432c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/mtrackinfobase.ui
@@ -0,0 +1,1077 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MidiTrackInfoBase</class>
+ <widget class="QFrame" name="MidiTrackInfoBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>150</width>
+ <height>580</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>3</horstretch>
+ <verstretch>3</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: TrackInfo</string>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="trackNameLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Ignored" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>Track 1</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetMinAndMaxSize</enum>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="iPatch">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Select instrument patch</string>
+ </property>
+ <property name="text">
+ <string>Select Patch</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="tableBox">
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <property name="rightMargin">
+ <number>0</number>
+ </property>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="matrixActions">
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="btnUp">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>24</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="btnDown">
+ <property name="minimumSize">
+ <size>
+ <width>24</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::MinimumExpanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="btnDelete">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>24</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QCheckBox" name="chkAdvanced">
+ <property name="cursor">
+ <cursorShape>PointingHandCursor</cursorShape>
+ </property>
+ <property name="text">
+ <string>Advanced</string>
+ </property>
+ <property name="iconSize">
+ <size>
+ <width>16</width>
+ <height>16</height>
+ </size>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QFrame" name="frame">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="MinimumExpanding">
+ <horstretch>1</horstretch>
+ <verstretch>1</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_3">
+ <item>
+ <layout class="QGridLayout" name="advGrid" rowstretch="0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetMinimumSize</enum>
+ </property>
+ <property name="verticalSpacing">
+ <number>0</number>
+ </property>
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <item row="12" column="1">
+ <widget class="SpinBox" name="iTransp" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="specialValueText" stdset="0">
+ <string>off</string>
+ </property>
+ <property name="maximum" stdset="0">
+ <number>127</number>
+ </property>
+ <property name="minimum" stdset="0">
+ <number>-127</number>
+ </property>
+ <property name="value" stdset="0">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="12" column="2">
+ <widget class="QLabel" name="TextLabel9">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Transp.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="indent">
+ <number>2</number>
+ </property>
+ </widget>
+ </item>
+ <item row="13" column="1">
+ <widget class="SpinBox" name="iVerz" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="specialValueText" stdset="0">
+ <string>off</string>
+ </property>
+ <property name="maximum" stdset="0">
+ <number>1000</number>
+ </property>
+ <property name="minimum" stdset="0">
+ <number>-1000</number>
+ </property>
+ </widget>
+ </item>
+ <item row="13" column="2">
+ <widget class="QLabel" name="TextLabel10">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Delay</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="indent">
+ <number>2</number>
+ </property>
+ </widget>
+ </item>
+ <item row="14" column="1">
+ <widget class="SpinBox" name="iLen" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="suffix" stdset="0">
+ <string>%</string>
+ </property>
+ <property name="maximum" stdset="0">
+ <number>200</number>
+ </property>
+ <property name="minimum" stdset="0">
+ <number>25</number>
+ </property>
+ <property name="value" stdset="0">
+ <number>100</number>
+ </property>
+ </widget>
+ </item>
+ <item row="14" column="2">
+ <widget class="QLabel" name="TextLabel11">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Length</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="indent">
+ <number>2</number>
+ </property>
+ </widget>
+ </item>
+ <item row="15" column="1">
+ <widget class="SpinBox" name="iKompr" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="prefix" stdset="0">
+ <string/>
+ </property>
+ <property name="suffix" stdset="0">
+ <string>%</string>
+ </property>
+ <property name="maximum" stdset="0">
+ <number>200</number>
+ </property>
+ <property name="minimum" stdset="0">
+ <number>25</number>
+ </property>
+ <property name="value" stdset="0">
+ <number>100</number>
+ </property>
+ </widget>
+ </item>
+ <item row="15" column="2">
+ <widget class="QLabel" name="TextLabel13">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>50</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Compr.</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="indent">
+ <number>2</number>
+ </property>
+ </widget>
+ </item>
+ <item row="16" column="1">
+ <widget class="SpinBox" name="iAnschl" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="maximum" stdset="0">
+ <number>127</number>
+ </property>
+ <property name="minimum" stdset="0">
+ <number>-127</number>
+ </property>
+ <property name="value" stdset="0">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="16" column="2">
+ <widget class="QLabel" name="TextLabel12">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Velocity</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="indent">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="1">
+ <widget class="SpinBox" name="iPan" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Change stereo position. Double-click on/off.</string>
+ </property>
+ <property name="whatsThis">
+ <string>Change stereo position. Double-click on/off.</string>
+ </property>
+ <property name="specialValueText" stdset="0">
+ <string>off</string>
+ </property>
+ <property name="maximum" stdset="0">
+ <number>63</number>
+ </property>
+ <property name="minimum" stdset="0">
+ <number>-65</number>
+ </property>
+ <property name="value" stdset="0">
+ <number>-65</number>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="2">
+ <widget class="QToolButton" name="panRecButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Add pan setting to song</string>
+ </property>
+ <property name="text">
+ <string>Pan</string>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="1">
+ <widget class="SpinBox" name="iLautst" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Volume. Double-click on/off.</string>
+ </property>
+ <property name="specialValueText" stdset="0">
+ <string>off</string>
+ </property>
+ <property name="maximum" stdset="0">
+ <number>127</number>
+ </property>
+ <property name="minimum" stdset="0">
+ <number>-1</number>
+ </property>
+ <property name="value" stdset="0">
+ <number>-1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="2">
+ <widget class="QToolButton" name="volRecButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Add vol setting to song</string>
+ </property>
+ <property name="text">
+ <string>Vol</string>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="1">
+ <widget class="SpinBox" name="iProgram" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Program. Double-click on/off.</string>
+ </property>
+ <property name="specialValueText" stdset="0">
+ <string>off</string>
+ </property>
+ <property name="maximum" stdset="0">
+ <number>128</number>
+ </property>
+ <property name="minimum" stdset="0">
+ <number>0</number>
+ </property>
+ <property name="value" stdset="0">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="8" column="2">
+ <widget class="QToolButton" name="progRecButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Add bank + prog settings to song</string>
+ </property>
+ <property name="text">
+ <string>Prog</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1" colspan="2">
+ <widget class="QComboBox" name="iOutput">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Ignored" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>output port</string>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="SpinBox" name="iOutputChannel" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>output channel</string>
+ </property>
+ <property name="whatsThis">
+ <string>all midi events are sent to this output channel</string>
+ </property>
+ <property name="maximum" stdset="0">
+ <number>16</number>
+ </property>
+ <property name="minimum" stdset="0">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <property name="topMargin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="textLabel1">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Record:</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="5" column="2">
+ <widget class="QToolButton" name="recordButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Add all settings to song</string>
+ </property>
+ <property name="text">
+ <string>All</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1">
+ <widget class="SpinBox" name="iHBank" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Bank Select MSB. Double-click on/off.</string>
+ </property>
+ <property name="specialValueText" stdset="0">
+ <string>off</string>
+ </property>
+ <property name="maximum" stdset="0">
+ <number>128</number>
+ </property>
+ <property name="minimum" stdset="0">
+ <number>0</number>
+ </property>
+ <property name="value" stdset="0">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="2">
+ <widget class="QLabel" name="TextLabel4">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>50</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="lineWidth">
+ <number>1</number>
+ </property>
+ <property name="text">
+ <string>H-Bank</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="indent">
+ <number>2</number>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="1">
+ <widget class="SpinBox" name="iLBank" native="true">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Bank Select LSB. Double-click on/off.</string>
+ </property>
+ <property name="specialValueText" stdset="0">
+ <string>off</string>
+ </property>
+ <property name="maximum" stdset="0">
+ <number>128</number>
+ </property>
+ <property name="minimum" stdset="0">
+ <number>0</number>
+ </property>
+ <property name="value" stdset="0">
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item row="7" column="2">
+ <widget class="QLabel" name="TextLabel5">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>50</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>50</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="lineWidth">
+ <number>1</number>
+ </property>
+ <property name="text">
+ <string>L-Bank</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="indent">
+ <number>2</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetFixedSize</enum>
+ </property>
+ <item>
+ <widget class="QLabel" name="iChanDetectLabel">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>0</width>
+ <height>0</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>24</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>input detect</string>
+ </property>
+ <property name="whatsThis">
+ <string>Input detect indicator. Detects all note on-off, controller, aftertouch,
+ program change, and pitchbend (but not sysex or realtime) events
+ on the selected channels, on the selected midi ports.</string>
+ </property>
+ <property name="text">
+ <string>W</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QToolButton" name="recEchoButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>24</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>24</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>Midi thru</string>
+ </property>
+ <property name="whatsThis">
+ <string>Pass input events through ('thru') to output.</string>
+ </property>
+ <property name="checkable">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="2" column="1">
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetMinimumSize</enum>
+ </property>
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QToolButton" name="iRButton">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>24</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>24</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="toolTip">
+ <string>input routing</string>
+ </property>
+ <property name="text">
+ <string>In</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="2">
+ <widget class="QLabel" name="TextLabel2">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>20</width>
+ <height>24</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Out ch</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <property name="indent">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <customwidgets>
+ <customwidget>
+ <class>SpinBox</class>
+ <extends>QWidget</extends>
+ <header location="global">spinbox.h</header>
+ </customwidget>
+ </customwidgets>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/mtscale.cpp b/attic/muse2-oom/muse2/muse/widgets/mtscale.cpp
new file mode 100644
index 00000000..8f27329f
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/mtscale.cpp
@@ -0,0 +1,424 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mtscale.cpp,v 1.8.2.7 2009/05/03 04:14:01 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <values.h>
+
+#include <QMouseEvent>
+#include <QPainter>
+
+#include "mtscale.h"
+#include "song.h"
+#include "icons.h"
+#include "gconfig.h"
+
+//---------------------------------------------------------
+// MTScale
+// Midi Time Scale
+//---------------------------------------------------------
+
+MTScale::MTScale(int* r, QWidget* parent, int xs, bool _mode)
+ : View(parent, xs, 1)
+ {
+ waveMode = _mode;
+ setToolTip(tr("bar scale"));
+ barLocator = false;
+ raster = r;
+ if (waveMode) {
+ pos[0] = tempomap.tick2frame(song->cpos());
+ pos[1] = tempomap.tick2frame(song->lpos());
+ pos[2] = tempomap.tick2frame(song->rpos());
+ }
+ else {
+ pos[0] = song->cpos();
+ pos[1] = song->lpos();
+ pos[2] = song->rpos();
+ }
+ pos[3] = MAXINT; // do not show
+ button = Qt::NoButton;
+ setMouseTracking(true);
+ connect(song, SIGNAL(posChanged(int, unsigned, bool)), SLOT(setPos(int, unsigned, bool)));
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+ connect(song, SIGNAL(markerChanged(int)), SLOT(redraw()));
+
+ setFixedHeight(28);
+ //setBg(QColor(53, 51, 56));
+ setBg(QColor(150, 176, 187));
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void MTScale::songChanged(int type)
+ {
+ if (type & (SC_SIG|SC_TEMPO)) {
+ if ((type & SC_TEMPO) && waveMode) {
+ pos[0] = tempomap.tick2frame(song->cpos());
+ pos[1] = tempomap.tick2frame(song->lpos());
+ pos[2] = tempomap.tick2frame(song->rpos());
+ }
+ redraw();
+ }
+ }
+
+//---------------------------------------------------------
+// setPos
+//---------------------------------------------------------
+
+void MTScale::setPos(int idx, unsigned val, bool)
+ {
+ if (val == MAXINT) {
+ if (idx == 3) {
+ pos[3] = MAXINT;
+ redraw(QRect(0, 0, width(), height()));
+ }
+ return;
+ }
+ if (waveMode)
+ val = tempomap.tick2frame(val);
+ if (val == pos[idx])
+ return;
+ //unsigned opos = mapx(pos[idx] == MAXINT ? val : pos[idx]);
+ int opos = mapx(pos[idx] == MAXINT ? val : pos[idx]);
+ pos[idx] = val;
+ if (!isVisible())
+ return;
+
+ int tval = mapx(val);
+ int x = -9;
+ int w = 18;
+
+ if (tval < 0) { // tval<0 occurs whenever the window is scrolled left, so I switched to signed int (ml)
+ //printf("MTScale::setPos - idx:%d val:%d tval:%d opos:%d w:%d h:%d\n", idx, val, tval, opos, width(), height());
+
+ redraw(QRect(0,0,width(),height()));
+ return;
+ }
+ //if (opos > (unsigned int) tval) { //prevent compiler warning: comparison signed/unsigned
+ if (opos > tval) {
+ w += opos - tval;
+ x += tval;
+ }
+ else {
+ w += tval - opos;
+ x += opos;
+ }
+ //printf("MTScale::setPos idx:%d val:%d tval:%d opos:%d x:%d w:%d h:%d\n", idx, val, tval, opos, x, w, height());
+
+ redraw(QRect(x, 0, w, height()));
+ }
+
+//---------------------------------------------------------
+// viewMousePressEvent
+//---------------------------------------------------------
+
+void MTScale::viewMousePressEvent(QMouseEvent* event)
+ {
+ button = event->button();
+ viewMouseMoveEvent(event);
+ }
+
+//---------------------------------------------------------
+// viewMouseReleaseEvent
+//---------------------------------------------------------
+
+void MTScale::viewMouseReleaseEvent(QMouseEvent*)
+ {
+ button = Qt::NoButton;
+ }
+
+//---------------------------------------------------------
+// viewMouseMoveEvent
+//---------------------------------------------------------
+
+void MTScale::viewMouseMoveEvent(QMouseEvent* event)
+ {
+ if (event->modifiers() & Qt::ShiftModifier )
+ setCursor(QCursor(Qt::PointingHandCursor));
+ else
+ setCursor(QCursor(Qt::ArrowCursor));
+
+ int x = event->x();
+ if (waveMode)
+ x = tempomap.frame2tick(x);
+ x = AL::sigmap.raster(x, *raster);
+ if (x < 0)
+ x = 0;
+ //printf("MTScale::viewMouseMoveEvent\n");
+ emit timeChanged(x);
+ int i;
+ switch (button) {
+ case Qt::LeftButton:
+ i = 0;
+ break;
+ case Qt::MidButton:
+ i = 1;
+ break;
+ case Qt::RightButton:
+ i = 2;
+ break;
+ default:
+ return; // if no button is pressed the function returns here
+ }
+ Pos p(x, true);
+
+ if(i== 0 && (event->modifiers() & Qt::ShiftModifier )) { // If shift +LMB we add a marker
+ Marker *alreadyExists = song->getMarkerAt(x);
+ if (!alreadyExists) {
+ song->addMarker(QString(""), x, false);
+ // Removed p3.3.43
+ // Song::addMarker() already emits a 'markerChanged'.
+ //emit addMarker(x);
+ }
+ }
+ else if (i== 2 && (event->modifiers() & Qt::ShiftModifier )) { // If shift +RMB we remove a marker
+ Marker *toRemove = song->getMarkerAt(x);
+ if (toRemove)
+ song->removeMarker(toRemove);
+ else
+ printf("No marker to remove\n");
+ }
+ else
+ song->setPos(i, p); // all other cases: relocating one of the locators
+ }
+
+//---------------------------------------------------------
+// leaveEvent
+//---------------------------------------------------------
+
+void MTScale::leaveEvent(QEvent*)
+ {
+ emit timeChanged(MAXINT);
+ }
+
+//---------------------------------------------------------
+// draw
+//---------------------------------------------------------
+
+void MTScale::pdraw(QPainter& p, const QRect& r)
+ {
+ QColor colTimeLine = QColor(0,0,0);
+ int x = r.x();
+ int w = r.width();
+
+ // Added by Tim. p3.3.6
+ //printf("MTScale::pdraw x:%d w:%d\n", x, w);
+
+ x -= 20;
+ w += 40; // wg. Text
+
+ //---------------------------------------------------
+ // draw Marker
+ //---------------------------------------------------
+
+ int y = 12;
+ //p.setPen(QColor(255,255,255));
+ p.setPen(colTimeLine);
+ p.setFont(config.fonts[4]);
+ p.drawLine(r.x(), y+1, r.x() + r.width(), y+1);
+ QRect tr(r);
+ tr.setHeight(12);
+ MarkerList* marker = song->marker();
+ for (iMarker m = marker->begin(); m != marker->end(); ++m) {
+
+ int xp;
+ if(waveMode)
+ xp = mapx(m->second.frame());
+ else
+ xp = mapx(m->second.tick());
+ if (xp > x+w)
+ break;
+ int xe = r.x() + r.width();
+ iMarker mm = m;
+ ++mm;
+ if (mm != marker->end()) {
+
+ if(waveMode)
+ xe = mapx(tempomap.tick2frame(mm->first));
+ else
+ xe = mapx(mm->first);
+ }
+
+ QRect tr(xp, 0, xe-xp, 13);
+ //if (m->second.current())
+ // p.fillRect(tr, white);
+
+ QRect wr = r.intersect(tr);
+ //if (r.intersects(tr))
+ if(!wr.isEmpty())
+ {
+ if (m->second.current())
+ {
+ //p.fillRect(tr, white);
+ p.fillRect(wr, QColor(89,89,102));
+ }
+
+ int x2;
+ //iMarker mm = m;
+ //++mm;
+ if (mm != marker->end())
+ {
+ if(waveMode)
+ x2 = mapx(tempomap.tick2frame(mm->first));
+ else
+ x2 = mapx(mm->first);
+ }
+ else
+ x2 = xp+200;
+
+ //printf("MTScale::pdraw marker %s xp:%d y:%d h:%d r.x:%d r.w:%d\n", m->second.name().toLatin1(), xp, height(), y, r.x(), r.width());
+
+ // Must be reasonable about very low negative x values! With long songs > 15min
+ // and with high horizontal magnification, 'ghost' drawings appeared,
+ // apparently the result of truncation later (xp = -65006 caused ghosting
+ // at bar 245 with magnification at max.), even with correct clipping region
+ // applied to painter in View::paint(). Tim. Apr 5 2009
+ // Quote: "Warning: Note that QPainter does not attempt to work around
+ // coordinate limitations in the underlying window system. Some platforms may
+ // behave incorrectly with coordinates as small as +/-4000."
+ if(xp >= -32)
+ p.drawPixmap(xp, 0, *flagIconS);
+
+ if(xp >= -1023)
+ {
+ QRect r = QRect(xp+10, 0, x2-xp, 12);
+ //p.setPen(QColor(220,222,223));
+ //p.setPen(QColor(255,255,255));
+ p.setPen(colTimeLine);
+ p.drawText(r, Qt::AlignLeft|Qt::AlignVCenter, m->second.name());
+ }
+
+ if(xp >= 0)
+ {
+ p.setPen(QColor(243,191,124));
+ p.drawLine(xp, y, xp, height());
+ }
+ }
+ }
+
+ //---------------------------------------------------
+ // draw location marker
+ //---------------------------------------------------
+
+ int h = height()-12;
+
+ if (barLocator) {
+ p.setPen(Qt::red);
+ int xp = mapx(pos[0]);
+ if (xp >= x && xp < x+w)
+ p.drawLine(xp, y, xp, h);
+ p.setPen(Qt::blue);
+ xp = mapx(pos[1]);
+ if (xp >= x && xp < x+w)
+ p.drawLine(xp, y, xp, h);
+ xp = mapx(pos[2]);
+ if (xp >= x && xp < x+w)
+ p.drawLine(xp, y, xp, h);
+ }
+ else {
+ for (int i = 0; i < 3; ++i) {
+ int xp = mapx(pos[i]);
+ if (xp >= x && xp < x+w) {
+ QPixmap* pm = markIcon[i];
+ p.drawPixmap(xp - pm->width()/2, y-1, *pm);
+ }
+ }
+ }
+ //p.setPen(QColor(220,222,223));
+ p.setPen(colTimeLine);
+ if (pos[3] != MAXINT) {
+ int xp = mapx(pos[3]);
+ if (xp >= x && xp < x+w)
+ p.drawLine(xp, 0, xp, height());
+ }
+
+ unsigned ctick;
+ int bar1, bar2, beat;
+ unsigned tick;
+
+ if (waveMode) {
+ ctick = tempomap.frame2tick(mapxDev(x));
+ AL::sigmap.tickValues(ctick, &bar1, &beat, &tick);
+ AL::sigmap.tickValues(tempomap.frame2tick(mapxDev(x+w)),
+ &bar2, &beat, &tick);
+ }
+ else {
+ ctick = mapxDev(x);
+ AL::sigmap.tickValues(ctick, &bar1, &beat, &tick);
+ AL::sigmap.tickValues(mapxDev(x+w), &bar2, &beat, &tick);
+ }
+
+//printf("bar %d %d-%d=%d\n", bar, ntick, stick, ntick-stick);
+
+ int stick = AL::sigmap.bar2tick(bar1, 0, 0);
+ int ntick;
+ for (int bar = bar1; bar <= bar2; bar++, stick = ntick) {
+ ntick = AL::sigmap.bar2tick(bar+1, 0, 0);
+ int tpix, a, b=0;
+ if (waveMode) {
+ a = tempomap.tick2frame(ntick);
+ b = tempomap.tick2frame(stick);
+ tpix = rmapx(a - b);
+ }
+ else {
+ tpix = rmapx(ntick - stick);
+ }
+ if (tpix < 64) {
+ // donÃŊÂŋÂ―t show beats if measure is this small
+ int n = 1;
+ if (tpix < 32)
+ n = 2;
+ if (tpix <= 16)
+ n = 4;
+ if (tpix < 8)
+ n = 8;
+ if (tpix <= 4)
+ n = 16;
+ if (tpix <= 2)
+ n = 32;
+ if (bar % n)
+ continue;
+ p.setFont(config.fonts[3]);
+ int x = mapx(waveMode ? b : stick);
+ QString s;
+ s.setNum(bar + 1);
+ p.drawLine(x, y+1, x, y+1+h);
+// QRect r = QRect(x+2, y, 0, h);
+ QRect r = QRect(x+2, y, 1000, h);
+ p.drawText(r, Qt::AlignLeft|Qt::AlignVCenter|Qt::TextDontClip, s);
+ }
+ else {
+ int z, n;
+ AL::sigmap.timesig(stick, z, n);
+ for (int beat = 0; beat < z; beat++) {
+ int xx = AL::sigmap.bar2tick(bar, beat, 0);
+ if (waveMode)
+ xx = tempomap.tick2frame(xx);
+ int xp = mapx(xx);
+ QString s;
+ QRect r(xp+2, y, 1000, h);
+ int y1;
+ int num;
+ if (beat == 0) {
+ num = bar + 1;
+ y1 = y + 1;
+ p.setFont(config.fonts[3]);
+ }
+ else {
+ num = beat + 1;
+ y1 = y + 7;
+ p.setFont(config.fonts[1]);
+ r.setY(y+3);
+ }
+ s.setNum(num);
+ p.drawLine(xp, y1, xp, y+1+h);
+ p.drawText(r, Qt::AlignLeft|Qt::AlignVCenter|Qt::TextDontClip, s);
+ }
+ }
+ }
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/mtscale.h b/attic/muse2-oom/muse2/muse/widgets/mtscale.h
new file mode 100644
index 00000000..7c53d4ff
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/mtscale.h
@@ -0,0 +1,49 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mtscale.h,v 1.3 2004/04/27 22:27:06 spamatica Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MTSCALE_H__
+#define __MTSCALE_H__
+
+#include "view.h"
+
+
+//---------------------------------------------------------
+// MTScale
+// scale for midi track
+//---------------------------------------------------------
+
+class MTScale : public View {
+ Q_OBJECT
+ int* raster;
+ unsigned pos[4];
+ int button;
+ bool barLocator;
+ bool waveMode;
+
+ private slots:
+ void songChanged(int);
+
+ protected:
+ virtual void pdraw(QPainter&, const QRect&);
+ virtual void viewMousePressEvent(QMouseEvent* event);
+ virtual void viewMouseMoveEvent(QMouseEvent* event);
+ virtual void viewMouseReleaseEvent(QMouseEvent* event);
+ virtual void leaveEvent(QEvent*e);
+
+ signals:
+ void timeChanged(unsigned);
+ //void addMarker(int);
+
+ public slots:
+ void setPos(int, unsigned, bool);
+
+ public:
+ MTScale(int* raster, QWidget* parent, int xscale, bool f = false);
+ void setBarLocator(bool f) { barLocator = f; }
+ };
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/musewidgetsplug.cpp b/attic/muse2-oom/muse2/muse/widgets/musewidgetsplug.cpp
new file mode 100644
index 00000000..4b61cf2a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/musewidgetsplug.cpp
@@ -0,0 +1,572 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: musewidgetsplug.cpp,v 1.9.2.9 2009/12/01 03:52:40 terminator356 Exp $
+// (C) Copyright 2001-2003 Werner Schweer (ws@seh.de)
+//=========================================================
+
+// this file makes some of the MusE widgets available
+// to QT-Designer
+
+// #include <qwidgetplugin.h>
+#include <QtCore/QtPlugin> // p4.0.2
+#include <QtDesigner/QDesignerCustomWidgetInterface> //
+#include <QPixmap>
+
+#include "poslabel.h"
+#include "pitchedit.h"
+#include "pitchlabel.h"
+#include "sig.h"
+#include "tempo.h"
+#include "tempolabel.h"
+#include "sigedit.h"
+#include "slider.h"
+#include "doublelabel.h"
+#include "checkbox.h"
+#include "combobox.h"
+#include "gconfig.h"
+
+int sampleRate = 44100; // some dummy values to get things compiled/linked
+int division = 384;
+int mtcType = 0;
+bool hIsB = false;
+
+static const char* vall[] = {
+ "c","c#","d","d#","e","f","f#","g","g#","a","a#","h"
+ };
+static const char* valu[] = {
+ "C","C#","D","D#","E","F","F#","G","G#","A","A#","H"
+ };
+
+GlobalConfigValues config = {
+ 190, // globalAlphaBlend
+ {
+ QColor(0xff, 0xff, 0xff), // palette
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff),
+ QColor(0xff, 0xff, 0xff)
+ },
+ {
+ QColor(255, 232, 140), // part colors
+ QColor(0xff, 0x00, 0x00),
+ QColor(0x00, 0xff, 0x00),
+ QColor(0x00, 0x00, 0xff),
+ QColor(0xff, 0xff, 0x00),
+ QColor(0x00, 0xff, 0xff),
+ QColor(0xff, 0x00, 0xff),
+ QColor(0x9f, 0xc7, 0xef),
+ QColor(0x00, 0xff, 0x7f),
+ QColor(0x7f, 0x00, 0x00),
+ QColor(0x00, 0x7f, 0x00),
+ QColor(0x00, 0x00, 0x7f),
+ QColor(0x7f, 0x7f, 0x3f),
+ QColor(0x00, 0x7f, 0x7f),
+ QColor(0x7f, 0x00, 0x7f),
+ QColor(0x00, 0x7f, 0xff),
+ QColor(0x00, 0x3f, 0x3f)
+ },
+ {
+ QString("Default"), // Default part color names
+ QString("Refrain"),
+ QString("Bridge"),
+ QString("Intro"),
+ QString("Coda"),
+ QString("Chorus"),
+ QString("Solo"),
+ QString("Brass"),
+ QString("Percussion"),
+ QString("Drums"),
+ QString("Guitar"),
+ QString("Bass"),
+ QString("Flute"),
+ QString("Strings"),
+ QString("Keyboard"),
+ QString("Piano"),
+ QString("Saxophone")
+ },
+ QColor(0, 0, 255), // transportHandleColor;
+ QColor(255, 0, 0), // bigTimeForegroundColor;
+ QColor(0, 0, 0), // bigTimeBackgroundColor;
+ QColor(200, 200, 200), // waveEditBackgroundColor;
+ {
+ QFont(QString("arial"), 10, QFont::Normal),
+ QFont(QString("arial"), 8, QFont::Normal),
+ QFont(QString("arial"), 10, QFont::Normal),
+ QFont(QString("arial"), 10, QFont::Bold),
+ QFont(QString("arial"), 8, QFont::Bold), // timescale numbers
+ QFont(QString("Lucidatypewriter"), 14, QFont::Bold),
+ QFont(QString("arial"), 8, QFont::Bold, true) // Mixer strip labels. Looks and fits better with bold + italic than bold alone,
+ // at the price of only few more pixels than Normal mode.
+ },
+ QColor(0xff, 0xff, 0xff), // trackBg;
+ QColor(0x80, 0xff, 0x80), // selected track Bg;
+ QColor(0x00, 0x00, 0x00), // selected track Fg;
+
+ QColor(0, 160, 255), // midiTrackLabelBg; // Med blue
+ QColor(0, 160, 255), // drumTrackLabelBg; // Med blue
+ Qt::magenta, // waveTrackLabelBg;
+ Qt::green, // outputTrackLabelBg;
+ Qt::red, // inputTrackLabelBg;
+ Qt::yellow, // groupTrackLabelBg;
+ QColor(120, 255, 255), // auxTrackLabelBg; // Light blue
+ QColor(255, 130, 0), // synthTrackLabelBg; // Med orange
+
+ QColor(220, 220, 220), // midiTrackBg;
+ QColor(220, 220, 220), // drumTrackBg;
+ QColor(220, 220, 220), // waveTrackBg;
+ QColor(189, 220, 193), // outputTrackBg;
+ QColor(189, 220, 193), // inputTrackBg;
+ QColor(220, 220, 220), // groupTrackBg;
+ QColor(220, 220, 220), // auxTrackBg;
+ QColor(220, 220, 220), // synthTrackBg;
+
+ QColor(98, 124, 168), // part canvas bg
+ QColor(255, 170, 0), // ctrlGraphFg; Medium orange
+ QColor(98, 124, 168), // mixerBg;
+
+ 384, // division;
+ 1024, // rtcTicks
+ -60, // int minMeter;
+ -60.0, // double minSlider;
+ false, // use Jack freewheel
+ 20, // int guiRefresh;
+ QString(""), // helpBrowser
+ true, // extendedMidi
+ 384, // division for smf export
+ QString(""), // copyright string for smf export
+ 1, // smf export file format
+ false, // midi export file 2 byte timesigs instead of 4
+ true, // optimize midi export file note offs
+ true, // Split imported tracks into multiple parts.
+ 1, // startMode
+ QString(""), // start song path
+ 384, // gui division
+ QRect(0, 0, 400, 300), // GeometryMain;
+ QRect(0, 0, 200, 100), // GeometryTransport;
+ QRect(0, 0, 600, 200), // GeometryBigTime;
+ QRect(0, 0, 400, 300), // GeometryPianoroll;
+ QRect(0, 0, 400, 300), // GeometryDrumedit;
+ //QRect(0, 0, 300, 500), // GeometryMixer; // Obsolete
+ {
+ QString("Mixer A"),
+ QRect(0, 0, 300, 500), // Mixer1
+ true, true, true, true,
+ true, true, true, true
+ },
+ {
+ QString("Mixer B"),
+ QRect(200, 200, 300, 500), // Mixer2
+ true, true, true, true,
+ true, true, true, true
+ },
+ true, // TransportVisible;
+ false, // BigTimeVisible;
+ false, // mixer1Visible;
+ false, // mixer2Visible;
+
+ false, // markerVisible; // This line was missing 2007-01-08 (willyfoobar)
+ true, // showSplashScreen
+ 1, // canvasShowPartType 1 - names, 2 events
+ 5, // canvasShowPartEvent
+ false, // canvasShowGrid;
+ QString(""), // canvasBgPixmap;
+ QString(""), // styleSheetFile
+ QString(""), // style
+ QString(""), // externalWavEditor //this line was missing 2007-01-08 (willyfoobar)
+ false, // useOldStyleStopShortCut
+ true, // moveArmedCheckBox
+ true, // useDenormalBias
+ false, // useOutputLimiter
+ true, // showDidYouKnow
+ false, // vstInPlace Enable VST in-place processing
+ 44100, // Dummy audio preferred sample rate
+ 512 // Dummy audio buffer size
+ };
+
+//---------------------------------------------------------
+// pitch2string
+//---------------------------------------------------------
+
+QString pitch2string(int v)
+ {
+ if (v < 0 || v > 127)
+ return QString("----");
+ int octave = (v / 12) - 2;
+ QString o;
+ o.sprintf("%d", octave);
+ int i = v % 12;
+ QString s(octave < 0 ? valu[i] : vall[i]);
+ if (hIsB) {
+ if (s == "h")
+ s = "b";
+ else if (s == "H")
+ s = "B";
+ }
+ return s + o;
+ }
+
+
+/* XPM */
+static const char* slider_pixmap[]={
+"22 22 50 1",
+". c None",
+"f c #004005",
+"g c #004007",
+"h c #004107",
+"m c #004108",
+"j c #00430a",
+"E c #00501f",
+"s c #005021",
+"e c #014006",
+"l c #024006",
+"F c #095e34",
+"D c #0b572a",
+"k c #0b582b",
+"n c #0f5328",
+"u c #12562d",
+"o c #155a35",
+"p c #165c38",
+"q c #165c39",
+"i c #17501a",
+"I c #175522",
+"r c #18603f",
+"N c #18795e",
+"t c #187a60",
+"R c #1e5a29",
+"y c #22633d",
+"O c #307755",
+"B c #408262",
+"v c #439191",
+"G c #468667",
+"d c #4c7a51",
+"H c #4d8a6c",
+"J c #569174",
+"C c #599276",
+"P c #5e967a",
+"A c #63b1c2",
+"V c #659477",
+"Q c #659b80",
+"S c #6da087",
+"w c #70b2bc",
+"x c #72b5c0",
+"z c #74b7c3",
+"K c #79a891",
+"a c #7ea48a",
+"T c #8cb4a0",
+"L c #a3c3b3",
+"M c #b7d8d1",
+"U c #bedcd5",
+"c c #c3d2c3",
+"b c #f1f5f1",
+"# c #ffffff",
+"......................",
+"......................",
+"......................",
+"......................",
+"......................",
+"......###a............",
+"......#bcad...........",
+"......#bcad...........",
+"......#bcad...........",
+"..efgh#bcaihhhhhhhjk..",
+".lmnop#bcaippppppqrst.",
+".huvwx#bcayxxxxxxzABC.",
+".DEFGH#bcaIHHHHHHJKLM.",
+"..NOPQ#bcaRQQQQQQSTU..",
+"......#bcad...........",
+"......#bcad...........",
+"......#bcad...........",
+"......VVVVd...........",
+".......dddd...........",
+"......................",
+"......................",
+"......................"};
+static const char *posedit_pixmap[] = {
+ "22 22 8 1",
+ " c Gray100",
+ ". c Gray97",
+ "X c #4f504f",
+ "o c #00007f",
+ "O c Gray0",
+ "+ c none",
+ "@ c Gray0",
+ "# c Gray0",
+ "++++++++++++++++++++++",
+ "++++++++++++++++++++++",
+ "++++++++++++++++++++++",
+ "++++++++++++++++++++++",
+ "+OOOOOOOOOOOOOOOOOOOO+",
+ "OOXXXXXXXXXXXXXXXXXXOO",
+ "OXX. OO OO O",
+ "OX. oo O O",
+ "OX. oo O .O",
+ "OX ooo oooo O O",
+ "OX oo oo oo O O",
+ "OX oooo oo oo O O",
+ "OX oo oo oo oo O O",
+ "OX oo oo oo oo O O",
+ "OX oooo oooo O O",
+ "OX OO OO O",
+ "OO..................OO",
+ "+OOOOOOOOOOOOOOOOOOOO+",
+ "++++++++++++++++++++++",
+ "++++++++++++++++++++++",
+ "++++++++++++++++++++++",
+ "++++++++++++++++++++++"
+ };
+
+static const char *pitchedit_pixmap[] = {
+ "22 22 8 1",
+ " c Gray100",
+ ". c Gray97",
+ "X c #4f504f",
+ "o c #00007f",
+ "O c Gray0",
+ "+ c none",
+ "@ c Gray0",
+ "# c Gray0",
+ "++++++++++++++++++++++",
+ "++++++++++++++++++++++",
+ "++++++++++++++++++++++",
+ "++++++++++++++++++++++",
+ "+OOOOOOOOOOOOOOOOOOOO+",
+ "OOXXXXXXXXXXXXXXXXXXOO",
+ "OXX. OO OO O",
+ "OX. o O O",
+ "OX. oo O .O",
+ "OX o o O O",
+ "OX o O O",
+ "OX o o O O",
+ "OX oooo O O",
+ "OX o O O",
+ "OX O O",
+ "OX OO OO O",
+ "OO..................OO",
+ "+OOOOOOOOOOOOOOOOOOOO+",
+ "++++++++++++++++++++++",
+ "++++++++++++++++++++++",
+ "++++++++++++++++++++++",
+ "++++++++++++++++++++++"
+ };
+
+//---------------------------------------------------------
+// MusEPlugin
+//---------------------------------------------------------
+
+class MusEPlugin : public QWidgetPlugin {
+ public:
+ MusEPlugin() {}
+ ~MusEPlugin() {}
+ QStringList keys() const;
+ QWidget* create(const QString& key, QWidget* parent=0,
+ const char* name = 0);
+ QString group(const QString& key) const;
+ QIcon iconSet(const QString& key) const;
+ QString includeFile(const QString& key) const;
+ QString toolTip(const QString& key) const;
+ QString whatsThis(const QString& key) const;
+ bool isContainer(const QString& key) const;
+ };
+
+//---------------------------------------------------------
+// keys
+//---------------------------------------------------------
+
+QStringList MusEPlugin::keys() const
+ {
+ QStringList list;
+ list << QString("PosEdit")
+ << QString("PitchEdit")
+ << QString("PosLabel")
+ << QString("PitchLabel")
+ << QString("TempoLabel")
+ << QString("TempoEdit")
+ << QString("SigEdit")
+ << QString("Slider")
+ << QString("DoubleLabel")
+ << QString("CheckBox")
+ << QString("ComboBox")
+ ;
+ return list;
+ }
+
+//---------------------------------------------------------
+// create
+//---------------------------------------------------------
+
+QWidget* MusEPlugin::create(const QString& key, QWidget* parent,
+ const char* name)
+ {
+ if (key == QString("PosEdit"))
+ return new PosEdit(parent, name);
+ else if (key == QString("PitchEdit"))
+ return new PitchEdit(parent, name);
+ else if (key == QString("PitchLabel"))
+ return new PitchLabel(parent, name);
+ else if (key == QString("PosLabel"))
+ return new PosLabel(parent, name);
+ else if (key == QString("TempoLabel"))
+ return new TempoLabel(parent, name);
+ else if (key == QString("TempoEdit"))
+ return new TempoEdit(parent, name);
+ else if (key == QString("SigEdit"))
+ return new SigEdit(parent, name);
+ else if (key == QString("Slider"))
+ return new Slider(parent, name);
+ else if (key == QString("DoubleLabel"))
+ return new DoubleLabel(parent, name);
+ else if (key == QString("CheckBox"))
+ return new CheckBox(parent, -1, name);
+ else if (key == QString("ComboBox"))
+ return new ComboBox(parent, name);
+ return 0;
+ }
+
+//---------------------------------------------------------
+// group
+//---------------------------------------------------------
+
+QString MusEPlugin::group(const QString& /*key*/) const
+ {
+ return QString("MusE");
+ }
+
+//---------------------------------------------------------
+// iconSet
+//---------------------------------------------------------
+
+QIcon MusEPlugin::iconSet(const QString& key) const
+ {
+ if (key == "PosEdit" || key == "PosLabel")
+ return QIcon(QPixmap(posedit_pixmap));
+ else if (key == "PitchEdit" || key == "PitchLabel")
+ return QIcon(QPixmap(pitchedit_pixmap));
+ else if (key == "TempoEdit" || key == "TempoLabel")
+ return QIcon(QPixmap(pitchedit_pixmap));
+ else if (key == "SigEdit")
+ return QIcon(QPixmap(pitchedit_pixmap));
+ else if (key == QString("Slider"))
+ return QIcon(QPixmap(slider_pixmap));
+// else if (key == QString("CheckBox"))
+// return QIconSet(QPixmap(slider_pixmap));
+// else if (key == QString("ComboBox"))
+// return QIconSet(QPixmap(slider_pixmap));
+ return QIcon();
+ }
+
+//---------------------------------------------------------
+// includeFile
+//---------------------------------------------------------
+
+QString MusEPlugin::includeFile(const QString& key) const
+ {
+ if (key == QString("PosEdit"))
+ return QString("posedit.h");
+ else if (key == QString("PitchEdit"))
+ return QString("pitchedit.h");
+ else if (key == QString("PitchLabel"))
+ return QString("pitchlabel.h");
+ else if (key == QString("PosLabel"))
+ return QString("poslabel.h");
+ else if (key == QString("TempoLabel"))
+ return QString("tempolabel.h");
+ else if (key == QString("TempoEdit"))
+ return QString("tempolabel.h");
+ else if (key == QString("SigEdit"))
+ return QString("sigedit.h");
+ else if (key == QString("Slider"))
+ return QString("slider.h");
+ else if (key == QString("DoubleLabel"))
+ return QString("dentry.h");
+ else if (key == QString("CheckBox"))
+ return QString("checkbox.h");
+ else if (key == QString("ComboBox"))
+ return QString("combobox.h");
+ return QString::null;
+ }
+
+//---------------------------------------------------------
+// toolTip
+//---------------------------------------------------------
+
+QString MusEPlugin::toolTip (const QString& key) const
+ {
+ if (key == QString("PosEdit"))
+ return QString("midi time position editor");
+ else if (key == QString("PitchEdit"))
+ return QString("midi pitch spinbox");
+ else if (key == QString("PitchLabel"))
+ return QString("midi pitch label");
+ else if (key == QString("PosLabel"))
+ return QString("midi time position label");
+ else if (key == QString("TempoLabel"))
+ return QString("midi tempo label");
+ else if (key == QString("TempoEdit"))
+ return QString("midi tempo spinbox");
+ else if (key == QString("SigEdit"))
+ return QString("midi signature spinbox");
+ else if (key == QString("Slider"))
+ return QString("slider for double values");
+ else if (key == QString("DoubleLabel"))
+ return QString("entry/label for double values");
+ else if (key == QString("CheckBox"))
+ return QString("checkbox with id");
+ else if (key == QString("ComboBox"))
+ return QString("combobox with id");
+ return QString::null;
+ }
+
+//---------------------------------------------------------
+// whatsThis
+//---------------------------------------------------------
+
+QString MusEPlugin::whatsThis (const QString& key) const
+ {
+ if (key == QString("PosEdit"))
+ return QString("midi time position editor");
+ else if (key == QString("PitchEdit"))
+ return QString("midi pitch spinbox");
+ else if (key == QString("PitchLabel"))
+ return QString("midi pitch label");
+ else if (key == QString("PosLabel"))
+ return QString("midi time position label");
+ else if (key == QString("TempoLabel"))
+ return QString("midi tempo label");
+ else if (key == QString("TempoEdit"))
+ return QString("midi tempo spinbox");
+ else if (key == QString("SigEdit"))
+ return QString("midi signature spinbox");
+ else if (key == QString("Slider"))
+ return QString("slider for double values");
+ else if (key == QString("DoubleLabel"))
+ return QString("entry/label for double values");
+ else if (key == QString("CheckBox"))
+ return QString("checkbox with id");
+ else if (key == QString("ComboBox"))
+ return QString("combobox with id");
+ return QString::null;
+ }
+
+//---------------------------------------------------------
+// isContainer
+//---------------------------------------------------------
+
+bool MusEPlugin::isContainer (const QString& /*key*/) const
+ {
+ return false;
+ }
+
+Q_EXPORT_PLUGIN(MusEPlugin)
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/nentry.cpp b/attic/muse2-oom/muse2/muse/widgets/nentry.cpp
new file mode 100644
index 00000000..77710e5a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/nentry.cpp
@@ -0,0 +1,401 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: nentry.cpp,v 1.1.1.1.2.1 2008/05/21 00:28:54 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QApplication>
+#include <QHBoxLayout>
+#include <QLabel>
+#include <QLineEdit>
+#include <QMouseEvent>
+#include <QTimer>
+
+#include "nentry.h"
+
+#define TIMER1 400
+#define TIMER2 200
+#define TIMEC 7
+#define TIMER3 100
+#define TIMEC2 20
+#define TIMER4 50
+
+NentryFilter::NentryFilter(QObject* parent)
+ : QObject(parent)
+ {
+ }
+
+void Nentry::setText(const QString& s)
+ {
+ edit->setText(s);
+ }
+
+//---------------------------------------------------------
+// eventFilter
+//---------------------------------------------------------
+
+bool NentryFilter::eventFilter(QObject*, QEvent* event)
+ {
+ Nentry* e = (Nentry*)parent();
+ if (event->type() == QEvent::MouseButtonPress) {
+ e->mousePress((QMouseEvent*)event);
+ return true;
+ }
+ if (event->type() == QEvent::MouseMove) {
+ e->mouseMove((QMouseEvent*)event);
+ return true;
+ }
+ if (event->type() == QEvent::MouseButtonDblClick) {
+ e->mouseDoubleClick((QMouseEvent*)event);
+ return true;
+ }
+ if (event->type() == QEvent::MouseButtonRelease) {
+ e->mouseRelease((QMouseEvent*)event);
+ return true;
+ }
+ if (event->type() == QEvent::Wheel) {
+ e->wheel((QWheelEvent*)event);
+ return true;
+ }
+ if (event->type() == QEvent::KeyPress) {
+ return e->keyPress((QKeyEvent*)event);
+ }
+ if (event->type() == QEvent::ContextMenu) {
+ return e->contextMenu((QContextMenuEvent*)event);
+ }
+ return false;
+ }
+
+//---------------------------------------------------------
+// Nentry
+// lineedit int values
+//---------------------------------------------------------
+
+Nentry::Nentry(QWidget* parent, const QString& txt,
+ int _lPos, bool dark) : QFrame(parent)
+ {
+ focusW = 0;
+ lPos = _lPos;
+ edit = new QLineEdit(this);
+ timer = new QTimer(this);
+ filter = new NentryFilter(this);
+ drawFrame = false;
+ edit->installEventFilter(filter);
+ edit->setFrame(drawFrame);
+
+ connect(timer, SIGNAL(timeout()), SLOT(repeat()));
+ connect(edit, SIGNAL(returnPressed()), SLOT(endEdit()));
+ edit->setCursor(QCursor(Qt::ArrowCursor));
+// edit->setFont(font3);
+ val = 0;
+ layout = new QHBoxLayout(this);
+ if (txt == "") {
+ layout->addWidget(edit, 1, Qt::AlignHCenter);
+ }
+ else {
+ label = new QLabel(txt, this);
+ if (lPos == 0) {
+ layout->addStretch(5);
+ layout->addSpacing(5);
+ layout->addWidget(label);
+ layout->addSpacing(5);
+ layout->addWidget(edit);
+ layout->addSpacing(5);
+ layout->addStretch(5);
+ }
+ else {
+ label->setAlignment(Qt::AlignLeft);
+ layout->addWidget(edit, 0, Qt::AlignRight);
+ layout->addSpacing(5);
+ layout->addWidget(label, 100, Qt::AlignRight|Qt::AlignVCenter);
+ }
+ }
+ if (dark) {
+ setDark();
+ }
+ edit->setFocusPolicy(Qt::NoFocus);
+ }
+
+void Nentry::setFocusPolicy(Qt::FocusPolicy policy)
+ {
+ edit->setFocusPolicy(policy);
+ }
+
+void Nentry::setDark()
+ {
+ const QPalette& oldpalette = edit->palette();
+
+ const QColor& newcolor = oldpalette.color(QPalette::Window);
+ QPalette newpalette(oldpalette);
+ newpalette.setColor(QPalette::Base, newcolor);
+
+ edit->setPalette(newpalette);
+ }
+
+//---------------------------------------------------------
+// setSize
+//---------------------------------------------------------
+
+void Nentry::setSize(int n)
+ {
+ QString s("0000000000000000");
+ QFontMetrics fm = edit->fontMetrics();
+ int w;
+ if (n <= 16)
+ w = fm.width(s, n);
+ else
+ w = fm.width('0') * n;
+
+ edit->setFixedWidth(w + 14);
+ }
+
+//---------------------------------------------------------
+// setFrame
+//---------------------------------------------------------
+
+void Nentry::setFrame(bool flag)
+ {
+ drawFrame = flag;
+ edit->setFrame(drawFrame);
+ }
+
+//---------------------------------------------------------
+// endEdit
+//---------------------------------------------------------
+
+void Nentry::endEdit()
+ {
+ if (edit->isModified()) {
+ if (setSValue(edit->text())) {
+ setString(val, false);
+ return;
+ }
+ edit->setModified(false);
+ }
+ if (focusW)
+ focusW->setFocus();
+ focusW = 0;
+ edit->clearFocus();
+ if (!drawFrame)
+ edit->setFrame(false);
+ setString(val, false);
+ }
+
+//---------------------------------------------------------
+// contextMenuEvent
+//---------------------------------------------------------
+
+bool Nentry::contextMenu(QContextMenuEvent *e)
+{
+ e->accept();
+ return true;
+}
+//---------------------------------------------------------
+// mousePress
+//---------------------------------------------------------
+
+void Nentry::mousePress(QMouseEvent* event)
+ {
+ button = event->button();
+ starty = event->y();
+ evx = event->x();
+ if (event->button() == Qt::LeftButton) {
+ focusW = qApp->focusWidget();
+ edit->setFocus();
+ edit->setFrame(true);
+ setString(val, true);
+ }
+ else {
+ timecount = 0;
+ repeat();
+ timer->start(TIMER1);
+ }
+ }
+
+//---------------------------------------------------------
+// repeat
+//---------------------------------------------------------
+
+void Nentry::repeat()
+ {
+ if (timecount == 1) {
+ ++timecount;
+ timer->stop();
+ timer->start(TIMER2);
+ return;
+ }
+ ++timecount;
+ if (timecount == TIMEC) {
+ timer->stop();
+ timer->start(TIMER3);
+ }
+ if (timecount == TIMEC2) {
+ timer->stop();
+ timer->start(TIMER4);
+ }
+
+ switch (button) {
+ case Qt::LeftButton:
+ return;
+ case Qt::MidButton:
+ decValue(evx);
+ break;
+ case Qt::RightButton:
+ incValue(evx);
+ break;
+ default:
+ break;
+ }
+ if (focusW)
+ focusW->setFocus();
+ edit->clearFocus();
+ }
+
+//---------------------------------------------------------
+// mouseRelease
+//---------------------------------------------------------
+
+void Nentry::mouseRelease(QMouseEvent* event)
+ {
+ button = Qt::NoButton;
+ timer->stop();
+ if (event->button() != Qt::LeftButton) {
+ if (focusW)
+ focusW->setFocus();
+ edit->clearFocus();
+ }
+ }
+
+//---------------------------------------------------------
+// mouseMove
+//---------------------------------------------------------
+
+void Nentry::mouseMove(QMouseEvent*)
+ {
+ switch (button) {
+ case Qt::LeftButton:
+ break;
+ case Qt::MidButton:
+ break;
+ case Qt::RightButton:
+ break;
+ default:
+ break;
+ }
+ }
+
+//---------------------------------------------------------
+// mouseDoubleClick
+//---------------------------------------------------------
+
+void Nentry::mouseDoubleClick(QMouseEvent* event)
+ {
+ if (event->button() != Qt::LeftButton) {
+ mousePress(event);
+ return;
+ }
+ }
+
+//---------------------------------------------------------
+// wheel
+//---------------------------------------------------------
+
+void Nentry::wheel(QWheelEvent* event)
+ {
+ int n = event->delta();
+ if (n > 0)
+ incValue(n);
+ else
+ decValue(-n);
+ event->accept();
+ }
+
+//---------------------------------------------------------
+// setValue
+//---------------------------------------------------------
+
+void Nentry::setValue(int v)
+ {
+ if (v == val)
+ return;
+ if (setString(v)) {
+ if (!drawFrame)
+ edit->setFrame(false);
+ edit->setEnabled(false);
+ }
+ else {
+ edit->setEnabled(true);
+ }
+ val = v;
+ }
+
+//---------------------------------------------------------
+// keyPress
+//---------------------------------------------------------
+
+bool Nentry::keyPress(QKeyEvent* event)
+ {
+ bool shift = event->modifiers() & Qt::ShiftModifier;
+ bool ctrl = event->modifiers() & Qt::ControlModifier;
+ int key = event->key();
+
+ if (shift) {
+ switch(key) {
+ case Qt::Key_Left:
+ case Qt::Key_Right:
+ return false;
+ default:
+ return true;
+ }
+ return true;
+ }
+ if (ctrl) {
+ switch(key) {
+ case Qt::Key_A:
+ case Qt::Key_B:
+ case Qt::Key_C:
+ case Qt::Key_D:
+ case Qt::Key_E:
+ case Qt::Key_F:
+ case Qt::Key_H:
+ case Qt::Key_V:
+ case Qt::Key_X:
+ case Qt::Key_Z:
+ case Qt::Key_Y:
+ return false;
+ default:
+ return true;
+ }
+ return true;
+ }
+ if (event->modifiers())
+ return true;
+ switch (key) {
+ case Qt::Key_Up: incValue(0); return true;
+ case Qt::Key_Down: decValue(0); return true;
+ case 0x30:
+ case 0x31:
+ case 0x32:
+ case 0x33:
+ case 0x34:
+ case 0x35:
+ case 0x36:
+ case 0x37:
+ case 0x38:
+ case 0x39:
+ case Qt::Key_Minus:
+ case Qt::Key_Left:
+ case Qt::Key_Right:
+ case Qt::Key_Backspace:
+ case Qt::Key_Home:
+ case Qt::Key_End:
+ case Qt::Key_Delete:
+ case Qt::Key_Return:
+ return false;
+ default:
+ break;
+ }
+ return true;
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/nentry.h b/attic/muse2-oom/muse2/muse/widgets/nentry.h
new file mode 100644
index 00000000..48343b4a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/nentry.h
@@ -0,0 +1,84 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: nentry.h,v 1.1.1.1.2.2 2008/05/21 00:28:54 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __NENTRY_H__
+#define __NENTRY_H__
+
+#include <QFrame>
+
+class QHBoxLayout;
+class QLabel;
+class QLineEdit;
+class QTimer;
+
+class NentryFilter : public QObject {
+ Q_OBJECT
+
+ protected:
+ bool eventFilter(QObject* object, QEvent* event);
+ public:
+ NentryFilter(QObject* parent);
+ };
+
+//---------------------------------------------------------
+// Nentry
+// numerical entry widget with optional label
+//---------------------------------------------------------
+
+class Nentry : public QFrame {
+ Q_OBJECT
+
+ int button;
+ int starty;
+ bool drawFrame;
+ QTimer* timer;
+ int evx;
+ int timecount;
+ QHBoxLayout* layout;
+ QObject* filter;
+ QLabel* label;
+ int lPos; // label Position 0 - left, 1 - right
+ QWidget* focusW;
+
+ protected:
+ QLineEdit* edit;
+ int val;
+ virtual void incValue(int x) = 0;
+ virtual void decValue(int x) = 0;
+ virtual bool setString(int, bool editable = false) = 0;
+ virtual bool setSValue(const QString&) = 0;
+
+ private slots:
+ void repeat();
+
+ protected slots:
+ void endEdit();
+
+ public slots:
+ virtual void setValue(int);
+
+ public:
+ Nentry(QWidget* parent, const QString& txt = QString(""),
+ int lPos = 0, bool dark=false);
+
+ int value() const { return val; }
+ void setFrame(bool);
+ //void setAlignment(int flag) { edit->setAlignment(flag); }
+ void setText(const QString& s);
+ void setSize(int n);
+ void setDark();
+
+ void mousePress(QMouseEvent*);
+ void mouseMove(QMouseEvent*);
+ void mouseDoubleClick(QMouseEvent*);
+ void mouseRelease(QMouseEvent*);
+ void wheel(QWheelEvent*);
+ bool keyPress(QKeyEvent*);
+ void setFocusPolicy(Qt::FocusPolicy);
+ bool contextMenu(QContextMenuEvent*);
+ };
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/noteinfo.cpp b/attic/muse2-oom/muse2/muse/widgets/noteinfo.cpp
new file mode 100644
index 00000000..4f0e0c8c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/noteinfo.cpp
@@ -0,0 +1,210 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: noteinfo.cpp,v 1.4.2.1 2008/08/18 00:15:26 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QLabel>
+
+#include "config.h"
+#include "noteinfo.h"
+#include "awl/posedit.h"
+//#include "awl/pitchedit.h"
+#include "song.h"
+#include "globals.h"
+///#include "posedit.h"
+#include "pitchedit.h"
+
+//---------------------------------------------------
+// NoteInfo
+// ToolBar
+// Start, LÃŊÂŋÂ―nge, Note, Velo an, Velo aus, Kanal
+//---------------------------------------------------
+
+//NoteInfo::NoteInfo(QMainWindow* parent)
+NoteInfo::NoteInfo(QWidget* parent)
+ : QToolBar(tr("Note Info"), parent)
+ {
+ deltaMode = false;
+
+ //QLabel* label = new QLabel(tr("Start"), this, "Start");
+ QLabel* label = new QLabel(tr("Start"));
+ label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+ label->setIndent(3);
+ addWidget(label);
+
+ //selTime = new PosEdit(this, "Start");
+ ///selTime = new PosEdit(0, "Start");
+ selTime = new Awl::PosEdit;
+ selTime->setObjectName("Start");
+
+ addWidget(selTime);
+
+ //label = new QLabel(tr("Len"), this, "Len");
+ label = new QLabel(tr("Len"));
+ label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+ label->setIndent(3);
+ addWidget(label);
+ //selLen = new QSpinBox(0, 100000, 1, this);
+ selLen = new QSpinBox();
+ selLen->setRange(0, 100000);
+ selLen->setSingleStep(1);
+ addWidget(selLen);
+
+ //label = new QLabel(tr("Pitch"), this, "Pitch");
+ label = new QLabel(tr("Pitch"));
+ label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+ label->setIndent(3);
+ addWidget(label);
+ //selPitch = new PitchEdit(this, "selPitch");
+ selPitch = new PitchEdit;
+ addWidget(selPitch);
+
+ //label = new QLabel(tr("Velo On"), this, "Velocity On");
+ label = new QLabel(tr("Velo On"));
+ label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+ label->setIndent(3);
+ addWidget(label);
+ //selVelOn = new QSpinBox(0, 127, 1, this);
+ selVelOn = new QSpinBox();
+ selVelOn->setRange(0, 127);
+ selVelOn->setSingleStep(1);
+ addWidget(selVelOn);
+
+ //label = new QLabel(tr("Velo Off"), this, "Velocity Off");
+ label = new QLabel(tr("Velo Off"));
+ label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+ label->setIndent(3);
+ addWidget(label);
+ //selVelOff = new QSpinBox(0, 127, 1, this);
+ selVelOff = new QSpinBox();
+ selVelOff->setRange(0, 127);
+ selVelOff->setSingleStep(1);
+ addWidget(selVelOff);
+
+ connect(selLen, SIGNAL(valueChanged(int)), SLOT(lenChanged(int)));
+ connect(selPitch, SIGNAL(valueChanged(int)), SLOT(pitchChanged(int)));
+ connect(selVelOn, SIGNAL(valueChanged(int)), SLOT(velOnChanged(int)));
+ connect(selVelOff, SIGNAL(valueChanged(int)), SLOT(velOffChanged(int)));
+ connect(selTime, SIGNAL(valueChanged(const Pos&)), SLOT(timeChanged(const Pos&)));
+ }
+
+//---------------------------------------------------------
+// setDeltaMode
+//---------------------------------------------------------
+
+void NoteInfo::setDeltaMode(bool val)
+ {
+ deltaMode = val;
+ selPitch->setDeltaMode(val);
+ if (val) {
+ selLen->setRange(-100000, 100000);
+ selVelOn->setRange(-127, 127);
+ selVelOff->setRange(-127, 127);
+ }
+ else {
+ selLen->setRange(0, 100000);
+ selVelOn->setRange(0, 127);
+ selVelOff->setRange(0, 127);
+ }
+ }
+
+//---------------------------------------------------------
+// lenChanged
+//---------------------------------------------------------
+
+void NoteInfo::lenChanged(int val)
+ {
+ if (!signalsBlocked())
+ emit valueChanged(VAL_LEN, val);
+ }
+
+//---------------------------------------------------------
+// velOnChanged
+//---------------------------------------------------------
+
+void NoteInfo::velOnChanged(int val)
+ {
+ if (!signalsBlocked())
+ emit valueChanged(VAL_VELON, val);
+ }
+
+//---------------------------------------------------------
+// velOffChanged
+//---------------------------------------------------------
+
+void NoteInfo::velOffChanged(int val)
+ {
+ if (!signalsBlocked())
+ emit valueChanged(VAL_VELOFF, val);
+ }
+
+//---------------------------------------------------------
+// pitchChanged
+//---------------------------------------------------------
+
+void NoteInfo::pitchChanged(int val)
+ {
+ if (!signalsBlocked())
+ emit valueChanged(VAL_PITCH, val);
+ }
+
+//---------------------------------------------------------
+// setValue
+//---------------------------------------------------------
+
+void NoteInfo::setValue(ValType type, int val)
+ {
+ blockSignals(true);
+ switch(type) {
+ case VAL_TIME:
+ selTime->setValue(val);
+ break;
+ case VAL_LEN:
+ selLen->setValue(val);
+ break;
+ case VAL_VELON:
+ selVelOn->setValue(val);
+ break;
+ case VAL_VELOFF:
+ selVelOff->setValue(val);
+ break;
+ case VAL_PITCH:
+ selPitch->setValue(val);
+ break;
+ }
+ blockSignals(false);
+ }
+
+//---------------------------------------------------------
+// setValue
+//---------------------------------------------------------
+
+void NoteInfo::setValues(unsigned tick, int val2, int val3, int val4,
+ int val5)
+ {
+ blockSignals(true);
+ if (selTime->pos().tick() != tick)
+ selTime->setValue(tick);
+ if (selLen->value() != val2)
+ selLen->setValue(val2);
+ if (selPitch->value() != val3)
+ selPitch->setValue(val3);
+ if (selVelOn->value() != val4)
+ selVelOn->setValue(val4);
+ if (selVelOff->value() != val5)
+ selVelOff->setValue(val5);
+ blockSignals(false);
+ }
+
+//---------------------------------------------------------
+// timeChanged
+//---------------------------------------------------------
+
+void NoteInfo::timeChanged(const Pos& pos)
+ {
+ if (!signalsBlocked())
+ emit valueChanged(VAL_TIME, pos.tick());
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/noteinfo.h b/attic/muse2-oom/muse2/muse/widgets/noteinfo.h
new file mode 100644
index 00000000..cc8fe16d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/noteinfo.h
@@ -0,0 +1,59 @@
+// MusE
+// Linux Music Editor
+// $Id: noteinfo.h,v 1.3 2004/01/09 17:12:54 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __NOTE_INFO_H__
+#define __NOTE_INFO_H__
+
+#include <QToolBar>
+
+namespace Awl {
+ class PosEdit;
+ //class PitchEdit;
+ };
+
+class QSpinBox;
+
+///class PosEdit;
+class PitchEdit;
+class Pos;
+
+//---------------------------------------------------------
+// NoteInfo
+//---------------------------------------------------------
+
+class NoteInfo : public QToolBar {
+ ///PosEdit* selTime;
+ Awl::PosEdit* selTime;
+ QSpinBox* selLen;
+ PitchEdit* selPitch;
+ QSpinBox* selVelOn;
+ QSpinBox* selVelOff;
+ bool deltaMode;
+
+ Q_OBJECT
+
+ public:
+ enum ValType {VAL_TIME, VAL_LEN, VAL_VELON, VAL_VELOFF, VAL_PITCH };
+ //NoteInfo(QMainWindow* parent);
+ NoteInfo(QWidget* parent = 0);
+ void setValues(unsigned, int, int, int, int);
+ void setDeltaMode(bool);
+
+ private slots:
+ void lenChanged(int);
+ void velOnChanged(int);
+ void velOffChanged(int);
+ void pitchChanged(int);
+ void timeChanged(const Pos&);
+
+ public slots:
+ void setValue(ValType, int);
+
+ signals:
+ void valueChanged(NoteInfo::ValType, int);
+ };
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/pcscale.cpp b/attic/muse2-oom/muse2/muse/widgets/pcscale.cpp
new file mode 100644
index 00000000..10392876
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/pcscale.cpp
@@ -0,0 +1,337 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mtscale.cpp,v 1.8.2.7 2009/05/03 04:14:01 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <values.h>
+
+#include <QMouseEvent>
+#include <QPainter>
+
+#include "pcscale.h"
+#include "song.h"
+#include "icons.h"
+#include "gconfig.h"
+#include "prcanvas.h"
+
+//---------------------------------------------------------
+// PCScale
+// Midi Time Scale
+//---------------------------------------------------------
+
+PCScale::PCScale(int* r, QWidget* parent, PianoRoll* editor, int xs, bool _mode)
+ : View(parent, xs, 1)
+ {
+ audio = 0;
+ currentEditor = editor;
+ waveMode = _mode;
+ setToolTip(tr("bar pcscale"));
+ barLocator = false;
+ raster = r;
+ if (waveMode) {
+ pos[0] = tempomap.tick2frame(song->cpos());
+ pos[1] = tempomap.tick2frame(song->lpos());
+ pos[2] = tempomap.tick2frame(song->rpos());
+ }
+ else {
+ pos[0] = song->cpos();
+ pos[1] = song->lpos();
+ pos[2] = song->rpos();
+ }
+ pos[3] = MAXINT; // do not show
+ button = Qt::NoButton;
+ setMouseTracking(true);
+ connect(song, SIGNAL(posChanged(int, unsigned, bool)), SLOT(setPos(int, unsigned, bool)));
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+ //connect(song, SIGNAL(markerChanged(int)), SLOT(redraw()));
+
+ setFixedHeight(14);
+ setBg(QColor(110, 141, 152));
+}
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void PCScale::songChanged(int type)
+{
+ if (type & (SC_SIG|SC_TEMPO)) {
+ if ((type & SC_TEMPO) && waveMode) {
+ pos[0] = tempomap.tick2frame(song->cpos());
+ pos[1] = tempomap.tick2frame(song->lpos());
+ pos[2] = tempomap.tick2frame(song->rpos());
+ }
+ redraw();
+ }
+ redraw();
+}
+
+//---------------------------------------------------------
+// setPos
+//---------------------------------------------------------
+
+void PCScale::setPos(int idx, unsigned val, bool)
+{
+ if (val == MAXINT) {
+ if (idx == 3) {
+ pos[3] = MAXINT;
+ redraw(QRect(0, 0, width(), height()));
+ }
+ return;
+ }
+ if (waveMode)
+ val = tempomap.tick2frame(val);
+ if (val == pos[idx])
+ return;
+ //unsigned opos = mapx(pos[idx] == MAXINT ? val : pos[idx]);
+ int opos = mapx(pos[idx] == MAXINT ? val : pos[idx]);
+ pos[idx] = val;
+ if (!isVisible())
+ return;
+
+ int tval = mapx(val);
+ int x = -9;
+ int w = 18;
+
+ if (tval < 0) { // tval<0 occurs whenever the window is scrolled left, so I switched to signed int (ml)
+ //printf("PCScale::setPos - idx:%d val:%d tval:%d opos:%d w:%d h:%d\n", idx, val, tval, opos, width(), height());
+
+ redraw(QRect(0,0,width(),height()));
+ return;
+ }
+ //if (opos > (unsigned int) tval) { //prevent compiler warning: comparison signed/unsigned
+ if (opos > tval) {
+ w += opos - tval;
+ x += tval;
+ }
+ else {
+ w += tval - opos;
+ x += opos;
+ }
+ //printf("PCScale::setPos idx:%d val:%d tval:%d opos:%d x:%d w:%d h:%d\n", idx, val, tval, opos, x, w, height());
+
+ redraw(QRect(x, 0, w, height()));
+}
+
+//---------------------------------------------------------
+// viewMousePressEvent
+//---------------------------------------------------------
+
+void PCScale::viewMousePressEvent(QMouseEvent* event)
+{
+ button = event->button();
+ viewMouseMoveEvent(event);
+}
+
+//---------------------------------------------------------
+// viewMouseReleaseEvent
+//---------------------------------------------------------
+
+void PCScale::viewMouseReleaseEvent(QMouseEvent*)
+{
+ button = Qt::NoButton;
+}
+
+//---------------------------------------------------------
+// viewMouseMoveEvent
+//---------------------------------------------------------
+
+void PCScale::viewMouseMoveEvent(QMouseEvent* event)
+{
+ if (event->modifiers() & Qt::ShiftModifier )
+ setCursor(QCursor(Qt::PointingHandCursor));
+ else
+ setCursor(QCursor(Qt::ArrowCursor));
+
+ int x = event->x();
+ x = AL::sigmap.raster(x, *raster);
+ if (x < 0)
+ x = 0;
+ //printf("PCScale::viewMouseMoveEvent\n");
+ int i;
+ switch (button) {
+ case Qt::LeftButton:
+ i = 0;
+ break;
+ case Qt::MidButton:
+ i = 1;
+ break;
+ case Qt::RightButton:
+ i = 2;
+ break;
+ default:
+ return; // if no button is pressed the function returns here
+ }
+ Pos p(x, true);
+ if (waveMode)
+ {
+ song->setPos(i, p);
+ return;
+ }
+
+ if(i== 0 && (event->modifiers() & Qt::ShiftModifier )) { // If shift +LMB we add a marker
+ //Add program change here
+ song->setPos(i, p); // all other cases: relocating one of the locators
+ emit selectInstrument();
+ emit addProgramChange();
+ }
+ else if (i== 2 && (event->modifiers() & Qt::ShiftModifier )) { // If shift +RMB we remove a marker
+ //Delete Program change here
+ Track* track = song->findTrack(currentEditor->curCanvasPart());
+ PartList* parts = track->parts();
+ for (iPart p = parts->begin(); p != parts->end(); ++p)
+ {
+ Part* mprt = p->second;
+ EventList* eventList = mprt->events();
+ for(iEvent evt = eventList->begin(); evt != eventList->end(); ++evt)
+ {
+ //Get event type.
+ Event pcevt = evt->second;
+ if(!pcevt.isNote())
+ {
+ if(pcevt.type() == Controller && pcevt.dataA() == CTRL_PROGRAM)
+ {
+ int xp = pcevt.tick()+mprt->tick();
+ if(xp >= x && xp <= (x+50))
+ {
+ //currentEditor->deleteSelectedProgramChange(evt->second, p->second);
+ if(audio)
+ {
+ song->startUndo();
+ audio->msgDeleteEvent(evt->second, p->second, true, true, true);
+ song->endUndo(SC_EVENT_MODIFIED);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+ else
+ song->setPos(i, p); // all other cases: relocating one of the locators
+}
+
+//---------------------------------------------------------
+// leaveEvent
+//---------------------------------------------------------
+
+void PCScale::leaveEvent(QEvent*)
+{
+ //emit timeChanged(MAXINT);
+}
+
+void PCScale::setEditor(PianoRoll* editor)
+{
+ currentEditor = editor;
+}
+
+void PCScale::updateProgram()
+{
+ redraw();
+}
+
+void PCScale::setAudio(Audio* a)
+{
+ if(!a)
+ return;
+ audio = a;
+}
+
+
+//---------------------------------------------------------
+// draw
+//---------------------------------------------------------
+
+void PCScale::pdraw(QPainter& p, const QRect& r)
+{
+ if(waveMode)
+ return;
+ int x = r.x();
+ int w = r.width();
+
+ x -= 20;
+ w += 40; // wg. Text
+
+ //---------------------------------------------------
+ // draw Flag
+ //---------------------------------------------------
+
+ int y = 12;
+ p.setPen(Qt::black);
+ p.setFont(config.fonts[4]);
+ p.drawLine(r.x(), y+1, r.x() + r.width(), y+1);
+ QRect tr(r);
+ tr.setHeight(12);
+ Track* track = song->findTrack(currentEditor->curCanvasPart());
+ PartList* parts = track->parts();
+ for (iPart m = parts->begin(); m != parts->end(); ++m)
+ {
+ Part* mprt = m->second;
+ EventList* eventList = mprt->events();
+ for(iEvent evt = eventList->begin(); evt != eventList->end(); ++evt)
+ {
+ //Get event type.
+ Event pcevt = evt->second;
+ if(!pcevt.isNote())
+ {
+ if(pcevt.type() == Controller && pcevt.dataA() == CTRL_PROGRAM)
+ {
+ int xp = mapx(pcevt.tick()+mprt->tick());
+ if (xp > x+w)
+ {
+ //printf("Its dying from greater than bar size\n");
+ break;
+ }
+ int xe = r.x() + r.width();
+ iEvent mm = evt;
+ ++mm;
+
+ QRect tr(xp, 0, xe-xp, 13);
+
+ QRect wr = r.intersect(tr);
+ if(!wr.isEmpty())
+ {
+ int x2;
+ if (mm != eventList->end())
+ {
+ x2 = mapx(pcevt.tick() + mprt->tick());
+ }
+ else
+ x2 = xp+200;
+
+ //printf("PCScale::pdraw marker %s xp:%d y:%d h:%d r.x:%d r.w:%d\n", "Test Debug", xp, height(), y, r.x(), r.width());
+
+ // Must be reasonable about very low negative x values! With long songs > 15min
+ // and with high horizontal magnification, 'ghost' drawings appeared,
+ // apparently the result of truncation later (xp = -65006 caused ghosting
+ // at bar 245 with magnification at max.), even with correct clipping region
+ // applied to painter in View::paint(). Tim. Apr 5 2009
+ // Quote: "Warning: Note that QPainter does not attempt to work around
+ // coordinate limitations in the underlying window system. Some platforms may
+ // behave incorrectly with coordinates as small as +/-4000."
+ if(xp >= -32)
+ p.drawPixmap(xp, 0, *flagIconSP);
+
+ // if(xp >= -1023)
+ // {
+ // QRect r = QRect(xp+10, 0, x2-xp, 12);
+ // p.setPen(Qt::black);
+ // //Use the program change info as name
+ // p.drawText(r, Qt::AlignLeft|Qt::AlignVCenter, "Test"/*pcevt.name()*/);
+ // }
+
+ //Andrew Commenting this line to test the new flag
+ //if(xp >= 0)
+ //{
+ // p.setPen(Qt::red);
+ // p.drawLine(xp, y, xp, height());
+ //}
+ }//END if(wr.isEmpty)
+ }//END if(CTRL_PROGRAM)
+ }//END if(!isNote)
+ }
+ }
+}
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/pcscale.h b/attic/muse2-oom/muse2/muse/widgets/pcscale.h
new file mode 100644
index 00000000..6f1de1aa
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/pcscale.h
@@ -0,0 +1,58 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: mtscale.h,v 1.3 2004/04/27 22:27:06 spamatica Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __PCSCALE_H__
+#define __PCSCALE_H__
+
+#include "view.h"
+#include "pianoroll.h"
+#include "midictrl.h"
+#include "audio.h"
+
+//---------------------------------------------------------
+// PCScale
+// program change scale for midi track
+//---------------------------------------------------------
+
+class PCScale : public View {
+ Q_OBJECT
+ PianoRoll* currentEditor;
+ int* raster;
+ unsigned pos[4];
+ int button;
+ bool barLocator;
+ bool waveMode;
+ Audio* audio;
+
+
+ private slots:
+ void songChanged(int);
+
+ protected:
+ virtual void pdraw(QPainter&, const QRect&);
+ virtual void viewMousePressEvent(QMouseEvent* event);
+ virtual void viewMouseMoveEvent(QMouseEvent* event);
+ virtual void viewMouseReleaseEvent(QMouseEvent* event);
+ virtual void leaveEvent(QEvent*e);
+
+ signals:
+ void selectInstrument();
+ void addProgramChange();
+
+ public slots:
+ void setPos(int, unsigned, bool);
+ void updateProgram();
+ void setAudio(Audio*);
+
+ public:
+ PCScale(int* raster, QWidget* parent, PianoRoll* editor, int xscale, bool f = false);
+ void setBarLocator(bool f) { barLocator = f; }
+ void setEditor(PianoRoll*);
+ PianoRoll* getEditor() { return currentEditor; }
+ };
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/pctable.cpp b/attic/muse2-oom/muse2/muse/widgets/pctable.cpp
new file mode 100644
index 00000000..afb6f6e9
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/pctable.cpp
@@ -0,0 +1,124 @@
+#include "pctable.h"
+#include "pctablemodel.h"
+#include <QTableView>
+#include <QHeaderView>
+#include <QModelIndex>
+#include <QDrag>
+#include <QPainter>
+#include <QPoint>
+#include <QBrush>
+#include <QPen>
+
+ProgramChangeTable::ProgramChangeTable(QWidget *parent) : QTableView(parent)
+{
+ setDragEnabled(true);
+ setAcceptDrops(true);
+ setCornerButtonEnabled(false);
+ verticalHeader()->hide();
+ //horizontalHeader()->hide();
+ setAutoFillBackground(true);
+ setTextElideMode(Qt::ElideNone);
+ setSelectionBehavior(QAbstractItemView::SelectRows);
+ setAlternatingRowColors(true);
+ setWordWrap(false);
+}
+
+void ProgramChangeTable::dropEvent(QDropEvent *evt)
+{
+ if (evt->mimeData()->hasText()) {
+ evt->setDropAction(Qt::MoveAction);
+ ProgramChangeTableModel* m = (ProgramChangeTableModel*)model();
+ QRect r = frameRect();
+ QModelIndex index = indexAt ( evt->pos() );
+ QString t = evt->mimeData()->text();
+ int srow = t.toInt();
+ int drow = index.row();
+ if(drow != -1 && drow != srow/* && r.contains(evt->pos())*/)
+ {
+ QList<QStandardItem*> dragItems = m->takeRow(srow);
+ m->insertRow(index.row(), dragItems);
+ emit rowOrderChanged();
+ }
+ }
+ else {
+ evt->ignore();
+ }
+}
+
+void ProgramChangeTable::mousePressEvent(QMouseEvent *evt)
+{
+ QModelIndex modidx = indexAt(evt->pos());
+ QRect arect = visualRect ( modidx );
+ arect.setWidth(20);
+ if (evt->button() == Qt::LeftButton && !arect.contains(evt->pos()) /*&& ((QInputEvent*)evt)->modifiers() & Qt::ShiftModifier*/) {
+ //printf("Mouse Press Event fired\n");
+ QTableView::mousePressEvent(evt);
+ QModelIndex index = currentIndex();
+ QString plainText = QString::number(index.row());
+ QMimeData *mimeData = new QMimeData;
+ mimeData->setText(plainText);
+ QDrag* drag = new QDrag(this);
+ drag->setMimeData(mimeData);
+ drag->setHotSpot(evt->pos() - rect().topLeft());
+ drag->start(Qt::MoveAction);
+ }
+ else
+ {
+ QTableView::mousePressEvent(evt);
+ }
+}
+
+void ProgramChangeTable::dragEnterEvent(QDragEnterEvent* evt)
+{
+ if (evt->mimeData()->hasText())
+ {
+ evt->acceptProposedAction();
+ //printf("dragEnterEvent fired\n");
+ }
+ else
+ evt->ignore();
+}
+
+void ProgramChangeTable::dragMoveEvent(QDragMoveEvent* evt)
+{
+ dropSite = evt->answerRect();
+
+ ProgramChangeTableModel* m = (ProgramChangeTableModel*)model();
+ m->emit_layoutChanged();
+}
+
+void ProgramChangeTable::paintEvent ( QPaintEvent* event )
+{
+ QTableView::paintEvent (event);
+ QPainter painter ( viewport() );
+ int x, y, w, h;
+ dropSite.getRect ( &x, &y, &w, &h );
+ QPoint point(x,y);
+ QModelIndex modidx = indexAt ( point );
+ QRect arect = visualRect ( modidx );
+ int b = arect.y();
+ QBrush brush(Qt::black, Qt::Dense4Pattern);
+ QPen pen;
+ pen.setWidth(2);
+ pen.setBrush(brush);
+ painter.setPen(pen);
+ painter.drawLine ( 0, b, width()-40, b );
+ event->accept();
+}
+
+QList<int> ProgramChangeTable::getSelectedRows()
+{
+ QList<int> rv;
+ QItemSelectionModel* smodel = selectionModel();
+ if(smodel->hasSelection())
+ {
+ QModelIndexList indexes = smodel->selectedRows();
+ QList<QModelIndex>::const_iterator id;
+ for (id = indexes.constBegin(); id != indexes.constEnd(); ++id)
+ {
+ int row = (*id).row();
+ rv.append(row);
+ }
+ }
+ return rv;
+}
diff --git a/attic/muse2-oom/muse2/muse/widgets/pctable.h b/attic/muse2-oom/muse2/muse/widgets/pctable.h
new file mode 100644
index 00000000..c8ba53bf
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/pctable.h
@@ -0,0 +1,31 @@
+#ifndef _PCTABLE_
+#define _PCTABLE_
+
+#include <QTableView>
+#include <QDropEvent>
+#include <QMouseEvent>
+#include <QDragEnterEvent>
+#include <QDragMoveEvent>
+#include <QPaintEvent>
+#include <QList>
+
+class ProgramChangeTable : public QTableView
+{
+ Q_OBJECT
+ virtual void dragEnterEvent(QDragEnterEvent*);
+ virtual void dragMoveEvent(QDragMoveEvent*);
+ virtual void paintEvent(QPaintEvent*);
+ QRect dropSite;
+
+ signals:
+ void rowOrderChanged();
+
+ public:
+ ProgramChangeTable(QWidget *parent = 0);
+ void dropEvent(QDropEvent *evt);
+ void mousePressEvent(QMouseEvent* evt);
+
+ public slots:
+ QList<int> getSelectedRows();
+};
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/pctablemodel.cpp b/attic/muse2-oom/muse2/muse/widgets/pctablemodel.cpp
new file mode 100644
index 00000000..24c3b1c1
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/pctablemodel.cpp
@@ -0,0 +1,18 @@
+#include "pctablemodel.h"
+#include <QTableView>
+
+ProgramChangeTableModel::ProgramChangeTableModel(QObject *parent) : QStandardItemModel(parent)
+{
+}
+
+QStringList ProgramChangeTableModel::mimeTypes()
+{
+ QStringList list;
+ list << "text/plain";
+ return list;
+}
+
+void ProgramChangeTableModel::emit_layoutChanged()
+{
+ emit layoutChanged();
+}
diff --git a/attic/muse2-oom/muse2/muse/widgets/pctablemodel.h b/attic/muse2-oom/muse2/muse/widgets/pctablemodel.h
new file mode 100644
index 00000000..fe6da658
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/pctablemodel.h
@@ -0,0 +1,16 @@
+#ifndef _PROGRAMCHAMGETABLEMODEL_
+#define _PROGRAMCHAMGETABLEMODEL_
+
+#include <QStandardItemModel>
+#include <QStringList>
+
+class ProgramChangeTableModel : public QStandardItemModel
+{
+ Q_OBJECT
+ virtual QStringList mimeTypes();
+
+ public:
+ ProgramChangeTableModel(QObject *parent = 0);
+ void emit_layoutChanged();
+};
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/pitchedit.cpp b/attic/muse2-oom/muse2/muse/widgets/pitchedit.cpp
new file mode 100644
index 00000000..563cd6a8
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/pitchedit.cpp
@@ -0,0 +1,64 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: pitchedit.cpp,v 1.2 2004/01/09 17:12:54 wschweer Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include "pitchedit.h"
+#include "helper.h"
+
+//---------------------------------------------------------
+// PitchEdit
+//---------------------------------------------------------
+
+PitchEdit::PitchEdit(QWidget* parent)
+ : QSpinBox(parent)
+ {
+ setMinimum(0);
+ setMaximum(127);
+ setSingleStep(1);
+ deltaMode = false;
+ }
+
+//---------------------------------------------------------
+// mapValueToText
+//---------------------------------------------------------
+
+QString PitchEdit::mapValueToText(int v)
+ {
+ if (deltaMode) {
+ QString s;
+ s.setNum(v);
+ return s;
+ }
+ else
+ return pitch2string(v);
+ }
+
+//---------------------------------------------------------
+// mapTextToValue
+//---------------------------------------------------------
+
+int PitchEdit::mapTextToValue(bool* ok)
+ {
+ printf("PitchEdit: mapTextToValue: not impl.\n");
+ if (ok)
+ *ok = false;
+ return 0;
+ }
+
+//---------------------------------------------------------
+// setDeltaMode
+//---------------------------------------------------------
+
+void PitchEdit::setDeltaMode(bool val)
+ {
+ deltaMode = val;
+ if (deltaMode)
+ setRange(-127, 127);
+ else
+ setRange(0, 127);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/pitchedit.h b/attic/muse2-oom/muse2/muse/widgets/pitchedit.h
new file mode 100644
index 00000000..8d2c8789
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/pitchedit.h
@@ -0,0 +1,33 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: pitchedit.h,v 1.2 2004/01/09 17:12:54 wschweer Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __PITCHEDIT_H__
+#define __PITCHEDIT_H__
+
+#include <QSpinBox>
+
+//---------------------------------------------------------
+// PitchEdit
+//---------------------------------------------------------
+
+class PitchEdit : public QSpinBox {
+ Q_OBJECT
+
+ bool deltaMode;
+
+ protected:
+ virtual QString mapValueToText(int v);
+ virtual int mapTextToValue(bool* ok);
+
+ public:
+ PitchEdit(QWidget* parent=0);
+ void setDeltaMode(bool);
+ };
+
+extern QString pitch2string(int v);
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/pitchlabel.cpp b/attic/muse2-oom/muse2/muse/widgets/pitchlabel.cpp
new file mode 100644
index 00000000..91daf09f
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/pitchlabel.cpp
@@ -0,0 +1,97 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: pitchlabel.cpp,v 1.2 2004/05/16 16:55:01 wschweer Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QApplication>
+#include <QStyle>
+
+#include "pitchedit.h"
+#include "pitchlabel.h"
+#include "helper.h"
+
+//---------------------------------------------------------
+// PitchLabel
+//---------------------------------------------------------
+
+PitchLabel::PitchLabel(QWidget* parent, const char* name)
+ : QLabel(parent)
+ {
+ setObjectName(name);
+ _pitchMode = true;
+ _value = -1;
+ setFrameStyle(WinPanel | Sunken);
+ setLineWidth(2);
+ setMidLineWidth(3);
+ setValue(0);
+ //int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, this); // ddskrjo 0
+ int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
+ setIndent(fw);
+ }
+
+//---------------------------------------------------------
+// setPitchMode
+//---------------------------------------------------------
+
+void PitchLabel::setPitchMode(bool val)
+ {
+ _pitchMode = val;
+ }
+
+//---------------------------------------------------------
+// sizeHint
+//---------------------------------------------------------
+
+QSize PitchLabel::sizeHint() const
+ {
+ QFontMetrics fm(font());
+ //int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, this); // ddskrjo 0
+ int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
+ int h = fm.height() + fw * 2;
+// int w = 2 + fm.width(QString("A#8")) + fw * 4;
+ int w = 2 + fm.width(QString("-9999")) + fw * 4; // must display 14Bit controller values
+ return QSize(w, h).expandedTo(QApplication::globalStrut());
+ }
+
+//---------------------------------------------------------
+// setValue
+//---------------------------------------------------------
+
+void PitchLabel::setValue(int val)
+ {
+ if (val == _value)
+ return;
+ _value = val;
+ QString s;
+ if (_pitchMode)
+ s = pitch2string(_value);
+ else
+ s.sprintf("%d", _value);
+ setText(s);
+ }
+
+//---------------------------------------------------------
+// setInt
+//---------------------------------------------------------
+
+void PitchLabel::setInt(int val)
+ {
+ if (_pitchMode)
+ setPitchMode(false);
+ setValue(val);
+ }
+
+//---------------------------------------------------------
+// setPitch
+//---------------------------------------------------------
+
+void PitchLabel::setPitch(int val)
+ {
+ if (!_pitchMode) {
+ setPitchMode(true);
+ }
+ setValue(val);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/pitchlabel.h b/attic/muse2-oom/muse2/muse/widgets/pitchlabel.h
new file mode 100644
index 00000000..6372f711
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/pitchlabel.h
@@ -0,0 +1,41 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: pitchlabel.h,v 1.1.1.1 2003/10/27 18:54:49 wschweer Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __PITCHLABEL_H__
+#define __PITCHLABEL_H__
+
+#include <QLabel>
+
+//---------------------------------------------------------
+// PitchLabel
+//---------------------------------------------------------
+
+class PitchLabel : public QLabel {
+ bool _pitchMode;
+ int _value;
+ Q_OBJECT
+
+ protected:
+ QSize sizeHint() const;
+
+ public slots:
+ void setValue(int);
+ void setInt(int);
+ void setPitch(int);
+
+ public:
+ PitchLabel(QWidget* parent, const char* name = 0);
+ int value() const { return _value; }
+ void setPitchMode(bool val);
+ bool pitchMode() const { return _pitchMode; }
+ };
+
+
+#endif
+
+
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/popupmenu.cpp b/attic/muse2-oom/muse2/muse/widgets/popupmenu.cpp
new file mode 100644
index 00000000..862bda91
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/popupmenu.cpp
@@ -0,0 +1,137 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: popupmenu.cpp,v 1.1.1.1 2010/07/18 03:21:00 terminator356 Exp $
+//
+// (C) Copyright 1999-2010 Werner Schweer (ws@seh.de)
+//
+// PopupMenu sub-class of QMenu created by Tim.
+//=========================================================
+
+//#include <stdio.h>
+#include <QMouseEvent>
+#include <QAction>
+#include <stdio.h>
+//#include <QStandardItemModel>
+
+#include "popupmenu.h"
+
+//======================
+// PopupMenu
+//======================
+
+PopupMenu::PopupMenu(QWidget* parent)
+ : QMenu(parent)
+{
+ // Menus will trigger! Set to make sure our trigger handlers ignore menus.
+ menuAction()->setData(-1);
+}
+
+PopupMenu::~PopupMenu()
+{
+ //printf("PopupMenu::~PopupMenu\n");
+}
+
+void PopupMenu::clear()
+{
+ QList<QAction*> list = actions();
+ for(int i = 0; i < list.size(); ++i)
+ {
+ QAction* act = list[i];
+ QMenu* menu = act->menu();
+ if(menu)
+ {
+ menu->clear();
+ act->setMenu(0); // CHECK: Is this OK?
+ delete menu;
+ }
+ }
+
+ // Now let QT remove and delete this menu's actions.
+ QMenu::clear();
+}
+
+QAction* PopupMenu::findActionFromData(QVariant v)
+{
+ QList<QAction*> list = actions();
+ for(int i = 0; i < list.size(); ++i)
+ {
+ QAction* act = list[i];
+ PopupMenu* menu = (PopupMenu*)act->menu();
+ if(menu)
+ {
+ if(QAction* actm = menu->findActionFromData(v))
+ return actm;
+ }
+ if(act->data() == v)
+ return act;
+ }
+ return 0;
+}
+
+void PopupMenu::mouseReleaseEvent(QMouseEvent *e)
+{
+ //Q_D(QMenu);
+ //if (d->mouseEventTaken(e))
+ // return;
+
+ //d->mouseDown = false;
+ //QAction *action = d->actionAt(e->pos());
+ QAction *action = actionAt(e->pos());
+
+ //for(QWidget *caused = this; caused;) {
+ // if (QMenu *m = qobject_cast<QMenu*>(caused)) {
+ // QAction *currentAction = d->currentAction;
+ // if(currentAction && (!currentAction->isEnabled() || currentAction->menu() || currentAction->isSeparator()))
+ // currentAction = 0;
+ // caused = m->d_func()->causedPopup.widget;
+ // if (m->d_func()->eventLoop)
+ // m->d_func()->syncAction = currentAction; // synchronous operation
+ // } else {
+ // break;
+ // }
+ //}
+
+ //if (action && action == d->currentAction) {
+ if (action && action == activeAction() && !action->isSeparator() && action->isEnabled())
+ {
+ //if (action->menu())
+ // action->menu()->d_func()->setFirstActionActive();
+ //else
+ //d->activateAction(action, QAction::Trigger);
+ action->activate(QAction::Trigger);
+ }
+ else
+ //if (d->motions > 6) {
+ // d->hideUpToMenuBar();
+ // }
+ QMenu::mouseReleaseEvent(e);
+}
+
+/*
+//======================
+// PopupView
+//======================
+
+PopupView::PopupView(QWidget* parent)
+ : QColumnView(parent)
+{
+ _model= new QStandardItemModel(this);
+ // FIXME: After clearing, then re-filling, no items seen.
+ // But if setModel is called FOR THE FIRST TIME after clearing the model,
+ // then it works. Calling setModel any time after that does not work.
+ setModel(_model);
+}
+
+PopupView::~PopupView()
+{
+ // Make sure to clear the popup so that any child popups are also deleted !
+ //popup->clear();
+}
+
+void PopupView::clear()
+{
+ _model->clear();
+}
+*/
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/popupmenu.h b/attic/muse2-oom/muse2/muse/widgets/popupmenu.h
new file mode 100644
index 00000000..c06d51f4
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/popupmenu.h
@@ -0,0 +1,59 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: popupmenu.h,v 1.1.1.1 2010/07/18 03:18:00 terminator356 Exp $
+//
+// (C) Copyright 1999-2010 Werner Schweer (ws@seh.de)
+//
+// PopupMenu sub-class of QMenu created by Tim.
+//=========================================================
+
+#ifndef __POPUPMENU_H__
+#define __POPUPMENU_H__
+
+#include <QMenu>
+//#include <QMouseEvent>
+//#include <QColumnView>
+
+class QWidget;
+class QMouseEvent;
+class QVariant;
+class QAction;
+//class QStandardItemModel;
+
+class PopupMenu : public QMenu
+{
+ Q_OBJECT
+
+ protected:
+ void mouseReleaseEvent(QMouseEvent *);
+
+ public:
+ PopupMenu(QWidget* parent=0);
+ ~PopupMenu();
+ void clear();
+ QAction* findActionFromData(QVariant);
+};
+
+
+/*
+class PopupView : public QColumnView
+{
+ Q_OBJECT
+ private:
+ QStandardItemModel* _model;
+
+ protected:
+
+ public:
+ PopupView(QWidget* parent=0);
+ ~PopupView();
+
+ void clear();
+ QStandardItemModel* model() { return _model; }
+};
+*/
+
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/posedit.cpp b/attic/muse2-oom/muse2/muse/widgets/posedit.cpp
new file mode 100644
index 00000000..3accf557
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/posedit.cpp
@@ -0,0 +1,854 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: posedit.cpp,v 1.3.2.2 2008/05/21 00:28:54 terminator356 Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <values.h>
+
+#include <QApplication>
+#include <QKeyEvent>
+#include <QMouseEvent>
+#include <QPaintEvent>
+#include <QPainter>
+#include <QResizeEvent>
+#include <QString>
+#include <QStyle>
+#include <QTimerEvent>
+
+#include "posedit.h"
+#include "sig.h"
+#include "spinbox.h"
+
+extern int mtcType;
+
+//---------------------------------------------------------
+// QNumberSection
+//---------------------------------------------------------
+
+class QNumberSection
+ {
+ int selstart;
+ int selend;
+
+ public:
+ QNumberSection(int selStart = 0, int selEnd = 0)
+ : selstart(selStart), selend(selEnd ) {}
+ int selectionStart() const { return selstart; }
+ void setSelectionStart(int s) { selstart = s; }
+ int selectionEnd() const { return selend; }
+ void setSelectionEnd( int s ) { selend = s; }
+ int width() const { return selend - selstart; }
+ };
+
+//---------------------------------------------------------
+// PosEditor
+//---------------------------------------------------------
+
+class PosEditor : public QLineEdit
+ {
+ PosEdit* cw;
+ bool frm;
+ QPixmap *pm;
+ int focusSec;
+ QList<QNumberSection> sections;
+ QString sep;
+ int offset;
+
+ int section(const QPoint&);
+
+ protected:
+ void init();
+ bool event(QEvent *e);
+ void resizeEvent(QResizeEvent*);
+ void paintEvent(QPaintEvent*);
+ void mousePressEvent(QMouseEvent *e);
+ void keyPressEvent(QKeyEvent * event );
+ void applyFocusSelection() {}
+
+ public:
+ PosEditor(PosEdit* Q_PARENT, const char * Q_NAME );
+ ~PosEditor();
+
+ void setControlWidget(PosEdit * widget);
+ PosEdit* controlWidget() const;
+
+ void setSeparator(const QString& s) { sep = s; }
+ QString separator() const { return sep; }
+ int focusSection() const { return focusSec; }
+
+ bool setFocusSection(int s);
+ void appendSection(const QNumberSection& sec);
+ void clearSections();
+ void setSectionSelection(int sec, int selstart, int selend);
+ };
+
+//---------------------------------------------------------
+// section
+//---------------------------------------------------------
+
+int PosEditor::section(const QPoint& pt)
+ {
+ if (pm->isNull())
+ return -1;
+ QPainter p(pm);
+ int fw = frm ? style()->pixelMetric(QStyle::PM_DefaultFrameWidth) : 0;
+ int x = 2 + fw;
+ int y = 0;
+ int w = width();
+ int h = height();
+ for (int i = 0; i < sections.count(); ++i) {
+ QString s = cw->sectionFormattedText(i);
+ QRect bb = p.boundingRect(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s);
+ int nx = bb.x() + bb.width();
+ if (pt.x() >= x && pt.x() < nx)
+ return i;
+ x = nx;
+ if (i < sections.count()-1) {
+ QString s = sep;
+ p.drawText(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s, -1, &bb);
+ x = bb.x() + bb.width();
+ }
+ }
+ return -1;
+ }
+
+//---------------------------------------------------------
+// PosEditor
+//---------------------------------------------------------
+
+PosEditor::PosEditor(PosEdit* parent, const char* name)
+ : QLineEdit(parent), sep(".")
+ {
+ setObjectName(name);
+ cw = parent;
+ frm = true;
+ focusSec = 0;
+ pm = new QPixmap;
+ offset = 0;
+ init();
+ }
+
+//---------------------------------------------------------
+// ~PosEditor
+//---------------------------------------------------------
+
+PosEditor::~PosEditor()
+ {
+ delete pm;
+ }
+
+//---------------------------------------------------------
+// init
+//---------------------------------------------------------
+
+void PosEditor::init()
+ {
+ setBackgroundMode(Qt::PaletteBase);
+ setFocusSection(-1);
+ setKeyCompression(true);
+ setFocusPolicy(Qt::WheelFocus);
+ }
+
+//---------------------------------------------------------
+// event
+//---------------------------------------------------------
+
+bool PosEditor::event(QEvent *e)
+ {
+ if (e->type() == QEvent::FocusIn || e->type() == QEvent::FocusOut) {
+ repaint( rect(), false);
+ }
+ else if (e->type() == QEvent::ShortcutOverride) {
+ QKeyEvent* ke = (QKeyEvent*) e;
+ switch (ke->key()) {
+ case Qt::Key_Delete:
+ case Qt::Key_Backspace:
+ case Qt::Key_Up:
+ case Qt::Key_Down:
+ case Qt::Key_Left:
+ case Qt::Key_Right:
+ ke->accept();
+ default:
+ break;
+ }
+ }
+ return QWidget::event(e);
+ }
+
+void PosEditor::resizeEvent(QResizeEvent *e)
+ {
+ pm->resize(e->size());
+ QWidget::resizeEvent(e);
+ }
+
+//---------------------------------------------------------
+// paintEvent
+//---------------------------------------------------------
+
+void PosEditor::paintEvent(QPaintEvent *)
+ {
+ if (pm->isNull())
+ return;
+
+ const QColorGroup & cg = colorGroup();
+ QPainter p(pm);
+ p.setPen(colorGroup().text());
+ QBrush bg = cg.brush(QColorGroup::Base);
+
+ int fw = frm ? style()->pixelMetric(QStyle::PM_DefaultFrameWidth) : 0;
+ int x = 2 + fw;
+ int y = 0;
+ int w = width();
+ int h = height();
+ p.fillRect(0, 0, w, h, bg);
+
+ for (int i = 0; i < sections.count(); ++i) {
+ QRect bb;
+ QString s = cw->sectionFormattedText(i);
+
+ if (hasFocus() && (int(i) == focusSec)) {
+ QBrush bg = cg.brush(QColorGroup::Highlight);
+ QRect r = p.boundingRect(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s, -1);
+ p.setPen(colorGroup().highlightedText());
+ p.fillRect(r, bg);
+ }
+ else
+ p.setPen(colorGroup().text());
+ p.drawText(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s, -1, &bb);
+ x = bb.x() + bb.width();
+ if (i < sections.count()-1) {
+ QString s = sep;
+ p.drawText(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s, -1, &bb);
+ x = bb.x() + bb.width();
+ }
+ }
+ p.end();
+ bitBlt(this, 0, 0, pm);
+ }
+
+//---------------------------------------------------------
+// mousePressEvent
+//---------------------------------------------------------
+
+void PosEditor::mousePressEvent(QMouseEvent *e)
+ {
+ QPoint p(e->pos().x(), 0);
+ int sec = section(p);
+ if (sec != -1) {
+ cw->setFocusSection(sec);
+ repaint(rect(), false);
+ }
+ }
+
+//---------------------------------------------------------
+// keyPressEvent
+//---------------------------------------------------------
+
+void PosEditor::keyPressEvent(QKeyEvent *e)
+ {
+ switch (e->key()) {
+ case Qt::Key_Right:
+ if (unsigned(focusSec) <= sections.count()) {
+ if (cw->setFocusSection(focusSec+1))
+ repaint(rect(), false);
+ }
+ case Qt::Key_Left:
+ if (focusSec > 0 ) {
+ if (cw->setFocusSection(focusSec-1))
+ repaint(rect(), false);
+ }
+ case Qt::Key_Up:
+ cw->stepUp();
+ case Qt::Key_Down:
+ cw->stepDown();
+ case Qt::Key_Backspace:
+ case Qt::Key_Delete:
+ cw->removeLastNumber(focusSec);
+ case Qt::Key_Return:
+ cw->enterPressed();
+ default:
+ QString txt = e->text();
+ if (!txt.isEmpty() && !sep.isEmpty() && txt[0] == sep[0]) {
+ // do the same thing as KEY_RIGHT when the user presses the separator key
+ if (unsigned(focusSec) < sections.count()) {
+ if (cw->setFocusSection(focusSec+1))
+ repaint(rect(), false);
+ }
+ }
+ int num = txt[0].digitValue();
+ if (num != -1) {
+ cw->addNumber(focusSec, num);
+ }
+ }
+ }
+
+void PosEditor::appendSection(const QNumberSection& sec)
+ {
+ sections.append(sec);
+ }
+void PosEditor::clearSections()
+ {
+ sections.clear();
+ }
+
+//---------------------------------------------------------
+// setSectionSelection
+//---------------------------------------------------------
+
+void PosEditor::setSectionSelection(int secNo, int selstart, int selend)
+ {
+ if (secNo < 0 || secNo > (int)sections.count())
+ return;
+ sections[secNo].setSelectionStart(selstart);
+ sections[secNo].setSelectionEnd(selend);
+ }
+
+//---------------------------------------------------------
+// setFocusSection
+//---------------------------------------------------------
+
+bool PosEditor::setFocusSection(int idx)
+ {
+ if (idx > (int)sections.count()-1 || idx < 0)
+ return false;
+ if (idx != focusSec) {
+ focusSec = idx;
+ applyFocusSelection();
+ return true;
+ }
+ return false;
+ }
+
+//---------------------------------------------------------
+// PosEdit
+//---------------------------------------------------------
+
+PosEdit::PosEdit(QWidget* parent, const char* name)
+ : QWidget(parent)
+ {
+ setObjectName(name);
+ init();
+ updateButtons();
+ }
+
+PosEdit::PosEdit(const Pos& time, QWidget* parent, const char* name)
+ : QWidget(parent, name)
+ {
+ init();
+ setValue(time);
+ updateButtons();
+ }
+
+PosEdit::~PosEdit()
+ {
+ }
+
+//---------------------------------------------------------
+// init
+//---------------------------------------------------------
+
+void PosEdit::init()
+ {
+ ed = new PosEditor(this, "pos editor");
+ controls = new SpinBox(this);
+ controls->setEditor(ed);
+ setFocusProxy(ed);
+ connect(controls, SIGNAL(stepUpPressed()), SLOT(stepUp()));
+ connect(controls, SIGNAL(stepDownPressed()), SLOT(stepDown()));
+ connect(this, SIGNAL(valueChanged(const Pos&)),SLOT(updateButtons()));
+
+ overwrite = false;
+ timerId = 0;
+ typing = false;
+ min = Pos(0);
+ max = Pos(MAX_TICK);
+ changed = false;
+ adv = false;
+
+
+ static Section s_midiSections[3] = { // measure, beat, tick
+ { 0, 4, 1, 0 },
+ { 5, 2, 1, 0 },
+ { 8, 3, 0, 0 }
+ };
+ static Section s_smpteSections[4] = { // minute second frame subframe
+ { 0, 3, 0, 0 },
+ { 4, 2, 0, 0 },
+ { 7, 2, 0, 0 },
+ { 10, 2, 0, 0 }
+ };
+ memcpy(midiSections, s_midiSections, sizeof(s_midiSections));
+ memcpy(smpteSections, s_smpteSections, sizeof(s_smpteSections));
+
+ _smpte = false; // show position in smpte format
+ sec = midiSections;
+ setSections();
+ setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
+ }
+
+//---------------------------------------------------------
+// setSetions
+//---------------------------------------------------------
+
+void PosEdit::setSections()
+ {
+ ed->clearSections();
+ ed->appendSection(QNumberSection(0,0));
+ ed->appendSection(QNumberSection(0,0));
+ ed->appendSection(QNumberSection(0,0));
+ if (_smpte) {
+ ed->appendSection(QNumberSection(0,0));
+ ed->setSeparator(QString(":"));
+ }
+ else {
+ ed->setSeparator(QString("."));
+ }
+ }
+
+//---------------------------------------------------------
+// smpte
+//---------------------------------------------------------
+
+bool PosEdit::smpte() const
+ {
+ return _smpte;
+ }
+
+//---------------------------------------------------------
+// setSmpte
+//---------------------------------------------------------
+
+void PosEdit::setSmpte(bool f)
+ {
+ _smpte = f;
+ sec = f ? smpteSections : midiSections;
+ setSections();
+ ed->repaint(ed->rect(), false);
+ }
+
+//---------------------------------------------------------
+// minValue
+//---------------------------------------------------------
+
+Pos PosEdit::minValue() const
+ {
+ return min;
+ }
+
+//---------------------------------------------------------
+// maxValue
+//---------------------------------------------------------
+
+Pos PosEdit::maxValue() const
+ {
+ return max;
+ }
+
+//---------------------------------------------------------
+// setRange
+//---------------------------------------------------------
+
+void PosEdit::setRange(const Pos& _min, const Pos& _max)
+ {
+ if (min.isValid())
+ min = _min;
+ if (max.isValid())
+ max = _max;
+ }
+
+//---------------------------------------------------------
+// setValue
+//---------------------------------------------------------
+
+void PosEdit::setValue(const Pos& time)
+ {
+ if (time > maxValue() || time < minValue())
+ return;
+ if (_smpte)
+ time.msf(&(sec[0].val), &(sec[1].val), &(sec[2].val),
+ &(sec[3].val));
+ else
+ time.mbt(&(sec[0].val), &(sec[1].val), &(sec[2].val));
+ changed = false;
+
+ updateButtons();
+ ed->repaint(ed->rect(), false);
+ }
+
+void PosEdit::setValue(const QString& s)
+ {
+ Pos time(s);
+ setValue(time);
+ }
+
+void PosEdit::setValue(int t)
+ {
+ Pos time(t);
+ setValue(time);
+ }
+
+Pos PosEdit::pos() const
+ {
+ if (_smpte) {
+ if (Pos::isValid(sec[0].val, sec[1].val, sec[2].val, sec[3].val))
+ return Pos(sec[0].val, sec[1].val, sec[2].val, sec[3].val);
+ }
+ else {
+ if (Pos::isValid(sec[0].val, sec[1].val, sec[2].val))
+ return Pos(sec[0].val, sec[1].val, sec[2].val);
+ }
+ return Pos();
+ }
+
+void PosEdit::setSeparator(const QString& s)
+ {
+ ed->setSeparator(s);
+ }
+
+QString PosEdit::separator() const
+ {
+ return ed->separator();
+ }
+
+bool PosEdit::event(QEvent *e)
+ {
+ if (e->type() == QEvent::FocusOut) {
+ typing = false;
+ if (changed) {
+ emit valueChanged(pos() );
+ changed = false;
+ }
+ }
+ return QWidget::event(e);
+ }
+
+void PosEdit::timerEvent(QTimerEvent *)
+ {
+ overwrite = true;
+ }
+
+//---------------------------------------------------------
+// stepUp
+//---------------------------------------------------------
+
+void PosEdit::stepUp()
+ {
+ int secNo = ed->focusSection();
+ bool accepted = false;
+
+ if (!outOfRange(secNo, sec[secNo].val+1)) {
+ accepted = true;
+ setSec(secNo, sec[secNo].val+1);
+ }
+ if (accepted) {
+ changed = true;
+ Pos p = pos();
+ emit valueChanged(p);
+ }
+ ed->repaint(ed->rect(), false);
+ }
+
+//---------------------------------------------------------
+// stepDown
+//---------------------------------------------------------
+
+void PosEdit::stepDown()
+ {
+ int secNo = ed->focusSection();
+ bool accepted = false;
+ if (!outOfRange(secNo, sec[secNo].val-1)) {
+ accepted = true;
+ setSec(secNo, sec[secNo].val-1);
+ }
+ if (accepted) {
+ changed = true;
+ emit valueChanged(pos());
+ }
+ ed->repaint(ed->rect(), false);
+ }
+
+//---------------------------------------------------------
+// sectionFormattedText
+// Returns the formatted number for section sec.
+//---------------------------------------------------------
+
+QString PosEdit::sectionFormattedText(int secNo)
+ {
+ QString txt = sectionText(secNo);
+ int so = sec[secNo].offset;
+ int len = sec[secNo].len;
+ int eo = so + len;
+
+ if (typing && secNo == ed->focusSection())
+ ed->setSectionSelection(secNo, eo - txt.length(), eo);
+ else
+ ed->setSectionSelection(secNo, so, eo);
+ txt = txt.rightJustify(len, '0');
+ return txt;
+ }
+
+//---------------------------------------------------------
+// setFocusSection
+//---------------------------------------------------------
+
+bool PosEdit::setFocusSection(int s)
+ {
+ if (s != ed->focusSection()) {
+ killTimer(timerId);
+ overwrite = true;
+ typing = false;
+ int so = sec[s].offset;
+ int eo = so + sec[s].len;
+ ed->setSectionSelection(s, so, eo);
+ if (changed) {
+ emit valueChanged(pos());
+ changed = false;
+ }
+ }
+ return ed->setFocusSection(s);
+ }
+
+//---------------------------------------------------------
+// setSec
+//---------------------------------------------------------
+
+void PosEdit::setSec(int secNo, int val)
+ {
+ if (val < 0)
+ val = 0;
+ if (_smpte) {
+ switch(secNo) {
+ case 0:
+ break;
+ case 1:
+ if (val > 59)
+ val = 59;
+ break;
+ case 2:
+ switch(mtcType) {
+ case 0: // 24 frames sec
+ if (val > 23)
+ val = 23;
+ break;
+ case 1:
+ if (val > 24)
+ val = 24;
+ break;
+ case 2: // 30 drop frame
+ case 3: // 30 non drop frame
+ if (val > 29)
+ val = 29;
+ break;
+ }
+ break;
+ case 3:
+ if (val > 99)
+ val = 99;
+ }
+ }
+ else {
+ switch(secNo) {
+ case 0:
+ break;
+ case 1:
+ {
+ int z, n;
+ int tick = sigmap.bar2tick(sec[0].val, val, sec[2].val);
+ sigmap.timesig(tick, z, n);
+ if (val >= n)
+ val = n-1;
+ }
+ break;
+ case 2:
+ {
+ int tick = sigmap.bar2tick(sec[0].val, sec[1].val, val);
+ int tb = sigmap.ticksBeat(tick);
+ if (val >= tb)
+ val = tb-1;
+ }
+ break;
+ }
+ }
+ sec[secNo].val = val;
+ }
+
+//---------------------------------------------------------
+// sectionText
+// Returns the text of section \a sec.
+//---------------------------------------------------------
+
+QString PosEdit::sectionText(int secNo)
+ {
+ return QString::number(sec[secNo].val + sec[secNo].voff);
+ }
+
+//---------------------------------------------------------
+// outOfRange
+// return true if out of range
+//---------------------------------------------------------
+
+bool PosEdit::outOfRange(int secNo, int val) const
+ {
+ if (val < 0)
+ return true;
+ int limit = MAXINT;
+ if (_smpte) {
+ switch(secNo) {
+ case 0:
+ break;
+ case 1:
+ limit = 59;
+ break;
+ case 2:
+ switch(mtcType) {
+ case 0: // 24 frames sec
+ limit = 23;
+ break;
+ case 1:
+ limit = 24;
+ break;
+ case 2: // 30 drop frame
+ case 3: // 30 non drop frame
+ limit = 29;
+ break;
+ }
+ break;
+ case 3:
+ limit = 99;
+ break;
+ }
+ }
+ else {
+ switch(secNo) {
+ case 0:
+ break;
+ case 1:
+ {
+ int z;
+ int tick = sigmap.bar2tick(sec[0].val, val, sec[2].val);
+ sigmap.timesig(tick, z, limit);
+ limit -= 1;
+ }
+ break;
+ case 2:
+ int tick = sigmap.bar2tick(sec[0].val, sec[1].val, val);
+ limit = sigmap.ticksBeat(tick) - 1;
+ break;
+ }
+ }
+ return val > limit;
+ }
+
+//---------------------------------------------------------
+// addNumber
+//---------------------------------------------------------
+
+void PosEdit::addNumber(int secNo, int num)
+ {
+ if (secNo == -1)
+ return;
+ killTimer(timerId);
+ bool accepted = false;
+ typing = true;
+ int voff = sec[secNo].voff;
+
+ QString txt = sectionText(secNo);
+
+ if ((unsigned) txt.length() == sec[secNo].len) {
+ if (!outOfRange(secNo, num - voff)) {
+ accepted = true;
+ sec[secNo].val = num - voff;
+ }
+ }
+ else {
+ txt += QString::number(num);
+ int temp = txt.toInt() - voff;
+ if (outOfRange(secNo, temp))
+ txt = sectionText(secNo);
+ else {
+ accepted = true;
+ sec[secNo].val = temp;
+ }
+ if (adv && ((unsigned) txt.length() == sec[secNo].len)) {
+ setFocusSection(ed->focusSection() + 1);
+ }
+ }
+ changed = accepted;
+ if (accepted)
+ emit valueChanged(pos());
+ timerId = startTimer(qApp->doubleClickInterval()*4);
+ ed->repaint(ed->rect(), false);
+ }
+
+//---------------------------------------------------------
+// removeLastNumber
+//---------------------------------------------------------
+
+void PosEdit::removeLastNumber(int secNo)
+ {
+ if (secNo == -1)
+ return;
+ QString txt = QString::number(sec[secNo].val);
+ txt = txt.mid(0, txt.length() - 1);
+ sec[secNo].val = txt.toInt() - sec[secNo].voff;
+ ed->repaint(ed->rect(), false);
+ }
+
+//---------------------------------------------------------
+// resizeEvent
+//---------------------------------------------------------
+
+void PosEdit::resizeEvent(QResizeEvent *)
+ {
+ controls->resize(width(), height());
+ }
+
+//---------------------------------------------------------
+// sizeHint
+//---------------------------------------------------------
+
+QSize PosEdit::sizeHint() const
+ {
+ QFontMetrics fm(font());
+ int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth,0, this); // ddskrjo 0
+ int h = fm.height() + fw * 2;
+ int w = 4 + controls->arrowWidth() + fw * 4;
+ if (_smpte)
+ w += fm.width('9') * 10 + fm.width(ed->separator()) * 3;
+ else
+ w += fm.width('9') * 10 + fm.width(ed->separator()) * 2;
+ return QSize(w, h).expandedTo(QApplication::globalStrut());
+ }
+
+//---------------------------------------------------------
+// updateButtons
+//---------------------------------------------------------
+
+void PosEdit::updateButtons()
+ {
+ bool upEnabled = isEnabled() && (pos() < maxValue());
+ bool downEnabled = isEnabled() && (pos() > minValue());
+
+ //printf("PosEdit::updateButtons smpte:%d upEnabled:%d downEnabled:%d\n", smpte(), upEnabled, downEnabled);
+
+ controls->setStepEnabled(upEnabled, downEnabled);
+ }
+
+//---------------------------------------------------------
+// enterPressed
+//---------------------------------------------------------
+void PosEdit::enterPressed()
+ {
+ emit returnPressed();
+ }
+
+//---------------------------------------------------------
+// setEnabled
+//---------------------------------------------------------
+void PosEdit::setEnabled(bool v)
+{
+ QWidget::setEnabled(v);
+ updateButtons();
+}
diff --git a/attic/muse2-oom/muse2/muse/widgets/posedit.h b/attic/muse2-oom/muse2/muse/widgets/posedit.h
new file mode 100644
index 00000000..e17da3a2
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/posedit.h
@@ -0,0 +1,104 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: posedit.h,v 1.1.1.1.2.1 2004/12/27 19:47:25 lunar_shuttle Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __POSEDIT_H__
+#define __POSEDIT_H__
+
+#include <QWidget>
+
+#include "pos.h"
+#include "section.h"
+
+class QResizeEvent;
+class QTimerEvent;
+
+class PosEditor;
+class SpinBox;
+
+//---------------------------------------------------------
+// PosEdit
+//---------------------------------------------------------
+
+class PosEdit : public QWidget
+ {
+ Q_OBJECT
+ Q_PROPERTY(QString separator READ separator WRITE setSeparator)
+ Q_PROPERTY(bool smpte READ smpte WRITE setSmpte)
+
+ void init();
+ void setSections();
+ QString sectionText(int sec);
+ Section midiSections[3];
+ Section smpteSections[4];
+ Section* sec;
+
+ bool _smpte;
+
+ bool adv;
+ bool overwrite;
+ int timerId;
+ bool typing;
+ Pos min;
+ Pos max;
+ bool changed;
+ PosEditor *ed;
+ SpinBox* controls;
+
+ private slots:
+ void stepUp();
+ void stepDown();
+
+ signals:
+ void valueChanged(const Pos&);
+ void returnPressed();
+
+ protected:
+ bool event(QEvent *e );
+ void timerEvent(QTimerEvent* e);
+ void resizeEvent(QResizeEvent*);
+ QString sectionFormattedText(int sec);
+ void addNumber(int sec, int num);
+ void removeLastNumber(int sec);
+ bool setFocusSection(int s);
+
+ virtual bool outOfRange(int, int) const;
+ virtual void setSec(int, int);
+ friend class PosEditor;
+
+ protected slots:
+ void updateButtons();
+
+ public slots:
+ virtual void setValue(const Pos& time);
+ void setValue(int t);
+ void setValue(const QString& s);
+ // Added p3.3.43
+ virtual void setEnabled(bool);
+
+ public:
+ PosEdit(QWidget* = 0, const char* = 0);
+ PosEdit(const Pos& time, QWidget*, const char* = 0);
+ ~PosEdit();
+
+ QSize sizeHint() const;
+ Pos pos() const;
+ virtual void setAutoAdvance(bool advance) { adv = advance; }
+ bool autoAdvance() const { return adv; }
+
+ virtual void setMinValue(const Pos& d) { setRange(d, maxValue()); }
+ Pos minValue() const;
+ virtual void setMaxValue( const Pos& d ) { setRange(minValue(), d ); }
+ Pos maxValue() const;
+ virtual void setRange(const Pos& min, const Pos& max);
+ QString separator() const;
+ virtual void setSeparator(const QString& s);
+ void setSmpte(bool);
+ bool smpte() const;
+ void enterPressed();
+ };
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/poslabel.cpp b/attic/muse2-oom/muse2/muse/widgets/poslabel.cpp
new file mode 100644
index 00000000..78903a1f
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/poslabel.cpp
@@ -0,0 +1,156 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: poslabel.cpp,v 1.2.2.2 2009/04/06 01:24:55 terminator356 Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdlib.h>
+#include <cmath>
+
+#include <QApplication>
+#include <QStyle>
+
+
+#include "poslabel.h"
+///#include "sig.h"
+#include "al/sig.h"
+#include "tempo.h"
+#include "globals.h"
+
+extern int mtcType;
+
+//---------------------------------------------------------
+// PosLabel
+//---------------------------------------------------------
+
+PosLabel::PosLabel(QWidget* parent, const char* name)
+ : QLabel(parent)
+ {
+ setObjectName(name);
+ _tickValue = 0;
+ _sampleValue = 0;
+ _smpte = false;
+ setFrameStyle(WinPanel | Sunken);
+ setLineWidth(2);
+ setMidLineWidth(3);
+ //int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, this); // ddskrjo 0
+ int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
+ setIndent(fw);
+ updateValue();
+ }
+
+//---------------------------------------------------------
+// sizeHint
+//---------------------------------------------------------
+
+QSize PosLabel::sizeHint() const
+ {
+ QFontMetrics fm(font());
+ //int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, this); // ddskrjo 0
+ int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
+ int h = fm.height() + fw * 2;
+ int w;
+ if (_smpte)
+ w = 2 + fm.width('9') * 9 + fm.width(':') * 3 + fw * 4;
+ else
+ w = 2 + fm.width('9') * 9 + fm.width('.') * 2 + fw * 4;
+ return QSize(w, h).expandedTo(QApplication::globalStrut());
+ }
+
+//---------------------------------------------------------
+// updateValue
+//---------------------------------------------------------
+
+void PosLabel::updateValue()
+ {
+ QString s;
+ if (_smpte) {
+ double time = double(_sampleValue) / double(sampleRate);
+ int min = int(time) / 60;
+ int sec = int(time) % 60;
+ double rest = time - (min * 60 + sec);
+ switch(mtcType) {
+ case 0: // 24 frames sec
+ rest *= 24;
+ break;
+ case 1: // 25
+ rest *= 25;
+ break;
+ case 2: // 30 drop frame
+ rest *= 30;
+ break;
+ case 3: // 30 non drop frame
+ rest *= 30;
+ break;
+ }
+ int frame = int(rest);
+ int subframe = int((rest-frame)*100);
+ s.sprintf("%03d:%02d:%02d:%02d", min, sec, frame, subframe);
+ }
+ else {
+ int bar, beat;
+ unsigned tick;
+ AL::sigmap.tickValues(_tickValue, &bar, &beat, &tick);
+ //s.sprintf("%04d.%02d.%03ud", bar+1, beat+1, tick);
+ s.sprintf("%04d.%02d.%03u", bar+1, beat+1, tick);
+ }
+ setText(s);
+ }
+
+//---------------------------------------------------------
+// setSampleValue
+//---------------------------------------------------------
+
+void PosLabel::setSampleValue(unsigned val)
+ {
+ if (val == _sampleValue)
+ return;
+ _sampleValue = val;
+ updateValue();
+ }
+
+//---------------------------------------------------------
+// setTickValue
+//---------------------------------------------------------
+
+void PosLabel::setTickValue(unsigned val)
+ {
+ if (val == _tickValue)
+ return;
+ if (val >= MAX_TICK)
+ abort();
+ _tickValue = val;
+ updateValue();
+ }
+
+//---------------------------------------------------------
+// setValue
+//---------------------------------------------------------
+
+void PosLabel::setValue(unsigned val)
+ {
+ unsigned oval = _smpte ? _sampleValue : _tickValue;
+ if (val == oval)
+ return;
+ if (_smpte)
+ _sampleValue = val;
+ else
+ _tickValue = val;
+ updateValue();
+ }
+
+//---------------------------------------------------------
+// setSmpte
+//---------------------------------------------------------
+
+void PosLabel::setSmpte(bool val)
+ {
+ _smpte = val;
+ if (val)
+ _sampleValue = tempomap.tick2frame(_tickValue);
+ else
+ _tickValue = tempomap.frame2tick(_sampleValue);
+ updateValue();
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/poslabel.h b/attic/muse2-oom/muse2/muse/widgets/poslabel.h
new file mode 100644
index 00000000..29c5297d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/poslabel.h
@@ -0,0 +1,45 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: poslabel.h,v 1.2 2004/01/11 18:55:37 wschweer Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __POSLABEL_H__
+#define __POSLABEL_H__
+
+#include <QLabel>
+
+//---------------------------------------------------------
+// PosLabel
+//---------------------------------------------------------
+
+class PosLabel : public QLabel {
+ bool _smpte;
+ unsigned _tickValue;
+ unsigned _sampleValue;
+ Q_OBJECT
+
+ void updateValue();
+
+ protected:
+ QSize sizeHint() const;
+
+ public slots:
+ void setTickValue(unsigned);
+ void setSampleValue(unsigned);
+ void setValue(unsigned);
+
+ public:
+ PosLabel(QWidget* parent, const char* name = 0);
+ unsigned value() const { return _smpte ? _sampleValue : _tickValue; }
+ unsigned tickValue() const { return _tickValue; }
+ unsigned sampleValue() const { return _sampleValue; }
+ void setSmpte(bool);
+ bool smpte() const { return _smpte; }
+ };
+
+
+#endif
+
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/projectcreate.ui b/attic/muse2-oom/muse2/muse/widgets/projectcreate.ui
new file mode 100644
index 00000000..406c83d6
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/projectcreate.ui
@@ -0,0 +1,145 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ProjectCreate</class>
+ <widget class="QDialog" name="ProjectCreate">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>569</width>
+ <height>340</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Create Project</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Project Name:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <widget class="QLineEdit" name="projectNameEdit"/>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Fixed</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>75</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Project Path to song file:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="createFolderCheckbox">
+ <property name="text">
+ <string>Create project folder (recommended for audio projects)</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <widget class="QLineEdit" name="storageDirEdit">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="browseDirButton">
+ <property name="text">
+ <string>Browse</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Song information:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPlainTextEdit" name="commentEdit"/>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>ProjectCreate</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/projectcreateimpl.cpp b/attic/muse2-oom/muse2/muse/widgets/projectcreateimpl.cpp
new file mode 100644
index 00000000..a019df95
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/projectcreateimpl.cpp
@@ -0,0 +1,65 @@
+#include <stdio.h>
+#include <qfiledialog.h>
+#include <qdir.h>
+#include "projectcreateimpl.h"
+#include "gconfig.h"
+#include "globals.h"
+#include "app.h"
+
+ProjectCreateImpl::ProjectCreateImpl(QWidget *parent) :
+ QDialog(parent)
+{
+ setupUi(this);
+
+ createFolderCheckbox->setChecked(config.projectStoreInFolder);
+ connect(browseDirButton,SIGNAL(clicked()), this, SLOT(selectDirectory()));
+ connect(projectNameEdit,SIGNAL(textChanged(QString)), this, SLOT(updateDirectoryPath()));
+ connect(createFolderCheckbox,SIGNAL(clicked()), this, SLOT(updateDirectoryPath()));
+ connect(buttonBox, SIGNAL(accepted()), this, SLOT(ok()));
+#if QT_VERSION >= 0x040700
+ projectNameEdit->setPlaceholderText("<Project Name>");
+ // Orcan: Commented out since there is no QPlainTextEdit::setPlaceholderText()
+ // as of Qt-4.7.1
+ //commentEdit->setPlaceholderText("<Add information about project here>");
+#endif
+ directoryPath = config.projectBaseFolder;
+ updateDirectoryPath();
+ show();
+}
+
+void ProjectCreateImpl::selectDirectory()
+{
+ QFileDialog qfd;
+ qfd.selectFile(directoryPath);
+ qfd.setFileMode(QFileDialog::DirectoryOnly);
+ if (qfd.exec() == QDialog::Rejected) {
+ return;
+ }
+ directoryPath=qfd.selectedFiles().first();
+ updateDirectoryPath();
+}
+
+void ProjectCreateImpl::updateDirectoryPath()
+{
+ if (createFolderCheckbox->isChecked()) {
+ storageDirEdit->setText(directoryPath + projectNameEdit->text() + "/" + projectNameEdit->text() + ".med");
+ } else {
+ storageDirEdit->setText(directoryPath + projectNameEdit->text() + ".med");
+ }
+}
+
+QString ProjectCreateImpl::getProjectPath()
+{
+ return storageDirEdit->text();
+}
+QString ProjectCreateImpl::getSongInfo()
+{
+ return commentEdit->toPlainText();
+}
+void ProjectCreateImpl::ok()
+{
+ config.projectStoreInFolder = createFolderCheckbox->isChecked();
+ config.projectBaseFolder = directoryPath;
+ muse->changeConfig(true);
+ emit accept();
+}
diff --git a/attic/muse2-oom/muse2/muse/widgets/projectcreateimpl.h b/attic/muse2-oom/muse2/muse/widgets/projectcreateimpl.h
new file mode 100644
index 00000000..77547c1a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/projectcreateimpl.h
@@ -0,0 +1,26 @@
+#ifndef PROJECTCREATEIMPL_H
+#define PROJECTCREATEIMPL_H
+
+#include <QDialog>
+#include "ui_projectcreate.h"
+
+class ProjectCreateImpl : public QDialog, Ui::ProjectCreate
+{
+Q_OBJECT
+
+ QString directoryPath;
+public:
+ explicit ProjectCreateImpl(QWidget *parent = 0);
+ QString getProjectPath();
+ QString getSongInfo();
+
+signals:
+
+public slots:
+ void updateDirectoryPath();
+ void selectDirectory();
+ void ok();
+
+};
+
+#endif // PROJECTCREATEIMPL_H
diff --git a/attic/muse2-oom/muse2/muse/widgets/scldiv.cpp b/attic/muse2-oom/muse2/muse/widgets/scldiv.cpp
new file mode 100644
index 00000000..0a75cbd4
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/scldiv.cpp
@@ -0,0 +1,655 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: scldiv.cpp,v 1.1.1.1 2003/10/27 18:54:32 wschweer Exp $
+//
+// Copyright (C) 1997 Josef Wilgen
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2,
+// as published by the Free Software Foundation.
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <cmath>
+#include "scldiv.h"
+#include "mmath.h"
+
+// ScaleDiv - A class for building scale divisions
+//
+// The ScaleDiv class can build
+// linear and logarithmic scale divisions for specified
+// intervals. It uses an adjustable algorithm to
+// generate the major and minor step widths automatically.
+// A scale division has a minimum value, a maximum value,
+// a vector of major marks, and a vector of minor marks.
+//
+// ScaleDiv uses implicit sharing for the mark vectors.
+//
+// Build a logarithmic scale division from 0.01 to 1000
+// and print out the major and minor marks.
+//.c
+// #include <scldiv.h>
+// #include <iostream.h>
+//
+// main()
+// {
+// int i,k;
+// ScaleDiv sd;
+//
+// sd.rebuild(0.01, 100, 10, 10, TRUE, 0.0);
+//
+// k=0;
+// for (i=0;i<sd.majCnt();i++)
+// {
+// while(k < sd.minCnt())
+// {
+// if(sd.minMark(k) < sd.majMark(i))
+// {
+// cout << " - " << sd.minMark(i) << "\n";
+// k++;
+// }
+// else
+// break;
+// }
+// cout << "-- " << sd.majMark(i) << "\n";
+// }
+// while(k < sd.minCnt())
+// {
+// cout << " - " << sd.minMark(i) << "\n";
+// k++;
+// }
+// }
+//
+//------------------------------------------------------------
+
+static const double step_eps = 1.0e-3;
+static const double border_eps = 1.0e-10;
+
+static bool limRange(double &val, double v1, double v2, double eps_rel = 0.0,
+ double eps_abs = 0.0)
+ {
+
+ bool rv = TRUE;
+ double vmin = qwtMin(v1, v2);
+ double vmax = qwtMax(v1, v2);
+ double delta_min = qwtMax(qwtAbs(eps_rel * vmin), qwtAbs(eps_abs));
+ double delta_max = qwtMax(qwtAbs(eps_rel * vmax), qwtAbs(eps_abs));
+
+ if (val < vmin)
+ {
+ if (val < vmin - delta_min) rv = FALSE;
+ val = vmin;
+ }
+ else if (val > vmax)
+ {
+ if (val > vmax + delta_max) rv = FALSE;
+ val = vmax;
+ }
+ return rv;
+
+}
+
+//------------------------------------------------------------
+//.F ScaleDiv::ScaleDiv
+// Construct a ScaleDiv instance.
+//
+//.u Syntax
+//.f ScaleDiv::ScaleDiv()
+//------------------------------------------------------------
+
+ScaleDiv::ScaleDiv()
+ {
+ d_lBound = 0.0;
+ d_hBound = 0.0;
+ d_majStep = 0.0;
+ d_log = FALSE;
+ }
+
+//------------------------------------------------------------
+//.F ScaleDiv::~ScaleDiv
+// Destroy a ScaleDiv instance.
+//
+//.u Syntax
+//.f ScaleDiv::~ScaleDiv()
+//------------------------------------------------------------
+
+ScaleDiv::~ScaleDiv()
+ {
+ }
+
+//------------------------------------------------------------
+//.F ScaleDiv::ScaleDiv
+// Copy Constructor
+//
+//.u Syntax
+//.f ScaleDiv::ScaleDiv(const ScaleDiv &s)
+//
+//.u Parameters
+//.p const ScaleDiv &s -- scale division to be copied
+//------------------------------------------------------------
+
+ScaleDiv::ScaleDiv(const ScaleDiv &s)
+ {
+ copy(s);
+ }
+
+//------------------------------------------------------------
+//.F ScaleDiv::operator=
+// Assignment operator
+//
+//.u Syntax
+//.f ScaleDiv & ScaleDiv::operator=(const ScaleDiv &s)
+//
+//.u Parameters
+//.p const ScaleDiv &s -- scale divison to be assigned
+//------------------------------------------------------------
+
+ScaleDiv& ScaleDiv::operator=(const ScaleDiv &s)
+ {
+ copy(s);
+ return *this;
+ }
+
+//------------------------------------------------------------
+//.F ScaleDiv::copy
+// Copy member data from another ScaleDiv instance.
+//
+//.u Syntax
+//.f void ScaleDiv::copy(const ScaleDiv &s)
+//
+//.u Parameters
+//.p const ScaleDiv &s
+//------------------------------------------------------------
+
+void ScaleDiv::copy(const ScaleDiv &s)
+ {
+ d_lBound = s.d_lBound;
+ d_hBound = s.d_hBound;
+ d_log = s.d_log;
+ d_majStep = s.d_majStep;
+ d_minMarks = s.d_minMarks;
+ d_majMarks = s.d_majMarks;
+ }
+
+//------------------------------------------------------------
+//.F ScaleDiv::rebuild
+// Build a scale width major and minor divisions
+//
+//.p
+// double x1 -- first boundary value
+// double x2 -- second boundary value
+// int maxMajSteps -- max. number of major step intervals
+// int maxMinSteps -- max. number of minor step intervals
+// bool log -- logarithmic division (TRUE/FALSE)
+// double step -- fixed major step width. Defaults to 0.0.
+// bool ascend -- if TRUE, sort in ascending order from min(x1, x2)
+// to max(x1, x2). If FALSE, sort in the direction
+// from x1 to x2. Defaults to TRUE.
+//
+//.u Return Value
+// True if the arrays have been allocated successfully.
+//
+//.u Description
+// If no fixed step width is specified or if it is set to 0, the
+// major step width will be calculated automatically according to the
+// the value of maxMajSteps. The maxMajSteps parameter has no effect
+// if a fixed step size is specified. The minor step width is always
+// calculated automatically.
+// If the step width is to be calculated automatically, the algorithm
+// tries to find reasonable values fitting into the scheme {1,2,5}*10^n
+// with an integer number n for linear scales.
+// For logarithmic scales, there are three different cases:
+//.i
+// -- If the major step width is one decade, the minor marks
+// will fit into one of the schemes {1,2,...9}, {2,4,6,8}, {2,5} or {5},
+// depending on the maxMinSteps parameter.
+// -- If the major step size spans
+// more than one decade, the minor step size will be {1,2,5}*10^n decades
+// with a natural number n.
+// -- If the whole range is less than one decade, a linear scale
+// division will be built
+//
+//.u Note
+// For logarithmic scales, the step width is measured in decades.
+//------------------------------------------------------------
+
+bool ScaleDiv::rebuild(double x1, double x2, int maxMajSteps, int maxMinSteps,
+ bool log, double step, bool ascend)
+{
+
+ int rv;
+
+ d_lBound = qwtMin(x1, x2);
+ d_hBound = qwtMax(x1, x2);
+ d_log = log;
+
+ if (d_log)
+ rv = buildLogDiv(maxMajSteps,maxMinSteps,step);
+ else
+ rv = buildLinDiv(maxMajSteps, maxMinSteps, step);
+
+ if ((!ascend) && (x2 < x1))
+ {
+ d_lBound = x1;
+ d_hBound = x2;
+ qwtTwistArray(d_majMarks.data(), d_majMarks.size());
+ qwtTwistArray(d_minMarks.data(), d_minMarks.size());
+ }
+
+ return rv;
+
+}
+
+//------------------------------------------------------------
+//.F ScaleDiv::buildLinDiv
+// Build a linear scale division in ascending order
+//
+//.u Syntax
+//.f bool ScaleDiv::buildLinDiv(int majSteps, int minSteps, double step)
+//
+//.u Parameters
+//.p int maxSteps -- max. number of step intervals
+// double step -- fixed step width
+//
+//.u Return Value
+// TRUE if array has been successfully resized
+//
+//.u Description
+// If the 'step' parameter is set to 0.0, this function
+// cal[culates the step width automatically according to
+// the value of 'maxSteps'. MaxSteps must be greater than or
+// equal to 2. It will be guessed if an invalid value is specified.
+// The maximum possible number of steps is limited to 10000.
+// The maxSteps parameter has no effect if a fixed step width is
+// specified.
+//
+//.u Note
+// This function uses the data members d_lBound and d_hBound and assumes
+// that d_hBound > d_lBound.
+//------------------------------------------------------------
+
+bool ScaleDiv::buildLinDiv(int maxMajSteps, int maxMinSteps, double step)
+ {
+
+ int nMaj, nMin, minSize, i0,i,k;
+ double val, mval;
+ double firstTick, lastTick;
+ double minStep;
+ QVector<double> buffer;
+ bool rv = TRUE;
+
+ // parameter range check
+ maxMajSteps = qwtMax(1, maxMajSteps);
+ maxMinSteps = qwtMax(0, maxMinSteps);
+ step = qwtAbs(step);
+
+ // reset vectors
+ d_minMarks.resize(0);
+ d_majMarks.resize(0);
+
+ if (d_lBound == d_hBound) return TRUE;
+
+ //
+ // Set up major divisions
+ //
+ if (step == 0.0)
+ d_majStep = qwtCeil125(qwtAbs(d_hBound - d_lBound) * 0.999999
+ / double(maxMajSteps));
+ else
+ d_majStep = step;
+
+ if (d_majStep == 0.0) return TRUE;
+
+ firstTick = ceil( (d_lBound - step_eps * d_majStep) / d_majStep) * d_majStep;
+ lastTick = floor( (d_hBound + step_eps * d_majStep) / d_majStep) * d_majStep;
+
+ nMaj = qwtMin(10000, int(rint((lastTick - firstTick) / d_majStep)) + 1);
+
+ d_majMarks.resize(nMaj);
+ qwtLinSpace(d_majMarks.data(), d_majMarks.size(), firstTick, lastTick);
+
+ //
+ // Set up minor divisions
+ //
+ if (maxMinSteps < 1) // no minor divs
+ return TRUE;
+
+ minStep = qwtCeil125( d_majStep / double(maxMinSteps) );
+
+ if (minStep == 0.0) return TRUE;
+
+ nMin = qwtAbs(int(rint(d_majStep / minStep))) - 1; // # minor steps per interval
+
+ // Do the minor steps fit into the interval?
+ if ( qwtAbs(double(nMin + 1) * minStep - d_majStep) > step_eps * d_majStep)
+ {
+ nMin = 1;
+ minStep = d_majStep * 0.5;
+ }
+
+ // Are there minor ticks below the first major tick?
+ if (d_majMarks[0] > d_lBound )
+ i0 = -1;
+ else
+ i0 = 0;
+
+ // resize buffer to the maximum possible number of minor ticks
+ buffer.resize(nMin * (nMaj + 1));
+
+ // calculate minor ticks
+ if (rv)
+ {
+ minSize = 0;
+ for (i = i0; i < (int)d_majMarks.size(); i++)
+ {
+ if (i >= 0)
+ val = d_majMarks[i];
+ else
+ val = d_majMarks[0] - d_majStep;
+
+ for (k=0; k< nMin; k++)
+ {
+ mval = (val += minStep);
+ if (limRange(mval, d_lBound, d_hBound, border_eps))
+ {
+ buffer[minSize] = mval;
+ minSize++;
+ }
+ }
+ }
+ //d_minMarks.duplicate(buffer.data(), minSize);
+ d_minMarks.resize(minSize);
+ qCopy(buffer.data(), buffer.data() + minSize, d_minMarks.begin());
+ }
+
+ return rv;
+ }
+
+//------------------------------------------------------------
+//.F ScaleDiv::buildLogDiv
+// Build a logarithmic scale division
+//
+//.u Syntax
+//.f bool ScaleDiv::buildLogDiv(int maxMajSteps, int maxMinSteps, int majStep)
+//
+//.u Parameters
+//.p int maxMajSteps, int maxMinSteps, int majStep
+//
+//.u Return Value
+// True if memory has been successfully allocated
+//
+//.u Note
+// This function uses the data members d_lBound and d_hBound and assumes
+// that d_hBound > d_lBound.
+//------------------------------------------------------------
+
+bool ScaleDiv::buildLogDiv(int maxMajSteps, int maxMinSteps, double majStep)
+ {
+ double firstTick, lastTick;
+ double lFirst, lLast;
+ double val, sval, minStep, minFactor;
+ int nMaj, nMin, minSize, i, k, k0, kstep, kmax, i0;
+ int rv = TRUE;
+ double width;
+
+ QVector<double> buffer;
+
+
+ // Parameter range check
+ maxMajSteps = qwtMax(1, qwtAbs(maxMajSteps));
+ maxMinSteps = qwtMax(0, qwtAbs(maxMinSteps));
+ majStep = qwtAbs(majStep);
+
+ // boundary check
+ limRange(d_hBound, LOG_MIN, LOG_MAX);
+ limRange(d_lBound, LOG_MIN, LOG_MAX);
+
+ // reset vectors
+ d_minMarks.resize(0);
+ d_majMarks.resize(0);
+
+ if (d_lBound == d_hBound) return TRUE;
+
+ // scale width in decades
+ width = log10(d_hBound) - log10(d_lBound);
+
+ // scale width is less than one decade -> build linear scale
+ if (width < 1.0)
+ {
+ rv = buildLinDiv(maxMajSteps, maxMinSteps, 0.0);
+ // convert step width to decades
+ if (d_majStep > 0)
+ d_majStep = log10(d_majStep);
+
+ return rv;
+ }
+
+ //
+ // Set up major scale divisions
+ //
+ if (majStep == 0.0)
+ d_majStep = qwtCeil125( width * 0.999999 / double(maxMajSteps));
+ else
+ d_majStep = majStep;
+
+ // major step must be >= 1 decade
+ d_majStep = qwtMax(d_majStep, 1.0);
+
+
+ lFirst = ceil((log10(d_lBound) - step_eps * d_majStep) / d_majStep) * d_majStep;
+ lLast = floor((log10(d_hBound) + step_eps * d_majStep) / d_majStep) * d_majStep;
+
+ firstTick = pow(10.0, lFirst);
+ lastTick = pow(10.0, lLast);
+
+ nMaj = qwtMin(10000, int(rint(qwtAbs(lLast - lFirst) / d_majStep)) + 1);
+
+ d_majMarks.resize(nMaj);
+ qwtLogSpace(d_majMarks.data(), d_majMarks.size(), firstTick, lastTick);
+
+
+ //
+ // Set up minor scale divisions
+ //
+
+ if ((d_majMarks.size() < 1) || (maxMinSteps < 1)) return TRUE; // no minor marks
+
+ if (d_majStep < 1.1) // major step width is one decade
+ {
+ if (maxMinSteps >= 8)
+ {
+ k0 = 2;
+ kmax = 9;
+ kstep = 1;
+ minSize = (d_majMarks.size() + 1) * 8;
+ }
+ else if (maxMinSteps >= 4)
+ {
+ k0 = 2;
+ kmax = 8;
+ kstep = 2;
+ minSize = (d_majMarks.size() + 1) * 4;
+ }
+ else if (maxMinSteps >= 2)
+ {
+ k0 = 2;
+ kmax = 5;
+ kstep = 3;
+ minSize = (d_majMarks.size() + 1) * 2;
+ }
+ else
+ {
+ k0 = 5;
+ kmax = 5;
+ kstep = 1;
+ minSize = (d_majMarks.size() + 1);
+ }
+
+ // resize buffer to the max. possible number of minor marks
+ buffer.resize(minSize);
+
+ // Are there minor ticks below the first major tick?
+ if ( d_lBound < firstTick )
+ i0 = -1;
+ else
+ i0 = 0;
+
+ minSize = 0;
+ for (i = i0; i< (int)d_majMarks.size(); i++)
+ {
+ if (i >= 0)
+ val = d_majMarks[i];
+ else
+ val = d_majMarks[0] / pow(10.0, d_majStep);
+
+ for (k=k0; k<= kmax; k+=kstep)
+ {
+ sval = val * double(k);
+ if (limRange(sval, d_lBound, d_hBound, border_eps))
+ {
+ buffer[minSize] = sval;
+ minSize++;
+ }
+ }
+ }
+
+ // copy values into the minMarks array
+ //d_minMarks.duplicate(buffer.data(), minSize);
+ d_minMarks.resize(minSize);
+ qCopy(buffer.data(), buffer.data() + minSize, d_minMarks.begin());
+
+
+ }
+ else // major step > one decade
+ {
+
+ // substep width in decades, at least one decade
+ minStep = qwtCeil125( (d_majStep - step_eps * (d_majStep / double(maxMinSteps)))
+ / double(maxMinSteps) );
+ minStep = qwtMax(1.0, minStep);
+
+ // # subticks per interval
+ nMin = int(rint(d_majStep / minStep)) - 1;
+
+ // Do the minor steps fit into the interval?
+ if ( qwtAbs( double(nMin + 1) * minStep - d_majStep) > step_eps * d_majStep)
+ nMin = 0;
+
+ if (nMin < 1) return TRUE; // no subticks
+
+ // resize buffer to max. possible number of subticks
+ buffer.resize((d_majMarks.size() + 1) * nMin );
+
+ // substep factor = 10^substeps
+ minFactor = qwtMax(pow(10,minStep), 10.0);
+
+ // Are there minor ticks below the first major tick?
+ if ( d_lBound < firstTick )
+ i0 = -1;
+ else
+ i0 = 0;
+
+ minSize = 0;
+ for (i = i0; i< (int)d_majMarks.size(); i++)
+ {
+ if (i >= 0)
+ val = d_majMarks[i];
+ else
+ val = firstTick / pow(10.0, d_majStep);
+
+ for (k=0; k< nMin; k++)
+ {
+ sval = (val *= minFactor);
+ if (limRange(sval, d_lBound, d_hBound, border_eps))
+ {
+ buffer[minSize] = sval;
+ minSize++;
+ }
+ }
+ }
+ //d_minMarks.duplicate(buffer.data(), minSize);
+ d_minMarks.resize(minSize);
+ qCopy(buffer.data(), buffer.data() + minSize, d_minMarks.begin());
+
+ }
+
+ return rv;
+}
+
+//------------------------------------------------------------
+//.F ScaleDiv::operator==
+// Equality operator
+//
+//.u Syntax
+//.f int ScaleDiv::operator==(const ScaleDiv &s)
+//
+//.u Parameters
+//.p const ScaleDiv &s
+//
+//.u Return Value
+// TRUE if this instance is equal to s
+//------------------------------------------------------------
+
+int ScaleDiv::operator==(const ScaleDiv &s) const
+ {
+ if (d_lBound != s.d_lBound)
+ return 0;
+ if (d_hBound != s.d_hBound)
+ return 0;
+ if (d_log != s.d_log)
+ return 0;
+ if (d_majStep != s.d_majStep)
+ return 0;
+ if (d_majMarks != s.d_majMarks)
+ return 0;
+ return (d_minMarks == s.d_minMarks);
+ }
+
+//------------------------------------------------------------
+//.F ScaleDiv::operator!=
+// Inequality
+//
+//.u Syntax
+//.f int ScaleDiv::operator!=(const ScaleDiv &s)
+//
+//.u Parameters
+//.p const ScaleDiv &s
+//
+//.u Return Value
+// TRUE if this instance is not equal to s
+//------------------------------------------------------------
+
+int ScaleDiv::operator!=(const ScaleDiv &s) const
+ {
+ return (!(*this == s));
+ }
+
+//------------------------------------------------------------
+//.F ScaleDiv::reset
+// Detach the shared data and set everything to zero.
+//
+//.u Syntax
+//.f void ScaleDiv::reset()
+//------------------------------------------------------------
+
+void ScaleDiv::reset()
+ {
+ // reset vectors
+ d_minMarks.resize(0);
+ d_majMarks.resize(0);
+
+
+ d_lBound = 0.0;
+ d_hBound = 0.0;
+ d_majStep = 0.0;
+ d_log = FALSE;
+ }
+
+
+
+
+
+
+
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/scldiv.h b/attic/muse2-oom/muse2/muse/widgets/scldiv.h
new file mode 100644
index 00000000..3d1e1d58
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/scldiv.h
@@ -0,0 +1,56 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: scldiv.h,v 1.1.1.1 2003/10/27 18:54:43 wschweer Exp $
+//
+// Copyright (C) 1997 Josef Wilgen
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2,
+// as published by the Free Software Foundation.
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SCLDIV_H__
+#define __SCLDIV_H__
+
+#include <QVector>
+
+class ScaleDiv
+ {
+ double d_lBound;
+ double d_hBound;
+ double d_majStep;
+ bool d_log;
+
+ QVector<double> d_majMarks;
+ QVector<double> d_minMarks;
+
+ void copy(const ScaleDiv &s);
+
+ bool buildLinDiv(int maxMajMark, int maxMinMark, double step = 0.0);
+ bool buildLogDiv(int maxMajMark, int maxMinMark, double step = 0.0);
+
+ public:
+ ScaleDiv ();
+ virtual ~ScaleDiv();
+ ScaleDiv(const ScaleDiv& s);
+
+ ScaleDiv& operator= (const ScaleDiv &s);
+ int operator== (const ScaleDiv &s) const;
+ int operator!= (const ScaleDiv &s) const;
+
+ double lBound() const { return d_lBound; }
+ double hBound() const { return d_hBound; }
+ int minCnt() const { return d_minMarks.size(); }
+ int majCnt() const { return d_majMarks.size(); }
+ bool logScale() const { return d_log; }
+ double majMark(int i) const { return d_majMarks[i]; }
+ double minMark(int i) const { return d_minMarks[i]; }
+ double majStep() const { return d_majStep; }
+ void reset();
+ bool rebuild(double lBound, double hBound, int maxMaj, int maxMin,
+ bool log, double step = 0.0, bool ascend = TRUE);
+ };
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/scldraw.cpp b/attic/muse2-oom/muse2/muse/widgets/scldraw.cpp
new file mode 100644
index 00000000..709e104a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/scldraw.cpp
@@ -0,0 +1,881 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: scldraw.cpp,v 1.1.1.1 2003/10/27 18:54:36 wschweer Exp $
+//
+// Copyright (C) 1997 Josef Wilgen
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2,
+// as published by the Free Software Foundation.
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <cmath>
+
+#include <QPainter>
+
+#include "mmath.h"
+#include "scldraw.h"
+
+
+int const ScaleDraw::minLen = 10;
+
+const double step_eps = 1.0e-6;
+static const double WorstCase = -8.8888888888888888888888e-88;
+
+//------------------------------------------------------------
+//.H ScaleDraw | 3 | 30/08/97 | Qwt Widget Library | Qwt Programmer's Manual
+//.I scldraw Different Scales
+//.U NAME
+// ScaleDraw - A class for drawing scales
+//
+//.U SYNOPSIS
+// #include <qwt_scldraw.h>
+//
+//.U DESCRIPTION
+// ScaleDraw can be used to draw linear or logarithmic scales.
+// A scale has an origin,
+// an orientation and a length, which all can be specified with
+// @ScaleDraw::setGeometry@.
+// After a scale division has been specified as a @^QwtScaleDiv@ object
+// using @ScaleDraw::setScale (1)@
+// or determined internally using @ScaleDraw::setScale (2)@,
+// the scale can be drawn with the @QwtScaleDiv::draw@ member.
+//
+//.U INHERITED CLASSES
+// @QwtDiMap@
+//
+//.U PUBLIC MEMBERS
+//.R
+// ScaleDraw::ScaleDraw -- constructor
+// ScaleDraw::setScale (1) -- set scale using QwtScaleDiv
+// ScaleDraw::setScale (2) -- set scale directly
+// ScaleDraw::setGeometry -- specify geometry
+// ScaleDraw::setAngleRange -- specify angle range for round scales
+// ScaleDraw::setLabelFormat -- set number format
+// ScaleDraw::scalediv -- return scale division
+// ScaleDraw::orientation -- return orientation
+// ScaleDraw::maxBoundingRect -- return maximum bounding rectangle
+// ScaleDraw::maxWidth -- return maximum width
+// ScaleDraw::maxHeight -- return maximum height
+// ScaleDraw::maxLabelWidth -- return maximum width of the number labels
+// ScaleDraw::draw -- draw the scale
+//
+//.U STATIC DATA MEMBERS
+//.t
+// enum ScaleDraw::Orientation { Left, Right, Top, Bottom, Round } --
+// Scale orientation
+//------------------------------------------------------------
+
+//------------------------------------------------------------
+//.U MEMBER FUNCTION DESCRIPTION
+//------------------------------------------------------------
+
+//------------------------------------------------------------
+//
+//.F ScaleDraw::ScaleDraw
+//
+// Constructor
+//.u Description
+// The range of the scale is initialized to [0, 100],
+// the angle range is set to [-135, 135], the geometry
+// is initialized such that the origin is at (0,0), the
+// length is 100, and the orientation is ScaleDraw::Bottom.
+//
+//------------------------------------------------------------
+ScaleDraw::ScaleDraw()
+{
+/* d_hpad = 6;
+ d_vpad = 3;
+ d_majLen = 8;
+ d_medLen = 6;
+ d_minLen = 4;
+ */
+
+ d_hpad = 3;
+ d_vpad = 1;
+ d_majLen = 4;
+ d_medLen = 3;
+ d_minLen = 2;
+
+ d_minAngle = -135 * 16;
+ d_maxAngle = 135 * 16;
+ d_fmt = 'g';
+ d_prec = 4;
+
+ // initialize scale and geometry
+ setGeometry(0,0,100,Bottom);
+ setScale(0,100,0,0,10);
+}
+
+
+//------------------------------------------------------------
+//
+//.F ScaleDraw::setScale (1)
+// Adjust the range of the scale
+//
+//.u Syntax
+//.f void ScaleDraw::setScale(double x1, double x2, double step, int logscale)
+//
+//.u Parameters
+//.p double x1 -- value at the left/low endpoint of the scale
+// double x2 -- value at the right/high endpoint of the scale
+// double step -- step size (default : 0.0)
+// int logscale -- logarithmic scale (default : 0)
+//
+//.u Description
+// If step == 0.0, the step width is calculated automatically
+// dependent on the maximal number of scale ticks.
+//
+//------------------------------------------------------------
+void ScaleDraw::setScale(double x1, double x2, int maxMajIntv,
+ int maxMinIntv, double step, int logscale)
+{
+ d_scldiv.rebuild( x1, x2, maxMajIntv, maxMinIntv, logscale, step, FALSE );
+ setDblRange( d_scldiv.lBound(), d_scldiv.hBound(), d_scldiv.logScale());
+}
+
+
+//------------------------------------------------------------
+//
+//.F ScaleDraw::setScale (2)
+// Change the scale division
+//
+//.u Syntax
+//.f void ScaleDraw::setScale(QwtAutoScale &as)
+//
+//.u Parameters
+//.p const QwtScaleDiv& sd -- new scale division
+//
+//------------------------------------------------------------
+
+void ScaleDraw::setScale(const ScaleDiv &s)
+{
+ d_scldiv = s;
+ setDblRange(d_scldiv.lBound(),d_scldiv.hBound(),d_scldiv.logScale());
+}
+
+
+
+//------------------------------------------------------------
+//.F ScaleDraw::draw
+// Draw the scale
+//.u Parameters
+//.p QPainter *p -- the painter
+//------------------------------------------------------------
+
+void ScaleDraw::draw(QPainter *p) const
+ {
+ double val,hval,majTick;
+
+ int i,k,kmax;
+
+ for (i=0; i< d_scldiv.majCnt(); i++)
+ {
+ val = d_scldiv.majMark(i);
+ drawTick(p, val, d_majLen);
+ drawLabel(p, val);
+ }
+
+ if (d_scldiv.logScale())
+ {
+ for (i=0; i< d_scldiv.minCnt(); i++)
+ {
+ drawTick(p,d_scldiv.minMark(i),d_minLen);
+ }
+ }
+ else
+ {
+ k = 0;
+ kmax = d_scldiv.majCnt() - 1;
+ if (kmax > 0)
+ {
+ majTick = d_scldiv.majMark(0);
+ hval = majTick - 0.5 * d_scldiv.majStep();
+
+ for (i=0; i< d_scldiv.minCnt(); i++)
+ {
+ val = d_scldiv.minMark(i);
+ if (val > majTick)
+ {
+ if (k < kmax)
+ {
+ k++;
+ majTick = d_scldiv.majMark(k);
+ }
+ else
+ {
+ majTick += d_scldiv.majMark(kmax) + d_scldiv.majStep();
+ }
+ hval = majTick - 0.5 * d_scldiv.majStep();
+
+ }
+ if (qwtAbs(val-hval) < step_eps * d_scldiv.majStep())
+ drawTick(p, val, d_medLen);
+ else
+ drawTick(p, val, d_minLen);
+ }
+ }
+ }
+
+ //
+ // draw backbone
+ //
+ //if (d_baseEnabled)
+ drawBackbone(p);
+
+}
+
+
+//------------------------------------------------------------
+//.F ScaleDraw::drawTick
+// Draws a singls scale tick
+//
+//.u Parameters
+//.p QPainter *p, double val, int len
+//------------------------------------------------------------
+
+void ScaleDraw::drawTick(QPainter *p, double val, int len) const
+ {
+ int tval = transform(val);
+ double arc;
+ int x1, x2, y1, y2;
+
+ switch(d_orient)
+ {
+ case Right:
+
+ p->drawLine(d_xorg, tval, d_xorg + len, tval);
+ break;
+
+ case Bottom:
+
+ p->drawLine(tval, d_yorg, tval, d_yorg + len);
+ break;
+
+ case Left:
+
+ p->drawLine(d_xorg, tval, d_xorg - len, tval);
+ break;
+
+ case Round:
+
+ if ((tval <= d_minAngle + 359 * 16) || (tval >= d_minAngle - 359 * 16))
+ {
+ arc = double(tval) / 16.0 * M_PI / 180.0;
+ x1 = qwtInt(d_xCenter + sin(arc) * d_radius);
+ x2 = qwtInt(d_xCenter + sin(arc) * (d_radius + double(len)));
+ y1 = qwtInt(d_yCenter - cos(arc) * d_radius);
+ y2 = qwtInt(d_yCenter - cos(arc) * (d_radius + double(len)));
+ p->drawLine(x1, y1, x2, y2);
+ }
+ break;
+
+ case Top:
+ default:
+
+ p->drawLine(tval, d_yorg, tval, d_yorg - len);
+ break;
+
+
+ }
+
+}
+
+
+
+
+//------------------------------------------------------------
+//.-
+//.F ScaleDraw::drawLabel
+// Draws the number label for a major scale tick
+//
+//.u Parameters
+//.p QPainter *p, double val
+//
+//------------------------------------------------------------
+void ScaleDraw::drawLabel(QPainter *p, double val) const
+{
+
+ static QString label;
+ static double pi_4 = M_PI * 0.25;
+ static double pi_75 = M_PI * 0.75;
+
+ double arc;
+ int xpos, ypos;
+ int tval;
+
+ QFontMetrics fm = p->fontMetrics();
+
+ tval = transform(val);
+
+ // correct rounding errors if val = 0
+ if ((!d_scldiv.logScale()) && (qwtAbs(val) < qwtAbs(step_eps * d_scldiv.majStep())))
+ val = 0.0;
+
+ label.setNum(val, d_fmt, d_prec);
+
+ switch(d_orient)
+ {
+ case Right:
+ p->drawText(d_xorg + d_majLen + d_hpad,
+ tval + (fm.ascent()-1) / 2,
+ label);
+ break;
+ case Left:
+ p->drawText(d_xorg - d_majLen - d_hpad - fm.width(label),
+ tval + (fm.ascent() -1) / 2,
+ label);
+ break;
+ case Bottom:
+ p->drawText(tval - (fm.width(label)-1) / 2, d_yorg + d_majLen + d_vpad + fm.ascent(), label);
+ break;
+ case Round:
+
+ if ((tval > d_minAngle + 359 * 16) || (tval < d_minAngle - 359 * 16))
+ break;
+
+ arc = double(tval) / 16.0 * M_PI / 180.0;
+
+ // Map arc into the interval -pi <= arc <= pi
+ if ((arc < -M_PI) || (arc > M_PI))
+ arc -= floor((arc + M_PI) / M_PI * 0.5) * 2.0 * M_PI;
+
+ xpos = 1 + qwtInt(d_xCenter + (d_radius + double(d_majLen + d_vpad)) * sin(arc));
+ ypos = qwtInt(d_yCenter - (d_radius + double(d_majLen + d_vpad)) * cos(arc));
+
+ if (arc < -pi_75)
+ {
+ p->drawText(xpos - qwtInt(double(fm.width(label))
+ * (1.0 + (arc + pi_75) * M_2_PI) ),
+ ypos + fm.ascent() - 1,
+ label);
+ }
+ else if (arc < -M_PI_4)
+ {
+ p->drawText(xpos - fm.width(label),
+
+
+ ypos - qwtInt(double(fm.ascent() - 1)
+ * (arc + M_PI_4) * M_2_PI),
+ label);
+ }
+ else if (arc < pi_4)
+ {
+ p->drawText(xpos + qwtInt(double(fm.width(label))
+ * ( arc - M_PI_4 ) * M_2_PI ),
+ ypos,
+ label);
+ }
+ else if (arc < pi_75)
+ {
+ p->drawText(xpos,
+ ypos + qwtInt(double(fm.ascent() - 1)
+ * (arc - M_PI_4) * M_2_PI),
+ label);
+ }
+ else
+ {
+ p->drawText(xpos - qwtInt(double(fm.width(label))
+ * ( arc - pi_75) * M_2_PI ),
+ ypos + fm.ascent() - 1,
+ label);
+ }
+ break;
+ case Top:
+ default:
+ p->drawText(tval - (fm.width(label)-1) / 2, d_yorg - d_majLen - d_vpad, label);
+ break;
+ }
+
+
+
+}
+
+//------------------------------------------------------------
+//.-
+//.F ScaleDraw::drawBackbone
+// Draws the baseline of the scale
+//
+//
+//.u Parameters
+//.p QPainter *p
+//
+//------------------------------------------------------------
+void ScaleDraw::drawBackbone(QPainter *p) const
+{
+ int bw2;
+ int a1, a2;
+ bw2 = p->pen().width() / 2;
+
+
+ switch(d_orient)
+ {
+ case Left:
+ p->drawLine(d_xorg - bw2, d_yorg, d_xorg - bw2, d_yorg + d_len - 1);
+ break;
+ case Right:
+ p->drawLine(d_xorg + bw2, d_yorg, d_xorg + bw2, d_yorg + d_len - 1);
+ break;
+ case Round:
+
+ a1 = qwtMin(i1(), i2()) - 90 * 16;
+ a2 = qwtMax(i1(), i2()) - 90 * 16;
+
+ p->drawArc(d_xorg, d_yorg, d_len,
+ d_len,
+ -a2, a2 - a1 + 1); // counterclockwise
+
+ break;
+
+ case Top:
+ p->drawLine(d_xorg, d_yorg - bw2, d_xorg + d_len - 1, d_yorg-bw2);
+ break;
+ case Bottom:
+ p->drawLine(d_xorg, d_yorg+bw2, d_xorg + d_len - 1, d_yorg+bw2);
+ break;
+ default:
+ p->drawLine(d_xorg, d_yorg, d_xorg + d_len - 1, d_yorg);
+ break;
+ }
+
+}
+
+
+//------------------------------------------------------------
+//
+//.F ScaleDraw::setGeometry
+// Specify the geometry of the scale
+//
+//
+//.u Parameters
+//.p int xorigin -- x coordinate of the origin
+// int yorigin -- y coordinate of the origin
+// int length -- length or diameter of the scale
+// Orientation o -- The orientation
+//
+//.u Description
+//
+// The parameters xorigin, yorigin and length have different meanings,
+// dependent on the
+// orientation:
+//.t
+// ScaleDraw::Left -- The origin is the topmost point of the
+// baseline. The baseline is a vertical line with the
+// specified length. Scale marks and labels are drawn
+// at the left of the baseline.
+//
+// ScaleDraw::Right -- The origin is the topmost point of the
+// baseline. The baseline is a vertical line with the
+// specified length. Scale marks and labels are drawn
+// at the right of the baseline.
+//
+// ScaleDraw::Top -- The origin is the leftmost point of the
+// baseline. The baseline is a horizontal line with the
+// specified length. Scale marks and labels are drawn
+// above the baseline.
+//
+// ScaleDraw::Bottom -- The origin is the leftmost point of the
+// baseline. The baseline is a horizontal line with the
+// specified length. Scale marks and labels are drawn
+// below the baseline.
+//
+// ScaleDraw::Round -- The origin is the top left corner of the
+// bounding rectangle of the baseline circle. The baseline
+// is the segment of a circle with a diameter of the specified length.
+// Scale marks and labels are drawn outside the baseline
+// circle.
+//
+//------------------------------------------------------------
+void ScaleDraw::setGeometry(int xorigin, int yorigin, int length, OrientationX o)
+{
+
+ d_xorg = xorigin;
+ d_yorg = yorigin;
+ d_radius = double(length) * 0.5;
+ d_xCenter = double(xorigin) + double(length) * 0.5;
+ d_yCenter = double(yorigin) + double(length) * 0.5;
+
+ if (length > minLen)
+ d_len = length;
+ else
+ d_len = minLen;
+
+ d_orient = o;
+
+ switch(d_orient)
+ {
+ case Left:
+ case Right:
+ setIntRange(d_yorg + d_len - 1, d_yorg);
+ break;
+ case Round:
+ setIntRange(d_minAngle, d_maxAngle);
+ break;
+ case Top:
+ case Bottom:
+ default:
+ setIntRange(d_xorg, d_xorg + d_len - 1);
+ break;
+ }
+}
+
+
+
+//------------------------------------------------------------
+//
+//.F ScaleDraw::maxWidth
+// Return the maximum width of the scale for a specified QPainter
+//
+//.u Syntax
+//.f int ScaleDraw::maxWidth(QPainter *p)
+//
+//.u Parameters
+//.p QPainter *p -- painter
+// bool worst -- if TRUE, assume the worst possible case. If FALSE,
+// calculate the real maximum width, which is more
+// CPU intensive.
+//
+//------------------------------------------------------------
+int ScaleDraw::maxWidth(QPainter *p, bool worst) const
+{
+ int rv = 0;
+ int bw = p->pen().width();
+
+ QString s;
+
+ QFontMetrics fm = p->fontMetrics();
+
+ rv = maxLabelWidth(p,worst);
+
+ switch (d_orient)
+ {
+ case Left:
+ case Right:
+ rv += (bw + d_hpad + d_majLen);
+ break;
+ case Round:
+ rv += (bw + d_vpad + d_majLen);
+ break;
+ case Top:
+ case Bottom:
+ default:
+ rv += d_len;
+ }
+
+ return rv;
+
+}
+
+//------------------------------------------------------------
+//
+//.F ScaleDraw::maxHeight
+// Return the maximum height of the scale for the
+// specified painter
+//
+//.u Syntax
+//.f int ScaleDraw::maxHeight(QPainter *p)
+//
+//.u Parameters
+//.p QPainter *p
+//
+//------------------------------------------------------------
+int ScaleDraw::maxHeight(QPainter *p) const
+{
+
+ int rv = 0;
+ int bw = p->pen().width();
+
+ p->save();
+ QFontMetrics fm = p->fontMetrics();
+
+ switch (d_orient)
+ {
+ case Top:
+ case Bottom:
+ case Round:
+ rv = bw + d_vpad + d_majLen + fm.height();
+ break;
+ case Left:
+ case Right:
+ default:
+ rv = d_len + ((fm.height() + 1) / 2);
+ }
+
+ return rv;
+
+}
+
+//------------------------------------------------------------
+//
+//.F ScaleDraw:maxBoundingRect
+// Return the maximum bounding rectangle of the scale
+// for a specified painter
+//
+//.u Parameters
+//.p QPainter *p -- painter
+//
+//.u Description
+// The bounding rectangle is not very exact for round scales
+// with strange angle ranges.
+//
+//------------------------------------------------------------
+QRect ScaleDraw::maxBoundingRect(QPainter *p) const
+{
+ int i, wl,h,wmax;
+ int a, ar, amin, amax;
+ double arc;
+
+ QRect r;
+
+ QFontMetrics fm = p->fontMetrics();
+
+ wl = maxLabelWidth(p, TRUE);
+ h = fm.height();
+
+ switch(d_orient)
+ {
+ case Left:
+
+ r = QRect( d_xorg - d_hpad - d_majLen - wl,
+ d_yorg - fm.ascent(),
+ d_majLen + d_hpad + wl,
+ d_len + fm.height());
+ break;
+
+ case Right:
+
+ r = QRect( d_xorg,
+ d_yorg - fm.ascent(),
+ d_majLen + d_hpad + wl,
+ d_len + fm.height());
+ break;
+
+ case Top:
+
+ r = QRect ( d_xorg - wl / 2,
+ d_yorg - d_majLen - fm.ascent(),
+ d_len + wl,
+ d_majLen + d_vpad + fm.ascent());
+ break;
+
+ case Bottom:
+
+ r = QRect ( d_xorg - wl / 2,
+ d_yorg,
+ d_len + wl,
+ d_majLen + d_vpad + fm.height());
+ break;
+
+ case Round:
+
+ amin = 2880;
+ amax = 0;
+ ar = 0;
+
+ for (i=0; i< d_scldiv.majCnt(); i++)
+ {
+ a = transform(d_scldiv.majMark(i));
+
+ while (a > 2880) a -= 5760;
+ while (a < - 2880) a += 5760;
+
+ ar = qwtAbs(a);
+
+ if (ar < amin) amin = ar;
+ if (ar > amax) amax = ar;
+
+ }
+
+ for (i=0; i< d_scldiv.minCnt(); i++)
+ {
+ a = transform(d_scldiv.majMark(i));
+
+ while (a > 2880) a -= 5760;
+ while (a < - 2880) a += 5760;
+
+ ar = qwtAbs(a);
+
+ if (ar < amin) amin = ar;
+ if (ar > amax) amax = ar;
+ }
+
+ arc = double(amin) / 16.0 * M_PI / 180.0;
+ r.setTop(qwtInt(d_yCenter - (d_radius + double(d_majLen + d_vpad)) * cos(arc))
+ + fm.ascent() );
+
+ arc = double(amax) / 16.0 * M_PI / 180.0;
+ r.setBottom(qwtInt(d_yCenter - (d_radius + double(d_majLen + d_vpad)) * cos(arc))
+ + fm.height() );
+
+ wmax = d_len + d_majLen + d_hpad + wl;
+
+ r.setLeft(d_xorg - d_majLen - d_hpad - wl);
+ r.setWidth(d_len + 2*(d_majLen + d_hpad + wl));
+ break;
+ }
+
+ return r;
+
+}
+
+//------------------------------------------------------------
+//
+//.F ScaleDraw::setAngleRange
+// Adjust the baseline circle segment for round scales.
+//
+//.u Syntax
+//.f void ScaleDraw::setAngleRange(double angle1, double angle2)
+//
+//.u Parameters
+//.p double angle1, double angle2
+// boundaries of the angle interval in degrees.
+//
+//.u Description
+// The baseline will be drawn from min(angle1,angle2) to max(angle1, angle2).
+// The settings have no effect if the scale orientation is not set to
+// ScaleDraw::Round. The default setting is [ -135, 135 ].
+// An angle of 0 degrees corresponds to the 12 o'clock position,
+// and positive angles count in a clockwise direction.
+//
+//.u Note
+//.i
+// -- The angle range is limited to [-360, 360] degrees. Angles exceeding
+// this range will be clipped.
+// -- For angles more than 359 degrees above or below min(angle1, angle2),
+// scale marks will not be drawn.
+// -- If you need a counterclockwise scale, use @QwtScaleDiv::setRange (1)@
+// or @QwtScaleDiv::setRange (2)@.
+//------------------------------------------------------------
+void ScaleDraw::setAngleRange(double angle1, double angle2)
+{
+ int amin, amax;
+
+ angle1 = qwtLim(angle1, -360.0, 360.0);
+ angle2 = qwtLim(angle2, -360.0, 360.0);
+ amin = int(rint(qwtMin(angle1, angle2) * 16.0));
+ amax = int(rint(qwtMax(angle1, angle2) * 16.0));
+
+ if (amin == amax)
+ {
+ amin -= 1;
+ amax += 1;
+ }
+
+ d_minAngle = amin;
+ d_maxAngle = amax;
+ setIntRange(d_minAngle, d_maxAngle);
+
+}
+
+
+//------------------------------------------------------------
+//
+//.F ScaleDraw::setLabelFormat
+// Set the number format for the major scale labels
+//
+//.u Syntax
+//.f void ScaleDraw::setLabelFormat(char f, int prec)
+//
+//.u Parameters
+//.p char f -- format character
+// int prec -- precision
+//
+//.u Description
+// Format character and precision have the same meaning as for the
+// QString class.
+//
+//.u See also
+// QString::setNum in the Qt manual
+//
+//------------------------------------------------------------
+void ScaleDraw::setLabelFormat(char f, int prec)
+{
+ d_fmt = f;
+ d_prec = prec;
+}
+
+//------------------------------------------------------------
+//
+//.F ScaleDraw::maxLabelWidth
+// Return the maximum width of a label
+//
+//.u Syntax
+//.f int ScaleDraw::maxLabelWidth(QPainter *p, int worst)
+//
+//.u Parameters
+//.p QPainter *p -- painter
+// int worst -- If TRUE, take the worst case. If FALSE, take
+// the actual width of the largest label.
+//
+//------------------------------------------------------------
+int ScaleDraw::maxLabelWidth(QPainter *p, int worst) const
+{
+
+ int i,rv = 0;
+ double val;
+ QString s;
+
+
+ QFontMetrics fm = p->fontMetrics();
+
+ if (worst) // worst case
+ {
+ s.setNum(WorstCase, d_fmt, d_prec);
+ rv = fm.width(s);
+ }
+ else // actual width
+ {
+ for (i=0;i<d_scldiv.majCnt(); i++)
+ {
+ val = d_scldiv.majMark(i);
+ // correct rounding errors if val = 0
+ if ((!d_scldiv.logScale()) && (qwtAbs(val) < step_eps * qwtAbs(d_scldiv.majStep())))
+ val = 0.0;
+ s.setNum(val, d_fmt, d_prec);
+ rv = qwtMax(rv,fm.width(s));
+ }
+ }
+
+
+ return rv;
+
+}
+
+
+//------------------------------------------------------------
+//
+//.F ScaleDraw::scaleDiv
+// Return the scale division
+//
+//.u Syntax
+//.f const QwtScaleDiv & ScaleDraw::scaleDiv() const
+//
+//.u See also
+// @^QwtScaleDiv@
+//------------------------------------------------------------
+
+//------------------------------------------------------------
+//
+//.F ScaleDraw::orientation
+// Return the orientation
+//
+//.u Syntax
+//.f int ScaleDraw::orientation() const
+//
+//.u See also
+// @ScaleDraw::setGeometry@
+//
+//------------------------------------------------------------
+
+
+
+
+
+
+
+
+
+
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/scldraw.h b/attic/muse2-oom/muse2/muse/widgets/scldraw.h
new file mode 100644
index 00000000..08a198ca
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/scldraw.h
@@ -0,0 +1,86 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: scldraw.h,v 1.1.1.1 2003/10/27 18:55:08 wschweer Exp $
+//
+// Copyright (C) 1997 Josef Wilgen
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2,
+// as published by the Free Software Foundation.
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SCLDRAW_H__
+#define __SCLDRAW_H__
+
+#include "dimap.h"
+#include "scldiv.h"
+
+class QPainter;
+class QRect;
+
+class AutoScale;
+
+class ScaleDraw : public DiMap {
+ public:
+ enum OrientationX { Bottom, Top, Left, Right, Round };
+
+ private:
+ ScaleDiv d_scldiv;
+ static const int minLen;
+ OrientationX d_orient;
+
+ int d_xorg;
+ int d_yorg;
+ int d_len;
+
+ int d_hpad;
+ int d_vpad;
+
+ int d_medLen;
+ int d_majLen;
+ int d_minLen;
+
+ int d_minAngle;
+ int d_maxAngle;
+
+ double d_xCenter;
+ double d_yCenter;
+ double d_radius;
+
+ char d_fmt;
+ int d_prec;
+
+ void drawTick(QPainter *p, double val, int len) const;
+ void drawBackbone(QPainter *p) const;
+ void drawLabel(QPainter *p, double val) const;
+
+ public:
+
+ ScaleDraw();
+
+ void setScale(const ScaleDiv &s);
+ void setScale(double vmin, double vmax, int maxMajIntv, int maxMinIntv,
+ double step = 0.0, int logarithmic = 0);
+ void setGeometry(int xorigin, int yorigin, int length, OrientationX o);
+ void setAngleRange(double angle1, double angle2);
+ void setLabelFormat(char f, int prec);
+
+ const ScaleDiv& scaleDiv() const { return d_scldiv; }
+ OrientationX orientation() const { return d_orient; }
+ QRect maxBoundingRect(QPainter *p) const;
+ int maxWidth(QPainter *p, bool worst = TRUE) const;
+ int maxHeight(QPainter *p) const;
+ int maxLabelWidth(QPainter *p, int worst = TRUE) const;
+ void draw(QPainter *p) const;
+ };
+
+#endif
+
+
+
+
+
+
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/sclif.cpp b/attic/muse2-oom/muse2/muse/widgets/sclif.cpp
new file mode 100644
index 00000000..8740bc53
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/sclif.cpp
@@ -0,0 +1,205 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: sclif.cpp,v 1.1.1.1 2003/10/27 18:55:10 wschweer Exp $
+
+// Copyright (C) 1997 Josef Wilgen
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2,
+// as published by the Free Software Foundation.
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "sclif.h"
+
+// ScaleIf - An interface class for widgets containing a scale
+//
+// This interface class is used to provide classes
+// with a protected ScaleDraw member and a public
+// interface to access that scale.
+//
+// The primary purpose of this class is to define
+// a common interface for classes which are supposed to
+// contain a ScaleDraw class. It provides a protected
+// ScaleDraw member
+// called d_scale and a couple of public member functions
+// which allow direct but restricted access
+// to this scale by the user.
+// Widgets derived from this class have
+// to implement the member function scaleChange(),
+// which is called to notify changes of the
+// scale parameters and usually requires repainting or
+// resizing respectively.
+// In general, a class derived from ScaleIf is
+// expected to manage the division and the position of its scale internally
+// when no user-defined scale is set. It should take the d_maxMinor
+// and d_maxMajor members into account, which can be set by the user.
+// An implementation can check if a user-defined scale is set by calling the
+// @ScaleIf::hasUserScale@ member.
+
+//------------------------------------------------------------
+// ScaleIf::ScaleIf
+// Construct a ScaleIf instance
+//
+// Syntax
+// ScaleIf::ScaleIf()
+//------------------------------------------------------------
+
+ScaleIf::ScaleIf()
+ {
+ d_userScale = FALSE;
+ d_maxMajor = 5;
+ d_maxMinor = 3;
+ d_scale.setScale(0.0,100.0,d_maxMajor, d_maxMinor);
+ }
+
+//------------------------------------------------------------
+// ScaleIf::setScale (1)
+// Specify a user-defined scale.
+//
+// Syntax
+// void ScaleIf::setScale(double vmin, double vmax, int logarithmic)
+//
+// Parameters
+// double vmin, double vmax -- boundary values
+// int logarithmic -- If != 0, Build a logarithmic scale
+//
+// Description
+// By default, the widget is supposed to control the range of its scale
+// automatically, but sometimes it is desirable to have a user-defined
+// scale which is not in sync with
+// the widget's range, e.g. if a logarithmic scale is needed
+// (sliders don't support that) or if the scale is required
+// to have a fixed range (say 0...100%), independent of the
+// widget's range.
+//
+// See also
+// @ScaleIf::autoScale@
+//------------------------------------------------------------
+
+void ScaleIf::setScale(double vmin, double vmax, int logarithmic)
+ {
+ setScale(vmin,vmax,0.0,logarithmic);
+ }
+
+//------------------------------------------------------------
+// ScaleIf::setScale (2)
+// Specify a user-defined scale.
+//
+// Syntax
+// void ScaleIf::setScale(double vmin, double vmax, int logarithmic)
+//
+// Parameters
+// double vmin, double vmax -- interval boundaries
+// int step -- major step size
+// int logarithmic -- If != 0, build a logarithmic scale
+//
+// Description
+// By default, the widget is supposed to control the range of its scale
+// automatically, but sometimes it is desirable to have a user-defined
+// scale which is not in sync with
+// the widget's range, e.g. if a logarithmic scale is needed
+// (sliders don't support that) or if the scale is required
+// to have a fixed range (say 0...100%), independent of the
+// widget's range.
+//------------------------------------------------------------
+
+void ScaleIf::setScale(double vmin, double vmax, double step, int logarithmic)
+ {
+ ScaleDiv oldscl(d_scale.scaleDiv());
+
+ d_scale.setScale(vmin, vmax, d_maxMajor, d_maxMinor, step, logarithmic);
+ d_userScale = TRUE;
+ if (oldscl != d_scale.scaleDiv())
+ scaleChange();
+ }
+
+//------------------------------------------------------------
+// Scale::setScale
+// Assign a user-defined scale division
+//
+// Syntax
+// void Scale::setScale(const ScaleDiv &s)
+//
+// Parameters
+// const ScaleDiv &s -- scale division
+//------------------------------------------------------------
+
+void ScaleIf::setScale(const ScaleDiv &s)
+ {
+ d_scale.setScale(s);
+ scaleChange();
+ }
+
+//------------------------------------------------------------
+// ScaleIf::autoScale
+// Advise the widget to control the scale range
+// internally.
+// Syntax
+// void ScaleIf::autoScale
+//
+// Description
+// Autoscaling is on by default.
+//------------------------------------------------------------
+
+void ScaleIf::autoScale()
+ {
+ if (!d_userScale) {
+ d_userScale = FALSE;
+ scaleChange();
+ }
+ }
+
+//------------------------------------------------------------
+// ScaleIf::setScaleMaxMajor
+// Set the maximum number of major tick intervals.
+//
+// Syntax
+// void ScaleIf::setScaleMaxMajor(int ticks)
+//
+// Parameters
+// int ticks -- maximal number of major ticks.
+//
+// Description
+// The scale's major ticks are calculated automatically such that
+// the number of major intervals does not exceed <ticks>.
+// The default value is 5.
+//------------------------------------------------------------
+
+void ScaleIf::setScaleMaxMajor(int ticks)
+ {
+ if (ticks != d_maxMajor) {
+ d_maxMajor = ticks;
+ d_scale.setScale(d_scale.scaleDiv().lBound(), d_scale.scaleDiv().hBound(),
+ d_maxMajor, d_maxMinor, 0.0,d_scale.scaleDiv().logScale());
+ scaleChange();
+ }
+ }
+
+//------------------------------------------------------------
+// ScaleIf::setScaleMaxMinor
+// Set the maximum number of minor tick intervals
+//
+// Syntax
+// void ScaleIf::setScaleMaxMinor(int ticks)
+//
+// Parameters
+// int ticks
+//
+// Description
+// The scale's minor ticks are calculated automatically such that
+// the number of minor intervals does not exceed <ticks>.
+// The default value is 3.
+//------------------------------------------------------------
+
+void ScaleIf::setScaleMaxMinor(int ticks)
+ {
+ if ( ticks != d_maxMinor) {
+ d_maxMinor = ticks;
+ d_scale.setScale(d_scale.scaleDiv().lBound(), d_scale.scaleDiv().hBound(),
+ d_maxMajor, d_maxMinor, 0.0, d_scale.scaleDiv().logScale());
+ scaleChange();
+ }
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/sclif.h b/attic/muse2-oom/muse2/muse/widgets/sclif.h
new file mode 100644
index 00000000..ec8eafc9
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/sclif.h
@@ -0,0 +1,50 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: sclif.h,v 1.1.1.1 2003/10/27 18:54:33 wschweer Exp $
+
+// Copyright (C) 1997 Josef Wilgen
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2,
+// as published by the Free Software Foundation.
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SCALE_IF_H__
+#define __SCALE_IF_H__
+
+#include "scldraw.h"
+
+//---------------------------------------------------------
+// ScaleIf
+//---------------------------------------------------------
+
+class ScaleIf
+ {
+ bool d_userScale;
+
+ protected:
+ ScaleDraw d_scale;
+ int d_maxMajor;
+ int d_maxMinor;
+ bool hasUserScale() {return d_userScale;}
+ virtual void scaleChange() = 0;
+
+ public:
+ ScaleIf();
+ virtual ~ScaleIf() {};
+
+ void setScale (double vmin, double vmax, int logarithmic = 0);
+ void setScale (double vmin, double vmax, double step, int logarithmic = 0);
+ void setScale(const ScaleDiv &s);
+ void setScaleMaxMajor( int ticks);
+ void setScaleMaxMinor( int ticks);
+ void autoScale();
+
+ int scaleMaxMinor() const {return d_maxMinor;}
+ int scaleMaxMajor() const {return d_maxMinor;}
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/scrollscale.cpp b/attic/muse2-oom/muse2/muse/widgets/scrollscale.cpp
new file mode 100644
index 00000000..de383deb
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/scrollscale.cpp
@@ -0,0 +1,509 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: scrollscale.cpp,v 1.2.2.2 2009/11/04 17:43:25 lunar_shuttle Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <cmath>
+
+#include <QBoxLayout>
+#include <QLabel>
+#include <QResizeEvent>
+#include <QScrollBar>
+#include <QSlider>
+#include <QToolButton>
+#include <QToolTip>
+
+// #include "globals.h"
+#include "scrollscale.h"
+#include "icons.h"
+
+//---------------------------------------------------------
+// setScale
+// "val" - slider value in range 0-1024
+//---------------------------------------------------------
+
+void ScrollScale::setScale ( int val )
+{
+ int off = offset();
+ if ( invers )
+ val = 1024 - val;
+ double min, max;
+ if ( scaleMin < 0 )
+ min = 1.0/ ( -scaleMin );
+ else
+ min = double ( scaleMin );
+
+ if ( scaleMax < 0 )
+ max = 1.0/ ( -scaleMax );
+ else
+ max = double ( scaleMax );
+
+ double diff = max-min;
+ double fkt = double ( val ) /1024.0;
+ double v = ( pow ( logbase, fkt )-1 ) / ( logbase-1 );
+ double scale;
+ if ( invers )
+ scale = max - v * diff;
+ else
+ scale = min + v * diff;
+
+ if ( scale < 1.0 )
+ scaleVal = - ( int ( 1.0 / scale ) );
+ else
+ scaleVal = int ( scale );
+ if ( scaleVal == -1 ) // nur so
+ scaleVal = 1;
+
+#if 0
+ if ( scaleMax > scaleMin )
+ {
+ if ( scale < scaleMin )
+ scale = scaleMin;
+ else if ( scale > scaleMax )
+ scale = scaleMax;
+ }
+ else
+ {
+ if ( scale < scaleMax )
+ scale = scaleMax;
+ else if ( scale > scaleMin )
+ scale = scaleMin;
+ }
+#endif
+
+ emit scaleChanged ( scaleVal );
+ if ( !noScale )
+ setRange ( minVal, maxVal );
+
+ int i = ( scroll->orientation() == Qt::Horizontal ) ? width() : height();
+ int pos, pmax;
+ if ( scaleVal < 1 )
+ {
+ pos = ( off-scaleVal/2 ) / ( -scaleVal );
+ pmax = ( maxVal-scaleVal-1 ) / ( -scaleVal ) - i;
+ }
+ else
+ {
+ pos = off * scaleVal;
+ pmax = maxVal * scaleVal - i;
+ }
+ if(pos > pmax)
+ pos = pmax;
+ setPos(pos);
+}
+
+//---------------------------------------------------------
+// setMag
+//---------------------------------------------------------
+
+void ScrollScale::setMag ( int cs )
+{
+ scale->setValue ( cs );
+ setScale ( cs );
+}
+
+//---------------------------------------------------------
+// setRange
+// min,max ticks
+//---------------------------------------------------------
+
+void ScrollScale::setRange ( int min, int max )
+{
+// if ((min != minVal) && (max != maxVal))
+// return;
+ minVal = min;
+ maxVal = max;
+ int i = ( scroll->orientation() == Qt::Horizontal ) ? width() : height();
+
+ if ( !noScale )
+ {
+ if ( scaleVal < 1 )
+ {
+ min = minVal / ( -scaleVal );
+ max = ( maxVal-scaleVal-1 ) / ( -scaleVal ) - i;
+ }
+ else
+ {
+ min = minVal * scaleVal;
+ max = maxVal * scaleVal - i;
+ }
+ }
+ else
+ max -= i;
+ if ( max < 0 )
+ max = 0;
+ if ( min < 0 )
+ min = 0;
+ if ( min > max )
+ max = min;
+
+ scroll->setRange ( min, max );
+
+ // qt doesn't check this...
+ if ( scroll->value() < min )
+ scroll->setValue ( min );
+ if ( scroll->value() > max )
+ scroll->setValue ( max );
+ scroll->setSingleStep(20);
+ scroll->setPageStep(i);
+}
+
+//---------------------------------------------------------
+// setPos
+// pos in pixel
+//---------------------------------------------------------
+
+void ScrollScale::setPos ( unsigned pos )
+{
+
+ scroll->setValue ( pos );
+}
+
+//---------------------------------------------------------
+// setPosNoLimit
+// pos in pixel
+//---------------------------------------------------------
+
+void ScrollScale::setPosNoLimit ( unsigned pos )
+{
+ //printf ( "ScrollScale::setPosNoLimit pos:%d scaleVal:%d offset ticks:%d\n", pos, scaleVal, pos2offset ( pos ) );
+
+ if((int)pos > scroll->maximum())
+ scroll->setMaximum(pos);
+ scroll->setValue(pos);
+}
+
+//---------------------------------------------------------
+// resizeEvent
+//---------------------------------------------------------
+
+void ScrollScale::resizeEvent ( QResizeEvent* )
+{
+ setScale ( scale->value() );
+}
+
+//---------------------------------------------------------
+// ScrollScale
+//---------------------------------------------------------
+
+ScrollScale::ScrollScale ( int s1, int s2, int cs, int max_, Qt::Orientation o,
+ QWidget* parent, int min_, bool inv, double bas )
+ : QWidget ( parent )
+{
+ noScale = false;
+ _page = 0;
+ _pages = 1;
+ pageButtons = false;
+ showMagFlag = true;
+ scaleMin = s1;
+ scaleMax = s2;
+ minVal = min_;
+ maxVal = max_;
+ up = 0;
+ down = 0;
+ logbase = bas;
+ invers = inv;
+
+ double min, max;
+ if ( scaleMin < 0 )
+ min = 1.0/ ( -scaleMin );
+ else
+ min = double ( scaleMin );
+
+ if ( scaleMax < 0 )
+ max = 1.0/ ( -scaleMax );
+ else
+ max = double ( scaleMax );
+
+ double cmag = ( cs < 0 ) ? ( 1.0/ ( -cs ) ) : double ( cs );
+ double diff = max-min;
+
+ //
+ // search initial value for slider
+ //
+ int cur = 512;
+ int delta = 256;
+ for ( int i = 0; i < 8; ++i )
+ {
+ int tryVal = invers ? 1025 - cur : cur;
+ double fkt = double ( tryVal ) /1024.0;
+ double v = ( pow ( logbase, fkt )-1 ) / ( logbase-1 );
+ double scale = invers ? ( max - v * diff ) : ( min + v * diff );
+ if ( scale == cmag ) // not very likely
+ break;
+ //printf("iteration %d invers:%d soll %f(cur:%d) - ist %f\n", i, invers, scale, cur, cmag);
+ int dd = invers ? -delta : delta;
+ cur += ( scale < cmag ) ? dd : -dd;
+ delta/=2;
+ }
+
+ scale = new QSlider (o);
+ // Added by Tim. For some reason focus was on.
+ // It messes up tabbing, and really should have a shortcut instead.
+ scale->setFocusPolicy(Qt::NoFocus);
+ scale->setMinimum(0);
+ scale->setMaximum(1024);
+ scale->setPageStep(1);
+ scale->setValue(cur);
+
+ scroll = new QScrollBar ( o );
+ //scroll->setFocusPolicy(Qt::NoFocus); // Tim.
+ setScale ( cur );
+
+ if ( o == Qt::Horizontal )
+ {
+ box = new QBoxLayout ( QBoxLayout::LeftToRight);
+ scale->setMaximumWidth ( 70 );
+ scroll->setMinimumWidth ( 50 );
+ }
+ else
+ {
+ box = new QBoxLayout ( QBoxLayout::TopToBottom);
+ scroll->setMinimumHeight ( 50 );
+ scale->setMaximumHeight ( 70 );
+ }
+ box->addWidget ( scroll, 10 );
+ box->addWidget ( scale, 5 );
+ setLayout(box);
+ connect ( scale, SIGNAL ( valueChanged ( int ) ), SLOT ( setScale ( int ) ) );
+ ///connect ( scale, SIGNAL ( valueChanged ( int ) ), SIGNAL ( lscaleChanged ( int ) ) ); // ??
+ connect ( scroll, SIGNAL ( valueChanged ( int ) ), SIGNAL ( scrollChanged ( int ) ) );
+}
+
+//---------------------------------------------------------
+// setPageButtons
+//---------------------------------------------------------
+
+void ScrollScale::setPageButtons ( bool flag )
+{
+ if ( flag == pageButtons )
+ return;
+
+ if ( flag )
+ {
+ if ( up == 0 )
+ {
+ up = new QToolButton;
+ up->setIcon ( QIcon(*upIcon) );
+ down = new QToolButton;
+ down->setIcon ( QIcon(*downIcon) );
+ pageNo = new QLabel;
+ QString s;
+ s.setNum ( _page+1 );
+ pageNo->setText ( s );
+ down->setToolTip(tr ( "next page" ) );
+ up->setToolTip(tr ( "previous page" ) );
+ pageNo->setToolTip(tr ( "current page number" ) );
+ box->insertWidget ( 1, up );
+ box->insertWidget ( 2, down );
+ box->insertSpacing ( 3, 5 );
+ box->insertWidget ( 4, pageNo );
+ box->insertSpacing ( 5, 5 );
+ connect ( up, SIGNAL ( clicked() ), SLOT ( pageUp() ) );
+ connect ( down, SIGNAL ( clicked() ), SLOT ( pageDown() ) );
+ }
+ up->show();
+ down->show();
+ pageNo->show();
+ if ( _page == ( _pages-1 ) )
+ down->setEnabled ( false );
+ if ( _page == 0 )
+ up->setEnabled ( false );
+ }
+ else
+ {
+ up->hide();
+ down->hide();
+ }
+ pageButtons = flag;
+}
+
+//---------------------------------------------------------
+// showMag
+//---------------------------------------------------------
+
+void ScrollScale::showMag ( bool flag )
+{
+ showMagFlag = flag;
+ if ( flag )
+ scale->show();
+ else
+ scale->hide();
+ box->activate();
+}
+
+//---------------------------------------------------------
+// offset
+//---------------------------------------------------------
+int ScrollScale::offset()
+{
+ return pos2offset ( scroll->value() );
+}
+
+//---------------------------------------------------------
+// pos2offset
+//---------------------------------------------------------
+int ScrollScale::pos2offset ( int pos )
+{
+ if ( scaleVal < 1 )
+ return pos * ( -scaleVal ) + scaleVal/2;
+ else
+ return pos / scaleVal;
+}
+
+//---------------------------------------------------------
+// setOffset
+// val in tick
+//---------------------------------------------------------
+
+void ScrollScale::setOffset ( int val )
+{
+ int i = ( scroll->orientation() == Qt::Horizontal ) ? width() : height();
+ int pos, max;
+
+ if ( scaleVal < 1 )
+ {
+ pos = ( val-scaleVal/2 ) / ( -scaleVal );
+ max = ( maxVal-scaleVal-1 ) / ( -scaleVal ) - i;
+ }
+ else
+ {
+ pos = val * scaleVal;
+ max = maxVal * scaleVal - i;
+ }
+ if ( pos > max )
+ {
+ int min;
+ if ( scaleVal < 1 )
+ {
+ maxVal = ( pos + width() ) * ( -scaleVal );
+ min = ( minVal-scaleVal/2 ) / ( -scaleVal );
+ max = ( maxVal-scaleVal/2 ) / ( -scaleVal ) - i;
+ }
+ else
+ {
+ maxVal = ( pos + width() + scaleVal/2 ) /scaleVal;
+ min = minVal * scaleVal;
+ max = maxVal * scaleVal - i;
+ }
+
+ if ( max < 0 )
+ max = 0;
+ if ( min < 0 )
+ min = 0;
+ if ( min > max )
+ max = min;
+ scroll->setRange ( min, max );
+ }
+
+ setPos ( pos );
+}
+
+//---------------------------------------------------------
+// pageUp
+// goto previous page
+//---------------------------------------------------------
+
+void ScrollScale::pageUp()
+{
+ if ( _page )
+ {
+ --_page;
+ emit newPage ( _page );
+ QString s;
+ s.setNum ( _page+1 );
+ pageNo->setText ( s );
+ if ( _page == 0 )
+ up->setEnabled ( false );
+ if ( _page == ( _pages-2 ) )
+ down->setEnabled ( true );
+ }
+}
+
+//---------------------------------------------------------
+// pageDown
+// goto next page
+//---------------------------------------------------------
+
+void ScrollScale::pageDown()
+{
+ if ( _page + 1 < _pages )
+ {
+ ++_page;
+ emit newPage ( _page );
+ QString s;
+ s.setNum ( _page+1 );
+ pageNo->setText ( s );
+ if ( _page == ( _pages-1 ) )
+ down->setEnabled ( false );
+ if ( _page == 1 )
+ up->setEnabled ( true );
+ }
+}
+
+//---------------------------------------------------------
+// setPages
+//---------------------------------------------------------
+
+void ScrollScale::setPages ( int n )
+{
+ _pages = n;
+ if ( _page >= _pages )
+ {
+ _page = _pages-1;
+ emit newPage ( _page );
+ QString s;
+ s.setNum ( _page+1 );
+ pageNo->setText ( s );
+ }
+ up->setEnabled ( _page );
+ down->setEnabled ( _page < ( _pages-1 ) );
+}
+
+int ScrollScale::pos() const
+{
+ return scroll->value();
+}
+
+int ScrollScale::mag() const
+{
+ return scale->value();
+}
+
+/**
+ * Hardcoded hackish function that corresponds to the values used for the scrollscales in PianoRoll and DrumEditor
+ * since I couldn't easily create any inverse function from the [0,1024]-range to detect where a zoom actually occurs
+ * (mg)
+ */
+int ScrollScale::getQuickZoomLevel(int mag)
+{
+ if (mag == 0)
+ return 0;
+
+ for (int i=0; i<24; i++) {
+ int val1 = ScrollScale::convertQuickZoomLevelToMag(i);
+ int val2 = ScrollScale::convertQuickZoomLevelToMag(i + 1);
+ if (mag > val1 && mag <= val2)
+ return i + 1;
+ }
+
+ return -1;
+
+}
+
+/**
+ * Function returning the boundary values for a zoom change, hardcoded corresponding to the values used in PianoRoll
+ * and DrumEditor
+ */
+int ScrollScale::convertQuickZoomLevelToMag(int zoomlevel)
+{
+ int vals[] = { 0, 1, 15, 30, 46, 62, 80, 99, 119, 140, 163,
+ 187, 214, 242, 274, 308, 346, 388, 436, 491, 555, 631,
+ 726, 849, 1024 };
+
+ return vals[zoomlevel];
+}
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/scrollscale.h b/attic/muse2-oom/muse2/muse/widgets/scrollscale.h
new file mode 100644
index 00000000..32043070
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/scrollscale.h
@@ -0,0 +1,85 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: scrollscale.h,v 1.2.2.3 2009/11/04 17:43:26 lunar_shuttle Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SCROLLSCALE_H__
+#define __SCROLLSCALE_H__
+
+#include <QSlider>
+
+class QBoxLayout;
+class QLabel;
+class QResizeEvent;
+class QScrollBar;
+class QToolButton;
+
+//---------------------------------------------------------
+// ScrollScale
+//---------------------------------------------------------
+
+class ScrollScale : public QWidget {
+ QSlider* scale;
+ QScrollBar* scroll;
+ int minVal, maxVal;
+ int scaleVal, scaleMin, scaleMax;
+ bool showMagFlag;
+ QBoxLayout* box;
+ bool noScale;
+ bool pageButtons;
+ int _page;
+ int _pages;
+ QToolButton* up;
+ QToolButton* down;
+ QLabel* pageNo;
+ bool invers;
+ double logbase;
+
+ virtual void resizeEvent(QResizeEvent*);
+ Q_OBJECT
+
+ private slots:
+ void pageUp();
+ void pageDown();
+
+ public slots:
+ void setPos(unsigned);
+ void setPosNoLimit(unsigned);
+ void setMag(int);
+ void setOffset(int val);
+ void setScale(int);
+
+ signals:
+ void scaleChanged(int);
+ void lscaleChanged(int);
+ void scrollChanged(int);
+ void newPage(int);
+
+ public:
+ ScrollScale(int, int, int, int max, Qt::Orientation,
+ QWidget*, int min = 0, bool i=false, double vv = 10.0);
+ int xmag() const { return scale->value(); }
+ void setXmag(int val) { scale->setValue(val); }
+ void setRange(int, int);
+ void showMag(bool);
+ void setNoScale(bool flag) { noScale = flag; }
+ void setPageButtons(bool flag);
+ void setPage(int n) { _page = n; }
+ int page() const { return _page; }
+ int pages() const { return _pages; }
+ void setPages(int n);
+ int pos() const;
+ int mag() const;
+ int getScaleValue() const { return scaleVal; }
+ void range(int* b, int* e) const { *b = minVal; *e = maxVal; }
+
+ int offset();
+ int pos2offset(int pos);
+ static int getQuickZoomLevel(int mag);
+ static int convertQuickZoomLevelToMag(int zoomlvl);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/section.h b/attic/muse2-oom/muse2/muse/widgets/section.h
new file mode 100644
index 00000000..7aaa4778
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/section.h
@@ -0,0 +1,19 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: section.h,v 1.1.1.1 2003/10/27 18:54:27 wschweer Exp $
+// (C) Copyright 2002 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SECTION_H__
+#define __SECTION_H__
+
+struct Section {
+ int offset;
+ unsigned len;
+ int voff;
+ int val;
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialog.cpp b/attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialog.cpp
new file mode 100644
index 00000000..ca627661
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialog.cpp
@@ -0,0 +1,99 @@
+//
+// C++ Implementation: shortcutcapturedialog
+//
+// Description:
+// Dialog window for capturing keyboard shortcuts
+//
+// Author: Mathias Lundgren <lunar_shuttle@users.sourceforge.net>, (C) 2003
+//
+// Copyright: Mathias Lundgren (lunar_shuttle@users.sourceforge.net) (C) 2003
+//
+//
+#include "shortcutcapturedialog.h"
+#include "shortcuts.h"
+
+#include <QKeyEvent>
+#include <QKeySequence>
+#include <QInputEvent>
+#include <QChar>
+
+ShortcutCaptureDialog::ShortcutCaptureDialog(QWidget* parent, int index)
+ : QDialog(parent)
+ {
+ setupUi(this);
+ QKeySequence q = QKeySequence(shortcuts[index].key);
+ oshrtLabel->setText(q);
+ connect(okButton, SIGNAL( clicked() ), this, SLOT( apply() ) );
+ connect(cancelButton, SIGNAL(pressed()), this, SLOT(cancel()));
+ shortcutindex = index;
+ grabKeyboard();
+ okButton->setText(tr("Ok"));
+ cancelButton->setText(tr("Cancel"));
+ }
+
+ShortcutCaptureDialog::~ShortcutCaptureDialog()
+ {
+ releaseKeyboard();
+ }
+
+void ShortcutCaptureDialog::keyPressEvent(QKeyEvent* e)
+ {
+ bool shift, alt, ctrl, meta, conflict = false, realkey = false;
+ QString msgString = "";
+ int temp_key;
+ Qt::KeyboardModifiers mods = ((QInputEvent*)e)->modifiers();
+ shift = mods & Qt::ShiftModifier;
+ ctrl = mods & Qt::ControlModifier;
+ alt = mods & Qt::AltModifier;
+ meta = mods & Qt::MetaModifier;
+ //printf("Key total: %d, alt: %d, ctrl: %d shift: %d\n",e->key(), alt, ctrl, shift);
+ temp_key = e->key();
+
+ QChar keychar(temp_key);
+ bool ispunct = keychar.isPunct();
+ bool issymbol = keychar.isSymbol();
+ //printf("Key:%x, alt:%d, ctrl:%d shift:%d ispunct:%d issymbol:%d text:%s\n",
+ // e->key(), alt, ctrl, shift, ispunct, issymbol, e->text().toLatin1().constData()); // REMOVE Tim.
+
+ temp_key += (shift ? (int)Qt::SHIFT : 0); // (int) Tim
+ temp_key += (ctrl ? (int)Qt::CTRL : 0); //
+ temp_key += (alt ? (int)Qt::ALT : 0); //
+ temp_key += (meta ? (int)Qt::META : 0);
+ //printf("Final key assembled: %d\n",temp_key);
+
+ // Check if this is a "real" key that completes a valid shortcut:
+ int k = e->key();
+ if (k < 256 || k == Qt::Key_Enter || k == Qt::Key_Return || (k >= Qt::Key_F1 && k <= Qt::Key_F12) || k == Qt::Key_Home || k == Qt::Key_PageUp
+ || k == Qt::Key_PageDown || k == Qt::Key_End || k == Qt::Key_Insert || k == Qt::Key_Delete
+ || k == Qt::Key_Up || k == Qt::Key_Down || k == Qt::Key_Left || k == Qt::Key_Right) {
+ key = temp_key;
+ realkey = true;
+ QKeySequence q = QKeySequence(key);
+ //QKeySequence q = QKeySequence(k, mods);
+ QString keyString = q;
+ if (keyString != QString::null)
+ nshrtLabel->setText(q);
+
+ // Check against conflicting shortcuts
+ for (int i=0; i < SHRT_NUM_OF_ELEMENTS; i++) {
+ if (shortcuts[i].key == key && (shortcuts[i].type & (shortcuts[shortcutindex].type | GLOBAL_SHRT | INVIS_SHRT))) {
+ msgString = tr("Shortcut conflicts with ") + QString(shortcuts[i].descr);
+ conflict = true;
+ break;
+ }
+ }
+ }
+ messageLabel->setText(msgString);
+ okButton->setEnabled(conflict == false && realkey);
+ if (!realkey)
+ nshrtLabel->setText(tr("Undefined"));
+
+
+ }
+
+void ShortcutCaptureDialog::apply()
+ {
+ //return the shortcut to configurator widget:
+ done(key);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialog.h b/attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialog.h
new file mode 100644
index 00000000..a7ba69c7
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialog.h
@@ -0,0 +1,35 @@
+//
+// C++ Interface: shortcutcapturedialog
+//
+// Description:
+// Dialog window for capturing keyboard shortcuts
+//
+// Author: Mathias Lundgren <lunar_shuttle@users.sourceforge.net>, (C) 2003
+//
+// Copyright: Mathias Lundgren (lunar_shuttle@users.sourceforge.net) (C) 2003
+//
+//
+
+#include "shortcuts.h"
+#include "filedialog.h"
+#include "ui_shortcutcapturedialogbase.h"
+
+class QKeyEvent;
+
+class ShortcutCaptureDialog : public QDialog, public Ui::ShortcutCaptureDialogBase
+ {
+ Q_OBJECT
+ private:
+ int shortcutindex;
+ void keyPressEvent(QKeyEvent* e);
+ int key;
+
+ private slots:
+ void apply();
+ void cancel() { reject(); };
+
+ public:
+ ShortcutCaptureDialog(QWidget* parent, int index=0);
+ ~ShortcutCaptureDialog();
+ };
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialogbase.ui b/attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialogbase.ui
new file mode 100644
index 00000000..61157890
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/shortcutcapturedialogbase.ui
@@ -0,0 +1,123 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ShortcutCaptureDialogBase</class>
+ <widget class="QDialog" name="ShortcutCaptureDialogBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>323</width>
+ <height>285</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Enter shortcut sequence</string>
+ </property>
+ <property name="modal">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QLabel" name="descrLabel">
+ <property name="text">
+ <string>Press keys to enter shortcut sequence!</string>
+ </property>
+ <property name="alignment">
+ <set>Qt::AlignCenter</set>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="messageLabel">
+ <property name="text">
+ <string/>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QLabel" name="oshrtTextLabel">
+ <property name="text">
+ <string>Old shortcut:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="oshrtLabel">
+ <property name="text">
+ <string>Undefined</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QLabel" name="nshrtTextLabel">
+ <property name="text">
+ <string>New shortcut:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="nshrtLabel">
+ <property name="text">
+ <string>Undefined</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QPushButton" name="okButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>OK</string>
+ </property>
+ <property name="shortcut">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ <property name="shortcut">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/shortcutconfig.cpp b/attic/muse2-oom/muse2/muse/widgets/shortcutconfig.cpp
new file mode 100644
index 00000000..78162f50
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/shortcutconfig.cpp
@@ -0,0 +1,127 @@
+//
+// C++ Implementation: shortcutconfig
+//
+// Description:
+// Dialog for configuring keyboard shortcuts
+//
+// Author: Mathias Lundgren <lunar_shuttle@users.sourceforge.net>, (C) 2003
+//
+// Copyright: Mathias Lundgren (lunar_shuttle@users.sourceforge.net) (C) 2003
+//
+//
+#include <QCloseEvent>
+#include <QKeySequence>
+#include <QString>
+
+#include "shortcutconfig.h"
+#include "shortcutcapturedialog.h"
+#include "shortcuts.h"
+
+ShortcutConfig::ShortcutConfig(QWidget* parent)
+ : QDialog(parent)
+ {
+ setupUi(this);
+ connect(cgListView, SIGNAL(itemActivated(QTreeWidgetItem*, int )),
+ this, SLOT(categorySelChanged(QTreeWidgetItem*, int)));
+ connect(scListView, SIGNAL(itemActivated(QTreeWidgetItem*, int )),
+ this, SLOT(shortcutSelChanged(QTreeWidgetItem*, int)));
+
+ connect(defineButton, SIGNAL(pressed()), this, SLOT(assignShortcut()));
+ connect(clearButton, SIGNAL(pressed()), this, SLOT(clearShortcut()));
+ connect(applyButton, SIGNAL(pressed()), this, SLOT(assignAll()));
+
+ current_category = ALL_SHRT;
+ cgListView->sortItems(SHRT_CATEGORY_COL, Qt::AscendingOrder);
+ _config_changed = false;
+
+ //Fill up category listview:
+ SCListViewItem* newItem;
+ SCListViewItem* selItem = 0;
+ for (int i=0; i < SHRT_NUM_OF_CATEGORIES; i++) {
+ newItem = new SCListViewItem(cgListView, i);
+ newItem->setText(SHRT_CATEGORY_COL, shortcut_category[i].name);
+ if(shortcut_category[i].id_flag == current_category)
+ selItem = newItem;
+ }
+ if(selItem)
+ cgListView->setCurrentItem(selItem); // Tim
+ updateSCListView();
+ }
+
+void ShortcutConfig::updateSCListView(int category)
+ {
+ scListView->clear();
+ SCListViewItem* newItem;
+ //QString catpre;
+ for (int i=0; i < SHRT_NUM_OF_ELEMENTS; i++) {
+ if (shortcuts[i].type & category) {
+ newItem = new SCListViewItem(scListView, i);
+ newItem->setText(SHRT_DESCR_COL, tr(shortcuts[i].descr));
+ //if(category == ALL_SHRT)
+ // catpre = QString(shortcut_category[shortcuts[i].type].name) + QString(": ");
+ //else
+ // catpre.clear();
+ //newItem->setText(SHRT_DESCR_COL, catpre + tr(shortcuts[i].descr)); // Tim
+ QKeySequence key = QKeySequence(shortcuts[i].key);
+ newItem->setText(SHRT_SHRTCUT_COL, key);
+ }
+ }
+ }
+
+void ShortcutConfig::assignShortcut()
+ {
+ SCListViewItem* active = (SCListViewItem*) scListView->selectedItems()[0];
+ int shortcutindex = active->getIndex();
+ ShortcutCaptureDialog* sc = new ShortcutCaptureDialog(this, shortcutindex);
+ int key = sc->exec();
+ delete(sc);
+ if (key != Rejected) {
+ shortcuts[shortcutindex].key = key;
+ QKeySequence keySequence = QKeySequence(key);
+ active->setText(SHRT_SHRTCUT_COL, keySequence);
+ _config_changed = true;
+ }
+ clearButton->setEnabled(true);
+ defineButton->setDown(false);
+ }
+
+void ShortcutConfig::clearShortcut()
+ {
+ SCListViewItem* active = (SCListViewItem*) scListView->selectedItems()[0];
+ int shortcutindex = active->getIndex();
+ shortcuts[shortcutindex].key = 0; //Cleared
+ active->setText(SHRT_SHRTCUT_COL,"");
+ clearButton->setDown(false);
+ clearButton->setEnabled(false);
+ _config_changed = true;
+ }
+
+void ShortcutConfig::categorySelChanged(QTreeWidgetItem* i, int /*column*/)
+ {
+ SCListViewItem* item = (SCListViewItem*) i;
+ current_category = shortcut_category[item->getIndex()].id_flag;
+ updateSCListView(current_category);
+ }
+
+void ShortcutConfig::shortcutSelChanged(QTreeWidgetItem* in_item, int /*column*/)
+ {
+ defineButton->setEnabled(true);
+ SCListViewItem* active = (SCListViewItem*) in_item;
+ int index = active->getIndex();
+ if (shortcuts[index].key != 0)
+ clearButton->setEnabled(true);
+ else
+ clearButton->setEnabled(false);
+ }
+
+void ShortcutConfig::closeEvent(QCloseEvent* /*e*/) // prevent compiler warning : unused variable
+ {
+ done(_config_changed);
+ }
+
+
+void ShortcutConfig::assignAll()
+ {
+ applyButton->setDown(false);
+ done(_config_changed);
+ }
diff --git a/attic/muse2-oom/muse2/muse/widgets/shortcutconfig.h b/attic/muse2-oom/muse2/muse/widgets/shortcutconfig.h
new file mode 100644
index 00000000..0cc11dd7
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/shortcutconfig.h
@@ -0,0 +1,60 @@
+//
+// C++ Interface: shortcutconfig
+//
+// Description:
+// Dialog for configuring keyboard shortcuts
+//
+// Author: Mathias Lundgren <lunar_shuttle@users.sourceforge.net>, (C) 2003
+//
+// Copyright: Mathias Lundgren (lunar_shuttle@users.sourceforge.net) (C) 2003
+//
+//
+#ifndef __SHORTCUTCONFIG_H
+#define __SHORTCUTCONFIG_H
+
+class QCloseEvent;
+
+#include "ui_shortcutconfigbase.h"
+
+#define SHRT_CATEGORY_COL 0
+enum
+ {
+ SHRT_DESCR_COL = 0,
+ SHRT_SHRTCUT_COL
+ };
+
+class SCListViewItem : public QTreeWidgetItem {
+ private:
+ int index;
+
+ public:
+ SCListViewItem(QTreeWidget* parent, int i)
+ : QTreeWidgetItem(parent), index(i) { }
+ int getIndex() { return index; }
+
+};
+
+
+class ShortcutConfig : public QDialog, public Ui::ShortcutConfigBase {
+ Q_OBJECT
+ private:
+ int current_category;
+ void updateSCListView(int category);
+ void updateSCListView() { updateSCListView(current_category); }
+ void closeEvent(QCloseEvent *e);
+
+ private slots:
+ void categorySelChanged(QTreeWidgetItem*, int);
+ void shortcutSelChanged(QTreeWidgetItem*, int);
+ void assignShortcut();
+ void clearShortcut();
+ void assignAll();
+
+
+ public:
+ ShortcutConfig(QWidget* parent);
+ bool _config_changed;
+
+};
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/shortcutconfigbase.ui b/attic/muse2-oom/muse2/muse/widgets/shortcutconfigbase.ui
new file mode 100644
index 00000000..892cc7c3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/shortcutconfigbase.ui
@@ -0,0 +1,177 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>ShortcutConfigBase</class>
+ <widget class="QDialog" name="ShortcutConfigBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>466</width>
+ <height>403</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Configure Keyboard Shortcuts</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QGroupBox" name="groupBox3">
+ <property name="title">
+ <string/>
+ </property>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>3</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QTreeWidget" name="cgListView">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Minimum" vsizetype="Expanding">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>105</width>
+ <height>200</height>
+ </size>
+ </property>
+ <column>
+ <property name="text">
+ <string>Shortcut Category</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>false</bool>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTreeWidget" name="scListView">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Expanding">
+ <horstretch>2</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>170</width>
+ <height>230</height>
+ </size>
+ </property>
+ <column>
+ <property name="text">
+ <string>Description</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Shortcut</string>
+ </property>
+ <property name="clickable">
+ <bool>true</bool>
+ </property>
+ <property name="resizable">
+ <bool>true</bool>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <spacer name="spacer3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>150</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="clearButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Clear</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+C</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="defineButton">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <property name="text">
+ <string>&amp;Define</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+D</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="spacer2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>30</width>
+ <height>21</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="applyButton">
+ <property name="text">
+ <string>&amp;Apply</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+A</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/sigedit.cpp b/attic/muse2-oom/muse2/muse/widgets/sigedit.cpp
new file mode 100644
index 00000000..d4c210e4
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/sigedit.cpp
@@ -0,0 +1,739 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: sigedit.cpp,v 1.1.1.1.2.1 2004/12/28 23:23:51 lunar_shuttle Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <values.h>
+
+#include <QEvent>
+#include <QKeyEvent>
+#include <QList>
+#include <QMouseEvent>
+#include <QPainter>
+#include <QPaintEvent>
+#include <QPixmap>
+#include <QResizeEvent>
+#include <QString>
+#include <QStyle>
+#include <QTimerEvent>
+
+///#include "sig.h"
+#include "al/sig.h"
+#include "sigedit.h"
+#include "spinbox.h"
+
+extern int mtcType;
+
+bool Sig::isValid() const
+{
+ if((z < 1) || (z > 63))
+ return false;
+
+ switch(n)
+ {
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 8:
+ case 16:
+ case 32:
+ case 64:
+ case 128:
+ return true;
+ default:
+ return false;
+ }
+}
+
+
+//---------------------------------------------------------
+// NumberSection
+//---------------------------------------------------------
+
+class NumberSection
+ {
+ int selstart;
+ int selend;
+
+ public:
+ NumberSection(int selStart = 0, int selEnd = 0)
+ : selstart(selStart), selend(selEnd ) {}
+ int selectionStart() const { return selstart; }
+ void setSelectionStart(int s) { selstart = s; }
+ int selectionEnd() const { return selend; }
+ void setSelectionEnd( int s ) { selend = s; }
+ int width() const { return selend - selstart; }
+ };
+
+//---------------------------------------------------------
+// SigEditor
+//---------------------------------------------------------
+
+class SigEditor : public QLineEdit
+ {
+ SigEdit* cw;
+ bool frm;
+ QPixmap *pm;
+ int focusSec;
+ QList<NumberSection> sections;
+ int offset;
+
+ int section(const QPoint&);
+
+ protected:
+ void init();
+ bool event(QEvent *e);
+ void resizeEvent(QResizeEvent*);
+ void paintEvent(QPaintEvent*);
+ void mousePressEvent(QMouseEvent *e);
+ void keyPressEvent(QKeyEvent * event );
+ void applyFocusSelection() {}
+
+ public:
+ SigEditor(SigEdit* parent, const char* name);
+ ~SigEditor();
+
+ void setControlWidget(SigEdit * widget);
+ SigEdit* controlWidget() const;
+
+ int focusSection() const { return focusSec; }
+
+ bool setFocusSection(int s);
+ void appendSection(const NumberSection& sec);
+ void clearSections();
+ void setSectionSelection(int sec, int selstart, int selend);
+ };
+
+//---------------------------------------------------------
+// section
+//---------------------------------------------------------
+
+int SigEditor::section(const QPoint& pt)
+ {
+ if (pm->isNull())
+ return -1;
+ QPainter p(pm);
+ int fw = frm ? style()->pixelMetric(QStyle::PM_DefaultFrameWidth) : 0;
+ int x = 2 + fw;
+ int y = 0;
+ int w = width();
+ int h = height();
+ for (int i = 0; i < sections.count(); ++i) {
+ QString s = cw->sectionFormattedText(i);
+ QRect bb = p.boundingRect(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s);
+ int nx = bb.x() + bb.width();
+ if (pt.x() >= x && pt.x() < nx)
+ return i;
+ x = nx;
+ if (i < sections.count()-1) {
+ QString s("/");
+ p.drawText(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s, -1, &bb);
+ x = bb.x() + bb.width();
+ }
+ }
+ return -1;
+ }
+
+//---------------------------------------------------------
+// SigEditor
+//---------------------------------------------------------
+
+SigEditor::SigEditor(SigEdit* parent, const char* name)
+ : QLineEdit(parent)
+ {
+ setObjectName(name);
+ cw = parent;
+ frm = true;
+ focusSec = 0;
+ pm = new QPixmap;
+ offset = 0;
+ init();
+ }
+
+//---------------------------------------------------------
+// ~SigEditor
+//---------------------------------------------------------
+
+SigEditor::~SigEditor()
+ {
+ delete pm;
+ }
+
+//---------------------------------------------------------
+// init
+//---------------------------------------------------------
+
+void SigEditor::init()
+ {
+ setBackgroundMode(Qt::PaletteBase);
+ setFocusSection(-1);
+ setKeyCompression(true);
+ setFocusPolicy(Qt::WheelFocus);
+ }
+
+//---------------------------------------------------------
+// event
+//---------------------------------------------------------
+
+bool SigEditor::event(QEvent *e)
+ {
+ if (e->type() == QEvent::FocusIn || e->type() == QEvent::FocusOut) {
+ repaint( rect(), false);
+ }
+ else if (e->type() == QEvent::ShortcutOverride) {
+ QKeyEvent* ke = (QKeyEvent*) e;
+ switch (ke->key()) {
+ case Qt::Key_Delete:
+ case Qt::Key_Backspace:
+ case Qt::Key_Up:
+ case Qt::Key_Down:
+ case Qt::Key_Left:
+ case Qt::Key_Right:
+ ke->accept();
+ default:
+ break;
+ }
+ }
+ return QLineEdit::event(e);
+ }
+
+void SigEditor::resizeEvent(QResizeEvent *e)
+ {
+ pm->resize(e->size());
+ QLineEdit::resizeEvent(e);
+ }
+
+//---------------------------------------------------------
+// paintEvent
+//---------------------------------------------------------
+
+void SigEditor::paintEvent(QPaintEvent *)
+ {
+ if (pm->isNull())
+ return;
+
+ const QColorGroup & cg = colorGroup();
+ QPainter p(pm);
+ p.setPen(colorGroup().text());
+ QBrush bg = cg.brush(QColorGroup::Base);
+
+ int fw = frm ? style()->pixelMetric(QStyle::PM_DefaultFrameWidth) : 0;
+ int x = 2 + fw;
+ int y = 0;
+ int w = width();
+ int h = height();
+ p.fillRect(0, 0, w, h, bg);
+
+ for (int i = 0; i < sections.count(); ++i) {
+ QRect bb;
+ QString s = cw->sectionFormattedText(i);
+
+ if (hasFocus() && (int(i) == focusSec)) {
+ QBrush bg = cg.brush(QColorGroup::Highlight);
+ QRect r = p.boundingRect(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s, -1);
+ p.setPen(colorGroup().highlightedText());
+ p.fillRect(r, bg);
+ }
+ else
+ p.setPen(colorGroup().text());
+ p.drawText(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s, -1, &bb);
+ x = bb.x() + bb.width();
+ if (i < sections.count()-1) {
+ QString s("/");
+ p.drawText(x, y, w, h, Qt::AlignVCenter|Qt::AlignLeft, s, -1, &bb);
+ x = bb.x() + bb.width();
+ }
+ }
+ p.end();
+ bitBlt(this, 0, 0, pm);
+ }
+
+//---------------------------------------------------------
+// mousePressEvent
+//---------------------------------------------------------
+
+void SigEditor::mousePressEvent(QMouseEvent *e)
+ {
+ QPoint p(e->pos().x(), 0);
+ int sec = section(p);
+ if (sec != -1) {
+ cw->setFocusSection(sec);
+ repaint(rect(), false);
+ }
+ }
+
+//---------------------------------------------------------
+// keyPressEvent
+//---------------------------------------------------------
+
+void SigEditor::keyPressEvent(QKeyEvent * e )
+ {
+ switch (e->key()) {
+ case Qt::Key_Right:
+ if (unsigned(focusSec) <= sections.count()) {
+ if (cw->setFocusSection(focusSec+1))
+ repaint(rect(), false);
+ }
+ case Qt::Key_Left:
+ if (focusSec > 0 ) {
+ if (cw->setFocusSection(focusSec-1))
+ repaint(rect(), false);
+ }
+ case Qt::Key_Up:
+ cw->stepUp();
+ case Qt::Key_Down:
+ cw->stepDown();
+ case Qt::Key_Backspace:
+ case Qt::Key_Delete:
+ cw->removeLastNumber(focusSec);
+ case Qt::Key_Enter:
+ case Qt::Key_Return:
+ cw->enterPressed();
+ default:
+ QString txt = e->text();
+ if (!txt.isEmpty() && txt[0] == '/') {
+ // do the same thing as KEY_RIGHT when the user presses the separator key
+ if (focusSec < (signed)(sections.count())) {
+ if (cw->setFocusSection(focusSec+1))
+ repaint(rect(), false);
+ }
+ }
+ int num = txt[0].digitValue();
+
+ //printf("SigEditor::keyPressEvent num:%d\n", num);
+
+ if (num != -1) {
+ cw->addNumber(focusSec, num);
+ }
+ }
+ }
+
+void SigEditor::appendSection(const NumberSection& sec)
+ {
+ sections.append(sec);
+ }
+void SigEditor::clearSections()
+ {
+ sections.clear();
+ }
+
+//---------------------------------------------------------
+// setSectionSelection
+//---------------------------------------------------------
+
+void SigEditor::setSectionSelection(int secNo, int selstart, int selend)
+ {
+ if (secNo < 0 || secNo > (int)sections.count())
+ return;
+ sections[secNo].setSelectionStart(selstart);
+ sections[secNo].setSelectionEnd(selend);
+ }
+
+//---------------------------------------------------------
+// setFocusSection
+//---------------------------------------------------------
+
+bool SigEditor::setFocusSection(int idx)
+ {
+ if (idx > (int)sections.count()-1 || idx < 0)
+ return false;
+ if (idx != focusSec) {
+ focusSec = idx;
+ applyFocusSelection();
+ return true;
+ }
+ return false;
+ }
+
+//---------------------------------------------------------
+// SigEdit
+//---------------------------------------------------------
+
+SigEdit::SigEdit(QWidget* parent, const char* name)
+ : QWidget(parent)
+ {
+ setObjectName(name);
+ init();
+ updateButtons();
+ }
+
+SigEdit::~SigEdit()
+ {
+ }
+
+//---------------------------------------------------------
+// init
+//---------------------------------------------------------
+
+void SigEdit::init()
+ {
+ ed = new SigEditor(this, "pos editor");
+ controls = new SpinBox(this);
+ controls->setEditor(ed);
+ setFocusProxy(ed);
+ connect(controls, SIGNAL(stepUpPressed()), SLOT(stepUp()));
+ connect(controls, SIGNAL(stepDownPressed()), SLOT(stepDown()));
+ connect(this, SIGNAL(valueChanged(int,int)),SLOT(updateButtons()));
+
+ overwrite = false;
+ timerId = 0;
+ typing = false;
+ changed = false;
+ adv = false;
+
+ sec[0].offset = 0;
+ sec[0].len = 2;
+ sec[0].val = 4;
+ sec[0].voff = 0;
+ sec[1].offset = 3;
+ sec[1].len = 3;
+ sec[1].val = 4;
+ sec[1].voff = 0;
+ ed->clearSections();
+ ed->appendSection(NumberSection(0,0));
+ ed->appendSection(NumberSection(0,0));
+ setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
+ }
+
+//---------------------------------------------------------
+// setValue
+//---------------------------------------------------------
+
+void SigEdit::setValue(const Sig& sig)
+ {
+ sec[0].val = sig.z;
+ sec[1].val = sig.n;
+ changed = false;
+ ed->repaint(ed->rect(), false);
+ }
+
+void SigEdit::setValue(const QString& s)
+ {
+ int z, n;
+ sscanf(s.toLatin1(), "%d/%d", &z, &n);
+ Sig sig(z, n);
+ setValue(sig);
+ }
+
+Sig SigEdit::sig() const
+ {
+ Sig sig(sec[0].val, sec[1].val);
+ return sig;
+ }
+
+bool SigEdit::event(QEvent *e)
+ {
+ if (e->type() == QEvent::FocusOut) {
+ typing = false;
+ if (changed) {
+ emit valueChanged(sig().z, sig().n);
+ changed = false;
+ }
+ }
+ return QWidget::event(e);
+ }
+
+void SigEdit::timerEvent(QTimerEvent *)
+ {
+ overwrite = true;
+ }
+
+//---------------------------------------------------------
+// stepUp
+//---------------------------------------------------------
+
+void SigEdit::stepUp()
+ {
+ bool accepted = false;
+ int secNo = ed->focusSection();
+ int val = sec[secNo].val;
+ if (secNo == 0) {
+ if (val < 63) {
+ ++val;
+ accepted = true;
+ }
+ }
+ else {
+ accepted = true;
+ switch(val) {
+ case 1: val = 2; break;
+ case 2: val = 3; break;
+ case 3: val = 4; break;
+ case 4: val = 8; break;
+ case 8: val = 16; break;
+ case 16: val = 32; break;
+ case 32: val = 64; break;
+ case 64: val = 128; break;
+ case 128: accepted = false; break;
+ }
+ }
+ if (accepted) {
+ setSec(secNo, val);
+ changed = true;
+ emit valueChanged(sec[0].val, sec[1].val);
+ }
+ ed->repaint(ed->rect(), false);
+ }
+
+//---------------------------------------------------------
+// stepDown
+//---------------------------------------------------------
+
+void SigEdit::stepDown()
+ {
+ bool accepted = false;
+ int secNo = ed->focusSection();
+ int val = sec[secNo].val;
+ if (secNo == 0) {
+ if (val > 1) {
+ --val;
+ accepted = true;
+ }
+ }
+ else {
+ accepted = true;
+ switch(val) {
+ case 1: accepted = false; break;
+ case 2: val = 1; break;
+ case 3: val = 2; break;
+ case 4: val = 3; break;
+ case 8: val = 4; break;
+ case 16: val = 8; break;
+ case 32: val = 16; break;
+ case 64: val = 32; break;
+ case 128: val = 64; break;
+ }
+ }
+ if (accepted) {
+ setSec(secNo, val);
+ changed = true;
+ emit valueChanged(sec[0].val, sec[1].val);
+ }
+ ed->repaint(ed->rect(), false);
+ }
+
+//---------------------------------------------------------
+// sectionFormattedText
+// Returns the formatted number for section sec.
+//---------------------------------------------------------
+
+QString SigEdit::sectionFormattedText(int secNo)
+ {
+ QString txt = sectionText(secNo);
+
+ int so = sec[secNo].offset;
+ int len = sec[secNo].len;
+ int eo = so + len;
+
+ if (typing && secNo == ed->focusSection())
+ ed->setSectionSelection(secNo, eo - txt.length(), eo);
+ else
+ ed->setSectionSelection(secNo, so, eo);
+ if (secNo == 0)
+ txt = txt.rightJustify(len, ' ');
+// else
+// txt = txt.leftJustify(len, ' ');
+ return txt;
+ }
+
+//---------------------------------------------------------
+// setFocusSection
+//---------------------------------------------------------
+
+bool SigEdit::setFocusSection(int s)
+ {
+ if (s != ed->focusSection()) {
+ killTimer(timerId);
+ overwrite = true;
+ typing = false;
+ int so = sec[s].offset;
+ int eo = so + sec[s].len;
+ ed->setSectionSelection(s, so, eo);
+ if (changed) {
+ emit valueChanged(sig().z, sig().n);
+ changed = false;
+ }
+ }
+ return ed->setFocusSection(s);
+ }
+
+//---------------------------------------------------------
+// setSec
+//---------------------------------------------------------
+
+void SigEdit::setSec(int secNo, int val)
+ {
+ sec[secNo].val = val;
+ }
+
+//---------------------------------------------------------
+// sectionText
+// Returns the text of section \a sec.
+//---------------------------------------------------------
+
+QString SigEdit::sectionText(int secNo)
+ {
+ return QString::number(sec[secNo].val + sec[secNo].voff);
+ }
+
+//---------------------------------------------------------
+// outOfRange
+// return true if out of range
+//---------------------------------------------------------
+
+bool SigEdit::outOfRange(int secNo, int val) const
+ {
+ if (secNo == 0)
+ return ((val < 1) || (val > 63));
+ switch (val) {
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ case 8:
+ case 16:
+ case 32:
+ case 64:
+ case 128:
+ // Changed p3.3.43
+ //return true;
+ return false;
+ default:
+ // Changed p3.3.43
+ //return false;
+ return true;
+ }
+ }
+
+//---------------------------------------------------------
+// addNumber
+//---------------------------------------------------------
+
+void SigEdit::addNumber(int secNo, int num)
+ {
+ if (secNo == -1)
+ return;
+ killTimer(timerId);
+ bool accepted = false;
+ typing = true;
+ int voff = sec[secNo].voff;
+
+ QString txt = sectionText(secNo);
+
+ //printf("SigEdit::addNumber secNo:%d num:%d voff:%d txt:%s\n", secNo, num, voff, txt.toLatin1());
+
+ if ((unsigned) txt.length() == sec[secNo].len) {
+ //printf("SigEdit::addNumber txt.length() == sec[secNo].len (%d)\n", sec[secNo].len);
+
+ if (!outOfRange(secNo, num - voff)) {
+ //printf("SigEdit::addNumber accepted\n");
+
+ accepted = true;
+ sec[secNo].val = num - voff;
+ }
+ }
+ else {
+ //printf("SigEdit::addNumber txt.length() != sec[secNo].len (%d)\n", sec[secNo].len);
+
+ txt += QString::number(num);
+ int temp = txt.toInt() - voff;
+ if (outOfRange(secNo, temp))
+ {
+ //printf("SigEdit::addNumber not accepted secNo:%d txt:%s temp:%d\n", secNo, txt.toLatin1(), temp);
+
+ txt = sectionText(secNo);
+ }
+ else {
+ //printf("SigEdit::addNumber accepted\n");
+
+ accepted = true;
+ sec[secNo].val = temp;
+ }
+ if (adv && ((unsigned) txt.length() == sec[secNo].len)) {
+ setFocusSection(ed->focusSection() + 1);
+ }
+ }
+ changed = accepted;
+ if (accepted)
+ emit valueChanged(sig().z, sig().n);
+ timerId = startTimer(qApp->doubleClickInterval()*4);
+ ed->repaint(ed->rect(), false);
+ }
+
+//---------------------------------------------------------
+// removeLastNumber
+//---------------------------------------------------------
+
+void SigEdit::removeLastNumber(int secNo)
+ {
+ if (secNo == -1)
+ return;
+ QString txt = QString::number(sec[secNo].val);
+ txt = txt.mid(0, txt.length() - 1);
+ sec[secNo].val = txt.toInt() - sec[secNo].voff;
+ ed->repaint(ed->rect(), false);
+ }
+
+//---------------------------------------------------------
+// resizeEvent
+//---------------------------------------------------------
+
+void SigEdit::resizeEvent(QResizeEvent *)
+ {
+ controls->resize(width(), height());
+ }
+
+//---------------------------------------------------------
+// sizeHint
+//---------------------------------------------------------
+
+QSize SigEdit::sizeHint() const
+ {
+ QFontMetrics fm(font());
+ int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth, 0, this); // ddskrjo
+ int h = fm.height() + fw * 2;
+
+ int w = 2 + controls->arrowWidth() + fw * 4;
+ w += fm.width('9') * 5 + fm.width('/');
+ return QSize(w, h).expandedTo(QApplication::globalStrut());
+ }
+
+//---------------------------------------------------------
+// updateButtons
+//---------------------------------------------------------
+
+void SigEdit::updateButtons()
+ {
+ int secNo = ed->focusSection();
+ int val = sec[secNo].val;
+
+ bool upEnabled;
+ bool downEnabled;
+
+ if (secNo == 0) {
+ upEnabled = val < 63;
+ downEnabled = val > 1;
+ }
+ else {
+ upEnabled = true;
+ downEnabled = true;
+ switch (val) {
+ case 1: downEnabled = false; break;
+ case 128: upEnabled = false; break;
+ }
+ }
+ controls->setStepEnabled(isEnabled() & upEnabled, isEnabled() & downEnabled);
+ }
+
+//---------------------------------------------------------
+// enterPressed
+//! emit returnPressed
+//---------------------------------------------------------
+void SigEdit::enterPressed()
+ {
+ emit returnPressed();
+ }
diff --git a/attic/muse2-oom/muse2/muse/widgets/sigedit.h b/attic/muse2-oom/muse2/muse/widgets/sigedit.h
new file mode 100644
index 00000000..07ae0741
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/sigedit.h
@@ -0,0 +1,88 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: sigedit.h,v 1.1.1.1.2.1 2004/12/28 23:23:51 lunar_shuttle Exp $
+// (C) Copyright 2002 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SIGEDIT_H__
+#define __SIGEDIT_H__
+
+#include <QWidget>
+
+#include "section.h"
+
+class QResizeEvent;
+class QTimerEvent;
+
+class SigEditor;
+class SpinBox;
+
+struct Sig {
+ int z;
+ int n;
+ public:
+ Sig(int _z, int _n) : z(_z), n(_n) {}
+ bool isValid() const;
+ };
+
+//---------------------------------------------------------
+// SigEdit
+//---------------------------------------------------------
+
+class SigEdit : public QWidget
+ {
+ Q_OBJECT
+ void init();
+
+ QString sectionText(int sec);
+ Section sec[2];
+
+ bool adv;
+ bool overwrite;
+ int timerId;
+ bool typing;
+ bool changed;
+ SigEditor *ed;
+ SpinBox* controls;
+
+ private slots:
+ void stepUp();
+ void stepDown();
+
+ signals:
+ void valueChanged(int, int);
+ void returnPressed();
+
+ protected:
+ bool event(QEvent *e );
+ void timerEvent(QTimerEvent* e);
+ void resizeEvent(QResizeEvent*);
+ QString sectionFormattedText(int sec);
+ void addNumber(int sec, int num);
+ void removeLastNumber(int sec);
+ bool setFocusSection(int s);
+
+ virtual bool outOfRange(int, int) const;
+ virtual void setSec(int, int);
+ friend class SigEditor;
+
+ protected slots:
+ void updateButtons();
+
+ public slots:
+ virtual void setValue(const Sig& sig);
+ void setValue(const QString& s);
+
+ public:
+ SigEdit(QWidget*, const char* = 0);
+ ~SigEdit();
+
+ QSize sizeHint() const;
+ Sig sig() const;
+ virtual void setAutoAdvance(bool advance) { adv = advance; }
+ bool autoAdvance() const { return adv; }
+ void enterPressed();
+ };
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/siglabel.cpp b/attic/muse2-oom/muse2/muse/widgets/siglabel.cpp
new file mode 100644
index 00000000..47fcd2f8
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/siglabel.cpp
@@ -0,0 +1,164 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: siglabel.cpp,v 1.1.1.1 2003/10/27 18:54:28 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "siglabel.h"
+#include <stdio.h>
+
+#define TIMER1 400
+#define TIMER2 200
+#define TIMEC 7
+#define TIMER3 100
+#define TIMEC2 20
+#define TIMER4 50
+
+#include "globals.h"
+#include <QMouseEvent>
+#include <QWheelEvent>
+#include <QLabel>
+
+//---------------------------------------------------------
+// SigLabel
+// edit Signature Values (4/4)
+//---------------------------------------------------------
+
+SigLabel::SigLabel(int z, int n, QWidget* parent) : QLabel(parent)
+ {
+ z = n = 0;
+ setFocusPolicy(Qt::NoFocus);
+ setAlignment(Qt::AlignCenter);
+ setValue(z, n);
+ }
+
+SigLabel::SigLabel(const AL::TimeSignature& sig, QWidget* parent) : QLabel(parent)
+ {
+ z = n = 0;
+ setFocusPolicy(Qt::NoFocus);
+ setAlignment(Qt::AlignCenter);
+ setValue(sig.z, sig.n);
+ }
+
+//---------------------------------------------------------
+// mousePressEvent
+//---------------------------------------------------------
+
+void SigLabel::mousePressEvent(QMouseEvent* event)
+ {
+ int button = event->button();
+ bool zaehler = event->x() < width() /2;
+
+ int zz = z, nn = n;
+ switch (button) {
+ case Qt::LeftButton:
+ return;
+ case Qt::MidButton:
+ incValue(zaehler, false, zz, nn);
+ break;
+ case Qt::RightButton:
+ incValue(zaehler, true, zz, nn);
+ break;
+ default:
+ break;
+ }
+ if ((zz != z) || (nn != n)) {
+ setValue(zz, nn);
+ emit valueChanged(AL::TimeSignature(zz, nn));
+ }
+ }
+
+//---------------------------------------------------------
+// incValue
+//---------------------------------------------------------
+
+void SigLabel::incValue(bool zaehler, bool up, int& zz, int& nn)
+ {
+ if (!up) {
+ if (zaehler) {
+ --zz;
+ if (zz < 1)
+ zz = 1;
+ }
+ else {
+ switch (nn) {
+ case 1: break;
+ case 2: nn = 1; break;
+ case 4: nn = 2; break;
+ case 8: nn = 4; break;
+ case 16: nn = 8; break;
+ case 32: nn = 16; break;
+ case 64: nn = 32; break;
+ case 128: nn = 64; break;
+ }
+ }
+ }
+ else {
+ if (zaehler) {
+ ++zz;
+ if (zz > 16)
+ zz = 16;
+ }
+ else {
+ switch (nn) {
+ case 1: nn = 2; break;
+ case 2: nn = 4; break;
+ case 4: nn = 8; break;
+ case 8: nn = 16; break;
+ case 16: nn = 32; break;
+ case 32: nn = 64; break;
+ case 64: nn = 128; break;
+ case 128: break;
+ }
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// wheelEvent
+//---------------------------------------------------------
+
+void SigLabel::wheelEvent(QWheelEvent* event)
+ {
+ bool zaehler = event->x() < width() /2;
+ int delta = event->delta();
+ int zz = z, nn = n;
+
+ bool inc = delta >= 0;
+ incValue(zaehler, inc, zz, nn);
+ if ((zz != z) || (nn != n)) {
+ setValue(zz, nn);
+ emit valueChanged(AL::TimeSignature(zz, nn));
+ }
+ }
+
+//---------------------------------------------------------
+// setValue
+//---------------------------------------------------------
+
+void SigLabel::setValue(int a, int b)
+ {
+ if (a == z && b == n)
+ return;
+ z = a;
+ n = b;
+ QString sa;
+ sa.setNum(a);
+
+ QString sb;
+ sb.setNum(b);
+
+ QString s = sa + QString("/") + sb;
+ setText(s);
+ }
+
+//---------------------------------------------------------
+// setFrame
+//---------------------------------------------------------
+
+void SigLabel::setFrame(bool flag)
+ {
+ setFrameStyle(flag ? Panel | Sunken : NoFrame);
+ setLineWidth(2);
+ }
diff --git a/attic/muse2-oom/muse2/muse/widgets/siglabel.h b/attic/muse2-oom/muse2/muse/widgets/siglabel.h
new file mode 100644
index 00000000..bf9e53b4
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/siglabel.h
@@ -0,0 +1,47 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: siglabel.h,v 1.1.1.1 2003/10/27 18:54:56 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SIGLABEL_H__
+#define __SIGLABEL_H__
+
+#include <al/sig.h>
+
+#include <QLabel>
+
+class QWheelEvent;
+class QMouseEvent;
+
+//---------------------------------------------------------
+// SigLabel
+// show/edit time signature
+//---------------------------------------------------------
+
+class SigLabel : public QLabel {
+ Q_OBJECT
+ virtual void mousePressEvent(QMouseEvent*);
+ virtual void wheelEvent(QWheelEvent*);
+ void incValue(bool zaehler, bool inc, int&, int&);
+
+ protected:
+ int z, n;
+
+ signals:
+ void valueChanged(const AL::TimeSignature&);
+
+ public slots:
+ virtual void setValue(int, int);
+ virtual void setValue(const AL::TimeSignature& sig) { setValue(sig.z, sig.n); }
+
+ public:
+ SigLabel(int z, int n, QWidget*);
+ SigLabel(const AL::TimeSignature&, QWidget*);
+ void value(int& a, int& b) const { a = z; b = n; }
+ AL::TimeSignature value() const { return AL::TimeSignature(z, n); }
+ void setFrame(bool);
+ };
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/sigscale.cpp b/attic/muse2-oom/muse2/muse/widgets/sigscale.cpp
new file mode 100644
index 00000000..74ed0bcb
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/sigscale.cpp
@@ -0,0 +1,152 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: sigscale.cpp,v 1.6 2004/04/11 13:03:32 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <values.h>
+
+#include <QMouseEvent>
+#include <QPainter>
+
+#include "al/sig.h" // Tim.
+#include "globals.h"
+#include "midieditor.h"
+#include "sigscale.h"
+#include "song.h"
+#include "gconfig.h"
+
+//---------------------------------------------------------
+// SigScale
+//---------------------------------------------------------
+
+SigScale::SigScale(int* r, QWidget* parent, int xs)
+ : View(parent, xs, 1)
+ {
+ setToolTip(tr("signature scale"));
+ raster = r;
+ pos[0] = song->cpos();
+ pos[1] = song->lpos();
+ pos[2] = song->rpos();
+ button = Qt::NoButton;
+ setMouseTracking(true);
+ connect(song, SIGNAL(posChanged(int, unsigned, bool)), this, SLOT(setPos(int, unsigned, bool)));
+ setFixedHeight(18);
+ }
+
+//---------------------------------------------------------
+// setPos
+//---------------------------------------------------------
+
+void SigScale::setPos(int idx, unsigned val, bool)
+ {
+ if (val == pos[idx])
+ return;
+ unsigned opos = mapx(pos[idx]);
+ pos[idx] = val;
+ if (!isVisible())
+ return;
+ val = mapx(val);
+ int x = -9;
+ int w = 18;
+ if (opos > val) {
+ w += opos - val;
+ x += val;
+ }
+ else {
+ w += val - opos;
+ x += opos;
+ }
+ redraw(QRect(x, 0, w, height()));
+ }
+
+void SigScale::viewMousePressEvent(QMouseEvent* event)
+ {
+ button = event->button();
+ viewMouseMoveEvent(event);
+ }
+
+void SigScale::viewMouseReleaseEvent(QMouseEvent*)
+ {
+ button = Qt::NoButton;
+ }
+
+void SigScale::viewMouseMoveEvent(QMouseEvent* event)
+ {
+ int x = AL::sigmap.raster(event->x(), *raster);
+ emit timeChanged(x);
+ int i;
+ switch (button) {
+ case Qt::LeftButton:
+ i = 0;
+ break;
+ case Qt::MidButton:
+ i = 1;
+ break;
+ case Qt::RightButton:
+ i = 2;
+ break;
+ default:
+ return;
+ }
+ Pos p(x, true);
+ song->setPos(i, p);
+ }
+
+//---------------------------------------------------------
+// leaveEvent
+//---------------------------------------------------------
+
+void SigScale::leaveEvent(QEvent*)
+ {
+// emit timeChanged(MAXINT);
+ }
+
+//---------------------------------------------------------
+// draw
+//---------------------------------------------------------
+
+void SigScale::pdraw(QPainter& p, const QRect& r)
+ {
+ int x = r.x();
+ int w = r.width();
+ int h = height();
+
+ if (x < 0)
+ x = 0;
+ p.setFont(config.fonts[3]);
+ ///for (ciSigEvent si = sigmap.begin(); si != sigmap.end(); ++si) {
+ for (AL::ciSigEvent si = AL::sigmap.begin(); si != AL::sigmap.end(); ++si) {
+ ///SigEvent* e = si->second;
+ AL::SigEvent* e = si->second;
+ int xp = mapx(e->tick);
+ if (xp > x+w)
+ break;
+ if (xp+40 < x)
+ continue;
+ p.drawLine(xp, 0, xp, h/2);
+ p.drawLine(xp, h/2, xp+5, h/2);
+ QString s;
+ s.sprintf("%d/%d", e->sig.z, e->sig.n);
+ p.drawText(xp+8, h-6, s);
+ }
+
+ //---------------------------------------------------
+ // draw location marker
+ //---------------------------------------------------
+
+ p.setPen(Qt::red);
+ int xp = mapx(pos[0]);
+ if (xp >= x && xp < x+w)
+ p.drawLine(xp, 0, xp, h);
+ p.setPen(Qt::blue);
+ xp = mapx(pos[1]);
+ if (xp >= x && xp < x+w)
+ p.drawLine(xp, 0, xp, h);
+ xp = mapx(pos[2]);
+ if (xp >= x && xp < x+w)
+ p.drawLine(xp, 0, xp, h);
+ }
+
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/sigscale.h b/attic/muse2-oom/muse2/muse/widgets/sigscale.h
new file mode 100644
index 00000000..8c9ffea9
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/sigscale.h
@@ -0,0 +1,46 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: sigscale.h,v 1.2 2004/01/11 18:55:37 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SIGSCALE_H__
+#define __SIGSCALE_H__
+
+#include "view.h"
+
+class MidiEditor;
+
+//---------------------------------------------------------
+// SigScale
+// Time Signature Scale
+//---------------------------------------------------------
+
+class SigScale : public View {
+ Q_OBJECT
+ int* raster;
+ unsigned pos[3];
+ int button;
+
+ signals:
+ void posChanged(unsigned, unsigned);
+
+ protected:
+ virtual void pdraw(QPainter&, const QRect&);
+ virtual void viewMousePressEvent(QMouseEvent* event);
+ virtual void viewMouseMoveEvent(QMouseEvent* event);
+ virtual void viewMouseReleaseEvent(QMouseEvent* event);
+ virtual void leaveEvent(QEvent*e);
+
+ signals:
+ void timeChanged(unsigned);
+
+ public slots:
+ void setPos(int, unsigned, bool);
+
+ public:
+ SigScale(int* raster, QWidget* parent, int xscale);
+ };
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/slider.cpp b/attic/muse2-oom/muse2/muse/widgets/slider.cpp
new file mode 100644
index 00000000..9776d4e1
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/slider.cpp
@@ -0,0 +1,975 @@
+#include <cmath>
+#include "mmath.h"
+
+#include <QPainter>
+#include <QResizeEvent>
+
+#include "slider.h"
+
+//-------------------------------------------------------------
+// Slider - The Slider Widget
+//
+// Slider is a slider widget which operates on an interval
+// of type double. Slider supports different layouts as
+// well as a scale.
+//------------------------------------------------------------
+
+//------------------------------------------------------------
+//.F Slider::Slider
+//
+// Constructor
+//
+//.u Syntax:
+//.f Slider::Slider(QWidget *parent, const char *name, Orientation orient = Horizontal, ScalePos scalePos = None, int bgStyle = BgTrough)
+//
+//.u Parameters
+//.p
+// QWidget *parent -- parent widget
+// const char *name -- The Widget's name. Default = 0.
+// Orientation Orient -- Orientation of the slider. Can be Slider::Horizontal
+// or Slider::Vertical.
+// Defaults to Horizontal.
+// ScalePos scalePos -- Position of the scale. Can be Slider::None,
+// Slider::Left, Slider::Right, Slider::Top,
+// or Slider::Bottom. Defaults to Slider::None.
+// int bgStyle -- Background style. Slider::BgTrough draws the
+// slider button in a trough, Slider::BgSlot draws
+// a slot underneath the button. An or-combination of both
+// may also be used. The default is Slider::BgTrough.
+//------------------------------------------------------------
+
+Slider::Slider(QWidget *parent, const char *name,
+ Qt::Orientation orient, ScalePos scalePos, int bgStyle)
+ : SliderBase(parent,name)
+ {
+ if (bgStyle == BgSlot) {
+ d_thumbLength = 16;
+ d_thumbHalf = 8;
+ d_thumbWidth = 30;
+ }
+ else {
+ //d_thumbLength = 30;
+ d_thumbLength = 32;
+ d_thumbHalf = 16;
+ d_thumbWidth = 16;
+ }
+
+ d_borderWidth = 2;
+ d_scaleDist = 4;
+ d_scaleStep = 0.0;
+ d_scalePos = scalePos;
+ d_xMargin = 0;
+ d_yMargin = 0;
+ d_bgStyle = bgStyle;
+
+
+ if (bgStyle & BgTrough)
+ d_bwTrough = d_borderWidth;
+ else
+ d_bwTrough = 0;
+
+ d_sliderRect.setRect(0, 0, 8, 8);
+ setOrientation(orient);
+ }
+
+//------------------------------------------------------------
+//.F Slider::~Slider
+// Destructor
+//.u Syntax
+//.f Slider::~Slider()
+//------------------------------------------------------------
+
+Slider::~Slider()
+ {
+ }
+
+//------------------------------------------------------------
+//
+//.F Slider::setBorderWidth
+// Change the slider's border width
+//
+//.u Syntax
+//.f void Slider::setBorderWidth(int bd)
+//
+//.u Parameters
+//.p int bd -- border width
+//
+//------------------------------------------------------------
+
+void Slider::setBorderWidth(int bd)
+{
+ d_borderWidth = qwtMin(qwtMax(bd,0),10);
+ if (d_bgStyle & BgTrough)
+ d_bwTrough = d_borderWidth;
+ else
+ d_bwTrough = 0;
+}
+
+//----------------------------------------------------
+//
+//.F Slider::setThumbLength
+//
+// Set the slider's thumb length
+//
+//.u Syntax
+// void Slider::setThumbLength(int l)
+//
+//.u Parameters
+//.p int l -- new length
+//
+//-----------------------------------------------------
+void Slider::setThumbLength(int l)
+{
+ d_thumbLength = qwtMax(l,8);
+ d_thumbHalf = d_thumbLength / 2;
+ resize(size());
+}
+
+//------------------------------------------------------------
+//
+//.F Slider::setThumbWidth
+// Change the width of the thumb
+//
+//.u Syntax
+//.p void Slider::setThumbWidth(int w)
+//
+//.u Parameters
+//.p int w -- new width
+//
+//------------------------------------------------------------
+void Slider::setThumbWidth(int w)
+{
+ d_thumbWidth = qwtMax(w,4);
+ resize(size());
+}
+
+
+//------------------------------------------------------------
+//.-
+//.F Slider::scaleChange
+// Notify changed scale
+//
+//.u Syntax
+//.f void Slider::scaleChange()
+//
+//.u Description
+// Called by QwtScaledWidget
+//
+//------------------------------------------------------------
+void Slider::scaleChange()
+{
+ if (!hasUserScale())
+ d_scale.setScale(minValue(), maxValue(), d_maxMajor, d_maxMinor);
+ update();
+}
+
+
+//------------------------------------------------------------
+//.-
+//.F Slider::fontChange
+// Notify change in font
+//
+//.u Syntax
+//.f Slider::fontChange(const QFont &oldFont)
+//
+//------------------------------------------------------------
+void Slider::fontChange(const QFont & /*oldFont*/)
+{
+ repaint();
+}
+
+//------------------------------------------------------------
+// drawSlider
+// Draw the slider into the specified rectangle.
+//------------------------------------------------------------
+
+void Slider::drawSlider(QPainter *p, const QRect &r)
+{
+ const QPalette& pal = palette();
+ QBrush brBack(pal.window());
+ QBrush brMid;
+ QBrush brDark(pal.dark());
+
+ QRect cr;
+
+ int ipos,dist1;
+ double rpos;
+ int lineDist;
+
+ if (d_bwTrough > 0) {
+ // qDrawShadePanel(p, r.x(), r.y(),
+ //r.width(), r.height(),
+ //pal, TRUE, d_bwTrough,0);
+ cr.setRect(r.x() + d_bwTrough,
+ r.y() + d_bwTrough,
+ r.width() - 2*d_bwTrough,
+ r.height() - 2*d_bwTrough);
+ brMid = pal.mid();
+ }
+ else {
+ cr = r;
+ brMid = brBack;
+ }
+
+ rpos = (value() - minValue()) / (maxValue() - minValue());
+
+ lineDist = d_borderWidth - 1;
+ if (lineDist < 1) lineDist = 1;
+
+ if (d_orient == Qt::Horizontal)
+ {
+
+ dist1 = int(double(cr.width() - d_thumbLength) * rpos);
+ ipos = cr.x() + dist1;
+ markerPos = ipos + d_thumbHalf;
+
+ //
+ // draw background
+ //
+ if (d_bgStyle & BgSlot)
+ {
+ drawHsBgSlot(p, cr, QRect(ipos, cr.y(), d_thumbLength, cr.height()), brMid);
+ }
+ else
+ {
+ p->fillRect(cr.x(),cr.y(),dist1,cr.height(),brMid);
+ p->fillRect(ipos + d_thumbLength, cr.y(),
+ cr.width() - d_thumbLength - dist1, cr.height(),brMid);
+ }
+
+ //
+ // Draw thumb
+ //
+ //qDrawShadePanel(p,ipos, cr.y(), d_thumbLength, cr.height(),
+ // pal, FALSE, d_borderWidth, &brBack);
+ QPixmap thumbp;
+ bool loaded = thumbp.load(":images/slider_thumb_h.png");
+ if(loaded)
+ p->drawPixmap(ipos, cr.y(), thumbp);
+
+ if (lineDist > 1)
+ qDrawShadeLine(p,markerPos, cr.y() + lineDist , markerPos,
+ cr.y() + cr.height() - lineDist,
+ pal, TRUE, 1);
+ else
+ {
+ p->setPen(pal.dark().color());
+ p->drawLine(markerPos -1 , cr.y() + lineDist, markerPos -1,
+ cr.y() + cr.height() - lineDist - 1);
+ p->setPen(pal.light().color());
+ p->drawLine(markerPos, cr.y() + lineDist, markerPos,
+ cr.y() + cr.height() - lineDist - 1);
+ }
+
+
+ }
+ else
+ {//Vertical slider
+ dist1 = int(double(cr.height() - d_thumbLength) * (1.0 - rpos));
+ ipos = cr.y() + dist1;
+ markerPos = ipos + d_thumbHalf;
+
+ //NOTE: this is adding the middle line in the slider
+ if ( d_bgStyle & BgSlot)
+ {
+ drawVsBgSlot(p, cr, QRect(cr.left(), ipos, cr.width(),
+ d_thumbLength), brMid);
+ }
+ else
+ {
+ //p->fillRect(cr.x(),cr.y(),cr.width(),ipos,brMid);
+ //p->fillRect(cr.x(), ipos + d_thumbLength, cr.width(),
+ //cr.height() - d_thumbLength - dist1, brMid);
+ }
+
+ //This adds the thumb slider
+ //qDrawShadePanel(p,cr.x(),ipos , cr.width(), d_thumbLength,
+ // pal,FALSE,d_borderWidth, &brBack);
+ QPixmap thumbp;
+ bool loaded = thumbp.load(":images/slider_thumb.png");
+ int knobx = cr.x()+2;
+ int knoby = ipos-12;
+ QRect knobRect(knobx, knoby, 18, 33);
+ //printf("Slider: Knob position X: %d Y: %d\n", knobx, knoby);
+ if(loaded)
+ {
+ p->setCompositionMode(QPainter::CompositionMode_SourceAtop);//QPainter::CompositionMode_SourceOver);
+ //p->drawPixmap(knobx, knoby, thumbp);
+ p->setClipping(false);
+ p->drawPixmap(knobRect, thumbp);
+ }
+ // if (lineDist > 1)
+ // qDrawShadeLine(p, cr.x() + lineDist , markerPos,
+ // cr.x() + cr.width() - lineDist, markerPos,
+ // pal, TRUE, 1);
+ // else
+ // {
+ //
+ // p->setPen(pal.dark().color());
+ // p->drawLine(cr.x() + lineDist, markerPos - 1 ,
+ // cr.x() + cr.width() - lineDist - 1, markerPos - 1);
+ // p->setPen(pal.light().color());
+ // p->drawLine(cr.x() + lineDist, markerPos,
+ // cr.x() + cr.width() - lineDist - 1 , markerPos);
+ // }
+ }
+
+}
+
+//------------------------------------------------------------
+//.-
+//.F Slider::drawSlotBg
+//
+//
+//.u Syntax
+//.f void Slider::drawSlotBg(QPainter *p, const QRect &rBound, const QRect &rThumb, const QRect &rSlot, const QBrush &brBack)
+//
+//.u Parameters
+//.p QPainter *p, const QRect &rBound, const QRect &rThumb, const QRect &rSlot, const QBrush &brBack
+//
+//------------------------------------------------------------
+void Slider::drawHsBgSlot(QPainter *p, const QRect &rBound, const QRect &rThumb, const QBrush &brBack)
+{
+ int ws, ds, dLeft;
+ int lPos, rPos;
+ QRect rSlot;
+ const QPalette& pal = palette();
+
+ ws = rBound.height();
+ if ((ws / 2) * 2 != ws)
+ ws = 5;
+ else
+ ws = 4;
+
+ ds = qwtMax(1, d_thumbLength/2 - 4);
+ dLeft = rThumb.left() - rBound.left();
+
+ rSlot = QRect(rBound.x() + ds, rBound.y() + (rBound.height() - ws) / 2,
+ rBound.width() - 2 * ds, ws);
+
+ rPos = qwtMin(rSlot.x(), rThumb.left());
+
+ if (rThumb.left() > rBound.x())
+ {
+ p->fillRect(rBound.x(),rBound.y(),dLeft, rSlot.top() - rBound.top(), brBack);
+ p->fillRect(rBound.x(),rSlot.bottom() + 1,dLeft,
+ rBound.bottom() - rSlot.bottom(),brBack);
+ if (rPos > rBound.left())
+ p->fillRect(rBound.x(),rSlot.y(),
+ rPos - rBound.left(),ws,brBack);
+
+ p->setPen(pal.dark().color());
+ if (rSlot.x() < rThumb.left())
+ p->drawLine(rSlot.x(), rSlot.bottom(), rSlot.x(), rSlot.top());
+ if (rSlot.x() < rThumb.left() - 1)
+ {
+ p->drawLine(rSlot.x(), rSlot.top(), rThumb.left() - 1, rSlot.top());
+ p->setPen(pal.light().color());
+ p->drawLine(rSlot.x() + 1, rSlot.bottom(),
+ rThumb.left() - 1, rSlot.bottom());
+
+ p->fillRect(rSlot.x() + 1, rSlot.y() + 1, dLeft - ds -1,
+ rSlot.height() -2, QBrush(pal.currentColorGroup() == QPalette::Disabled ?
+ pal.color(QPalette::Disabled, QPalette::WindowText) : QColor(0,12,16)));
+ }
+ }
+
+ lPos = qwtMax(rSlot.right(), rThumb.right()) + 1;
+ if (rThumb.right() < rBound.right())
+ {
+ p->fillRect(rThumb.right() + 1,rBound.y(),rBound.right() - rThumb.right(),
+ rSlot.top() - rBound.top(), brBack);
+ p->fillRect(rThumb.right() + 1,rSlot.bottom() + 1,
+ rBound.right() - rThumb.right(),
+ rBound.bottom() - rSlot.bottom(),brBack);
+ if (lPos <= rBound.right())
+ p->fillRect(lPos, rSlot.y() , rBound.right() - lPos + 1, ws ,brBack);
+
+ p->setPen(pal.dark().color());
+ if (rSlot.right() > rThumb.right())
+ {
+ p->drawLine(rThumb.right() + 1, rSlot.top(), rSlot.right(), rSlot.top());
+ p->setPen(pal.light().color());
+ p->drawLine(rSlot.right(), rSlot.bottom(), rSlot.right(), rSlot.top() + 1);
+ }
+
+ if (rSlot.right() > rThumb.right() + 1)
+ {
+ p->setPen(pal.light().color());
+ p->drawLine(rThumb.right() + 1, rSlot.bottom(),
+ rSlot.right() -1, rSlot.bottom());
+ p->fillRect(rThumb.right() + 1, rSlot.y() + 1,
+ rSlot.right() - rThumb.right() - 1,
+ rSlot.height() -2, QBrush(pal.currentColorGroup() == QPalette::Disabled ?
+ pal.color(QPalette::Disabled, QPalette::WindowText) : Qt::black));
+ }
+ }
+
+}
+
+//------------------------------------------------------------
+//.-
+//.F Slider::drawVsBgSlot
+//
+//
+//.u Syntax
+//.f void Slider::drawVsBgSlot(QPainter *p, const QRect &rBound, const QRect &rThumb, const QBrush &brBack)
+//
+//.u Parameters
+//.p QPainter *p, const QRect &rBound, const QRect &rThumb, const QBrush &brBack
+//
+//.u Return Value
+//
+//.u Description
+//
+//------------------------------------------------------------
+void Slider::drawVsBgSlot(QPainter *p, const QRect &rBound, const QRect &rThumb, const QBrush &brBack)
+{
+ QColor green = QColor(49,175,197);
+ QColor yellow = QColor(156,85,115);
+ QColor red = QColor(197,49,87);
+ QLinearGradient vuGrad(QPointF(0, 0), QPointF(0, rBound.height()));
+ vuGrad.setColorAt(1, green);
+ //vuGrad.setColorAt(0.3, yellow);
+ vuGrad.setColorAt(0, red);
+ QPen myPen = QPen();
+ //myPen.setCapStyle(Qt::RoundCap);
+ //myPen.setStyle(Qt::DashLine);
+ myPen.setBrush(QBrush(vuGrad));
+ //myPen.setWidth(w-8);
+ myPen.setWidth(1);
+
+ QColor darkColor = QColor(17,31,40);
+ QColor lightColor = QColor(80,96,109);
+ int ws, ds, dTop;
+ int lPos, hPos;
+ QRect rSlot;
+ const QPalette& pal = palette();
+
+ ws = rBound.width();
+ if ((ws / 2) * 2 != ws)
+ ws = 5;
+ else
+ ws = 4;
+
+ ds = qwtMax(1, d_thumbLength/2 - 4);
+ dTop = rThumb.top() - rBound.top();
+
+ rSlot = QRect(rBound.x() + (rBound.width() - ws) / 2, rBound.y() + ds,
+ ws, rBound.height() - 2 * ds);
+
+ hPos = qwtMin(rSlot.y(), rThumb.top());
+
+ if (rThumb.top() > rBound.top())
+ {
+ p->setPen(lightColor);
+ //p->fillRect(rBound.x(),rBound.y(), rSlot.left() - rBound.left(),dTop, brBack);
+ //p->fillRect(rSlot.right() + 1, rBound.y(),
+ // rBound.right() - rSlot.right(), dTop,brBack);
+ //if (hPos > rBound.top())
+ // p->fillRect(rSlot.x(),rBound.y(), ws, hPos - rBound.top(),brBack);
+
+ //p->setPen(pal.dark().color());
+ p->setPen(darkColor);
+ if (rSlot.top() < rThumb.top())
+ p->drawLine(rSlot.left(), rSlot.top(), rSlot.right(), rSlot.top());
+
+
+ if (rSlot.top() < rThumb.top() - 1)
+ {
+ p->drawLine(rSlot.left(), rThumb.top() - 1, rSlot.left(), rSlot.top());
+ //p->setPen(pal.light().color());
+ p->setPen(lightColor);
+ p->drawLine(rSlot.right(), rSlot.top() + 1, rSlot.right(), rThumb.top() - 1);
+
+ p->fillRect(rSlot.x() - 1, rSlot.y() + 1, rSlot.width() + 2,
+ dTop - ds -1, QBrush(pal.currentColorGroup() == QPalette::Disabled ?
+ pal.color(QPalette::Disabled, QPalette::WindowText) : QColor(0,12,16)));
+
+ }
+ }
+
+ lPos = qwtMax(rSlot.bottom(), rThumb.bottom()) + 1;
+ if (rThumb.bottom() < rBound.bottom())
+ {
+ // p->fillRect(rBound.left(), rThumb.bottom() + 1,
+ // rSlot.left() - rBound.left(),
+ // rBound.bottom() - rThumb.bottom(), brBack);
+ // p->fillRect(rSlot.right() + 1, rThumb.bottom() + 1,
+ // rBound.right() - rSlot.right(),
+ // rBound.bottom() - rThumb.bottom(), brBack);
+ //if (lPos <= rBound.bottom())
+ // p->fillRect(rSlot.left(), lPos, ws, rBound.bottom() - lPos + 1, brBack);
+
+ p->setPen(lightColor);
+ //p->setPen(pal.dark().color());
+ if (rSlot.bottom() > rThumb.bottom())
+ {
+ p->drawLine(rSlot.left(), rThumb.bottom() + 1, rSlot.left(), rSlot.bottom());
+ //p->setPen(pal.light().color());
+ p->setPen(lightColor);
+ p->drawLine(rSlot.left() * 1, rSlot.bottom(), rSlot.right(), rSlot.bottom());
+ }
+
+ if (rSlot.bottom() > rThumb.bottom() + 1)
+ {
+ //p->setPen(pal.light().color());
+ p->setPen(lightColor);
+ p->drawLine(rSlot.right(), rThumb.bottom() + 1, rSlot.right(),
+ rSlot.bottom());
+ p->fillRect(rSlot.left() - 1, rThumb.bottom() + 1,
+ rSlot.width() + 2, rSlot.bottom() - rThumb.bottom() - 1,
+ QBrush(pal.currentColorGroup() == QPalette::Disabled ?
+ pal.color(QPalette::Disabled, QPalette::WindowText) : QColor(0,12,16)));
+ p->setPen(myPen);
+ int myoffset = rSlot.left() + 1;
+ int scrollTop = rSlot.bottom() - rThumb.bottom() - 1;
+ int scrollB = rThumb.bottom() + 1;
+ for(int i = 0; i < 2; i++)
+ {
+ p->drawLine(myoffset, scrollB, myoffset, rSlot.bottom());
+ ++myoffset;
+ }
+ }
+ }
+
+}
+
+//------------------------------------------------------------
+//.-
+//.F Slider::getValue
+// Determine the value corresponding to a specified
+// mouse location.
+//
+//.u Syntax
+//.f double Slider::getValue(const QPoint &p)
+//
+//.u Parameters
+//.p const QPoint &p --
+//
+//.u Description
+// Called by SliderBase
+//------------------------------------------------------------
+double Slider::getValue( const QPoint &p)
+{
+ double rv;
+ int pos;
+ QRect r = d_sliderRect;
+
+ r.setLeft(r.left() + d_bwTrough);
+ r.setRight(r.right() - d_bwTrough);
+ r.setTop(r.top() - d_bwTrough);
+ r.setBottom(r.bottom() - d_bwTrough);
+
+ if (d_orient == Qt::Horizontal)
+ {
+
+ if (r.width() <= d_thumbLength)
+ {
+ rv = 0.5 * (minValue() + maxValue());
+ }
+ else
+ {
+ pos = p.x() - r.x() - d_thumbHalf;
+ rv = minValue() +
+ rint( (maxValue() - minValue()) * double(pos)
+ / double(r.width() - d_thumbLength)
+ / step() ) * step();
+ }
+
+ }
+ else
+ {
+ if (r.height() <= d_thumbLength)
+ {
+ rv = 0.5 * (minValue() + maxValue());
+ }
+ else
+ {
+ pos = p.y() - r.y() - d_thumbHalf;
+ rv = minValue() +
+ rint( (maxValue() - minValue()) *
+ (1.0 - double(pos)
+ / double(r.height() - d_thumbLength))
+ / step() ) * step();
+ }
+
+ }
+
+ return(rv);
+}
+
+
+//------------------------------------------------------------
+//.-
+//.F Slider::getScrollMode
+// Determine scrolling mode and direction
+//
+//.u Syntax
+//.f void Slider::getScrollMode( const QPoint &p, int &scrollMode, int &direction )
+//
+//.u Parameters
+//.p const QPoint &p -- point
+//
+//.u Description
+// Called by SliderBase
+//
+//------------------------------------------------------------
+void Slider::getScrollMode( QPoint &p, const Qt::MouseButton &button, int &scrollMode, int &direction )
+{
+ if(cursorHoming() && button == Qt::LeftButton)
+ {
+ if(d_sliderRect.contains(p))
+ {
+ scrollMode = ScrMouse;
+ direction = 0;
+
+ int mp = 0;
+ QRect cr;
+ QPoint cp;
+ int ipos,dist1;
+ double rpos;
+ int lineDist;
+
+ if(d_bwTrough > 0)
+ cr.setRect(d_sliderRect.x() + d_bwTrough,
+ d_sliderRect.y() + d_bwTrough,
+ d_sliderRect.width() - 2*d_bwTrough,
+ d_sliderRect.height() - 2*d_bwTrough);
+ else
+ cr = d_sliderRect;
+
+ rpos = (value() - minValue()) / (maxValue() - minValue());
+
+ lineDist = d_borderWidth - 1;
+ if(lineDist < 1) lineDist = 1;
+
+ if(d_orient == Qt::Horizontal)
+ {
+ dist1 = int(double(cr.width() - d_thumbLength) * rpos);
+ ipos = cr.x() + dist1;
+ mp = ipos + d_thumbHalf;
+
+ p.setX(mp);
+ cp = mapToGlobal( QPoint(mp, p.y()) );
+ }
+ else
+ {
+ dist1 = int(double(cr.height() - d_thumbLength) * (1.0 - rpos));
+ ipos = cr.y() + dist1;
+ mp = ipos + d_thumbHalf;
+ p.setY(mp);
+ cp = mapToGlobal( QPoint(p.x(), mp) );
+ }
+ cursor().setPos(cp.x(), cp.y());
+ }
+ }
+ else
+ {
+ int currentPos;
+ if (d_orient == Qt::Horizontal)
+ currentPos = p.x();
+ else
+ currentPos = p.y();
+
+ if (d_sliderRect.contains(p))
+ {
+ if ((currentPos > markerPos - d_thumbHalf)
+ && (currentPos < markerPos + d_thumbHalf))
+ {
+ scrollMode = ScrMouse;
+ direction = 0;
+ }
+ else
+ {
+ scrollMode = ScrPage;
+ if (((currentPos > markerPos) && (d_orient == Qt::Horizontal))
+ || ((currentPos <= markerPos) && (d_orient != Qt::Horizontal)))
+ direction = 1;
+ else
+ direction = -1;
+ }
+ }
+ else
+ {
+ scrollMode = ScrNone;
+ direction = 0;
+ }
+
+ }
+}
+
+//------------------------------------------------------------
+//.F Slider::paintEvent
+// Qt paint event
+//
+//.u Syntax
+//.f void Slider::paintEvent(QPaintEvent *e)
+//------------------------------------------------------------
+
+void Slider::paintEvent(QPaintEvent* /*e*/)
+ {
+ QPainter p;
+
+ if (p.begin(this)) {
+ if (d_scalePos != None) {
+ p.fillRect(rect(), palette().window());
+ d_scale.draw(&p);
+ }
+ drawSlider(&p, d_sliderRect);
+ }
+ p.end();
+ }
+
+//------------------------------------------------------------
+//.F Slider::resizeEvent
+// Qt resize event
+//
+//.u Parameters
+//.p QResizeEvent *e
+//
+//.u Syntax
+//.f void Slider::resizeEvent(QResizeEvent *e)
+//------------------------------------------------------------
+
+void Slider::resizeEvent(QResizeEvent *e)
+{
+
+ d_resized = TRUE;
+ QSize s = e->size();
+ int sliderWidth = d_thumbWidth + 2 * d_bwTrough;
+
+ // reposition slider
+ if(d_orient == Qt::Horizontal)
+ {
+ switch(d_scalePos)
+ {
+ case Top:
+
+ d_sliderRect.setRect(this->rect().x() + d_xMargin,
+ this->rect().y() + s.height() - 1
+ - d_yMargin - sliderWidth,
+ s.width() - 2 * d_xMargin,
+ sliderWidth);
+ d_scale.setGeometry(d_sliderRect.x() + d_bwTrough + d_thumbHalf,
+ d_sliderRect.y() - d_scaleDist,
+ d_sliderRect.width() - d_thumbLength - 2*d_bwTrough,
+ ScaleDraw::Top);
+
+ break;
+
+ case Bottom:
+
+ d_sliderRect.setRect(this->rect().x() + d_xMargin,
+ this->rect().y() + d_yMargin,
+ s.width() - 2*d_xMargin,
+ sliderWidth);
+ d_scale.setGeometry(d_sliderRect.x() + d_bwTrough + d_thumbHalf,
+ d_sliderRect.y() + d_sliderRect.height() + d_scaleDist,
+ d_sliderRect.width() - d_thumbLength - 2*d_bwTrough,
+ ScaleDraw::Bottom);
+
+ break;
+
+ default:
+ d_sliderRect.setRect(this->rect().x(), this->rect().x(),
+ s.width(), s.height());
+ break;
+ }
+ }
+ else
+ {
+ switch(d_scalePos)
+ {
+ case Left:
+ d_sliderRect.setRect(this->rect().x() + s.width()
+ - sliderWidth - 1 - d_xMargin,
+ this->rect().y() + d_yMargin,
+ sliderWidth,
+ s.height() - 2 * d_yMargin);
+ d_scale.setGeometry(d_sliderRect.x() - d_scaleDist,
+ d_sliderRect.y() + d_thumbHalf + d_bwTrough,
+ s.height() - d_thumbLength - 2*d_bwTrough,
+ ScaleDraw::Left);
+
+ break;
+ case Right:
+ d_sliderRect.setRect(this->rect().x() + d_xMargin,
+ this->rect().y() + d_yMargin,
+ sliderWidth,
+ s.height() - 2* d_yMargin);
+ d_scale.setGeometry(this->rect().x() + d_sliderRect.width()
+ + d_scaleDist,
+ d_sliderRect.y() + d_thumbHalf + d_bwTrough,
+ s.height() - d_thumbLength - 2*d_bwTrough,
+ ScaleDraw::Right);
+ break;
+ default:
+ d_sliderRect.setRect(this->rect().x(), this->rect().x(),
+ s.width(), s.height());
+ break;
+ }
+ }
+
+}
+
+//------------------------------------------------------------
+//.-
+//.F Slider::valueChange
+// Notify change of value
+//
+//.u Syntax
+//.f void Slider::valueChange()
+//
+//------------------------------------------------------------
+
+void Slider::valueChange()
+ {
+ update();
+ SliderBase::valueChange();
+ }
+
+//------------------------------------------------------------
+//.-
+//.F Slider::rangeChange
+// Notify change of range
+//
+//.u Description
+//
+//.u Syntax
+//.f void Slider::rangeChange()
+//
+//------------------------------------------------------------
+void Slider::rangeChange()
+{
+ if (!hasUserScale())
+ d_scale.setScale(minValue(), maxValue(), d_maxMajor, d_maxMinor);
+ SliderBase::rangeChange();
+ repaint();
+}
+
+//------------------------------------------------------------
+//
+//.F Slider::setMargins
+// Set distances between the widget's border and
+// internals.
+//
+//.u Syntax
+//.f void Slider::setMargins(int hor, int vert)
+//
+//.u Parameters
+//.p int hor, int vert -- Margins
+//
+//------------------------------------------------------------
+void Slider::setMargins(int hor, int vert)
+{
+ d_xMargin = qwtMax(0, hor);
+ d_yMargin = qwtMin(0, vert);
+ resize(this->size());
+}
+
+//------------------------------------------------------------
+//
+//.F Slider::sizeHint
+// Return a recommended size
+//
+//.u Syntax
+//.f QSize Slider::sizeHint() const
+//
+//.u Note
+// The return value of sizeHint() depends on the font and the
+// scale.
+//------------------------------------------------------------
+
+QSize Slider::sizeHint() //const ddskrjo
+ {
+ QPainter p;
+ int msWidth = 0, msHeight = 0;
+
+ int w = 40;
+ int h = 40;
+ if (d_scalePos != None) {
+ if (p.begin(this)) {
+ msWidth = d_scale.maxWidth(&p, FALSE);
+ msHeight = d_scale.maxHeight(&p);
+ }
+ p.end();
+
+ switch(d_orient) {
+ case Qt::Vertical:
+ w = 2*d_xMargin + d_thumbWidth + 2*d_bwTrough + msWidth + d_scaleDist + 2;
+ break;
+ case Qt::Horizontal:
+ h = 2*d_yMargin + d_thumbWidth + 2*d_bwTrough + msHeight + d_scaleDist;
+ break;
+ }
+ }
+ else { // no scale
+ switch(d_orient) {
+ case Qt::Vertical:
+ w = 16 + 2 * d_bwTrough;
+ break;
+ case Qt::Horizontal:
+ h = 16 + 2 * d_bwTrough;
+ break;
+ }
+ }
+ return QSize(w, h);
+ }
+
+//---------------------------------------------------------
+// setOrientation
+//---------------------------------------------------------
+
+void Slider::setOrientation(Qt::Orientation o)
+ {
+ d_orient = o;
+ ScaleDraw::OrientationX so = ScaleDraw::Bottom;
+ switch(d_orient) {
+ case Qt::Vertical:
+ if (d_scalePos == Right)
+ so = ScaleDraw::Right;
+ else
+ so = ScaleDraw::Left;
+ break;
+ case Qt::Horizontal:
+ if (d_scalePos == Bottom)
+ so = ScaleDraw::Bottom;
+ else
+ so = ScaleDraw::Top;
+ break;
+ }
+
+ d_scale.setGeometry(0, 0, 40, so);
+ if (d_orient == Qt::Vertical)
+ setMinimumSize(10,20);
+ else
+ setMinimumSize(20,10);
+ QRect r = geometry();
+ setGeometry(r.x(), r.y(), r.height(), r.width());
+ update();
+ }
+
+Qt::Orientation Slider::orientation() const
+ {
+ return d_orient;
+ }
+
+double Slider::lineStep() const
+ {
+ return 1.0;
+ }
+
+double Slider::pageStep() const
+ {
+ return 1.0;
+ }
+
+void Slider::setLineStep(double)
+ {
+ }
+
+void Slider::setPageStep(double)
+ {
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/slider.h b/attic/muse2-oom/muse2/muse/widgets/slider.h
new file mode 100644
index 00000000..4addc5f4
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/slider.h
@@ -0,0 +1,96 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: slider.h,v 1.3.2.2 2008/01/19 13:33:47 wschweer Exp $
+//
+// Copyright (C) 1997 Josef Wilgen
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2,
+// as published by the Free Software Foundation.
+//
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SLIDER_H__
+#define __SLIDER_H__
+
+#include "sclif.h"
+#include "sliderbase.h"
+#include "scldraw.h"
+#include <QPixmap>
+
+//---------------------------------------------------------
+// Slider
+//---------------------------------------------------------
+
+class Slider : public SliderBase, public ScaleIf
+ {
+ Q_OBJECT
+
+ public:
+ enum ScalePos { None, Left, Right, Top, Bottom };
+ enum { BgTrough = 0x1, BgSlot = 0x2 };
+
+ private:
+ Q_PROPERTY( double lineStep READ lineStep WRITE setLineStep )
+ Q_PROPERTY( double pageStep READ pageStep WRITE setPageStep )
+ Q_PROPERTY( Qt::Orientation orientation READ orientation WRITE setOrientation )
+
+ QRect d_sliderRect;
+
+ int d_thumbLength;
+ int d_thumbHalf;
+ int d_thumbWidth;
+ int d_borderWidth;
+ int d_bwTrough;
+ int d_scaleDist;
+ int d_xMargin;
+ int d_yMargin;
+
+ int d_resized;
+ bool d_autoResize;
+ double d_scaleStep;
+
+ Qt::Orientation d_orient;
+ ScalePos d_scalePos;
+ int d_bgStyle;
+ int markerPos;
+
+ void drawHsBgSlot(QPainter *, const QRect&, const QRect&,const QBrush&);
+ void drawVsBgSlot(QPainter *, const QRect&, const QRect&,const QBrush&);
+
+ protected:
+ virtual void drawSlider (QPainter *p, const QRect &r);
+ double getValue(const QPoint &p);
+ void getScrollMode( QPoint &p, const Qt::MouseButton &button, int &scrollMode, int &direction);
+ void resizeEvent(QResizeEvent *e);
+ void paintEvent (QPaintEvent *e);
+ void valueChange();
+ void rangeChange();
+ void scaleChange();
+ void fontChange(const QFont &oldFont);
+
+ public:
+ Slider(QWidget *parent, const char *name = 0,
+ Qt::Orientation orient = Qt::Vertical,
+ ScalePos scalePos = None,
+ int bgStyle = BgTrough);
+
+ ~Slider();
+ void setThumbLength(int l);
+ void setThumbWidth(int w);
+
+ void setOrientation(Qt::Orientation o);
+ Qt::Orientation orientation() const;
+
+ double lineStep() const;
+ double pageStep() const;
+
+ void setLineStep(double);
+ void setPageStep(double);
+
+ void setBorderWidth(int bw);
+ void setMargins(int x, int y);
+ QSize sizeHint(); // const;
+ };
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/sliderbase.cpp b/attic/muse2-oom/muse2/muse/widgets/sliderbase.cpp
new file mode 100644
index 00000000..320e1bc3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/sliderbase.cpp
@@ -0,0 +1,726 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: sliderbase.cpp,v 1.4.2.4 2007/01/27 14:52:43 spamatica Exp $
+
+// Copyright (C) 1997 Josef Wilgen
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2,
+// as published by the Free Software Foundation.
+//
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <cmath>
+#include "sliderbase.h"
+#include "mmath.h"
+#include <QWheelEvent>
+#include <QMouseEvent>
+#include <QTimerEvent>
+
+// DESCRIPTION
+// SliderBase is a base class for
+// slider widgets. QwtSliderBase handles the mouse events
+// and updates the slider's value accordingly. Derived classes
+// only have to implement the @QwtSliderBase::getValue@ and
+// @QwtSliderBase::getScrollMode@ members, and should react to a
+// @QwtSliderbase::valueChange@, which normally requires repainting.
+
+//------------------------------------------------------------
+//.F SliderBase::SliderBase
+// Constructor
+//
+//.u Syntax
+//.f SliderBase::SliderBase(QWidget *parent, const char *name)
+//
+//.u Parameters
+//.p QWidget *parent, const char *name
+//
+//------------------------------------------------------------
+
+SliderBase::SliderBase(QWidget *parent, const char *name)
+: QWidget(parent)
+ {
+ setObjectName(name);
+ _id = -1;
+ _cursorHoming = false;
+ _ignoreMouseMove = false;
+ d_tmrID = 0;
+ d_updTime = 150;
+ d_mass = 0.0;
+ d_tracking = true;
+ d_mouseOffset = 0.0;
+ d_scrollMode = ScrNone;
+ setRange(0.0, 1.0, 0.1);
+ }
+
+//------------------------------------------------------------
+//.F SliderBase::~SliderBase
+// Destructor
+//
+//.u Syntax
+//.f SliderBase::~SliderBase()
+//------------------------------------------------------------
+
+SliderBase::~SliderBase()
+ {
+ if (d_tmrID)
+ killTimer(d_tmrID);
+ }
+
+
+//------------------------------------------------------------
+//.F void SliderBase::wheelEvent(QWheelEvent *e)
+// Add wheel event handling
+//
+//.u Syntax
+//.f void SliderBase::wheelEvent(QWheelEvent *e)
+//------------------------------------------------------------
+void SliderBase::wheelEvent(QWheelEvent *e)
+{
+ // Avoid unwanted wheel events from outside the control.
+ // Just in case it grabs focus somehow.
+ // Tested: No go, can't seem to determine where event came from.
+ /*
+ const QPoint gp = mapToGlobal(e->pos());
+ const QRect gr = QRect(mapToGlobal(rect().topLeft()), mapToGlobal(rect().bottomRight()));
+ if(!gr.contains(gp))
+ {
+ e->ignore();
+ return;
+ } */
+
+ e->accept();
+
+ float inc = (maxValue() - minValue()) / 40;
+ if (e->modifiers() == Qt::ShiftModifier)
+ inc = inc / 10;
+
+ if(inc < step())
+ inc = step();
+
+ if(e->delta() > 0)
+ setValue(value()+inc);
+ else
+ setValue(value()-inc);
+
+ emit sliderMoved(value(), _id);
+}
+
+
+//------------------------------------------------------------
+//.F SliderBase::stopMoving
+// Stop updating if automatic scrolling is active
+//
+//.u Syntax
+//.f void SliderBase::stopMoving()
+//------------------------------------------------------------
+
+void SliderBase::stopMoving()
+ {
+ if(d_tmrID) {
+ killTimer(d_tmrID);
+ d_tmrID = 0;
+ }
+ }
+
+//------------------------------------------------------------
+//.F SliderBase::setUpdateTime
+// Specify the update interval for automatic scrolling
+//
+//.u Syntax
+//.f void SliderBase::setUpdateTime(int t)
+//
+//.u Parameters
+//.p int t -- update interval in milliseconds
+//
+//.u See also
+// @SliderBase::getScrollMode@
+//------------------------------------------------------------
+
+void SliderBase::setUpdateTime(int t)
+ {
+ if (t < 50)
+ t = 50;
+ d_updTime = t;
+ }
+
+//------------------------------------------------------------
+//.F SliderBase::mousePressEvent
+// Mouse press event handler
+//
+//.u Syntax
+//.f void SliderBase::mousePressEvent(QMouseEvent *e)
+//
+//.u Parameters
+//.p QMouseEvent *e -- Qt Mouse press event
+//------------------------------------------------------------
+
+void SliderBase::mousePressEvent(QMouseEvent *e)
+ {
+ QPoint p = e->pos();
+ const Qt::MouseButton button = e->button();
+ d_timerTick = 0;
+
+ getScrollMode(p, button, d_scrollMode, d_direction);
+ stopMoving();
+
+ switch(d_scrollMode) {
+ case ScrPage:
+ case ScrTimer:
+ d_mouseOffset = 0;
+ DoubleRange::incPages(d_direction);
+ emit sliderMoved(value(), _id);
+ d_tmrID = startTimer(qwtMax(250, 2 * d_updTime));
+ break;
+
+ case ScrMouse:
+ d_speed = 0;
+ if(button == Qt::RightButton)
+ {
+ emit sliderRightClicked(e->globalPos(), _id);
+ break;
+ }
+ d_time.start();
+ if(_cursorHoming && button == Qt::LeftButton)
+ {
+ _ignoreMouseMove = true;
+ d_mouseOffset = 0.0;
+ }
+ else
+ d_mouseOffset = getValue(p) - value();
+
+ emit sliderPressed(_id);
+ break;
+
+ default:
+ d_mouseOffset = 0;
+ d_direction = 0;
+ break;
+ }
+ }
+
+
+//------------------------------------------------------------
+//.-
+//.F SliderBase::buttonRelease
+// Emit a valueChanged() signal if necessary
+//
+//.u Syntax
+//.f void SliderBase::buttonReleased()
+//
+//------------------------------------------------------------
+void SliderBase::buttonReleased()
+{
+ if ((!d_tracking) || (value() != prevValue()))
+ emit valueChanged(value(), _id);
+}
+
+
+//------------------------------------------------------------
+//
+//.F SliderBase::mouseReleaseEvent
+// Mouse Release Event handler
+//
+//.u Syntax
+//.f void SliderBase::mouseReleaseEvent(QMouseEvent *e)
+//
+//.u Parameters
+//.p QMouseEvent *e -- Qt Mouse Event
+//
+//------------------------------------------------------------
+void SliderBase::mouseReleaseEvent(QMouseEvent *e)
+{
+ int ms = 0;
+ /*double inc = step(); */ // prevent compiler warning: unused variable
+ _ignoreMouseMove = false;
+ const Qt::MouseButton button = e->button();
+
+ switch(d_scrollMode)
+ {
+
+ case ScrMouse:
+
+ if(button == Qt::RightButton)
+ {
+ d_scrollMode = ScrNone;
+ break;
+ }
+ if(_cursorHoming && button == Qt::LeftButton)
+ d_scrollMode = ScrNone;
+ else
+ {
+ setPosition(e->pos());
+ d_direction = 0;
+ d_mouseOffset = 0;
+ if (d_mass > 0.0)
+ {
+ ms = d_time.elapsed();
+ if ((fabs(d_speed) > 0.0) && (ms < 50))
+ d_tmrID = startTimer(d_updTime);
+ }
+ else
+ {
+ d_scrollMode = ScrNone;
+ buttonReleased();
+ }
+ }
+ emit sliderReleased(_id);
+
+ break;
+
+ case ScrDirect:
+
+ setPosition(e->pos());
+ d_direction = 0;
+ d_mouseOffset = 0;
+ d_scrollMode = ScrNone;
+ buttonReleased();
+ break;
+
+ case ScrPage:
+ stopMoving();
+ d_timerTick = 0;
+ buttonReleased();
+ d_scrollMode = ScrNone;
+ break;
+
+ case ScrTimer:
+ stopMoving();
+ d_timerTick = 0;
+ buttonReleased();
+ d_scrollMode = ScrNone;
+ break;
+
+ default:
+ d_scrollMode = ScrNone;
+ buttonReleased();
+ }
+}
+
+
+//------------------------------------------------------------
+//
+//.F SliderBase::setPosition
+// Move the slider to a specified point, adjust the value
+// and emit signals if necessary
+//
+//.u Syntax
+//.f void SliderBase::setPosition(const QPoint &p)
+//
+//.u Parameters
+//.p const QPoint &p
+//
+//------------------------------------------------------------
+void SliderBase::setPosition(const QPoint &p)
+{
+ DoubleRange::fitValue(getValue(p) - d_mouseOffset);
+}
+
+
+//------------------------------------------------------------
+//
+//.F SliderBase::setTracking
+//
+// Enables or disables tracking.
+//
+//.u Syntax
+//.f void SliderBase::setTracking(bool enable)
+//
+//.u Parameters
+//.p bool enable -- enable (TRUE) or disable (FALSE) tracking
+//
+//.u Description
+//
+// If tracking is enabled, the slider emits a
+// valueChanged() signal whenever its value
+// changes (the default behaviour). If tracking
+// is disabled, the value changed() signal will only
+// be emitted if
+//.i -- the user releases the mouse
+// button and the value has changed or
+// -- at the end of automatic scrolling.
+//.P
+// Tracking is enabled by default.
+//------------------------------------------------------------
+void SliderBase::setTracking(bool enable)
+{
+ d_tracking = enable;
+}
+
+//------------------------------------------------------------
+//.-
+//.F SliderBase::mouseMoveEvent
+// Mouse Move Event handler
+//
+//.u Syntax
+//.f void SliderBase::mouseMoveEvent(QMouseEvent *e)
+//
+//.u Parameters
+//.p QMouseEvent *e -- Qt Mouse Move Event
+//
+//------------------------------------------------------------
+void SliderBase::mouseMoveEvent(QMouseEvent *e)
+{
+ if(_ignoreMouseMove)
+ {
+ _ignoreMouseMove = false;
+ return;
+ }
+
+ double ms = 0.0;
+ if (d_scrollMode == ScrMouse )
+ {
+ setPosition(e->pos());
+ if (d_mass > 0.0)
+ {
+ ms = double(d_time.elapsed());
+ if (ms < 1.0) ms = 1.0;
+ d_speed = (exactValue() - exactPrevValue()) / ms;
+ d_time.start();
+ }
+ if (value() != prevValue())
+ emit sliderMoved(value(), _id);
+ }
+
+}
+
+
+
+//------------------------------------------------------------
+//
+//.F SliderBase::timerEvent
+// Timer event handler
+//
+//.u Syntax
+//.f void SliderBase::timerEvent(QTimerEvent *e)
+//
+//.u Parameters
+//.p QTimerEvent *e -- Qt timer event
+//
+//------------------------------------------------------------
+
+void SliderBase::timerEvent(QTimerEvent*)
+{
+ double newval;
+ double inc = step();
+
+ switch (d_scrollMode)
+ {
+ case ScrMouse:
+ if (d_mass > 0.0)
+ {
+ d_speed *= exp( - double(d_updTime) * 0.001 / d_mass );
+ newval = exactValue() + d_speed * double(d_updTime);
+ DoubleRange::fitValue(newval);
+ // stop if d_speed < one step per second
+ if (fabs(d_speed) < 0.001 * fabs(step()))
+ {
+ d_speed = 0;
+ stopMoving();
+ buttonReleased();
+ }
+
+ }
+ else
+ stopMoving();
+
+ break;
+
+ case ScrPage:
+ DoubleRange::incPages(d_direction);
+
+ if (value() != prevValue())
+ emit sliderMoved(value(), _id);
+
+ if (!d_timerTick)
+ {
+ killTimer(d_tmrID);
+ d_tmrID = startTimer(d_updTime);
+ }
+ break;
+ case ScrTimer:
+ DoubleRange::fitValue(value() + double(d_direction) * inc);
+
+ if (value() != prevValue())
+ emit sliderMoved(value(), _id);
+
+ if (!d_timerTick)
+ {
+ killTimer(d_tmrID);
+ d_tmrID = startTimer(d_updTime);
+ }
+ break;
+ default:
+ stopMoving();
+ break;
+ }
+
+ d_timerTick = 1;
+}
+
+
+//------------------------------------------------------------
+//
+//.F SliderBase::valueChange
+// Notify change of value
+//
+//.u Syntax
+//.f void SliderBase::valueChange()
+//
+//.u Parameters
+//.p double x -- new value
+//
+//.u Description
+// This function can be reimplemented by derived classes
+// in order to keep track of changes, i.e. repaint the widget.
+// The default implementation emits a valueChanged() signal
+// if tracking is enabled.
+//
+//------------------------------------------------------------
+void SliderBase::valueChange()
+{
+ if (d_tracking)
+ emit valueChanged(value(), _id);
+}
+
+//------------------------------------------------------------
+//
+//.F SliderBase::setMass
+// Set the slider's mass for flywheel effect.
+//
+//.u Syntax
+//.f void SliderBase::setMass(double val)
+//
+//.u Parameters
+//.p double val -- new mass in kg
+//
+//.u Description
+//
+// If the slider's mass is greater then 0, it will continue
+// to move after the mouse button has been released. Its speed
+// decreases with time at a rate depending on the slider's mass.
+// A large mass means that it will continue to move for a
+// long time.
+//
+// Limits: If the mass is smaller than 1g, it is set to zero.
+// The maximal mass is limited to 100kg.
+//
+// Derived widgets may overload this function to make it public.
+//
+//------------------------------------------------------------
+void SliderBase::setMass(double val)
+{
+ if (val < 0.001)
+ d_mass = 0.0;
+ else if (val > 100.0)
+ d_mass = 100.0;
+ else
+ d_mass = val;
+}
+
+
+//------------------------------------------------------------
+//
+//.F SliderBase::setValue
+// Move the slider to a specified value
+//
+//.u Syntax
+//.f void SliderBase::setValue(double val)
+//
+//.u Parameters
+//.p double val -- new value
+//
+//.u Description
+// This function can be used to move the slider to a value
+// which is not an integer multiple of the step size.
+//
+//.u See also
+// @SliderBase::fitValue@
+//------------------------------------------------------------
+
+void SliderBase::setValue(double val)
+ {
+ if (d_scrollMode == ScrMouse)
+ stopMoving();
+ DoubleRange::setValue(val);
+ }
+
+
+//------------------------------------------------------------
+//
+//.F QSlider::fitValue
+// Set the slider's value to the nearest integer multiple
+// of the step size.
+//
+//.u Syntax
+//.f void SliderBase::fitValue(double val)
+//
+//.u See also:
+// @SliderBase::setValue@
+//------------------------------------------------------------
+void SliderBase::fitValue(double val)
+{
+ if (d_scrollMode == ScrMouse) stopMoving();
+ DoubleRange::fitValue(val);
+}
+
+
+//------------------------------------------------------------
+//
+//.F SliderBase::incValue
+// Increment the value by a specified number of steps
+//
+//.u Syntax
+//.f void SliderBase::incValue(int steps)
+//
+//.u Parameters
+//.p int steps -- number of steps
+//
+//------------------------------------------------------------
+void SliderBase::incValue(int steps)
+{
+ if (d_scrollMode == ScrMouse) stopMoving();
+ DoubleRange::incValue(steps);
+}
+
+
+//------------------------------------------------------------
+//
+//.F SliderBase::stepPage
+// Increment the value by a specified number of steps
+//
+//.u Syntax
+//.f void SliderBase::stepPages(int pages)
+//
+//.u Parameters
+//.p int pages -- +/- number of pages
+//
+//.u Description
+// Steps the control as if pager was clicked.
+// Designed to be called from outside (like from a buddy label), rather than from
+// the control itself. Calls DoubleRange::incPages, which normally causes valueChange()
+// (and emits valueChanged), but also emits sliderMoved.
+//
+//------------------------------------------------------------
+void SliderBase::stepPages(int pages)
+{
+ DoubleRange::incPages(pages);
+ emit sliderMoved(value(), _id);
+}
+
+
+//------------------------------------------------------------
+//
+//.F SliderBase::getValue
+// Determine the value corresponding to a specified poind
+//
+//.u Syntax
+//.f void SliderBase::getValue(const QPoint &p)
+//
+//.u Parameters
+//.p const QPoint &p -- point
+//
+//.u Description
+// This is an abstract virtual function which is called when
+// the user presses or releases a mouse button or moves the
+// mouse. It has to be implemented by the derived class.
+//
+//------------------------------------------------------------
+
+//------------------------------------------------------------
+//
+//.F SliderBase::getScrollMode
+// Determine what to do when the user presses a mouse button.
+//
+//.u Syntax
+//.f void SliderBase::getScrollMode(const QPoint &p, int &scrollMode, int &direction)
+//
+//.u Input Parameters
+//.p const QPoint &p -- point where the mouse was pressed
+//
+//.u Output parameters
+// int &scrollMode -- The scrolling mode
+// int &direction -- direction: 1, 0, or -1.
+//
+//.u Description
+// This function is abstract and has to be implemented by derived classes.
+// It is called on a mousePress event. The derived class can determine
+// what should happen next in dependence of the position where the mouse
+// was pressed by returning scrolling mode and direction. SliderBase
+// knows the following modes:
+//.t
+// SliderBase::ScrNone -- Scrolling switched off. Don't change the value.
+// SliderBase::ScrMouse -- Change the value while the user keeps the
+// button pressed and moves the mouse.
+// SliderBase::ScrTimer -- Automatic scrolling. Increment the value
+// in the specified direction as long as
+// the user keeps the button pressed.
+// SliderBase::ScrPage -- Automatic scrolling. Same as ScrTimer, but
+// increment by page size.
+//
+//
+//------------------------------------------------------------
+
+//------------------------------------------------------------
+//
+//.F SliderBase::valueChanged
+// Notify a change of value.
+//
+//.u Syntax
+//.f void SliderBase::valueChanged(double value, int id)
+//
+//.u Parameters
+//.p double value -- new value
+//
+//.u Description
+// In the default setting
+// (tracking enabled), this signal will be emitted every
+// time the value changes ( see setTracking() ).
+//------------------------------------------------------------
+
+//------------------------------------------------------------
+//
+//.F SliderBase::sliderPressed
+// This signal is emitted when the user presses the
+// movable part of the slider (start ScrMouse Mode).
+//
+//.u Syntax
+//.f void SliderBase::sliderPressed()
+//
+//------------------------------------------------------------
+
+//------------------------------------------------------------
+//
+//.F SliderBase::SliderReleased
+// This signal is emitted when the user releases the
+// movable part of the slider.
+//
+//.u Syntax
+//.f void QwtSliderbase::SliderReleased()
+//
+//------------------------------------------------------------
+
+
+//------------------------------------------------------------
+//
+//.F SliderBase::sliderMoved
+// This signal is emitted when the user moves the
+// slider with the mouse.
+//
+//.u Syntax
+//.f void SliderBase::sliderMoved(double value, int _id)
+//
+//.u Parameters
+//.p double value -- new value
+//
+//------------------------------------------------------------
+
+
+
+
+
+
+
+
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/sliderbase.h b/attic/muse2-oom/muse2/muse/widgets/sliderbase.h
new file mode 100644
index 00000000..8bfac9c3
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/sliderbase.h
@@ -0,0 +1,101 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: sliderbase.h,v 1.4.2.3 2006/11/14 06:28:37 terminator356 Exp $
+
+// Copyright (C) 1997 Josef Wilgen
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License, version 2,
+// as published by the Free Software Foundation.
+//
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SLIDERBASE_H__
+#define __SLIDERBASE_H__
+
+#include "drange.h"
+
+#include <QTime>
+#include <QWidget>
+
+//---------------------------------------------------------
+// SliderBase
+//---------------------------------------------------------
+
+class SliderBase : public QWidget, public DoubleRange
+ {
+ Q_OBJECT
+ Q_PROPERTY( int id READ id WRITE setId )
+ Q_PROPERTY( double minValue READ minValue WRITE setMinValue )
+ Q_PROPERTY( double maxValue READ maxValue WRITE setMaxValue )
+ Q_PROPERTY( double value READ value WRITE setValue )
+
+ int _id;
+ int d_tmrID;
+ int d_updTime;
+ int d_timerTick;
+ QTime d_time;
+ double d_speed;
+ double d_mass;
+ bool _cursorHoming;
+ bool _ignoreMouseMove;
+
+ void buttonReleased();
+
+ protected:
+ int d_scrollMode;
+ double d_mouseOffset;
+ int d_direction;
+ int d_tracking;
+
+ virtual void setMass(double val);
+ void setPosition(const QPoint &p);
+ virtual void valueChange();
+ virtual double mass() const { return d_mass; }
+
+ void wheelEvent(QWheelEvent *e);
+ void timerEvent(QTimerEvent *e);
+ void mousePressEvent(QMouseEvent *e);
+ void mouseReleaseEvent(QMouseEvent *e);
+ void mouseMoveEvent(QMouseEvent *e);
+ virtual double getValue(const QPoint & p) = 0;
+ virtual void getScrollMode( QPoint &p, const Qt::MouseButton &button,
+ int &scrollMode, int &direction) = 0;
+
+ public slots:
+ void setValue(double val);
+ void fitValue(double val);
+ void incValue(int steps);
+
+ signals:
+ void valueChanged(double value, int id);
+ void sliderPressed(int id);
+ void sliderReleased(int id);
+ void sliderMoved(double value, int id);
+ void sliderRightClicked(const QPoint &p, int id);
+
+ public:
+ enum { ScrNone, ScrMouse, ScrTimer, ScrDirect, ScrPage };
+
+ SliderBase( QWidget *parent = 0, const char *name = 0 );
+ ~SliderBase();
+
+ bool cursorHoming() const { return _cursorHoming; }
+ void setCursorHoming(bool b) { _cursorHoming = b; }
+ void setUpdateTime(int t);
+ // void incValue(double nSteps);
+ void stopMoving();
+ void setTracking(bool enable);
+
+ double value() const { return DoubleRange::value(); }
+ void stepPages(int pages);
+ double minValue() const { return DoubleRange::minValue(); }
+ double maxValue() const { return DoubleRange::maxValue(); }
+ void setMinValue(double v) { DoubleRange::setRange(v, maxValue(), 0.0, 1); }
+ void setMaxValue(double v) { DoubleRange::setRange(minValue(), v, 0.0, 1); }
+ int id() const { return _id; }
+ void setId(int i) { _id = i; }
+ };
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/songinfo.h b/attic/muse2-oom/muse2/muse/widgets/songinfo.h
new file mode 100644
index 00000000..d566e00a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/songinfo.h
@@ -0,0 +1,37 @@
+//=============================================================================
+// MusE
+// Linux Music Editor
+// $Id: songinfo.h,v 1.0.0.0 2010/11/17 01:01:01 ogetbilo Exp $
+//
+// Copyright (C) 1999-2010 by Werner Schweer and others
+//
+// This program is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License version 2.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+//=============================================================================
+
+#include "ui_songinfo.h"
+
+class QDialog;
+
+
+//---------------------------------------------------------
+// SongInfoWidget
+// Wrapper around Ui::SongInfo
+//---------------------------------------------------------
+
+class SongInfoWidget : public QDialog, public Ui::SongInfo
+{
+ Q_OBJECT
+
+ public:
+ SongInfoWidget(QDialog *parent = 0) : QDialog(parent) { setupUi(this); }
+};
diff --git a/attic/muse2-oom/muse2/muse/widgets/songinfo.ui b/attic/muse2-oom/muse2/muse/widgets/songinfo.ui
new file mode 100644
index 00000000..0944ce93
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/songinfo.ui
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SongInfo</class>
+ <widget class="QDialog" name="SongInfo">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>403</width>
+ <height>274</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>Song Information</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <item>
+ <layout class="QVBoxLayout">
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QTextEdit" name="songInfoText"/>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <item>
+ <spacer name="spacer1">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>311</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonCancel">
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+C</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonOk">
+ <property name="text">
+ <string>&amp;Ok</string>
+ </property>
+ <property name="shortcut">
+ <string>Alt+O</string>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>SongInfo</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>SongInfo</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/spinbox.cpp b/attic/muse2-oom/muse2/muse/widgets/spinbox.cpp
new file mode 100644
index 00000000..ee585da7
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/spinbox.cpp
@@ -0,0 +1,84 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: spinbox.cpp,v 1.1.2.3 2009/07/09 18:27:11 terminator356 Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QKeyEvent>
+#include <QEvent>
+#include "spinbox.h"
+
+//---------------------------------------------------------
+// SpinBox
+//---------------------------------------------------------
+
+SpinBox::SpinBox(QWidget* parent)
+ : QSpinBox(parent)
+{
+ _clearFocus = true;
+}
+
+SpinBox::SpinBox(int minValue, int maxValue, int step, QWidget* parent)
+ : QSpinBox(parent)
+{
+ setRange(minValue, maxValue);
+ setSingleStep(step);
+ _clearFocus = true;
+}
+
+bool SpinBox::eventFilter(QObject* o, QEvent* ev)
+{
+ // if (o != (QObject*)editor()) ddskrjo can't find editor()
+ // return QSpinBox::eventFilter(o,ev);
+
+ bool retval = FALSE;
+ if(ev->type() == QEvent::KeyPress)
+ {
+ QKeyEvent* k = (QKeyEvent*)ev;
+ if(k->key() == Qt::Key_Up || k->key() == Qt::Key_Down)
+ {
+ // stepUp/stepDown will be called. Set this now.
+ _clearFocus = false;
+ }
+ else if (k->key() == Qt::Key_Enter || k->key() == Qt::Key_Return)
+ {
+ // With this line, two enter presses after an edit will clear focus.
+ // Without, just one enter press clears the focus.
+ //if(!editor()->isModified())
+ {
+ clearFocus();
+ return TRUE;
+ }
+ }
+ }
+ else
+ if(ev->type() == QEvent::MouseButtonDblClick)
+ {
+ emit doubleClicked();
+ return TRUE;
+ }
+
+ retval = QSpinBox::eventFilter(o, ev);
+
+ return retval;
+}
+
+void SpinBox::stepUp()
+{
+ QSpinBox::stepUp();
+ if(_clearFocus)
+ clearFocus();
+ else
+ _clearFocus = true;
+}
+
+void SpinBox::stepDown()
+{
+ QSpinBox::stepDown();
+ if(_clearFocus)
+ clearFocus();
+ else
+ _clearFocus = true;
+}
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/spinbox.h b/attic/muse2-oom/muse2/muse/widgets/spinbox.h
new file mode 100644
index 00000000..43ff85be
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/spinbox.h
@@ -0,0 +1,43 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: spinbox.h,v 1.1.2.2 2009/02/02 21:38:01 terminator356 Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+// SpinBox:
+// Click up/down, or mousewheel, or hit enter with un-modified text (which means enter TWICE for modified text),
+// and the control will give up focus, thereby allowing you to use global shortcut keys afterwards.
+// Up/down keys still keep the focus.
+#ifndef __SPINBOX_H__
+#define __SPINBOX_H__
+
+#include <QSpinBox>
+#include <QEvent>
+
+//---------------------------------------------------------
+// SpinBox
+//---------------------------------------------------------
+
+class SpinBox : public QSpinBox {
+ Q_OBJECT
+
+ bool _clearFocus;
+
+ protected:
+ bool eventFilter(QObject* obj, QEvent* ev);
+
+ public slots:
+ virtual void stepUp();
+ virtual void stepDown();
+
+ signals:
+ void doubleClicked();
+
+ public:
+ SpinBox(QWidget* parent=0);
+ SpinBox(int minValue, int maxValue, int step = 1, QWidget* parent=0);
+};
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/spinboxFP.cpp b/attic/muse2-oom/muse2/muse/widgets/spinboxFP.cpp
new file mode 100644
index 00000000..2d8f3372
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/spinboxFP.cpp
@@ -0,0 +1,172 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: spinboxFP.cpp,v 1.1.1.1 2003/10/27 18:55:03 wschweer Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <cmath>
+
+//#include <QtGui>
+//#include <QDoubleValidator>
+//#include <QLineEdit>
+
+#include "spinboxFP.h"
+
+//---------------------------------------------------------
+// SpinBoxFP
+//---------------------------------------------------------
+
+SpinBoxFP::SpinBoxFP(QWidget* parent)
+ //: QSpinBox(parent)
+ : QDoubleSpinBox(parent)
+ {
+ //validator = new QDoubleValidator(this);
+ //lineEdit()->setValidator(validator = new QDoubleValidator(this));
+ //validator->setNotation(QDoubleValidator::StandardNotation);
+
+ //_decimals = 0;
+ setDecimals(0);
+
+ connect(this, SIGNAL(valueChanged(double)), SLOT(valueChange(double)));
+ }
+
+SpinBoxFP::SpinBoxFP(int minValue, int maxValue, int step, QWidget* parent)
+//SpinBoxFP::SpinBoxFP(double minValue, double maxValue, double step, QWidget* parent)
+ //: QSpinBox(parent)
+ : QDoubleSpinBox(parent)
+ {
+ //validator = new QDoubleValidator(this);
+ //lineEdit()->setValidator(validator = new QDoubleValidator(this));
+ //validator->setNotation(QDoubleValidator::StandardNotation);
+
+ //_decimals = 0;
+ QDoubleSpinBox::setDecimals(0);
+
+ setRange(minValue, maxValue);
+ setSingleStep(step);
+
+ connect(this, SIGNAL(valueChanged(double)), SLOT(valueChange(double)));
+ }
+
+//---------------------------------------------------------
+// valueChange
+//---------------------------------------------------------
+
+void SpinBoxFP::valueChange(double)
+{
+ double div = exp10(decimals());
+ emit valueChanged(int(value() * div));
+}
+
+//---------------------------------------------------------
+// setValue
+//---------------------------------------------------------
+
+void SpinBoxFP::setValue(int val)
+ {
+ double div = exp10(decimals());
+ QDoubleSpinBox::setValue(double(val) / div );
+ }
+
+//---------------------------------------------------------
+// intValue
+//---------------------------------------------------------
+
+int SpinBoxFP::intValue()
+ {
+ double div = exp10(decimals());
+ return int(value() * div);
+ }
+
+//---------------------------------------------------------
+// setDecimals
+//---------------------------------------------------------
+
+void SpinBoxFP::setDecimals(int val)
+ {
+ //_decimals = val;
+
+ //updateDisplay();
+ //interpretText(); // TODO: Check - is this what we need? Will send out signals?
+ //setValue(value()); // Try this. "setValue() will emit valueChanged() if the new value is different from the old one."
+
+ QDoubleSpinBox::setDecimals(val);
+ double step = 1.0 / exp10(val);
+ setSingleStep(step);
+ }
+
+/*
+//---------------------------------------------------------
+// validate
+//---------------------------------------------------------
+
+QValidator::State SpinBoxFP::validate(QString& input, int& pos) const
+{
+ // Must set these dynamically as settings may have changed.
+ validator->setRange(minimum(), maximum(), _decimals);
+
+ QValidator::State s = validator->validate(input, pos);
+ return s;
+}
+
+//---------------------------------------------------------
+// mapValueToText
+//---------------------------------------------------------
+
+QString SpinBoxFP::textFromValue(int value) const
+ {
+ if (_decimals) {
+ QString s;
+ int div = int(exp10(_decimals));
+// printf("val %d, prec %d, div %d\n", value, _precision, div);
+
+ s.sprintf("%d.%0*d", value/div, _decimals, value%div);
+ //s.sprintf("%0*f", value, _decimals);
+
+ return s;
+ }
+ return QSpinBox::textFromValue(value);
+ }
+
+//---------------------------------------------------------
+// mapTextToValue
+//---------------------------------------------------------
+
+int SpinBoxFP::valueFromText(const QString& text) const
+ {
+ //QString qs = cleanText();
+ if (_decimals) {
+ //const char* s = qs.toLatin1();
+ //const char* s = cleanText().toAscii().data();
+
+ //int a, b;
+ bool ok;
+ double f = text.toDouble(&ok);
+
+ //int n = sscanf(s, "%d.%d", &a, &b);
+ //int n = sscanf(s, "%f", &f);
+
+ //if (n != 2) {
+ //if (n != 1) {
+ if (!ok) {
+
+ // *ok = false;
+ //return 0;
+ // TODO: Check - Hmm, no OK parameter. Why return 0? Let's try:
+ // Keep returning the current value until something valid comes in...
+ return value();
+ }
+
+ //int div = int(exp10(_decimals));
+ double div = int(exp10(_decimals));
+
+ //return a * div + b;
+ return (f * div);
+
+ }
+ return QSpinBox::valueFromText(text);
+ }
+
+*/ \ No newline at end of file
diff --git a/attic/muse2-oom/muse2/muse/widgets/spinboxFP.h b/attic/muse2-oom/muse2/muse/widgets/spinboxFP.h
new file mode 100644
index 00000000..4c0b75db
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/spinboxFP.h
@@ -0,0 +1,53 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: spinboxFP.h,v 1.1.1.1.2.1 2008/05/21 00:28:54 terminator356 Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SPINBOXFP_H__
+#define __SPINBOXFP_H__
+
+//#include <QSpinBox>
+#include <QDoubleSpinBox>
+
+//class QValidator;
+//class QDoubleValidator;
+
+//---------------------------------------------------------
+// SpinBoxFP
+//---------------------------------------------------------
+
+//class SpinBoxFP : public QSpinBox {
+class SpinBoxFP : public QDoubleSpinBox {
+ Q_OBJECT
+ //Q_PROPERTY( int decimals READ decimals WRITE setDecimals )
+
+ //int _decimals;
+ //QDoubleValidator* validator;
+
+ signals:
+ void valueChanged(int);
+
+ private slots:
+ void valueChange(double);
+
+ protected:
+ //virtual QString textFromValue(int) const;
+ //virtual int valueFromText(const QString&) const;
+ //virtual QValidator::State validate(QString&, int&) const;
+
+ public:
+ SpinBoxFP(QWidget* parent=0);
+ SpinBoxFP(int minValue, int maxValue, int step = 1, QWidget* parent=0);
+ //SpinBoxFP(double minValue, double maxValue, double step = 1.0, QWidget* parent=0);
+
+ void setValue(int val);
+ int intValue();
+
+ void setDecimals(int);
+ //int decimals() const { return _decimals; }
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/splitter.cpp b/attic/muse2-oom/muse2/muse/widgets/splitter.cpp
new file mode 100644
index 00000000..96fe2378
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/splitter.cpp
@@ -0,0 +1,79 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: splitter.cpp,v 1.1.1.1 2003/10/27 18:54:59 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "splitter.h"
+#include "xml.h"
+
+#include <QList>
+#include <QStringList>
+
+//---------------------------------------------------------
+// Splitter
+//---------------------------------------------------------
+
+Splitter::Splitter(Qt::Orientation o, QWidget* parent, const char* name)
+ : QSplitter(o, parent)
+ {
+ setObjectName(name);
+ setOpaqueResize(true);
+ }
+
+//---------------------------------------------------------
+// saveConfiguration
+//---------------------------------------------------------
+
+void Splitter::writeStatus(int level, Xml& xml)
+ {
+ QList<int> vl = sizes();
+ //xml.nput(level++, "<%s>", name());
+ xml.nput(level++, "<%s>", Xml::xmlString(objectName()).toLatin1().constData());
+ QList<int>::iterator ivl = vl.begin();
+ for (; ivl != vl.end(); ++ivl) {
+ xml.nput("%d ", *ivl);
+ }
+ //xml.nput("</%s>\n", name());
+ xml.nput("</%s>\n", Xml::xmlString(objectName()).toLatin1().constData());
+ }
+
+//---------------------------------------------------------
+// loadConfiguration
+//---------------------------------------------------------
+
+void Splitter::readStatus(Xml& xml)
+ {
+ QList<int> vl;
+
+ for (;;) {
+ Xml::Token token = xml.parse();
+ const QString& tag = xml.s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::TagStart:
+ xml.unknown("Splitter");
+ break;
+ case Xml::Text:
+ {
+ //QStringList sl = QStringList::split(' ', tag);
+ QStringList sl = tag.split(QString(" "), QString::SkipEmptyParts);
+ for (QStringList::Iterator it = sl.begin(); it != sl.end(); ++it) {
+ int val = (*it).toInt();
+ vl.append(val);
+ }
+ }
+ break;
+ case Xml::TagEnd:
+ if (tag == objectName()) {
+ setSizes(vl);
+ return;
+ }
+ default:
+ break;
+ }
+ }
+ }
diff --git a/attic/muse2-oom/muse2/muse/widgets/splitter.h b/attic/muse2-oom/muse2/muse/widgets/splitter.h
new file mode 100644
index 00000000..98a64087
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/splitter.h
@@ -0,0 +1,29 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: splitter.h,v 1.1.1.1 2003/10/27 18:54:51 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SPLITTER_H__
+#define __SPLITTER_H__
+
+#include <QSplitter>
+
+class Xml;
+
+//---------------------------------------------------------
+// Splitter
+//---------------------------------------------------------
+
+class Splitter : public QSplitter {
+ Q_OBJECT
+
+ public:
+ Splitter(Qt::Orientation o, QWidget* parent, const char* name);
+ void writeStatus(int level, Xml&);
+ void readStatus(Xml&);
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/swidget.cpp b/attic/muse2-oom/muse2/muse/widgets/swidget.cpp
new file mode 100644
index 00000000..79f5b845
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/swidget.cpp
@@ -0,0 +1,20 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: swidget.cpp,v 1.1.1.1 2003/10/27 18:54:27 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "swidget.h"
+
+#include <QResizeEvent>
+
+//---------------------------------------------------------
+// resizeEvent
+//---------------------------------------------------------
+
+void SWidget::resizeEvent(QResizeEvent* ev)
+ {
+ emit heightChanged(ev->size().height());
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/swidget.h b/attic/muse2-oom/muse2/muse/widgets/swidget.h
new file mode 100644
index 00000000..c5f4fd6a
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/swidget.h
@@ -0,0 +1,31 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: swidget.h,v 1.1.1.1 2003/10/27 18:54:49 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __SWIDGET_H__
+#define __SWIDGET_H__
+
+#include <QWidget>
+
+//---------------------------------------------------------
+// SWidget
+// a simple widget which emits a heighChanged signal
+// on received ResizeEventīs
+//---------------------------------------------------------
+
+class SWidget : public QWidget {
+ virtual void resizeEvent(QResizeEvent*);
+ Q_OBJECT
+
+ signals:
+ void heightChanged(int);
+
+ public:
+ SWidget(QWidget* parent) : QWidget(parent) {}
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/synthconfigbase.ui b/attic/muse2-oom/muse2/muse/widgets/synthconfigbase.ui
new file mode 100644
index 00000000..97f0beaa
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/synthconfigbase.ui
@@ -0,0 +1,168 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SynthConfigBase</class>
+ <widget class="QDialog" name="SynthConfigBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>630</width>
+ <height>492</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Synth Configuration</string>
+ </property>
+ <layout class="QGridLayout">
+ <item row="1" column="1">
+ <widget class="QGroupBox" name="GroupBox3">
+ <property name="title">
+ <string>Instances</string>
+ </property>
+ <layout class="QGridLayout">
+ <item row="0" column="0">
+ <widget class="QTreeWidget" name="instanceList">
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Midi Port</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <layout class="QHBoxLayout">
+ <item>
+ <widget class="QPushButton" name="removeInstance">
+ <property name="text">
+ <string>Remove Instance</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="Spacer2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>113</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="0" column="0" colspan="2">
+ <widget class="QGroupBox" name="groupBox10">
+ <property name="title">
+ <string>Midi connections</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <item>
+ <widget class="QTableWidget" name="mdevView">
+ <attribute name="verticalHeaderDefaultSectionSize">
+ <number>18</number>
+ </attribute>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QGroupBox" name="GroupBox2">
+ <property name="title">
+ <string>Soft Synthesizer</string>
+ </property>
+ <layout class="QGridLayout">
+ <item row="1" column="0">
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="addInstance">
+ <property name="text">
+ <string>Add Instance</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="Spacer1">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="0">
+ <widget class="QTreeWidget" name="synthList">
+ <property name="toolTip">
+ <string>list of available software synthesizers</string>
+ </property>
+ <property name="allColumnsShowFocus">
+ <bool>true</bool>
+ </property>
+ <column>
+ <property name="text">
+ <string>File</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Inst</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Name</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Version</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Description</string>
+ </property>
+ </column>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections/>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/tb1.cpp b/attic/muse2-oom/muse2/muse/widgets/tb1.cpp
new file mode 100644
index 00000000..510e15d1
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/tb1.cpp
@@ -0,0 +1,268 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: tb1.cpp,v 1.3.2.2 2007/01/04 00:35:17 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+//#include <assert.h>
+#include <stdio.h>
+#include <values.h>
+
+#include <QHeaderView>
+#include <QTableWidget>
+#include <QToolButton>
+
+#include "config.h"
+#include "lcombo.h"
+#include "tb1.h"
+#include "globals.h"
+#include "poslabel.h"
+#include "pitchlabel.h"
+
+static int rasterTable[] = {
+ //------ 8 4 2
+ 1, 4, 8, 16, 32, 64, 128, 256, 512, 1024,
+ 1, 6, 12, 24, 48, 96, 192, 384, 768, 1536,
+ 1, 9, 18, 36, 72, 144, 288, 576, 1152, 2304
+ };
+
+static const char* rasterStrings[] =
+{
+ QT_TRANSLATE_NOOP("@default", "Off"), "2pp", "5pp", "64T", "32T", "16T", "8T", "4T", "2T", "1T",
+ QT_TRANSLATE_NOOP("@default", "Off"), "3pp", "6pp", "64", "32", "16", "8", "4", "2", "1",
+ QT_TRANSLATE_NOOP("@default", "Off"), "4pp", "7pp", "64.", "32.", "16.", "8.", "4.", "2.", "1."
+};
+
+static int quantTable[] = {
+ 1, 16, 32, 64, 128, 256, 512, 1024,
+ 1, 24, 48, 96, 192, 384, 768, 1536,
+ 1, 36, 72, 144, 288, 576, 1152, 2304
+ };
+
+static const char* quantStrings[] = {
+ QT_TRANSLATE_NOOP("@default", "Off"), "64T", "32T", "16T", "8T", "4T", "2T", "1T",
+ QT_TRANSLATE_NOOP("@default", "Off"), "64", "32", "16", "8", "4", "2", "1",
+ QT_TRANSLATE_NOOP("@default", "Off"), "64.", "32.", "16.", "8.", "4.", "2.", "1."
+ };
+
+//---------------------------------------------------------
+// genToolbar
+// solo time pitch raster quant
+//---------------------------------------------------------
+
+Toolbar1::Toolbar1(QWidget* parent, int r, int q, bool sp)
+ : QToolBar(QString("Quant'n'Snap-tools"), parent)
+ {
+ pitch = 0;
+ showPitch = sp;
+ // ORCAN - FIXME: Check this:
+ //setHorizontalStretchable(false);
+ //setHorizontalPolicy(QSizePolicy::Minimum);
+ //setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Preferred);
+
+ solo = new QToolButton();
+ solo->setText(tr("Solo"));
+ solo->setCheckable(true);
+ addWidget(solo);
+
+ //---------------------------------------------------
+ // Cursor Position
+ //---------------------------------------------------
+
+ QLabel* label = new QLabel(tr("Cursor"));
+ label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
+ label->setIndent(3);
+ //addWidget(label);
+ pos = new PosLabel(0, "pos");
+ pos->setFixedHeight(22);
+ pos->setObjectName("Cursor");
+ addWidget(pos);
+ if (showPitch) {
+ pitch = new PitchLabel(0);
+ //pitch->setEnabled(false);
+ pitch->setFixedHeight(22);
+ pitch->setObjectName("pitchLabel");
+ addWidget(pitch);
+ }
+
+ //---------------------------------------------------
+ // Raster, Quant.
+ //---------------------------------------------------
+
+ raster = new LabelCombo(tr("Snap"), 0);
+ quant = new LabelCombo(tr("Quantize"), 0);
+
+ rlist = new QTableWidget(10, 3);
+ qlist = new QTableWidget(8, 3);
+ rlist->verticalHeader()->setDefaultSectionSize(22);
+ rlist->horizontalHeader()->setDefaultSectionSize(32);
+ rlist->setSelectionMode(QAbstractItemView::SingleSelection);
+ rlist->verticalHeader()->hide();
+ rlist->horizontalHeader()->hide();
+ qlist->verticalHeader()->setDefaultSectionSize(22);
+ qlist->horizontalHeader()->setDefaultSectionSize(32);
+ qlist->setSelectionMode(QAbstractItemView::SingleSelection);
+ qlist->verticalHeader()->hide();
+ qlist->horizontalHeader()->hide();
+
+ rlist->setMinimumWidth(96);
+ qlist->setMinimumWidth(96);
+
+ raster->setView(rlist);
+ quant->setView(qlist);
+
+ for (int j = 0; j < 3; j++)
+ for (int i = 0; i < 10; i++)
+ rlist->setItem(i, j, new QTableWidgetItem(tr(rasterStrings[i + j * 10])));
+ for (int j = 0; j < 3; j++)
+ for (int i = 0; i < 8; i++)
+ qlist->setItem(i, j, new QTableWidgetItem(tr(quantStrings[i + j * 8])));
+
+ setRaster(r);
+ setQuant(q);
+
+ addWidget(raster);
+ addWidget(quant);
+
+ // FIXME: Not working right.
+ raster->setFixedHeight(38);
+ quant->setFixedHeight(38);
+
+ //---------------------------------------------------
+ // To Menu
+ //---------------------------------------------------
+
+ addWidget(new QLabel(tr("To")));
+ QComboBox* toList = new QComboBox;
+ toList->setFixedHeight(22);
+ toList->insertItem(0, tr("All Events"));
+ toList->insertItem(CMD_RANGE_LOOP, tr("Looped Ev."));
+ toList->insertItem(CMD_RANGE_SELECTED, tr("Selected Ev."));
+ toList->insertItem(CMD_RANGE_LOOP | CMD_RANGE_SELECTED, tr("Looped+Sel."));
+ addWidget(toList);
+
+ connect(raster, SIGNAL(activated(int)), SLOT(_rasterChanged(int)));
+ connect(quant, SIGNAL(activated(int)), SLOT(_quantChanged(int)));
+ //connect(rlist, SIGNAL(cellClicked(int,int)), SLOT(_rasterChanged(int, int)));
+ //connect(qlist, SIGNAL(cellClicked(int,int)), SLOT(_quantChanged(int,int)));
+ connect(toList, SIGNAL(activated(int)), SIGNAL(toChanged(int)));
+ connect(solo, SIGNAL(toggled(bool)), SIGNAL(soloChanged(bool)));
+ //pos->setEnabled(false);
+ }
+
+//---------------------------------------------------------
+// rasterChanged
+//---------------------------------------------------------
+
+void Toolbar1::_rasterChanged(int /*i*/)
+//void Toolbar1::_rasterChanged(int r, int c)
+ {
+ emit rasterChanged(rasterTable[rlist->currentRow() + rlist->currentColumn() * 10]);
+ //emit rasterChanged(rasterTable[r + c * 10]);
+ }
+
+//---------------------------------------------------------
+// quantChanged
+//---------------------------------------------------------
+
+void Toolbar1::_quantChanged(int /*i*/)
+//void Toolbar1::_quantChanged(int r, int c)
+ {
+ emit quantChanged(quantTable[qlist->currentRow() + qlist->currentColumn() * 8]);
+ //emit quantChanged(quantTable[r + c * 8]);
+ }
+
+//---------------------------------------------------------
+// setPitch
+//---------------------------------------------------------
+
+void Toolbar1::setPitch(int val)
+ {
+ if (pitch && showPitch) {
+ //pitch->setEnabled(val != -1); //Removed by Andrew there is no need for this as its not a control item
+ pitch->setPitch(val);
+ }
+ }
+
+void Toolbar1::setInt(int val)
+ {
+ if (pitch && showPitch) {
+ //pitch->setEnabled(val != -1); //Removed by Andrew there is no need for this as its not a control item
+ pitch->setInt(val);
+ }
+ }
+
+//---------------------------------------------------------
+// setTime
+//---------------------------------------------------------
+
+void Toolbar1::setTime(unsigned val)
+ {
+ if (!pos->isVisible()) {
+ //printf("NOT visible\n");
+ return;
+ }
+ if (val != MAXINT)
+ pos->setValue(val);
+ //if (val == MAXINT)
+ // pos->setEnabled(false);
+ //else {
+ //pos->setEnabled(true);
+ //pos->setValue(val);
+ //}
+ }
+
+//---------------------------------------------------------
+// setRaster
+//---------------------------------------------------------
+
+void Toolbar1::setRaster(int val)
+ {
+ for (unsigned i = 0; i < sizeof(rasterTable)/sizeof(*rasterTable); i++) {
+ if (val == rasterTable[i]) {
+ raster->setCurrentIndex(i);
+ return;
+ }
+ }
+ printf("setRaster(%d) not defined\n", val);
+ raster->setCurrentIndex(0);
+ }
+
+//---------------------------------------------------------
+// setQuant
+//---------------------------------------------------------
+
+void Toolbar1::setQuant(int val)
+ {
+ for (unsigned i = 0; i < sizeof(quantTable)/sizeof(*quantTable); i++) {
+ if (val == quantTable[i]) {
+ quant->setCurrentIndex(i);
+ return;
+ }
+ }
+ printf("setQuant(%d) not defined\n", val);
+ quant->setCurrentIndex(0);
+ }
+
+//---------------------------------------------------------
+// setSolo
+//---------------------------------------------------------
+
+void Toolbar1::setSolo(bool flag)
+ {
+ solo->blockSignals(true);
+ solo->setChecked(flag);
+ solo->blockSignals(false);
+ }
+
+//---------------------------------------------------------
+// setPitchMode
+//---------------------------------------------------------
+
+void Toolbar1::setPitchMode(bool /*flag*/)
+ {
+ // if(pitch)
+// pitch->setPitchMode(flag);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/tb1.h b/attic/muse2-oom/muse2/muse/widgets/tb1.h
new file mode 100644
index 00000000..fbed13b1
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/tb1.h
@@ -0,0 +1,61 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: tb1.h,v 1.2 2004/01/11 18:55:37 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __TB1_H__
+#define __TB1_H__
+
+#include <QToolBar>
+
+class QToolButton;
+class QTableWidget;
+
+class PosLabel;
+class PitchLabel;
+class Track;
+class LabelCombo;
+
+//---------------------------------------------------------
+// Toolbar1
+//---------------------------------------------------------
+
+class Toolbar1 : public QToolBar {
+ QToolButton* solo;
+ PosLabel* pos;
+ PitchLabel* pitch;
+ LabelCombo* quant;
+ QTableWidget* qlist;
+ LabelCombo* raster;
+ QTableWidget* rlist;
+ bool showPitch;
+ Q_OBJECT
+
+ private slots:
+ void _rasterChanged(int);
+ void _quantChanged(int);
+
+ public slots:
+ void setTime(unsigned);
+ void setPitch(int);
+ void setInt(int);
+ void setRaster(int);
+ void setQuant(int);
+
+ signals:
+ void rasterChanged(int);
+ void quantChanged(int);
+ void soloChanged(bool);
+ void toChanged(int);
+
+ public:
+ //Toolbar1(QMainWindow* parent = 0, int r=96,
+ Toolbar1(QWidget* parent, int r=96,
+ int q=96, bool showPitch=true);
+ void setSolo(bool val);
+ void setPitchMode(bool flag);
+ };
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/tempolabel.cpp b/attic/muse2-oom/muse2/muse/widgets/tempolabel.cpp
new file mode 100644
index 00000000..a26b0b69
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/tempolabel.cpp
@@ -0,0 +1,123 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: tempolabel.cpp,v 1.1.1.1 2003/10/27 18:54:29 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QApplication>
+#include <QStyle>
+
+#include "tempolabel.h"
+
+//---------------------------------------------------------
+// TempoLabel
+//---------------------------------------------------------
+
+TempoLabel::TempoLabel(QWidget* parent, const char* name)
+ : QLabel(parent)
+ {
+ setObjectName(name);
+ setFrameStyle(WinPanel | Sunken);
+ setLineWidth(2);
+ setMidLineWidth(3);
+ _value = 1.0;
+ setValue(0.0);
+ setIndent(3);
+ setMinimumSize(sizeHint());
+ }
+
+//---------------------------------------------------------
+// setVal
+//---------------------------------------------------------
+
+void TempoLabel::setValue(int val)
+ {
+ setValue(double(val/1000.0));
+ }
+
+void TempoLabel::setValue(double val)
+ {
+ if (val == _value)
+ return;
+ _value = val;
+ QString s = QString("%1").arg(val, 3, 'f', 2);
+ setText(s);
+ }
+
+//---------------------------------------------------------
+// sizeHint
+//---------------------------------------------------------
+
+QSize TempoLabel::sizeHint() const
+ {
+ QFontMetrics fm(font());
+ int fw = 4;
+ int h = fm.height() + fw * 2;
+ int w = 6 + fm.width(QString("000.00")) + fw * 2; // 6=indent
+ return QSize(w, h).expandedTo(QApplication::globalStrut());
+ }
+
+//---------------------------------------------------------
+// TempoSpinBox
+//---------------------------------------------------------
+
+TempoEdit::TempoEdit(QWidget* parent)
+ : QDoubleSpinBox(parent)
+ {
+ curVal = -1.0;
+ setSingleStep(1.0);
+ setRange(30.0, 600.0);
+ connect(this, SIGNAL(valueChanged(double)), SLOT(newValue(double)));
+ }
+
+//---------------------------------------------------------
+// sizeHint
+//---------------------------------------------------------
+
+QSize TempoEdit::sizeHint() const
+ {
+ QFontMetrics fm(font());
+ int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth);
+ int h = fm.height() + fw * 2;
+ int w = 2 + fm.width(QString("000.00")) + fw * 4 + 30;
+ return QSize(w, h).expandedTo(QApplication::globalStrut());
+ }
+
+//---------------------------------------------------------
+// tempoChanged
+//---------------------------------------------------------
+
+void TempoEdit::newValue(double val)
+ {
+ if (val != curVal) {
+ curVal = val;
+ emit tempoChanged(curVal);
+ }
+ }
+
+//---------------------------------------------------------
+// setValue
+//---------------------------------------------------------
+
+void TempoEdit::setValue(double val)
+ {
+ if (val != curVal) {
+ curVal = val;
+ blockSignals(true);
+ QDoubleSpinBox::setValue(val);
+ blockSignals(false);
+ }
+ }
+
+
+//---------------------------------------------------------
+// tempo
+//---------------------------------------------------------
+
+//int TempoEdit::tempo() const
+// {
+// return lrint(60000000.0/value());
+// }
+
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/tempolabel.h b/attic/muse2-oom/muse2/muse/widgets/tempolabel.h
new file mode 100644
index 00000000..71aeb4b8
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/tempolabel.h
@@ -0,0 +1,61 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: tempolabel.h,v 1.1.1.1 2003/10/27 18:55:05 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __TEMPOLABEL_H__
+#define __TEMPOLABEL_H__
+
+#include <QLabel>
+#include <QDoubleSpinBox>
+
+//---------------------------------------------------------
+// TempoLabel
+//---------------------------------------------------------
+
+class TempoLabel : public QLabel {
+ double _value;
+
+ Q_OBJECT
+
+ protected:
+ QSize sizeHint() const;
+
+ public slots:
+ void setValue(int);
+ void setValue(double);
+
+ public:
+ TempoLabel(QWidget*, const char* name = 0);
+ };
+
+//---------------------------------------------------------
+// TempoEdit
+//---------------------------------------------------------
+
+class TempoEdit : public QDoubleSpinBox {
+ Q_OBJECT
+
+ double curVal;
+
+ protected:
+ QSize sizeHint() const;
+
+ private slots:
+ void newValue(double);
+
+ public slots:
+ void setValue(double);
+
+ signals:
+ void tempoChanged(double);
+
+ public:
+ TempoEdit(QWidget*);
+ //int tempo() const;
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/tools.cpp b/attic/muse2-oom/muse2/muse/widgets/tools.cpp
new file mode 100644
index 00000000..32f42ad9
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/tools.cpp
@@ -0,0 +1,142 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: tools.cpp,v 1.2 2004/04/28 21:56:13 spamatica Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include "tools.h"
+
+#include <QActionGroup>
+
+#include "icons.h"
+#include "action.h"
+
+const char* infoPointer = QT_TRANSLATE_NOOP("@default", "select Pointer Tool:\n"
+ "with the pointer tool you can:\n"
+ " select parts\n"
+ " move parts\n"
+ " copy parts");
+const char* infoPencil = QT_TRANSLATE_NOOP("@default", "select Pencil Tool:\n"
+ "with the pencil tool you can:\n"
+ " create new parts\n"
+ " modify length of parts");
+const char* infoDel = QT_TRANSLATE_NOOP("@default", "select Delete Tool:\n"
+ "with the delete tool you can delete parts");
+const char* infoCut = QT_TRANSLATE_NOOP("@default", "select Cut Tool:\n"
+ "with the cut tool you can split a part");
+const char* infoGlue = QT_TRANSLATE_NOOP("@default", "select Glue Tool:\n"
+ "with the glue tool you can glue two parts");
+const char* infoScore = QT_TRANSLATE_NOOP("@default", "select Score Tool:\n");
+const char* infoQuant = QT_TRANSLATE_NOOP("@default", "select Quantize Tool:\n"
+ "insert display quantize event");
+const char* infoDraw = QT_TRANSLATE_NOOP("@default", "select Drawing Tool");
+const char* infoMute = QT_TRANSLATE_NOOP("@default", "select Muting Tool:\n"
+ "click on part to mute/unmute");
+
+ToolB toolList[] = {
+ {&pointerIcon, QT_TRANSLATE_NOOP("@default", "pointer"), infoPointer },
+ {&pencilIcon, QT_TRANSLATE_NOOP("@default", "pencil"), infoPencil },
+ {&deleteIcon, QT_TRANSLATE_NOOP("@default", "eraser"), infoDel },
+ {&cutIcon, QT_TRANSLATE_NOOP("@default", "cutter"), infoCut },
+ {&note1Icon, QT_TRANSLATE_NOOP("@default", "score"), infoScore },
+ {&glueIcon, QT_TRANSLATE_NOOP("@default", "glue"), infoGlue },
+ {&quantIcon, QT_TRANSLATE_NOOP("@default", "quantize"), infoQuant },
+ {&drawIcon, QT_TRANSLATE_NOOP("@default", "draw"), infoDraw },
+ {&editmuteIcon, QT_TRANSLATE_NOOP("@default", "mute parts"), infoMute },
+ };
+
+//---------------------------------------------------------
+// EditToolBar
+//---------------------------------------------------------
+
+//EditToolBar::EditToolBar(QMainWindow* parent, int tools, const char*)
+EditToolBar::EditToolBar(QWidget* parent, int tools, const char*)
+ : QToolBar(tr("Edit Tools"), parent)
+ {
+ QActionGroup* action = new QActionGroup(parent); // Parent needed.
+ action->setExclusive(true);
+
+ nactions = 0;
+ for (unsigned i = 0; i < sizeof(toolList)/sizeof(*toolList); ++i) {
+ if ((tools & (1 << i))==0)
+ continue;
+ ++nactions;
+ }
+ actions = new Action*[nactions];
+ bool first = true;
+ int n = 0;
+ for (unsigned i = 0; i < sizeof(toolList)/sizeof(*toolList); ++i) {
+ if ((tools & (1 << i))==0)
+ continue;
+ ToolB* t = &toolList[i];
+
+ Action* a = new Action(action, 1<<i, t->tip, true);
+ actions[n] = a;
+ //a->setIconSet(QIcon(**(t->icon)));
+ a->setIcon(QIcon(**(t->icon)));
+ a->setToolTip(tr(t->tip));
+ a->setWhatsThis(tr(t->ltip));
+ if (first) {
+ a->setChecked(true);
+ first = false;
+ }
+ ++n;
+ }
+ action->setVisible(true);
+ //action->addTo(this);
+ // Note: Does not take ownership.
+ addActions(action->actions());
+
+ connect(action, SIGNAL(selected(QAction*)), SLOT(toolChanged(QAction*)));
+ }
+
+//---------------------------------------------------------
+// toolChanged
+//---------------------------------------------------------
+
+void EditToolBar::toolChanged(QAction* action)
+ {
+ emit toolChanged(((Action*)action)->id());
+ }
+
+//---------------------------------------------------------
+// ~EditToolBar
+//---------------------------------------------------------
+
+EditToolBar::~EditToolBar()
+ {
+ delete actions;
+ }
+
+//---------------------------------------------------------
+// set
+//---------------------------------------------------------
+
+void EditToolBar::set(int id)
+ {
+ for (int i = 0; i < nactions; ++i) {
+ Action* action = actions[i];
+ if (action->id() == id) {
+ action->setChecked(true);
+ toolChanged(action);
+ return;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// curTool
+//---------------------------------------------------------
+
+int EditToolBar::curTool()
+ {
+ for (int i = 0; i < nactions; ++i) {
+ Action* action = actions[i];
+ if (action->isChecked())
+ return action->id();
+ }
+ return -1;
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/tools.h b/attic/muse2-oom/muse2/muse/widgets/tools.h
new file mode 100644
index 00000000..7cc5e62c
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/tools.h
@@ -0,0 +1,58 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: tools.h,v 1.1.1.1 2003/10/27 18:54:49 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __TOOLS_H__
+#define __TOOLS_H__
+
+#include <QToolBar>
+
+class Action;
+
+class QAction;
+class QPixmap;
+class QWidget;
+
+enum Tool { PointerTool=1, PencilTool=2, RubberTool=4, CutTool=8,
+ ScoreTool=16, GlueTool=32, QuantTool=64, DrawTool=128, MuteTool=256};
+
+const int arrangerTools = PointerTool | PencilTool | RubberTool | CutTool | GlueTool | MuteTool;
+
+struct ToolB {
+ QPixmap** icon;
+ const char* tip;
+ const char* ltip;
+ };
+
+extern ToolB toolList[];
+
+//---------------------------------------------------------
+// EditToolBar
+//---------------------------------------------------------
+
+class EditToolBar : public QToolBar {
+ Q_OBJECT
+ Action** actions;
+ int nactions;
+
+ private slots:
+ void toolChanged(QAction* action);
+
+ signals:
+ void toolChanged(int);
+
+ public slots:
+ void set(int id);
+
+ public:
+ //EditToolBar(QMainWindow*, int, const char* name = 0);
+ EditToolBar(QWidget* /*parent*/, int /*tools*/, const char* name = 0); // Needs a parent !
+ ~EditToolBar();
+ int curTool();
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/trackvieweditorbase.ui b/attic/muse2-oom/muse2/muse/widgets/trackvieweditorbase.ui
new file mode 100644
index 00000000..0d04f461
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/trackvieweditorbase.ui
@@ -0,0 +1,282 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <author>Andrew Williams</author>
+ <class>TrackViewEditorBase</class>
+ <widget class="QDialog" name="TrackViewEditorBase">
+ <property name="windowModality">
+ <enum>Qt::NonModal</enum>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>754</width>
+ <height>550</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>1</horstretch>
+ <verstretch>1</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Track View</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <property name="modal">
+ <bool>true</bool>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="spacing">
+ <number>12</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout" name="groupLayout">
+ <item>
+ <widget class="QLabel" name="lblGroup">
+ <property name="minimumSize">
+ <size>
+ <width>60</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>60</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Views:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="cmbViews">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>32</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="nameLayout">
+ <item>
+ <widget class="QLabel" name="lblName">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>60</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>63</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Name:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="txtName">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>16777215</width>
+ <height>32</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="typeLayout">
+ <item>
+ <widget class="QLabel" name="lblType">
+ <property name="minimumSize">
+ <size>
+ <width>60</width>
+ <height>32</height>
+ </size>
+ </property>
+ <property name="maximumSize">
+ <size>
+ <width>60</width>
+ <height>16777215</height>
+ </size>
+ </property>
+ <property name="text">
+ <string>Type:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QComboBox" name="cmbType">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>1</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimumSize">
+ <size>
+ <width>80</width>
+ <height>32</height>
+ </size>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="listLayout">
+ <item>
+ <widget class="QListView" name="listAllTracks">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>1</horstretch>
+ <verstretch>1</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAsNeeded</enum>
+ </property>
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="selectionMode">
+ <enum>QAbstractItemView::ExtendedSelection</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="actionBox">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::No|QDialogButtonBox::Yes</set>
+ </property>
+ <property name="centerButtons">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QListView" name="listSelectedTracks">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Expanding">
+ <horstretch>1</horstretch>
+ <verstretch>1</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAsNeeded</enum>
+ </property>
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="selectionMode">
+ <enum>QAbstractItemView::ExtendedSelection</enum>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="9"/>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>accepted()</signal>
+ <receiver>TrackViewEditorBase</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>248</x>
+ <y>254</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>157</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonBox</sender>
+ <signal>rejected()</signal>
+ <receiver>TrackViewEditorBase</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>316</x>
+ <y>260</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>286</x>
+ <y>274</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+ <designerdata>
+ <property name="gridDeltaX">
+ <number>10</number>
+ </property>
+ <property name="gridDeltaY">
+ <number>10</number>
+ </property>
+ <property name="gridSnapX">
+ <bool>true</bool>
+ </property>
+ <property name="gridSnapY">
+ <bool>true</bool>
+ </property>
+ <property name="gridVisible">
+ <bool>true</bool>
+ </property>
+ </designerdata>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/transformbase.ui b/attic/muse2-oom/muse2/muse/widgets/transformbase.ui
new file mode 100644
index 00000000..578b4a97
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/transformbase.ui
@@ -0,0 +1,1068 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>MidiTransformDialogBase</class>
+ <widget class="QDialog" name="MidiTransformDialogBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>826</width>
+ <height>545</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Midi Transformator</string>
+ </property>
+ <property name="sizeGripEnabled">
+ <bool>true</bool>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="3" column="0" colspan="2">
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QPushButton" name="buttonNew">
+ <property name="text">
+ <string>&amp;New</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonDelete">
+ <property name="text">
+ <string>&amp;Delete</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <spacer name="Horizontal Spacing2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonApply">
+ <property name="text">
+ <string>&amp;Apply</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonOk">
+ <property name="text">
+ <string>&amp;OK</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="buttonCancel">
+ <property name="text">
+ <string>&amp;Cancel</string>
+ </property>
+ <property name="autoDefault">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="0" column="0" rowspan="3">
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="TextLabel1_2">
+ <property name="text">
+ <string>PresetList</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QListWidget" name="presetList">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="MinimumExpanding">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item row="1" column="1">
+ <widget class="QGroupBox" name="GroupBox5">
+ <property name="title">
+ <string>Processing</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="TextLabel5">
+ <property name="text">
+ <string>Event Type</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QComboBox" name="procEventOp">
+ <item>
+ <property name="text">
+ <string>Keep</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Fix</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QComboBox" name="procType">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <item>
+ <property name="text">
+ <string>Note</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Poly Pressure</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Control Change</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Aftertouch</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Pitch Bend</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>NRPN</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>RPN</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="procVal1Op">
+ <item>
+ <property name="text">
+ <string>Keep</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Plus</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Minus</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Multiply</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Divide</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Fix</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Value 2</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Invert</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>ScaleMap</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Flip</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Dyn</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Random</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="TextLabel6">
+ <property name="text">
+ <string>Value 1</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLabel" name="TextLabel7">
+ <property name="text">
+ <string>Value 2</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QLabel" name="TextLabel10_2">
+ <property name="text">
+ <string>Length</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <widget class="QLabel" name="TextLabel12">
+ <property name="text">
+ <string>Position</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QComboBox" name="procVal2Op">
+ <item>
+ <property name="text">
+ <string>Keep</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Plus</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Minus</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Multiply</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Divide</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Fix</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Value 1</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Invert</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Dyn</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Random</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QComboBox" name="procLenOp">
+ <item>
+ <property name="text">
+ <string>Keep</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Plus</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Minus</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Multiply</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Divide</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Fix</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QSpinBox" name="procVal1b">
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QSpinBox" name="procVal2b">
+ <property name="maximum">
+ <number>9999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="SpinBoxFP" name="procVal1a">
+ <property name="maximum" stdset="0">
+ <number>99999999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="4">
+ <widget class="QComboBox" name="procPosOp">
+ <item>
+ <property name="text">
+ <string>Keep</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Plus</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Minus</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Multiply</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Divide</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="SpinBoxFP" name="procVal2a">
+ <property name="maximum" stdset="0">
+ <number>99999999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="SpinBoxFP" name="procLenA">
+ <property name="maximum" stdset="0">
+ <number>99999999</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="4">
+ <widget class="SpinBoxFP" name="procPosA">
+ <property name="maximum" stdset="0">
+ <number>99999999</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QGroupBox" name="GroupBox3">
+ <property name="title">
+ <string>Filter</string>
+ </property>
+ <layout class="QGridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="1" column="0">
+ <widget class="QComboBox" name="selEventOp">
+ <item>
+ <property name="text">
+ <string>All</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Equal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Unequal</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QComboBox" name="selType">
+ <property name="enabled">
+ <bool>false</bool>
+ </property>
+ <item>
+ <property name="text">
+ <string>Note</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Poly Pressure</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Control Change</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Aftertouch</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Pitch Bend</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>NRPN</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>RPN</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="0" column="2">
+ <widget class="QLabel" name="TextLabel3">
+ <property name="text">
+ <string>Value 2</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLabel" name="TextLabel2">
+ <property name="text">
+ <string>Value 1</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="0">
+ <widget class="QLabel" name="TextLabel1">
+ <property name="text">
+ <string>Event Type</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="selVal1Op">
+ <item>
+ <property name="text">
+ <string>Ignore</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Equal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Unequal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Higher</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Lower</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Inside</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Outside</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QLabel" name="TextLabel10">
+ <property name="text">
+ <string>Length</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4">
+ <widget class="QLabel" name="TextLabel11">
+ <property name="text">
+ <string>Bar Range</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="2">
+ <widget class="QComboBox" name="selVal2Op">
+ <item>
+ <property name="text">
+ <string>Ignore</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Equal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Unequal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Higher</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Lower</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Inside</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Outside</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="3">
+ <widget class="QComboBox" name="selLenOp">
+ <item>
+ <property name="text">
+ <string>Ignore</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Equal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Unequal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Higher</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Lower</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Inside</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Outside</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="1" column="4">
+ <widget class="QComboBox" name="selRangeOp">
+ <item>
+ <property name="text">
+ <string>Ignore</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Equal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Unequal</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Higher</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Lower</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Inside</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Outside</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QSpinBox" name="selVal1b">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="3">
+ <widget class="QSpinBox" name="selLenA">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="3">
+ <widget class="QSpinBox" name="selLenB">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="2">
+ <widget class="QSpinBox" name="selVal2a">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="2">
+ <widget class="QSpinBox" name="selVal2b">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QSpinBox" name="selVal1a">
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="4">
+ <widget class="SpinBoxFP" name="selBarB">
+ <property name="decimals" stdset="0">
+ <number>3</number>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="4">
+ <widget class="SpinBoxFP" name="selBarA">
+ <property name="minimum" stdset="0">
+ <number>1000</number>
+ </property>
+ <property name="decimals" stdset="0">
+ <number>3</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QGroupBox" name="GroupBox6_2">
+ <property name="title">
+ <string>Preset</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QLabel" name="TextLabel13_2">
+ <property name="text">
+ <string>Name:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="nameEntry"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="TextLabel14_2">
+ <property name="text">
+ <string>Comment:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QTextEdit" name="commentEntry"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="GroupBox5_2">
+ <property name="title">
+ <string>Range</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QCheckBox" name="processAll">
+ <property name="text">
+ <string>process all events</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="selectedTracks">
+ <property name="text">
+ <string>selected tracks</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QCheckBox" name="insideLoop">
+ <property name="text">
+ <string>inside loop</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="GroupBox7_2">
+ <property name="title">
+ <string>Function</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QComboBox" name="funcOp">
+ <item>
+ <property name="text">
+ <string>Select</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Quantize</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Delete</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Transform</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Insert</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Copy</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>Extract</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="TextLabel9_2">
+ <property name="text">
+ <string>Quantize Value</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="ComboQuant" name="funcQuantVal" native="true"/>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <customwidgets>
+ <customwidget>
+ <class>SpinBoxFP</class>
+ <extends>QDoubleSpinBox</extends>
+ <header>spinboxFP.h</header>
+ </customwidget>
+ <customwidget>
+ <class>ComboQuant</class>
+ <extends>QComboBox</extends>
+ <header>comboQuant.h</header>
+ </customwidget>
+ </customwidgets>
+ <tabstops>
+ <tabstop>selEventOp</tabstop>
+ <tabstop>selType</tabstop>
+ <tabstop>selVal1Op</tabstop>
+ <tabstop>selVal1a</tabstop>
+ <tabstop>selVal1b</tabstop>
+ <tabstop>selVal2Op</tabstop>
+ <tabstop>selVal2a</tabstop>
+ <tabstop>selVal2b</tabstop>
+ <tabstop>selLenOp</tabstop>
+ <tabstop>selLenA</tabstop>
+ <tabstop>selLenB</tabstop>
+ <tabstop>selRangeOp</tabstop>
+ <tabstop>procEventOp</tabstop>
+ <tabstop>procType</tabstop>
+ <tabstop>procVal1Op</tabstop>
+ <tabstop>procVal1b</tabstop>
+ <tabstop>procVal2Op</tabstop>
+ <tabstop>procVal2b</tabstop>
+ <tabstop>procLenOp</tabstop>
+ <tabstop>procPosOp</tabstop>
+ <tabstop>nameEntry</tabstop>
+ <tabstop>commentEntry</tabstop>
+ <tabstop>processAll</tabstop>
+ <tabstop>selectedTracks</tabstop>
+ <tabstop>insideLoop</tabstop>
+ <tabstop>funcOp</tabstop>
+ <tabstop>presetList</tabstop>
+ <tabstop>buttonNew</tabstop>
+ <tabstop>buttonDelete</tabstop>
+ <tabstop>buttonApply</tabstop>
+ <tabstop>buttonOk</tabstop>
+ <tabstop>buttonCancel</tabstop>
+ </tabstops>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>buttonOk</sender>
+ <signal>clicked()</signal>
+ <receiver>MidiTransformDialogBase</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>buttonCancel</sender>
+ <signal>clicked()</signal>
+ <receiver>MidiTransformDialogBase</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/transposebase.ui b/attic/muse2-oom/muse2/muse/widgets/transposebase.ui
new file mode 100644
index 00000000..63ac74a6
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/transposebase.ui
@@ -0,0 +1,228 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>TransposeDialogBase</class>
+ <widget class="QDialog" name="TransposeDialogBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>289</width>
+ <height>340</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Midi Transpose</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QGroupBox" name="GroupBox1">
+ <property name="title">
+ <string>Value</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <widget class="QSpinBox" name="delta">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="minimum">
+ <number>-99</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="TextLabel1">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="MinimumExpanding" vsizetype="Minimum">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string>halftones</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="ButtonBox1">
+ <property name="title">
+ <string>Time</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QRadioButton" name="time_all">
+ <property name="text">
+ <string>all</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="time_selected">
+ <property name="text">
+ <string>between markers</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="ButtonBox2">
+ <property name="title">
+ <string>Parts</string>
+ </property>
+ <layout class="QVBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QRadioButton" name="parts_all">
+ <property name="text">
+ <string>all</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="parts_selected">
+ <property name="windowTitle">
+ <string/>
+ </property>
+ <property name="text">
+ <string>all in selected tracks</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>0</number>
+ </property>
+ <item>
+ <spacer name="Spacer1">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton">
+ <property name="text">
+ <string>OK</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>okButton</sender>
+ <signal>clicked()</signal>
+ <receiver>TransposeDialogBase</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>cancelButton</sender>
+ <signal>clicked()</signal>
+ <receiver>TransposeDialogBase</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/ttoolbar.cpp b/attic/muse2-oom/muse2/muse/widgets/ttoolbar.cpp
new file mode 100644
index 00000000..774cb34d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/ttoolbar.cpp
@@ -0,0 +1,24 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: ttoolbar.cpp,v 1.1.1.1 2003/10/27 18:54:46 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QAction>
+#include "globals.h"
+
+//---------------------------------------------------------
+// syncChanged
+//---------------------------------------------------------
+
+void syncChanged(bool flag)
+ {
+ startAction->setEnabled(!flag);
+ forwardAction->setEnabled(!flag);
+ rewindAction->setEnabled(!flag);
+ stopAction->setEnabled(!flag);
+ playAction->setEnabled(!flag);
+ }
+
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/ttoolbar.h b/attic/muse2-oom/muse2/muse/widgets/ttoolbar.h
new file mode 100644
index 00000000..b7d34b2d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/ttoolbar.h
@@ -0,0 +1,9 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: ttoolbar.h,v 1.1.1.1 2003/10/27 18:54:52 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+extern void syncChanged(bool flag);
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/ttoolbutton.cpp b/attic/muse2-oom/muse2/muse/widgets/ttoolbutton.cpp
new file mode 100644
index 00000000..324b5fca
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/ttoolbutton.cpp
@@ -0,0 +1,29 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: ttoolbutton.cpp,v 1.1 2004/02/21 16:53:50 wschweer Exp $
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QPainter>
+#include <QStyle>
+
+#include "ttoolbutton.h"
+#include "gconfig.h"
+#include "icons.h"
+
+//---------------------------------------------------------
+// drawButton
+//---------------------------------------------------------
+
+void TransparentToolButton::drawButton(QPainter* p)
+ {
+ int w = width();
+ int h = height();
+ QIcon::Mode mode = isEnabled() ? QIcon::Normal : QIcon::Disabled;
+ QIcon::State state = isChecked() ? QIcon::On : QIcon::Off;
+ const QPixmap pm(icon().pixmap(style()->pixelMetric(QStyle::PM_SmallIconSize), mode, state));
+ p->drawPixmap(QPoint((w - pm.width())/2, (h - pm.height())/2), pm);
+ }
+
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/ttoolbutton.h b/attic/muse2-oom/muse2/muse/widgets/ttoolbutton.h
new file mode 100644
index 00000000..b4c54401
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/ttoolbutton.h
@@ -0,0 +1,28 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: ttoolbutton.h,v 1.1 2004/02/21 16:53:51 wschweer Exp $
+// (C) Copyright 2004 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __TTOOLBUTTON_H__
+#define __TTOOLBUTTON_H__
+
+#include <QToolButton>
+
+//---------------------------------------------------------
+// TransparentToolButton
+//---------------------------------------------------------
+
+class TransparentToolButton : public QToolButton {
+ Q_OBJECT
+
+ virtual void drawButton(QPainter*);
+
+ public:
+ TransparentToolButton(QWidget* parent, const char* name = 0)
+ : QToolButton(parent) {setObjectName(name);}
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/tvieweditor.cpp b/attic/muse2-oom/muse2/muse/widgets/tvieweditor.cpp
new file mode 100644
index 00000000..583eae57
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/tvieweditor.cpp
@@ -0,0 +1,196 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: $
+//
+// (C) Copyright 2010 Andrew Williams and Christopher Cherrett
+//=========================================================
+
+
+#include <QMessageBox>
+#include <QDialog>
+#include <QStringListModel>
+#include <QPushButton>
+#include <QItemSelectionModel>
+#include <QModelIndexList>
+#include <QModelIndex>
+
+#include <math.h>
+#include <string.h>
+#include "tvieweditor.h"
+#include "song.h"
+#include "globals.h"
+#include "config.h"
+#include "gconfig.h"
+#include "utils.h"
+#include "audio.h"
+#include "midi.h"
+#include "icons.h"
+#include "app.h"
+#include "popupmenu.h"
+#include "track.h"
+#include "trackview.h"
+#include "synth.h"
+
+TrackViewEditor::TrackViewEditor(QWidget* parent, TrackViewList* vl) : QDialog(parent)
+{
+ setupUi(this);
+ _allTracks = song->tracks();
+ _viewList = vl;
+ //MIDI=0, DRUM, WAVE, AUDIO_OUTPUT, AUDIO_INPUT, AUDIO_GROUP,AUDIO_AUX
+ _trackTypes = (QStringList() << "Audio_Out" << "Audio_In" << "Audio_Aux" << "Audio_Group" << "Midi" << "Soft_Synth"); //new QStringList();
+ //Populate trackTypes and pass it to cmbTypes
+ cmbType->addItems(_trackTypes);
+ QStringList stracks;
+ for(ciTrack t = _allTracks->begin(); t != _allTracks->end(); ++t)
+ {
+ _tracks.push_back((*t));
+ switch((*t)->type()) {/*{{{*/
+ case Track::MIDI:
+ case Track::DRUM:
+ _midis.push_back((MidiTrack*)(*t));
+ break;
+ case Track::WAVE:
+ _waves.push_back((WaveTrack*)(*t));
+ break;
+ case Track::AUDIO_OUTPUT:
+ _outputs.push_back((AudioOutput*)(*t));
+ stracks << (*t)->name();
+ break;
+ case Track::AUDIO_GROUP:
+ _groups.push_back((AudioGroup*)(*t));
+ break;
+ case Track::AUDIO_AUX:
+ _auxs.push_back((AudioAux*)(*t));
+ break;
+ case Track::AUDIO_INPUT:
+ _inputs.push_back((AudioInput*)(*t));
+ break;
+ case Track::AUDIO_SOFTSYNTH:
+ SynthI* s = (SynthI*)(*t);
+ _synthIs.push_back(s);
+ break;
+ }/*}}}*/
+ }
+ listAllTracks->setModel(new QStringListModel(stracks));
+ btnAdd = actionBox->button(QDialogButtonBox::Yes);
+ btnAdd->setText(tr("Add Track"));
+ connect(btnAdd, SIGNAL(clicked(bool)), SLOT(btnAddTrack(bool)));
+ btnRemove = actionBox->button(QDialogButtonBox::No);
+ btnRemove->setText(tr("Remove Track"));
+ btnRemove->setFocusPolicy(btnAdd->focusPolicy());
+ connect(btnRemove, SIGNAL(clicked(bool)), SLOT(btnRemoveTrack(bool)));
+
+ connect(cmbViews, SIGNAL(currentIndexChanged(QString&)), SLOT(cmbViewSelected(QString&)));
+ connect(cmbType, SIGNAL(currentIndexChanged(int)), SLOT(cmbTypeSelected(int)));
+}
+
+
+//----------------------------------------------
+// Slots
+//----------------------------------------------
+void TrackViewEditor::cmbViewSelected(QString& sl)
+{
+ //Perform actions to populate list below based on selected view
+}
+
+void TrackViewEditor::cmbTypeSelected(int type)
+{
+ //Perform actions to populate list below based on selected type
+ //We need to repopulate and filter the allTrackList
+ //"Audio_Out" "Audio_In" "Audio_Aux" "Audio_Group" "Midi" "Soft_Synth"
+ QStringList stracks;
+ switch(type) {/*{{{*/
+ case 0:
+ for(ciTrack t = _outputs.begin(); t != _outputs.end(); ++t)
+ {
+ //This should be checked against track in other views
+ stracks << (*t)->name();
+ }
+ case 1:
+ for(ciTrack t = _inputs.begin(); t != _inputs.end(); ++t)
+ {
+ //This should be checked against track in other views
+ stracks << (*t)->name();
+ }
+ break;
+ case 2:
+ for(ciTrack t = _auxs.begin(); t != _auxs.end(); ++t)
+ {
+ //This should be checked against track in other views
+ stracks << (*t)->name();
+ }
+ break;
+ case 3:
+ for(ciTrack t = _groups.begin(); t != _groups.end(); ++t)
+ {
+ //This should be checked against track in other views
+ stracks << (*t)->name();
+ }
+ break;
+ case 4:
+ for(ciTrack t = _midis.begin(); t != _midis.end(); ++t)
+ {
+ //This should be checked against track in other views
+ stracks << (*t)->name();
+ }
+ break;
+ case 5:
+ for(ciTrack t = _synthIs.begin(); t != _synthIs.end(); ++t)
+ {
+ //This should be checked against track in other views
+ stracks << (*t)->name();
+ }
+ break;
+ }/*}}}*/
+ listAllTracks->setModel(new QStringListModel(stracks));
+}
+
+void TrackViewEditor::btnAddTrack(bool state)
+{
+ //Perform actions to add action to right list and remove from left
+ printf("Add button clicked\n");
+ QItemSelectionModel* model = listAllTracks->selectionModel();
+ if(model->hasSelection())
+ {
+ QModelIndexList sel = model->selectedRows(0);
+ QList<QModelIndex>::const_iterator id;
+ for (id = sel.constBegin(); id != sel.constEnd(); ++id)
+ //for(QModelIndex* id = sel.begin(); id != sel.end(); ++id)
+ {
+ //We have to index we will get the row.
+ int row = (*id).row();
+ /*QStringListModel* m = */QAbstractItemModel* m = listAllTracks->model();
+ QVariant v = m->data((*id));
+ QString val = v.toString();
+ Track* trk = song->findTrack(val);
+ if(trk)
+ printf("Adding Track from row: %d\n", row);
+ //printf("Found Track %s at index %d with type %d\n", val, row, trk->type());
+ }
+ }
+}
+
+void TrackViewEditor::btnRemoveTrack(bool state)
+{
+ //Perform action to remove track from the selectedTracks list
+ printf("Remove button clicked\n");
+}
+
+void TrackViewEditor::setSelectedTracks(TrackList* t)
+{
+ _selected = t;
+ //Call methods to update the display
+}
+
+void TrackViewEditor::setTypes(QStringList t)
+{
+ _trackTypes = t;
+ //Call methods to update the display
+}
+
+void TrackViewEditor::setViews(TrackViewList* l)
+{
+ _viewList = l;
+ //Call methods to update the display
+}
diff --git a/attic/muse2-oom/muse2/muse/widgets/tvieweditor.h b/attic/muse2-oom/muse2/muse/widgets/tvieweditor.h
new file mode 100644
index 00000000..e9835fbd
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/tvieweditor.h
@@ -0,0 +1,67 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: $
+//
+// (C) Copyright 2010 Andrew Williams and Christopher Cherrett
+//=========================================================
+
+#ifndef __TRACKVIEWEDITOR_H__
+#define __TRACKVIEWEDITOR_H__
+
+#include "ui_trackvieweditorbase.h"
+#include <QList>
+#include <QObject>
+#include "trackview.h"
+#include "track.h"
+
+class TrackView;
+class Track;
+class QDialog;
+class QPushButton;
+
+class TrackViewEditor : public QDialog, public Ui::TrackViewEditorBase
+{
+ Q_OBJECT
+ TrackList* _allTracks;
+ TrackViewList* _viewList;
+ TrackList* _selected;
+ TrackList _tracks; // tracklist as seen by arranger
+ MidiTrackList _midis;
+ WaveTrackList _waves;
+ InputList _inputs; // audio input ports
+ OutputList _outputs; // audio output ports
+ GroupList _groups; // mixer groups
+ AuxList _auxs; // aux sends
+ SynthIList _synthIs;
+
+ QStringList _trackTypes;
+ QPushButton* btnAdd;
+ QPushButton* btnRemove;
+
+ private slots:
+ void cmbViewSelected(QString&);
+ void cmbTypeSelected(int);
+ void btnAddTrack(bool);
+ void btnRemoveTrack(bool);
+
+ public:
+ TrackViewEditor(QWidget*, TrackViewList* = 0);
+ void setSelectedTracks(TrackList*);
+ TrackList* selectedTracks( ) { return _selected; }
+ void setTypes(QStringList);
+ void setViews(TrackViewList*);
+ QStringList trackTypes(){return _trackTypes;}
+ TrackViewList* views(){return _viewList;}
+
+ TrackList* tracks() { return &_tracks; }
+ MidiTrackList* midis() { return &_midis; }
+ WaveTrackList* waves() { return &_waves; }
+ InputList* inputs() { return &_inputs; }
+ OutputList* outputs() { return &_outputs; }
+ GroupList* groups() { return &_groups; }
+ AuxList* auxs() { return &_auxs; }
+ SynthIList* syntis() { return &_synthIs; }
+};
+
+#endif
diff --git a/attic/muse2-oom/muse2/muse/widgets/utils.cpp b/attic/muse2-oom/muse2/muse/widgets/utils.cpp
new file mode 100644
index 00000000..1bf4ca64
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/utils.cpp
@@ -0,0 +1,356 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: utils.cpp,v 1.1.1.1.2.3 2009/11/14 03:37:48 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <sys/time.h>
+
+#include <QFrame>
+
+#include "utils.h"
+
+//---------------------------------------------------------
+// curTime
+//---------------------------------------------------------
+
+double curTime()
+ {
+ struct timeval t;
+ gettimeofday(&t, 0);
+ return (double)((double)t.tv_sec + (t.tv_usec / 1000000.0));
+ }
+
+//---------------------------------------------------------
+// dump
+// simple debug output
+//---------------------------------------------------------
+
+void dump(const unsigned char* p, int n)
+ {
+ printf("dump %d\n", n);
+ for (int i = 0; i < n; ++i) {
+ printf("%02x ", *p++);
+ if ((i > 0) && (i % 16 == 0) && (i+1 < n))
+ printf("\n");
+ }
+ printf("\n");
+ }
+
+//---------------------------------------------------------
+// num2cols
+//---------------------------------------------------------
+
+int num2cols(int min, int max)
+ {
+ int amin = abs(min);
+ int amax = abs(max);
+ int l = amin > amax ? amin : amax;
+ return int(log10(l)) + 1;
+ }
+
+//---------------------------------------------------------
+// hLine
+//---------------------------------------------------------
+
+QFrame* hLine(QWidget* w)
+ {
+ QFrame* delim = new QFrame(w);
+ delim->setFrameStyle(QFrame::HLine | QFrame::Sunken);
+ return delim;
+ }
+
+//---------------------------------------------------------
+// vLine
+//---------------------------------------------------------
+
+QFrame* vLine(QWidget* w)
+ {
+ QFrame* delim = new QFrame(w);
+ delim->setFrameStyle(QFrame::VLine | QFrame::Sunken);
+ return delim;
+ }
+
+//---------------------------------------------------------
+// bitmap2String
+// 5c -> 1-4 1-6
+//
+// 01011100
+//
+//---------------------------------------------------------
+
+QString bitmap2String(int bm)
+ {
+ QString s;
+//printf("bitmap2string: bm %04x", bm);
+ if (bm == 0xffff)
+ s = "all";
+ else if (bm == 0)
+ s = "none";
+ else {
+ bool range = false;
+ int first = 0;
+ bool needSpace = false;
+ bm &= 0xffff;
+ for (int i = 0; i < 17; ++i) {
+ //for (int i = 0; i < 16; ++i) {
+ if ((1 << i) & bm) {
+ if (!range) {
+ range = true;
+ first = i;
+ }
+ }
+ else {
+ if (range) {
+ if (needSpace)
+ s += " ";
+ QString ns;
+ if (first == i-1)
+ ns.sprintf("%d", first+1);
+ else
+ ns.sprintf("%d-%d", first+1, i);
+ s += ns;
+ needSpace = true;
+ }
+ range = false;
+ }
+ }
+ }
+//printf(" -> <%s>\n", s.toLatin1());
+ return s;
+ }
+
+//---------------------------------------------------------
+// u32bitmap2String
+//---------------------------------------------------------
+// Added by Tim. p3.3.8
+
+QString u32bitmap2String(unsigned int bm)
+ {
+ QString s;
+//printf("bitmap2string: bm %04x", bm);
+ //if (bm == 0xffff)
+ if (bm == 0xffffffff)
+ s = "all";
+ else if (bm == 0)
+ s = "none";
+ else {
+ bool range = false;
+ int first = 0;
+ //unsigned int first = 0;
+ bool needSpace = false;
+ //bm &= 0xffff;
+ //for (int i = 0; i < 17; ++i) {
+ for (int i = 0; i < 33; ++i) {
+ if ((i < 32) && ((1U << i) & bm)) {
+ if (!range) {
+ range = true;
+ first = i;
+ }
+ }
+ else {
+ if (range) {
+ if (needSpace)
+ s += " ";
+ QString ns;
+ if (first == i-1)
+ ns.sprintf("%d", first+1);
+ //ns.sprintf("%u", first+1);
+ else
+ ns.sprintf("%d-%d", first+1, i);
+ //ns.sprintf("%u-%u", first+1, i);
+ s += ns;
+ needSpace = true;
+ }
+ range = false;
+ }
+ }
+ }
+//printf(" -> <%s>\n", s.toLatin1());
+ return s;
+ }
+
+//---------------------------------------------------------
+// string2bitmap
+//---------------------------------------------------------
+
+int string2bitmap(const QString& str)
+ {
+ int val = 0;
+ QString ss = str.simplified();
+ QByteArray ba = ss.toLatin1();
+ const char* s = ba.constData();
+//printf("string2bitmap <%s>\n", s);
+
+ if (s == 0)
+ return 0;
+ if (strcmp(s, "all") == 0)
+ return 0xffff;
+ if (strcmp(s, "none") == 0)
+ return 0;
+// printf("str2bitmap: <%s> ", str.toLatin1);
+ int tval = 0;
+ bool range = false;
+ int sval = 0;
+ while (*s == ' ')
+ ++s;
+ while (*s) {
+ if (*s >= '0' && *s <= '9') {
+ tval *= 10;
+ tval += *s - '0';
+ }
+ else if (*s == ' ' || *s == ',') {
+ if (range) {
+ for (int i = sval-1; i < tval; ++i)
+ val |= (1 << i);
+ range = false;
+ }
+ else {
+ val |= (1 << (tval-1));
+ }
+ tval = 0;
+ }
+ else if (*s == '-') {
+ range = true;
+ sval = tval;
+ tval = 0;
+ }
+ ++s;
+ }
+ if (range && tval) {
+ for (int i = sval-1; i < tval; ++i)
+ val |= (1 << i);
+ }
+ else if (tval) {
+ val |= (1 << (tval-1));
+ }
+ return val & 0xffff;
+ }
+
+//---------------------------------------------------------
+// string2u32bitmap
+//---------------------------------------------------------
+// Added by Tim. p3.3.8
+
+unsigned int string2u32bitmap(const QString& str)
+ {
+ //int val = 0;
+ unsigned int val = 0;
+ QString ss = str.simplified();
+ QByteArray ba = ss.toLatin1();
+ const char* s = ba.constData();
+//printf("string2bitmap <%s>\n", s);
+
+ if (s == 0)
+ return 0;
+ if (strcmp(s, "all") == 0)
+ //return 0xffff;
+ return 0xffffffff;
+ if (strcmp(s, "none") == 0)
+ return 0;
+// printf("str2bitmap: <%s> ", str.toLatin1);
+ int tval = 0;
+ //unsigned int tval = 0;
+ bool range = false;
+ int sval = 0;
+ //unsigned int sval = 0;
+ while (*s == ' ')
+ ++s;
+ while (*s) {
+ if (*s >= '0' && *s <= '9') {
+ tval *= 10;
+ tval += *s - '0';
+ }
+ else if (*s == ' ' || *s == ',') {
+ if (range) {
+ for (int i = sval-1; i < tval; ++i)
+ //for (unsigned int i = sval-1; i < tval; ++i)
+ val |= (1U << i);
+ range = false;
+ }
+ else {
+ val |= (1U << (tval-1));
+ }
+ tval = 0;
+ }
+ else if (*s == '-') {
+ range = true;
+ sval = tval;
+ tval = 0;
+ }
+ ++s;
+ }
+ if (range && tval) {
+ for (int i = sval-1; i < tval; ++i)
+ //for (unsigned int i = sval-1; i < tval; ++i)
+ val |= (1U << i);
+ }
+ else if (tval) {
+ val |= (1U << (tval-1));
+ }
+ //return val & 0xffff;
+ return val;
+ }
+
+//---------------------------------------------------------
+// autoAdjustFontSize
+// w: Widget to auto adjust font size
+// s: String to fit
+// ignoreWidth: Set if dealing with a vertically constrained widget - one which is free to resize horizontally.
+// ignoreHeight: Set if dealing with a horizontally constrained widget - one which is free to resize vertically.
+//---------------------------------------------------------
+// Added by Tim. p3.3.8
+
+bool autoAdjustFontSize(QFrame* w, const QString& s, bool ignoreWidth, bool ignoreHeight, int max, int min)
+{
+ // In case the max or min was obtained from QFont::pointSize() which returns -1
+ // if the font is a pixel font, or if min is greater than max...
+ if(!w || (min < 0) || (max < 0) || (min > max))
+ return false;
+
+ // Limit the minimum and maximum sizes to something at least readable.
+ if(max < 4)
+ max = 4;
+ if(min < 4)
+ min = 4;
+
+ QRect cr = w->contentsRect();
+ QRect r;
+ QFont fnt = w->font();
+ // An extra amount just to be sure - I found it was still breaking up two words which would fit on one line.
+ int extra = 4;
+ // Allow at least one loop. min can be equal to max.
+ for(int i = max; i >= min; --i)
+ {
+ fnt.setPointSize(i);
+ QFontMetrics fm(fnt);
+ r = fm.boundingRect(s);
+ // Would the text fit within the widget?
+ if((ignoreWidth || (r.width() <= (cr.width() - extra))) && (ignoreHeight || (r.height() <= cr.height())))
+ break;
+ }
+ // Added by Tim. p3.3.9
+ //printf("autoAdjustFontSize: ptsz:%d widget:%s before setFont x:%d y:%d w:%d h:%d\n", fnt.pointSize(), w->name(), w->x(), w->y(), w->width(), w->height());
+
+ // Here we will always have a font ranging from min to max point size.
+ w->setFont(fnt);
+ // Added by Tim. p3.3.9
+ //printf("autoAdjustFontSize: ptsz:%d widget:%s x:%d y:%d w:%d h:%d frame w:%d rw:%d rh:%d\n", fnt.pointSize(), w->name(), w->x(), w->y(), w->width(), w->height(), w->frameWidth(), cr.width(), cr.height());
+
+ // Force minimum height. Use the expected height for the highest given point size.
+ // This way the mixer strips aren't all different label heights, but can be larger if necessary.
+ // Only if ignoreHeight is set (therefore the height is adjustable).
+ if(ignoreHeight)
+ {
+ fnt.setPointSize(max);
+ QFontMetrics fm(fnt);
+ // Set the label's minimum height equal to the height of the font.
+ w->setMinimumHeight(fm.height() + 2 * w->frameWidth());
+ }
+
+ return true;
+}
diff --git a/attic/muse2-oom/muse2/muse/widgets/utils.h b/attic/muse2-oom/muse2/muse/widgets/utils.h
new file mode 100644
index 00000000..654a7834
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/utils.h
@@ -0,0 +1,29 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: utils.h,v 1.1.1.1.2.3 2009/11/14 03:37:48 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __UTILS_H__
+#define __UTILS_H__
+
+class QFrame;
+class QString;
+class QWidget;
+
+
+extern QString bitmap2String(int bm);
+extern int string2bitmap(const QString& str);
+extern QString u32bitmap2String(unsigned int bm);
+extern unsigned int string2u32bitmap(const QString& str);
+extern bool autoAdjustFontSize(QFrame* w, const QString& s, bool ignoreWidth = false, bool ignoreHeight = false, int max = 10, int min = 4);
+
+extern int num2cols(int min, int max);
+extern QFrame* hLine(QWidget* parent);
+extern QFrame* vLine(QWidget* parent);
+extern void dump(const unsigned char* p, int n);
+extern double curTime();
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/velocity.cpp b/attic/muse2-oom/muse2/muse/widgets/velocity.cpp
new file mode 100644
index 00000000..309beb4d
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/velocity.cpp
@@ -0,0 +1,46 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: velocity.cpp,v 1.1.1.1 2003/10/27 18:55:04 wschweer Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <QButtonGroup>
+#include "velocity.h"
+
+//---------------------------------------------------------
+// Velocity
+//---------------------------------------------------------
+
+Velocity::Velocity(QDialog* parent)
+ : QDialog(parent)
+ {
+ setupUi(this);
+ rangeGroup = new QButtonGroup;
+ rangeGroup->addButton(allEvents,0);
+ rangeGroup->addButton(selectedEvents,1);
+ rangeGroup->addButton(loopedEvents,2);
+ rangeGroup->addButton(selectedLooped,3);
+ }
+
+//---------------------------------------------------------
+// accept
+//---------------------------------------------------------
+
+void Velocity::accept()
+ {
+ _range = rangeGroup->checkedId();
+ _rateVal = rate->value();
+ _offsetVal = offset->value();
+ QDialog::accept();
+ }
+
+//---------------------------------------------------------
+// setRange
+//---------------------------------------------------------
+
+void Velocity::setRange(int id)
+ {
+ rangeGroup->button(id)->setChecked(true);
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/velocity.h b/attic/muse2-oom/muse2/muse/widgets/velocity.h
new file mode 100644
index 00000000..cf5b2779
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/velocity.h
@@ -0,0 +1,39 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: velocity.h,v 1.1.1.1 2003/10/27 18:54:51 wschweer Exp $
+// (C) Copyright 2001 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __VELOCITY_H__
+#define __VELOCITY_H__
+
+#include "ui_velocitybase.h"
+
+class QButtonGroup;
+
+//---------------------------------------------------------
+// Velocity
+//---------------------------------------------------------
+
+class Velocity : public QDialog, public Ui::VelocityBase {
+ int _range;
+ int _rateVal;
+ int _offsetVal;
+
+ Q_OBJECT
+ QButtonGroup* rangeGroup;
+
+ protected slots:
+ void accept();
+
+ public:
+ Velocity(QDialog* parent = 0);
+ void setRange(int id);
+ int range() const { return _range; }
+ int rateVal() const { return _rateVal; }
+ int offsetVal() const { return _offsetVal; }
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/velocitybase.ui b/attic/muse2-oom/muse2/muse/widgets/velocitybase.ui
new file mode 100644
index 00000000..1e386e11
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/velocitybase.ui
@@ -0,0 +1,211 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>VelocityBase</class>
+ <widget class="QDialog" name="VelocityBase">
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>275</width>
+ <height>316</height>
+ </rect>
+ </property>
+ <property name="windowTitle">
+ <string>MusE: Modify Velocity</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_2">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QGroupBox" name="rangeBox">
+ <property name="title">
+ <string>Range</string>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <item>
+ <widget class="QRadioButton" name="allEvents">
+ <property name="text">
+ <string>All Events</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="selectedEvents">
+ <property name="text">
+ <string>Selected Events</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="loopedEvents">
+ <property name="text">
+ <string>Looped Events</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QRadioButton" name="selectedLooped">
+ <property name="text">
+ <string>Selected &amp; Looped</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <widget class="QGroupBox" name="groupBox_2">
+ <property name="title">
+ <string>Values</string>
+ </property>
+ <layout class="QGridLayout" name="gridLayout">
+ <property name="margin">
+ <number>11</number>
+ </property>
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="TextLabel3">
+ <property name="text">
+ <string>Rate:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QSpinBox" name="rate">
+ <property name="suffix">
+ <string>%</string>
+ </property>
+ <property name="maximum">
+ <number>200</number>
+ </property>
+ <property name="value">
+ <number>100</number>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="0">
+ <widget class="QLabel" name="TextLabel4">
+ <property name="text">
+ <string>Offset:</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="1" column="1">
+ <widget class="QSpinBox" name="offset">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>127</number>
+ </property>
+ <property name="singleStep">
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="spacing">
+ <number>6</number>
+ </property>
+ <item>
+ <spacer name="Spacer1">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Expanding</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton">
+ <property name="text">
+ <string>OK</string>
+ </property>
+ <property name="autoDefault">
+ <bool>false</bool>
+ </property>
+ <property name="default">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <layoutdefault spacing="6" margin="11"/>
+ <resources/>
+ <connections>
+ <connection>
+ <sender>okButton</sender>
+ <signal>clicked()</signal>
+ <receiver>VelocityBase</receiver>
+ <slot>accept()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ <connection>
+ <sender>cancelButton</sender>
+ <signal>clicked()</signal>
+ <receiver>VelocityBase</receiver>
+ <slot>reject()</slot>
+ <hints>
+ <hint type="sourcelabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ <hint type="destinationlabel">
+ <x>20</x>
+ <y>20</y>
+ </hint>
+ </hints>
+ </connection>
+ </connections>
+</ui>
diff --git a/attic/muse2-oom/muse2/muse/widgets/view.cpp b/attic/muse2-oom/muse2/muse/widgets/view.cpp
new file mode 100644
index 00000000..31cc212e
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/view.cpp
@@ -0,0 +1,639 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: view.cpp,v 1.3.2.2 2009/04/06 01:24:55 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "view.h"
+#include <cmath>
+#include <stdio.h>
+#include <QPainter>
+#include <QPixmap>
+#include <QResizeEvent>
+#include <QDropEvent>
+#include <QMouseEvent>
+#include <QKeyEvent>
+#include <QPaintEvent>
+
+// Don't use this, it was just for debugging.
+// It's much slower than muse-1 no matter how hard I tried.
+// The left/right pixmap shifters in seXPos setYPos
+// just ate up all the time no matter what I tried.
+//#defines VIEW_USE_DOUBLE_BUFFERING 1
+
+//---------------------------------------------------------
+// View::View
+// double xMag = (xmag < 0) ? 1.0/-xmag : double(xmag)
+//---------------------------------------------------------
+
+View::View(QWidget* w, int xm, int ym, const char* name)
+ : QWidget(w)
+ {
+ setAttribute(Qt::WA_NoSystemBackground);
+ setAttribute(Qt::WA_StaticContents);
+ // This is absolutely required for speed! Otherwise painfully slow because we get
+ // full rect paint events even on small scrolls! See help on QPainter::scroll().
+ setAttribute(Qt::WA_OpaquePaintEvent);
+
+ setObjectName(QString(name));
+ xmag = xm;
+ ymag = ym;
+ xpos = 0;
+ ypos = 0;
+ xorg = 0;
+ yorg = 0;
+ _virt = true;
+ setBackgroundRole(QPalette::NoRole);
+ brush.setStyle(Qt::SolidPattern);
+ brush.setColor(Qt::lightGray);
+ #ifdef VIEW_USE_DOUBLE_BUFFERING
+ pmValid = false;
+ #endif
+ }
+
+//---------------------------------------------------------
+// setOrigin
+//---------------------------------------------------------
+
+void View::setOrigin(int x, int y)
+ {
+ xorg = x;
+ yorg = y;
+ redraw();
+ }
+
+//---------------------------------------------------------
+// setXMag
+//---------------------------------------------------------
+
+void View::setXMag(int xs)
+ {
+ xmag = xs;
+ redraw();
+ }
+
+//---------------------------------------------------------
+// seqYMag
+//---------------------------------------------------------
+
+void View::setYMag(int ys)
+ {
+ ymag = ys;
+ redraw();
+ }
+
+//---------------------------------------------------------
+// setXPos
+// x - phys offset
+//---------------------------------------------------------
+
+void View::setXPos(int x)
+ {
+ int delta = xpos - x; // - -> shift left
+ xpos = x;
+
+ #ifdef VIEW_USE_DOUBLE_BUFFERING
+ if (pm.isNull())
+ return;
+ if (!pmValid) {
+ //printf("View::setXPos !pmValid x:%d width:%d delta:%d\n", x, width(), delta);
+ redraw();
+ return;
+ }
+
+ int w = width();
+ int h = height();
+
+ QRect r;
+ if (delta >= w || delta <= -w)
+ r = QRect(0, 0, w, h);
+ else if (delta < 0) { // shift left
+ //bitBlt(&pm, 0, 0, &pm, -delta, 0, w + delta, h, CopyROP, true);
+ QPainter p(&pm);
+ p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing, false);
+ //printf("View::setXPos x:%d w:%d delta:%d r.x:%d r.w:%d\n",
+ // x, w, delta, r.x(), r.width());
+ p.drawPixmap(0, 0, pm, -delta, 0, w + delta, h);
+ r = QRect(w + delta, 0, -delta, h);
+ }
+ else { // shift right
+ //bitBlt(&pm, delta, 0, &pm, 0, 0, w-delta, h, CopyROP, true);
+ QPainter p(&pm);
+ p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing, false);
+ //printf("View::setXPos x:%d w:%d delta:%d r.x:%d r.w:%d\n",
+ // x, w, delta, r.x(), r.width());
+ p.drawPixmap(delta, 0, pm, 0, 0, w-delta, h);
+ r = QRect(0, 0, delta, h);
+ }
+ QRect olr = overlayRect();
+ QRect olr1(olr);
+ olr1.translate(delta, 0);
+
+ r |= olr;
+ r |= olr1;
+
+ //printf("View::setXPos x:%d w:%d delta:%d r.x:%d r.w:%d\n", x, w, delta, r.x(), r.width());
+ //printf("View::setXPos paint delta:%d r.x:%d r.y:%d r.w:%d r.h:%d\n", delta, r.x(), r.y(), r.width(), r.height());
+
+ paint(r);
+ update();
+
+ #else
+ scroll(delta, 0);
+ #endif
+ }
+
+//---------------------------------------------------------
+// setYPos
+//---------------------------------------------------------
+
+void View::setYPos(int y)
+ {
+ int delta = ypos - y; // - -> shift up
+ ypos = y;
+
+ #ifdef VIEW_USE_DOUBLE_BUFFERING
+ if (pm.isNull())
+ return;
+ if (!pmValid) {
+ //printf("View::setYPos !pmValid y:%d height:%d delta:%d\n", y, height(), delta);
+
+ redraw();
+ return;
+ }
+
+ int w = width();
+ int h = height();
+
+ QRect r;
+ if (delta >= h || delta <= -h)
+ r = QRect(0, 0, w, h);
+ else if (delta < 0) { // shift up
+ //bitBlt(&pm, 0, 0, &pm, 0, -delta, w, h + delta, CopyROP, true);
+ QPainter p(&pm);
+ p.drawPixmap(0, 0, pm, 0, -delta, w, h + delta);
+ r = QRect(0, h + delta, w, -delta);
+ }
+ else { // shift down
+ //bitBlt(&pm, 0, delta, &pm, 0, 0, w, h-delta, CopyROP, true);
+ QPainter p(&pm);
+ p.drawPixmap(0, delta, pm, 0, 0, w, h-delta);
+ r = QRect(0, 0, w, delta);
+ }
+ QRect olr = overlayRect();
+ QRect olr1(olr);
+ olr1.translate(0, delta);
+
+ r |= olr;
+ r |= olr1;
+
+ //printf("View::setYPos paint delta:%d r.x:%d r.y:%d r.w:%d r.h:%d\n", delta, r.x(), r.y(), r.width(), r.height());
+
+ paint(r);
+ update();
+
+ #else
+ scroll(0, delta);
+ #endif
+ }
+
+//---------------------------------------------------------
+// resizeEvent
+//---------------------------------------------------------
+
+void View::resizeEvent(QResizeEvent* ev)
+ {
+ #ifdef VIEW_USE_DOUBLE_BUFFERING
+ //pm.resize(ev->size());
+ //printf("View::resizeEvent width:%d height:%d\n",
+ // ev->size().width(), ev->size().height());
+
+ if(pm.isNull())
+ {
+ //printf("View::resizeEvent pixmap is null\n");
+ pm = QPixmap(ev->size().width(), ev->size().height());
+ }
+ else
+ pm = pm.copy(QRect(QPoint(0, 0), ev->size()));
+ pmValid = false;
+ #endif
+ }
+
+//---------------------------------------------------------
+// paintEvent
+//---------------------------------------------------------
+
+void View::paintEvent(QPaintEvent* ev)
+ {
+ //printf("View::paintEvent x:%d width:%d y:%d height:%d\n",
+ // ev->rect().x(), ev->rect().width(), ev->rect().y(), ev->rect().height());
+
+ #ifdef VIEW_USE_DOUBLE_BUFFERING
+ if (!pmValid)
+ paint(ev->rect());
+
+ //bitBlt(this, ev->rect().topLeft(), &pm, ev->rect(), CopyROP, true);
+ QPainter p(this);
+ //p.setCompositionMode(QPainter::CompositionMode_Source);
+ p.drawPixmap(ev->rect().topLeft(), pm, ev->rect());
+
+ #else
+ paint(ev->rect());
+ #endif
+ }
+
+//---------------------------------------------------------
+// redraw
+//---------------------------------------------------------
+
+void View::redraw()
+ {
+ //printf("View::redraw()\n");
+
+ #ifdef VIEW_USE_DOUBLE_BUFFERING
+ QRect r(0, 0, pm.width(), pm.height());
+ //printf("View::redraw() r.x:%d r.w:%d\n", r.x(), r.width());
+ paint(r);
+ #endif
+
+ update();
+ }
+
+//---------------------------------------------------------
+// redraw
+//---------------------------------------------------------
+
+void View::redraw(const QRect& r)
+ {
+ //printf("View::redraw(QRect& r) r.x:%d r.w:%d\n", r.x(), r.width());
+
+ #ifdef VIEW_USE_DOUBLE_BUFFERING
+ paint(r);
+ #endif
+
+ update(r);
+ }
+
+//---------------------------------------------------------
+// paint
+// r - phys coord system
+//---------------------------------------------------------
+
+void View::paint(const QRect& r)
+ {
+ #ifdef VIEW_USE_DOUBLE_BUFFERING
+ if (pm.isNull())
+ return;
+ #endif
+
+ QRect rr(r);
+
+ //printf("View::paint x:%d width:%d y:%d height:%d\n", r.x(), r.width(), r.y(), r.height());
+
+ #ifdef VIEW_USE_DOUBLE_BUFFERING
+ if (!pmValid) {
+ pmValid = true;
+ rr = QRect(0, 0, pm.width(), pm.height());
+ }
+
+ QPainter p(&pm);
+ #else
+ QPainter p(this);
+ #endif
+
+ p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform | QPainter::HighQualityAntialiasing, false);
+
+ if (bgPixmap.isNull())
+ p.fillRect(rr, brush);
+ else
+ p.drawTiledPixmap(rr, bgPixmap, QPoint(xpos + rmapx(xorg)
+ + rr.x(), ypos + rmapy(yorg) + rr.y()));
+
+ p.setClipRegion(rr);
+
+ //printf("View::paint r.x:%d w:%d\n", rr.x(), rr.width());
+ pdraw(p, rr); // draw into pixmap
+
+ p.resetMatrix(); // Q3 support says use resetMatrix instead, but resetMatrix advises resetTransform instead...
+ //p.resetTransform();
+
+ drawOverlay(p);
+ }
+
+//---------------------------------------------------------
+// keyPressEvent
+//---------------------------------------------------------
+
+void View::keyPressEvent(QKeyEvent* event)
+ {
+ viewKeyPressEvent(event);
+ }
+
+//---------------------------------------------------------
+// viewKeyPressEvent
+//---------------------------------------------------------
+
+void View::viewKeyPressEvent(QKeyEvent* event)
+ {
+ event->ignore();
+ }
+
+//---------------------------------------------------------
+// mousePressEvent
+//---------------------------------------------------------
+
+void View::mousePressEvent(QMouseEvent* ev)
+ {
+ QMouseEvent e(ev->type(), mapDev(ev->pos()),
+ ev->globalPos(), ev->button(), ev->buttons(), ev->modifiers());
+ viewMousePressEvent(&e);
+ }
+
+//---------------------------------------------------------
+// mouseDoubleClickEvent
+//---------------------------------------------------------
+
+void View::mouseDoubleClickEvent(QMouseEvent* ev)
+ {
+ QMouseEvent e(ev->type(), mapDev(ev->pos()),
+ ev->globalPos(), ev->button(), ev->buttons(), ev->modifiers());
+ viewMouseDoubleClickEvent(&e);
+ }
+
+//---------------------------------------------------------
+// mouseMoveEvent
+//---------------------------------------------------------
+
+void View::mouseMoveEvent(QMouseEvent* ev)
+ {
+ QMouseEvent e(ev->type(), mapDev(ev->pos()),
+ ev->globalPos(), ev->button(), ev->buttons(), ev->modifiers());
+ viewMouseMoveEvent(&e);
+ }
+
+//---------------------------------------------------------
+// mouseReleaseEvent
+//---------------------------------------------------------
+
+void View::mouseReleaseEvent(QMouseEvent* ev)
+ {
+ QMouseEvent e(ev->type(), mapDev(ev->pos()),
+ ev->globalPos(), ev->button(), ev->buttons(), ev->modifiers());
+ viewMouseReleaseEvent(&e);
+ }
+
+//---------------------------------------------------------
+// dropEvent
+//---------------------------------------------------------
+
+void View::dropEvent(QDropEvent* ev)
+ {
+ // From Q3 support:
+ // "Sets the drop to happen at the given point. You do not normally need to use this
+ // as it will be set internally before your widget receives the drop event."
+ // But we need to remap it here...
+ //ev->setPoint(mapDev(ev->pos()));
+ QDropEvent nev(mapDev(ev->pos()), ev->possibleActions(), ev->mimeData(), ev->mouseButtons(), ev->keyboardModifiers(), ev->type());
+ //viewDropEvent(ev);
+ viewDropEvent(&nev);
+ }
+
+//---------------------------------------------------------
+// setBg
+//---------------------------------------------------------
+
+void View::setBg(const QPixmap& bgpm)
+ {
+ bgPixmap = bgpm;
+ redraw();
+ }
+
+//---------------------------------------------------------
+// pdraw
+// r - phys coords
+//---------------------------------------------------------
+
+void View::pdraw(QPainter& p, const QRect& r)
+ {
+ //printf("View::pdraw virt:%d x:%d width:%d y:%d height:%d\n", virt(), r.x(), r.width(), r.y(), r.height());
+
+ if (virt()) {
+ setPainter(p);
+ int x = r.x();
+ int y = r.y();
+ int w = r.width();
+ int h = r.height();
+ if (xmag <= 0) {
+ x -= 1;
+ w += 2;
+ x = (x + xpos + rmapx(xorg)) * (-xmag);
+ w = w * (-xmag);
+ }
+ else {
+ x = (x + xpos + rmapx(xorg)) / xmag;
+ w = (w + xmag - 1) / xmag;
+ x -= 1;
+ w += 2;
+ }
+ if (ymag <= 0) {
+ y -= 1;
+ h += 2;
+ y = (y + ypos + rmapy(yorg)) * (-ymag);
+ h = h * (-ymag);
+ }
+ else {
+ y = (y + ypos + rmapy(yorg)) / ymag;
+ h = (h + ymag - 1) / ymag;
+ y -= 1;
+ h += 2;
+ }
+
+ if (x < 0)
+ x = 0;
+ if (y < 0)
+ y = 0;
+
+ draw(p, QRect(x, y, w, h));
+ }
+ else
+ draw(p, r);
+ }
+
+//---------------------------------------------------------
+// setPainter
+//---------------------------------------------------------
+
+void View::setPainter(QPainter& p)
+ {
+ p.resetMatrix(); // Q3 support says use resetMatrix instead, but resetMatrix advises resetTransform instead...
+ //p.resetTransform();
+
+ p.translate(double(-(xpos+rmapx(xorg))), double(-(ypos+rmapy(yorg))));
+ double xMag = (xmag < 0) ? 1.0/(-xmag) : double(xmag);
+ double yMag = (ymag < 0) ? 1.0/(-ymag) : double(ymag);
+ p.scale(xMag, yMag);
+ }
+
+//---------------------------------------------------------
+// map
+//---------------------------------------------------------
+
+QRect View::map(const QRect& r) const
+ {
+ int x, y, w, h;
+ if (xmag < 0) {
+ x = r.x()/(-xmag) - (xpos + rmapx(xorg)); // round down
+ w = (r.width()-xmag-1) / (-xmag); // round up
+ }
+ else {
+ x = r.x()*xmag - (xpos + rmapx(xorg));
+ w = r.width() * xmag;
+ }
+ if (ymag < 0) {
+ y = r.y()/-ymag - (ypos + rmapy(yorg));
+ h = (r.height()-ymag-1) / (-ymag);
+ }
+ else {
+ y = r.y() * ymag - (ypos + rmapy(yorg));
+ h = r.height() * ymag;
+ }
+ return QRect(x, y, w, h);
+ }
+
+QPoint View::map(const QPoint& p) const
+ {
+ int x, y;
+ if (xmag < 0) {
+ x = p.x()/(-xmag) - (xpos + rmapx(xorg)); // round down
+ }
+ else {
+ x = p.x()*xmag - (xpos + rmapx(xorg));
+ }
+ if (ymag < 0) {
+ y = p.y()/-ymag - (ypos + rmapy(yorg));
+ }
+ else {
+ y = p.y() * ymag - (ypos + rmapy(yorg));
+ }
+ return QPoint(x, y);
+ }
+
+QRect View::mapDev(const QRect& r) const
+ {
+ return QRect(mapxDev(r.x()), mapyDev(r.y()),
+ rmapxDev(r.width()), rmapyDev(r.height()));
+ }
+
+QPoint View::mapDev(const QPoint& r) const
+ {
+ return QPoint(mapxDev(r.x()), mapyDev(r.y()));
+ }
+
+int View::mapx(int x) const
+ {
+ if (xmag < 0) {
+ return (x-xmag/2)/(-xmag) - (xpos + rmapx(xorg)); // round
+ }
+ else {
+ return (x * xmag) - (xpos + rmapx(xorg));
+ }
+ }
+int View::mapy(int y) const
+ {
+ if (ymag < 0) {
+ return (y-ymag/2)/(-ymag) - (ypos + rmapy(yorg)); // round
+ }
+ else {
+ return (y * ymag) - (ypos + rmapy(yorg));
+ }
+ }
+int View::mapxDev(int x) const
+ {
+ int val;
+ if (xmag <= 0)
+ val = (x + xpos + rmapx(xorg)) * (-xmag);
+ else
+ val = (x + xpos + rmapx(xorg) + xmag / 2) / xmag;
+ if (val < 0) // DEBUG
+ val = 0;
+ return val;
+ }
+
+int View::mapyDev(int y) const
+ {
+ if (ymag <= 0)
+ return (y + ypos + rmapy(yorg)) * (-ymag);
+ else
+ return (y + ypos + rmapy(yorg) + ymag / 2) / ymag;
+ }
+
+int View::rmapx(int x) const
+ {
+ if (xmag < 0)
+ return (x-xmag/2) / (-xmag);
+ else
+ return x * xmag;
+ }
+int View::rmapy(int y) const
+ {
+ if (ymag < 0)
+ return (y-ymag/2) / (-ymag);
+ else
+ return y * ymag;
+ }
+int View::rmapxDev(int x) const
+ {
+ if (xmag <= 0)
+ return x * (-xmag);
+ else
+ return (x + xmag/2) / xmag;
+ }
+int View::rmapyDev(int y) const
+ {
+ if (ymag <= 0)
+ return y * (-ymag);
+ else
+ return (y + ymag/2) / ymag;
+ }
+
+/*
+QRect View::devToVirt(const QRect& r)
+{
+ int x = r.x();
+ int y = r.y();
+ int w = r.width();
+ int h = r.height();
+ if (xmag <= 0) {
+ x -= 1;
+ w += 2;
+ x = (x + xpos + rmapx(xorg)) * (-xmag);
+ w = w * (-xmag);
+ }
+ else {
+ x = (x + xpos + rmapx(xorg)) / xmag;
+ w = (w + xmag - 1) / xmag;
+ x -= 1;
+ w += 2;
+ }
+ if (ymag <= 0) {
+ y -= 1;
+ h += 2;
+ y = (y + ypos + rmapy(yorg)) * (-ymag);
+ h = h * (-ymag);
+ }
+ else {
+ y = (y + ypos + rmapy(yorg)) / ymag;
+ h = (h + ymag - 1) / ymag;
+ y -= 1;
+ h += 2;
+ }
+
+ if (x < 0)
+ x = 0;
+ if (y < 0)
+ y = 0;
+
+ return QRect(x, y, w, h);
+}
+*/ \ No newline at end of file
diff --git a/attic/muse2-oom/muse2/muse/widgets/view.h b/attic/muse2-oom/muse2/muse/widgets/view.h
new file mode 100644
index 00000000..f8b0c90f
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/view.h
@@ -0,0 +1,107 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: view.h,v 1.2.2.1 2008/01/26 07:23:21 terminator356 Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __VIEW_H__
+#define __VIEW_H__
+
+#include <QWidget>
+
+class QDropEvent;
+class QKeyEvent;
+class QMouseEvent;
+class QPaintEvent;
+class QPainter;
+class QPixmap;
+class QResizeEvent;
+
+//---------------------------------------------------------
+// View
+// horizontal View with double buffering
+//---------------------------------------------------------
+
+class View : public QWidget {
+ QPixmap pm; // for double buffering
+ bool pmValid;
+ QPixmap bgPixmap; // background Pixmap
+ QBrush brush;
+ bool _virt;
+ Q_OBJECT
+
+ protected:
+ int xorg;
+ int yorg;
+ int xpos, ypos;
+ int xmag, ymag;
+
+ virtual void keyPressEvent(QKeyEvent* event);
+ virtual void mousePressEvent(QMouseEvent* event);
+ virtual void mouseDoubleClickEvent(QMouseEvent* event);
+ virtual void mouseMoveEvent(QMouseEvent* event);
+ virtual void mouseReleaseEvent(QMouseEvent* event);
+ virtual void dropEvent(QDropEvent* event);
+
+ virtual void draw(QPainter&, const QRect&) {}
+ virtual void drawOverlay(QPainter&) {}
+ virtual QRect overlayRect() const { return QRect(0, 0, 0, 0); }
+
+ virtual void pdraw(QPainter&, const QRect&);
+
+ virtual void paintEvent(QPaintEvent* ev);
+ void redraw(const QRect&);
+
+ void paint(const QRect& r);
+
+ virtual void resizeEvent(QResizeEvent*);
+ virtual void viewKeyPressEvent(QKeyEvent*);
+ virtual void viewMousePressEvent(QMouseEvent*) {}
+ virtual void viewMouseDoubleClickEvent(QMouseEvent*) {}
+ virtual void viewMouseMoveEvent(QMouseEvent*) {}
+ virtual void viewMouseReleaseEvent(QMouseEvent*) {}
+ virtual void viewDropEvent(QDropEvent*) {}
+
+ QRect map(const QRect&) const;
+ QPoint map(const QPoint&) const;
+ QRect mapDev(const QRect&) const;
+ QPoint mapDev(const QPoint&) const;
+
+ int mapx(int x) const;
+ int mapy(int y) const;
+ int mapyDev(int y) const;
+ int mapxDev(int x) const;
+ int rmapy(int y) const;
+ int rmapyDev(int y) const;
+ //QRect devToVirt(const QRect&);
+
+ void setPainter(QPainter& p);
+
+ public slots:
+ void setXPos(int);
+ void setYPos(int);
+ void setXMag(int xs);
+ void setYMag(int ys);
+ void redraw();
+
+ public:
+ View(QWidget*, int, int, const char* name = 0);
+ void setBg(const QPixmap& pm);
+ void setBg(const QColor& color) { brush.setColor(color); redraw(); }
+ void setXOffset(int v) { setXPos(mapx(v)); }
+ int xOffset() const { return mapxDev(xpos)-xorg; }
+ int xOffsetDev() const { return xpos-rmapx(xorg); }
+
+ int yOffset() const { return mapyDev(ypos)-yorg; }
+ int getXScale() const { return xmag; }
+ int getYScale() const { return ymag; }
+ void setOrigin(int x, int y);
+ void setVirt(bool flag) { _virt = flag; }
+ bool virt() const { return _virt; }
+ int rmapxDev(int x) const;
+ int rmapx(int x) const;
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/vscale.cpp b/attic/muse2-oom/muse2/muse/widgets/vscale.cpp
new file mode 100644
index 00000000..943124e5
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/vscale.cpp
@@ -0,0 +1,28 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: vscale.cpp,v 1.1.1.1 2003/10/27 18:54:41 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include "vscale.h"
+
+#include <QPainter>
+#include <QPaintEvent>
+
+//---------------------------------------------------------
+// paintEvent
+//---------------------------------------------------------
+
+void VScale::paintEvent(QPaintEvent*)
+ {
+ int h = height();
+ int w = width();
+ QPainter p;
+ p.begin(this);
+ p.drawLine(w/2, h/4, w, h/4);
+ p.drawLine(0, h/2, w, h/2);
+ p.drawLine(w/2, (3*h)/4, w, (3*h)/4);
+ p.end();
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/vscale.h b/attic/muse2-oom/muse2/muse/widgets/vscale.h
new file mode 100644
index 00000000..100c5fb2
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/vscale.h
@@ -0,0 +1,29 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: vscale.h,v 1.1.1.1.2.1 2008/01/19 13:33:47 wschweer Exp $
+// (C) Copyright 1999 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __VSCALE_H__
+#define __VSCALE_H__
+
+#include <QWidget>
+
+class QPaintEvent;
+
+//---------------------------------------------------------
+// VScale
+//---------------------------------------------------------
+
+class VScale : public QWidget {
+ Q_OBJECT
+
+ virtual void paintEvent(QPaintEvent*);
+
+ public:
+ VScale(QWidget* parent=0) : QWidget(parent) {setFixedWidth(18);}
+ };
+
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/wtscale.cpp b/attic/muse2-oom/muse2/muse/widgets/wtscale.cpp
new file mode 100644
index 00000000..2c02b631
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/wtscale.cpp
@@ -0,0 +1,286 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: wtscale.cpp,v 1.3 2004/04/11 13:03:32 wschweer Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <values.h>
+
+#include <QPainter>
+#include <QRect>
+#include <QToolTip>
+
+#include "wtscale.h"
+#include "midieditor.h"
+#include "globals.h"
+#include "song.h"
+#include "../marker/marker.h"
+#include "icons.h"
+
+//---------------------------------------------------------
+// WTScale
+// Wave Time Scale
+//---------------------------------------------------------
+
+WTScale::WTScale(int* r, QWidget* parent, int xs)
+ : View(parent, xs, 1)
+ {
+ QToolTip::add(this, tr("bar scale"));
+ barLocator = false;
+ raster = r;
+ pos[0] = int(song->tempomap()->tick2time(song->cpos()) * sampleRate);
+ pos[1] = int(song->tempomap()->tick2time(song->lpos()) * sampleRate);
+ pos[2] = int(song->tempomap()->tick2time(song->rpos()) * sampleRate);
+ pos[3] = -1; // do not show
+ button = Qt::NoButton;
+ setMouseTracking(true);
+ connect(song, SIGNAL(posChanged(int, unsigned, bool)), SLOT(setPos(int, unsigned, bool)));
+ connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
+ connect(song, SIGNAL(markerChanged(int)), SLOT(redraw()));
+ setFixedHeight(28);
+ setBg(QColor(0xe0, 0xe0, 0xe0));
+ }
+
+//---------------------------------------------------------
+// songChanged
+//---------------------------------------------------------
+
+void WTScale::songChanged(int /*type*/)
+ {
+ }
+
+//---------------------------------------------------------
+// setPos
+//---------------------------------------------------------
+
+void WTScale::setPos(int idx, unsigned val, bool adjustScrollbar)
+ {
+ val = int(song->tempomap()->tick2time(val) * sampleRate);
+ if (val == pos[idx])
+ return;
+ int opos = mapx(pos[idx] == -1 ? val : pos[idx]);
+ pos[idx] = val;
+ if (!isVisible())
+ return;
+ val = mapx(val);
+ int x = -9;
+ int w = 18;
+ if (opos > val) {
+ w += opos - val;
+ x += val;
+ }
+ else {
+ w += val - opos;
+ x += opos;
+ }
+ redraw(QRect(x, 0, w, height()));
+ }
+
+//---------------------------------------------------------
+// viewMousePressEvent
+//---------------------------------------------------------
+
+void WTScale::viewMousePressEvent(QMouseEvent* event)
+ {
+ button = event->button();
+ viewMouseMoveEvent(event);
+ }
+
+//---------------------------------------------------------
+// viewMouseReleaseEvent
+//---------------------------------------------------------
+
+void WTScale::viewMouseReleaseEvent(QMouseEvent* event)
+ {
+ button = Qt::NoButton;
+ }
+
+//---------------------------------------------------------
+// viewMouseMoveEvent
+//---------------------------------------------------------
+
+void WTScale::viewMouseMoveEvent(QMouseEvent* event)
+ {
+ int x= song->tempomap()->time2tick(double(event->x())/double(sampleRate));
+ x = song->raster(x, *raster);
+ if (x < 0)
+ x = 0;
+ emit timeChanged(x);
+ int i;
+ switch (button) {
+ case Qt::LeftButton:
+ i = 0;
+ break;
+ case Qt::MidButton:
+ i = 1;
+ break;
+ case Qt::RightButton:
+ i = 2;
+ break;
+ default:
+ return;
+ }
+ song->setPos(i, x);
+ }
+
+//---------------------------------------------------------
+// leaveEvent
+//---------------------------------------------------------
+
+void WTScale::leaveEvent(QEvent*)
+ {
+// emit timeChanged(MAXINT);
+ }
+
+//---------------------------------------------------------
+// draw
+//---------------------------------------------------------
+
+void WTScale::pdraw(QPainter& p, const QRect& r)
+ {
+ int x = r.x();
+ int w = r.width();
+
+ x -= 20;
+ w += 40; // wg. Text
+
+ //
+ // draw Marker
+ //
+ int y = 12;
+ p.setPen(Qt::black);
+ p.setFont(font4);
+ p.drawLine(r.x(), y+1, r.x() + r.width(), y+1);
+ QRect tr(r);
+ tr.setHeight(12);
+ MarkerList* marker = song->marker();
+ for (iMarker m = marker->begin(); m != marker->end(); ++m) {
+ int xp = mapx(int(m->second.time() * sampleRate));
+ if (xp > x+w)
+ break;
+ int xe = r.x() + r.width();
+ iMarker mm = m;
+ ++mm;
+ if (mm != marker->end()) {
+ xe = mapx(mm->first);
+ }
+ QRect tr(xp, 0, xe-xp, 13);
+ if (m->second.current()) {
+ p.fillRect(tr, Qt::white);
+ }
+ if (r.intersects(tr)) {
+ int x2;
+ iMarker mm = m;
+ ++mm;
+ if (mm != marker->end())
+ x2 = mapx(mm->first);
+ else
+ x2 = xp+200;
+ QRect r = QRect(xp+10, 0, x2-xp, 12);
+ p.drawPixmap(xp, 0, *flagIconS);
+ p.drawText(r, Qt::AlignLeft|Qt::AlignVCenter, m->second.name());
+ }
+ }
+
+ //---------------------------------------------------
+ // draw location marker
+ //---------------------------------------------------
+
+ int h = height()-12;
+
+ if (barLocator) {
+ p.setPen(Qt::red);
+ int xp = mapx(pos[0]);
+ if (xp >= x && xp < x+w)
+ p.drawLine(xp, y, xp, h);
+ p.setPen(Qt::blue);
+ xp = mapx(pos[1]);
+ if (xp >= x && xp < x+w)
+ p.drawLine(xp, y, xp, h);
+ xp = mapx(pos[2]);
+ if (xp >= x && xp < x+w)
+ p.drawLine(xp, y, xp, h);
+ }
+ else {
+ for (int i = 0; i < 3; ++i) {
+ int xp = mapx(pos[i]);
+ if (xp >= x && xp < x+w) {
+ QPixmap* pm = markIcon[i];
+ p.drawPixmap(xp - pm->width()/2, y-1, *pm);
+ }
+ }
+ }
+ p.setPen(Qt::black);
+ if (pos[3] != -1) {
+ int xp = mapx(pos[3]);
+ if (xp >= x && xp < x+w)
+ p.drawLine(xp, 0, xp, height());
+ }
+
+ int ctick = song->samples2tick(mapxDev(x));
+ int bar1, bar2, beat, tick;
+ song->tickValues(ctick, &bar1, &beat, &tick);
+ song->tickValues(song->samples2tick(mapxDev(x+w)), &bar2, &beat, &tick);
+
+//printf("bar %d %d-%d=%d\n", bar, ntick, stick, ntick-stick);
+
+ int stick = song->bar2tick(bar1, 0, 0);
+ int ntick;
+ for (int bar = bar1; bar <= bar2; bar++, stick = ntick) {
+ ntick = song->bar2tick(bar+1, 0, 0);
+ int a = song->tick2samples(ntick);
+ int b = song->tick2samples(stick);
+ int tpix = rmapx(a - b);
+ if (tpix < 64) {
+ // donīt show beats if measure is this small
+ int n = 1;
+ if (tpix < 32)
+ n = 2;
+ if (tpix <= 16)
+ n = 4;
+ if (tpix < 8)
+ n = 8;
+ if (tpix <= 4)
+ n = 16;
+ if (tpix <= 2)
+ n = 32;
+ if (bar % n)
+ continue;
+ p.setFont(font3);
+ int x = mapx(b);
+ QString s;
+ s.setNum(bar + 1);
+ p.drawLine(x, y+1, x, y+1+h);
+ QRect r = QRect(x+2, y, 0, h);
+ p.drawText(r, Qt::AlignLeft|Qt::AlignVCenter|Qt::TextDontClip, s);
+ }
+ else {
+ int z, n;
+ song->timesig(stick, z, n);
+ for (int beat = 0; beat < z; beat++) {
+ int xx = song->tick2samples(song->bar2tick(bar, beat, 0));
+ int xp = mapx(xx);
+ QString s;
+ QRect r(xp+2, y, 0, h);
+ int y1;
+ int num;
+ if (beat == 0) {
+ num = bar + 1;
+ y1 = y + 1;
+ p.setFont(font3);
+ }
+ else {
+ num = beat + 1;
+ y1 = y + 7;
+ p.setFont(font1);
+ r.setY(y+3);
+ }
+ s.setNum(num);
+ p.drawLine(xp, y1, xp, y+1+h);
+ p.drawText(r, Qt::AlignLeft|Qt::AlignVCenter|Qt::TextDontClip, s);
+ }
+ }
+ }
+ }
+
diff --git a/attic/muse2-oom/muse2/muse/widgets/wtscale.h b/attic/muse2-oom/muse2/muse/widgets/wtscale.h
new file mode 100644
index 00000000..f12bbc6f
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/widgets/wtscale.h
@@ -0,0 +1,46 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: wtscale.h,v 1.2 2004/01/11 18:55:37 wschweer Exp $
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __MTSCALE_H__
+#define __MTSCALE_H__
+
+#include "view.h"
+
+//---------------------------------------------------------
+// WTScale
+// scale for wave track
+//---------------------------------------------------------
+
+class WTScale : public View {
+ Q_OBJECT
+ int* raster;
+ unsigned pos[4];
+ int button;
+ bool barLocator;
+
+ private slots:
+ void songChanged(int);
+
+ protected:
+ virtual void pdraw(QPainter&, const QRect&);
+ virtual void viewMousePressEvent(QMouseEvent* event);
+ virtual void viewMouseMoveEvent(QMouseEvent* event);
+ virtual void viewMouseReleaseEvent(QMouseEvent* event);
+ virtual void leaveEvent(QEvent*e);
+
+ signals:
+ void timeChanged(unsigned);
+
+ public slots:
+ void setPos(int, unsigned, bool);
+
+ public:
+ WTScale(int* raster, QWidget* parent, int xscale);
+ void setBarLocator(bool f) { barLocator = f; }
+ };
+#endif
+
diff --git a/attic/muse2-oom/muse2/muse/xml.cpp b/attic/muse2-oom/muse2/muse/xml.cpp
new file mode 100644
index 00000000..6a12283e
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/xml.cpp
@@ -0,0 +1,734 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: xml.cpp,v 1.17.2.6 2009/12/07 20:48:45 spamatica Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#include <stdio.h>
+#include <stdarg.h>
+
+#include <QString>
+#include <QColor>
+#include <QWidget>
+#include <QRect>
+
+#include "xml.h"
+
+//---------------------------------------------------------
+// Note:
+// this code is a Q/D hack for reading/parsing and
+// writing XML-Files
+// - can only handle the XML subset used by MusE
+// - may not handle misformed XML (eg. when manually
+// editing MusE output)
+
+//---------------------------------------------------------
+// Xml
+//---------------------------------------------------------
+
+Xml::Xml(FILE* _f)
+ {
+ f = _f;
+ _line = 0;
+ _col = 0;
+ level = 0;
+ inTag = false;
+ inComment = false;
+ lbuffer[0] = 0;
+ bufptr = lbuffer;
+ _minorVersion = -1;
+ _majorVersion = -1;
+ }
+
+Xml::Xml(const char* buf)
+ {
+ f = 0;
+ _line = 0;
+ _col = 0;
+ level = 0;
+ inTag = false;
+ inComment = false;
+ bufptr = buf;
+ _minorVersion = -1;
+ _majorVersion = -1;
+ }
+
+//---------------------------------------------------------
+// next
+//---------------------------------------------------------
+
+void Xml::next()
+ {
+ if (*bufptr == 0) {
+ if (f == 0 || fgets(lbuffer, 512, f) == 0) {
+ c = EOF;
+ return;
+ }
+ bufptr = lbuffer;
+ }
+ c = *bufptr++;
+ if (c == '\n') {
+ ++_line;
+ _col = -1;
+ }
+ ++_col;
+ }
+
+//---------------------------------------------------------
+// nextc
+// get next non space character
+//---------------------------------------------------------
+
+void Xml::nextc()
+ {
+ next();
+ while (c == ' ' || c == '\t' || c == '\n')
+ next();
+ }
+
+//---------------------------------------------------------
+// token
+// read token into _s2
+//---------------------------------------------------------
+
+void Xml::token(int cc)
+ {
+ char buffer[512];
+ int i = 0;
+ for (; i < 511;) {
+ if (c == ' ' || c == '\t' || c == cc || c == '\n' || c == EOF)
+ break;
+ buffer[i++] = c;
+ next();
+ }
+ buffer[i] = 0;
+ _s2 = buffer; // deep copy !?
+ }
+
+//---------------------------------------------------------
+// stoken
+// read string token into _s2
+//---------------------------------------------------------
+
+void Xml::stoken()
+ {
+ char buffer[1024*4];
+ int i = 0;
+ buffer[i] = c;
+ ++i;
+ next();
+ for (;i < 1024*4-1;) {
+ if (c == '"') {
+ buffer[i++] = c;
+ next();
+ break;
+ }
+ if (c == '&') {
+ char entity[6];
+ int k = 0;
+ for (; k < 6; ++k) {
+ next();
+ if (c == EOF)
+ break;
+ else if (c == ';') {
+ entity[k] = 0;
+ if (strcmp(entity, "quot") == 0)
+ c = '"';
+ else if (strcmp(entity, "amp") == 0)
+ c = '&';
+ else if (strcmp(entity, "lt") == 0)
+ c = '<';
+ else if (strcmp(entity, "gt") == 0)
+ c = '>';
+ else if (strcmp(entity, "apos") == 0)
+ c = '\\';
+ else
+ entity[k] = c;
+ break;
+ }
+ else
+ entity[k] = c;
+ }
+ if (c == EOF || k == 6) {
+ // dump entity
+ int n = 0;
+ buffer[i++] = '&';
+ for (;(i < 511) && (n < k); ++i, ++n)
+ buffer[i] = entity[n];
+ }
+ else
+ buffer[i++] = c;
+ }
+ else if(c != EOF)
+ buffer[i++] = c;
+ if (c == EOF)
+ break;
+ next();
+ }
+ buffer[i] = 0;
+ _s2 = buffer;
+ }
+
+//---------------------------------------------------------
+// strip
+// strip `"` from string
+//---------------------------------------------------------
+
+QString Xml::strip(const QString& s)
+ {
+ int l = s.length();
+ if (l >= 2 && s[0] == '"')
+ return s.mid(1, l-2);
+ return s;
+ }
+
+//---------------------------------------------------------
+// parse
+//---------------------------------------------------------
+
+Xml::Token Xml::parse()
+ {
+ char buffer[1024*1024]; // increase buffer -rj
+ char* p;
+
+ again:
+ bool endFlag = false;
+ nextc();
+ if (c == EOF) {
+ printf("unexpected EOF reading *.med file at level %d, line %d, <%s><%s><%s>\n",
+ level, _line, _tag.toLatin1().constData(), _s1.toLatin1().constData(), _s2.toLatin1().constData());
+ return level == 0 ? End : Error;
+ }
+
+ _s1 = QString("");
+ if (inTag) {
+ //-------------------
+ // parse Attributes
+ //-------------------
+ if (c == '/') {
+ nextc();
+ token('>');
+ if (c != '>') {
+ printf("Xml: unexpected char '%c', expected '>'\n", c);
+ goto error;
+ }
+ _s1 = _tag;
+ inTag = false;
+ --level;
+ return TagEnd;
+ }
+ _s2 = QString("");
+ token('=');
+ _s1 = _s2;
+ nextc(); // skip space
+ if (c == '"')
+ stoken();
+ else
+ token('>');
+ if (c == '>')
+ inTag = false;
+ else
+ --bufptr;
+ _s2 = strip(_s2);
+ return Attribut;
+ }
+ if (c == '<') {
+ //--------------
+ // parse Tag
+ //--------------
+ next();
+ if (c == '/') {
+ endFlag = true;
+ next();
+ }
+ if (c == '?') {
+ next();
+ p = buffer;
+ for (;;) {
+ if (c == '?' || c == EOF || c == '>')
+ break;
+ *p++ = c;
+ // TODO: check overflow
+ next();
+ }
+ *p = 0;
+ _s1 = QString(buffer);
+ if (c == EOF) {
+ fprintf(stderr, "XML: unexpected EOF\n");
+ goto error;
+ }
+ nextc();
+ if (c != '>') {
+ fprintf(stderr, "XML: '>' expected\n");
+ goto error;
+ }
+ next();
+ return Proc;
+ }
+ else if (c == '!') { // process comment
+ bool endc = false;
+ for(;;) {
+ next();
+ if (c == '>' && endc)
+ break;
+ endc = c == '-';
+ if (c == EOF) {
+ fprintf(stderr, "XML: unexpected EOF in comment\n");
+ goto error;
+ }
+ }
+ goto again;
+ }
+ p = buffer;
+ for (;;) {
+ if (c == '/' || c == ' ' || c == '\t' || c == '>' || c == '\n' || c == EOF)
+ break;
+ // TODO: check overflow
+ *p++ = c;
+ next();
+ }
+ *p = 0;
+ _s1 = QString(buffer);
+ // skip white space:
+ while (c == ' ' || c == '\t' || c == '\n')
+ next();
+ if (c == '/') {
+ nextc();
+ if (c == '>')
+ return Flag;
+ fprintf(stderr, "XML: '>' expected\n");
+ goto error;
+ }
+ if (c == '?') {
+ nextc();
+ if (c == '>')
+ return Proc;
+ fprintf(stderr, "XML: '>' expected\n");
+ goto error;
+ }
+ if (c == '>') {
+ if (endFlag) {
+ --level;
+ return TagEnd;
+ }
+ else {
+ ++level;
+ return TagStart;
+ }
+ }
+ else {
+ _tag = _s1;
+ --bufptr;
+ inTag = true;
+ ++level;
+ if (!endFlag) {
+ return TagStart;
+ }
+ fprintf(stderr, "XML: endFlag expected\n");
+ goto error;
+ }
+ }
+ else {
+ //--------------
+ // parse Text
+ //--------------
+ if (level == 0) {
+ fprintf(stderr, "XML: level = 0\n");
+ goto error;
+ }
+ p = buffer;
+ for (;;) {
+ if (c == EOF || c == '<')
+ break;
+ if (c == '&') {
+ next();
+ if (c == '<') { // be tolerant with old muse files
+ *p++ = '&';
+ continue;
+ }
+ char name[32];
+ char* dp = name;
+ *dp++ = c;
+ for (; dp-name < 31;) {
+ next();
+ if (c == ';')
+ break;
+ *dp++ = c;
+ }
+ *dp = 0;
+ if (strcmp(name, "lt") == 0)
+ c = '<';
+ else if (strcmp(name, "gt") == 0)
+ c = '>';
+ else if (strcmp(name, "apos") == 0)
+ c = '\\';
+ else if (strcmp(name, "quot") == 0)
+ c = '"';
+ else if (strcmp(name, "amp") == 0)
+ c = '&';
+ else
+ c = '?';
+ }
+ *p++ = c;
+ next();
+ }
+ *p = 0;
+ _s1 = QString(buffer);
+
+ if (c == '<')
+ --bufptr;
+ return Text;
+ }
+error:
+ fprintf(stderr, "XML Parse Error at line %d col %d\n", _line, _col+1);
+ return Error;
+ }
+
+//---------------------------------------------------------
+// parse(QString)
+//---------------------------------------------------------
+
+QString Xml::parse(const QString& tag)
+ {
+ QString a;
+
+ for (;;) {
+ switch (parse()) {
+ case Error:
+ case End:
+ return a;
+ default:
+ case TagStart:
+ case Attribut:
+ break;
+ case Text:
+ a = _s1;
+ break;
+ case TagEnd:
+ if (_s1 == tag)
+ return a;
+ break;
+ }
+ }
+ return a;
+ }
+
+//---------------------------------------------------------
+// parse1
+//---------------------------------------------------------
+
+QString Xml::parse1()
+ {
+ return parse(_s1.simplified());
+ }
+
+//---------------------------------------------------------
+// parseInt
+//---------------------------------------------------------
+
+int Xml::parseInt()
+ {
+ QString s(parse1().simplified());
+ bool ok;
+ int base = 10;
+ if (s.startsWith("0x") || s.startsWith("0X")) {
+ base = 16;
+ s = s.mid(2);
+ }
+ int n = s.toInt(&ok, base);
+ return n;
+ }
+
+//---------------------------------------------------------
+// parseUInt
+//---------------------------------------------------------
+// Added by Tim. p3.3.8
+
+unsigned int Xml::parseUInt()
+ {
+ QString s(parse1().simplified());
+ bool ok;
+ int base = 10;
+ if (s.startsWith("0x") || s.startsWith("0X")) {
+ base = 16;
+ s = s.mid(2);
+ }
+ unsigned int n = s.toUInt(&ok, base);
+ return n;
+ }
+
+//---------------------------------------------------------
+// parseFloat
+//---------------------------------------------------------
+
+float Xml::parseFloat()
+ {
+ QString s(parse1().simplified());
+ return s.toFloat();
+ }
+
+//---------------------------------------------------------
+// parseDouble
+//---------------------------------------------------------
+
+double Xml::parseDouble()
+ {
+ QString s(parse1().simplified());
+ return s.toDouble();
+ }
+
+//---------------------------------------------------------
+// unknown
+//---------------------------------------------------------
+
+void Xml::unknown(const char* s)
+ {
+ printf("%s: unknown tag <%s> at line %d\n",
+ s, _s1.toLatin1().constData(), _line+1);
+ parse1();
+ }
+
+//---------------------------------------------------------
+// header
+//---------------------------------------------------------
+
+void Xml::header()
+ {
+ fprintf(f, "<?xml version=\"1.0\"?>\n");
+ }
+
+//---------------------------------------------------------
+// put
+//---------------------------------------------------------
+
+void Xml::put(const char* format, ...)
+ {
+ va_list args;
+ va_start(args, format);
+
+ vfprintf(f, format, args);
+ va_end(args);
+ putc('\n', f);
+ }
+
+void Xml::put(int level, const char* format, ...)
+ {
+ va_list args;
+ va_start(args, format);
+ putLevel(level);
+ vfprintf(f, format, args);
+ va_end(args);
+ putc('\n', f);
+ }
+
+//---------------------------------------------------------
+// nput
+//---------------------------------------------------------
+
+void Xml::nput(int level, const char* format, ...)
+ {
+ va_list args;
+ va_start(args, format);
+ putLevel(level);
+ vfprintf(f, format, args);
+ va_end(args);
+ }
+
+void Xml::nput(const char* format, ...)
+ {
+ va_list args;
+ va_start(args, format);
+ vfprintf(f, format, args);
+ va_end(args);
+ }
+
+//---------------------------------------------------------
+// tag
+//---------------------------------------------------------
+
+void Xml::tag(int level, const char* format, ...)
+ {
+ va_list args;
+ va_start(args, format);
+ putLevel(level);
+ putc('<', f);
+ vfprintf(f, format, args);
+ va_end(args);
+ putc('>', f);
+ putc('\n', f);
+ }
+
+//---------------------------------------------------------
+// etag
+//---------------------------------------------------------
+
+void Xml::etag(int level, const char* format, ...)
+ {
+ va_list args;
+ va_start(args, format);
+ putLevel(level);
+ putc('<', f);
+ putc('/', f);
+ vfprintf(f, format, args);
+ va_end(args);
+ putc('>', f);
+ putc('\n', f);
+ }
+
+void Xml::putLevel(int n)
+ {
+ for (int i = 0; i < n*2; ++i)
+ putc(' ', f);
+ }
+
+void Xml::intTag(int level, const char* name, int val)
+ {
+ putLevel(level);
+ fprintf(f, "<%s>%d</%s>\n", name, val, name);
+ }
+
+void Xml::uintTag(int level, const char* name, unsigned int val)
+ {
+ putLevel(level);
+ fprintf(f, "<%s>%u</%s>\n", name, val, name);
+ }
+
+void Xml::floatTag(int level, const char* name, float val)
+ {
+ putLevel(level);
+ QString s("<%1>%2</%3>\n");
+ fprintf(f, "%s", s.arg(name).arg(val).arg(name).toLatin1().constData());
+ }
+
+void Xml::doubleTag(int level, const char* name, double val)
+ {
+ putLevel(level);
+ QString s("<%1>%2</%3>\n");
+ fprintf(f, "%s", s.arg(name).arg(val).arg(name).toLatin1().constData());
+ }
+
+void Xml::strTag(int level, const char* name, const char* val)
+ {
+ putLevel(level);
+ fprintf(f, "<%s>", name);
+ if (val) {
+ while (*val) {
+ switch(*val) {
+ case '&': fprintf(f, "&amp;"); break;
+ case '<': fprintf(f, "&lt;"); break;
+ case '>': fprintf(f, "&gt;"); break;
+ case '\\': fprintf(f, "&apos;"); break;
+ case '"': fprintf(f, "&quot;"); break;
+ default: fputc(*val, f); break;
+ }
+ ++val;
+ }
+ }
+ fprintf(f, "</%s>\n", name);
+ }
+
+//---------------------------------------------------------
+// colorTag
+//---------------------------------------------------------
+
+void Xml::colorTag(int level, const char* name, const QColor& color)
+ {
+ putLevel(level);
+ fprintf(f, "<%s r=\"%d\" g=\"%d\" b=\"%d\"></%s>\n",
+ name, color.red(), color.green(), color.blue(), name);
+ }
+
+//---------------------------------------------------------
+// geometryTag
+//---------------------------------------------------------
+
+void Xml::geometryTag(int level, const char* name, const QWidget* g)
+ {
+ qrectTag(level, name, QRect(g->pos(), g->size()));
+ }
+
+//---------------------------------------------------------
+// qrectTag
+//---------------------------------------------------------
+
+void Xml::qrectTag(int level, const char* name, const QRect& r)
+ {
+ putLevel(level);
+ fprintf(f, "<%s x=\"%d\" y=\"%d\" w=\"%d\" h=\"%d\"></%s>\n",
+ name, r.x(), r.y(), r.width(), r.height(), name);
+ }
+
+//---------------------------------------------------------
+// strTag
+//---------------------------------------------------------
+
+void Xml::strTag(int level, const char* name, const QString& val)
+ {
+ strTag(level, name, val.toLatin1().constData());
+ }
+
+//---------------------------------------------------------
+// Xml::skip
+//---------------------------------------------------------
+
+void Xml::skip(const QString& etag)
+ {
+ for (;;) {
+ Token token = parse();
+ const QString& tag = s1();
+ switch (token) {
+ case Xml::Error:
+ case Xml::End:
+ return;
+ case Xml::Text:
+ break;
+ case Xml::TagEnd:
+ if (tag == etag)
+ return;
+ break;
+ case Xml::TagStart:
+ skip(tag);
+ break;
+ default:
+ break;
+ }
+ }
+ }
+
+//---------------------------------------------------------
+// xmlString
+//---------------------------------------------------------
+
+QString Xml::xmlString(const char* s)
+ {
+ return Xml::xmlString(QString(s));
+ }
+
+//---------------------------------------------------------
+// xmlString
+//---------------------------------------------------------
+
+QString Xml::xmlString(const QString& ss)
+ {
+ QString s(ss);
+ s.replace('&', "&amp;");
+ s.replace('<', "&lt;");
+ s.replace('>', "&gt;");
+ s.replace('\'', "&apos;");
+ s.replace('"', "&quot;");
+ return s;
+ }
+
+void Xml::dump(QString &dump)
+ {
+ if (f == 0)
+ return;
+ fpos_t pos;
+ fgetpos(f, &pos);
+ rewind(f);
+ while(fgets(lbuffer, 512, f) != 0)
+ dump.append(lbuffer);
+ fsetpos(f, &pos);
+ }
diff --git a/attic/muse2-oom/muse2/muse/xml.h b/attic/muse2-oom/muse2/muse/xml.h
new file mode 100644
index 00000000..646c1a12
--- /dev/null
+++ b/attic/muse2-oom/muse2/muse/xml.h
@@ -0,0 +1,96 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: xml.h,v 1.8.2.3 2009/11/09 20:28:28 terminator356 Exp $
+//
+// (C) Copyright 2000 Werner Schweer (ws@seh.de)
+//=========================================================
+
+#ifndef __XML_H__
+#define __XML_H__
+
+#include <stdio.h>
+
+#include <QString>
+
+class QColor;
+class QRect;
+class QWidget;
+
+//---------------------------------------------------------
+// Xml
+// very simple XML-like parser
+//---------------------------------------------------------
+
+class Xml {
+ FILE* f;
+ int _line;
+ int _col;
+ QString _s1, _s2, _tag;
+ int level;
+ bool inTag;
+ bool inComment;
+ int _minorVersion;
+ int _majorVersion;
+
+ int c; // current char
+ char lbuffer[512];
+ const char* bufptr;
+
+ void next();
+ void nextc();
+ void token(int);
+ void stoken();
+ QString strip(const QString& s);
+ void putLevel(int n);
+
+ public:
+ enum Token {Error, TagStart, TagEnd, Flag,
+ Proc, Text, Attribut, End};
+ int majorVersion() const { return _majorVersion; }
+ int minorVersion() const { return _minorVersion; }
+ void setVersion(int maj, int min) {
+ _minorVersion = min;
+ _majorVersion = maj;
+ }
+ Xml(FILE*);
+ Xml(const char*);
+ Token parse();
+ QString parse(const QString&);
+ QString parse1();
+ int parseInt();
+ unsigned int parseUInt();
+ float parseFloat();
+ double parseDouble();
+ void unknown(const char*);
+ int line() const { return _line; } // current line
+ int col() const { return _col; } // current col
+ const QString& s1() { return _s1; }
+ const QString& s2() { return _s2; }
+ void dump(QString &dump);
+
+ void header();
+ void put(const char* format, ...);
+ void put(int level, const char* format, ...);
+ void nput(int level, const char* format, ...);
+ void nput(const char* format, ...);
+ void tag(int level, const char* format, ...);
+ void etag(int level, const char* format, ...);
+ void intTag(int level, const char* const name, int val);
+ void uintTag(int level, const char* const name, unsigned int val);
+ void doubleTag(int level, const char* const name, double val);
+ void floatTag(int level, const char* const name, float val);
+ void strTag(int level, const char* const name, const char* val);
+ void strTag(int level, const char* const name, const QString& s);
+ void colorTag(int level, const char* name, const QColor& color);
+ void geometryTag(int level, const char* name, const QWidget* g);
+ void qrectTag(int level, const char* name, const QRect& r);
+ static QString xmlString(const QString&);
+ static QString xmlString(const char*);
+
+ void skip(const QString& tag);
+ };
+
+extern QRect readGeometry(Xml&, const QString&);
+#endif
+