mirror of
https://github.com/ggerganov/ggwave.git
synced 2026-02-06 16:47:59 +08:00
js, examples : fix a few minor issues caused by the recent API changes
This commit is contained in:
@@ -15,17 +15,21 @@ var factory = require('ggwave')
|
||||
factory().then(function(ggwave) {
|
||||
// create ggwave instance with default parameters
|
||||
var parameters = ggwave.getDefaultParameters();
|
||||
|
||||
parameters.operatingMode |= ggwave.GGWAVE_OPERATING_MODE_USE_DSS;
|
||||
|
||||
var instance = ggwave.init(parameters);
|
||||
console.log('instance: ' + instance);
|
||||
|
||||
var payload = 'hello js';
|
||||
|
||||
// generate audio waveform for string "hello js"
|
||||
var waveform = ggwave.encode(instance, payload, ggwave.TxProtocolId.GGWAVE_TX_PROTOCOL_AUDIBLE_FAST, 10);
|
||||
var waveform = ggwave.encode(instance, payload, ggwave.ProtocolId.GGWAVE_PROTOCOL_AUDIBLE_FAST, 10);
|
||||
|
||||
// decode the audio waveform back to text
|
||||
var res = ggwave.decode(instance, waveform);
|
||||
|
||||
if (res != payload) {
|
||||
if (new TextDecoder("utf-8").decode(res) != payload) {
|
||||
process.exit(1);
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user