11import uuidV4 from 'uuid/v4'
22import { map } from 'lodash'
3- import { newRecording } from '../../../../types/recording'
3+ import { newRecording , newOverdub } from '../../../../types/recording'
44import { startPlayback , stopPlayback } from '../../timelines/timelines'
55
66
7-
87export const MIDI_OVERDUB_RECORDING_STARTED = 'MIDI_OVERDUB_RECORDING_STARTED'
98export const MIDI_OVERDUB_RECORDING_STOPPED = 'MIDI_OVERDUB_RECORDING_STOPPED'
109export const MIDI_EVENT_RECORDED = 'MIDI_EVENT_RECORDED'
@@ -23,33 +22,15 @@ export const createNewMidiRecording = (recordingId = uuidV4()) => dispatch =>
2322 }
2423 } )
2524
26- /**
27- * startMidiOverdub creates a new overdub recording within a given recording.
28- *
29- * @param deviceId: the id of the input midi device being recorded. This is not
30- * stored in the redux store, but rather intercepted by the midi
31- * middleware.
32- * @param recordingId: the id of the recording for which this is an overdub.
33- * @param overdubId (optional)
34- */
35- // TODO (cw|2017.2017) get rid of this garbage, its not used anymore -____-
36- export const startMidiOverdub = ( deviceId , recordingId , overdubId = uuidV4 ( ) , timeOffset = 0 ) => dispatch => {
37- dispatch ( {
38- type : MIDI_OVERDUB_RECORDING_STARTED ,
39- payload : {
40- input : deviceId ,
41- recordingId,
42- overdub : newOverdub ( overdubId , timeOffset )
43- }
44- } )
45- }
46-
47- export const startMidiOverdubs = ( recordings , timelineId ) => dispatch => {
25+ export const startMidiOverdubs = ( recordingContexts , timelineId ) => dispatch => {
4826 // start overdub recording
4927 dispatch ( {
5028 type : MIDI_OVERDUB_RECORDING_STARTED ,
5129 payload : {
52- recordings : map ( recordings , recording => ( { ...recording , overdubId : uuidV4 ( ) } ) ) ,
30+ recordingContexts : map (
31+ recordingContexts ,
32+ recordingContext => ( { ...recordingContext , overdub : newOverdub ( uuidV4 ( ) , 0 ) } ) , // TODO (cw|10.29.2017) parameterize timeOffset
33+ ) ,
5334 timelineId,
5435 } ,
5536 } )
@@ -58,12 +39,12 @@ export const startMidiOverdubs = (recordings, timelineId) => dispatch => {
5839 dispatch ( startPlayback ( timelineId ) )
5940}
6041
61- export const stopMidiOverdubs = ( recordings , timelineId ) => dispatch => {
42+ export const stopMidiOverdubs = ( recordingContexts , timelineId ) => dispatch => {
6243 // stop overdub recording
6344 dispatch ( {
6445 type : MIDI_OVERDUB_RECORDING_STOPPED ,
6546 payload : {
66- recordings ,
47+ recordingContexts ,
6748 timelineId,
6849 } ,
6950 } )
@@ -72,24 +53,6 @@ export const stopMidiOverdubs = (recordings, timelineId) => dispatch => {
7253 dispatch ( stopPlayback ( timelineId ) )
7354}
7455
75- /**
76- * stopMidiOverdub stops recording an overdub.
77- *
78- * @param deviceId
79- * @param recordingId
80- * @param overdubId
81- */
82- export const stopMidiOverdub = ( deviceId , recordingId , overdubId ) => dispatch => {
83- dispatch ( {
84- type : MIDI_OVERDUB_RECORDING_STOPPED ,
85- payload : {
86- input : deviceId ,
87- recordingId,
88- overdubId,
89- }
90- } )
91- }
92-
9356/**
9457 * recordMidiEvent records a midi event to a recording overdub. This action should
9558 * only be used by the midi-middleware.
@@ -98,11 +61,10 @@ export const stopMidiOverdub = (deviceId, recordingId, overdubId) => dispatch =>
9861 * @param overdubId
9962 * @param midiEvent
10063 */
101- export const recordMidiEvent = ( recordingId , overdubId , midiEvent ) => dispatch => {
64+ export const recordMidiEvent = ( overdubId , midiEvent ) => dispatch => {
10265 dispatch ( {
10366 type : MIDI_EVENT_RECORDED ,
10467 payload : {
105- recordingId,
10668 overdubId,
10769 event : midiEvent ,
10870 }
0 commit comments