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

« back to all changes in this revision

Viewing changes to TuxGuitar-fluidsynth/src/org/herac/tuxguitar/player/impl/midiport/fluidsynth/MidiOutputPortImpl.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2009-04-25 19:49:27 UTC
  • mfrom: (1.1.3 upstream) (2.1.7 jaunty)
  • Revision ID: james.westby@ubuntu.com-20090425194927-pblqed0zxp0pmyeq
Tags: 1.1-1
* New Upstream Release (Closes: #489859) (LP: #366476)
* Merged patch : tuxguitar_1.0.dak-1ubuntu1.patch
* debian/README.txt
  - suggests to install tuxguitar-jsa

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
package org.herac.tuxguitar.player.impl.midiport.fluidsynth;
 
2
 
 
3
import java.io.File;
 
4
 
 
5
import org.herac.tuxguitar.player.base.MidiOutputPort;
 
6
import org.herac.tuxguitar.player.base.MidiReceiver;
 
7
 
 
8
public class MidiOutputPortImpl extends MidiOutputPort{
 
9
        
 
10
        private MidiSynth synth;
 
11
        private MidiReceiverImpl receiver;
 
12
        private String soundFont;
 
13
        
 
14
        public MidiOutputPortImpl(MidiSynth synth,File soundfont){
 
15
                super(getUniqueKey(soundfont),getUniqueName(soundfont));
 
16
                this.soundFont = soundfont.getAbsolutePath();
 
17
                this.receiver = new MidiReceiverImpl(synth);
 
18
                this.synth = synth;
 
19
        }
 
20
        
 
21
        public void open(){
 
22
                if(!this.synth.isConnected(this)){
 
23
                        this.synth.connect(this);
 
24
                }
 
25
        }
 
26
        
 
27
        public void close(){
 
28
                if(this.synth.isConnected(this)){
 
29
                        this.synth.disconnect(this);
 
30
                }
 
31
        }
 
32
        
 
33
        public MidiReceiver getReceiver(){
 
34
                this.open();
 
35
                return this.receiver;
 
36
        }
 
37
        
 
38
        public void check(){
 
39
                // Not implemented
 
40
        }
 
41
        
 
42
        public String getSoundFont() {
 
43
                return this.soundFont;
 
44
        }
 
45
        
 
46
        public static String getUniqueKey(File soundfont){
 
47
                return ("tuxguitar-fluidsynth_" + soundfont.getAbsolutePath());
 
48
        }
 
49
        
 
50
        private static String getUniqueName(File soundfont){
 
51
                String name = soundfont.getName();
 
52
                int extensionIndex = name.lastIndexOf(".");
 
53
                if( extensionIndex > 0 ){
 
54
                        name = name.substring( 0, extensionIndex );
 
55
                }
 
56
                return ("TG Fluidsynth " + "[" + name + "]");
 
57
        }
 
58
}