~ubuntu-branches/ubuntu/lucid/tuxguitar/lucid-security

« back to all changes in this revision

Viewing changes to TuxGuitar/src/org/herac/tuxguitar/player/impl/sequencer/MidiTrackController.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2008-06-19 00:30:30 UTC
  • mfrom: (1.1.1 upstream) (2.1.3 hardy)
  • Revision ID: james.westby@ubuntu.com-20080619003030-agens2gvd5m4dacu
New upstream release (Closes: #481728) also (LP: #176979, #212207)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.herac.tuxguitar.player.impl.sequencer;
 
2
 
 
3
import java.util.ArrayList;
 
4
import java.util.List;
 
5
 
 
6
import org.herac.tuxguitar.player.base.MidiPlayerException;
 
7
 
 
8
public class MidiTrackController {
 
9
        
 
10
        
 
11
        private List tracks;
 
12
        private MidiSequencerImpl sequencer;
 
13
        private boolean anySolo;
 
14
        
 
15
        public MidiTrackController(MidiSequencerImpl sequencer){
 
16
                this.sequencer = sequencer;
 
17
                this.tracks = new ArrayList();
 
18
                this.anySolo = false;
 
19
        }
 
20
        
 
21
        public void init(int count){
 
22
                this.tracks.clear();
 
23
                for(int i = 0; i < count; i ++){
 
24
                        this.tracks.add(new MidiTrack());
 
25
                }
 
26
        }
 
27
        
 
28
        public void clearTracks(){
 
29
                this.tracks.clear();
 
30
        }
 
31
        
 
32
        public void checkAnySolo(){
 
33
                this.anySolo = false;
 
34
                for(int i = 0; i < this.tracks.size(); i ++){
 
35
                        MidiTrack track = (MidiTrack)this.tracks.get(i);
 
36
                        if(track.isSolo()){
 
37
                                this.anySolo = true;
 
38
                                break;
 
39
                        }
 
40
                }
 
41
        }
 
42
        
 
43
        public void setSolo(int index,boolean solo) throws MidiPlayerException{
 
44
                if(index >= 0 && index < this.tracks.size()){
 
45
                        MidiTrack track = (MidiTrack)this.tracks.get(index);
 
46
                        track.setSolo(solo);
 
47
                        checkAnySolo();
 
48
                        if(track.isSolo()){
 
49
                                setMute(index,false);
 
50
                                this.sequencer.getMidiPort().out().sendAllNotesOff();
 
51
                        }
 
52
                }
 
53
        }
 
54
        
 
55
        public void setMute(int index,boolean mute) throws MidiPlayerException{
 
56
                if(index >= 0 && index < this.tracks.size()){
 
57
                        MidiTrack track = (MidiTrack)this.tracks.get(index);
 
58
                        track.setMute(mute);
 
59
                        if(track.isMute()){
 
60
                                setSolo(index,false);
 
61
                                this.sequencer.getMidiPort().out().sendAllNotesOff();
 
62
                        }
 
63
                }
 
64
        }
 
65
        
 
66
        public boolean isSolo(int index){
 
67
                if(index >= 0 && index < this.tracks.size()){
 
68
                        MidiTrack track = (MidiTrack)this.tracks.get(index);
 
69
                        return track.isSolo();
 
70
                }
 
71
                return false;
 
72
        }
 
73
        
 
74
        public boolean isMute(int index){
 
75
                if(index >= 0 && index < this.tracks.size()){
 
76
                        MidiTrack track = (MidiTrack)this.tracks.get(index);
 
77
                        return track.isMute();
 
78
                }
 
79
                return false;
 
80
        }
 
81
        
 
82
        public boolean isAnySolo(){
 
83
                return this.anySolo;
 
84
        }
 
85
}