예제 #1
0
파일: riff.cpp 프로젝트: svn2github/vmpk
void Riff::processINSH(quint32& bank, quint32& pc, bool& perc)
{
    read32bit();
    bank = read32bit();
    pc = read32bit();
    perc = (bank & 0x80000000) != 0;
    bank &= 0x3FFF;
}
예제 #2
0
파일: riff.cpp 프로젝트: svn2github/vmpk
quint32 Riff::readChunk(quint32& chunkType)
{
    quint32 len = 0;
    chunkType = read32bit();
    len = read32bit();
//    qDebug() << "chunkType:" << toString(chunkType)
//             << "(" << hex << chunkType << ")"
//             << "length:" << dec << len;
    return len;
}
예제 #3
0
파일: riff.cpp 프로젝트: svn2github/vmpk
quint32 Riff::readExpectedChunk(quint32 cktype)
{
    quint32 chunkType, len = 0;
    chunkType = read32bit();
    if (chunkType == cktype) {
        len = read32bit();
//        qDebug() << "Expected chunkType:" << toString(chunkType)
//                 << "(" << hex << chunkType << ")"
//                 << "length:" << dec << len;
    }
    return len;
}
예제 #4
0
파일: riff.cpp 프로젝트: svn2github/vmpk
quint32 Riff::readChunkID()
{
    quint32 chunkID = read32bit();
//    qDebug() << "chunkID:" << toString(chunkID)
//             << "(" << hex << chunkID << ")";
    return chunkID;
}
예제 #5
0
파일: midifile.c 프로젝트: asmCode/rw2014
static void readheader(void) /* read a header chunk */
{
    int format, ntrks, division;

    if (readmt("MThd") == EOF)
        return;

    Mf_toberead = read32bit();
    format = read16bit();
    ntrks = read16bit();
    division = read16bit();

    if (Mf_header)
        (*Mf_header)(format,ntrks,division);

    /* flush any extra stuff, in case the length of header is not 6 */
    while (Mf_toberead > 0)
        (void) egetc();
}
예제 #6
0
static inline uint32_t ALWAYS_INLINE
getstreambits( uint8_t *in, int32_t bitoffset, int32_t numbits )
{
	uint32_t	load1, load2;
	uint32_t	byteoffset = bitoffset / 8;
	uint32_t	result;
	
	//Assert( numbits <= 32 );

	load1 = read32bit( in + byteoffset );

	if ( (numbits + (bitoffset & 0x7)) > 32)
	{
		int32_t load2shift;

		result = load1 << (bitoffset & 0x7);
		load2 = (uint32_t) in[byteoffset+4];
		load2shift = (8-(numbits + (bitoffset & 0x7)-32));
		load2 >>= load2shift;
		result >>= (32-numbits);
		result |= load2;		
	}
예제 #7
0
파일: midifile.c 프로젝트: asmCode/rw2014
static int readtrack(void) /* read a track chunk */
{
    /* This array is indexed by the high half of a status byte.  It's */
    /* value is either the number of bytes needed (1 or 2) for a channel */
    /* message, or 0 (meaning it's not  a channel message). */
    static int chantype[] = {
        0, 0, 0, 0, 0, 0, 0, 0,		/* 0x00 through 0x70 */
        2, 2, 2, 2, 1, 1, 2, 0		/* 0x80 through 0xf0 */
    };
    long lookfor;
    int c, c1, type;
    int sysexcontinue = 0; /* 1 if last message was an unfinished sysex */
    int running = 0;       /* 1 when running status used */
    int status = 0;        /* status value (e.g. 0x90==note-on) */
    int needed;

    if (readmt("MTrk") == EOF)
        return(0);

    Mf_toberead = read32bit();
    Mf_currtime = 0;

    if (Mf_starttrack)
        (*Mf_starttrack)();

    while (Mf_toberead > 0) {
        Mf_currtime += readvarinum();	/* delta time */

        c = egetc();

        if (sysexcontinue && c != 0xf7)
            mferror("didn't find expected continuation of a sysex");

        if ((c & 0x80) == 0) {	 /* running status? */
            if (status == 0)
                mferror("unexpected running status");
            running = 1;
            c1 = c;
            c = status;
        } else if (c < 0xf0) {
            status = c;
            running = 0;
        }

        needed = chantype[(c>>4) & 0xf];

        if (needed) { /* ie. is it a channel message? */
            if (! running)
                c1 = egetc();
            chanmessage(status, c1, (needed>1) ? egetc() : 0);
            continue;;
        }

        switch (c) {
            case 0xff:			/* meta event */
                type = egetc();
                lookfor = Mf_toberead - readvarinum();
                msginit();

                while (Mf_toberead > lookfor)
                    msgadd(egetc());

                metaevent(type);
                break;

            case 0xf0:		/* start of system exclusive */
                lookfor = Mf_toberead - readvarinum();
                msginit();
                msgadd(0xf0);

                while (Mf_toberead > lookfor)
                    msgadd(c = egetc());

                if (c == 0xf7 || Mf_nomerge == 0)
                    sysex();
                else
                    sysexcontinue = 1;  /* merge into next msg */
                break;

            case 0xf7:	/* sysex continuation or arbitrary stuff */
                lookfor = Mf_toberead - readvarinum();

                if (! sysexcontinue)
                    msginit();

                while (Mf_toberead > lookfor)
                    msgadd(c=egetc());

                if ( ! sysexcontinue ) {
                    if (Mf_arbitrary)
                        (*Mf_arbitrary)(msgleng(),msg());
                } else if (c == 0xf7) {
                    sysex();
                    sysexcontinue = 0;
                }
                break;
            default:
                badbyte(c);
                break;
        }
    }

    if (Mf_endtrack)
        (*Mf_endtrack)();
    return(1);
}