Esempio n. 1
0
void CJpegEncoder::InitYUV(int frameBufferLen, int frameW, int frameH)
{
	if(cinfoCreated)
		return;
	cinfoCreated = TRUE;
	jpeg_create_compress(&cinfo);

	cinfo.dest = &destMgr;

	cinfo.input_components = 3;
	cinfo.in_color_space = JCS_YCbCr;

	jpeg_set_defaults(&cinfo);

	cinfo.dct_method = JDCT_FASTEST;
	cinfo.optimize_coding = FALSE;

	cinfo.raw_data_in = TRUE;
	jpeg_set_colorspace(&cinfo, JCS_YCbCr);

	SetQuality(JPEG_QUALITY);

	frameBufferSize = frameBufferLen;
	frameBuffer = (unsigned char*) malloc(frameBufferSize);
	frameWidth = frameW;
	frameHeight = frameH;
}
Esempio n. 2
0
SphereNode::SphereNode()
:	MeshInstanceNode()
{
    sphereMesh = NULL;
    SetQuality(80);
    
    CreateSphere(1.f, Color(0.f, 0.f, 0.f, 1.f));
}
Esempio n. 3
0
void AItem::CloneItemSettings(AItem* cloneFromItem)
{
	SetName(cloneFromItem->GetName());
	SetGrade(cloneFromItem->GetGrade());
	SetQuality(cloneFromItem->GetQuality());
	SetType(cloneFromItem->GetType());
	SetItemOwner(cloneFromItem->GetItemOwner());
}
// Allows/disallows hardware acceleration.
HRESULT DS3DSoundEngine::EnableHardware(bool bEnable)
{
    if (m_bAllowHardware != bEnable)
    {
        m_bAllowHardware = bEnable;

        // force the re-creation of all playing sounds, and adjust the 
        // voice limits.
        return SetQuality(m_quality);
    }
    else
    {
        return S_OK;
    }
}
//*****************************************************************************	
void CCeWatchElement::Init()
//*****************************************************************************	
{
	DeleteAllChildren();

	m_Name.Empty();
	m_strFormat.Empty();
	m_Type.Init();

	SetQuality(OPC_QUALITY_BAD | OPC_QUALITY_NOT_CONNECTED);
	m_strValue = CCeWatchBackEnd::GetStateText(CEEmptyValue);
	m_strTime.Empty();

	m_HistoryList.RemoveAll();
	
	m_DebugId = 4711;
}
Esempio n. 6
0
//-----------------------------------------------------------------------------
mglCanvas::mglCanvas(int w, int h) : mglBase()
{
	clr(MGL_DISABLE_SCALE);
	set(MGL_VECT_FRAME);	// NOTE: require a lot of memory!
	Z=0;	C=G=G4=GB=0;	OI=0;	gif=0;
	CurFrameId=0;	Delay=0.5;
	Width=Height=Depth=0;	ObjId=-1;
	fscl=ftet=0;		PlotId = "frame";
	pnt_col = 0;

	ac.ch='c';
	ax.dir = mglPoint(1,0,0);	ax.a = mglPoint(0,1,0);	ax.b = mglPoint(0,0,1);	ax.ch='x';
	ay.dir = mglPoint(0,1,0);	ay.a = mglPoint(1,0,0);	ay.b = mglPoint(0,0,1);	ay.ch='y';
	az.dir = mglPoint(0,0,1);	az.a = mglPoint(0,1,0);	az.b = mglPoint(1,0,0);	az.ch='z';

	SetSize(w,h);	SetQuality(MGL_DRAW_NORM);	DefaultPlotParam();
}
Esempio n. 7
0
void CJpegEncoder::InitRGB()
{
	if(cinfoCreated)
		return;
	cinfoCreated = TRUE;
	jpeg_create_compress(&cinfo);

	cinfo.dest = &destMgr;

	cinfo.input_components = 3;
	cinfo.in_color_space = JCS_RGB;

	jpeg_set_defaults(&cinfo);

	cinfo.dct_method = JDCT_FASTEST;
	cinfo.optimize_coding = FALSE;

	SetQuality(JPEG_QUALITY);
}
Esempio n. 8
0
bool CItemVendable::r_LoadVal(CScript &s)
{
	ADDTOCALLSTACK("CItemVendable::r_LoadVal");
	EXC_TRY("LoadVal");
	switch ( FindTableSorted( s.GetKey(), sm_szLoadKeys, COUNTOF( sm_szLoadKeys )-1 ))
	{
	case IVC_PRICE:	// PRICE
		m_price = s.GetArgVal();
		return true;
	case IVC_QUALITY:	// QUALITY
		SetQuality( static_cast<WORD>(s.GetArgVal()));
		return true;
	}
	return CItem::r_LoadVal(s);
	EXC_CATCH;

	EXC_DEBUG_START;
	EXC_ADD_SCRIPT;
	EXC_DEBUG_END;
	return false;
}
Esempio n. 9
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine, int nCmdShow)
{
	char *pb;
	char *pe;
	WNDCLASS wc;
	HWND hWnd;
	HMENU hMainMenu;
	MSG msg;

	for (pb = lpCmdLine; *pb == ' ' || *pb == '\t'; pb++);
	for (pe = pb; *pe != '\0'; pe++);
	while (--pe > pb && (*pe == ' ' || *pe == '\t'));
	/* Now pb and pe point at respectively the first and last
	   non-blank character in lpCmdLine. If pb > pe then the command line
	   is blank. */
	if (*pb == '"' && *pe == '"')
		pb++;
	else
		pe++;
	*pe = '\0';
	/* Now pb contains the filename, if any, specified on the command line. */

	hWnd = FindWindow(WND_CLASS_NAME, NULL);
	if (hWnd != NULL) {
		/* as instance of WASAP is already running */
		if (*pb != '\0') {
			/* pass the filename */
			COPYDATASTRUCT cds = { 'O', (DWORD) (pe + 1 - pb), pb };
			SendMessage(hWnd, WM_COPYDATA, (WPARAM) NULL, (LPARAM) &cds);
		}
		else {
			/* bring the open dialog to top */
			HWND hChild = GetLastActivePopup(hWnd);
			if (hChild != hWnd)
				SetForegroundWindow(hChild);
		}
		return 0;
	}

	wc.style = CS_OWNDC | CS_VREDRAW | CS_HREDRAW;
	wc.lpfnWndProc = MainWndProc;
	wc.cbClsExtra = 0;
	wc.cbWndExtra = 0;
	wc.hInstance = hInstance;
	wc.hIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_APP));
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
	wc.lpszMenuName = NULL;
	wc.lpszClassName = WND_CLASS_NAME;
	RegisterClass(&wc);

	hWnd = CreateWindow(WND_CLASS_NAME,
		APP_TITLE,
		WS_OVERLAPPEDWINDOW,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		CW_USEDEFAULT,
		NULL,
		NULL,
		hInstance,
		NULL
	);

	hStopIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_STOP));
	hPlayIcon = LoadIcon(hInstance, MAKEINTRESOURCE(IDI_PLAY));
	hMainMenu = LoadMenu(hInstance, MAKEINTRESOURCE(IDR_TRAYMENU));
	hTrayMenu = GetSubMenu(hMainMenu, 0);
	hSongMenu = CreatePopupMenu();
	InsertMenu(hTrayMenu, 1, MF_BYPOSITION | MF_ENABLED | MF_STRING | MF_POPUP,
	           (UINT_PTR) hSongMenu, "So&ng");
	hQualityMenu = GetSubMenu(hTrayMenu, 3);
	SetMenuDefaultItem(hTrayMenu, 0, TRUE);
	Tray_Add(hWnd, hStopIcon);
	SetQuality(hWnd, use_16bit, quality);
	if (*pb != '\0') {
		memcpy(strFile, pb, pe + 1 - pb);
		LoadFile(hWnd);
	}
	else
		SelectAndLoadFile(hWnd);
	while (GetMessage(&msg, NULL, 0, 0)) {
		TranslateMessage(&msg);
		DispatchMessage(&msg);
	}
	WaveOut_Close();
	Tray_Delete(hWnd);
	DestroyMenu(hMainMenu);
	return 0;
}
Esempio n. 10
0
static LRESULT CALLBACK MainWndProc(HWND hWnd, UINT msg, WPARAM wParam,
                                    LPARAM lParam)
{
	UINT idc;
	POINT pt;
	PCOPYDATASTRUCT pcds;
	switch (msg) {
	case WM_COMMAND:
		if (opening)
			break;
		idc = LOWORD(wParam);
		switch (idc) {
		case IDM_OPEN:
			SelectAndLoadFile(hWnd);
			break;
		case IDM_STOP:
			WaveOut_Stop();
			Tray_Modify(hWnd, hStopIcon);
			break;
		case IDM_ABOUT:
			MessageBox(hWnd,
				ASAP_CREDITS
				"WASAP icons (C) 2005 Lukasz Sychowicz\n\n"
				ASAP_COPYRIGHT,
				APP_TITLE " " ASAP_VERSION,
				MB_OK | MB_ICONINFORMATION);
			break;
		case IDM_EXIT:
			PostQuitMessage(0);
			break;
		default:
			if (idc >= IDM_SONG1 && idc < IDM_SONG1 + songs) {
				WaveOut_Stop();
				PlaySong(hWnd, idc - IDM_SONG1);
			}
			else if (idc >= IDM_QUALITY_RF && idc <= IDM_QUALITY_MB3)
				SetQuality(hWnd, use_16bit, idc - IDM_QUALITY_RF);
			else if (idc >= IDM_8BIT && idc <= IDM_16BIT)
				SetQuality(hWnd, idc - IDM_8BIT, quality);
			break;
		}
		break;
	case WM_DESTROY:
		PostQuitMessage(0);
		break;
	case MYWM_NOTIFYICON:
		if (opening) {
			SetForegroundWindow(GetLastActivePopup(hWnd));
			break;
		}
		switch (lParam) {
		case WM_LBUTTONDOWN:
			SelectAndLoadFile(hWnd);
			break;
		case WM_RBUTTONDOWN:
			GetCursorPos(&pt);
			SetForegroundWindow(hWnd);
			TrackPopupMenu(hTrayMenu,
				TPM_RIGHTALIGN | TPM_BOTTOMALIGN | TPM_RIGHTBUTTON,
				pt.x, pt.y, 0, hWnd, NULL);
			PostMessage(hWnd, WM_NULL, 0, 0);
			break;
		default:
			break;
		}
		break;
	case WM_COPYDATA:
		pcds = (PCOPYDATASTRUCT) lParam;
		if (pcds->dwData == 'O' && pcds->cbData <= sizeof(strFile)) {
			memcpy(strFile, pcds->lpData, pcds->cbData);
			LoadFile(hWnd);
		}
		break;
	default:
		return DefWindowProc(hWnd, msg, wParam, lParam);
	}
	return 0;
}
void
SaveWindowAttributes::SetFromNode(DataNode *parentNode)
{
    if(parentNode == 0)
        return;

    DataNode *searchNode = parentNode->GetNode("SaveWindowAttributes");
    if(searchNode == 0)
        return;

    DataNode *node;
    if((node = searchNode->GetNode("outputToCurrentDirectory")) != 0)
        SetOutputToCurrentDirectory(node->AsBool());
    if((node = searchNode->GetNode("outputDirectory")) != 0)
        SetOutputDirectory(node->AsString());
    if((node = searchNode->GetNode("fileName")) != 0)
        SetFileName(node->AsString());
    if((node = searchNode->GetNode("family")) != 0)
        SetFamily(node->AsBool());
    if((node = searchNode->GetNode("format")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 14)
                SetFormat(FileFormat(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            FileFormat value;
            if(FileFormat_FromString(node->AsString(), value))
                SetFormat(value);
        }
    }
    if((node = searchNode->GetNode("width")) != 0)
        SetWidth(node->AsInt());
    if((node = searchNode->GetNode("height")) != 0)
        SetHeight(node->AsInt());
    if((node = searchNode->GetNode("screenCapture")) != 0)
        SetScreenCapture(node->AsBool());
    if((node = searchNode->GetNode("saveTiled")) != 0)
        SetSaveTiled(node->AsBool());
    if((node = searchNode->GetNode("quality")) != 0)
        SetQuality(node->AsInt());
    if((node = searchNode->GetNode("progressive")) != 0)
        SetProgressive(node->AsBool());
    if((node = searchNode->GetNode("binary")) != 0)
        SetBinary(node->AsBool());
    if((node = searchNode->GetNode("lastRealFilename")) != 0)
        SetLastRealFilename(node->AsString());
    if((node = searchNode->GetNode("stereo")) != 0)
        SetStereo(node->AsBool());
    if((node = searchNode->GetNode("compression")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 4)
                SetCompression(CompressionType(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            CompressionType value;
            if(CompressionType_FromString(node->AsString(), value))
                SetCompression(value);
        }
    }
    if((node = searchNode->GetNode("forceMerge")) != 0)
        SetForceMerge(node->AsBool());
    if((node = searchNode->GetNode("resConstraint")) != 0)
    {
        // Allow enums to be int or string in the config file
        if(node->GetNodeType() == INT_NODE)
        {
            int ival = node->AsInt();
            if(ival >= 0 && ival < 3)
                SetResConstraint(ResConstraint(ival));
        }
        else if(node->GetNodeType() == STRING_NODE)
        {
            ResConstraint value;
            if(ResConstraint_FromString(node->AsString(), value))
                SetResConstraint(value);
        }
    }
    if((node = searchNode->GetNode("advancedMultiWindowSave")) != 0)
        SetAdvancedMultiWindowSave(node->AsBool());
    if((node = searchNode->GetNode("subWindowAtts")) != 0)
        subWindowAtts.SetFromNode(node);
}
Esempio n. 12
0
void CameraServer::Serve() {
  int sock = socket(AF_INET, SOCK_STREAM, 0);

  if (sock == -1)
    wpi_setErrnoError();

  int reuseAddr = 1;
  if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, &reuseAddr, sizeof(reuseAddr)) == -1)
    wpi_setErrnoError();

  sockaddr_in address, clientAddress;

  memset(&address, 0, sizeof(address));
  address.sin_family = AF_INET;
  address.sin_addr.s_addr = htonl(INADDR_ANY);
  address.sin_port = htons(kPort);

  if (bind(sock, (struct sockaddr *)&address, sizeof(address)) == -1)
    wpi_setErrnoError();

  if (listen(sock, 10) == -1)
    wpi_setErrnoError();

  while(true) {
    socklen_t clientAddressLen = sizeof(clientAddress);

    int conn = accept(sock, (struct sockaddr*)&clientAddress, &clientAddressLen);
    if (conn == -1) {
      wpi_setErrnoError();
      continue;
    }

    Request req;
    if (read(conn, &req, sizeof(req)) == -1) {
      wpi_setErrnoError();
      close(conn);
      continue;
    } else {
      req.fps = ntohl(req.fps);
      req.compression = ntohl(req.compression);
      req.size = ntohl(req.size);
    }

    // TODO: Support the SW Compression. The rest of the code below will work as though this
    // check isn't here
    if (req.compression != kHardwareCompression) {
      wpi_setWPIErrorWithContext(IncompatibleState, "Choose \"USB Camera HW\" on the dashboard");
      close(conn);
      continue;
    }

    {
      // Wait for the camera to be setw
      std::unique_lock<std::recursive_mutex> lock(m_imageMutex);
      if (!m_camera) {
        std::cout << "Camera not yet ready, awaiting first image" << std::endl;
        m_newImageVariable.wait(lock);
      }
      m_hwClient = req.compression == kHardwareCompression;
      if (!m_hwClient) SetQuality(100 - req.compression);
      else if (m_camera) m_camera->SetFPS(req.fps);
      SetSize(req.size);
    }

    auto period = std::chrono::microseconds(1000000) / req.fps;
    while (true) {
      auto startTime = std::chrono::steady_clock::now();
      std::tuple<uint8_t*, unsigned int, unsigned int, bool> imageData;
      {
        std::unique_lock<std::recursive_mutex> lock(m_imageMutex);
        m_newImageVariable.wait(lock);
        imageData = m_imageData;
        m_imageData = std::make_tuple(nullptr, 0, 0, false);
      }

      unsigned int size = std::get<1>(imageData);
      unsigned int netSize = htonl(size);
      unsigned int start = std::get<2>(imageData);
      uint8_t *data = std::get<0>(imageData);

      if (data == nullptr) continue;

      if (write(conn, kMagicNumber, sizeof(kMagicNumber)) == -1) {
        wpi_setErrnoErrorWithContext("[CameraServer] Error sending magic number");
        FreeImageData(imageData);
        break;
      }
      if (write(conn, &netSize, sizeof(netSize)) == -1) {
        wpi_setErrnoErrorWithContext("[CameraServer] Error sending image size");
        FreeImageData(imageData);
        break;
      }
      if (write(conn, &data[start], sizeof(uint8_t) * size) == -1) {
        wpi_setErrnoErrorWithContext("[CameraServer] Error sending image data");
        FreeImageData(imageData);
        break;
      }
      FreeImageData(imageData);
      std::this_thread::sleep_until(startTime + period);
    }
    close(conn);
  }
  close(sock);
}
BonkEnc::ConfigureFAAC::ConfigureFAAC()
{
	Point	 pos;
	Size	 size;

	currentConfig = BonkEnc::currentConfig;

	mpegVersion = currentConfig->faac_mpegversion;
	aacType = currentConfig->faac_type;
	bitrate = currentConfig->faac_bitrate;
	allowjs = currentConfig->faac_allowjs;
	usetns = currentConfig->faac_usetns;
	setQuality = currentConfig->faac_set_quality;
	aacQuality = currentConfig->faac_aac_quality;
	allowID3 = currentConfig->faac_enable_id3;
	fileFormat = currentConfig->faac_enable_mp4;

	mainWnd			= new Window(String(BonkEnc::i18n->TranslateString("%1 encoder configuration")).Replace("%1", "FAAC"), currentConfig->wndPos + Point(80, 80), Size(547, 295));
	mainWnd->SetRightToLeft(BonkEnc::i18n->IsActiveLanguageRightToLeft());

	mainWnd_titlebar	= new Titlebar(TB_CLOSEBUTTON);
	divbar			= new Divider(39, OR_HORZ | OR_BOTTOM);

	pos.x = 175;
	pos.y = 29;
	size.cx = 0;
	size.cy = 0;

	btn_cancel		= new Button(BonkEnc::i18n->TranslateString("Cancel"), NIL, pos, size);
	btn_cancel->onAction.Connect(&ConfigureFAAC::Cancel, this);
	btn_cancel->SetOrientation(OR_LOWERRIGHT);

	pos.x -= 88;

	btn_ok			= new Button(BonkEnc::i18n->TranslateString("OK"), NIL, pos, size);
	btn_ok->onAction.Connect(&ConfigureFAAC::OK, this);
	btn_ok->SetOrientation(OR_LOWERRIGHT);

	pos.x = 7;
	pos.y = 7;
	size.cx = 525;
	size.cy = 208;

	tabwidget		= new TabWidget(pos, size);

	layer_format		= new Layer(BonkEnc::i18n->TranslateString("Format"));

	pos.x = 135;
	pos.y = 11;
	size.cx = 120;
	size.cy = 65;

	group_version		= new GroupBox(BonkEnc::i18n->TranslateString("MPEG version"), pos, size);

	pos.x += 10;
	pos.y += 13;
	size.cx = 99;
	size.cy = 0;

	option_version_mpeg2	= new OptionBox("MPEG 2", pos, size, &mpegVersion, 1);
	option_version_mpeg2->onAction.Connect(&ConfigureFAAC::SetMPEGVersion, this);

	pos.y += 25;

	option_version_mpeg4	= new OptionBox("MPEG 4", pos, size, &mpegVersion, 0);
	option_version_mpeg4->onAction.Connect(&ConfigureFAAC::SetMPEGVersion, this);

	pos.x = 7;
	pos.y = 88;
	size.cx = 120;
	size.cy = 90;

	group_aactype		= new GroupBox(BonkEnc::i18n->TranslateString("AAC object type"), pos, size);

	pos.x += 10;
	pos.y += 13;
	size.cx = 99;
	size.cy = 0;

	option_aactype_main	= new OptionBox("MAIN", pos, size, &aacType, 1);
	option_aactype_main->onAction.Connect(&ConfigureFAAC::SetObjectType, this);

	pos.y += 25;

	option_aactype_low	= new OptionBox("LC", pos, size, &aacType, 2);
	option_aactype_low->onAction.Connect(&ConfigureFAAC::SetObjectType, this);

	pos.y += 25;

	option_aactype_ltp	= new OptionBox("LTP", pos, size, &aacType, 4);
	option_aactype_ltp->onAction.Connect(&ConfigureFAAC::SetObjectType, this);

	pos.x = 7;
	pos.y = 11;
	size.cx = 120;
	size.cy = 65;

	group_mp4		= new GroupBox(BonkEnc::i18n->TranslateString("File format"), pos, size);

	pos.x += 10;
	pos.y += 13;
	size.cx = 99;
	size.cy = 0;

	option_mp4		= new OptionBox("MP4", pos, size, &fileFormat, 1);
	option_mp4->onAction.Connect(&ConfigureFAAC::SetFileFormat, this);

	if (!currentConfig->enable_mp4)
	{
		option_mp4->Deactivate();

		fileFormat = 0;
	}

	pos.y += 25;

	option_aac		= new OptionBox("AAC", pos, size, &fileFormat, 0);
	option_aac->onAction.Connect(&ConfigureFAAC::SetFileFormat, this);

	pos.x = 135;
	pos.y = 88;
	size.cx = 279;
	size.cy = 90;

	group_id3v2		= new GroupBox(BonkEnc::i18n->TranslateString("Info tags"), pos, size);

	pos.x += 10;
	pos.y += 13;
	size.cx = 200;
	size.cy = 0;

	check_id3v2		= new CheckBox(BonkEnc::i18n->TranslateString("Allow ID3v2 tags in AAC files"), pos, size, &allowID3);
	check_id3v2->SetWidth(check_id3v2->textSize.cx + 20);

	pos.y += 25;

	text_note		= new Text(BonkEnc::i18n->TranslateString("Note:"), pos);

	pos.x += text_note->textSize.cx + 2;

	text_id3v2		= new Text(BonkEnc::i18n->TranslateString("Some players may have problems playing AAC\nfiles with ID3 tags attached. Please use this option only\nif you are sure that your player can handle these tags."), pos);

	group_id3v2->SetWidth(text_note->textSize.cx + text_id3v2->textSize.cx + 22);

	layer_quality		= new Layer(BonkEnc::i18n->TranslateString("Quality"));

	pos.x = 7;
	pos.y = 11;
	size.cx = 320;
	size.cy = 65;

	group_bitrate		= new GroupBox(BonkEnc::i18n->TranslateString("Bitrate / Quality"), pos, size);

	pos.x += 10;
	pos.y += 13;
	size.cx = 150;
	size.cy = 0;

	option_bitrate		= new OptionBox(BonkEnc::i18n->TranslateString("Bitrate per channel:"), pos, size, &setQuality, 0);
	option_bitrate->onAction.Connect(&ConfigureFAAC::ToggleBitrateQuality, this);
	option_bitrate->SetWidth(option_bitrate->textSize.cx + 19);

	pos.x += (option_bitrate->GetWidth() + 9);
	size.cx = 227 - option_bitrate->GetWidth();
	size.cy = 0;

	slider_bitrate		= new Slider(pos, size, OR_HORZ, &bitrate, 8, 256);
	slider_bitrate->onValueChange.Connect(&ConfigureFAAC::SetBitrate, this);

	pos.x += (size.cx + 8);
	pos.y -= 1;
	size.cx = 25;

	edit_bitrate		= new EditBox("", pos, size, 3);
	edit_bitrate->SetFlags(EDB_NUMERIC);
	edit_bitrate->onInput.Connect(&ConfigureFAAC::SetBitrateByEditBox, this);

	pos.x += 32;
	pos.y += 3;

	text_bitrate_kbps	= new Text("kbps", pos);

	pos.x = 17;
	pos.y += 23;
	size.cx = 150;
	size.cy = 0;

	option_quality		= new OptionBox(BonkEnc::i18n->TranslateString("Set quality:"), pos, size, &setQuality, 1);
	option_quality->onAction.Connect(&ConfigureFAAC::ToggleBitrateQuality, this);
	option_quality->SetWidth(option_bitrate->textSize.cx + 19);

	pos.x += (option_quality->GetWidth() + 9);
	size.cx = 227 - option_quality->GetWidth();
	size.cy = 0;

	slider_quality		= new Slider(pos, size, OR_HORZ, &aacQuality, 10, 500);
	slider_quality->onValueChange.Connect(&ConfigureFAAC::SetQuality, this);

	pos.x += (size.cx + 8);
	pos.y -= 1;
	size.cx = 25;

	edit_quality		= new EditBox("", pos, size, 3);
	edit_quality->SetFlags(EDB_NUMERIC);
	edit_quality->onInput.Connect(&ConfigureFAAC::SetQualityByEditBox, this);

	pos.x += 32;
	pos.y += 3;

	text_quality_percent	= new Text("%", pos);

	pos.x = 335;
	pos.y = 11;
	size.cx = 179;
	size.cy = 42;

	group_js		= new GroupBox(BonkEnc::i18n->TranslateString("Stereo mode"), pos, size);

	pos.x += 10;
	pos.y += 13;
	size.cx = 158;
	size.cy = 0;

	check_js		= new CheckBox(BonkEnc::i18n->TranslateString("Allow Joint Stereo"), pos, size, &allowjs);

	pos.x = 335;
	pos.y = 65;
	size.cx = 179;
	size.cy = 42;

	group_tns		= new GroupBox(BonkEnc::i18n->TranslateString("Temporal Noise Shaping"), pos, size);

	pos.x += 10;
	pos.y += 13;
	size.cx = 158;
	size.cy = 0;

	check_tns		= new CheckBox(BonkEnc::i18n->TranslateString("Use Temporal Noise Shaping"), pos, size, &usetns);

	pos.x = 7;
	pos.y = 88;
	size.cx = 320;
	size.cy = 43;

	group_bandwidth		= new GroupBox(BonkEnc::i18n->TranslateString("Maximum bandwidth"), pos, size);

	pos.x += 11;
	pos.y += 15;

	text_bandwidth		= new Text(BonkEnc::i18n->TranslateString("Maximum AAC frequency bandwidth to use (Hz):"), pos);

	pos.x += (text_bandwidth->textSize.cx + 8);
	pos.y -= 3;
	size.cx = 291 - text_bandwidth->textSize.cx;
	size.cy = 0;

	edit_bandwidth		= new EditBox(String::FromInt(currentConfig->faac_bandwidth), pos, size, 5);
	edit_bandwidth->SetFlags(EDB_NUMERIC);

	SetBitrate();
	SetQuality();
	SetMPEGVersion();
	SetFileFormat();

	ToggleBitrateQuality();

	Add(mainWnd);

	mainWnd->Add(btn_ok);
	mainWnd->Add(btn_cancel);
	mainWnd->Add(tabwidget);
	mainWnd->Add(mainWnd_titlebar);
	mainWnd->Add(divbar);

	tabwidget->Add(layer_quality);
	tabwidget->Add(layer_format);

	layer_format->Add(group_version);
	layer_format->Add(option_version_mpeg2);
	layer_format->Add(option_version_mpeg4);
	layer_format->Add(group_aactype);
	layer_format->Add(option_aactype_main);
	layer_format->Add(option_aactype_low);
	layer_format->Add(option_aactype_ltp);
	layer_format->Add(group_mp4);
	layer_format->Add(option_mp4);
	layer_format->Add(option_aac);
	layer_format->Add(group_id3v2);
	layer_format->Add(check_id3v2);
	layer_format->Add(text_note);
	layer_format->Add(text_id3v2);

	layer_quality->Add(group_bitrate);
	layer_quality->Add(option_bitrate);
	layer_quality->Add(slider_bitrate);
	layer_quality->Add(edit_bitrate);
	layer_quality->Add(text_bitrate_kbps);
	layer_quality->Add(option_quality);
	layer_quality->Add(slider_quality);
	layer_quality->Add(edit_quality);
	layer_quality->Add(text_quality_percent);
	layer_quality->Add(group_js);
	layer_quality->Add(check_js);
	layer_quality->Add(group_tns);
	layer_quality->Add(check_tns);
	layer_quality->Add(group_bandwidth);
	layer_quality->Add(text_bandwidth);
	layer_quality->Add(edit_bandwidth);

	mainWnd->SetFlags(mainWnd->GetFlags() | WF_NOTASKBUTTON);
	mainWnd->SetIcon(ImageLoader::Load("freac.pci:0"));
}
// Basic initialization.  This was pulled out of the constructor so that we
// can return error values.
HRESULT DS3DSoundEngine::Init(HWND hwnd, bool bUseDSound8)
{
    HRESULT hr;

    // Create the device
	// mdvalley: Changed to Create8
	if(bUseDSound8)
		hr = DirectSoundCreate8(NULL, &m_pDirectSound8, NULL);
	else
		hr = DirectSoundCreate(NULL, &m_pDirectSound, NULL);
    if (hr == DSERR_NODRIVER || hr == DSERR_ALLOCATED || ZFailed(hr)) return hr;

	if(bUseDSound8)
		hr = m_pDirectSound8->SetCooperativeLevel(hwnd, DSSCL_PRIORITY);
	else
		hr = m_pDirectSound->SetCooperativeLevel(hwnd, DSSCL_PRIORITY);
    if (hr == DSERR_ALLOCATED) 
    {
        debugf("Failure: unable to get DSSCL_PRIORITY access to DSound.  Failing over to DSSCL_NORMAL.\n");
		if(bUseDSound8)
			hr = m_pDirectSound->SetCooperativeLevel(hwnd, DSSCL_NORMAL);
		else
			hr = m_pDirectSound->SetCooperativeLevel(hwnd, DSSCL_NORMAL);
    }
    if (ZFailed(hr)) return hr;

    // go ahead and try compacting the memory; it's not neccessary but may 
    // give us better hardware utilization on some sound cards.
	// mdvalley: This has no function in DX8, but it's harmless.
	if(!bUseDSound8)
		m_pDirectSound->Compact(); // if it fails, who cares.  

    // get the primary buffer
    DSBUFFERDESC dsbufferdesc;
    memset(&dsbufferdesc, 0, sizeof(DSBUFFERDESC));
    dsbufferdesc.dwSize = sizeof(dsbufferdesc);
    dsbufferdesc.dwFlags = DSBCAPS_CTRL3D | DSBCAPS_PRIMARYBUFFER;
	dsbufferdesc.dwBufferBytes = 0;		// mdvalley: Set these for the primary
	dsbufferdesc.lpwfxFormat = NULL;
	if(bUseDSound8)
		hr = m_pDirectSound8->CreateSoundBuffer(&dsbufferdesc, &m_pPrimaryBuffer, NULL);
	else
		hr = m_pDirectSound->CreateSoundBuffer(&dsbufferdesc, &m_pPrimaryBuffer, NULL);
    if (ZFailed(hr)) return hr;

    // get the DirectSound listener
    hr = m_pPrimaryBuffer->QueryInterface(IID_IDirectSound3DListener, (LPVOID *)&m_pDSListener);
    if (ZFailed(hr)) return hr;

    // get the capabilities of the hardware
    memset(&m_dscaps, 0, sizeof(DSCAPS));
    m_dscaps.dwSize = sizeof(DSCAPS);
	if(bUseDSound8)
		hr = m_pDirectSound8->GetCaps(&m_dscaps);
	else
		hr = m_pDirectSound->GetCaps(&m_dscaps);
    if (ZFailed(hr)) return hr;
    DumpCaps();

    // Set the quality-related settings
    hr = SetQuality(midQuality);
    if (ZFailed(hr)) return hr;

    // start the primary buffer playing continuously
    hr = m_pPrimaryBuffer->Play(0, 0, DSBPLAY_LOOPING);
    if ((hr != DSERR_PRIOLEVELNEEDED) && ZFailed(hr)) return hr;

    return S_OK;
}
Esempio n. 15
0
// toggle variable bit rate
void plVoiceRecorder::SetVBR(bool vbr)
{
    plSpeex::GetInstance()->VBR(vbr);
    SetQuality(plSpeex::GetInstance()->GetQuality());       // update proper quality param
}