You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+68-32
Original file line number
Diff line number
Diff line change
@@ -3,16 +3,16 @@
3
3
`synaudio` is a JavaScript library that finds the synchronization point between two similar audio clips.
4
4
* Synchronize two audio clips by finding the sample offset with the [Pearson correlation coefficient](https://en.wikipedia.org/wiki/Pearson_correlation_coefficient).
5
5
* Correlation algorithm implemented as WebAssembly SIMD.
6
-
* Built in Web Worker implementation for easy multithreading.
6
+
* Built in Web Worker implementations for concurrency.
7
7
8
8
---
9
9
10
10
*[Installing](#installing)
11
11
*[Usage](#usage)
12
12
*[API](#api)
13
13
*[Options](#options)
14
-
*[Types](#types)
15
14
*[Methods](#methods)
15
+
*[Types](#types)
16
16
17
17
## Installing
18
18
@@ -32,7 +32,7 @@
32
32
});
33
33
```
34
34
35
-
1. Call `sync`or `syncWorker` method on the instance to find the synchronization point in samples between two audio clips.
35
+
1. Call the `sync`, `syncWorker`, or `syncWorkerConcurrent` method on the instance to find the synchronization point in samples between two audio clips.
36
36
37
37
* See the [API](#api) section below for details on these methods.
38
38
@@ -50,12 +50,13 @@
50
50
}
51
51
52
52
const {
53
-
sampleOffset, // position relative to `base` where `comparison` matches best
54
-
correlation // covariance coefficient of the match [ ranging -1 (worst) to 1 (best) ]
55
-
} =awaitsynAudio.syncWorker(
56
-
base, // audio data to use a base for the comparison
57
-
comparison // audio data to compare against the base
58
-
);
53
+
sampleOffset, // position relative to `base` where `comparison` matches best
54
+
correlation, // covariance coefficient of the match [ ranging -1 (worst) to 1 (best) ]
55
+
} =awaitsynAudio.syncWorkerConcurrent(
56
+
base, // audio data to use a base for the comparison
57
+
comparison, // audio data to compare against the base
58
+
4// number of threads to spawn
59
+
);
59
60
```
60
61
61
62
## API
@@ -64,22 +65,74 @@
64
65
65
66
Class that that finds the synchronization point between two similar audio clips.
66
67
67
-
### Options
68
-
69
68
```js
70
-
constsynAudio=newSynAudio({
71
-
correlationSampleSize:5000,
72
-
initialGranularity:16,
69
+
newSynAudio({
70
+
correlationSampleSize:1234,
71
+
initialGranularity:1
73
72
});
74
73
```
75
74
75
+
### Options
76
+
```ts
77
+
declareinterfaceSynAudioOptions {
78
+
correlationSampleSize?:number; // default 11025
79
+
initialGranularity?:number; // default 16
80
+
}
81
+
```
76
82
*`correlationSampleSize`*optional, defaults to 11025*
77
83
* Number of samples to compare while finding the best offset
78
84
* Higher numbers will increase accuracy at the cost of slower computation
79
85
*`initialGranularity`*optional, defaults to 16*
80
86
* Number of samples to jump while performing the first pass search
81
87
* Higher numbers will decrease accuracy at the benefit of much faster computation
0 commit comments