3 # This script edits the Ardour source code to change all references to "audio frames" into "audio samples". We skip 3rd party and special libraries,
4 # and after the global edit do a bunch of per-file fixups for things that the global edit can't take care of.
6 # This was written so that it can be run after merging various PRs and development branches in the near term (July 2017) future.
8 # It also reveals just how confusing this naming "scheme" was.
10 grep_blacklist="qm-dsp/ build/ appleutility/ fluidsynth/ hidapi/ fst/ lua/ vamp-plugins/ ltc/ vfork/ ltc_file_reader.cc ltc_file_reader.h"
12 files=`find . -name \*.cc -o -name \*.h -o -name \*.c`
18 for b in $grep_blacklist ; do
19 if echo $f | grep -sq $b ; then
24 if [ $skip -eq 1 ] ; then
29 echo Processing $f ...
31 # Three sets of transformations:
32 # The first changes all instances of "frames" etc. that need to remain in place. They get temporarily converted to FROOME.
33 # Then we do the global frame->sample substitution.
34 # Then we change FROOME back to frame etc.
37 -e 's/gtkmm\/frame\.h/gtkmm\/FROOME.h/g' \
38 -e 's/video_image_frame/video_image_FROOME/g' \
39 -e 's/subframes_per_frame/subframes_per_FROOME/g' \
40 -e 's/per_timecode_frame/per_timecode_FROOME/g' \
41 -e 's/frames_per_hour/FROOMES_per_hour/g' \
42 -e 's/frames_per_second/FROOMES_per_second/g' \
43 -e 's/drop_frames/drop_FROOMES/g' \
44 -e 's/sync_frame_rate/sync_FROOME_rate/g' \
45 -e 's/frame-rate/FROOME-rate/g' \
46 -e 's/frame rate/FROOME rate/g' \
47 -e 's/video frame/video FROOME/g' \
48 -e 's/video_frame/video_FROOME/g' \
49 -e 's/video-frame/video-FROOME/g' \
50 -e 's/timecode frame/timecode FROOME/g' \
51 -e 's/timecode_frame/timecode_FROOME/g' \
52 -e 's/timecode\.frame/timecode.FROOME/g' \
53 -e 's/time\.frames/time.FROOMES/g' \
54 -e 's/info\.frames/info.FROOMES/g' \
55 -e 's/per_ltc_frame/per_ltc_FROOME/g' \
56 -e 's/frame"/FROOME"/g' \
57 -e 's/quarter_frame/quarter_FROOME/g' \
58 -e 's/quarter frame/quarter FROOME/g' \
59 -e 's/quarter-frame/quarter-FROOME/g' \
60 -e 's/put_frames/put_FROOMES/g' \
61 -e 's/bound_frame/bound_FROOME/g' \
62 -e 's/mtc_frame/mtc_FROOME/g' \
63 -e 's/self->frame/self->FROOME/g' \
64 -e 's/_time\.frames/_time.FROOMES/g' \
65 -e 's/(jack[a-z_][a-z_]*)frame/\1FROOME/g' \
66 -e 's/tc([a-z_][a-z_]*)\.frame/tc\1.FROOME/g' \
67 -e 's/([tT][cC])\.frame/\1.FROOME/g' \
68 -e 's/framepos_sec/FROOMEpos_sec/g' \
69 -e 's/Timecode_Frames/Timecode_FROOMES/g' \
70 -e 's/frames_floor/FROOMES_floot/g' \
72 -e 's/AudioFrames/Samples/g' \
73 -e 's/Frames/Samples/g' \
74 -e 's/MusicFrame/MusicSample/g' \
75 -e 's/([^a-zA-Z]|^)frame$/\1sample/g' \
76 -e 's/([^a-zA-Z]|^)frames$/\1samples/g' \
77 -e 's/([^a-zA-Z]|^)frames([^a-zA-Z])/\1samples\2/g' \
78 -e 's/([^a-zA-Z]|^)frame([^a-zA-Z])/\1sample\2/g' \
79 -e 's/([^a-zA-Z]|^)framepos([^a-zA-Z])/\1samplepos\2/g' \
80 -e 's/([^a-zA-Z]|^)Framepos([^a-zA-Z])/\1Samplepos\2/g' \
81 -e 's/([^a-zA-Z]|^)framecnt([^a-zA-Z])/\1samplecnt\2/g' \
82 -e 's/([^a-zA-Z]|^)frameoffset([^a-zA-Z])/\1sampleoffset\2/g' \
84 -e 's/FFROOMES/Frames/g' \
85 -e 's/FROOMES/frames/g' \
86 -e 's/FROOME/frame/g' \
91 sed -i -E -e 's/([^_])samples/\1frames/g' -e 's/samples;/frames;/' libs/timecode/timecode/time.h
92 sed -i -E -e 's/>sample([^a-z])/>frame\1/' -e 's/\.sample([^a-z])/.frame\1/' -e 's/engine\.frame/engine.sample/g' libs/backends/jack/jack_audiobackend.cc
93 sed -i -E -e 's/\.samples/.frames/g' libs/timecode/src/time.cc
94 sed -i -E -e 's/"samples"/"frames"/g' -e 's/Time::samples\)/Time::frames)/g' -e 's/sample2/frame2/g' libs/ardour/luabindings.cc
95 sed -i -E -e 's/framecnt_t/samplecnt_t/' libs/ardour/ardour/ltc_file_reader.h
96 sed -i -E -e 's/sample_units/frame_units/g' \
97 -e 's/sample_tens/frame_tens/g' \
98 -e 's/ltc_sample/ltc_frame/g' \
99 -e 's/equal_ltc_frame_time/equal_ltc_sample_time/g' \
100 -e 's/stime\.sample/stime.frame/g' \
101 -e 's/([^a-z_])ltc_sample([^a-z_])/\1ltc_frame\2/g' \
102 -e 's/last_ltc_frame/last_ltc_sample/g' \
103 -e 's/ltc_sample_alignment/ltc_frame_alignment/g' \
104 libs/ardour/ltc_slave.cc
105 sed -i -E -e 's/equal_ltc_frame_time/equal_ltc_sample_time/g' libs/ardour/ardour/slave.h
106 sed -i -E -e 's/ltc_sample_alignment/ltc_frame_alignment/g' -e 's/ltc_encoder_([sg])et_sample/ltc_encoder_\1et_frame/g' libs/ardour/session_ltc.cc
107 sed -i -E -e 's/>samples/>frames/g' libs/ardour/lv2_evbuf.c
108 sed -i -E -e 's/t.samples/t.frames/g' libs/ardour/session_vst.cc
109 sed -i -E -e 's/>frame/>sample/g' -e 's/forge_sample_time/forge_frame_time/g' libs/plugins/a-fluidsynth.lv2/a-fluidsynth.cc
110 sed -i -E -e 's/Samples,$/S_Samples,/g' gtk2_ardour/audio_clock.h
111 sed -i -E -e 's/adj_sample\.frame/adj_sample.sample/g' gtk2_ardour/editor_drag.cc
112 sed -i -E -e 's/frame, track_speed/sample, track_speed/' gtk2_ardour/editor_ops.cc
113 sed -i -E -e 's/timediff\.samples/timediff.frames/' gtk2_ardour/editor_drag.cc
114 sed -i -E -e 's/time\.frames/time.samples/' gtk2_ardour/export_format_dialog.cc
115 sed -i -E -e 's/sample\.frame/sample.sample/g' gtk2_ardour/region_view.cc
117 git mv libs/ardour/beats_frames_converter.cc libs/ardour/beats_samples_converter.cc
118 git mv libs/ardour/ardour/beats_frames_converter.h libs/ardour/ardour/beats_samples_converter.h
119 sed -i -E -e 's/beats_frames_/beats_samples_/' libs/ardour/wscript
121 # editor hacking for leftmost
123 sed -i -E -e 's/leftmost_sample;/_leftmost_sample;/' gtk2_ardour/editor.h
124 sed -i -E -e 's/, leftmost_sample \(/, _leftmost_sample (/' gtk2_ardour/editor.cc
125 for f in gtk2_ardour/editor*.cc ; do
126 sed -i -E -e 's/leftmost_sample( ?\()/leftmost_CALL\1/g' -e 's/leftmost_sample/_leftmost_sample/g' -e 's/leftmost_CALL/leftmost_sample/g' $f
129 # audio clock hack (context dependent edit, so sed can't do it)
132 --- gtk2_ardour/audio_clock.cc~ 2017-07-15 10:40:44.394569157 -0400
133 +++ gtk2_ardour/audio_clock.cc 2017-07-15 11:36:41.997873534 -0400
136 return edit_string.substr (8, 4);
143 @@ -1510,7 +1510,7 @@
152 @@ -1774,7 +1774,7 @@
153 f = (samplecnt_t) floor (_session->sample_rate() / _session->timecode_frames_per_second());
163 # add a hack to the enums table
166 --- libs/ardour/enums.cc~ 2017-07-15 12:16:09.507761761 -0400
167 +++ libs/ardour/enums.cc 2017-07-15 12:16:20.471847339 -0400
169 #define REGISTER_ENUM(e) i.push_back (e); s.push_back (#e)
170 #define REGISTER_CLASS_ENUM(t,e) i.push_back (t::e); s.push_back (#e)
172 + /* in mid-2017 the entire code base was changed to use "samples"
173 + instead of frames, which included several enums. This hack table
174 + entry will catch all of them.
176 + enum_writer.add_to_hack_table ("Frames", "Samples");
178 REGISTER_ENUM (NullAutomation);
179 REGISTER_ENUM (GainAutomation);
180 REGISTER_ENUM (PanAzimuthAutomation);