1.3.5 • Published 7 months ago

spectrogram-drawer v1.3.5

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

Spectrogram Drawer

Spectrogram drawer for heart, lung and bowel sounds

Install the NPM Module

npm i spectrogram-drawer --save

Usage

1. Import AudioEngine

import AudioEngine from 'spectrogram-drawer';

2. Add Canvas to View:

    <canvas id="canvasID"></canvas>

3. Initialize:

    this.audioEngine = await new AudioEngine.default().initAudioEngine('canvasID', 'YOUR_SDK_KEY');
    let constraints = { audio: true }
    navigator.mediaDevices.getUserMedia(constraints)
      .then(async (stream) => {
        this.audioContext = new AudioContext();
        await this.audioEngine.startIt(false);
        this.audioEngine.loadOpusDecoder();
      })

Config:

  • mode: 'HEART' | 'LUNG'
  • gain for HEART: minimum 1 to maximum 3
  • gain for LUNG: minimum 1 to maximum 20

4. Send Audio input

Load Audio files
    const audioContext = new AudioContext();
    fetch('audio.wav')
    .then(response => response.arrayBuffer())
    .then(arrayBuffer => audioContext.decodeAudioData(arrayBuffer))
    .then(audioBuffer => {
        this.audioEngine.testAudioInput(audioBuffer.getChannelData(0));
    });
Live input stream with getUserMedia.
    navigator.mediaDevices.getUserMedia({audio: true})
        .then((stream) => {
          const context = new AudioContext({sampleRate: 16000});
            const source = context.createMediaStreamSource(stream);
            const processor = context.createScriptProcessor(1024, 1, 1);
        
            source.connect(processor);
            processor.connect(context.destination);
        
            processor.onaudioprocess = (e) => {
              this.audioEngine.testAudioInput(e.inputBuffer.getChannelData(0));
            };
        });

Properties

1. Pause
this.audioEngine.pause();
2. Stop
this.audioEngine.stop();
3. Resume
this.audioEngine.resume();
4. Change Playback Speed
this.audioEngine.playbackSpeedChange(speed); // speed [0.25, 0.5, 0.75, 1, 1.25, 1.50, 1.75, 2]
5. Disable Auto Gain and Noise Filters
this.audioEngine.setAutoGainFlag(false); // By default, the gain is enabled
this.audioEngine.setFilterFlag(false); // By default, the filter is enabled
NOTE: We are supporting 5 canvases to be displayed at the same time in a screen
1.2.8

7 months ago

1.3.5

7 months ago

1.3.4

7 months ago

1.3.3

7 months ago

1.3.2

7 months ago

1.3.1

7 months ago

1.2.9

7 months ago

1.2.7

7 months ago

1.2.6

7 months ago

1.2.5

7 months ago

1.2.4

7 months ago

1.2.3

7 months ago

1.2.0

12 months ago

1.2.2

8 months ago

1.2.1

12 months ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.2

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.1

2 years ago

0.0.0

2 years ago

1.0.0

2 years ago