How to use speaker - 4 common examples

To help you get started, we’ve selected a few speaker examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github guo-yu / player / libs / player.js View on Github external
function onPlaying(f) {
        self.lameFormat = f
        var speaker = new Volume()
        speaker.pipe(new Speaker(self.lameFormat))

        self.speaker = {
          'readableStream': this,
          'Speaker': speaker,
        }

        self.emit('playing', song)
        self.history.push(index)

        // This is where the song acturaly played end,
        // can't trigger playend event here cause
        // unpipe will fire this speaker's close event.
        this.pipe(speaker)
          .once('close', () => 
            self.emit('playend', song))
      }
github mohayonao / pico.js / src / player / node-speaker-player.js View on Github external
this._node = new stream.Readable();
    this._node._read = (n) => {
      let streamL = this.processor.streams[0];
      let streamR = this.processor.streams[1];
      let buf = new Buffer(n);

      this.processor.process(this.streamSize);

      for (let i = 0, imax = this.streamSize; i < imax; i++) {
        buf.writeFloatLE(streamL[i], i * 8 + 0);
        buf.writeFloatLE(streamR[i], i * 8 + 4);
      }

      this._node.push(buf);
    };
    this._node.pipe(new Speaker({
      sampleRate: this.sampleRate,
      samplesPerFrame: this.streamSize,
      channels: 2,
      float: true
    }));
  }
github brian-ai / core / src / brain / communication / speaker / index.js View on Github external
const createSpeaker = callback => {
	const speaker = new Speaker({
		channels: 1,
		bitDepth: 16,
		sampleRate: 17650
	})

	speaker.on('open', () => {
		logger.info('Speaker opened')
	})

	speaker.on('close', () => {
		logger.info('Speaker closed')
		callback()
	})

	return speaker
}
github guo-yu / player / libs / player.js View on Github external
pause() {
    if (this.paused) {
      this.speaker.Speaker = new Volume()
      this.speaker.Speaker.pipe(new Speaker(this.lameFormat))

      this.lameStream.pipe(this.speaker.Speaker)
    } else {
      this.speaker.Speaker.end()
    }

    this.paused = !this.paused
    return this	
  }

speaker

Output PCM audio data to the speakers

(MIT AND LGPL-2.1-only)
Latest version published 7 months ago

Package Health Score

49 / 100
Full package analysis

Popular speaker functions