mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

322 lines
12 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/package/clifford/mixmagic/pitch.patch
  9. # ROCK Linux is Copyright (C) 1998 - 2005 Clifford Wolf
  10. #
  11. # This patch file is dual-licensed. It is available under the license the
  12. # patched project is licensed under, as long as it is an OpenSource license
  13. # as defined at http://www.opensource.org/ (e.g. BSD, X11) or under the terms
  14. # of the GNU General Public License as published by the Free Software
  15. # Foundation; either version 2 of the License, or (at your option) any later
  16. # version.
  17. #
  18. # --- ROCK-COPYRIGHT-NOTE-END ---
  19. This patch adds pitch shifting to mixmagic. (by Clifford)
  20. --- ./src/block.c.orig Sat Mar 9 11:06:32 2002
  21. +++ ./src/block.c Mon May 13 20:16:56 2002
  22. @@ -834,6 +834,7 @@
  23. b->start = block->start + MIN (block->selection_start, block->selection_end);
  24. b->length = ABS (block->selection_start - block->selection_end);
  25. + block->length_unpitched = block->length * block->pitch;
  26. b->sample = sample_ref (block->sample);
  27. b->position = block->position + MIN (block->selection_start, block->selection_end);
  28. @@ -1143,6 +1144,8 @@
  29. newBlock->sample = sample_ref (block->sample);
  30. newBlock->start = block->start;
  31. newBlock->length = block->length;
  32. + newBlock->length_unpitched = block->length_unpitched;
  33. + newBlock->pitch = block->pitch;
  34. /* Position it on the same place as the popup menu */
  35. newBlock->position = block->position;
  36. @@ -1183,8 +1186,8 @@
  37. block_draw (Block *block)
  38. {
  39. gint i, width, height;
  40. - gint offset, value;
  41. - GString * start_gs , * len_gs ;
  42. + gint offset, offset_start, value;
  43. + GString * start_gs , * len_gs , * pitch_gs;
  44. g_assert (IS_BLOCK(block));
  45. @@ -1210,11 +1213,13 @@
  46. width,
  47. height);
  48. - offset = block->start / INDEX_RATIO;
  49. + offset_start = block->start / INDEX_RATIO;
  50. + offset = 0;
  51. for (i = 0; i < width;i++) {
  52. value = index_get_average (block->sample->index,
  53. - offset, block->start / INDEX_RATIO,
  54. + offset_start + offset * block->pitch,
  55. + block->start / INDEX_RATIO,
  56. block->track->song->x_scale / INDEX_RATIO,
  57. block->sample->length / INDEX_RATIO / 2) / ((float)0x7f / height);
  58. gdk_draw_line (block->pixmap,
  59. @@ -1254,13 +1259,42 @@
  60. /* Draw title */
  61. + gdk_draw_text (block->pixmap,
  62. + GTK_WIDGET(block)->style->font,
  63. + GTK_WIDGET(block)->style->fg_gc[GTK_WIDGET(block)->state],
  64. + 10, 15,
  65. + "F:",
  66. + 2);
  67. +
  68. gdk_draw_text (block->pixmap,
  69. GTK_WIDGET(block)->style->font,
  70. GTK_WIDGET(block)->style->fg_gc[GTK_WIDGET(block)->state],
  71. - 0, 10,
  72. + 25, 15,
  73. block->sample->id,
  74. strlen (block->sample->id));
  75. + /* Draw Pitch Value */
  76. +
  77. + pitch_gs = g_string_sized_new(20);
  78. +
  79. + pitch_gs->len = g_snprintf(pitch_gs->str, 20, "%c%02d.%02d %%",
  80. + block->pitch == 0 ? '0' : (block->pitch > 0 ? '+' : '-'),
  81. + abs(block->pitch*10000 - 10000) / 100,
  82. + abs(block->pitch*10000 - 10000) % 100);
  83. +
  84. + gdk_draw_text (block->pixmap,
  85. + GTK_WIDGET(block)->style->font,
  86. + GTK_WIDGET(block)->style->fg_gc[GTK_WIDGET(block)->state],
  87. + 10, 30,
  88. + "P:",
  89. + 2);
  90. +
  91. + gdk_draw_text (block->pixmap,
  92. + GTK_WIDGET(block)->style->font,
  93. + GTK_WIDGET(block)->style->fg_gc[GTK_WIDGET(block)->state],
  94. + 25, 30,
  95. + pitch_gs->str,
  96. + pitch_gs->len);
  97. /* Draw start time */
  98. @@ -1281,14 +1315,14 @@
  99. gdk_draw_text (block->pixmap,
  100. GTK_WIDGET(block)->style->font,
  101. GTK_WIDGET(block)->style->fg_gc[GTK_WIDGET(block)->state],
  102. - 0, height - 20,
  103. + 10, height - 20,
  104. "S:",
  105. 2);
  106. gdk_draw_text (block->pixmap,
  107. GTK_WIDGET(block)->style->font,
  108. GTK_WIDGET(block)->style->fg_gc[GTK_WIDGET(block)->state],
  109. - 15, height - 20,
  110. + 25, height - 20,
  111. start_gs->str,
  112. start_gs->len);
  113. @@ -1313,14 +1347,14 @@
  114. gdk_draw_text (block->pixmap,
  115. GTK_WIDGET(block)->style->font,
  116. GTK_WIDGET(block)->style->fg_gc[GTK_WIDGET(block)->state],
  117. - 0, height - 5,
  118. + 10, height - 5,
  119. "L:",
  120. 2);
  121. gdk_draw_text (block->pixmap,
  122. GTK_WIDGET(block)->style->font,
  123. GTK_WIDGET(block)->style->fg_gc[GTK_WIDGET(block)->state],
  124. - 15, height - 5,
  125. + 25, height - 5,
  126. len_gs->str,
  127. len_gs->len);
  128. @@ -1481,6 +1515,73 @@
  129. gtk_widget_draw (GTK_WIDGET (block), NULL);
  130. }
  131. +static void block_set_pitch (GtkWidget *widget, Block *block, gfloat newpitch) {
  132. + block->pitch = newpitch;
  133. + block->length = block->length_unpitched / newpitch;
  134. + block_update (block);
  135. + song_set_dirty (block->track->song, TRUE);
  136. +}
  137. +
  138. +static void block_dec_pitch_1 (GtkWidget *widget, Block *block)
  139. + { block_set_pitch (widget, block, block->pitch - 0.0001); }
  140. +
  141. +static void block_dec_pitch_3 (GtkWidget *widget, Block *block)
  142. + { block_set_pitch (widget, block, block->pitch - 0.0003); }
  143. +
  144. +static void block_dec_pitch_5 (GtkWidget *widget, Block *block)
  145. + { block_set_pitch (widget, block, block->pitch - 0.0005); }
  146. +
  147. +static void block_dec_pitch_10 (GtkWidget *widget, Block *block)
  148. + { block_set_pitch (widget, block, block->pitch - 0.0010); }
  149. +
  150. +static void block_dec_pitch_30 (GtkWidget *widget, Block *block)
  151. + { block_set_pitch (widget, block, block->pitch - 0.0030); }
  152. +
  153. +static void block_dec_pitch_50 (GtkWidget *widget, Block *block)
  154. + { block_set_pitch (widget, block, block->pitch - 0.0050); }
  155. +
  156. +static void block_dec_pitch_100 (GtkWidget *widget, Block *block)
  157. + { block_set_pitch (widget, block, block->pitch - 0.0100); }
  158. +
  159. +static void block_dec_pitch_300 (GtkWidget *widget, Block *block)
  160. + { block_set_pitch (widget, block, block->pitch - 0.0300); }
  161. +
  162. +static void block_dec_pitch_500 (GtkWidget *widget, Block *block)
  163. + { block_set_pitch (widget, block, block->pitch - 0.0500); }
  164. +
  165. +
  166. +static void block_pitch_reset (GtkWidget *widget, Block *block)
  167. + { block_set_pitch (widget, block, 1); }
  168. +
  169. +
  170. +static void block_inc_pitch_1 (GtkWidget *widget, Block *block)
  171. + { block_set_pitch (widget, block, block->pitch + 0.0001); }
  172. +
  173. +static void block_inc_pitch_3 (GtkWidget *widget, Block *block)
  174. + { block_set_pitch (widget, block, block->pitch + 0.0003); }
  175. +
  176. +static void block_inc_pitch_5 (GtkWidget *widget, Block *block)
  177. + { block_set_pitch (widget, block, block->pitch + 0.0005); }
  178. +
  179. +static void block_inc_pitch_10 (GtkWidget *widget, Block *block)
  180. + { block_set_pitch (widget, block, block->pitch + 0.0010); }
  181. +
  182. +static void block_inc_pitch_30 (GtkWidget *widget, Block *block)
  183. + { block_set_pitch (widget, block, block->pitch + 0.0030); }
  184. +
  185. +static void block_inc_pitch_50 (GtkWidget *widget, Block *block)
  186. + { block_set_pitch (widget, block, block->pitch + 0.0050); }
  187. +
  188. +static void block_inc_pitch_100 (GtkWidget *widget, Block *block)
  189. + { block_set_pitch (widget, block, block->pitch + 0.0100); }
  190. +
  191. +static void block_inc_pitch_300 (GtkWidget *widget, Block *block)
  192. + { block_set_pitch (widget, block, block->pitch + 0.0300); }
  193. +
  194. +static void block_inc_pitch_500 (GtkWidget *widget, Block *block)
  195. + { block_set_pitch (widget, block, block->pitch + 0.0500); }
  196. +
  197. +
  198. static void
  199. block_select_all (GtkWidget *widget, Block *block)
  200. {
  201. @@ -1534,6 +1635,26 @@
  202. GNOMEUIINFO_SEPARATOR,
  203. GNOMEUIINFO_ITEM_NONE (N_("Convert to loopblock"), N_("Convert to loopblock"), block_convert_to_loopblock),
  204. GNOMEUIINFO_SEPARATOR,
  205. + GNOMEUIINFO_ITEM_NONE (N_("Pitch -5.00"), N_(""), block_dec_pitch_500),
  206. + GNOMEUIINFO_ITEM_NONE (N_("Pitch -3.00"), N_(""), block_dec_pitch_300),
  207. + GNOMEUIINFO_ITEM_NONE (N_("Pitch -1.00"), N_(""), block_dec_pitch_100),
  208. + GNOMEUIINFO_ITEM_NONE (N_("Pitch -0.50"), N_(""), block_dec_pitch_50),
  209. + GNOMEUIINFO_ITEM_NONE (N_("Pitch -0.30"), N_(""), block_dec_pitch_30),
  210. + GNOMEUIINFO_ITEM_NONE (N_("Pitch -0.10"), N_(""), block_dec_pitch_10),
  211. + GNOMEUIINFO_ITEM_NONE (N_("Pitch -0.05"), N_(""), block_dec_pitch_5),
  212. + GNOMEUIINFO_ITEM_NONE (N_("Pitch -0.03"), N_(""), block_dec_pitch_3),
  213. + GNOMEUIINFO_ITEM_NONE (N_("Pitch -0.01"), N_(""), block_dec_pitch_1),
  214. + GNOMEUIINFO_ITEM_NONE (N_("Reset Pitch"), N_(""), block_pitch_reset),
  215. + GNOMEUIINFO_ITEM_NONE (N_("Pitch +0.01"), N_(""), block_inc_pitch_1),
  216. + GNOMEUIINFO_ITEM_NONE (N_("Pitch +0.03"), N_(""), block_inc_pitch_3),
  217. + GNOMEUIINFO_ITEM_NONE (N_("Pitch +0.05"), N_(""), block_inc_pitch_5),
  218. + GNOMEUIINFO_ITEM_NONE (N_("Pitch +0.10"), N_(""), block_inc_pitch_10),
  219. + GNOMEUIINFO_ITEM_NONE (N_("Pitch +0.30"), N_(""), block_inc_pitch_30),
  220. + GNOMEUIINFO_ITEM_NONE (N_("Pitch +0.50"), N_(""), block_inc_pitch_50),
  221. + GNOMEUIINFO_ITEM_NONE (N_("Pitch +1.00"), N_(""), block_inc_pitch_100),
  222. + GNOMEUIINFO_ITEM_NONE (N_("Pitch +3.00"), N_(""), block_inc_pitch_300),
  223. + GNOMEUIINFO_ITEM_NONE (N_("Pitch +5.00"), N_(""), block_inc_pitch_500),
  224. + GNOMEUIINFO_SEPARATOR,
  225. GNOMEUIINFO_ITEM_NONE (N_("Select all"), N_("Make the selection cover the whole block"), block_select_all),
  226. GNOMEUIINFO_END
  227. };
  228. @@ -1640,24 +1761,30 @@
  229. mix_into_buffer (Block *block, gint16 *buffer, gint position, gint length)
  230. {
  231. gint16 *data;
  232. - gint i;
  233. + gint i, data_offset, data_xoffset;
  234. - data = (gint16 *)(block->sample->data +
  235. - (block->start + position - block->position) * block->sample->byte_p_spl);
  236. -
  237. - for (i = 0;i < length / (sizeof (guint16) * 2);i++) {
  238. + data = (gint16 *)(block->sample->data +
  239. + (block->start - block->position) *
  240. + block->sample->byte_p_spl);
  241. + data_offset = position;
  242. +
  243. + for (i = 0; i < length / (sizeof (guint16) * 2); i++) {
  244. +
  245. + data_xoffset = data_offset * block->pitch;
  246. + data_xoffset *= block->sample->num_channels;
  247. mixer_mix_sample_into_buffer (buffer,
  248. - data,
  249. + data + data_xoffset,
  250. block->amp_env,
  251. block->pan_env,
  252. block->track->amp,
  253. block->track->pan,
  254. - position - block->position + i, block->sample->num_channels);
  255. + position - block->position + i,
  256. + block->sample->num_channels);
  257. - data += block->sample->num_channels;
  258. + data_offset++;
  259. buffer += 2;
  260. }
  261. }
  262. /*
  263. @@ -1675,8 +1813,11 @@
  264. block->start = atoi ((ptr = xmlGetProp (node, "start")));
  265. g_free (ptr);
  266. - block->length = atoi ((ptr = xmlGetProp (node, "length")));
  267. + block->length_unpitched = atoi ((ptr = xmlGetProp (node, "length")));
  268. g_free (ptr);
  269. + block->pitch = (float)atoi ((ptr = xmlGetProp (node, "pitch"))) / 10000;
  270. + g_free (ptr);
  271. + block->length = (float)block->length_unpitched * block->pitch;
  272. block->position = atoi ((ptr = xmlGetProp (node, "position")));
  273. g_free (ptr);
  274. ptr = xmlGetProp (node, "sample");
  275. --- ./src/track.c.orig Tue Mar 12 06:39:42 2002
  276. +++ ./src/track.c Mon Mar 11 20:53:32 2002
  277. @@ -328,6 +328,8 @@
  278. block->start = 0;
  279. block->length = sample_get_length(block->sample);
  280. + block->length_unpitched = sample_get_length(block->sample);
  281. + block->pitch=1;
  282. /* Position it on the same place as the popup menu */
  283. block->position = (x + (gint)(GTK_LAYOUT (track->layout)->hadjustment->value)) * track->song->x_scale;
  284. --- ./src/block.h.orig Mon Mar 11 20:47:57 2002
  285. +++ ./src/block.h Mon Mar 11 20:37:16 2002
  286. @@ -89,6 +89,9 @@
  287. gint length; /* The length of this block */
  288. gint position; /* Position in time */
  289. + gfloat pitch; /* Pitch shifting (in %) */
  290. + gint length_unpitched; /* The length before pitch is applied */
  291. +
  292. Sample *sample; /* The sample assosiated with this block */
  293. GList *amp_env; /* Pointer to this blocks amplitude envelope or NULL */