@opendaw/studio-core 0.0.96 → 0.0.97
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RecordAudio.d.ts","sourceRoot":"","sources":["../../src/capture/RecordAudio.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,UAAU,EAAmB,MAAM,kBAAkB,CAAA;
|
|
1
|
+
{"version":3,"file":"RecordAudio.d.ts","sourceRoot":"","sources":["../../src/capture/RecordAudio.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,UAAU,EAAmB,MAAM,kBAAkB,CAAA;AAGvG,OAAO,EAAa,mBAAmB,EAA2B,MAAM,0BAA0B,CAAA;AAClG,OAAO,EAAC,OAAO,EAAC,MAAM,YAAY,CAAA;AAClC,OAAO,EAAC,gBAAgB,EAAC,MAAM,qBAAqB,CAAA;AACpD,OAAO,EAAC,OAAO,EAAC,MAAM,WAAW,CAAA;AAGjC,yBAAiB,WAAW,CAAC;IACzB,KAAK,kBAAkB,GAAG;QACtB,gBAAgB,EAAE,gBAAgB,CAAA;QAClC,UAAU,EAAE,SAAS,CAAA;QACrB,aAAa,EAAE,mBAAmB,CAAA;QAClC,OAAO,EAAE,OAAO,CAAA;QAChB,OAAO,EAAE,OAAO,CAAA;QAChB,aAAa,EAAE,MAAM,CAAA;KACxB,CAAA;IAOD,MAAM,CAAC,MAAM,KAAK,GACd,kFAAgF,kBAAkB,KAChG,UAkJL,CAAA;;CACJ"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { asInstanceOf, Option, quantizeFloor, Terminable, Terminator, UUID } from "@opendaw/lib-std";
|
|
2
2
|
import { PPQN, TimeBase } from "@opendaw/lib-dsp";
|
|
3
|
-
import { AudioFileBox,
|
|
3
|
+
import { AudioFileBox, AudioRegionBox, TrackBox, ValueEventCollectionBox } from "@opendaw/studio-boxes";
|
|
4
4
|
import { ColorCodes, TrackType, UnionBoxTypes } from "@opendaw/studio-adapters";
|
|
5
5
|
import { RecordTrack } from "./RecordTrack";
|
|
6
6
|
export var RecordAudio;
|
|
@@ -16,7 +16,7 @@ export var RecordAudio;
|
|
|
16
16
|
let lastPosition = 0;
|
|
17
17
|
let currentWaveformOffset = outputLatency;
|
|
18
18
|
let takeNumber = 0;
|
|
19
|
-
const {
|
|
19
|
+
const { env: { audioContext: { sampleRate } }, engine: { preferences: { settings: { recording } } } } = project;
|
|
20
20
|
const { loopArea } = timelineBox;
|
|
21
21
|
const createFileBox = () => {
|
|
22
22
|
const fileDateString = new Date()
|
|
@@ -32,32 +32,25 @@ export var RecordAudio;
|
|
|
32
32
|
takeNumber++;
|
|
33
33
|
const trackBox = RecordTrack.findOrCreate(editing, capture.audioUnitBox, TrackType.Audio, forceNewTrack);
|
|
34
34
|
const collectionBox = ValueEventCollectionBox.create(boxGraph, UUID.generate());
|
|
35
|
-
const stretchBox = AudioPitchStretchBox.create(boxGraph, UUID.generate());
|
|
36
|
-
WarpMarkerBox.create(boxGraph, UUID.generate(), box => box.owner.refer(stretchBox.warpMarkers));
|
|
37
|
-
const warpMarkerBox = WarpMarkerBox.create(boxGraph, UUID.generate(), box => box.owner.refer(stretchBox.warpMarkers));
|
|
38
35
|
const regionBox = AudioRegionBox.create(boxGraph, UUID.generate(), box => {
|
|
39
36
|
box.file.refer(fileBox.unwrap());
|
|
40
37
|
box.events.refer(collectionBox.owners);
|
|
41
38
|
box.regions.refer(trackBox.regions);
|
|
42
39
|
box.position.setValue(position);
|
|
43
40
|
box.hue.setValue(ColorCodes.forTrackType(TrackType.Audio));
|
|
44
|
-
box.timeBase.setValue(TimeBase.
|
|
41
|
+
box.timeBase.setValue(TimeBase.Seconds);
|
|
45
42
|
box.label.setValue(`Take ${takeNumber}`);
|
|
46
|
-
box.playMode.refer(stretchBox);
|
|
47
43
|
box.waveformOffset.setValue(waveformOffset);
|
|
48
44
|
});
|
|
49
45
|
capture.addRecordedRegion(regionBox);
|
|
50
46
|
project.selection.select(regionBox);
|
|
51
|
-
return { trackBox, regionBox
|
|
47
|
+
return { trackBox, regionBox };
|
|
52
48
|
};
|
|
53
|
-
const finalizeTake = (take,
|
|
54
|
-
const { trackBox, regionBox
|
|
49
|
+
const finalizeTake = (take, durationInSeconds) => {
|
|
50
|
+
const { trackBox, regionBox } = take;
|
|
55
51
|
if (regionBox.isAttached()) {
|
|
56
|
-
regionBox.duration.setValue(
|
|
57
|
-
regionBox.loopDuration.setValue(
|
|
58
|
-
const seconds = tempoMap.intervalToSeconds(0, loopDurationPPQN);
|
|
59
|
-
warpMarkerBox.position.setValue(loopDurationPPQN);
|
|
60
|
-
warpMarkerBox.seconds.setValue(seconds);
|
|
52
|
+
regionBox.duration.setValue(durationInSeconds);
|
|
53
|
+
regionBox.loopDuration.setValue(durationInSeconds);
|
|
61
54
|
}
|
|
62
55
|
const { olderTakeAction, olderTakeScope } = recording;
|
|
63
56
|
if (olderTakeScope === "all") {
|
|
@@ -110,7 +103,7 @@ export var RecordAudio;
|
|
|
110
103
|
}
|
|
111
104
|
else {
|
|
112
105
|
currentTake.ifSome(({ regionBox: { duration } }) => {
|
|
113
|
-
recordingWorklet.limit(Math.ceil((currentWaveformOffset +
|
|
106
|
+
recordingWorklet.limit(Math.ceil((currentWaveformOffset + duration.getValue()) * sampleRate));
|
|
114
107
|
});
|
|
115
108
|
fileBox.ifSome(fb => fb.endInSeconds.setValue(recordingWorklet.numberOfFrames / sampleRate));
|
|
116
109
|
}
|
|
@@ -121,14 +114,13 @@ export var RecordAudio;
|
|
|
121
114
|
const currentPosition = owner.getValue();
|
|
122
115
|
const loopEnabled = loopArea.enabled.getValue();
|
|
123
116
|
const loopFrom = loopArea.from.getValue();
|
|
124
|
-
const loopTo = loopArea.to.getValue();
|
|
125
117
|
const allowTakes = project.engine.preferences.settings.recording.allowTakes;
|
|
126
118
|
if (loopEnabled && allowTakes && currentTake.nonEmpty() && currentPosition < lastPosition) {
|
|
127
119
|
editing.modify(() => {
|
|
128
120
|
currentTake.ifSome(take => {
|
|
129
|
-
const
|
|
130
|
-
finalizeTake(take,
|
|
131
|
-
currentWaveformOffset +=
|
|
121
|
+
const actualDurationInSeconds = take.regionBox.duration.getValue();
|
|
122
|
+
finalizeTake(take, actualDurationInSeconds);
|
|
123
|
+
currentWaveformOffset += actualDurationInSeconds;
|
|
132
124
|
});
|
|
133
125
|
startNewTake(loopFrom);
|
|
134
126
|
}, false);
|
|
@@ -142,20 +134,16 @@ export var RecordAudio;
|
|
|
142
134
|
currentTake = Option.wrap(createTakeRegion(position, currentWaveformOffset, false));
|
|
143
135
|
}, false);
|
|
144
136
|
}
|
|
145
|
-
currentTake.ifSome(({ regionBox
|
|
137
|
+
currentTake.ifSome(({ regionBox }) => {
|
|
146
138
|
editing.modify(() => {
|
|
147
139
|
if (regionBox.isAttached()) {
|
|
148
140
|
const { duration, loopDuration } = regionBox;
|
|
149
|
-
const
|
|
150
|
-
const
|
|
151
|
-
duration.setValue(
|
|
152
|
-
loopDuration.setValue(
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const totalSamples = Math.ceil((currentWaveformOffset + seconds) * sampleRate);
|
|
156
|
-
recordingWorklet.setFillLength(totalSamples);
|
|
157
|
-
fileBox.ifSome(fb => fb.endInSeconds.setValue(totalSamples / sampleRate));
|
|
158
|
-
warpMarkerBox.seconds.setValue(seconds);
|
|
141
|
+
const totalSeconds = recordingWorklet.numberOfFrames / sampleRate;
|
|
142
|
+
const takeSeconds = totalSeconds - currentWaveformOffset;
|
|
143
|
+
duration.setValue(takeSeconds);
|
|
144
|
+
loopDuration.setValue(takeSeconds);
|
|
145
|
+
recordingWorklet.setFillLength(recordingWorklet.numberOfFrames);
|
|
146
|
+
fileBox.ifSome(fb => fb.endInSeconds.setValue(totalSeconds));
|
|
159
147
|
}
|
|
160
148
|
else {
|
|
161
149
|
terminator.terminate();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opendaw/studio-core",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.97",
|
|
4
4
|
"license": "LGPL-3.0-or-later",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -61,5 +61,5 @@
|
|
|
61
61
|
"@opendaw/studio-forge-boxes": "^0.0.70",
|
|
62
62
|
"@opendaw/typescript-config": "^0.0.28"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "358e4750820e821c3f39bb9b5aaa4227f982e955"
|
|
65
65
|
}
|