Mercurial > hg > cmdp
view src/uk/ac/qmul/eecs/depic/daw/WavePeaks.java @ 4:473da40f3d39 tip
added html formatting to Daw/package-info.java
author | Fiore Martin <f.martin@qmul.ac.uk> |
---|---|
date | Thu, 25 Feb 2016 17:50:09 +0000 |
parents | 629262395647 |
children |
line wrap: on
line source
/* Cross-Modal DAW Prototype - Prototype of a simple Cross-Modal Digital Audio Workstation. Copyright (C) 2015 Queen Mary University of London (http://depic.eecs.qmul.ac.uk/) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>. */ package uk.ac.qmul.eecs.depic.daw; import java.util.ArrayList; import java.util.List; /** * * a list of list of chunks corresponding to peaks in the sound wave. One list for each possible scaling factor. * */ public class WavePeaks extends ArrayList<List<Chunk>> { private static final long serialVersionUID = 1L; private boolean constructed; public WavePeaks(int maxScaleFactor) { super(maxScaleFactor+1); /* wave peaks indexes the list of chunks by scale factor since there is * no 0 scaleFactor the first position of the list is never used but it must * be filled up in order to avoid index out of bounds exception */ for(int i=0; i<maxScaleFactor+1;i++) add(null); constructed = true; } @Override public void add(int scaleFactor, List<Chunk> element){ if(constructed && scaleFactor == 0) throw new IllegalArgumentException("scaleFactor cannot be 0"); super.set(scaleFactor, element); } @Override public boolean add(List<Chunk> element){ if(constructed) throw new UnsupportedOperationException("Use add(scaleFactor), List<ChunkElement>"); else return super.add(element); } public List<Chunk> withScaleFactor(int scaleFactor){ return super.get(scaleFactor); } }