opus-codec 0.0.41 → 0.0.43

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/native/index.d.ts CHANGED
@@ -1,4 +1,7 @@
1
- export interface EmscriptenRuntime {
1
+ type GeneratedOpusGettersAndSetters =
2
+ import('./opus-ts-getters-and-setters').GeneratedOpusGettersAndSetters;
3
+
4
+ export interface EmscriptenRuntime extends GeneratedOpusGettersAndSetters {
2
5
  HEAPU8: Uint8Array;
3
6
  _malloc(n: number): number;
4
7
  _size_of_int(): number;
package/native/index.js CHANGED
@@ -27,7 +27,7 @@ Module['ready'] = new Promise(function(resolve, reject) {
27
27
  readyPromiseResolve = resolve;
28
28
  readyPromiseReject = reject;
29
29
  });
30
- ["_size_of_int","_size_of_void_ptr","_malloc","_free","_opus_decoder_create","_opus_decoder_destroy","_opus_decode_float","_opus_encoder_create","_opus_encoder_destroy","_opus_encoder_ctl","_opus_encode_float","_fflush","onRuntimeInitialized"].forEach((prop) => {
30
+ ["_size_of_int","_size_of_void_ptr","_malloc","_free","_opus_decoder_create","_opus_decoder_destroy","_opus_decode_float","_opus_encoder_create","_opus_encoder_destroy","_opus_encoder_ctl","_opus_encode_float","_opus_set_complexity","_opus_get_complexity","_opus_set_bitrate","_opus_get_bitrate","_opus_set_vbr","_opus_get_vbr","_opus_set_vbr_constraint","_opus_get_vbr_constraint","_opus_set_force_channels","_opus_get_force_channels","_opus_set_max_bandwidth","_opus_get_max_bandwidth","_opus_set_bandwidth","_opus_set_signal","_opus_get_signal","_opus_set_application","_opus_get_application","_opus_get_lookahead","_opus_set_inband_fec","_opus_get_inband_fec","_opus_set_packet_loss_perc","_opus_get_packet_loss_perc","_opus_set_dtx","_opus_get_dtx","_opus_set_lsb_depth","_opus_get_lsb_depth","_opus_set_expert_frame_duration","_opus_get_expert_frame_duration","_opus_set_prediction_disabled","_opus_get_prediction_disabled","_opus_get_bandwidth","_opus_get_sample_rate","_opus_set_phase_inversion_disabled","_opus_get_phase_inversion_disabled","_opus_get_in_dtx","_opus_set_gain","_opus_get_gain","_opus_get_last_packet_duration","_opus_get_pitch","_fflush","onRuntimeInitialized"].forEach((prop) => {
31
31
  if (!Object.getOwnPropertyDescriptor(Module['ready'], prop)) {
32
32
  Object.defineProperty(Module['ready'], prop, {
33
33
  get: () => abort('You are getting ' + prop + ' on the Promise object, instead of the instance. Use .then() to get called back with the instance, see the MODULARIZE docs in src/settings.js'),
@@ -1381,6 +1381,84 @@ var _size_of_int = Module["_size_of_int"] = createExportWrapper("size_of_int");
1381
1381
  /** @type {function(...*):?} */
1382
1382
  var _size_of_void_ptr = Module["_size_of_void_ptr"] = createExportWrapper("size_of_void_ptr");
1383
1383
  /** @type {function(...*):?} */
1384
+ var _opus_set_complexity = Module["_opus_set_complexity"] = createExportWrapper("opus_set_complexity");
1385
+ /** @type {function(...*):?} */
1386
+ var _opus_get_complexity = Module["_opus_get_complexity"] = createExportWrapper("opus_get_complexity");
1387
+ /** @type {function(...*):?} */
1388
+ var _opus_set_bitrate = Module["_opus_set_bitrate"] = createExportWrapper("opus_set_bitrate");
1389
+ /** @type {function(...*):?} */
1390
+ var _opus_get_bitrate = Module["_opus_get_bitrate"] = createExportWrapper("opus_get_bitrate");
1391
+ /** @type {function(...*):?} */
1392
+ var _opus_set_vbr = Module["_opus_set_vbr"] = createExportWrapper("opus_set_vbr");
1393
+ /** @type {function(...*):?} */
1394
+ var _opus_get_vbr = Module["_opus_get_vbr"] = createExportWrapper("opus_get_vbr");
1395
+ /** @type {function(...*):?} */
1396
+ var _opus_set_vbr_constraint = Module["_opus_set_vbr_constraint"] = createExportWrapper("opus_set_vbr_constraint");
1397
+ /** @type {function(...*):?} */
1398
+ var _opus_get_vbr_constraint = Module["_opus_get_vbr_constraint"] = createExportWrapper("opus_get_vbr_constraint");
1399
+ /** @type {function(...*):?} */
1400
+ var _opus_set_force_channels = Module["_opus_set_force_channels"] = createExportWrapper("opus_set_force_channels");
1401
+ /** @type {function(...*):?} */
1402
+ var _opus_get_force_channels = Module["_opus_get_force_channels"] = createExportWrapper("opus_get_force_channels");
1403
+ /** @type {function(...*):?} */
1404
+ var _opus_set_max_bandwidth = Module["_opus_set_max_bandwidth"] = createExportWrapper("opus_set_max_bandwidth");
1405
+ /** @type {function(...*):?} */
1406
+ var _opus_get_max_bandwidth = Module["_opus_get_max_bandwidth"] = createExportWrapper("opus_get_max_bandwidth");
1407
+ /** @type {function(...*):?} */
1408
+ var _opus_set_bandwidth = Module["_opus_set_bandwidth"] = createExportWrapper("opus_set_bandwidth");
1409
+ /** @type {function(...*):?} */
1410
+ var _opus_set_signal = Module["_opus_set_signal"] = createExportWrapper("opus_set_signal");
1411
+ /** @type {function(...*):?} */
1412
+ var _opus_get_signal = Module["_opus_get_signal"] = createExportWrapper("opus_get_signal");
1413
+ /** @type {function(...*):?} */
1414
+ var _opus_set_application = Module["_opus_set_application"] = createExportWrapper("opus_set_application");
1415
+ /** @type {function(...*):?} */
1416
+ var _opus_get_application = Module["_opus_get_application"] = createExportWrapper("opus_get_application");
1417
+ /** @type {function(...*):?} */
1418
+ var _opus_get_lookahead = Module["_opus_get_lookahead"] = createExportWrapper("opus_get_lookahead");
1419
+ /** @type {function(...*):?} */
1420
+ var _opus_set_inband_fec = Module["_opus_set_inband_fec"] = createExportWrapper("opus_set_inband_fec");
1421
+ /** @type {function(...*):?} */
1422
+ var _opus_get_inband_fec = Module["_opus_get_inband_fec"] = createExportWrapper("opus_get_inband_fec");
1423
+ /** @type {function(...*):?} */
1424
+ var _opus_set_packet_loss_perc = Module["_opus_set_packet_loss_perc"] = createExportWrapper("opus_set_packet_loss_perc");
1425
+ /** @type {function(...*):?} */
1426
+ var _opus_get_packet_loss_perc = Module["_opus_get_packet_loss_perc"] = createExportWrapper("opus_get_packet_loss_perc");
1427
+ /** @type {function(...*):?} */
1428
+ var _opus_set_dtx = Module["_opus_set_dtx"] = createExportWrapper("opus_set_dtx");
1429
+ /** @type {function(...*):?} */
1430
+ var _opus_get_dtx = Module["_opus_get_dtx"] = createExportWrapper("opus_get_dtx");
1431
+ /** @type {function(...*):?} */
1432
+ var _opus_set_lsb_depth = Module["_opus_set_lsb_depth"] = createExportWrapper("opus_set_lsb_depth");
1433
+ /** @type {function(...*):?} */
1434
+ var _opus_get_lsb_depth = Module["_opus_get_lsb_depth"] = createExportWrapper("opus_get_lsb_depth");
1435
+ /** @type {function(...*):?} */
1436
+ var _opus_set_expert_frame_duration = Module["_opus_set_expert_frame_duration"] = createExportWrapper("opus_set_expert_frame_duration");
1437
+ /** @type {function(...*):?} */
1438
+ var _opus_get_expert_frame_duration = Module["_opus_get_expert_frame_duration"] = createExportWrapper("opus_get_expert_frame_duration");
1439
+ /** @type {function(...*):?} */
1440
+ var _opus_set_prediction_disabled = Module["_opus_set_prediction_disabled"] = createExportWrapper("opus_set_prediction_disabled");
1441
+ /** @type {function(...*):?} */
1442
+ var _opus_get_prediction_disabled = Module["_opus_get_prediction_disabled"] = createExportWrapper("opus_get_prediction_disabled");
1443
+ /** @type {function(...*):?} */
1444
+ var _opus_get_bandwidth = Module["_opus_get_bandwidth"] = createExportWrapper("opus_get_bandwidth");
1445
+ /** @type {function(...*):?} */
1446
+ var _opus_get_sample_rate = Module["_opus_get_sample_rate"] = createExportWrapper("opus_get_sample_rate");
1447
+ /** @type {function(...*):?} */
1448
+ var _opus_set_phase_inversion_disabled = Module["_opus_set_phase_inversion_disabled"] = createExportWrapper("opus_set_phase_inversion_disabled");
1449
+ /** @type {function(...*):?} */
1450
+ var _opus_get_phase_inversion_disabled = Module["_opus_get_phase_inversion_disabled"] = createExportWrapper("opus_get_phase_inversion_disabled");
1451
+ /** @type {function(...*):?} */
1452
+ var _opus_get_in_dtx = Module["_opus_get_in_dtx"] = createExportWrapper("opus_get_in_dtx");
1453
+ /** @type {function(...*):?} */
1454
+ var _opus_set_gain = Module["_opus_set_gain"] = createExportWrapper("opus_set_gain");
1455
+ /** @type {function(...*):?} */
1456
+ var _opus_get_gain = Module["_opus_get_gain"] = createExportWrapper("opus_get_gain");
1457
+ /** @type {function(...*):?} */
1458
+ var _opus_get_last_packet_duration = Module["_opus_get_last_packet_duration"] = createExportWrapper("opus_get_last_packet_duration");
1459
+ /** @type {function(...*):?} */
1460
+ var _opus_get_pitch = Module["_opus_get_pitch"] = createExportWrapper("opus_get_pitch");
1461
+ /** @type {function(...*):?} */
1384
1462
  var ___errno_location = createExportWrapper("__errno_location");
1385
1463
  /** @type {function(...*):?} */
1386
1464
  var _fflush = Module["_fflush"] = createExportWrapper("fflush");
package/native/index.wasm CHANGED
Binary file
@@ -0,0 +1,41 @@
1
+ export type GeneratedOpusGettersAndSetters = {
2
+ _opus_set_complexity(enc: number,value: number): number;
3
+ _opus_get_complexity(enc: number,value: number): number;
4
+ _opus_set_bitrate(enc: number,value: number): number;
5
+ _opus_get_bitrate(enc: number,value: number): number;
6
+ _opus_set_vbr(enc: number,value: number): number;
7
+ _opus_get_vbr(enc: number,value: number): number;
8
+ _opus_set_vbr_constraint(enc: number,value: number): number;
9
+ _opus_get_vbr_constraint(enc: number,value: number): number;
10
+ _opus_set_force_channels(enc: number,value: number): number;
11
+ _opus_get_force_channels(enc: number,value: number): number;
12
+ _opus_set_max_bandwidth(enc: number,value: number): number;
13
+ _opus_get_max_bandwidth(enc: number,value: number): number;
14
+ _opus_set_bandwidth(enc: number,value: number): number;
15
+ _opus_set_signal(enc: number,value: number): number;
16
+ _opus_get_signal(enc: number,value: number): number;
17
+ _opus_set_application(enc: number,value: number): number;
18
+ _opus_get_application(enc: number,value: number): number;
19
+ _opus_get_lookahead(enc: number,value: number): number;
20
+ _opus_set_inband_fec(enc: number,value: number): number;
21
+ _opus_get_inband_fec(enc: number,value: number): number;
22
+ _opus_set_packet_loss_perc(enc: number,value: number): number;
23
+ _opus_get_packet_loss_perc(enc: number,value: number): number;
24
+ _opus_set_dtx(enc: number,value: number): number;
25
+ _opus_get_dtx(enc: number,value: number): number;
26
+ _opus_set_lsb_depth(enc: number,value: number): number;
27
+ _opus_get_lsb_depth(enc: number,value: number): number;
28
+ _opus_set_expert_frame_duration(enc: number,value: number): number;
29
+ _opus_get_expert_frame_duration(enc: number,value: number): number;
30
+ _opus_set_prediction_disabled(enc: number,value: number): number;
31
+ _opus_get_prediction_disabled(enc: number,value: number): number;
32
+ _opus_get_bandwidth(enc: number,value: number): number;
33
+ _opus_get_sample_rate(enc: number,value: number): number;
34
+ _opus_set_phase_inversion_disabled(enc: number,value: number): number;
35
+ _opus_get_phase_inversion_disabled(enc: number,value: number): number;
36
+ _opus_get_in_dtx(enc: number,value: number): number;
37
+ _opus_set_gain(enc: number,value: number): number;
38
+ _opus_get_gain(enc: number,value: number): number;
39
+ _opus_get_last_packet_duration(enc: number,value: number): number;
40
+ _opus_get_pitch(enc: number,value: number): number;
41
+ };
package/opus/Encoder.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { Runtime } from "../runtime";
2
- export default class Encoder {
1
+ import { Runtime } from '../runtime';
2
+ import { OpusGettersAndSetters } from './OpusGettersAndSetters';
3
+ export default class Encoder extends OpusGettersAndSetters {
3
4
  #private;
4
5
  constructor(runtime: Runtime, sampleRate: number, channels: number, application: number,
5
6
  /**
package/opus/Encoder.js CHANGED
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const runtime_1 = require("../runtime");
4
- class Encoder {
5
- #errorPointer;
4
+ const OpusGettersAndSetters_1 = require("./OpusGettersAndSetters");
5
+ class Encoder extends OpusGettersAndSetters_1.OpusGettersAndSetters {
6
6
  #error;
7
7
  #runtime;
8
8
  #encoder;
@@ -18,13 +18,14 @@ class Encoder {
18
18
  * how many bytes will we be receiving through encodeFloat() function
19
19
  */
20
20
  pcmBufferLength) {
21
- if (!outBufferLength) {
22
- throw new Error("outBufferLength must be more than 0");
23
- }
21
+ const error = new runtime_1.Integer(runtime);
22
+ const encoderId = runtime
23
+ .originalRuntime()
24
+ ._opus_encoder_create(sampleRate, channels, application, error.offset());
25
+ super(runtime, encoderId);
24
26
  this.#holder = new runtime_1.ResourcesHolder();
25
- this.#error = new runtime_1.Integer(runtime);
27
+ this.#error = error;
26
28
  this.#runtime = runtime;
27
- this.#errorPointer = new runtime_1.Pointer(runtime, this.#error);
28
29
  /**
29
30
  * pcm buffer
30
31
  */
@@ -38,16 +39,16 @@ class Encoder {
38
39
  */
39
40
  this.#holder.add(this.#encoded);
40
41
  this.#holder.add(this.#pcm);
41
- this.#holder.add(this.#errorPointer);
42
42
  this.#holder.add(this.#error);
43
43
  /**
44
44
  * create encoder
45
45
  */
46
- this.#encoder = runtime
47
- .originalRuntime()
48
- ._opus_encoder_create(sampleRate, channels, application, this.#errorPointer.value());
49
- if (this.#error.value() < 0) {
50
- throw new Error("Failed to create encoder");
46
+ this.#encoder = encoderId;
47
+ if (error.value() < 0) {
48
+ throw new Error('Failed to create encoder');
49
+ }
50
+ if (!outBufferLength) {
51
+ throw new Error('outBufferLength must be more than 0');
51
52
  }
52
53
  }
53
54
  encoded() {
@@ -0,0 +1,44 @@
1
+ import { Runtime } from '../runtime';
2
+ export declare class OpusGettersAndSetters {
3
+ #private;
4
+ constructor(runtime: Runtime, opusEncoderOffset: number);
5
+ setComplexity(x: number): boolean;
6
+ getComplexity(): number;
7
+ setBitrate(x: number): boolean;
8
+ getBitrate(): number;
9
+ setVbr(x: number): boolean;
10
+ getVbr(): number;
11
+ setVbrConstraint(x: number): boolean;
12
+ getVbrConstraint(): number;
13
+ setForceChannels(x: number): boolean;
14
+ getForceChannels(): number;
15
+ setMaxBandwidth(x: number): boolean;
16
+ getMaxBandwidth(): number;
17
+ setBandwidth(x: number): boolean;
18
+ setSignal(x: number): boolean;
19
+ getSignal(): number;
20
+ setApplication(x: number): boolean;
21
+ getApplication(): number;
22
+ getLookahead(): number;
23
+ setInbandFec(x: number): boolean;
24
+ getInbandFec(): number;
25
+ setPacketLossperc(x: number): boolean;
26
+ getPacketLossperc(): number;
27
+ setDtx(x: number): boolean;
28
+ getDtx(): number;
29
+ setLsbDepth(x: number): boolean;
30
+ getLsbDepth(): number;
31
+ setExpertFrameduration(x: number): boolean;
32
+ getExpertFrameduration(): number;
33
+ setPredictionDisabled(x: number): boolean;
34
+ getPredictionDisabled(): number;
35
+ getBandwidth(): number;
36
+ getSampleRate(): number;
37
+ setPhaseInversiondisabled(x: number): boolean;
38
+ getPhaseInversiondisabled(): number;
39
+ getInDtx(): number;
40
+ setGain(x: number): boolean;
41
+ getGain(): number;
42
+ getLastPacketduration(): number;
43
+ getPitch(): number;
44
+ }
@@ -0,0 +1,219 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.OpusGettersAndSetters = void 0;
7
+ const runtime_1 = require("../runtime");
8
+ const constants_1 = __importDefault(require("./constants"));
9
+ class OpusGettersAndSetters {
10
+ #opusEncoderOffset;
11
+ #runtime;
12
+ #value;
13
+ constructor(runtime, opusEncoderOffset) {
14
+ this.#runtime = runtime;
15
+ this.#value = new runtime_1.Integer(runtime);
16
+ this.#opusEncoderOffset = opusEncoderOffset;
17
+ }
18
+ setComplexity(x) {
19
+ const result = this.#runtime.originalRuntime()._opus_set_complexity(this.#opusEncoderOffset, x);
20
+ return result === constants_1.default.OPUS_OK;
21
+ }
22
+ getComplexity() {
23
+ const result = this.#runtime.originalRuntime()._opus_get_complexity(this.#opusEncoderOffset, this.#value.offset());
24
+ if (result != constants_1.default.OPUS_OK)
25
+ throw new Error('Failed to set OPUS_GET_COMPLEXITY');
26
+ return this.#value.value();
27
+ }
28
+ setBitrate(x) {
29
+ const result = this.#runtime.originalRuntime()._opus_set_bitrate(this.#opusEncoderOffset, x);
30
+ return result === constants_1.default.OPUS_OK;
31
+ }
32
+ getBitrate() {
33
+ const result = this.#runtime.originalRuntime()._opus_get_bitrate(this.#opusEncoderOffset, this.#value.offset());
34
+ if (result != constants_1.default.OPUS_OK)
35
+ throw new Error('Failed to set OPUS_GET_BITRATE');
36
+ return this.#value.value();
37
+ }
38
+ setVbr(x) {
39
+ const result = this.#runtime.originalRuntime()._opus_set_vbr(this.#opusEncoderOffset, x);
40
+ return result === constants_1.default.OPUS_OK;
41
+ }
42
+ getVbr() {
43
+ const result = this.#runtime.originalRuntime()._opus_get_vbr(this.#opusEncoderOffset, this.#value.offset());
44
+ if (result != constants_1.default.OPUS_OK)
45
+ throw new Error('Failed to set OPUS_GET_VBR');
46
+ return this.#value.value();
47
+ }
48
+ setVbrConstraint(x) {
49
+ const result = this.#runtime.originalRuntime()._opus_set_vbr_constraint(this.#opusEncoderOffset, x);
50
+ return result === constants_1.default.OPUS_OK;
51
+ }
52
+ getVbrConstraint() {
53
+ const result = this.#runtime.originalRuntime()._opus_get_vbr_constraint(this.#opusEncoderOffset, this.#value.offset());
54
+ if (result != constants_1.default.OPUS_OK)
55
+ throw new Error('Failed to set OPUS_GET_VBR_CONSTRAINT');
56
+ return this.#value.value();
57
+ }
58
+ setForceChannels(x) {
59
+ const result = this.#runtime.originalRuntime()._opus_set_force_channels(this.#opusEncoderOffset, x);
60
+ return result === constants_1.default.OPUS_OK;
61
+ }
62
+ getForceChannels() {
63
+ const result = this.#runtime.originalRuntime()._opus_get_force_channels(this.#opusEncoderOffset, this.#value.offset());
64
+ if (result != constants_1.default.OPUS_OK)
65
+ throw new Error('Failed to set OPUS_GET_FORCE_CHANNELS');
66
+ return this.#value.value();
67
+ }
68
+ setMaxBandwidth(x) {
69
+ const result = this.#runtime.originalRuntime()._opus_set_max_bandwidth(this.#opusEncoderOffset, x);
70
+ return result === constants_1.default.OPUS_OK;
71
+ }
72
+ getMaxBandwidth() {
73
+ const result = this.#runtime.originalRuntime()._opus_get_max_bandwidth(this.#opusEncoderOffset, this.#value.offset());
74
+ if (result != constants_1.default.OPUS_OK)
75
+ throw new Error('Failed to set OPUS_GET_MAX_BANDWIDTH');
76
+ return this.#value.value();
77
+ }
78
+ setBandwidth(x) {
79
+ const result = this.#runtime.originalRuntime()._opus_set_bandwidth(this.#opusEncoderOffset, x);
80
+ return result === constants_1.default.OPUS_OK;
81
+ }
82
+ setSignal(x) {
83
+ const result = this.#runtime.originalRuntime()._opus_set_signal(this.#opusEncoderOffset, x);
84
+ return result === constants_1.default.OPUS_OK;
85
+ }
86
+ getSignal() {
87
+ const result = this.#runtime.originalRuntime()._opus_get_signal(this.#opusEncoderOffset, this.#value.offset());
88
+ if (result != constants_1.default.OPUS_OK)
89
+ throw new Error('Failed to set OPUS_GET_SIGNAL');
90
+ return this.#value.value();
91
+ }
92
+ setApplication(x) {
93
+ const result = this.#runtime.originalRuntime()._opus_set_application(this.#opusEncoderOffset, x);
94
+ return result === constants_1.default.OPUS_OK;
95
+ }
96
+ getApplication() {
97
+ const result = this.#runtime.originalRuntime()._opus_get_application(this.#opusEncoderOffset, this.#value.offset());
98
+ if (result != constants_1.default.OPUS_OK)
99
+ throw new Error('Failed to set OPUS_GET_APPLICATION');
100
+ return this.#value.value();
101
+ }
102
+ getLookahead() {
103
+ const result = this.#runtime.originalRuntime()._opus_get_lookahead(this.#opusEncoderOffset, this.#value.offset());
104
+ if (result != constants_1.default.OPUS_OK)
105
+ throw new Error('Failed to set OPUS_GET_LOOKAHEAD');
106
+ return this.#value.value();
107
+ }
108
+ setInbandFec(x) {
109
+ const result = this.#runtime.originalRuntime()._opus_set_inband_fec(this.#opusEncoderOffset, x);
110
+ return result === constants_1.default.OPUS_OK;
111
+ }
112
+ getInbandFec() {
113
+ const result = this.#runtime.originalRuntime()._opus_get_inband_fec(this.#opusEncoderOffset, this.#value.offset());
114
+ if (result != constants_1.default.OPUS_OK)
115
+ throw new Error('Failed to set OPUS_GET_INBAND_FEC');
116
+ return this.#value.value();
117
+ }
118
+ setPacketLossperc(x) {
119
+ const result = this.#runtime.originalRuntime()._opus_set_packet_loss_perc(this.#opusEncoderOffset, x);
120
+ return result === constants_1.default.OPUS_OK;
121
+ }
122
+ getPacketLossperc() {
123
+ const result = this.#runtime.originalRuntime()._opus_get_packet_loss_perc(this.#opusEncoderOffset, this.#value.offset());
124
+ if (result != constants_1.default.OPUS_OK)
125
+ throw new Error('Failed to set OPUS_GET_PACKET_LOSS_PERC');
126
+ return this.#value.value();
127
+ }
128
+ setDtx(x) {
129
+ const result = this.#runtime.originalRuntime()._opus_set_dtx(this.#opusEncoderOffset, x);
130
+ return result === constants_1.default.OPUS_OK;
131
+ }
132
+ getDtx() {
133
+ const result = this.#runtime.originalRuntime()._opus_get_dtx(this.#opusEncoderOffset, this.#value.offset());
134
+ if (result != constants_1.default.OPUS_OK)
135
+ throw new Error('Failed to set OPUS_GET_DTX');
136
+ return this.#value.value();
137
+ }
138
+ setLsbDepth(x) {
139
+ const result = this.#runtime.originalRuntime()._opus_set_lsb_depth(this.#opusEncoderOffset, x);
140
+ return result === constants_1.default.OPUS_OK;
141
+ }
142
+ getLsbDepth() {
143
+ const result = this.#runtime.originalRuntime()._opus_get_lsb_depth(this.#opusEncoderOffset, this.#value.offset());
144
+ if (result != constants_1.default.OPUS_OK)
145
+ throw new Error('Failed to set OPUS_GET_LSB_DEPTH');
146
+ return this.#value.value();
147
+ }
148
+ setExpertFrameduration(x) {
149
+ const result = this.#runtime.originalRuntime()._opus_set_expert_frame_duration(this.#opusEncoderOffset, x);
150
+ return result === constants_1.default.OPUS_OK;
151
+ }
152
+ getExpertFrameduration() {
153
+ const result = this.#runtime.originalRuntime()._opus_get_expert_frame_duration(this.#opusEncoderOffset, this.#value.offset());
154
+ if (result != constants_1.default.OPUS_OK)
155
+ throw new Error('Failed to set OPUS_GET_EXPERT_FRAME_DURATION');
156
+ return this.#value.value();
157
+ }
158
+ setPredictionDisabled(x) {
159
+ const result = this.#runtime.originalRuntime()._opus_set_prediction_disabled(this.#opusEncoderOffset, x);
160
+ return result === constants_1.default.OPUS_OK;
161
+ }
162
+ getPredictionDisabled() {
163
+ const result = this.#runtime.originalRuntime()._opus_get_prediction_disabled(this.#opusEncoderOffset, this.#value.offset());
164
+ if (result != constants_1.default.OPUS_OK)
165
+ throw new Error('Failed to set OPUS_GET_PREDICTION_DISABLED');
166
+ return this.#value.value();
167
+ }
168
+ getBandwidth() {
169
+ const result = this.#runtime.originalRuntime()._opus_get_bandwidth(this.#opusEncoderOffset, this.#value.offset());
170
+ if (result != constants_1.default.OPUS_OK)
171
+ throw new Error('Failed to set OPUS_GET_BANDWIDTH');
172
+ return this.#value.value();
173
+ }
174
+ getSampleRate() {
175
+ const result = this.#runtime.originalRuntime()._opus_get_sample_rate(this.#opusEncoderOffset, this.#value.offset());
176
+ if (result != constants_1.default.OPUS_OK)
177
+ throw new Error('Failed to set OPUS_GET_SAMPLE_RATE');
178
+ return this.#value.value();
179
+ }
180
+ setPhaseInversiondisabled(x) {
181
+ const result = this.#runtime.originalRuntime()._opus_set_phase_inversion_disabled(this.#opusEncoderOffset, x);
182
+ return result === constants_1.default.OPUS_OK;
183
+ }
184
+ getPhaseInversiondisabled() {
185
+ const result = this.#runtime.originalRuntime()._opus_get_phase_inversion_disabled(this.#opusEncoderOffset, this.#value.offset());
186
+ if (result != constants_1.default.OPUS_OK)
187
+ throw new Error('Failed to set OPUS_GET_PHASE_INVERSION_DISABLED');
188
+ return this.#value.value();
189
+ }
190
+ getInDtx() {
191
+ const result = this.#runtime.originalRuntime()._opus_get_in_dtx(this.#opusEncoderOffset, this.#value.offset());
192
+ if (result != constants_1.default.OPUS_OK)
193
+ throw new Error('Failed to set OPUS_GET_IN_DTX');
194
+ return this.#value.value();
195
+ }
196
+ setGain(x) {
197
+ const result = this.#runtime.originalRuntime()._opus_set_gain(this.#opusEncoderOffset, x);
198
+ return result === constants_1.default.OPUS_OK;
199
+ }
200
+ getGain() {
201
+ const result = this.#runtime.originalRuntime()._opus_get_gain(this.#opusEncoderOffset, this.#value.offset());
202
+ if (result != constants_1.default.OPUS_OK)
203
+ throw new Error('Failed to set OPUS_GET_GAIN');
204
+ return this.#value.value();
205
+ }
206
+ getLastPacketduration() {
207
+ const result = this.#runtime.originalRuntime()._opus_get_last_packet_duration(this.#opusEncoderOffset, this.#value.offset());
208
+ if (result != constants_1.default.OPUS_OK)
209
+ throw new Error('Failed to set OPUS_GET_LAST_PACKET_DURATION');
210
+ return this.#value.value();
211
+ }
212
+ getPitch() {
213
+ const result = this.#runtime.originalRuntime()._opus_get_pitch(this.#opusEncoderOffset, this.#value.offset());
214
+ if (result != constants_1.default.OPUS_OK)
215
+ throw new Error('Failed to set OPUS_GET_PITCH');
216
+ return this.#value.value();
217
+ }
218
+ }
219
+ exports.OpusGettersAndSetters = OpusGettersAndSetters;
@@ -0,0 +1,33 @@
1
+ declare const constants: {
2
+ OPUS_OK: number;
3
+ OPUS_BAD_ARG: number;
4
+ OPUS_BUFFER_TOO_SMALL: number;
5
+ OPUS_INTERNAL_ERROR: number;
6
+ OPUS_INVALID_PACKET: number;
7
+ OPUS_UNIMPLEMENTED: number;
8
+ OPUS_INVALID_STATE: number;
9
+ ' OPUS_ALLOC_FAIL': number;
10
+ OPUS_AUTO: number;
11
+ OPUS_BITRATE_MAX: number;
12
+ OPUS_APPLICATION_VOIP: number;
13
+ OPUS_APPLICATION_AUDIO: number;
14
+ OPUS_APPLICATION_RESTRICTED_LOWDELAY: number;
15
+ OPUS_SIGNAL_VOICE: number;
16
+ OPUS_SIGNAL_MUSIC: number;
17
+ OPUS_BANDWIDTH_NARROWBAND: number;
18
+ OPUS_BANDWIDTH_MEDIUMBAND: number;
19
+ OPUS_BANDWIDTH_WIDEBAND: number;
20
+ OPUS_BANDWIDTH_SUPERWIDEBAND: number;
21
+ OPUS_BANDWIDTH_FULLBAND: number;
22
+ OPUS_FRAMESIZE_ARG: number;
23
+ OPUS_FRAMESIZE_2_5_MS: number;
24
+ OPUS_FRAMESIZE_5_MS: number;
25
+ OPUS_FRAMESIZE_10_MS: number;
26
+ OPUS_FRAMESIZE_20_MS: number;
27
+ OPUS_FRAMESIZE_40_MS: number;
28
+ OPUS_FRAMESIZE_60_MS: number;
29
+ OPUS_FRAMESIZE_80_MS: number;
30
+ OPUS_FRAMESIZE_100_MS: number;
31
+ OPUS_FRAMESIZE_120_MS: number;
32
+ };
33
+ export default constants;
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const constants = {
4
+ 'OPUS_OK': 0,
5
+ 'OPUS_BAD_ARG': -1,
6
+ 'OPUS_BUFFER_TOO_SMALL': -2,
7
+ 'OPUS_INTERNAL_ERROR': -3,
8
+ 'OPUS_INVALID_PACKET': -4,
9
+ 'OPUS_UNIMPLEMENTED': -5,
10
+ 'OPUS_INVALID_STATE': -6,
11
+ ' OPUS_ALLOC_FAIL': -7,
12
+ 'OPUS_AUTO': -1000,
13
+ 'OPUS_BITRATE_MAX': -1,
14
+ 'OPUS_APPLICATION_VOIP': 2048,
15
+ 'OPUS_APPLICATION_AUDIO': 2049,
16
+ 'OPUS_APPLICATION_RESTRICTED_LOWDELAY': 2051,
17
+ 'OPUS_SIGNAL_VOICE': 3001,
18
+ 'OPUS_SIGNAL_MUSIC': 3002,
19
+ 'OPUS_BANDWIDTH_NARROWBAND': 1101,
20
+ 'OPUS_BANDWIDTH_MEDIUMBAND': 1102,
21
+ 'OPUS_BANDWIDTH_WIDEBAND': 1103,
22
+ 'OPUS_BANDWIDTH_SUPERWIDEBAND': 1104,
23
+ 'OPUS_BANDWIDTH_FULLBAND': 1105,
24
+ 'OPUS_FRAMESIZE_ARG': 5000,
25
+ 'OPUS_FRAMESIZE_2_5_MS': 5001,
26
+ 'OPUS_FRAMESIZE_5_MS': 5002,
27
+ 'OPUS_FRAMESIZE_10_MS': 5003,
28
+ 'OPUS_FRAMESIZE_20_MS': 5004,
29
+ 'OPUS_FRAMESIZE_40_MS': 5005,
30
+ 'OPUS_FRAMESIZE_60_MS': 5006,
31
+ 'OPUS_FRAMESIZE_80_MS': 5007,
32
+ 'OPUS_FRAMESIZE_100_MS': 5008,
33
+ 'OPUS_FRAMESIZE_120_MS': 5009,
34
+ };
35
+ exports.default = constants;
package/opus/index.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  export { default as Encoder } from './Encoder';
2
2
  export { default as Decoder } from './Decoder';
3
3
  export { default as RingBuffer } from './RingBuffer';
4
+ export { default as constants } from './constants';
package/opus/index.js CHANGED
@@ -3,10 +3,12 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
3
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
4
4
  };
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.RingBuffer = exports.Decoder = exports.Encoder = void 0;
6
+ exports.constants = exports.RingBuffer = exports.Decoder = exports.Encoder = void 0;
7
7
  var Encoder_1 = require("./Encoder");
8
8
  Object.defineProperty(exports, "Encoder", { enumerable: true, get: function () { return __importDefault(Encoder_1).default; } });
9
9
  var Decoder_1 = require("./Decoder");
10
10
  Object.defineProperty(exports, "Decoder", { enumerable: true, get: function () { return __importDefault(Decoder_1).default; } });
11
11
  var RingBuffer_1 = require("./RingBuffer");
12
12
  Object.defineProperty(exports, "RingBuffer", { enumerable: true, get: function () { return __importDefault(RingBuffer_1).default; } });
13
+ var constants_1 = require("./constants");
14
+ Object.defineProperty(exports, "constants", { enumerable: true, get: function () { return __importDefault(constants_1).default; } });
package/package.json CHANGED
@@ -1,7 +1,9 @@
1
1
  {
2
2
  "devDependencies": {
3
3
  "@types/node": "14.x",
4
+ "codestreamjs": "^0.0.1",
4
5
  "cxx-parser": "0.x",
6
+ "eslint": "8.x",
5
7
  "glob": "9.x",
6
8
  "prettier": "2.x",
7
9
  "ts-loader": "9.x",
@@ -11,13 +13,13 @@
11
13
  "webpack-cli": "5.x"
12
14
  },
13
15
  "name": "opus-codec",
14
- "version": "0.0.41",
16
+ "version": "0.0.43",
15
17
  "license": "MIT",
16
18
  "files": [
17
19
  "{native,runtime,opus}/*.{d.ts,js,wasm}"
18
20
  ],
19
21
  "scripts": {
20
- "prepublishOnly": "npx tsc -b opus runtime",
22
+ "prepublishOnly": "npx tsc -b test --force",
21
23
  "test": "npx ts-node test"
22
24
  },
23
25
  "dependencies": {
@@ -1,9 +1,10 @@
1
- import { IResource } from "./ResourcesHolder";
2
- import Runtime from "./Runtime";
1
+ import { IResource } from './ResourcesHolder';
2
+ import Runtime from './Runtime';
3
3
  export default class Integer implements IResource {
4
4
  #private;
5
5
  constructor(runtime: Runtime);
6
6
  value(): number;
7
+ set(value: number): void;
7
8
  size(): number;
8
9
  offset(): number;
9
10
  destroy(): void;
@@ -11,7 +11,10 @@ class Integer {
11
11
  if (this.#runtime.originalRuntime()._size_of_int() !== 4) {
12
12
  throw new Error('invalid integer byte size');
13
13
  }
14
- return this.#runtime.view().getInt32(this.#offset);
14
+ return this.#runtime.view().getInt32(this.#offset, true);
15
+ }
16
+ set(value) {
17
+ this.#runtime.view().setInt32(this.#offset, value, true);
15
18
  }
16
19
  size() {
17
20
  return this.#runtime.originalRuntime()._size_of_int();