sonification.js 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* *
  2. *
  3. * (c) 2009-2019 Øystein Moseng
  4. *
  5. * Sonification module for Highcharts
  6. *
  7. * License: www.highcharts.com/license
  8. *
  9. * */
  10. 'use strict';
  11. import H from '../../parts/Globals.js';
  12. import Instrument from 'Instrument.js';
  13. import instruments from 'instrumentDefinitions.js';
  14. import Earcon from 'Earcon.js';
  15. import pointSonifyFunctions from 'pointSonify.js';
  16. import chartSonifyFunctions from 'chartSonify.js';
  17. import utilities from 'utilities.js';
  18. import TimelineClasses from 'Timeline.js';
  19. // Expose on the Highcharts object
  20. /**
  21. * Global classes and objects related to sonification.
  22. *
  23. * @requires module:modules/sonification
  24. *
  25. * @name Highcharts.sonification
  26. * @type {Highcharts.SonificationObject}
  27. */
  28. /**
  29. * Global classes and objects related to sonification.
  30. *
  31. * @requires module:modules/sonification
  32. *
  33. * @interface Highcharts.SonificationObject
  34. *//**
  35. * Note fade-out-time in milliseconds. Most notes are faded out quickly by
  36. * default if there is time. This is to avoid abrupt stops which will cause
  37. * perceived clicks.
  38. * @name Highcharts.SonificationObject#fadeOutDuration
  39. * @type {number}
  40. *//**
  41. * Utility functions.
  42. * @name Highcharts.SonificationObject#utilities
  43. * @private
  44. * @type {object}
  45. *//**
  46. * The Instrument class.
  47. * @name Highcharts.SonificationObject#Instrument
  48. * @type {Function}
  49. *//**
  50. * Predefined instruments, given as an object with a map between the instrument
  51. * name and the Highcharts.Instrument object.
  52. * @name Highcharts.SonificationObject#instruments
  53. * @type {Object}
  54. *//**
  55. * The Earcon class.
  56. * @name Highcharts.SonificationObject#Earcon
  57. * @type {Function}
  58. *//**
  59. * The TimelineEvent class.
  60. * @private
  61. * @name Highcharts.SonificationObject#TimelineEvent
  62. * @type {Function}
  63. *//**
  64. * The TimelinePath class.
  65. * @private
  66. * @name Highcharts.SonificationObject#TimelinePath
  67. * @type {Function}
  68. *//**
  69. * The Timeline class.
  70. * @private
  71. * @name Highcharts.SonificationObject#Timeline
  72. * @type {Function}
  73. */
  74. H.sonification = {
  75. fadeOutDuration: 20,
  76. // Classes and functions
  77. utilities: utilities,
  78. Instrument: Instrument,
  79. instruments: instruments,
  80. Earcon: Earcon,
  81. TimelineEvent: TimelineClasses.TimelineEvent,
  82. TimelinePath: TimelineClasses.TimelinePath,
  83. Timeline: TimelineClasses.Timeline
  84. };
  85. // Chart specific
  86. H.Point.prototype.sonify = pointSonifyFunctions.pointSonify;
  87. H.Point.prototype.cancelSonify = pointSonifyFunctions.pointCancelSonify;
  88. H.Series.prototype.sonify = chartSonifyFunctions.seriesSonify;
  89. H.extend(H.Chart.prototype, {
  90. sonify: chartSonifyFunctions.chartSonify,
  91. pauseSonify: chartSonifyFunctions.pause,
  92. resumeSonify: chartSonifyFunctions.resume,
  93. rewindSonify: chartSonifyFunctions.rewind,
  94. cancelSonify: chartSonifyFunctions.cancel,
  95. getCurrentSonifyPoints: chartSonifyFunctions.getCurrentPoints,
  96. setSonifyCursor: chartSonifyFunctions.setCursor,
  97. resetSonifyCursor: chartSonifyFunctions.resetCursor,
  98. resetSonifyCursorEnd: chartSonifyFunctions.resetCursorEnd,
  99. sonification: {}
  100. });