f@0
|
1 /*
|
f@0
|
2 Cross-Modal DAW Prototype - Prototype of a simple Cross-Modal Digital Audio Workstation.
|
f@0
|
3
|
f@0
|
4 Copyright (C) 2015 Queen Mary University of London (http://depic.eecs.qmul.ac.uk/)
|
f@0
|
5
|
f@0
|
6 This program is free software: you can redistribute it and/or modify
|
f@0
|
7 it under the terms of the GNU General Public License as published by
|
f@0
|
8 the Free Software Foundation, either version 3 of the License, or
|
f@0
|
9 (at your option) any later version.
|
f@0
|
10
|
f@0
|
11 This program is distributed in the hope that it will be useful,
|
f@0
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
f@0
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
f@0
|
14 GNU General Public License for more details.
|
f@0
|
15
|
f@0
|
16 You should have received a copy of the GNU General Public License
|
f@0
|
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
|
f@0
|
18 */
|
f@0
|
19 package uk.ac.qmul.eecs.depic.daw.gui;
|
f@0
|
20
|
f@0
|
21 import java.beans.PropertyChangeEvent;
|
f@0
|
22 import java.beans.PropertyChangeListener;
|
f@0
|
23
|
f@0
|
24 import javax.swing.event.ChangeEvent;
|
f@0
|
25 import javax.swing.event.ChangeListener;
|
f@0
|
26
|
f@0
|
27 import uk.ac.qmul.eecs.depic.daw.Daw;
|
f@0
|
28 import uk.ac.qmul.eecs.depic.daw.Selection;
|
f@0
|
29 import uk.ac.qmul.eecs.depic.daw.Sonification;
|
f@0
|
30 import uk.ac.qmul.eecs.depic.daw.SoundType;
|
f@0
|
31 import uk.ac.qmul.eecs.depic.daw.SoundWave;
|
f@0
|
32
|
f@2
|
33 /**
|
f@2
|
34 * Plays sonification sounds of the audio track through the member variable of
|
f@2
|
35 * type {@code Sonification} that is initialized with {@code Daw.getSoundEngineFactory().getSharedSonification()}
|
f@2
|
36 *
|
f@2
|
37 * Listen to property changes of AudioTrack objects ("cursorPos" and "mouseDragSelection" properties)
|
f@2
|
38 * and to changes of sequence graphs (automation graphs) objects.
|
f@2
|
39 *
|
f@2
|
40 */
|
f@0
|
41 class AudioTrackSonification implements PropertyChangeListener, ChangeListener {
|
f@0
|
42 private Sonification sonification = Daw.getSoundEngineFactory().getSharedSonification();
|
f@0
|
43 private AudioTrack track;
|
f@0
|
44
|
f@0
|
45 AudioTrackSonification(AudioTrack track){
|
f@0
|
46 this.track = track;
|
f@0
|
47 }
|
f@0
|
48
|
f@0
|
49 @Override
|
f@0
|
50 public void propertyChange(PropertyChangeEvent evt) {
|
f@0
|
51 if("cursorPos".equals(evt.getPropertyName())){
|
f@0
|
52 AudioTrack track = (AudioTrack)evt.getSource();
|
f@0
|
53 SoundWave soundWave = track.getSoundWave();
|
f@0
|
54 int newPos = (Integer)evt.getNewValue();
|
f@0
|
55
|
f@0
|
56 if(soundWave.hasSequence()){
|
f@0
|
57 /* check if the cursor stumbled upon or left an automation point */
|
f@0
|
58 for(SequencePoint p : track.getAutomationGraph().getSequencePoints()){
|
f@0
|
59 if(p.isXCentredAt(newPos)){
|
f@0
|
60 sonification.getSequenceMapping(SoundType.AUTOMATION).renderValue(p.getSequenceValue()); //FIXME remove comments
|
f@0
|
61 }
|
f@0
|
62 }
|
f@0
|
63
|
f@0
|
64 if(track.showAutomationSound){
|
f@0
|
65 sonification.getSequenceMapping(SoundType.AUTOMATION).renderCurveAt(
|
f@0
|
66 soundWave.getSequence(),
|
f@0
|
67 soundWave.getMillisecPerChunk() * newPos,
|
f@0
|
68 Float.POSITIVE_INFINITY);
|
f@0
|
69 }
|
f@0
|
70 }
|
f@0
|
71
|
f@0
|
72 if(soundWave.getDbWave().hasSequence()){
|
f@0
|
73 /* check if the cursor stumbled upon or left an automation point */
|
f@0
|
74 // for(SequencePoint p : track.getPeakLevelGraph().getSequencePoints()){
|
f@0
|
75 // if(p.isXCentredAt(newPos)){
|
f@0
|
76 // sonification.getSequenceMapping(GuiSoundType.PEAK_LEVEL).renderValue(p.getSequenceValue());
|
f@0
|
77 // }
|
f@0
|
78 // }
|
f@0
|
79
|
f@0
|
80 if(track.showPeakLevelSound){
|
f@0
|
81 sonification.getSequenceMapping(SoundType.PEAK_LEVEL).renderCurveAt(
|
f@0
|
82 soundWave.getDbWave().getSequence(),
|
f@0
|
83 soundWave.getMillisecPerChunk() * newPos,
|
f@0
|
84 Float.POSITIVE_INFINITY);
|
f@0
|
85 }
|
f@0
|
86 }
|
f@0
|
87
|
f@0
|
88 if(track.trackInteraction.getMouseSelection().isOpen()){
|
f@0
|
89 return;
|
f@0
|
90 }
|
f@0
|
91
|
f@0
|
92 /* play selection sound if within selection, stop it if without */
|
f@0
|
93 if(track.trackInteraction.getMouseSelection().contains(newPos)){
|
f@0
|
94 sonification.withinSelection(1.0f, 0.0f);
|
f@0
|
95 }else {
|
f@0
|
96 sonification.outsideSelection();
|
f@0
|
97 }
|
f@0
|
98
|
f@0
|
99 if(track.trackInteraction.getMouseSelection().getStart() == newPos){
|
f@0
|
100 sonification.play(SoundType.SHIFT_START);
|
f@0
|
101 }else if(track.trackInteraction.getMouseSelection().getEnd() == newPos){
|
f@0
|
102 sonification.play(SoundType.SHIFT_END);
|
f@0
|
103 }
|
f@0
|
104 }else if("mouseDragSelection".equals(evt.getPropertyName())){
|
f@0
|
105 if( ((Selection)evt.getNewValue()).isOpen() ){
|
f@0
|
106 sonification.outsideSelection();
|
f@0
|
107 }
|
f@0
|
108 }
|
f@0
|
109 }
|
f@0
|
110
|
f@0
|
111 @Override
|
f@0
|
112 public void stateChanged(ChangeEvent evt) {
|
f@0
|
113 if(track.showAutomationSound){
|
f@0
|
114 SoundWave soundWave = track.getSoundWave();
|
f@0
|
115 sonification.getSequenceMapping(SoundType.AUTOMATION).renderCurveAt(
|
f@0
|
116 soundWave.getSequence(),
|
f@0
|
117 soundWave.getMillisecPerChunk() * soundWave.getCurrentChunkPosition(),
|
f@0
|
118 Float.POSITIVE_INFINITY);
|
f@0
|
119 }
|
f@0
|
120 }
|
f@0
|
121
|
f@0
|
122 }
|