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.beads;
|
f@0
|
20
|
f@1
|
21
|
f@0
|
22 import uk.ac.qmul.eecs.depic.daw.Parameter;
|
f@0
|
23 import uk.ac.qmul.eecs.depic.daw.Parameter.Type;
|
f@1
|
24 import uk.ac.qmul.eecs.depic.daw.Sample;
|
f@0
|
25 import uk.ac.qmul.eecs.depic.daw.Sonification;
|
f@0
|
26 import uk.ac.qmul.eecs.depic.daw.SoundEngineFactory;
|
f@0
|
27 import uk.ac.qmul.eecs.depic.daw.SoundWave;
|
f@0
|
28 import uk.ac.qmul.eecs.depic.daw.beads.sonification.BeadsSonification;
|
f@0
|
29
|
f@2
|
30 /**
|
f@2
|
31 *
|
f@2
|
32 * Beads implementation of the {@code SoundEngineFactory}. All the object returned are typed with
|
f@2
|
33 * classes of this package. Therefore all the classes use the same Beads library and enjoy package
|
f@2
|
34 * access with one another.
|
f@2
|
35 *
|
f@2
|
36 * Also they can be safely downcasted in order to get full functionality. For example
|
f@2
|
37 * in {@code createParameter} the argument of type {@code SoundWave} is downcasted
|
f@2
|
38 * to {@code BeadsSoundWave}. This is guaranteed to be safe because the way SoundWave objects
|
f@2
|
39 * are created is through the {@code createSoundWave} method, which returns a BeadsSoundWave.
|
f@2
|
40 *
|
f@2
|
41 * This is in the spirit of the Facade design pattern. So a unique point of access to the package object
|
f@2
|
42 * guarantees all the objects come from that package, despite implementing interfaces which are defined
|
f@2
|
43 * outside.
|
f@2
|
44 *
|
f@2
|
45 *
|
f@2
|
46 *
|
f@2
|
47 */
|
f@0
|
48 public class BeadsSoundEngineFactory implements SoundEngineFactory {
|
f@0
|
49 private static final int MAX_TRACK_SCALE_FACTOR = 10;
|
f@0
|
50 private static final int MIN_CHUNCKSIZE = 8;
|
f@0
|
51 private int minChunk;
|
f@0
|
52 private int maxScaleFactor;
|
f@0
|
53 private int initialScaleFactor;
|
f@0
|
54 private Sonification sonification;
|
f@0
|
55
|
f@0
|
56 public BeadsSoundEngineFactory(){
|
f@0
|
57 minChunk = MIN_CHUNCKSIZE;
|
f@0
|
58 maxScaleFactor = MAX_TRACK_SCALE_FACTOR;
|
f@0
|
59 initialScaleFactor = MAX_TRACK_SCALE_FACTOR/2 + 1;
|
f@0
|
60 sonification = new BeadsSonification();
|
f@0
|
61 }
|
f@0
|
62
|
f@0
|
63 @Override
|
f@0
|
64 public SoundWave createSoundWave() {
|
f@0
|
65 return new BeadsSoundWave(
|
f@0
|
66 minChunk,
|
f@0
|
67 maxScaleFactor,
|
f@0
|
68 initialScaleFactor);
|
f@0
|
69 }
|
f@0
|
70
|
f@0
|
71 public BeadsSoundEngineFactory setSoundWaveParameters(int minChunk,int maxScaleFactor, int initialScaleFactor){
|
f@0
|
72 this.minChunk = minChunk;
|
f@0
|
73 this.maxScaleFactor = maxScaleFactor;
|
f@0
|
74 this.initialScaleFactor = initialScaleFactor;
|
f@0
|
75 return this;
|
f@0
|
76 }
|
f@0
|
77
|
f@0
|
78 @Override
|
f@0
|
79 public Parameter createParameter(Type type, SoundWave wave) {
|
f@0
|
80 if(Parameter.GAIN_TYPE.equals(type)) {
|
f@0
|
81 return new GainParameter(((BeadsSoundWave)wave).ac,2);
|
f@0
|
82 }else if(Parameter.PAN_TYPE.equals(type)) {
|
f@0
|
83 return new PanParameter(((BeadsSoundWave)wave).ac);
|
f@0
|
84 }else{
|
f@0
|
85 return null;
|
f@0
|
86 }
|
f@0
|
87 }
|
f@0
|
88
|
f@0
|
89 @Override
|
f@0
|
90 public Sonification getSharedSonification() {
|
f@0
|
91 return sonification;
|
f@0
|
92 }
|
f@1
|
93
|
f@1
|
94 @Override
|
f@1
|
95 public Sample createSample(String fileAbsolutePath) throws Exception {
|
f@1
|
96 return new BeadsSampleWrapper(new net.beadsproject.beads.data.Sample(
|
f@1
|
97 fileAbsolutePath,
|
f@1
|
98 net.beadsproject.beads.data.Sample.Regime.newStreamingRegimeWithAging(1000, 1000)
|
f@1
|
99 )
|
f@1
|
100 );
|
f@1
|
101 }
|
f@0
|
102
|
f@0
|
103 }
|