Пример #1
0
bool HalfSector::loadFromFile(SDL_Renderer* gRenderer,
		std::string path) {
	bool success = IRendable::loadFromFile(gRenderer, path);
	string text = getHalf() == LowHalf? "1 - 18" : "19 - 36";
	setRenderedText(gRenderer, text);
	return success;
}
Пример #2
0
QString MsnParser::parseMsn(const QString &msn) const
{
    QString answer = QString::number(table[msn[5]] / 2 + 1) + "-";      // Month
    answer += QString::number(table[msn[4]] + dateRange);               // Year
    return QDate::fromString(answer, "M-yyyy")                          // Date Format
            .toString(getHalf(table[msn[5]] % 2 == 0) + "MMMM yyyy");   // For "January" instead "1"
}
Пример #3
0
int WavPlayer::PlayAudio()
{
    unsigned long len;
    void *pcmbuffer;
    int ret;

    pcmbuffer = LoadPCM(FileName, &len);
    if(!pcmbuffer)
    {
        fprintf(stderr, "%s: %s\n", FileName, strerror(errno));
        exit(EXIT_FAILURE);
    }

    unsigned char* bytes = (unsigned char*)pcmbuffer;
    int index = 0;

    // 'RIFF'
    getWord(bytes, index);
    index += 4;
    // int Length
    getWord(bytes, index);
    index += 4;
    // 'WAVE'
    getWord(bytes, index);
    index += 4;
    // 'fmt '
    getWord(bytes, index);
    index += 4;

    // int Format Length
    int fmtLen = getWord(bytes, index);
    index += 4;
    AudioFormat = getHalf(bytes, index);
    index += 2;
    NumChannels = getHalf(bytes, index);
    index += 2;
    SampleRate = getWord(bytes, index);
    index += 4;
    ByteRate = getWord(bytes, index);
    index += 4;
    BlockAlign = getHalf(bytes, index);
    index += 2;
    BitsPerSample = getHalf(bytes, index);
    index += 2;
    index += fmtLen - 16;
    while(!isDataChunk(bytes, index))
    {
        // Any Chunk
        getWord(bytes, index);
        index += 4;
        // Any Chunk Length
        int anyChunkLen = getWord(bytes, index);
        index += 4 + anyChunkLen;
    }
    // 'data'
    getWord(bytes, index);
    index += 4;
    // int Data Length
    unsigned long dataLen = getWord(bytes, index);
    index += 4;
    unsigned char* target = &bytes[index];

    ret = PlayBuffer((void *)target, dataLen);
    free(pcmbuffer);
    return ret;
}