~ubuntu-branches/ubuntu/oneiric/tuxguitar/oneiric

« back to all changes in this revision

Viewing changes to src/org/herac/tuxguitar/player/impl/MidiMetaEventListener.java

  • Committer: Bazaar Package Importer
  • Author(s): Philippe Coval
  • Date: 2008-06-19 00:30:30 UTC
  • mto: (5.1.2 sid)
  • mto: This revision was merged to the branch mainline in revision 3.
  • Revision ID: james.westby@ubuntu.com-20080619003030-h719szrhsngou7c6
Tags: upstream-1.0
ImportĀ upstreamĀ versionĀ 1.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Created on 13-dic-2005
3
 
 *
4
 
 * TODO To change the template for this generated file go to
5
 
 * Window - Preferences - Java - Code Style - Code Templates
6
 
 */
7
 
package org.herac.tuxguitar.player.impl;
8
 
 
9
 
import javax.sound.midi.MetaEventListener;
10
 
import javax.sound.midi.MetaMessage;
11
 
 
12
 
/**
13
 
 * @author julian
14
 
 *
15
 
 * TODO To change the template for this generated type comment go to
16
 
 * Window - Preferences - Java - Code Style - Code Templates
17
 
 */
18
 
public class MidiMetaEventListener implements MetaEventListener{    
19
 
              
20
 
    private long move;
21
 
    
22
 
    public MidiMetaEventListener(){
23
 
        this.move = 0;
24
 
    }
25
 
    
26
 
    public void meta(MetaMessage meta) {   
27
 
        if(meta.getType() == MidiMessageUtils.TICK_MOVE){                               
28
 
                setMove(parseLong(meta.getData()));
29
 
        }
30
 
    }    
31
 
    
32
 
    private long parseLong(byte[] v){
33
 
        return ((v[7] & 0xff) << 56) | ((v[6] & 0xff) << 48) | ((v[5] & 0xff) << 40) | ((v[4] & 0xff) << 32) |
34
 
                           ((v[3] & 0xff) << 24) | ((v[2] & 0xff) << 16) | ((v[1] & 0xff) << 8) | (v[0] & 0xff);
35
 
    }
36
 
    
37
 
    public long getMove(){
38
 
        return this.move;        
39
 
    }
40
 
 
41
 
    public void setMove(long move){
42
 
        this.move = move;        
43
 
    }    
44
 
    
45
 
    public void reset(){
46
 
        this.move = 0;
47
 
    }
48
 
    
49
 
}