Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Volume Controller #13

Merged
merged 3 commits into from
Jun 14, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@
"type": "string",
"default": null,
"markdownDescription": "A glob targeting some uncompressed sounds files (`.wav` etc.). Leave blank for built-in voice lines. \nRestart required."
},
"hotheadedVSCode.voiceVolume": {
"type": "number",
"default": 1,
"description": "Volume level for voice playback (0.0 - 1.5)."
}
}
}
Expand All @@ -46,12 +51,14 @@
"devDependencies": {
"@types/glob": "^7.1.3",
"@types/node": "^13.13.21",
"@types/pcm-volume": "^1.0.0",
"@types/vscode": "^1.46.0",
"typescript": "^3.9.7",
"vsce": "^1.79.5"
},
"dependencies": {
"glob": "^7.1.6",
"pcm-volume": "^1.0.0",
"speaker": "^0.5.2"
}
}
11 changes: 10 additions & 1 deletion src/Player.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { workspace } from "vscode";
import * as Speaker from "speaker";
import * as fs from "fs";
import Volume = require("pcm-volume");
89netraM marked this conversation as resolved.
Show resolved Hide resolved

const playQueue: Array<string> = new Array<string>();
let isPlaying: boolean = false;
Expand All @@ -13,7 +15,14 @@ function play(file: string): void {
sampleRate: 44100,
final: donePlaying
});
fs.createReadStream(file).pipe(speaker);
const v = new Volume();
const voiceVolume = workspace
.getConfiguration("hotheadedVSCode")
.get<number>("voiceVolume") as number;
v.setVolume(voiceVolume);

v.pipe(speaker);
fs.createReadStream(file).pipe(v);
89netraM marked this conversation as resolved.
Show resolved Hide resolved
}
function donePlaying(): void {
isPlaying = false;
Expand Down