Exemple #1
0
pascal void PrebufTimerProc(EventLoopTimerRef inTimer, void *inUserData)
{ // monitor prebuffering progress
	DWORD progress=BASS_StreamGetFilePosition(chan,BASS_FILEPOS_BUFFER)
		*100/BASS_StreamGetFilePosition(chan,BASS_FILEPOS_END); // percentage of buffer filled
	if (progress>75 || !BASS_StreamGetFilePosition(chan,BASS_FILEPOS_CONNECTED)) { // over 75% full (or end of download)
		RemoveEventLoopTimer(prebuftimer); // finished prebuffering, stop monitoring
		{ // get the broadcast name and URL
			const char *icy=BASS_ChannelGetTags(chan,BASS_TAG_ICY);
			if (!icy) icy=BASS_ChannelGetTags(chan,BASS_TAG_HTTP); // no ICY tags, try HTTP
			if (icy) {
				for (;*icy;icy+=strlen(icy)+1) {
					if (!strncasecmp(icy,"icy-name:",9))
						SetStaticText(31,icy+9);
					if (!strncasecmp(icy,"icy-url:",8))
						SetStaticText(32,icy+8);
				}
			} else
				SetStaticText(31,"");
		}
		// get the stream title and set sync for subsequent titles
		DoMeta();
		BASS_ChannelSetSync(chan,BASS_SYNC_META,0,&MetaSync,0); // Shoutcast
		BASS_ChannelSetSync(chan,BASS_SYNC_OGG_CHANGE,0,&MetaSync,0); // Icecast/OGG
		// set sync for end of stream
		BASS_ChannelSetSync(chan,BASS_SYNC_END,0,&EndSync,0);
		// play it!
		BASS_ChannelPlay(chan,FALSE);
	} else {
		char text[20];
		sprintf(text,"buffering... %d%%",progress);
		SetStaticText(31,text);
	}
}
Exemple #2
0
// update stream title from metadata
void DoMeta()
{
	const char *meta=BASS_ChannelGetTags(chan,BASS_TAG_META);
	if (meta) { // got Shoutcast metadata
		char *p=strstr(meta,"StreamTitle='");
		if (p) {
			p=strdup(p+13);
			strchr(p,';')[-1]=0;
			SetStaticText(30,p);
			free(p);
		}
	} else {
		meta=BASS_ChannelGetTags(chan,BASS_TAG_OGG);
		if (meta) { // got Icecast/OGG tags
			const char *artist=NULL,*title=NULL,*p=meta;
			for (;*p;p+=strlen(p)+1) {
				if (!strncasecmp(p,"artist=",7)) // found the artist
					artist=p+7;
				if (!strncasecmp(p,"title=",6)) // found the title
					title=p+6;
			}
			if (title) {
				if (artist) {
					char text[100];
					snprintf(text,sizeof(text),"%s - %s",artist,title);
					SetStaticText(30,text);
				} else
					SetStaticText(30,title);
			}
		}
    }
}
Exemple #3
0
pascal OSStatus CustomEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
{
	DWORD id=0;
	GetEventParameter(inEvent,'evid',0,NULL,sizeof(id),NULL,&id);
	switch (id) {
		case 'open':
			SetStaticText(31,"connecting...");
			SetStaticText(30,"");
			SetStaticText(32,"");
			break;
		case 'end ':
			SetStaticText(31,"not playing");
			SetStaticText(30,"");
			SetStaticText(32,"");
			break;
		case 'stat':
			{
				char *status;
				GetEventParameter(inEvent,'data',0,NULL,sizeof(status),NULL,&status);
				SetStaticText(32,status); // display connection status
				free(status);
			}
			break;
		case 'meta':
			DoMeta();
			break;
	}
	return noErr;
}
Exemple #4
0
pascal void TempoEventHandler(ControlHandle control, SInt16 part)
{
	float p=(float)GetControl32BitValue(control);
	char c[20];

	// set new tempo
	BASS_ChannelSetAttribute(chan, BASS_ATTRIB_TEMPO, p);

	// update tempo static text
	sprintf(c,"Tempo = %d%%", (long)p);
	SetStaticText(12,c);
}
Exemple #5
0
pascal void TimerProc(EventLoopTimerRef inTimer, void *inUserData)
{
	float ratio=BASS_FX_TempoGetRateRatio(chan);
	if (!ratio) return;
	SetControl32BitValue(GetControl(15),(DWORD)BASS_ChannelBytes2Seconds(chan,BASS_ChannelGetPosition(chan,BASS_POS_BYTE))); // update position
	{ // show the approximate position in MM:SS format
		char c[50];
		DWORD totalsec=GetControl32BitMaximum(GetControl(15))/ratio;
		DWORD posec=GetControl32BitValue(GetControl(15))/ratio;
		sprintf(c,"Playing position: %02u:%02u / %02u:%02u",posec/60,posec%60,totalsec/60,totalsec%60);
		SetStaticText(14,c);
	}
}
void CAtmoLiveSettings::HandleHorzScroll(int code,int position,HWND scrollBarHandle) {
     // slider handling...
    char buffer[100];
    int dlgItemId = GetDlgCtrlID(scrollBarHandle);
    switch(dlgItemId) {
           case IDC_EdgeWeighting: {
                int EdgeWeighting = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
                sprintf(buffer,"Edge weighting [%d]",EdgeWeighting);
                SetStaticText(IDC_TXT_EDGEWEIGHTNING, buffer);
                this->m_pDynData->getAtmoConfig()->setLiveView_EdgeWeighting(EdgeWeighting);
                break;
           }

           case IDC_BrightCorrect: {
                int BrightCorrect = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
                sprintf(buffer,"Brightness [%d%%]",BrightCorrect);
                SetStaticText(IDC_TXT_BRIGHTCORRECT, buffer);
                this->m_pDynData->getAtmoConfig()->setLiveView_BrightCorrect(BrightCorrect);
                break;
           }
           case IDC_DarknessLimit: {
                int DarknessLimit = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
                sprintf(buffer,"Darkness Limit [%d]",DarknessLimit);
                SetStaticText(IDC_TXT_DARKNESSLIMIT, buffer);
                this->m_pDynData->getAtmoConfig()->setLiveView_DarknessLimit(DarknessLimit);
                break;
           }

           case IDC_HueWinSize: {
                int HueWinSize = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
                sprintf(buffer,"Hue windowing [%d]",HueWinSize);
                SetStaticText(IDC_TXT_HUEWINSIZE, buffer);
                this->m_pDynData->getAtmoConfig()->setLiveView_HueWinSize(HueWinSize);
                break;
           }

           case IDC_SatWinSize: {
                int SatWinSize = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
                sprintf(buffer,"Sat windowing [%d]",SatWinSize);
                SetStaticText(IDC_TXT_SATWINSIZE, buffer);
                this->m_pDynData->getAtmoConfig()->setLiveView_SatWinSize(SatWinSize);
                break;
           }

           case IDC_Filter_MeanLength: {
                int Filter_MeanLength = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
                sprintf(buffer,"Filter length [%d ms]",Filter_MeanLength);
                SetStaticText(IDC_TXT_Filter_MeanLength, buffer);
                this->m_pDynData->getAtmoConfig()->setLiveViewFilter_MeanLength(Filter_MeanLength);
                break;
           }

           case IDC_Filter_MeanThreshold: {
                int Filter_MeanThreshold = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
                sprintf(buffer,"Filter threshold [%d%%]",Filter_MeanThreshold);
                SetStaticText(IDC_TXT_Filter_MeanThreshold, buffer);
                this->m_pDynData->getAtmoConfig()->setLiveViewFilter_MeanThreshold(Filter_MeanThreshold);
                break;
           }

           case IDC_Filter_PercentNew: {
                int Filter_PercentNew = (int)SendMessage(scrollBarHandle, TBM_GETPOS, 0, 0);
                sprintf(buffer,"Filter smoothness [%d%%]",Filter_PercentNew);
                SetStaticText(IDC_TXT_Filter_PercentNew, buffer);
                this->m_pDynData->getAtmoConfig()->setLiveViewFilter_PercentNew(Filter_PercentNew);
                break;
           }

           default:
               return;

    }
}
ATMO_BOOL CAtmoLiveSettings::InitDialog(WPARAM wParam) 
{
        CAtmoConfig *config = m_pDynData->getAtmoConfig();
        char buffer[256];
        HWND hwndCtrl;

        hwndCtrl = this->getDlgItem(IDC_GDI_CAPURE_RATE);
        sprintf(buffer,"%d",config->getLiveView_GDI_FrameRate());
        Edit_SetText(hwndCtrl, buffer);
        Edit_LimitText(hwndCtrl,2);

        LoadDisplayList();

        hwndCtrl = getDlgItem(IDC_FILTERMODE);
        ComboBox_AddString(hwndCtrl, "No Filter");
        ComboBox_AddString(hwndCtrl, "Combined");
        ComboBox_AddString(hwndCtrl, "Percent");
        ComboBox_SetCurSel(hwndCtrl, (int)config->getLiveViewFilterMode());

        hwndCtrl = getDlgItem(IDC_WIDESCREEN);
        Button_SetCheck(hwndCtrl, config->getLiveView_WidescreenMode());

        SetupSliderControl(IDC_EdgeWeighting,1,30,config->getLiveView_EdgeWeighting(),5);
        SendMessage(getDlgItem(IDC_EdgeWeighting),TBM_SETPAGESIZE,0,2);
        sprintf(buffer,"Edge weighting [%d]",config->getLiveView_EdgeWeighting());
        SetStaticText(IDC_TXT_EDGEWEIGHTNING, buffer);

        SetupSliderControl(IDC_BrightCorrect,50,300,config->getLiveView_BrightCorrect(),15);
        SendMessage(getDlgItem(IDC_BrightCorrect),TBM_SETPAGESIZE,0,10);
        sprintf(buffer,"Brightness [%d%%]",config->getLiveView_BrightCorrect());
        SetStaticText(IDC_TXT_BRIGHTCORRECT, buffer);

        SetupSliderControl(IDC_DarknessLimit,0,10,config->getLiveView_DarknessLimit(),1);
        SendMessage(getDlgItem(IDC_DarknessLimit),TBM_SETPAGESIZE,0,1);
        sprintf(buffer,"Darkness Limit [%d]",config->getLiveView_DarknessLimit());
        SetStaticText(IDC_TXT_DARKNESSLIMIT, buffer);

        SetupSliderControl(IDC_HueWinSize,0,5,config->getLiveView_HueWinSize(),1);
        SendMessage(getDlgItem(IDC_HueWinSize),TBM_SETPAGESIZE,0,1);
        sprintf(buffer,"Hue windowing [%d]",config->getLiveView_HueWinSize());
        SetStaticText(IDC_TXT_HUEWINSIZE, buffer);

        SetupSliderControl(IDC_SatWinSize,0,5,config->getLiveView_SatWinSize(),1);
        SendMessage(getDlgItem(IDC_SatWinSize),TBM_SETPAGESIZE,0,1);
        sprintf(buffer,"Sat windowing [%d]",config->getLiveView_SatWinSize());
        SetStaticText(IDC_TXT_SATWINSIZE, buffer);

        SetupSliderControl(IDC_Filter_MeanLength,300,5000,config->getLiveViewFilter_MeanLength(),0);
        SendMessage(getDlgItem(IDC_Filter_MeanLength),TBM_SETPAGESIZE,0,100);
        sprintf(buffer,"Filter length [%d ms]",config->getLiveViewFilter_MeanLength());
        SetStaticText(IDC_TXT_Filter_MeanLength, buffer);

        SetupSliderControl(IDC_Filter_MeanThreshold,1,100,config->getLiveViewFilter_MeanThreshold(),0);
        SendMessage(getDlgItem(IDC_Filter_MeanThreshold),TBM_SETPAGESIZE,0,5);
        sprintf(buffer,"Filter threshold [%d%%]",config->getLiveViewFilter_MeanThreshold());
        SetStaticText(IDC_TXT_Filter_MeanThreshold, buffer);

        SetupSliderControl(IDC_Filter_PercentNew,1,100,config->getLiveViewFilter_PercentNew(),0);
        SendMessage(getDlgItem(IDC_Filter_PercentNew),TBM_SETPAGESIZE,0,5);
        sprintf(buffer,"Filter smoothness [%d%%]",config->getLiveViewFilter_PercentNew());
        SetStaticText(IDC_TXT_Filter_PercentNew, buffer);

        return ATMO_FALSE;
}
Exemple #8
0
pascal OSStatus OpenEventHandler(EventHandlerCallRef inHandlerRef, EventRef inEvent, void *inUserData)
{
	DWORD p;
	NavDialogRef fileDialog;
	NavDialogCreationOptions fo;
	NavGetDefaultDialogCreationOptions(&fo);
	fo.optionFlags=0;
	fo.parentWindow=win;
	NavCreateChooseFileDialog(&fo,NULL,NULL,NULL,NULL,NULL,&fileDialog);
	if (!NavDialogRun(fileDialog)) {
		NavReplyRecord r;
		if (!NavDialogGetReply(fileDialog,&r)) {
			AEKeyword k;
			FSRef fr;
			if (!AEGetNthPtr(&r.selection,1,typeFSRef,&k,NULL,&fr,sizeof(fr),NULL)) {
				char file[256];
				FSRefMakePath(&fr,(BYTE*)file,sizeof(file));
				BASS_StreamFree(chan); // free old streams before opening new
		
				// create decode channel
				chan = BASS_StreamCreateFile(FALSE,file,0,0,BASS_SAMPLE_FLOAT|BASS_STREAM_DECODE|BASS_STREAM_PRESCAN);

				// check for MOD
				if (!chan) chan = BASS_MusicLoad(FALSE, file, 0, 0, BASS_SAMPLE_FLOAT|BASS_MUSIC_RAMP|BASS_STREAM_DECODE|BASS_MUSIC_PRESCAN,0);

				if (!chan) {
					SetControlTitleWithCFString(inUserData,CFSTR("click here to open a file && play it..."));
					Error("Selected file couldn't be loaded!");
				} else {
					// create new stream - decoded & reversed
					// 2 seconds decoding block as a decoding channel
					if (!(chan=BASS_FX_ReverseCreate(chan, 2, BASS_STREAM_DECODE|BASS_FX_FREESOURCE))) {
						SetControlTitleWithCFString(inUserData,CFSTR("click here to open a file && play it..."));
						Error("Couldn't create a reversed stream!");
						BASS_StreamFree(chan);
						BASS_MusicFree(chan);
					} else {
						// create a new stream - decoded & resampled :)
						if (!(chan=BASS_FX_TempoCreate(chan, BASS_SAMPLE_LOOP|BASS_FX_FREESOURCE))){
							SetControlTitleWithCFString(inUserData,CFSTR("click here to open a file && play it..."));
							Error("Couldn't create a resampled stream!");
							BASS_StreamFree(chan);
							BASS_MusicFree(chan);
						} else {
							// update the Button to show the loaded file
							c2pstrcpy((BYTE*)file,file);
							SetControlTitle(inUserData,(BYTE*)file);

							// update the position slider
							p = BASS_ChannelBytes2Seconds(chan, BASS_ChannelGetLength(chan, BASS_POS_BYTE));
							SetControl32BitMaximum(GetControl(15),p);
							SetControl32BitValue(GetControl(15),p);

							// set Volume
							p = GetControl32BitValue(GetControl(11));
							BASS_ChannelSetAttribute(chan, BASS_ATTRIB_VOL, (float)p/100.0f);

							// update tempo slider
							SetControl32BitValue(GetControl(13),0);
							SetStaticText(12,"Tempo = 0%");

							// play new created stream
							BASS_ChannelPlay(chan,FALSE);
						}
					}
				}
			}
			NavDisposeReply(&r);
		}
	}
	NavDialogDispose(fileDialog);
	return noErr;
}
Exemple #9
0
// =========================================================================
BOOL CALLBACK dlgAbout_HandleMsg_WM_INITDIALOG(HWND hDlg)
{
    LPWSTR strVersion;
    SHINITDLGINFO shidi;
    WCHAR betaNumber[5];  // Needs to be long enough to hold the beta number
    DWORD driverVersion;
    WCHAR driverVersionStr[256]; // 256 pretty arbitary; just needs to be big
                                 // enough to store the formatted version
                                 // string
    SDUI18N_LANGUAGEW translationDetails;

    DEBUGOUTGUI(DEBUGLEV_ENTER, (TEXT("dlgAbout_HandleMsg_WM_INITDIALOG\n")));

    shidi.dwMask = SHIDIM_FLAGS;
    shidi.dwFlags = (
                     SHIDIF_DONEBUTTON | 
                     SHIDIF_SIPDOWN | 
                     SHIDIF_SIZEDLGFULLSCREEN
                    );
    shidi.hDlg = hDlg;
    SHInitDialog(&shidi);

    G_dlgAbout_MenuBar = SetupMenu_Simple(hDlg, IDR_MENU_NULL);
    G_URLBrush = CreateSolidBrush(RGB(255, 0, 255));

    SDUi18n_TranslateWindow(hDlg);
    SDUi18n_TranslateCommandBar(G_dlgAbout_MenuBar);

    // App title...
    SDUTextSetBold(hDlg, IDC_APP_TITLE, TRUE);
    SetStaticText(hDlg, IDC_APP_TITLE, APP_TITLE);

    // Meeeee!
    SetStaticText(hDlg, IDC_APP_AUTHORCREDIT, APP_AUTHOR_CREDIT);

    // Translator credit...
    SetControlVisible(hDlg, IDC_APP_TRANSLATORCREDIT, FALSE);
    if (!(SDUi18nIsLanguageCodeEnglishW(G_Options->LanguageCode)))
        {
        if (SDUi18n_GetTranslationDetailsW(
                                    G_Options->LanguageCode,
                                    &translationDetails
                                    ))
            {
            SetStaticText(
                          hDlg, 
                          IDC_APP_TRANSLATORCREDIT,
                          SDUParamSubstituteW(
                             _("%1 translation by %2"),
                             TEXT("%s"), translationDetails.LanguageName,
                             TEXT("%s"), translationDetails.TranslatorName,
                             NULL
                             )
                         );

            SetControlVisible(hDlg, IDC_APP_TRANSLATORCREDIT, TRUE);
            }
        }

    // App version...
    if (SDUGetVersionInfoShortFmtAlloc(
                                  NULL,
                                  &strVersion
                                 ))
        {
        SetStaticText(hDlg, IDC_APP_VERSION, strVersion);
        free(strVersion);
        }		

    if (APP_BETA_BUILD > 0)
        {
        _itow(APP_BETA_BUILD, betaNumber, 10);
        AppendStaticText_ResizeToText(hDlg, IDC_APP_VERSION, TEXT(" "));
        AppendStaticText_ResizeToText(hDlg, IDC_APP_VERSION, _("BETA"));
        AppendStaticText_ResizeToText(hDlg, IDC_APP_VERSION, TEXT(" "));
        AppendStaticText_ResizeToText(hDlg, IDC_APP_VERSION, betaNumber);
        }

    // Driver version...
    SetStaticText(
                  hDlg, 
                  IDC_DRIVER_VERSION, 
                  _("<unknown>")
                 );
    if (driver_VersionID(&driverVersion))
        {
        if (_snwprintf(
                       driverVersionStr, 
                       //(sizeof(driverVersionStr) * sizeof(driverVersionStr[0])),
                       (sizeof(driverVersionStr) / sizeof(driverVersionStr[0])),
                       TEXT("v%d.%0.2d.%0.4d"), 
                       (driverVersion & 0xFF000000) / 0x00FF0000,
                       (driverVersion & 0x00FF0000) / 0x0000FF00,
                       (driverVersion & 0x0000FFFF)
                      ) >= 0)
            {
            SetStaticText(hDlg, IDC_DRIVER_VERSION, driverVersionStr);
            }
        }

    _dlgAbout_AlignControls(hDlg);

    // Tappable URL...
    SetStaticText(hDlg, IDC_STATIC_URL, APP_URL);
    SDUTextSetUnderline(hDlg, IDC_STATIC_URL, TRUE);

    DEBUGOUTGUI(DEBUGLEV_EXIT, (TEXT("dlgAbout_HandleMsg_WM_INITDIALOG\n")));
    return TRUE;
}