abcjs-rails 2.3 → 3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/abcjs/api/abc_animation.js +166 -4
  3. data/app/assets/javascripts/abcjs/api/abc_tunebook.js +170 -15
  4. data/app/assets/javascripts/abcjs/data/abc_tune.js +69 -47
  5. data/app/assets/javascripts/abcjs/edit/abc_editor.js +78 -37
  6. data/app/assets/javascripts/abcjs/midi/abc_midi_controls.js +513 -0
  7. data/app/assets/javascripts/abcjs/midi/abc_midi_create.js +29 -7
  8. data/app/assets/javascripts/abcjs/midi/abc_midi_flattener.js +21 -18
  9. data/app/assets/javascripts/abcjs/midi/abc_midi_js_preparer.js +233 -0
  10. data/app/assets/javascripts/abcjs/midi/abc_midi_renderer.js +3 -229
  11. data/app/assets/javascripts/abcjs/midi/abc_midi_sequencer.js +11 -3
  12. data/app/assets/javascripts/abcjs/parse/abc_common.js +24 -0
  13. data/app/assets/javascripts/abcjs/parse/abc_parse.js +58 -16
  14. data/app/assets/javascripts/abcjs/parse/abc_parse_header.js +4 -1
  15. data/app/assets/javascripts/abcjs/parse/abc_parse_key_voice.js +5 -0
  16. data/app/assets/javascripts/abcjs/write/abc_absolute_element.js +9 -2
  17. data/app/assets/javascripts/abcjs/write/abc_abstract_engraver.js +71 -19
  18. data/app/assets/javascripts/abcjs/write/abc_beam_element.js +11 -3
  19. data/app/assets/javascripts/abcjs/write/abc_brace_element.js +51 -0
  20. data/app/assets/javascripts/abcjs/write/abc_create_clef.js +3 -3
  21. data/app/assets/javascripts/abcjs/write/abc_create_key_signature.js +3 -3
  22. data/app/assets/javascripts/abcjs/write/abc_create_time_signature.js +3 -3
  23. data/app/assets/javascripts/abcjs/write/abc_crescendo_element.js +4 -1
  24. data/app/assets/javascripts/abcjs/write/abc_decoration.js +1 -1
  25. data/app/assets/javascripts/abcjs/write/abc_engraver_controller.js +10 -9
  26. data/app/assets/javascripts/abcjs/write/abc_glyphs.js +1 -1
  27. data/app/assets/javascripts/abcjs/write/abc_relative_element.js +1 -1
  28. data/app/assets/javascripts/abcjs/write/abc_renderer.js +85 -13
  29. data/app/assets/javascripts/abcjs/write/abc_staff_group_element.js +16 -0
  30. data/app/assets/javascripts/abcjs/write/abc_tempo_element.js +31 -11
  31. data/app/assets/javascripts/abcjs/write/abc_tie_element.js +8 -1
  32. data/lib/abcjs-rails/version.rb +1 -1
  33. metadata +6 -3
@@ -26,8 +26,9 @@ if (!window.ABCJS.write)
26
26
  "use strict";
27
27
  var totalHeightInPitches = 5;
28
28
 
29
- ABCJS.write.TempoElement = function(tempo) {
29
+ ABCJS.write.TempoElement = function(tempo, tuneNumber) {
30
30
  this.tempo = tempo;
31
+ this.tuneNumber = tuneNumber;
31
32
  this.tempoHeightAbove = totalHeightInPitches;
32
33
  this.pitch = undefined; // This will be set later
33
34
  };
@@ -57,14 +58,35 @@ if (!window.ABCJS.write)
57
58
  var temposcale = 0.75;
58
59
  var tempopitch = this.pitch - totalHeightInPitches + 1; // The pitch we receive is the top of the allotted area: change that to practically the bottom.
59
60
  var duration = this.tempo.duration[0]; // TODO when multiple durations
60
- var abselem = new ABCJS.write.AbsoluteElement(this.tempo, duration, 1, 'tempo');
61
- var durlog = Math.floor(Math.log(duration) / Math.log(2));
62
- var dot = 0;
63
- for (var tot = Math.pow(2, durlog), inc = tot / 2; tot < duration; dot++, tot += inc, inc /= 2);
64
- var c = renderer.engraver.chartable.note[-durlog];
65
- var flag = renderer.engraver.chartable.uflags[-durlog];
61
+ var abselem = new ABCJS.write.AbsoluteElement(this.tempo, duration, 1, 'tempo', this.tuneNumber);
62
+ // There aren't an infinite number of note values, but we are passed a float, so just in case something is off upstream,
63
+ // merge all of the in between points.
64
+ var dot;
65
+ var flag;
66
+ var note;
67
+ if (duration <= 1/32) { note = "noteheads.quarter"; flag = "flags.u32nd"; dot = 0; }
68
+ else if (duration <= 1/16) { note = "noteheads.quarter"; flag = "flags.u16th"; dot = 0; }
69
+ else if (duration <= 3/32) { note = "noteheads.quarter"; flag = "flags.u32nd"; dot = 1; }
70
+ else if (duration <= 1/8) { note = "noteheads.quarter"; flag = "flags.u8th"; dot = 0; }
71
+ else if (duration <= 3/16) { note = "noteheads.quarter"; flag = "flags.u16th"; dot = 1; }
72
+ else if (duration <= 1/4) { note = "noteheads.quarter"; dot = 0; }
73
+ else if (duration <= 3/8) { note = "noteheads.quarter"; flag = "flags.u8th"; dot = 1; }
74
+ else if (duration <= 1/2) { note = "noteheads.half"; dot = 0; }
75
+ else if (duration <= 3/4) { note = "noteheads.quarter"; dot = 1; }
76
+ else if (duration <= 1) { note = "noteheads.whole"; dot = 0; }
77
+ else if (duration <= 1.5) { note = "noteheads.half"; dot = 1; }
78
+ else if (duration <= 2) { note = "noteheads.dbl"; dot = 0; }
79
+ else if (duration <= 3) { note = "noteheads.whole"; dot = 1; }
80
+ else { note = "noteheads.dbl"; dot = 1; }
81
+
82
+ // TODO-PER: the following had a bug in it when there are dotted notes - so the above code brute forces it.
83
+ // var durlog = Math.floor(Math.log(duration) / Math.log(2));
84
+ // var dot = 0;
85
+ // for (var tot = Math.pow(2, durlog), inc = tot / 2; tot < duration; dot++, tot += inc, inc /= 2);
86
+ // var note = renderer.engraver.chartable.note[-durlog];
87
+ // var flag = renderer.engraver.chartable.uflags[-durlog];
66
88
  var temponote = renderer.engraver.createNoteHead(abselem, // TODO-PER: This seems late to be creating this element. Shouldn't it happen before draw?
67
- c,
89
+ note,
68
90
  {verticalPos: tempopitch},
69
91
  "up",
70
92
  0,
@@ -76,7 +98,7 @@ if (!window.ABCJS.write)
76
98
  );
77
99
  abselem.addHead(temponote);
78
100
  var stem;
79
- if (duration < 1) {
101
+ if (note !== "noteheads.whole" && note !== "noteheads.dbl") {
80
102
  var p1 = tempopitch + 1 / 3 * temposcale;
81
103
  var p2 = tempopitch + 7 * temposcale;
82
104
  var dx = temponote.dx + temponote.w;
@@ -88,8 +110,6 @@ if (!window.ABCJS.write)
88
110
  abselem.setX(x);
89
111
  for (var i = 0; i < abselem.children.length; i++)
90
112
  abselem.children[i].draw(renderer, x);
91
- //if (stem)
92
- // stem.draw(renderer, x);
93
113
  x += (abselem.w + 5);
94
114
  var str = "= " + this.tempo.bpm;
95
115
  text = renderer.renderText(x, y, str, 'tempofont', 'tempo', "start");
@@ -43,6 +43,10 @@ ABCJS.write.TieElem.prototype.setEndX = function(endLimitElem) {
43
43
  this.endLimitX = endLimitElem;
44
44
  };
45
45
 
46
+ ABCJS.write.TieElem.prototype.setHint = function () {
47
+ this.hint = true;
48
+ };
49
+
46
50
  ABCJS.write.TieElem.prototype.setUpperAndLowerElements = function(positionY) {
47
51
  // Doesn't depend on the highest and lowest, so there's nothing to do here.
48
52
  };
@@ -101,6 +105,9 @@ ABCJS.write.TieElem.prototype.layout = function (lineStartX, lineEndX) {
101
105
  ABCJS.write.TieElem.prototype.draw = function (renderer, linestartx, lineendx) {
102
106
  this.layout(linestartx, lineendx);
103
107
 
104
- renderer.drawArc(this.startX, this.endX, this.startY, this.endY, this.above);
108
+ var klass;
109
+ if (this.hint)
110
+ klass = "abcjs-hint";
111
+ renderer.drawArc(this.startX, this.endX, this.startY, this.endY, this.above, klass);
105
112
 
106
113
  };
@@ -1,5 +1,5 @@
1
1
  module Abcjs
2
2
  module Rails
3
- VERSION = "2.3"
3
+ VERSION = "3.0"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: abcjs-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: '2.3'
4
+ version: '3.0'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Paul Rosen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-19 00:00:00.000000000 Z
11
+ date: 2016-12-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -38,8 +38,10 @@ files:
38
38
  - app/assets/javascripts/abcjs/api/abc_tunebook.js
39
39
  - app/assets/javascripts/abcjs/data/abc_tune.js
40
40
  - app/assets/javascripts/abcjs/edit/abc_editor.js
41
+ - app/assets/javascripts/abcjs/midi/abc_midi_controls.js
41
42
  - app/assets/javascripts/abcjs/midi/abc_midi_create.js
42
43
  - app/assets/javascripts/abcjs/midi/abc_midi_flattener.js
44
+ - app/assets/javascripts/abcjs/midi/abc_midi_js_preparer.js
43
45
  - app/assets/javascripts/abcjs/midi/abc_midi_renderer.js
44
46
  - app/assets/javascripts/abcjs/midi/abc_midi_sequencer.js
45
47
  - app/assets/javascripts/abcjs/parse/abc_common.js
@@ -52,6 +54,7 @@ files:
52
54
  - app/assets/javascripts/abcjs/write/abc_absolute_element.js
53
55
  - app/assets/javascripts/abcjs/write/abc_abstract_engraver.js
54
56
  - app/assets/javascripts/abcjs/write/abc_beam_element.js
57
+ - app/assets/javascripts/abcjs/write/abc_brace_element.js
55
58
  - app/assets/javascripts/abcjs/write/abc_create_clef.js
56
59
  - app/assets/javascripts/abcjs/write/abc_create_key_signature.js
57
60
  - app/assets/javascripts/abcjs/write/abc_create_time_signature.js
@@ -90,7 +93,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
90
93
  version: '0'
91
94
  requirements: []
92
95
  rubyforge_project:
93
- rubygems_version: 2.4.5.1
96
+ rubygems_version: 2.5.1
94
97
  signing_key:
95
98
  specification_version: 4
96
99
  summary: This packages the abcjs javascript files in a gem for easy reuse in Rails