abcjs.mdx 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. import { Piano } from 'react-piano';
  2. import 'react-piano/dist/styles.css';
  3. import ABCNotation from '@site/src/components/ABCNotation';
  4. import ReactPlayer from 'react-player'
  5. # Notation
  6. Flipping through a bunch of pdfs or watching videos for scales isn't going to cut it so I'm adding two libraries to help me make some music notation. The first is a library for rendering piano keys and the second is a library for rendering ABC notation.
  7. - [react-piano](https://github.com/kevinsqi/react-piano)
  8. - [ABC.js](https://www.abcjs.net/)
  9. - [ABC Notation](https://en.wikipedia.org/wiki/ABC_notation)
  10. <ReactPlayer
  11. url='https://davidawindham.com/wha/music-notation.mp4'
  12. controls={true}
  13. width='100%'
  14. height='100%'
  15. />
  16. ## React Piano Example
  17. ## C Major Scale
  18. <Piano
  19. noteRange={{ first: 48, last: 74 }}
  20. width={600}
  21. activeNotes={[60, 62, 64, 65, 67, 69, 71, 72]}
  22. playNote={(midiNumber) => {
  23. console.log(midiNumber);
  24. }}
  25. stopNote={(midiNumber) => {
  26. console.log(midiNumber);
  27. }}
  28. />
  29. ```js
  30. <Piano
  31. noteRange={{ first: 48, last: 74 }}
  32. width={600}
  33. activeNotes={[60, 62, 64, 65, 67, 69, 71]}
  34. playNote={(midiNumber) => {
  35. console.log(midiNumber);
  36. }}
  37. stopNote={(midiNumber) => {
  38. console.log(midiNumber);
  39. }}
  40. />
  41. ```
  42. ## D Major Scale
  43. <Piano
  44. noteRange={{ first: 48, last: 74 }}
  45. width={600}
  46. activeNotes={[50, 52, 54, 55, 57, 59, 61, 62]}
  47. playNote={(midiNumber) => {
  48. console.log(midiNumber);
  49. }}
  50. stopNote={(midiNumber) => {
  51. console.log(midiNumber);
  52. }}
  53. />
  54. ```js
  55. <Piano
  56. noteRange={{ first: 48, last: 74 }}
  57. width={600}
  58. activeNotes={[50, 52, 54, 55, 57, 59, 61, 62]}
  59. playNote={(midiNumber) => {
  60. console.log(midiNumber);
  61. }}
  62. stopNote={(midiNumber) => {
  63. console.log(midiNumber);
  64. }}
  65. />
  66. ```
  67. ## ABC Notation Example
  68. <ABCNotation notation={`X:1
  69. T:Example
  70. M:4/4
  71. L:1/8
  72. K:C
  73. C,D,E,F, G,A,B,C DEFG ABcd|efgab c'd'e'f' g'a'b'c''|`} />
  74. ```js
  75. <ABCNotation notation={`
  76. X:1
  77. T:Example
  78. M:4/4
  79. L:1/8
  80. K:C
  81. C,D,E,F, G,A,B,C DEFG ABcd|efgab c'd'e'f' g'a'b'c''|
  82. `}
  83. />
  84. ```
  85. <ABCNotation
  86. notation={`X:1
  87. T:Example with chord symbols
  88. M:4/4
  89. L:1/4
  90. K:C
  91. "C"CDEF|"G"GABc|"F"FEDC|"C"C4|`}
  92. options={{
  93. add_classes: true,
  94. responsive: 'resize',
  95. clickListener: (abcElem) => {
  96. console.log(abcElem);
  97. }
  98. }}
  99. />
  100. ```js
  101. <ABCNotation notation={`
  102. X:1
  103. T:Example with chord symbols
  104. M:4/4
  105. L:1/4
  106. K:C
  107. "C"CDEF|"G"GABc|"F"FEDC|"C"C4|
  108. `}
  109. options={{
  110. add_classes: true,
  111. responsive: 'resize',
  112. clickListener: (abcElem) => {
  113. console.log(abcElem);
  114. }
  115. }}
  116. />
  117. ```