コード例 #1
0
ファイル: SabreController.cpp プロジェクト: djimoun/SabreCE
void SabreController::printHomeScreen(uint8_t selectedInput, uint8_t attenuation)
{
	OLED.defineCustomChar0();					// restore custom character 0
	OLED.defineCustomChar1();					// restore custom character 1
	OLED.defineCustomChar2();					// restore custom character 2
	OLED.clear();
	
	switch (GUI_Substate)
	{
		case NoVolumeNumbersHS:					// Home Screen: No volume numbers
		printInputName(0, 0);
		printLargeInput(selectedInput, 16);
		printSampleRate(0, 2);
		printInputFormat(0, 3);
		break;
		case NoInputNumberHS:					// Home Screen: No large input number
		printInputName(0, 0);
		printSampleRate(0, 2);
		printInputFormat(0, 3);
		if (sabreDAC.Mute)
		{
			printLargeMuteSymbol(13);
		}
		else
		{
			printLargeAttenuation(attenuation, 13);
		}
		break;
		default:								// Home Screen: (default) use large input and volume numbers
		printInputName(4, 2);
		printLargeInput(selectedInput, 0);
		if (sabreDAC.Mute)
		{
			printLargeMuteSymbol(13);
		}
		else
		{
			printLargeAttenuation(attenuation, 13);
		}
		printSampleRate(0, 0);
		printInputFormat(4, 3);
		break;
	}
	NoDisplay = false;
	this->GUI_State = HomeScreen;
}
コード例 #2
0
ファイル: lame_main.c プロジェクト: TimothyGu/lame
static int
lame_decoder(lame_t gfp, FILE * outf, char *inPath, char *outPath)
{
    short int Buffer[2][1152];
    int     i, iread;
    double  wavsize;
    int     tmp_num_channels = lame_get_num_channels(gfp);
    int     skip_start = samples_to_skip_at_start();
    int     skip_end = samples_to_skip_at_end();
    DecoderProgress dp = 0;

    if (!(tmp_num_channels >= 1 && tmp_num_channels <= 2)) {
        error_printf("Internal error.  Aborting.");
        exit(-1);
    }

    if (global_ui_config.silent < 9) {
        console_printf("\rinput:  %s%s(%g kHz, %i channel%s, ",
                       strcmp(inPath, "-") ? inPath : "<stdin>",
                       strlen(inPath) > 26 ? "\n\t" : "  ",
                       lame_get_in_samplerate(gfp) / 1.e3,
                       tmp_num_channels, tmp_num_channels != 1 ? "s" : "");

        printInputFormat(gfp);

        console_printf(")\noutput: %s%s(16 bit, Microsoft WAVE)\n",
                       strcmp(outPath, "-") ? outPath : "<stdout>",
                       strlen(outPath) > 45 ? "\n\t" : "  ");

        if (skip_start > 0)
            console_printf("skipping initial %i samples (encoder+decoder delay)\n", skip_start);
        if (skip_end > 0)
            console_printf("skipping final %i samples (encoder padding-decoder delay)\n", skip_end);

        switch (global_reader.input_format) {
        case sf_mp3:
        case sf_mp2:
        case sf_mp1:
            dp = decoder_progress_init(lame_get_num_samples(gfp),
                                       global_decoder.mp3input_data.framesize);
            break;
        case sf_raw:
        case sf_wave:
        case sf_aiff:
        default:
            dp = decoder_progress_init(lame_get_num_samples(gfp),
                                       lame_get_in_samplerate(gfp) < 32000 ? 576 : 1152);
            break;
        }
    }

    if (0 == global_decoder.disable_wav_header)
        WriteWaveHeader(outf, 0x7FFFFFFF, lame_get_in_samplerate(gfp), tmp_num_channels, 16);
    /* unknown size, so write maximum 32 bit signed value */

    wavsize = 0;
    do {
        iread = get_audio16(gfp, Buffer); /* read in 'iread' samples */
        if (iread >= 0) {
            wavsize += iread;
            if (dp != 0) {
                decoder_progress(dp, &global_decoder.mp3input_data, iread);
            }
            put_audio16(outf, Buffer, iread, tmp_num_channels);
        }
    } while (iread > 0);

    i = (16 / 8) * tmp_num_channels;
    assert(i > 0);
    if (wavsize <= 0) {
        if (global_ui_config.silent < 10)
            error_printf("WAVE file contains 0 PCM samples\n");
        wavsize = 0;
    }
    else if (wavsize > 0xFFFFFFD0 / i) {
        if (global_ui_config.silent < 10)
            error_printf("Very huge WAVE file, can't set filesize accordingly\n");
        wavsize = 0xFFFFFFD0;
    }
    else {
        wavsize *= i;
    }
    /* if outf is seekable, rewind and adjust length */
    if (!global_decoder.disable_wav_header && strcmp("-", outPath)
        && !fseek(outf, 0l, SEEK_SET))
        WriteWaveHeader(outf, (int) wavsize, lame_get_in_samplerate(gfp), tmp_num_channels, 16);
    fclose(outf);
    close_infile();

    if (dp != 0)
        decoder_progress_finish(dp);
    return 0;
}