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;
|
f@0
|
20
|
f@0
|
21 import java.util.ArrayList;
|
f@0
|
22 import java.util.List;
|
f@0
|
23
|
f@1
|
24 /**
|
f@1
|
25 *
|
f@1
|
26 * a list of list of chunks corresponding to peaks in the sound wave. One list for each possible scaling factor.
|
f@1
|
27 *
|
f@1
|
28 */
|
f@0
|
29 public class WavePeaks extends ArrayList<List<Chunk>> {
|
f@0
|
30 private static final long serialVersionUID = 1L;
|
f@0
|
31 private boolean constructed;
|
f@0
|
32
|
f@0
|
33 public WavePeaks(int maxScaleFactor) {
|
f@0
|
34 super(maxScaleFactor+1);
|
f@0
|
35 /* wave peaks indexes the list of chunks by scale factor since there is
|
f@0
|
36 * no 0 scaleFactor the first position of the list is never used but it must
|
f@0
|
37 * be filled up in order to avoid index out of bounds exception */
|
f@0
|
38 for(int i=0; i<maxScaleFactor+1;i++)
|
f@0
|
39 add(null);
|
f@0
|
40 constructed = true;
|
f@0
|
41 }
|
f@0
|
42
|
f@0
|
43 @Override
|
f@0
|
44 public void add(int scaleFactor, List<Chunk> element){
|
f@0
|
45 if(constructed && scaleFactor == 0)
|
f@0
|
46 throw new IllegalArgumentException("scaleFactor cannot be 0");
|
f@0
|
47 super.set(scaleFactor, element);
|
f@0
|
48 }
|
f@0
|
49
|
f@0
|
50 @Override
|
f@0
|
51 public boolean add(List<Chunk> element){
|
f@0
|
52 if(constructed)
|
f@0
|
53 throw new UnsupportedOperationException("Use add(scaleFactor), List<ChunkElement>");
|
f@0
|
54 else
|
f@0
|
55 return super.add(element);
|
f@0
|
56 }
|
f@0
|
57
|
f@0
|
58
|
f@0
|
59 public List<Chunk> withScaleFactor(int scaleFactor){
|
f@0
|
60 return super.get(scaleFactor);
|
f@0
|
61 }
|
f@0
|
62
|
f@0
|
63 }
|