mirror of
https://github.com/onyx-and-iris/meld-cli.git
synced 2025-08-06 20:11:45 +00:00
Compare commits
4 Commits
df44c52e48
...
8c7dfefb7b
Author | SHA1 | Date | |
---|---|---|---|
8c7dfefb7b | |||
310e96aa0f | |||
b6e734513a | |||
aa125d2f46 |
@ -104,6 +104,13 @@ meld-cli audio toggle "Mic"
|
|||||||
meld-cli audio status "Mic"
|
meld-cli audio status "Mic"
|
||||||
```
|
```
|
||||||
|
|
||||||
|
- gain: Adjust the audio gain
|
||||||
|
- args: audioName gainValue
|
||||||
|
|
||||||
|
```console
|
||||||
|
meld-cli audio gain "System" -12.8
|
||||||
|
```
|
||||||
|
|
||||||
#### Stream
|
#### Stream
|
||||||
|
|
||||||
- start: Start streaming
|
- start: Start streaming
|
||||||
|
@ -13,7 +13,7 @@ import WebSocket from 'ws'
|
|||||||
import cli from '../src/cli.js'
|
import cli from '../src/cli.js'
|
||||||
import style from '../src/style.js'
|
import style from '../src/style.js'
|
||||||
import { sceneHelp, sceneList, sceneSwitch, sceneCurrent } from '../src/scene.js'
|
import { sceneHelp, sceneList, sceneSwitch, sceneCurrent } from '../src/scene.js'
|
||||||
import { audioHelp, audioList, audioMute, audioUnmute, audioToggle, audioStatus } from '../src/audio.js'
|
import { audioHelp, audioList, audioMute, audioUnmute, audioToggle, audioStatus, audioGain } from '../src/audio.js'
|
||||||
import { streamHelp, streamStart, streamStop, streamToggle, streamStatus } from '../src/stream.js'
|
import { streamHelp, streamStart, streamStop, streamToggle, streamStatus } from '../src/stream.js'
|
||||||
import { recordHelp, recordStart, recordStop, recordToggle, recordStatus } from '../src/record.js'
|
import { recordHelp, recordStart, recordStop, recordToggle, recordStatus } from '../src/record.js'
|
||||||
import { clipHelp, clipSave } from '../src/clip.js'
|
import { clipHelp, clipSave } from '../src/clip.js'
|
||||||
@ -138,6 +138,12 @@ socket.onopen = function () {
|
|||||||
}
|
}
|
||||||
withChannel(socket, (channel) => audioStatus(channel, audioArguments[0]))
|
withChannel(socket, (channel) => audioStatus(channel, audioArguments[0]))
|
||||||
break
|
break
|
||||||
|
case 'gain':
|
||||||
|
if (!audioArguments[0] || isNaN(audioArguments[1])) {
|
||||||
|
printError('Error: Audio name and gain value are required for the gain command.')
|
||||||
|
}
|
||||||
|
withChannel(socket, (channel) => audioGain(channel, audioArguments[0], parseFloat(audioArguments[1])))
|
||||||
|
break
|
||||||
default:
|
default:
|
||||||
printHelp(audioHelp)
|
printHelp(audioHelp)
|
||||||
}
|
}
|
||||||
|
4
package-lock.json
generated
4
package-lock.json
generated
@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@onyx-and-iris/meld-cli",
|
"name": "@onyx-and-iris/meld-cli",
|
||||||
"version": "0.5.3",
|
"version": "0.6.0",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@onyx-and-iris/meld-cli",
|
"name": "@onyx-and-iris/meld-cli",
|
||||||
"version": "0.5.3",
|
"version": "0.6.0",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"cli-color": "^2.0.4",
|
"cli-color": "^2.0.4",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@onyx-and-iris/meld-cli",
|
"name": "@onyx-and-iris/meld-cli",
|
||||||
"version": "0.5.3",
|
"version": "0.6.0",
|
||||||
"description": "A command line interface for Meld Studio WebChannel API",
|
"description": "A command line interface for Meld Studio WebChannel API",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
"meld",
|
"meld",
|
||||||
|
46
src/audio.js
46
src/audio.js
@ -27,6 +27,9 @@ const commands = {
|
|||||||
},
|
},
|
||||||
status: {
|
status: {
|
||||||
desc: 'Show current audio status'
|
desc: 'Show current audio status'
|
||||||
|
},
|
||||||
|
gain: {
|
||||||
|
desc: 'Adjust the audio gain'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -238,11 +241,52 @@ function audioStatus (channel, audioName) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adjust the gain of a specific audio track by name.
|
||||||
|
* @param {Object} channel - The channel object containing Meld session data.
|
||||||
|
* @param {string} audioName - The name of the audio track to adjust.
|
||||||
|
* @param {number} gainValue - The gain value to set (-60.0 to 0.0).
|
||||||
|
* @returns {Promise<string>} Resolves with a success message or rejects with an error.
|
||||||
|
*/
|
||||||
|
function audioGain (channel, audioName, gainValue) {
|
||||||
|
if (!channel.objects || !channel.objects.meld) {
|
||||||
|
return Promise.reject(new Error('Meld object not found in channel.'))
|
||||||
|
}
|
||||||
|
const meld = channel.objects.meld
|
||||||
|
let itemId
|
||||||
|
for (const [key, value] of Object.entries(meld.session.items)) {
|
||||||
|
if (value.type === 'track' && value.name === audioName) {
|
||||||
|
itemId = key
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!itemId) {
|
||||||
|
return Promise.reject(new Error(`No audio device with name ${style.errHighlight(audioName)} found.`))
|
||||||
|
}
|
||||||
|
|
||||||
|
if (typeof gainValue !== 'number' || gainValue < -60.0 || gainValue > 0.0) {
|
||||||
|
return Promise.reject(new Error('Gain value must be between -60.0 and 0.0.'))
|
||||||
|
}
|
||||||
|
// Convert dB (-60.0 to 0.0) to linear gain (0 to 1)
|
||||||
|
const dbDisplay = Math.pow(10, gainValue / 20)
|
||||||
|
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
meld.setGain(itemId, dbDisplay)
|
||||||
|
.then(() => {
|
||||||
|
resolve(`Audio track ${style.highlight(audioName)} gain set to ${gainValue}.`)
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
reject(new Error(`Error setting audio gain: ${err.message}`))
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
export {
|
export {
|
||||||
audioHelp,
|
audioHelp,
|
||||||
audioList,
|
audioList,
|
||||||
audioMute,
|
audioMute,
|
||||||
audioUnmute,
|
audioUnmute,
|
||||||
audioToggle,
|
audioToggle,
|
||||||
audioStatus
|
audioStatus,
|
||||||
|
audioGain
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user