Skip to content

Commit ebebc59

Browse files
committed
update examples
1 parent 12f80cd commit ebebc59

3 files changed

Lines changed: 7 additions & 12 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,6 @@ build
33
index.js
44
index.d.ts
55
node_modules
6+
yarn-error.log
67
*.wav
78
*.raw

examples/smokePlay.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,23 +17,20 @@
1717

1818
var portAudio = require('../index.js');
1919
var fs = require('fs');
20-
var rs = fs.createReadStream('test.wav');
21-
22-
var sampleRate = 48000;
20+
var file = fs.readFileSync('test.wav');
2321

2422
console.log(portAudio.getDevices());
2523

2624
var ao = new portAudio.AudioOutput({
27-
channelCount: 2,
25+
channelCount: 1,
2826
sampleFormat: portAudio.SampleFormat16Bit,
29-
sampleRate: sampleRate,
27+
sampleRate: 44100,
3028
deviceId: -1
3129
});
3230

33-
rs.pipe(ao);
34-
3531
ao.on('error', console.error);
36-
ao.once('finish', () => { console.log("Finish called."); });
3732
ao.start();
33+
ao.write(file);
34+
ao.end();
3835

3936
process.on('SIGINT', () => ao.quit());

examples/smokeSine.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ function tenSecondsIsh(writer, data, callback) {
5454
if (i > 0) {
5555
// had to stop early!
5656
// write some more once it drains
57-
console.log("So draining.");
5857
writer.once('drain', write);
5958
}
6059
}
@@ -65,6 +64,4 @@ ao.on('error', console.error);
6564
tenSecondsIsh(ao, buffer, console.log.bind(null, "Done!"));
6665
ao.start();
6766

68-
setTimeout(() => ao.abort(), 1000);
69-
70-
process.once('SIGINT', ao.quit);
67+
process.once('SIGINT', () => ao.quit());

0 commit comments

Comments
 (0)