~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/MidiPortImpl.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.MidiOut;
6
 
import org.herac.tuxguitar.player.base.MidiPort;
7
 
import org.herac.tuxguitar.player.impl.midiport.fluidsynth.MidiOutImpl;
8
 
 
9
 
public class MidiPortImpl extends MidiPort{
10
 
        
11
 
        private MidiSynth synth;
12
 
        private MidiOutImpl midiOut;
13
 
        private String soundFont;
14
 
        
15
 
        public MidiPortImpl(MidiSynth synth,File soundfont){
16
 
                super(getUniqueKey(soundfont),getUniqueName(soundfont));
17
 
                this.soundFont = soundfont.getAbsolutePath();
18
 
                this.midiOut = new MidiOutImpl(synth);
19
 
                this.synth = synth;
20
 
        }
21
 
        
22
 
        public void open(){
23
 
                if(!this.synth.isConnected(this)){
24
 
                        this.synth.connect(this);
25
 
                }
26
 
        }
27
 
        
28
 
        public void close(){
29
 
                if(this.synth.isConnected(this)){
30
 
                        this.synth.disconnect(this);
31
 
                }
32
 
        }
33
 
        
34
 
        public MidiOut out(){
35
 
                this.open();
36
 
                return this.midiOut;
37
 
        }
38
 
        
39
 
        public void check(){
40
 
                // Not implemented
41
 
        }
42
 
        
43
 
        public String getSoundFont() {
44
 
                return this.soundFont;
45
 
        }
46
 
        
47
 
        public static String getUniqueKey(File soundfont){
48
 
                return ("tuxguitar-fluidsynth_" + soundfont.getAbsolutePath());
49
 
        }
50
 
        
51
 
        private static String getUniqueName(File soundfont){
52
 
                String name = soundfont.getName();
53
 
                int extensionIndex = name.lastIndexOf(".");
54
 
                if( extensionIndex > 0 ){
55
 
                        name = name.substring( 0, extensionIndex );
56
 
                }
57
 
                return ("TG Fluidsynth " + "[" + name + "]");
58
 
        }
59
 
}