No Description

rtty.html 4.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. <html>
  2. <head>
  3. <meta charset="utf-8">
  4. <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=yes">
  5. <link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
  6. <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
  7. <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
  8. <script src="rtty.js"></script>
  9. <style>
  10. button, input, textarea {
  11. margin-bottom: 10px;
  12. }
  13. </style>
  14. </head>
  15. <body>
  16. <div class="container">
  17. <div class="row">
  18. <div class="col-md-12">
  19. <h1>rtty.js</h1>
  20. </div>
  21. </div>
  22. <div class="row">
  23. <div class="col-md-4">
  24. <div class="panel panel-default">
  25. <div class="panel-heading"><h3 class="panel-title">Output Control</h3></div>
  26. <div class="panel-body">
  27. <b>Baud Rate:</b> <input class="form-control" id="baudrate" type="number" value="45.45">
  28. <b>Mark Frequency:</b> <input class="form-control" id="markfrequency" type="number" value="2125">
  29. <b>Space Frequency:</b> <input class="form-control" id="spacefrequency" type="number" value="2295">
  30. <button class="btn btn-default" id="start">Start Audio</button>
  31. <button class="btn btn-default" id="stop">Stop Audio</button>
  32. <button class="btn btn-default" id="invert">Invert</button>
  33. </div>
  34. </div>
  35. <div class="panel panel-default">
  36. <div class="panel-heading"><h3 class="panel-title">Modulator Control</h3></div>
  37. <div class="panel-body">
  38. <button class="btn btn-default" id="pause">Pause</button>
  39. <button class="btn btn-default" id="resume">Resume</button>
  40. <button class="btn btn-default" id="flush">Flush Buffer</button>
  41. </div>
  42. </div>
  43. </div>
  44. <div class="col-md-8">
  45. <div class="panel panel-default">
  46. <div class="panel-heading"><h3 class="panel-title">Input</h3></div>
  47. <div class="panel-body">
  48. <textarea class="form-control" id="data" rows="14">
  49. Is it a fact—or have I dreamt it—that, by means of electricity, the world of matter has become a great nerve, vibrating thousands of miles in a breathless point of time?
  50. </textarea>
  51. <button class="btn btn-default" id="encode">Encode</button>
  52. </div>
  53. </div>
  54. </div>
  55. </div>
  56. </div>
  57. </body>
  58. <script>
  59. var modulator = new RTTY({
  60. baudrate: parseFloat(document.querySelector('#baudrate').value),
  61. mark: parseFloat(document.querySelector('#markfrequency').value),
  62. space: parseFloat(document.querySelector('#spacefrequency').value)
  63. });
  64. modulator.bufferEmptyCallback = function() {
  65. };
  66. document.querySelector('#start').onclick = function() {
  67. document.querySelector('#baudrate').disabled=true;
  68. document.querySelector('#markfrequency').disabled=true;
  69. document.querySelector('#spacefrequency').disabled=true;
  70. modulator.baudrate = parseFloat(document.querySelector('#baudrate').value);
  71. modulator.mark = parseFloat(document.querySelector('#markfrequency').value);
  72. modulator.space = parseFloat(document.querySelector('#spacefrequency').value);
  73. modulator.startSound();
  74. };
  75. document.querySelector('#stop').onclick = function() {
  76. modulator.stopSound();
  77. document.querySelector('#baudrate').disabled=false;
  78. document.querySelector('#markfrequency').disabled=false;
  79. document.querySelector('#spacefrequency').disabled=false;
  80. };
  81. document.querySelector('#invert').onclick = function() {
  82. modulator.invert();
  83. };
  84. document.querySelector('#pause').onclick = function() {
  85. modulator.pauseModulation();
  86. };
  87. document.querySelector('#resume').onclick = function() {
  88. modulator.resumeModulation();
  89. };
  90. document.querySelector('#encode').onclick = function() {
  91. modulator.modulate(document.querySelector('#data').value);
  92. };
  93. document.querySelector('#flush').onclick = function() {
  94. modulator.flushBuffer();
  95. };
  96. </script>
  97. </html>