Subversion Repositories svn.mios

Rev

Rev 213 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
213 tk 1
/*
2
 * @(#)SIDV2librarian.java  beta1   2008/01/21
3
 *
4
 * Copyright (C) 2008    Rutger Vlek (rutgervlek@hotmail.com)
5
 *
6
 * This application is free software; you can redistribute it and/or modify
7
 * it under the terms of the GNU General Public License as published by
8
 * the Free Software Foundation; either version 2 of the License, or
9
 * (at your option) any later version.
10
 *
11
 * This application is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this application; if not, write to the Free Software
18
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
19
 */
20
 
21
package org.midibox.sidlibr;
22
 
23
import javax.sound.midi.Receiver;
24
 
628 adamjking 25
public class EnsBank {
213 tk 26
    private Ensemble[] bank;
628 adamjking 27
    public static int ensSize = 1048; // Number of SysEx string characters
213 tk 28
    public static int bankSize = 128;
29
    private Receiver receiver;
628 adamjking 30
 
213 tk 31
    public EnsBank(Receiver receiver) {
32
        this.receiver = receiver;
33
        initBank();
34
    }
628 adamjking 35
 
213 tk 36
    public void initBank() {
37
        bank = new Ensemble[bankSize];
628 adamjking 38
        for (int c = 0; c < bankSize; c++) {
213 tk 39
            bank[c] = new Ensemble(receiver);
40
        }
41
    }
628 adamjking 42
 
213 tk 43
    public void setEnsembleAt(int i, Ensemble p) {
44
        bank[i] = p;
45
    }
628 adamjking 46
 
213 tk 47
    public Ensemble getEnsembleAt(int i) {
48
        return bank[i];
49
    }
628 adamjking 50
 
51
    public String parseBankSyx(String syx) {
213 tk 52
        String status = "succesful";
628 adamjking 53
        try {
213 tk 54
            initBank();
628 adamjking 55
            for (int i = 0; i < syx.length() / ensSize; i++) {
213 tk 56
                bank[i] = new Ensemble(receiver);
628 adamjking 57
                String stat = bank[i].parseEnsemble(syx.substring(i * ensSize,
58
                        (i + 1) * ensSize));
213 tk 59
                if (status == "checksum error") {
60
                    status = stat;
61
                    break;
62
                }
63
            }
64
        } catch (Exception e) {
65
            status = "parse error";
66
        }
67
        return status;
68
    }
69
}