An audio player for macOS 10.8 and newer. https://kode54.net/cog
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.

175 lines
5.3KB

  1. /* _______ ____ __ ___ ___
  2. * \ _ \ \ / \ / \ \ / / ' ' '
  3. * | | \ \ | | || | \/ | . .
  4. * | | | | | | || ||\ /| |
  5. * | | | | | | || || \/ | | ' ' '
  6. * | | | | | | || || | | . .
  7. * | |_/ / \ \__// || | |
  8. * /_______/ynamic \____/niversal /__\ /____\usic /| . . ibliotheque
  9. * / \
  10. * / . \
  11. * ptmeffect.c - Code for converting PTM / / \ \
  12. * effects to IT effects. | < / \_
  13. * | \/ /\ /
  14. * By Christopher Snowhill. Based on xmeffect.c \_ / > /
  15. * by Julien Cugniere. | \ / /
  16. * | ' /
  17. * \__/
  18. */
  19. #include <stdlib.h>
  20. #include <string.h>
  21. #include "dumb.h"
  22. #include "internal/it.h"
  23. void _dumb_it_ptm_convert_effect(int effect, int value, IT_ENTRY *entry) {
  24. if (effect >= PTM_N_EFFECTS)
  25. return;
  26. /* Linearisation of the effect number... */
  27. if (effect == PTM_E) {
  28. effect = PTM_EBASE + HIGH(value);
  29. value = LOW(value);
  30. }
  31. /* convert effect */
  32. entry->mask |= IT_ENTRY_EFFECT;
  33. switch (effect) {
  34. case PTM_APPREGIO:
  35. effect = IT_ARPEGGIO;
  36. break;
  37. case PTM_PORTAMENTO_UP:
  38. effect = IT_PORTAMENTO_UP;
  39. break;
  40. case PTM_PORTAMENTO_DOWN:
  41. effect = IT_PORTAMENTO_DOWN;
  42. break;
  43. case PTM_TONE_PORTAMENTO:
  44. effect = IT_TONE_PORTAMENTO;
  45. break;
  46. case PTM_VIBRATO:
  47. effect = IT_VIBRATO;
  48. break;
  49. case PTM_VOLSLIDE_TONEPORTA:
  50. effect = IT_VOLSLIDE_TONEPORTA;
  51. break;
  52. case PTM_VOLSLIDE_VIBRATO:
  53. effect = IT_VOLSLIDE_VIBRATO;
  54. break;
  55. case PTM_TREMOLO:
  56. effect = IT_TREMOLO;
  57. break;
  58. case PTM_SAMPLE_OFFSET:
  59. effect = IT_SET_SAMPLE_OFFSET;
  60. break;
  61. case PTM_VOLUME_SLIDE:
  62. effect = IT_VOLUME_SLIDE;
  63. break;
  64. case PTM_POSITION_JUMP:
  65. effect = IT_JUMP_TO_ORDER;
  66. break;
  67. case PTM_SET_CHANNEL_VOLUME:
  68. effect = IT_SET_CHANNEL_VOLUME;
  69. break;
  70. case PTM_PATTERN_BREAK:
  71. effect = IT_BREAK_TO_ROW;
  72. break;
  73. case PTM_SET_GLOBAL_VOLUME:
  74. effect = IT_SET_GLOBAL_VOLUME;
  75. break;
  76. case PTM_RETRIGGER:
  77. effect = IT_RETRIGGER_NOTE;
  78. break;
  79. case PTM_FINE_VIBRATO:
  80. effect = IT_FINE_VIBRATO;
  81. break;
  82. /* TODO properly */
  83. case PTM_NOTE_SLIDE_UP:
  84. effect = IT_PTM_NOTE_SLIDE_UP;
  85. break;
  86. case PTM_NOTE_SLIDE_DOWN:
  87. effect = IT_PTM_NOTE_SLIDE_DOWN;
  88. break;
  89. case PTM_NOTE_SLIDE_UP_RETRIG:
  90. effect = IT_PTM_NOTE_SLIDE_UP_RETRIG;
  91. break;
  92. case PTM_NOTE_SLIDE_DOWN_RETRIG:
  93. effect = IT_PTM_NOTE_SLIDE_DOWN_RETRIG;
  94. break;
  95. case PTM_SET_TEMPO_BPM:
  96. effect = (value < 0x20) ? (IT_SET_SPEED) : (IT_SET_SONG_TEMPO);
  97. break;
  98. case PTM_EBASE + PTM_E_SET_FINETUNE:
  99. effect = SBASE + IT_S_FINETUNE;
  100. break; /** TODO */
  101. case PTM_EBASE + PTM_E_SET_LOOP:
  102. effect = SBASE + IT_S_PATTERN_LOOP;
  103. break;
  104. case PTM_EBASE + PTM_E_NOTE_CUT:
  105. effect = SBASE + IT_S_DELAYED_NOTE_CUT;
  106. break;
  107. case PTM_EBASE + PTM_E_NOTE_DELAY:
  108. effect = SBASE + IT_S_NOTE_DELAY;
  109. break;
  110. case PTM_EBASE + PTM_E_PATTERN_DELAY:
  111. effect = SBASE + IT_S_PATTERN_DELAY;
  112. break;
  113. case PTM_EBASE + PTM_E_SET_PANNING:
  114. effect = SBASE + IT_S_SET_PAN;
  115. break;
  116. case PTM_EBASE + PTM_E_FINE_VOLSLIDE_UP:
  117. effect = IT_VOLUME_SLIDE;
  118. value = EFFECT_VALUE(value, 0xF);
  119. break;
  120. case PTM_EBASE + PTM_E_FINE_VOLSLIDE_DOWN:
  121. effect = IT_VOLUME_SLIDE;
  122. value = EFFECT_VALUE(0xF, value);
  123. break;
  124. case PTM_EBASE + PTM_E_FINE_PORTA_UP:
  125. effect = IT_PORTAMENTO_UP;
  126. value = EFFECT_VALUE(0xF, value);
  127. break;
  128. case PTM_EBASE + PTM_E_FINE_PORTA_DOWN:
  129. effect = IT_PORTAMENTO_DOWN;
  130. value = EFFECT_VALUE(0xF, value);
  131. break;
  132. case PTM_EBASE + PTM_E_RETRIG_NOTE:
  133. effect = IT_XM_RETRIGGER_NOTE;
  134. value = EFFECT_VALUE(0, value);
  135. break;
  136. case PTM_EBASE + PTM_E_SET_VIBRATO_CONTROL:
  137. effect = SBASE + IT_S_SET_VIBRATO_WAVEFORM;
  138. value &= ~4; /** TODO: value&4 -> don't retrig wave */
  139. break;
  140. case PTM_EBASE + PTM_E_SET_TREMOLO_CONTROL:
  141. effect = SBASE + IT_S_SET_TREMOLO_WAVEFORM;
  142. value &= ~4; /** TODO: value&4 -> don't retrig wave */
  143. break;
  144. default:
  145. /* user effect (often used in demos for synchronisation) */
  146. entry->mask &= ~IT_ENTRY_EFFECT;
  147. }
  148. /* Inverse linearisation... */
  149. if (effect >= SBASE && effect < SBASE + 16) {
  150. value = EFFECT_VALUE(effect - SBASE, value);
  151. effect = IT_S;
  152. }
  153. entry->effect = effect;
  154. entry->effectvalue = value;
  155. }