musictunes.c 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. /*
  2. * This file is part of the MicroPython project, http://micropython.org/
  3. *
  4. * The music encoded herein is either in the public domain, composed by
  5. * Nicholas H.Tollervey or the composer is untraceable and covered by fair
  6. * (educational) use.
  7. *
  8. * The MIT License (MIT)
  9. *
  10. * Copyright (c) 2015 Damien P. George
  11. * Copyright (c) 2015 Nicholas H. Tollervey
  12. *
  13. * Permission is hereby granted, free of charge, to any person obtaining a copy
  14. * of this software and associated documentation files (the "Software"), to deal
  15. * in the Software without restriction, including without limitation the rights
  16. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  17. * copies of the Software, and to permit persons to whom the Software is
  18. * furnished to do so, subject to the following conditions:
  19. *
  20. * The above copyright notice and this permission notice shall be included in
  21. * all copies or substantial portions of the Software.
  22. *
  23. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  24. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  25. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  26. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  27. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  28. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  29. * THE SOFTWARE.
  30. */
  31. #include "py/mphal.h"
  32. #include "py/objtuple.h"
  33. #if MICROPY_PY_MUSIC
  34. #define N(q) MP_ROM_QSTR(MP_QSTR_ ## q)
  35. #define T(name, ...) \
  36. typedef struct music_tune_ ## name ## _s {\
  37. mp_obj_base_t base; \
  38. size_t len; \
  39. mp_rom_obj_t items[sizeof((mp_obj_t[]){__VA_ARGS__})/sizeof(mp_obj_t)]; \
  40. } music_tune_ ## name ## _t; \
  41. \
  42. const music_tune_ ## name ## _t microbit_music_tune_ ## name ## _obj = {{&mp_type_tuple}, .len = (sizeof((mp_obj_t[]){__VA_ARGS__})/sizeof(mp_obj_t)), .items = {__VA_ARGS__}};
  43. T(dadadadum,
  44. N(r4_colon_2), N(g), N(g), N(g), N(eb_colon_8), N(r_colon_2), N(f), N(f),
  45. N(f), N(d_colon_8));
  46. T(entertainer,
  47. N(d4_colon_1), N(d_hash_), N(e), N(c5_colon_2), N(e4_colon_1),
  48. N(c5_colon_2), N(e4_colon_1), N(c5_colon_3), N(c_colon_1), N(d),
  49. N(d_hash_), N(e), N(c), N(d), N(e_colon_2), N(b4_colon_1), N(d5_colon_2),
  50. N(c_colon_4));
  51. T(prelude,
  52. N(c4_colon_1), N(e), N(g), N(c5), N(e), N(g4), N(c5), N(e), N(c4), N(e),
  53. N(g), N(c5), N(e), N(g4), N(c5), N(e), N(c4), N(d), N(g), N(d5), N(f),
  54. N(g4), N(d5), N(f), N(c4), N(d), N(g), N(d5), N(f), N(g4), N(d5), N(f),
  55. N(b3), N(d4), N(g), N(d5), N(f), N(g4), N(d5), N(f), N(b3), N(d4), N(g),
  56. N(d5), N(f), N(g4), N(d5), N(f), N(c4), N(e), N(g), N(c5), N(e), N(g4),
  57. N(c5), N(e), N(c4), N(e), N(g), N(c5), N(e), N(g4), N(c5), N(e));
  58. T(ode,
  59. N(e4), N(e), N(f), N(g), N(g), N(f), N(e), N(d), N(c), N(c), N(d), N(e),
  60. N(e_colon_6), N(d_colon_2), N(d_colon_8), N(e_colon_4), N(e), N(f), N(g),
  61. N(g), N(f), N(e), N(d), N(c), N(c), N(d), N(e), N(d_colon_6),
  62. N(c_colon_2), N(c_colon_8));
  63. T(nyan,
  64. N(f_hash_5_colon_2), N(g_hash_), N(c_hash__colon_1), N(d_hash__colon_2),
  65. N(b4_colon_1), N(d5_colon_1), N(c_hash_), N(b4_colon_2), N(b),
  66. N(c_hash_5), N(d), N(d_colon_1), N(c_hash_), N(b4_colon_1),
  67. N(c_hash_5_colon_1), N(d_hash_), N(f_hash_), N(g_hash_), N(d_hash_),
  68. N(f_hash_), N(c_hash_), N(d), N(b4), N(c_hash_5), N(b4),
  69. N(d_hash_5_colon_2), N(f_hash_), N(g_hash__colon_1), N(d_hash_),
  70. N(f_hash_), N(c_hash_), N(d_hash_), N(b4), N(d5), N(d_hash_), N(d),
  71. N(c_hash_), N(b4), N(c_hash_5), N(d_colon_2), N(b4_colon_1), N(c_hash_5),
  72. N(d_hash_), N(f_hash_), N(c_hash_), N(d), N(c_hash_), N(b4),
  73. N(c_hash_5_colon_2), N(b4), N(c_hash_5), N(b4), N(f_hash__colon_1),
  74. N(g_hash_), N(b_colon_2), N(f_hash__colon_1), N(g_hash_), N(b),
  75. N(c_hash_5), N(d_hash_), N(b4), N(e5), N(d_hash_), N(e), N(f_hash_),
  76. N(b4_colon_2), N(b), N(f_hash__colon_1), N(g_hash_), N(b), N(f_hash_),
  77. N(e5), N(d_hash_), N(c_hash_), N(b4), N(f_hash_), N(d_hash_), N(e),
  78. N(f_hash_), N(b_colon_2), N(f_hash__colon_1), N(g_hash_), N(b_colon_2),
  79. N(f_hash__colon_1), N(g_hash_), N(b), N(b), N(c_hash_5), N(d_hash_),
  80. N(b4), N(f_hash_), N(g_hash_), N(f_hash_), N(b_colon_2), N(b_colon_1),
  81. N(a_hash_), N(b), N(f_hash_), N(g_hash_), N(b), N(e5), N(d_hash_), N(e),
  82. N(f_hash_), N(b4_colon_2), N(c_hash_5));
  83. T(ringtone,
  84. N(c4_colon_1), N(d), N(e_colon_2), N(g), N(d_colon_1), N(e), N(f_colon_2),
  85. N(a), N(e_colon_1), N(f), N(g_colon_2), N(b), N(c5_colon_4));
  86. T(funk,
  87. N(c2_colon_2), N(c), N(d_hash_), N(c_colon_1), N(f_colon_2), N(c_colon_1),
  88. N(f_colon_2), N(f_hash_), N(g), N(c), N(c), N(g), N(c_colon_1),
  89. N(f_hash__colon_2), N(c_colon_1), N(f_hash__colon_2), N(f), N(d_hash_));
  90. T(blues,
  91. N(c2_colon_2), N(e), N(g), N(a), N(a_hash_), N(a), N(g), N(e),
  92. N(c2_colon_2), N(e), N(g), N(a), N(a_hash_), N(a), N(g), N(e), N(f), N(a),
  93. N(c3), N(d), N(d_hash_), N(d), N(c), N(a2), N(c2_colon_2), N(e), N(g),
  94. N(a), N(a_hash_), N(a), N(g), N(e), N(g), N(b), N(d3), N(f), N(f2), N(a),
  95. N(c3), N(d_hash_), N(c2_colon_2), N(e), N(g), N(e), N(g), N(f), N(e),
  96. N(d));
  97. T(birthday,
  98. N(c4_colon_3), N(c_colon_1), N(d_colon_4), N(c_colon_4), N(f),
  99. N(e_colon_8), N(c_colon_3), N(c_colon_1), N(d_colon_4), N(c_colon_4),
  100. N(g), N(f_colon_8), N(c_colon_3), N(c_colon_1), N(c5_colon_4), N(a4),
  101. N(f), N(e), N(d), N(a_hash__colon_3), N(a_hash__colon_1), N(a_colon_4),
  102. N(f), N(g), N(f_colon_8));
  103. T(wedding,
  104. N(c4_colon_4), N(f_colon_3), N(f_colon_1), N(f_colon_8), N(c_colon_4),
  105. N(g_colon_3), N(e_colon_1), N(f_colon_8), N(c_colon_4), N(f_colon_3),
  106. N(a_colon_1), N(c5_colon_4), N(a4_colon_3), N(f_colon_1), N(f_colon_4),
  107. N(e_colon_3), N(f_colon_1), N(g_colon_8));
  108. T(funeral,
  109. N(c3_colon_4), N(c_colon_3), N(c_colon_1), N(c_colon_4),
  110. N(d_hash__colon_3), N(d_colon_1), N(d_colon_3), N(c_colon_1),
  111. N(c_colon_3), N(b2_colon_1), N(c3_colon_4));
  112. T(punchline,
  113. N(c4_colon_3), N(g3_colon_1), N(f_hash_), N(g), N(g_hash__colon_3), N(g),
  114. N(r), N(b), N(c4));
  115. T(python,
  116. N(d5_colon_1), N(b4), N(r), N(b), N(b), N(a_hash_), N(b), N(g5), N(r),
  117. N(d), N(d), N(r), N(b4), N(c5), N(r), N(c), N(c), N(r), N(d),
  118. N(e_colon_5), N(c_colon_1), N(a4), N(r), N(a), N(a), N(g_hash_), N(a),
  119. N(f_hash_5), N(r), N(e), N(e), N(r), N(c), N(b4), N(r), N(b), N(b), N(r),
  120. N(c5), N(d_colon_5), N(d_colon_1), N(b4), N(r), N(b), N(b), N(a_hash_),
  121. N(b), N(b5), N(r), N(g), N(g), N(r), N(d), N(c_hash_), N(r), N(a), N(a),
  122. N(r), N(a), N(a_colon_5), N(g_colon_1), N(f_hash__colon_2), N(a_colon_1),
  123. N(a), N(g_hash_), N(a), N(e_colon_2), N(a_colon_1), N(a), N(g_hash_),
  124. N(a), N(d), N(r), N(c_hash_), N(d), N(r), N(c_hash_), N(d_colon_2),
  125. N(r_colon_3));
  126. T(baddy,
  127. N(c3_colon_3), N(r), N(d_colon_2), N(d_hash_), N(r), N(c), N(r), N(f_hash__colon_8), );
  128. T(chase,
  129. N(a4_colon_1), N(b), N(c5), N(b4), N(a_colon_2), N(r), N(a_colon_1), N(b), N(c5), N(b4), N(a_colon_2), N(r), N(a_colon_2), N(e5), N(d_hash_), N(e), N(f), N(e), N(d_hash_), N(e), N(b4_colon_1), N(c5), N(d), N(c), N(b4_colon_2), N(r), N(b_colon_1), N(c5), N(d), N(c), N(b4_colon_2), N(r), N(b_colon_2), N(e5), N(d_hash_), N(e), N(f), N(e), N(d_hash_), N(e), );
  130. T(ba_ding,
  131. N(b5_colon_1), N(e6_colon_3), );
  132. T(wawawawaa,
  133. N(e3_colon_3), N(r_colon_1), N(d_hash__colon_3), N(r_colon_1), N(d_colon_4), N(r_colon_1), N(c_hash__colon_8), );
  134. T(jump_up,
  135. N(c5_colon_1), N(d), N(e), N(f), N(g), );
  136. T(jump_down,
  137. N(g5_colon_1), N(f), N(e), N(d), N(c), );
  138. T(power_up,
  139. N(g4_colon_1), N(c5), N(e), N(g_colon_2), N(e_colon_1), N(g_colon_3), );
  140. T(power_down,
  141. N(g5_colon_1), N(d_hash_), N(c), N(g4_colon_2), N(b_colon_1), N(c5_colon_3), );
  142. #undef N
  143. #undef T
  144. #endif // MICROPY_PY_MUSIC