Newer
Older
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import de.tobias.playpad.NativeAudio.NativeAudioDelegate;
import de.tobias.playpad.audio.AudioCapability;
import de.tobias.playpad.audio.AudioHandler;
import de.tobias.playpad.audio.AudioHandlerConnect;
import de.tobias.playpad.audio.Peakable.Channel;
import de.tobias.playpad.pad.PadStatus;
import de.tobias.playpad.pad.conntent.PadContent;
import de.tobias.playpad.viewcontroller.AudioHandlerViewController;
import javafx.util.Duration;
public class NativeAudioMacHandlerConnect extends AudioHandlerConnect implements NativeAudioDelegate {
private static final HashMap<Integer, NativeAudioMacHandler> handlers = new HashMap<>();
public NativeAudioMacHandlerConnect() {
NativeAudio.initialize();
NativeAudio.setDelegate(this);
}
@Override
public AudioHandler createAudioHandler(PadContent content) {
NativeAudioMacHandler nativeAudioMacHandler = new NativeAudioMacHandler(content);
handlers.put(nativeAudioMacHandler.getId(), nativeAudioMacHandler);
return nativeAudioMacHandler;
}
@Override
public AudioHandlerViewController getAudioHandlerSettingsViewController() {
return null;
}
@Override
public String getType() {
return "Native";
}
@Override
public void onFinish(int id) {
NativeAudioMacHandler nativeAudioMacHandler = handlers.get(id);
if (nativeAudioMacHandler != null) {
PadContent content = nativeAudioMacHandler.getContent();
if (content != null) {
content.getPad().setStatus(PadStatus.STOP);
}
}
}
@Override
public void onPositionChanged(int id, double position) {
NativeAudioMacHandler nativeAudioMacHandler = handlers.get(id);
if (nativeAudioMacHandler != null) {
nativeAudioMacHandler.positionProperty.set(Duration.seconds(position));
}
}
@Override
public void onPeakMeter(int id, float left, float right) {
NativeAudioMacHandler nativeAudioMacHandler = handlers.get(id);
if (nativeAudioMacHandler != null) {
nativeAudioMacHandler.audioLevelProperty(Channel.LEFT).set(left);
nativeAudioMacHandler.audioLevelProperty(Channel.RIGHT).set(right);
}
}
@Override
public boolean isFeatureAvaiable(AudioCapability audioCapability) {
return false;
}
@Override
public AudioHandlerViewController getAudioFeatureSettings(AudioCapability audioCapablility) {
return null;
}
}