{"id":19030591,"url":"https://github.com/mmende/soundengine","last_synced_at":"2025-04-23T16:04:31.197Z","repository":{"id":57366467,"uuid":"84311903","full_name":"mmende/soundengine","owner":"mmende","description":"A C++ addon for node.js that allows interacting with soundcards to e.g. play, record or process live microphone samples and send them back to the speakers.","archived":false,"fork":false,"pushed_at":"2024-01-09T13:49:11.000Z","size":1372,"stargazers_count":6,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T16:04:22.856Z","etag":null,"topics":["audio","dsp","nodejs","playback","portaudio","recording","soundcard","speaker"],"latest_commit_sha":null,"homepage":null,"language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mmende.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-03-08T11:13:31.000Z","updated_at":"2024-01-09T13:49:15.000Z","dependencies_parsed_at":"2024-10-24T05:20:12.305Z","dependency_job_id":null,"html_url":"https://github.com/mmende/soundengine","commit_stats":{"total_commits":12,"total_committers":2,"mean_commits":6.0,"dds":0.08333333333333337,"last_synced_commit":"fd35f0d7bacb5469bafa714a7d0f491afeff2a41"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmende%2Fsoundengine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmende%2Fsoundengine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmende%2Fsoundengine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mmende%2Fsoundengine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mmende","download_url":"https://codeload.github.com/mmende/soundengine/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250468273,"owners_count":21435452,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["audio","dsp","nodejs","playback","portaudio","recording","soundcard","speaker"],"created_at":"2024-11-08T21:18:41.411Z","updated_at":"2025-04-23T16:04:31.177Z","avatar_url":"https://github.com/mmende.png","language":"C++","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Soundengine\n\nA C++ addon for node.js that allows interacting with soundcards to e.g. play, record or process live microphone samples and send them back to the speakers.\nThe module uses [PortAudio](http://portaudio.com) to interact with the different host apis.\n\n## Prerequisites\n\nSoundengine requires the shared portaudio library.  \n\n### MacOS (via homebrew)\n\n```sh\n$ brew install portaudio fftw\n```\n\n### Ubuntu (with apt-get)\n\n\n```sh\n$ sudo apt-get install libasound-dev libportaudio2 portaudio19-dev libfftw3-3 libfftw3-dev libfftw3-double3\n```\n\n\u003c!--\nDownload PortAudio from [here](http://www.portaudio.com/download.html) and unpack it.  \nIn the unpacked portaudio folder\n\n```sh\n$ ./configure \u0026\u0026 make\n$ sudo make install\n```\n--\u003e\n\n### Windows\n\n...not supported yet.\n\n\n## Installation\n\n```sh\n$ npm i soundengine\n```\n\n## Basic usage example\n\n```javascript\nconst soundengine = require('soundengine')\n\n// Start live transmission from the default input device to the default output device at 22kHz\nvar engine = new soundengine.engine({sampleRate: 22050})\n\n// Start recording\nengine.startRecording()\n\n// Apply a beep to the output when recording has stopped\nengine.on('recording_stopped', () =\u003e {\n    engine.beep({frequency: 300})\n})\n\n// Stop recording after 5 seconds\nsetTimeout(() =\u003e {\n    // Stop the recording\n    engine.stopRecording()\n\n    // Playback of the recording\n    engine.startPlayback()\n}, 5000)\n\n// Let the programm run forever\nprocess.stdin.resume()\n```\n\n## Api\n\n### Devices\n\nTo list the available devices\n\n```javascript\nconst soundengine = require('soundengine')\nvar devices = soundengine.getDevices()\n```\n\n### Device properties\n\n### Engine options\n\nProperty                 | Type      | Description\n-------------------------|-----------|-------------------------------------------------------\nid                       | number    | The device id to use in the engine options.\nname                     | string    | The device name.\ndefaultSampleRate        | number    | The default sample rate of the device.\nmaxInputChannels         | number    | The maximum supported input channels for this device.\nmaxOutputChannels        | number    | The maximum supported output channels for this device.\ndefaultLowInputLatency   | number    | [See PortAudio docs](http://www.portaudio.com/docs/latency.html)\ndefaultLowOutputLatency  | number    | [See PortAudio docs](http://www.portaudio.com/docs/latency.html)\ndefaultHighInputLatency  | number    | [See PortAudio docs](http://www.portaudio.com/docs/latency.html)\ndefaultHighOutputLatency | number    | [See PortAudio docs](http://www.portaudio.com/docs/latency.html)\n\n### Engine methods\n\nThe engine class actually has almost all the methods of a nodejs [EventEmitter](https://nodejs.org/api/events.html#events_class_eventemitter) to interact with the upcomming events. Furthermore these methods exist:\n\n* `loadRecording(file: string)` - Loads a wave `file` that is then playable with `startPlayback()`. \u003csup\u003e(1)\u003c/sup\u003e\n* `startPlayback()` - Starts playback of the last recording or loaded file.\n* `stopPlayback()` - Stops playback.\n* `pausePlayback()` - Pauses playback.\n* `isPlaying(): boolean` - Returns if playback is active.\n* `startRecording()` - Starts recording.\n* `stopRecording()` - Stops recording.\n* `deleteRecording()` - Deletes the recording that is currently held in memory.\n* `saveRecording(file: string)` - Saves the recording to a wave `file`. \u003csup\u003e(2)\u003c/sup\u003e\n* `isRecording(): boolean` - Returns if recording is active.\n* `getRecordingSamples(): number` - Return the number of total samples.\n* `getPlaybackPosition(): number` - Returns the current sample index of the playback.\n* `getRecordingSampleAt(index: number): number` - Returns a specific sample (between -1..1) at `index`.\n* `getPlaybackProgress(): number` - Returns the relative playback progress (between 0..1).\n* `setPlaybackProgress(progress: number)` - Sets the relative playback progress (between 0..1).\n* `beep(options?: beepOptions)` - Applies a beep to the output.\n* `getVolume(): number` - Returns the volume (between 0..1).\n* `setVolume(volume: number)` - Sets the volume (between 0..1).\n* `getMute(): boolean` - Returns if the output is muted or not.\n* `setMute(mute?: boolean)` - Mutes or unmutes the output.\n* `getOptions(): engineOptions` - Returns the current engine options.\n* `setOptions(options?: engineOptions)` - Sets the engine options.\n* `synchronize()` - Clears the internal buffer queues. If there for example is a large delay between the input and the output after initializing a new engine, calling `synchronize` could potentially minimize this delay.\n\n***Notes:***\u003cbr\u003e\n*(1) Currently only 32bit floating point waves with the same samplerate of the current engine can be loaded (and the header will not be checked).*\u003cbr\u003e\n*(2) The wave files are 32bit floating point.*\n\n### Engine options\n\nOption          | Type      | Default                     | Description\n----------------|-----------|-----------------------------|------------\nsampleRate      | number    | 44100                       | Samples per second for each channel.\nbufferSize      | number    | 1024                        | The count of samples for each processing iteration.\ninputChannels   | number    | 1                           | The number of input channels.\noutputChannels  | number    | 1                           | The number of output channels (should equal inputChannels).\ninputDevice     | number    | default input device        | The id of the input device to use or -1 for a output only stream.\noutputDevice    | number    | default output device       | The id of the output device to use or -1 for a input only stream.\ninputLatency    | number    | default high input latency  | [See PortAudio docs](http://www.portaudio.com/docs/latency.html)\noutputLatency   | number    | default high output latency | [See PortAudio docs](http://www.portaudio.com/docs/latency.html)\n\n## Beep options\n\nOption          | Type      | Default               | Description\n----------------|-----------|-----------------------|------------\nduration        | number    | 200                   | The duration of the applied beep in ms.\nfrequency       | number    | 700                   | The frequency of the beep (sine wave).\nlevel           | number    | 1.0                   | The volume of the beep (between 0..1).\n\n## Engine events\n\nEventName            | Signature                            | Description\n---------------------|--------------------------------------|------------\ndata                 | (inputBuffer: number[]): number[]    | Will be called when a new `inputBuffer` is available to be processed and returned. **Note: If the processing function takes to long to process the buffer you might experience dropouts.**\ninfo                 | ({min: number[], max: number[]})     | This event gets fired with messurements of the inputBuffer such as peaks (min) for every channel.\nplayback_started     |                                      | Gets fired when playback started.\nplayback_stopped     |                                      | Gets fired when playback stopped.\nplayback_paused      |                                      | Gets fired when playback paused.\nplayback_progress    | (progress: number)                   | Gets fired when playback progressed with the relative progress.\nplayback_finished    |                                      | Gets fired when playback reached the end of the recording or loaded wave.\nrecording_loaded     |                                      | Gets fired when the `loadRecording` loaded a file successfully.\nrecording_started    |                                      | Gets fired when recording started.\nrecording_stopped    |                                      | Gets fired when recording stopped.\nrecording_progress   |                                      | Gets fired when recording progressed.\nrecording_saved      |                                      | Gets fired when the recording was saved with `saveRecording`.\nrecording_deleted    |                                      | Gets fired when the recording in memory was deleted.\nbeep_started         |                                      | Gets fired when the `beep` method started apply a beep to the output.\nbeep_stopped         |                                      | Gets fired when the `beep` method stopped apply a beep to the output.\n\n\n## Todos\n\n* Implement fft stuff","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmende%2Fsoundengine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmmende%2Fsoundengine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmmende%2Fsoundengine/lists"}