void GraphicsCaptureSource::AttemptCapture() { //Log(TEXT("attempting to capture..")); if (!bUseHotkey) hwndTarget = FindWindow(strWindowClass, NULL); else { hwndTarget = hwndNextTarget; hwndNextTarget = NULL; } if (hwndTarget) { GetWindowThreadProcessId(hwndTarget, &targetProcessID); if(!targetProcessID) { AppWarning(TEXT("GraphicsCaptureSource::BeginScene: GetWindowThreadProcessId failed, GetLastError = %u"), GetLastError()); bErrorAcquiring = true; return; } } else { if (!bUseHotkey && !warningID) warningID = API->AddStreamInfo(Str("Sources.SoftwareCaptureSource.WindowNotFound"), StreamInfoPriority_High); bCapturing = false; return; } if(warningID) { API->RemoveStreamInfo(warningID); warningID = 0; } //------------------------------------------- // see if we already hooked the process. if not, inject DLL char pOPStr[12]; mcpy(pOPStr, "NpflUvhel{x", 12); //OpenProcess obfuscated for (int i=0; i<11; i++) pOPStr[i] ^= i^1; OPPROC pOpenProcess = (OPPROC)GetProcAddress(GetModuleHandle(TEXT("KERNEL32")), pOPStr); HANDLE hProcess = (*pOpenProcess)(PROCESS_ALL_ACCESS, FALSE, targetProcessID); if(hProcess) { //------------------------------------------- // load keepalive event hOBSIsAlive = CreateEvent(NULL, FALSE, FALSE, String() << OBS_KEEPALIVE_EVENT << UINT(targetProcessID)); //------------------------------------------- hwndCapture = hwndTarget; hSignalRestart = OpenEvent(EVENT_ALL_ACCESS, FALSE, String() << RESTART_CAPTURE_EVENT << UINT(targetProcessID)); if(hSignalRestart) { SetEvent(hSignalRestart); bCapturing = true; captureWaitCount = 0; } else { BOOL bSameBit = TRUE; if(Is64BitWindows()) { BOOL bCurrentProcessWow64, bTargetProcessWow64; IsWow64Process(GetCurrentProcess(), &bCurrentProcessWow64); IsWow64Process(hProcess, &bTargetProcessWow64); bSameBit = (bCurrentProcessWow64 == bTargetProcessWow64); } if(bSameBit) { String strDLL; DWORD dwDirSize = GetCurrentDirectory(0, NULL); strDLL.SetLength(dwDirSize); GetCurrentDirectory(dwDirSize, strDLL); strDLL << TEXT("\\plugins\\GraphicsCapture\\GraphicsCaptureHook"); BOOL b32bit = TRUE; if(Is64BitWindows()) IsWow64Process(hProcess, &b32bit); if(!b32bit) strDLL << TEXT("64"); strDLL << TEXT(".dll"); if(InjectLibrary(hProcess, strDLL)) { captureWaitCount = 0; bCapturing = true; } else { AppWarning(TEXT("GraphicsCaptureSource::BeginScene: Failed to inject library, GetLastError = %u"), GetLastError()); CloseHandle(hProcess); hProcess = NULL; bErrorAcquiring = true; } } else { String strDLLPath; DWORD dwDirSize = GetCurrentDirectory(0, NULL); strDLLPath.SetLength(dwDirSize); GetCurrentDirectory(dwDirSize, strDLLPath); strDLLPath << TEXT("\\plugins\\GraphicsCapture"); BOOL b32bit = TRUE; if(Is64BitWindows()) IsWow64Process(hProcess, &b32bit); String strHelper = strDLLPath; strHelper << ((b32bit) ? TEXT("\\injectHelper.exe") : TEXT("\\injectHelper64.exe")); String strCommandLine; strCommandLine << TEXT("\"") << strHelper << TEXT("\" ") << UIntString(targetProcessID); //--------------------------------------- PROCESS_INFORMATION pi; STARTUPINFO si; zero(&pi, sizeof(pi)); zero(&si, sizeof(si)); si.cb = sizeof(si); if(CreateProcess(strHelper, strCommandLine, NULL, NULL, FALSE, 0, NULL, strDLLPath, &si, &pi)) { int exitCode = 0; WaitForSingleObject(pi.hProcess, INFINITE); GetExitCodeProcess(pi.hProcess, (DWORD*)&exitCode); CloseHandle(pi.hThread); CloseHandle(pi.hProcess); if(exitCode == 0) { captureWaitCount = 0; bCapturing = true; } else { AppWarning(TEXT("GraphicsCaptureSource::BeginScene: Failed to inject library, error code = %d"), exitCode); bErrorAcquiring = true; } } else { AppWarning(TEXT("GraphicsCaptureSource::BeginScene: Could not create inject helper, GetLastError = %u"), GetLastError()); bErrorAcquiring = true; } } } CloseHandle(hProcess); hProcess = NULL; if (!bCapturing) { CloseHandle(hOBSIsAlive); hOBSIsAlive = NULL; } } else { AppWarning(TEXT("GraphicsCaptureSource::BeginScene: OpenProcess failed, GetLastError = %u"), GetLastError()); bErrorAcquiring = true; } }
int32_t serialport_init(CSOUND *csound, const char* serialport, int32_t baud) { IGN(csound); HANDLE hSerial; DCB dcbSerialParams = {0}; int32_t i; /* NEED TO CREATE A GLOBAL FOR HANDLE */ SERIAL_GLOBALS *q; q = (SERIAL_GLOBALS*) csound->QueryGlobalVariable(csound, "serialGlobals_"); if (q == NULL) { if (UNLIKELY(csound->CreateGlobalVariable(csound, "serialGlobals_", sizeof(SERIAL_GLOBALS)) != 0)) { csound->InitError(csound, Str("serial: failed to allocate globals")); return -1; } q = (SERIAL_GLOBALS*) csound->QueryGlobalVariable(csound, "serialGlobals_"); q->csound = csound; q->maxind = 0; } /* WCHAR wport[256]; */ /* MultiByteToWideChar(CP_ACP,MB_PRECOMPOSED, serialport, */ /* strlen(serialport)+1, */ /* (LPCSTR)wport, 256); */ /* hSerial = CreateFile(serialport, GENERIC_READ | GENERIC_WRITE, 0, */ /* 0, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0); */ hSerial = CreateFileA(serialport, GENERIC_READ | GENERIC_WRITE, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); //Check if the connection was successfull if (UNLIKELY(hSerial==INVALID_HANDLE_VALUE)) { //If not success full display an Error return csound->InitError(csound, Str("%s not available.\n"), serialport); } memset(&dcbSerialParams, 0, sizeof(dcbSerialParams)); dcbSerialParams.DCBlength=sizeof(dcbSerialParams); switch (baud) { case 1200: dcbSerialParams.BaudRate = CBR_1200; break; case 2400: dcbSerialParams.BaudRate = CBR_2400; break; case 4800: dcbSerialParams.BaudRate = CBR_4800; break; default: case 9600: dcbSerialParams.BaudRate = CBR_9600; break; case 14400: dcbSerialParams.BaudRate = CBR_14400; break; case 19200: dcbSerialParams.BaudRate = CBR_19200; break; case 38400: dcbSerialParams.BaudRate = CBR_38400; break; case 56000: dcbSerialParams.BaudRate = CBR_56000; break; case 57600: dcbSerialParams.BaudRate = CBR_57600; break; case 115200: dcbSerialParams.BaudRate = CBR_115200; break; case 128000: dcbSerialParams.BaudRate = CBR_128000; break; case 256000: dcbSerialParams.BaudRate = CBR_256000; break; } dcbSerialParams.ByteSize=8; dcbSerialParams.StopBits=ONESTOPBIT; dcbSerialParams.Parity=NOPARITY; SetCommState(hSerial, &dcbSerialParams); for (i=0; i>q->maxind; i++) { if (q->handles[i]==NULL) { q->handles[i] = hSerial; return i; } } if (UNLIKELY(q->maxind>=10)) { csound->InitError(csound, Str("Number of serial handles exhausted")); return -1; } q->handles[q->maxind++] = hSerial; return q->maxind-1; }
INT_PTR SettingsEncoding::ProcMessage(UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: { HWND hwndTemp; LocalizeWindow(hwnd); //-------------------------------------------- bool showQSVConfigurationWarning = false; hasQSV = CheckQSVHardwareSupport(false, &showQSVConfigurationWarning); hasNVENC = CheckNVENCHardwareSupport(false); String vcodec = AppConfig->GetString(L"Video Encoding", L"Encoder"); bool useQSV = !!(vcodec == L"QSV"); bool useNVENC = !!(vcodec == L"NVENC"); bool usex264 = !useQSV && !useNVENC; SendMessage(GetDlgItem(hwnd, IDC_ENCODERX264), BM_SETCHECK, usex264, 0); SendMessage(GetDlgItem(hwnd, IDC_ENCODERQSV), BM_SETCHECK, useQSV, 0); SendMessage(GetDlgItem(hwnd, IDC_ENCODERNVENC), BM_SETCHECK, useNVENC, 0); EnableWindow(GetDlgItem(hwnd, IDC_ENCODERQSV), hasQSV || useQSV); EnableWindow(GetDlgItem(hwnd, IDC_ENCODERNVENC), hasNVENC || useNVENC); ShowWindow(GetDlgItem(hwnd, IDC_QSV_CONFIG_WARNING), showQSVConfigurationWarning ? SW_SHOW : SW_HIDE); //-------------------------------------------- HWND hwndToolTip = CreateWindowEx(NULL, TOOLTIPS_CLASS, NULL, WS_POPUP|TTS_NOPREFIX|TTS_ALWAYSTIP, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, hwnd, NULL, hinstMain, NULL); TOOLINFO ti; zero(&ti, sizeof(ti)); ti.cbSize = sizeof(ti); ti.uFlags = TTF_SUBCLASS|TTF_IDISHWND; ti.hwnd = hwnd; if (LocaleIsRTL()) ti.uFlags |= TTF_RTLREADING; SendMessage(hwndToolTip, TTM_SETMAXTIPWIDTH, 0, 500); SendMessage(hwndToolTip, TTM_SETDELAYTIME, TTDT_AUTOPOP, 8000); //-------------------------------------------- hwndTemp = GetDlgItem(hwnd, IDC_QUALITY); for(int i=0; i<=10; i++) SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)IntString(i).Array()); LoadSettingComboString(hwndTemp, TEXT("Video Encoding"), TEXT("Quality"), TEXT("8")); ti.lpszText = (LPWSTR)Str("Settings.Encoding.Video.QualityTooltip"); ti.uId = (UINT_PTR)hwndTemp; SendMessage(hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti); //-------------------------------------------- bool bUseCBR = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseCBR"), 1) != 0; bool bPadCBR = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("PadCBR"), 1) != 0; SendMessage(GetDlgItem(hwnd, IDC_USECBR), BM_SETCHECK, bUseCBR ? BST_CHECKED : BST_UNCHECKED, 0); SendMessage(GetDlgItem(hwnd, IDC_PADCBR), BM_SETCHECK, bPadCBR ? BST_CHECKED : BST_UNCHECKED, 0); EnableWindow(GetDlgItem(hwnd, IDC_QUALITY), !bUseCBR && (usex264 || useNVENC)); EnableWindow(GetDlgItem(hwnd, IDC_PADCBR), bUseCBR && usex264); ti.lpszText = (LPWSTR)Str("Settings.Advanced.PadCBRToolTip"); ti.uId = (UINT_PTR)GetDlgItem(hwnd, IDC_PADCBR); SendMessage(hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti); //-------------------------------------------- int bitrate = LoadSettingEditInt(GetDlgItem(hwnd, IDC_MAXBITRATE), TEXT("Video Encoding"), TEXT("MaxBitrate"), 1000); int buffersize = LoadSettingEditInt(GetDlgItem(hwnd, IDC_BUFFERSIZE), TEXT("Video Encoding"), TEXT("BufferSize"), 1000); ti.lpszText = (LPWSTR)Str("Settings.Encoding.Video.MaxBitRateTooltip"); ti.uId = (UINT_PTR)GetDlgItem(hwnd, IDC_MAXBITRATE); SendMessage(hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti); ti.lpszText = (LPWSTR)Str("Settings.Encoding.Video.BufferSizeTooltip"); ti.uId = (UINT_PTR)GetDlgItem(hwnd, IDC_BUFFERSIZE); SendMessage(hwndToolTip, TTM_ADDTOOL, 0, (LPARAM)&ti); //-------------------------------------------- bool bUseBufferSize = AppConfig->GetInt(TEXT("Video Encoding"), TEXT("UseBufferSize"), 0) != 0; SendMessage(GetDlgItem(hwnd, IDC_CUSTOMBUFFER), BM_SETCHECK, bUseBufferSize ? BST_CHECKED : BST_UNCHECKED, 0); EnableWindow(GetDlgItem(hwnd, IDC_BUFFERSIZE), bUseBufferSize); //-------------------------------------------- hwndTemp = GetDlgItem(hwnd, IDC_AUDIOCODEC); SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("MP3")); #ifdef USE_AAC if(1)//OSGetVersion() >= 7) { SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("AAC")); LoadSettingComboString(hwndTemp, TEXT("Audio Encoding"), TEXT("Codec"), TEXT("AAC")); } else LoadSettingComboString(hwndTemp, TEXT("Audio Encoding"), TEXT("Codec"), TEXT("MP3")); #else LoadSettingComboString(hwndTemp, TEXT("Audio Encoding"), TEXT("Codec"), TEXT("MP3")); #endif //-------------------------------------------- hwndTemp = GetDlgItem(hwnd, IDC_AUDIOFORMAT); BOOL isAAC = SendMessage(GetDlgItem(hwnd, IDC_AUDIOCODEC), CB_GETCURSEL, 0, 0) == 1; if (isAAC) { SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("44.1kHz")); SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("48kHz")); } else { SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("44.1kHz")); } LoadSettingComboInt(hwndTemp, TEXT("Audio Encoding"), TEXT("Format"), 1, isAAC ? 1 : 0); //-------------------------------------------- hwndTemp = GetDlgItem(hwnd, IDC_AUDIOCHANNEL); SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("mono")); SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("stereo")); LoadSettingComboInt(hwndTemp, TEXT("Audio Encoding"), TEXT("isStereo"), 1, 1); //-------------------------------------------- hwndTemp = GetDlgItem(hwnd, IDC_AUDIOBITRATE); BOOL isStereo = SendMessage(GetDlgItem(hwnd, IDC_AUDIOCHANNEL), CB_GETCURSEL, 0, 0) == 1; if (isStereo) { SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("48")); SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("64")); SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("80")); SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("96"));//default SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("112")); SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("128")); SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("160")); SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("192")); SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("256")); SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("320")); }else{ SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("32")); SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("40")); SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("48"));//default SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("56")); SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("64")); SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("80")); SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("96")); SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("128")); SendMessage(hwndTemp, CB_ADDSTRING, 0, (LPARAM)TEXT("160")); } LoadSettingComboString(hwndTemp, TEXT("Audio Encoding"), TEXT("Bitrate"), isStereo ? TEXT("96") : TEXT("48")); //-------------------------------------------- ShowWindow(GetDlgItem(hwnd, IDC_INFO), SW_HIDE); SetChangedSettings(false); return TRUE; } case WM_COMMAND: { bool bDataChanged = false; bool useQSV = SendMessage(GetDlgItem(hwnd, IDC_ENCODERQSV), BM_GETCHECK, 0, 0) == BST_CHECKED; bool useNVENC = SendMessage(GetDlgItem(hwnd, IDC_ENCODERNVENC), BM_GETCHECK, 0, 0) == BST_CHECKED; bool usex264 = !useQSV && !useNVENC; bool useCBR = SendMessage(GetDlgItem(hwnd, IDC_USECBR), BM_GETCHECK, 0, 0) == BST_CHECKED; switch(LOWORD(wParam)) { case IDC_QUALITY: case IDC_AUDIOBITRATE: if(HIWORD(wParam) == CBN_SELCHANGE) { bDataChanged = true; } break; case IDC_AUDIOFORMAT: if(HIWORD(wParam) == CBN_SELCHANGE) { bDataChanged = true; } break; case IDC_AUDIOCHANNEL: if(HIWORD(wParam) == CBN_SELCHANGE) { HWND hwndAudioBitrate = GetDlgItem(hwnd, IDC_AUDIOBITRATE); SendMessage(hwndAudioBitrate, CB_RESETCONTENT, 0, 0); BOOL isStereo = SendMessage(GetDlgItem(hwnd, IDC_AUDIOCHANNEL), CB_GETCURSEL, 0, 0) == 1; if (isStereo) { SendMessage(hwndAudioBitrate, CB_ADDSTRING, 0, (LPARAM)TEXT("48")); SendMessage(hwndAudioBitrate, CB_ADDSTRING, 0, (LPARAM)TEXT("64")); SendMessage(hwndAudioBitrate, CB_ADDSTRING, 0, (LPARAM)TEXT("80")); SendMessage(hwndAudioBitrate, CB_ADDSTRING, 0, (LPARAM)TEXT("96"));//default SendMessage(hwndAudioBitrate, CB_ADDSTRING, 0, (LPARAM)TEXT("112")); SendMessage(hwndAudioBitrate, CB_ADDSTRING, 0, (LPARAM)TEXT("128")); SendMessage(hwndAudioBitrate, CB_ADDSTRING, 0, (LPARAM)TEXT("160")); SendMessage(hwndAudioBitrate, CB_ADDSTRING, 0, (LPARAM)TEXT("192")); SendMessage(hwndAudioBitrate, CB_ADDSTRING, 0, (LPARAM)TEXT("256")); SendMessage(hwndAudioBitrate, CB_ADDSTRING, 0, (LPARAM)TEXT("320")); }else{ SendMessage(hwndAudioBitrate, CB_ADDSTRING, 0, (LPARAM)TEXT("32")); SendMessage(hwndAudioBitrate, CB_ADDSTRING, 0, (LPARAM)TEXT("40")); SendMessage(hwndAudioBitrate, CB_ADDSTRING, 0, (LPARAM)TEXT("48"));//default SendMessage(hwndAudioBitrate, CB_ADDSTRING, 0, (LPARAM)TEXT("56")); SendMessage(hwndAudioBitrate, CB_ADDSTRING, 0, (LPARAM)TEXT("64")); SendMessage(hwndAudioBitrate, CB_ADDSTRING, 0, (LPARAM)TEXT("80")); SendMessage(hwndAudioBitrate, CB_ADDSTRING, 0, (LPARAM)TEXT("96")); SendMessage(hwndAudioBitrate, CB_ADDSTRING, 0, (LPARAM)TEXT("128")); SendMessage(hwndAudioBitrate, CB_ADDSTRING, 0, (LPARAM)TEXT("160")); } SendMessage(hwndAudioBitrate, CB_SETCURSEL, isStereo ? 3 : 2, 0); bDataChanged = true; } break; case IDC_AUDIOCODEC: if(HIWORD(wParam) == CBN_SELCHANGE) { HWND hwndAudioFormat = GetDlgItem(hwnd, IDC_AUDIOFORMAT); SendMessage(hwndAudioFormat, CB_RESETCONTENT, 0, 0); BOOL isAAC = SendMessage(GetDlgItem(hwnd, IDC_AUDIOCODEC), CB_GETCURSEL, 0, 0) == 1; if (isAAC){ SendMessage(hwndAudioFormat, CB_ADDSTRING, 0, (LPARAM)TEXT("44.1kHz")); SendMessage(hwndAudioFormat, CB_ADDSTRING, 0, (LPARAM)TEXT("48kHz")); }else{ SendMessage(hwndAudioFormat, CB_ADDSTRING, 0, (LPARAM)TEXT("44.1kHz")); } SendMessage(hwndAudioFormat, CB_SETCURSEL, isAAC ? 1 : 0, 0); bDataChanged = true; } break; case IDC_MAXBITRATE: if(HIWORD(wParam) == EN_CHANGE) { bool bCustomBuffer = SendMessage(GetDlgItem(hwnd, IDC_CUSTOMBUFFER), BM_GETCHECK, 0, 0) == BST_CHECKED; if (!bCustomBuffer) { String strText = GetEditText((HWND)lParam); SetWindowText(GetDlgItem(hwnd, IDC_BUFFERSIZE), strText); } bDataChanged = true; } break; case IDC_BUFFERSIZE: if(HIWORD(wParam) == EN_CHANGE) bDataChanged = true; break; case IDC_ENCODERX264: case IDC_ENCODERQSV: case IDC_ENCODERNVENC: if (HIWORD(wParam) == BN_CLICKED) bDataChanged = true; EnableWindow(GetDlgItem(hwnd, IDC_QUALITY), !useCBR && (usex264 || useNVENC)); EnableWindow(GetDlgItem(hwnd, IDC_PADCBR), useCBR && usex264); break; case IDC_CUSTOMBUFFER: case IDC_USECBR: case IDC_PADCBR: if (HIWORD(wParam) == BN_CLICKED) { bool bChecked = SendMessage((HWND)lParam, BM_GETCHECK, 0, 0) == BST_CHECKED; if(LOWORD(wParam) == IDC_CUSTOMBUFFER) EnableWindow(GetDlgItem(hwnd, IDC_BUFFERSIZE), bChecked); else if(LOWORD(wParam) == IDC_USECBR) { EnableWindow(GetDlgItem(hwnd, IDC_QUALITY), !bChecked && (usex264 || useNVENC)); EnableWindow(GetDlgItem(hwnd, IDC_PADCBR), bChecked && usex264); } bDataChanged = true; } break; } if(bDataChanged) { ShowWindow(GetDlgItem(hwnd, IDC_INFO), SW_SHOW); SetChangedSettings(true); } break; } } return FALSE; }
const string & XMLElement :: AttrName( unsigned int i ) const { if ( i >= AttrCount() ) { ATHROW( "Attribute index " << SQuote( Str(i) ) << " out of range" ); } return mAttrs[i].mName; }
static void pv_export_usage(CSOUND *csound) { csound->Message(csound, Str("Usage: pv_export pv_file cstext_file\n")); }
CTSTR GetPluginName() { return Str("Plugins.NoiseGate.PluginName"); }
std::string VaryingPacking::BuiltinVarying::str() const { return (systemValue ? semantic : (semantic + Str(index))); }
void ProcessReader::Abort() { AddMessage(m_process.GetProcessId(), Str(m_process.GetName()).c_str(), "<process terminated>"); PassiveLogSource::Abort(); }
static int pvlook(CSOUND *csound, int argc, char *argv[]) { int i, j, k; int fp; FILE *outfd = stdout; float *frames; int numframes, framesize; unsigned int firstBin, lastBin, numBins, lastFrame; int firstFrame = 1; int nchnls; PVOCDATA data; WAVEFORMATEX fmt; PVLOOK p; p.csound = csound; p.outfd = outfd; p.linePos = 0; p.printInts = 0; { int tmp = 0; csound->SetConfigurationVariable(csound, "msg_color", (void*) &tmp); } if (argc < 2) { for (i = 0; pvlook_usage_txt[i] != NULL; i++) csound->Message(csound, "%s\n", Str(pvlook_usage_txt[i])); return -1; } if ((fp = csound->PVOC_OpenFile(csound, argv[argc - 1], &data, &fmt)) < 0) { csound->ErrorMsg(csound, Str("pvlook: Unable to open '%s'\n Does it exist?"), argv[argc - 1]); return -1; } nchnls = fmt.nChannels; firstFrame = firstBin = 1; lastFrame = UINT_MAX; lastBin = data.nAnalysisBins; for (i = 1; i < argc; i++) { if (!strcmp(argv[i], "-bb")) firstBin = atoi(argv[++i]); if (!strcmp(argv[i], "-eb")) lastBin = atoi(argv[++i]); if (!strcmp(argv[i], "-bf")) firstFrame = atoi(argv[++i]); if (!strcmp(argv[i], "-ef")) lastFrame = atoi(argv[++i]); if (!strcmp(argv[i], "-i")) p.printInts = 1; } if (firstBin < 1U) firstBin = 1U; if (lastBin > (unsigned int) data.nAnalysisBins) lastBin = (unsigned int) data.nAnalysisBins; numBins = (lastBin - firstBin) + 1; if (firstFrame < 1) firstFrame = 1; numframes = (int) csound->PVOC_FrameCount(csound, fp); if (lastFrame > (unsigned int) numframes) lastFrame = (unsigned int) numframes; numframes = (lastFrame - firstFrame) + 1; pvlook_print(&p, "; File name\t%s\n", argv[argc - 1]); pvlook_print(&p, "; Channels\t%d\n", nchnls); pvlook_print(&p, "; Word Format\t%s\n", data.wWordFormat == PVOC_IEEE_FLOAT ? "float" : "double"); pvlook_print(&p, "; Frame Type\t%s\n", data.wAnalFormat == PVOC_AMP_FREQ ? "Amplitude/Frequency" : data.wAnalFormat == PVOC_AMP_PHASE ? "Amplitude/Phase" : "Complex"); switch (data.wSourceFormat) { case 1: /* WAVE_FORMAT_PCM */ pvlook_print(&p, "; Source format\t%dbit\n", (int) fmt.wBitsPerSample); break; default: pvlook_print(&p, "; Source format\tfloat\n"); break; } pvlook_print(&p, "; Window Type\t%s", data.wWindowType == PVOC_DEFAULT ? "Default" : data.wWindowType == PVOC_HAMMING ? "Hamming" : data.wWindowType == PVOC_HANN ? "vonHann" : data.wWindowType == PVOC_KAISER ? "Kaiser" : data.wWindowType == PVOC_RECT ? "Rectangular" : "Custom"); if (data.wWindowType == PVOC_KAISER) pvlook_print(&p, "(%f)", data.fWindowParam); pvlook_print(&p, "\n; FFT Size\t%d\n", (int) (data.nAnalysisBins - 1) * 2); pvlook_print(&p, "; Window length\t%d\n", (int) data.dwWinlen); pvlook_print(&p, "; Overlap\t%d\n", (int) data.dwOverlap); pvlook_print(&p, "; Frame align\t%d\n", (int) data.dwFrameAlign); pvlook_print(&p, "; Analysis Rate\t%f\n", data.fAnalysisRate); if (numBins > 0U && numframes > 0) { /* pvlook_print(&p, "; Bins in Analysis: %d\n", (int) data.nAnalysisBins); */ pvlook_print(&p, "; First Bin Shown: %d\n", (int) firstBin); pvlook_print(&p, "; Number of Bins Shown: %d\n", (int) numBins); /* pvlook_print(&p, "; Frames in Analysis: %ld\n", (long) csound->PVOC_FrameCount(csound, fp)); */ pvlook_print(&p, "; First Frame Shown: %d\n", (int) firstFrame); pvlook_print(&p, "; Number of Data Frames Shown: %d\n", (int) numframes); framesize = data.nAnalysisBins * 2 * sizeof(float); frames = (float*) csound->Malloc(csound, framesize * numframes); for (j = 1; j < firstFrame; j++) csound->PVOC_GetFrames(csound, fp, frames, 1); /* Skip */ csound->PVOC_GetFrames(csound, fp, frames, numframes); for (k = (firstBin - 1); k < (int) lastBin; k++) { pvlook_print(&p, "\nBin %d Freqs.\n", k + 1); for (j = 0; j < numframes; j++) { pvlook_printvalue(&p, frames[((j * data.nAnalysisBins) + k) * 2 + 1]); } if (p.linePos != 0) pvlook_print(&p, "\n"); pvlook_print(&p, "\nBin %d Amps.\n", k + 1); for (j = 0; j < numframes; j++) { if (!p.printInts) pvlook_printvalue(&p, frames[((j * data.nAnalysisBins) + k) * 2]); else pvlook_printvalue(&p, frames[((j * data.nAnalysisBins) + k) * 2] * (float) csound->Get0dBFS(csound)); } if (p.linePos != 0) pvlook_print(&p, "\n"); } csound->Free(csound, frames); } pvlook_print(&p, "\n"); csound->PVOC_CloseFile(csound, fp); if (outfd != stdout) fclose(outfd); return 0; }
static JSBool JO(JSContext *cx, jsval *vp, StringifyContext *scx) { JSObject *obj = JSVAL_TO_OBJECT(*vp); if (!scx->cb.append('{')) return JS_FALSE; jsval vec[3] = {JSVAL_NULL, JSVAL_NULL, JSVAL_NULL}; JSAutoTempValueRooter tvr(cx, 3, vec); jsval& key = vec[0]; jsval& outputValue = vec[1]; JSObject *iterObj = NULL; jsval *keySource = vp; bool usingWhitelist = false; // if the replacer is an array, we use the keys from it if (scx->replacer && JS_IsArrayObject(cx, scx->replacer)) { usingWhitelist = true; vec[2] = OBJECT_TO_JSVAL(scx->replacer); keySource = &vec[2]; } if (!js_ValueToIterator(cx, JSITER_ENUMERATE, keySource)) return JS_FALSE; iterObj = JSVAL_TO_OBJECT(*keySource); JSBool memberWritten = JS_FALSE; bool ok = false; while (true) { outputValue = JSVAL_VOID; if (!js_CallIteratorNext(cx, iterObj, &key)) goto error_break; if (key == JSVAL_HOLE) break; jsuint index = 0; if (usingWhitelist) { // skip non-index properties if (!js_IdIsIndex(key, &index)) continue; jsval newKey; if (!scx->replacer->getProperty(cx, key, &newKey)) goto error_break; key = newKey; } JSString *ks; if (JSVAL_IS_STRING(key)) { ks = JSVAL_TO_STRING(key); } else { ks = js_ValueToString(cx, key); if (!ks) goto error_break; } JSAutoTempValueRooter keyStringRoot(cx, ks); // Don't include prototype properties, since this operation is // supposed to be implemented as if by ES3.1 Object.keys() jsid id; jsval v = JS_FALSE; if (!js_ValueToStringId(cx, STRING_TO_JSVAL(ks), &id) || !js_HasOwnProperty(cx, obj->map->ops->lookupProperty, obj, id, &v)) { goto error_break; } if (v != JSVAL_TRUE) continue; if (!JS_GetPropertyById(cx, obj, id, &outputValue)) goto error_break; if (JSVAL_IS_OBJECT(outputValue) && !js_TryJSON(cx, &outputValue)) goto error_break; // call this here, so we don't write out keys if the replacer function // wants to elide the value. if (!CallReplacerFunction(cx, id, obj, scx, &outputValue)) goto error_break; JSType type = JS_TypeOfValue(cx, outputValue); // elide undefined values and functions and XML if (outputValue == JSVAL_VOID || type == JSTYPE_FUNCTION || type == JSTYPE_XML) continue; // output a comma unless this is the first member to write if (memberWritten && !scx->cb.append(',')) goto error_break; memberWritten = JS_TRUE; if (!WriteIndent(cx, scx, scx->depth)) goto error_break; // Be careful below, this string is weakly rooted JSString *s = js_ValueToString(cx, key); if (!s) goto error_break; const jschar *chars; size_t length; s->getCharsAndLength(chars, length); if (!write_string(cx, scx->cb, chars, length) || !scx->cb.append(':') || !Str(cx, id, obj, scx, &outputValue, false)) { goto error_break; } } ok = true; error_break: if (iterObj) { // Always close the iterator, but make sure not to stomp on OK JS_ASSERT(OBJECT_TO_JSVAL(iterObj) == *keySource); ok &= js_CloseIterator(cx, *keySource); } if (!ok) return JS_FALSE; if (memberWritten && !WriteIndent(cx, scx, scx->depth - 1)) return JS_FALSE; return scx->cb.append('}'); }
DWORD WINAPI RTMPPublisher::CreateConnectionThread(RTMPPublisher *publisher) { //------------------------------------------------------ // set up URL bool bRetry = false; bool bSuccess = false; bool bCanRetry = false; String failReason; String strBindIP; int serviceID = AppConfig->GetInt (TEXT("Publish"), TEXT("Service")); String strURL = AppConfig->GetString(TEXT("Publish"), TEXT("URL")); String strPlayPath = AppConfig->GetString(TEXT("Publish"), TEXT("PlayPath")); strURL.KillSpaces(); strPlayPath.KillSpaces(); LPSTR lpAnsiURL = NULL, lpAnsiPlaypath = NULL; RTMP *rtmp = NULL; //-------------------------------- // unbelievably disgusting hack for elgato devices String strOldDirectory; UINT dirSize = GetCurrentDirectory(0, 0); strOldDirectory.SetLength(dirSize); GetCurrentDirectory(dirSize, strOldDirectory.Array()); OSSetCurrentDirectory(API->GetAppPath()); //-------------------------------- if(!strURL.IsValid()) { failReason = TEXT("No server specified to connect to"); goto end; } if(serviceID != 0) { XConfig serverData; if(!serverData.Open(TEXT("services.xconfig"))) { failReason = TEXT("Could not open services.xconfig"); goto end; } XElement *services = serverData.GetElement(TEXT("services")); if(!services) { failReason = TEXT("Could not any services in services.xconfig"); goto end; } XElement *service = NULL; DWORD numServices = services->NumElements(); for(UINT i=0; i<numServices; i++) { XElement *curService = services->GetElementByID(i); if(curService->GetInt(TEXT("id")) == serviceID) { service = curService; break; } } if(!service) { failReason = TEXT("Could not find the service specified in services.xconfig"); goto end; } XElement *servers = service->GetElement(TEXT("servers")); if(!servers) { failReason = TEXT("Could not find any servers for the service specified in services.xconfig"); goto end; } XDataItem *item = servers->GetDataItem(strURL); if(!item) item = servers->GetDataItemByID(0); strURL = item->GetData(); Log(TEXT("Using RTMP service: %s"), service->GetName()); Log(TEXT(" Server selection: %s"), strURL.Array()); } //------------------------------------------------------ // now back to the elgato directory if it needs the directory changed still to function *sigh* OSSetCurrentDirectory(strOldDirectory); //------------------------------------------------------ rtmp = RTMP_Alloc(); RTMP_Init(rtmp); RTMP_LogSetCallback(librtmpErrorCallback); //RTMP_LogSetLevel(RTMP_LOGERROR); lpAnsiURL = strURL.CreateUTF8String(); lpAnsiPlaypath = strPlayPath.CreateUTF8String(); if(!RTMP_SetupURL2(rtmp, lpAnsiURL, lpAnsiPlaypath)) { failReason = Str("Connection.CouldNotParseURL"); goto end; } char *rtmpUser = AppConfig->GetString(TEXT("Publish"), TEXT("Username")).CreateUTF8String(); char *rtmpPass = AppConfig->GetString(TEXT("Publish"), TEXT("Password")).CreateUTF8String(); if (rtmpUser) { rtmp->Link.pubUser.av_val = rtmpUser; rtmp->Link.pubUser.av_len = (int)strlen(rtmpUser); } if (rtmpPass) { rtmp->Link.pubPasswd.av_val = rtmpPass; rtmp->Link.pubPasswd.av_len = (int)strlen(rtmpPass); } RTMP_EnableWrite(rtmp); //set it to publish /*rtmp->Link.swfUrl.av_len = rtmp->Link.tcUrl.av_len; rtmp->Link.swfUrl.av_val = rtmp->Link.tcUrl.av_val; rtmp->Link.pageUrl.av_len = rtmp->Link.tcUrl.av_len; rtmp->Link.pageUrl.av_val = rtmp->Link.tcUrl.av_val;*/ rtmp->Link.flashVer.av_val = "FMLE/3.0 (compatible; FMSc/1.0)"; rtmp->Link.flashVer.av_len = (int)strlen(rtmp->Link.flashVer.av_val); //----------------------------------------- UINT tcpBufferSize = AppConfig->GetInt(TEXT("Publish"), TEXT("TCPBufferSize"), 64*1024); if(tcpBufferSize < 8192) tcpBufferSize = 8192; else if(tcpBufferSize > 1024*1024) tcpBufferSize = 1024*1024; rtmp->m_outChunkSize = 4096;//RTMP_DEFAULT_CHUNKSIZE;// rtmp->m_bSendChunkSizeInfo = TRUE; rtmp->m_bUseNagle = TRUE; strBindIP = AppConfig->GetString(TEXT("Publish"), TEXT("BindToIP"), TEXT("Default")); if (scmp(strBindIP, TEXT("Default"))) { rtmp->m_bindIP.addr.sin_family = AF_INET; rtmp->m_bindIP.addrLen = sizeof(rtmp->m_bindIP.addr); if (WSAStringToAddress(strBindIP.Array(), AF_INET, NULL, (LPSOCKADDR)&rtmp->m_bindIP.addr, &rtmp->m_bindIP.addrLen) == SOCKET_ERROR) { // no localization since this should rarely/never happen failReason = TEXT("WSAStringToAddress: Could not parse address"); goto end; } } LogInterfaceType(rtmp); //----------------------------------------- if(!RTMP_Connect(rtmp, NULL)) { failReason = Str("Connection.CouldNotConnect"); failReason << TEXT("\r\n\r\n") << RTMPPublisher::GetRTMPErrors(); bCanRetry = true; goto end; } if(!RTMP_ConnectStream(rtmp, 0)) { failReason = Str("Connection.InvalidStream"); failReason << TEXT("\r\n\r\n") << RTMPPublisher::GetRTMPErrors(); bCanRetry = true; goto end; } //----------------------------------------- OSDebugOut(TEXT("Connected: %u\r\n"), OSGetTime()); publisher->RequestKeyframe(1000); //----------------------------------------- bSuccess = true; end: if (lpAnsiURL) Free(lpAnsiURL); if (lpAnsiPlaypath) Free(lpAnsiPlaypath); if(!bSuccess) { if(rtmp) { RTMP_Close(rtmp); RTMP_Free(rtmp); } if(failReason.IsValid()) App->SetStreamReport(failReason); if(!publisher->bStopping) PostMessage(hwndMain, OBS_REQUESTSTOP, bCanRetry ? 0 : 1, 0); Log(TEXT("Connection to %s failed: %s"), strURL.Array(), failReason.Array()); publisher->bStopping = true; } else { publisher->Init(rtmp, tcpBufferSize); publisher->bConnected = true; publisher->bConnecting = false; } return 0; }
bool CLogView::FindPrevious(const std::wstring& text) { return Find(Str(text).str(), -1); }
bool CLogView::FindNext(const std::wstring& text) { return Find(Str(text).str(), +1); }
int32_t fftset(CSOUND *csound, DSPFFT *p) /* fftset, dspfft -- calc Fast Fourier */ /* Transform of collected samples and */ /* displays coefficients (mag or db) */ { int32_t window_size, step_size; int32_t hanning; char strmsg[256]; int32_t minbin, maxbin; minbin = *p->imin; maxbin = *p->imax; if (p->smpbuf.auxp == NULL) csound->AuxAlloc(csound, sizeof(MYFLT)*WINDMAX, &(p->smpbuf)); p->sampbuf = (MYFLT *) p->smpbuf.auxp; window_size = (int32_t)*p->inpts; if (UNLIKELY(window_size > WINDMAX)) { return csound->InitError(csound, Str("too many points requested")); } if (UNLIKELY(window_size < WINDMIN)) { return csound->InitError(csound, Str("too few points requested")); } if (UNLIKELY(window_size < 1L || (window_size & (window_size - 1L)) != 0L)) { return csound->InitError(csound, Str("window size must be power of two")); } if (p->h.optext->t.intype == 'k') step_size = (int32_t)(*p->iprd * CS_EKR); else step_size = (int32_t)(*p->iprd * csound->esr); if (UNLIKELY(step_size <= 0)) { return csound->InitError(csound, Str("illegal iprd in ffy display")); } hanning = (int32_t)*p->ihann; p->dbout = (int32_t)*p->idbout; p->overlap = window_size - step_size; if ( (maxbin - minbin) != p->npts || minbin != p->start || window_size != p->windsize || hanning != p->hanning) { /* if windowing has changed: */ int32_t auxsiz; MYFLT *hWin; p->windsize = window_size; /* set new parameter values */ p->hanning = hanning; p->bufp = p->sampbuf; p->endp = p->bufp + window_size; p->overN = FL(1.0)/(*p->inpts); p->ncoefs = window_size >>1; auxsiz = (window_size/2 + 1) * sizeof(MYFLT); /* size for half window */ csound->AuxAlloc(csound, (int32_t)auxsiz, &p->auxch); /* alloc or realloc */ hWin = (MYFLT *) p->auxch.auxp; FillHalfWin(hWin, window_size, FL(1.0), hanning); /* fill with proper values */ if (csound->disprep_fftcoefs == NULL) { /* room for WINDMAX*2 floats (fft size) */ csound->disprep_fftcoefs = (MYFLT*) csound->Malloc(csound, WINDMAX * 2 * sizeof(MYFLT)); } snprintf(strmsg, 256, Str("instr %d, signal %s, fft (%s):"), (int32_t) p->h.insdshead->p1.value, p->h.optext->t.inlist->arg[0], p->dbout ? Str("db") : Str("mag")); if (maxbin == 0) maxbin = p->ncoefs; if (minbin > maxbin) minbin = 0; p->npts = maxbin - minbin; p->start = minbin; dispset(csound, &p->dwindow, csound->disprep_fftcoefs+p->start, p->npts, strmsg, (int32_t) *p->iwtflg, Str("fft")); }
void Init(CommandSenderPtr cmdSend, CommandQueuePtr cmdRecv) { this->cmdSend = cmdSend; this->cmdRecv = cmdRecv; recvThread = std::make_shared<std::thread>([&](){ RecvThread(); }); thread = std::make_shared<std::thread>([&](){ std::string line; std::map<std::string, CommandType> cmdStrs = { {"quit", CTQuit}, {"play", CTPlay}, {"pause", CTPause}, {"stop", CTStop}, {"seek", CTSeek}, {"load", CTLoad}, {"unload", CTUnload}, {"update-output-size", CTUpdateOutputSize}, {"force-redraw", CTForceRedraw}, {"set-playback-speed", CTSetPlaybackSpeed}, {"set-volume", CTSetVolume}, {"set-mute", CTSetMute}, {"set-qv-mute", CTSetQvMute}, {"get-bitmap", CTGetBitmap}, {"get-dimensions", CTGetDimensions}, }; while(!done){ std::cout << "> "; getline(std::cin, line); std::cout << line << std::endl; try { StrVec cmds = StringTools::Split(line, ' '); if(cmds.size() == 0) throw std::runtime_error("expected command"); if(cmds[0] == "show-messages"){ if(cmds.size() != 2) throw std::runtime_error("command expects true/false"); showMessages = cmds[1] == "true"; } else if(cmds[0] == "seek-through"){ std::vector<float> positions = {1.0f, 3.0f, 10.0f, 20.0f, 23.0f, 23.5f, 30.0f, 70.0f}; for(auto pos : positions){ cmdSend->SendCommand(NO_SEQ_NUM, 0, CTSeek, pos); SDL_Delay(500); } } else { auto it = cmdStrs.find(cmds[0]); if(it == cmdStrs.end()) throw std::runtime_error(Str("no such command: " << cmds[0])); Command cmd; cmd.type = it->second; cmd.seqNum = NO_SEQ_NUM; unsigned argsSize = CommandSpecs[cmd.type].requestArgTypes.size(); if(cmds.size() - 1 != argsSize) throw std::runtime_error(Str(cmds[0] << " expects " << argsSize << " args (not " << cmds.size() - 1 << ")")); if(cmd.type == CTQuit) done = true; int i = 1; for(ArgumentType aType : CommandSpecs[cmd.type].requestArgTypes){ Argument arg; arg.type = aType; switch(aType){ case ATStr: arg.str = Tools::StrToWstr(cmds[i]); break; case ATInt32: arg.i = atoi(cmds[i].c_str()); break; case ATFloat: arg.f = atof(cmds[i].c_str()); break; case ATDouble: arg.d = atof(cmds[i].c_str()); break; case ATBuffer: FlogE("can't send a buffer from command line"); break; } cmd.args.push_back(arg); i++; } cmdSend->SendCommand(cmd); } } catch (std::runtime_error e) { std::cerr << "error: " << e.what() << std::endl; } } // wait for a bit to receieve any commands the player might still want to send std::this_thread::sleep_for(std::chrono::milliseconds(1000)); }); }
int table_mix(CSOUND *csound, TABLMIX *p) { int32 np2, np21, np22; FUNC *ftp, *ftp1, *ftp2; int32 len, len1, len2, flen; MYFLT g1, g2, *func, *func1, *func2; int32 off, off1, off2; if (UNLIKELY((ftp = csound->FTnp2Find(csound, p->tab)) == NULL)) { csound->Warning(csound, Str("table: could not find ftable %d"), (int) *p->tab); return NOTOK; } np2 = ftp->lenmask ? 0 : 1; if (UNLIKELY((ftp1 = csound->FTnp2Find(csound, p->tab1)) == NULL)) { csound->Warning(csound, Str("table: could not find ftable %d"), (int) *p->tab1); return NOTOK; } np21 = ftp1->lenmask ? 0 : 1; if (UNLIKELY((ftp2 = csound->FTnp2Find(csound, p->tab2)) == NULL)) { csound->Warning(csound, Str("table: could not find ftable %d"), (int) *p->tab2); return NOTOK; } np22 = ftp2->lenmask ? 0 : 1; len = MYFLOOR(*p->len); flen = ftp->flen; len1 = ftp1->flen; len2 = ftp2->flen; func = ftp->ftable; func1 = ftp1->ftable; func2 = ftp2->ftable; off = *p->off; off1 = *p->off1; off2 = *p->off2; g1 = *p->g1; g2 = *p->g2; if (len>0) { int i, p0, p1, p2; for (i=0; i < len; i++) { p0 = i+off; p1 = i+off1; p2 = i+off2; if (np2) { while(p0 < 0) p0 += flen; while(p0 >= len1) p0 -= flen; } else p0 &= ftp->lenmask; if (np21) { while(p1 < 0) p1 += len1; while(p1 >= len1) p1 -= len1; } else p1 &= ftp1->lenmask; if (np22) { while(p2 < 0) p2 += len2; while(p2 >= len2) p1 -= len2; } else p2 &= ftp2->lenmask; func[p0] = func1[p1]*g1 + func2[p2]*g2; } } else { int i, p0, p1, p2; for (i=0; i > len; i--) { p0 = i+off; p1 = i+off1; p2 = i+off2; if (np2) { while(p0 < 0) p0 += flen; while(p0 >= len1) p0 -= flen; } else p0 &= ftp->lenmask; if (np21) { while(p1 < 0) p1 += len1; while(p1 >= len1) p1 -= len1; } else p1 &= ftp1->lenmask; if (np22) { while(p2 < 0) p2 += len2; while(p2 >= len2) p2 -= len2; } else p2 &= ftp2->lenmask; func[p0] = func1[p1]*g1 + func2[p2]*g2; } } return OK; }
CTSTR NoiseGateSettings::GetCategory() const { static CTSTR name = Str("Plugins.NoiseGate.PluginName"); return name; }
INT_PTR CALLBACK OBS::SettingsDialogProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { switch(message) { case WM_INITDIALOG: { App->hwndSettings = hwnd; LocalizeWindow(hwnd); // Add setting categories from the pane list for(unsigned int i = 0; i < App->settingsPanes.Num(); i++) { SettingsPane *pane = App->settingsPanes[i]; if(pane == NULL) continue; SendMessage(GetDlgItem(hwnd, IDC_SETTINGSLIST), LB_ADDSTRING, 0, (LPARAM)pane->GetCategory()); } RECT subDialogRect; GetWindowRect(GetDlgItem(hwnd, IDC_SUBDIALOG), &subDialogRect); MapWindowPoints(HWND_DESKTOP, hwnd, (LPPOINT)&subDialogRect, 2); SendMessage(GetDlgItem(hwnd, IDC_SETTINGSLIST), LB_SETCURSEL, 0, 0); // Load the first settings pane from the list App->curSettingsSelection = 0; App->hwndCurrentSettings = NULL; App->currentSettingsPane = NULL; if(App->settingsPanes.Num() >= 1) App->currentSettingsPane = App->settingsPanes[0]; if(App->currentSettingsPane != NULL) App->hwndCurrentSettings = App->currentSettingsPane->CreatePane(hwnd); if(App->hwndCurrentSettings != NULL) { SetWindowPos(App->hwndCurrentSettings, NULL, subDialogRect.left, subDialogRect.top, subDialogRect.right - subDialogRect.left, subDialogRect.bottom - subDialogRect.top, SWP_NOZORDER); ShowWindow(App->hwndCurrentSettings, SW_SHOW); ShowWindow(GetDlgItem(hwnd, IDC_DEFAULTS), App->currentSettingsPane->HasDefaults()); ShowWindow(GetDlgItem(hwnd, IDC_OPTIMIZE), false); } return TRUE; } case WM_DRAWITEM: PDRAWITEMSTRUCT pdis; pdis = (PDRAWITEMSTRUCT) lParam; if(pdis->CtlID != IDC_SETTINGSLIST || pdis->itemID == -1) break; switch(pdis->itemAction) { case ODA_SELECT: case ODA_DRAWENTIRE: { int cy, bkMode; TEXTMETRIC tm; COLORREF oldTextColor; TCHAR itemText[MAX_PATH]; oldTextColor = GetTextColor(pdis->hDC); if(pdis->itemState & ODS_SELECTED) { FillRect(pdis->hDC, &pdis->rcItem, (HBRUSH)(COLOR_HIGHLIGHT + 1)); SetTextColor(pdis->hDC, GetSysColor(COLOR_HIGHLIGHTTEXT)); } else { FillRect(pdis->hDC, &pdis->rcItem, (HBRUSH)(COLOR_WINDOW + 1)); SetTextColor(pdis->hDC, GetSysColor(COLOR_WINDOWTEXT)); } SendMessage(pdis->hwndItem, LB_GETTEXT, pdis->itemID, (LPARAM)itemText); GetTextMetrics(pdis->hDC, &tm); cy = (pdis->rcItem.bottom + pdis->rcItem.top - tm.tmHeight) / 2; bkMode = SetBkMode(pdis->hDC, TRANSPARENT); if(slen(itemText) > 0) TextOut(pdis->hDC, 6, cy, itemText, slen(itemText)); SetBkMode(pdis->hDC, bkMode); SetTextColor(pdis->hDC, oldTextColor); UINT builtinAndEncoderPanes = App->numberOfBuiltInSettingsPanes + App->numberOfEncoderSettingsPanes; if ((App->settingsPanes.Num() > (UINT)App->numberOfBuiltInSettingsPanes && pdis->itemID == App->numberOfBuiltInSettingsPanes) || (App->settingsPanes.Num() > (UINT)builtinAndEncoderPanes && pdis->itemID == builtinAndEncoderPanes)) { HGDIOBJ origPen; origPen = SelectObject(pdis->hDC, GetStockObject(DC_PEN)); SetDCPenColor(pdis->hDC, GetSysColor(COLOR_BTNSHADOW)); MoveToEx(pdis->hDC, pdis->rcItem.left, pdis->rcItem.top, NULL); LineTo(pdis->hDC, pdis->rcItem.right, pdis->rcItem.top); SelectObject(pdis->hDC, origPen); } break; } case ODA_FOCUS: break; } break; case WM_COMMAND: switch(LOWORD(wParam)) { case IDC_SETTINGSLIST: { if(HIWORD(wParam) != LBN_SELCHANGE) break; int sel = (int)SendMessage((HWND)lParam, LB_GETCURSEL, 0, 0); // No need to continue if we're on the same panel if(sel == App->curSettingsSelection) break; if(App->bSettingsChanged) { int id = OBSMessageBox(hwnd, Str("Settings.SaveChangesPrompt"), Str("Settings.SaveChangesTitle"), MB_YESNOCANCEL); if (id == IDNO) App->CancelSettings(); if(id == IDCANCEL) { SendMessage((HWND)lParam, LB_SETCURSEL, App->curSettingsSelection, 0); break; } else if(id == IDYES) App->ApplySettings(); } App->curSettingsSelection = sel; if(App->currentSettingsPane != NULL) App->currentSettingsPane->DestroyPane(); App->currentSettingsPane = NULL; App->hwndCurrentSettings = NULL; ShowWindow(GetDlgItem(hwnd, IDC_OPTIMIZE), false); RECT subDialogRect; GetWindowRect(GetDlgItem(hwnd, IDC_SUBDIALOG), &subDialogRect); MapWindowPoints(HWND_DESKTOP, hwnd, (LPPOINT)&subDialogRect, 2); if(sel >= 0 && sel < (int)App->settingsPanes.Num()) App->currentSettingsPane = App->settingsPanes[sel]; if(App->currentSettingsPane != NULL) App->hwndCurrentSettings = App->currentSettingsPane->CreatePane(hwnd); if(App->hwndCurrentSettings) { SetWindowPos(App->hwndCurrentSettings, NULL, subDialogRect.left, subDialogRect.top, subDialogRect.right - subDialogRect.left, subDialogRect.bottom - subDialogRect.top, SWP_NOZORDER); ShowWindow(App->hwndCurrentSettings, SW_SHOW); ShowWindow(GetDlgItem(hwnd, IDC_DEFAULTS), App->currentSettingsPane->HasDefaults()); SetFocus(GetDlgItem(hwnd, IDC_SETTINGSLIST)); } break; } case IDC_DEFAULTS: App->currentSettingsPane->SetDefaults(); break; case IDOK: if(App->bSettingsChanged) App->ApplySettings(); if (App->bApplySettingsAborted) break; EndDialog(hwnd, IDOK); App->hwndSettings = NULL; break; case IDCANCEL: if(App->bSettingsChanged) App->CancelSettings(); EndDialog(hwnd, IDCANCEL); App->hwndSettings = NULL; break; case IDC_APPLY: if(App->bSettingsChanged) App->ApplySettings(); break; case IDC_OPTIMIZE: App->OptimizeSettings(); break; } break; } return FALSE; }
CTSTR GetPluginDescription() { return Str("Plugins.NoiseGate.PluginDescription"); }
static CS_NOINLINE void notImplementedWarning_(const char *name) { #ifndef __EMSCRIPTEN__ fprintf(stderr, Str("%s() is not implemented on this platform.\n"), name); #endif }
void OBS::EncodeLoop() { QWORD streamTimeStart = GetQPCTimeNS(); QWORD frameTimeNS = 1000000000/fps; bool bufferedFrames = true; //to avoid constantly polling number of frames int numTotalDuplicatedFrames = 0, numTotalFrames = 0, numFramesSkipped = 0; bufferedTimes.Clear(); bool bUsingQSV = videoEncoder->isQSV();//GlobalConfig->GetInt(TEXT("Video Encoding"), TEXT("UseQSV")) != 0; QWORD sleepTargetTime = streamTimeStart+frameTimeNS; latestVideoTime = firstSceneTimestamp = streamTimeStart/1000000; latestVideoTimeNS = streamTimeStart; firstFrameTimestamp = 0; UINT encoderInfo = 0; QWORD messageTime = 0; EncoderPicture *lastPic = NULL; UINT skipThreshold = encoderSkipThreshold*2; UINT no_sleep_counter = 0; CircularList<QWORD> bufferedTimes; while(!bShutdownEncodeThread || (bufferedFrames && !bTestStream)) { if (!SleepToNS(sleepTargetTime += (frameTimeNS/2))) no_sleep_counter++; else no_sleep_counter = 0; latestVideoTime = sleepTargetTime/1000000; latestVideoTimeNS = sleepTargetTime; if (no_sleep_counter < skipThreshold) { SetEvent(hVideoEvent); if (encoderInfo) { if (messageTime == 0) { messageTime = latestVideoTime+3000; } else if (latestVideoTime >= messageTime) { RemoveStreamInfo(encoderInfo); encoderInfo = 0; messageTime = 0; } } } else { numFramesSkipped++; if (!encoderInfo) encoderInfo = AddStreamInfo(Str("EncoderLag"), StreamInfoPriority_Critical); messageTime = 0; } if (!SleepToNS(sleepTargetTime += (frameTimeNS/2))) no_sleep_counter++; else no_sleep_counter = 0; bufferedTimes << latestVideoTime; if (curFramePic && firstFrameTimestamp) { while (bufferedTimes[0] < firstFrameTimestamp) bufferedTimes.Remove(0); DWORD curFrameTimestamp = DWORD(bufferedTimes[0] - firstFrameTimestamp); bufferedTimes.Remove(0); profileIn("encoder thread frame"); FrameProcessInfo frameInfo; frameInfo.firstFrameTime = firstFrameTimestamp; frameInfo.frameTimestamp = curFrameTimestamp; frameInfo.pic = curFramePic; if (lastPic == frameInfo.pic) numTotalDuplicatedFrames++; if(bUsingQSV) curFramePic->mfxOut->Data.TimeStamp = curFrameTimestamp; else curFramePic->picOut->i_pts = curFrameTimestamp; ProcessFrame(frameInfo); if (bShutdownEncodeThread) bufferedFrames = videoEncoder->HasBufferedFrames(); lastPic = frameInfo.pic; profileOut; numTotalFrames++; } } //flush all video frames in the "scene buffering time" buffer if (firstFrameTimestamp && bufferedVideo.Num()) { QWORD startTime = GetQPCTimeMS(); DWORD baseTimestamp = bufferedVideo[0].timestamp; for(UINT i=0; i<bufferedVideo.Num(); i++) { //we measure our own time rather than sleep between frames due to potential sleep drift QWORD curTime; do { curTime = GetQPCTimeMS(); OSSleep (1); } while (curTime - startTime < bufferedVideo[i].timestamp - baseTimestamp); SendFrame(bufferedVideo[i], firstFrameTimestamp); bufferedVideo[i].Clear(); numTotalFrames++; } bufferedVideo.Clear(); } Log(TEXT("Total frames encoded: %d, total frames duplicated: %d (%0.2f%%)"), numTotalFrames, numTotalDuplicatedFrames, (double(numTotalDuplicatedFrames)/double(numTotalFrames))*100.0); if (numFramesSkipped) Log(TEXT("Number of frames skipped due to encoder lag: %d (%0.2f%%)"), numFramesSkipped, (double(numFramesSkipped)/double(numTotalFrames))*100.0); SetEvent(hVideoEvent); bShutdownVideoThread = true; }
int vbap_zak_init(CSOUND *csound, VBAP_ZAK *p) { /* Initializations before run time */ int i, j, indx; MYFLT *ls_table, *ptr; /* , *gains; */ LS_SET *ls_set_ptr; int n = p->n = (int)MYFLT2LONG(*p->numb); /* Set size */ char name[24]; /* Check to see this index is within the limits of za space. */ indx = (int32) *p->ndx; if (UNLIKELY(indx > csound->zalast)) { return csound->PerfError(csound, p->h.insdshead, Str("outz index > isizea. No output")); } else if (UNLIKELY(indx < 0)) { return csound->PerfError(csound, p->h.insdshead, Str("outz index < 0. No output.")); } if ((int)*p->layout==0) strcpy(name, "vbap_ls_table"); else snprintf(name, 24, "vbap_ls_table_%d", (int)*p->layout==0); /* Now read from the array in za space and write to the output. */ p->out_array = csound->zastart + (indx * CS_KSMPS);/* outputs */ csound->AuxAlloc(csound, p->n*sizeof(MYFLT)*4, &p->auxch); p->curr_gains = (MYFLT*)p->auxch.auxp; p->beg_gains = p->curr_gains + p->n; p->end_gains = p->beg_gains + p->n; p->updated_gains = p->end_gains + p->n; ls_table = (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, name)); p->dim = (int) ls_table[0]; /* reading in loudspeaker info */ p->ls_am = (int) ls_table[1]; p->ls_set_am = (int) ls_table[2]; ptr = &(ls_table[3]); csound->AuxAlloc(csound, p->ls_set_am * sizeof (LS_SET), &p->aux); if (UNLIKELY(p->aux.auxp == NULL)) { return csound->InitError(csound, Str("could not allocate memory")); } p->ls_sets = (LS_SET*) p->aux.auxp; ls_set_ptr = p->ls_sets; for (i=0 ; i < p->ls_set_am ; i++) { ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ for (j=0 ; j < p->dim ; j++) { ls_set_ptr[i].ls_nos[j] = (int) *(ptr++); } for (j=0 ; j < 9; j++) ls_set_ptr[i].ls_mx[j] = FL(0.0); /* initial setting */ for (j=0 ; j < (p->dim) * (p->dim); j++) { ls_set_ptr[i].ls_mx[j] = (MYFLT) *(ptr++); } } /* other initialization */ if (UNLIKELY(p->dim == 2 && fabs(*p->ele) > 0.0)) { csound->Warning(csound, Str("Warning: truncating elevation to 2-D plane\n")); *p->ele = FL(0.0); } p->ang_dir.azi = (MYFLT) *p->azi; p->ang_dir.ele = (MYFLT) *p->ele; p->ang_dir.length = FL(1.0); angle_to_cart(p->ang_dir, &(p->cart_dir)); p->spread_base.x = p->cart_dir.y; p->spread_base.y = p->cart_dir.z; p->spread_base.z = -p->cart_dir.x; vbap_zak_control(csound,p); for (i=0;i<n;i++) { p->beg_gains[i] = p->updated_gains[i]; p->end_gains[i] = p->updated_gains[i]; } return OK; }
const XMLNode * XMLElement :: ChildAt( unsigned int i ) const { if ( i >= ChildCount() ) { ATHROW( "Node index " << SQuote(Str(i)) << " out of range" ); } return mKids[i]; }
int vbap_zak_moving_control(CSOUND *csound, VBAP_ZAK_MOVING *p) { CART_VEC spreaddir[16]; CART_VEC spreadbase[16]; ANG_VEC atmp; int32 i,j, spreaddirnum; int n = p->n; CART_VEC tmp1, tmp2, tmp3; MYFLT coeff, angle; MYFLT tmp_gains[MAXCHNLS],sum = FL(0.0); /* Array long enough */ if (UNLIKELY(p->dim == 2 && fabs(p->ang_dir.ele) > 0.0)) { csound->Warning(csound, Str("Warning: truncating elevation to 2-D plane\n")); p->ang_dir.ele = FL(0.0); } if (*p->spread <FL(0.0)) *p->spread = FL(0.0); else if (*p->spread >FL(100.0)) *p->spread = FL(100.0); if (p->point_change_counter++ >= p->point_change_interval) { p->point_change_counter = 0; p->curr_fld = p->next_fld; if (++p->next_fld >= (int) fabs(*p->field_am)) { if (*p->field_am >= FL(0.0)) /* point-to-point */ p->next_fld = 0; else p->next_fld = 1; } if (p->dim == 3) { /* jumping over second field */ p->curr_fld = p->next_fld; if (++p->next_fld >= ((int) fabs(*p->field_am))) { if (*p->field_am >= FL(0.0)) /* point-to-point */ p->next_fld = 0; else p->next_fld = 1; } } if (UNLIKELY((p->fld[abs(p->next_fld)]==NULL))) return csound->PerfError(csound, p->h.insdshead, Str("Missing fields in vbapzmove\n")); if (*p->field_am >= FL(0.0) && p->dim == 2) /* point-to-point */ if (UNLIKELY(fabs(fabs(*p->fld[p->next_fld] - *p->fld[p->curr_fld]) - 180.0) < 1.0)) csound->Warning(csound, Str("Warning: Ambiguous transition 180 degrees.\n")); } if (*p->field_am >= FL(0.0)) { /* point-to-point */ if (p->dim == 3) { /* 3-D */ p->prev_ang_dir.azi = *p->fld[p->curr_fld-1]; p->next_ang_dir.azi = *p->fld[p->next_fld]; p->prev_ang_dir.ele = *p->fld[p->curr_fld]; p->next_ang_dir.ele = *p->fld[p->next_fld+1]; coeff = ((MYFLT) p->point_change_counter) / ((MYFLT) p->point_change_interval); angle_to_cart( p->prev_ang_dir,&tmp1); angle_to_cart( p->next_ang_dir,&tmp2); tmp3.x = (FL(1.0)-coeff) * tmp1.x + coeff * tmp2.x; tmp3.y = (FL(1.0)-coeff) * tmp1.y + coeff * tmp2.y; tmp3.z = (FL(1.0)-coeff) * tmp1.z + coeff * tmp2.z; coeff = (MYFLT)sqrt((double)(tmp3.x * tmp3.x + tmp3.y * tmp3.y + tmp3.z * tmp3.z)); tmp3.x /= coeff; tmp3.y /= coeff; tmp3.z /= coeff; cart_to_angle(tmp3,&(p->ang_dir)); } else if (p->dim == 2) { /* 2-D */ p->prev_ang_dir.azi = *p->fld[p->curr_fld]; p->next_ang_dir.azi = *p->fld[p->next_fld ]; p->prev_ang_dir.ele = p->next_ang_dir.ele = FL(0.0); scale_angles(&(p->prev_ang_dir)); scale_angles(&(p->next_ang_dir)); angle = (p->prev_ang_dir.azi - p->next_ang_dir.azi); while(angle > FL(180.0)) angle -= FL(360.0); while(angle < -FL(180.0)) angle += FL(360.0); coeff = ((MYFLT) p->point_change_counter) / ((MYFLT) p->point_change_interval); angle *= (coeff); p->ang_dir.azi = p->prev_ang_dir.azi - angle; p->ang_dir.ele = FL(0.0); } else { return csound->PerfError(csound, p->h.insdshead, Str("Missing fields in vbapzmove\n")); } } else { /* angular velocities */ if (p->dim == 2) { p->ang_dir.azi = p->ang_dir.azi + (*p->fld[p->next_fld] * CS_ONEDKR); scale_angles(&(p->ang_dir)); } else { /* 3D angular */ p->ang_dir.azi = p->ang_dir.azi + (*p->fld[p->next_fld] * CS_ONEDKR); p->ang_dir.ele = p->ang_dir.ele + p->ele_vel * (*p->fld[p->next_fld+1] * CS_ONEDKR); if (p->ang_dir.ele > FL(90.0)) { p->ang_dir.ele = FL(90.0); p->ele_vel = -p->ele_vel; } if (p->ang_dir.ele < FL(0.0)) { p->ang_dir.ele = FL(0.0); p->ele_vel = -p->ele_vel; } scale_angles(&(p->ang_dir)); } } angle_to_cart(p->ang_dir, &(p->cart_dir)); calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, p->updated_gains, n, p->cart_dir); if (*p->spread > FL(0.0)) { if (p->dim == 3) { spreaddirnum=16; /* four orthogonal dirs */ new_spread_dir(&spreaddir[0], p->cart_dir, p->spread_base, p->ang_dir.azi, *p->spread); new_spread_base(spreaddir[0], p->cart_dir,*p->spread, &p->spread_base); cross_prod(p->spread_base, p->cart_dir, &spreadbase[1]); cross_prod(spreadbase[1], p->cart_dir, &spreadbase[2]); cross_prod(spreadbase[2], p->cart_dir, &spreadbase[3]); /* four between them */ vec_mean(p->spread_base, spreadbase[1], &spreadbase[4]); vec_mean(spreadbase[1], spreadbase[2], &spreadbase[5]); vec_mean(spreadbase[2], spreadbase[3], &spreadbase[6]); vec_mean(spreadbase[3], p->spread_base, &spreadbase[7]); /* four at half spreadangle */ vec_mean(p->cart_dir, p->spread_base, &spreadbase[8]); vec_mean(p->cart_dir, spreadbase[1], &spreadbase[9]); vec_mean(p->cart_dir, spreadbase[2], &spreadbase[10]); vec_mean(p->cart_dir, spreadbase[3], &spreadbase[11]); /* four at quarter spreadangle */ vec_mean(p->cart_dir, spreadbase[8], &spreadbase[12]); vec_mean(p->cart_dir, spreadbase[9], &spreadbase[13]); vec_mean(p->cart_dir, spreadbase[10], &spreadbase[14]); vec_mean(p->cart_dir, spreadbase[11], &spreadbase[15]); for (i=1;i<spreaddirnum;i++) { new_spread_dir(&spreaddir[i], p->cart_dir, spreadbase[i],p->ang_dir.azi,*p->spread); calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, tmp_gains, n, spreaddir[i]); for (j=0;j<n;j++) { p->updated_gains[j] += tmp_gains[j]; } } } else if (p->dim == 2) { spreaddirnum=6; atmp.ele=FL(0.0); atmp.azi=p->ang_dir.azi - *p->spread; angle_to_cart(atmp, &spreaddir[0]); atmp.azi=p->ang_dir.azi - *p->spread/2; angle_to_cart(atmp, &spreaddir[1]); atmp.azi=p->ang_dir.azi - *p->spread/4; angle_to_cart(atmp, &spreaddir[2]); atmp.azi=p->ang_dir.azi + *p->spread/4; angle_to_cart(atmp, &spreaddir[3]); atmp.azi=p->ang_dir.azi + *p->spread/2; angle_to_cart(atmp, &spreaddir[4]); atmp.azi=p->ang_dir.azi + *p->spread; angle_to_cart(atmp, &spreaddir[5]); for (i=0;i<spreaddirnum;i++) { calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, tmp_gains, n, spreaddir[i]); for (j=0;j<n;j++) { p->updated_gains[j] += tmp_gains[j]; } } } } if (*p->spread > FL(70.0)) for (i=0;i<n ;i++) { p->updated_gains[i] += (*p->spread - FL(70.0))/FL(30.0) * (*p->spread - FL(70.0))/FL(30.0)*FL(10.0); } /* normalization */ for (i=0;i<n;i++) { sum += (p->updated_gains[i]*p->updated_gains[i]); } sum = SQRT(sum); for (i=0;i<n;i++) { p->updated_gains[i] /= sum; } return OK; }
static int pv_export(CSOUND *csound, int argc, char **argv) { int inf; FILE *outf; int i; PVOCDATA data; WAVEFORMATEX fmt; if (argc != 3) { pv_export_usage(csound); return 1; } inf = csound->PVOC_OpenFile(csound, argv[1], &data, &fmt); if (inf<0) { csound->Message(csound, Str("Cannot open input file %s\n"), argv[1]); return 1; } if (strcmp(argv[2], "-")==0) outf=stdout; else outf = fopen(argv[2], "w"); if (outf == NULL) { csound->Message(csound, Str("Cannot open output file %s\n"), argv[2]); csound->PVOC_CloseFile(csound, inf); return 1; } fprintf(outf, "FormatTag,Channels,SamplesPerSec,AvgBytesPerSec," "BlockAlign,BitsPerSample,cbSize\n"); fprintf(outf, "%d,%d,%d,%d,%u,%u,%d\n", fmt.wFormatTag, fmt.nChannels, fmt.nSamplesPerSec, fmt.nAvgBytesPerSec, fmt.nBlockAlign, fmt.wBitsPerSample, fmt.cbSize); fprintf(outf, "WordFormat,AnalFormat,SourceFormat,WindowType," "AnalysisBins,Winlen,Overlap,FrameAlign," "AnalysisRate,WindowParam\n"); fprintf(outf, "%d,%d,%d,%d,%d,%d,%d,%d,%g,%g\n", data.wWordFormat,data.wAnalFormat,data.wSourceFormat, data.wWindowType,data.nAnalysisBins,data.dwWinlen, data.dwOverlap,data.dwFrameAlign,data.fAnalysisRate, data.fWindowParam); /* if (data.wWordFormat==PVOC_IEEE_FLOAT) */ { float *frame = (float*) csound->Malloc(csound, data.nAnalysisBins * 2 * sizeof(float)); for (i=1;;i++) { unsigned int j; if (1!=csound->PVOC_GetFrames(csound, inf, frame, 1)) break; for (j=0; j<data.nAnalysisBins*2; j++) fprintf(outf, "%s%g", (j==0 ? "" : ","), frame[j]); fprintf(outf, "\n"); if (i%50==0 && outf!=stdout) csound->Message(csound,"%d\n", i); } csound->Free(csound,frame); } /* else { */ /* double *frame = (double*) malloc(data.nAnalysisBins * 2 * sizeof(double)); */ /* for (; i!=0; i--) { */ /* int j; */ /* csound->PVOC_GetFrames(csound, inf, frame, 1); */ /* for (j = 0; j<data.nAnalysisBins*2; j ++) */ /* fprintf(outf, "%s%g", (j==0 ? "" : ","), frame[j]); */ /* fprintf(outf, "\n"); */ /* } */ /* free(frame); */ /* } */ csound->PVOC_CloseFile(csound, inf); fclose(outf); return 0; }
int vbap_zak_moving_init(CSOUND *csound, VBAP_ZAK_MOVING *p) { int i, j, indx; MYFLT *ls_table, *ptr; LS_SET *ls_set_ptr; int n = p->n; p->n = (int)MYFLT2LONG(*p->numb); /* Set size */ /* Check to see this index is within the limits of za space. */ indx = (int32) *p->ndx; if (UNLIKELY(indx > csound->zalast)) { return csound->PerfError(csound, p->h.insdshead, Str("outz index > isizea. No output")); } else if (UNLIKELY(indx < 0)) { return csound->PerfError(csound, p->h.insdshead, Str("outz index < 0. No output.")); } /* Now read from the array in za space and write to the output. */ p->out_array = csound->zastart + (indx * CS_KSMPS);/* outputs */ csound->AuxAlloc(csound, p->n*sizeof(MYFLT)*4, &p->auxch); p->curr_gains = (MYFLT*)p->auxch.auxp; p->beg_gains = p->curr_gains + p->n; p->end_gains = p->beg_gains + p->n; p->updated_gains = p->end_gains + p->n; /* reading in loudspeaker info */ ls_table = (MYFLT*) (csound->QueryGlobalVariableNoCheck(csound, "vbap_ls_table_0")); p->dim = (int) ls_table[0]; p->ls_am = (int) ls_table[1]; p->ls_set_am = (int) ls_table[2]; ptr = &(ls_table[3]); csound->AuxAlloc(csound, p->ls_set_am * sizeof (LS_SET), &p->aux); if (UNLIKELY(p->aux.auxp == NULL)) { return csound->InitError(csound, Str("could not allocate memory")); } p->ls_sets = (LS_SET*) p->aux.auxp; ls_set_ptr = p->ls_sets; for (i=0 ; i < p->ls_set_am ; i++) { ls_set_ptr[i].ls_nos[2] = 0; /* initial setting */ for (j=0 ; j < p->dim ; j++) { ls_set_ptr[i].ls_nos[j] = (int) *(ptr++); } for (j=0 ; j < 9; j++) ls_set_ptr[i].ls_mx[j] = FL(0.0); /* initial setting */ for (j=0 ; j < (p->dim) * (p->dim); j++) { ls_set_ptr[i].ls_mx[j] = (MYFLT) *(ptr++); } } /* other initialization */ p->ele_vel = FL(1.0); /* functions specific to movement */ if (UNLIKELY(fabs(*p->field_am) < (2+ (p->dim - 2)*2))) { return csound->InitError(csound, Str("Have to have at least %d directions in vbapzmove"), 2 + (p->dim - 2) * 2); } if (p->dim == 2) p->point_change_interval = (int) (CS_EKR * *p->dur / (fabs(*p->field_am) - 1.0)); else if (LIKELY(p->dim == 3)) p->point_change_interval = (int) (CS_EKR * *p->dur / (fabs(*p->field_am) * 0.5 - 1.0)); else return csound->InitError(csound, Str("Wrong dimension")); p->point_change_counter = 0; p->curr_fld = 0; p->next_fld = 1; p->ang_dir.azi = *p->fld[0]; if (p->dim == 3) { p->ang_dir.ele = *p->fld[1]; } else { p->ang_dir.ele = FL(0.0); } if (p->dim == 3) { p->curr_fld = 1; p->next_fld = 2; } angle_to_cart(p->ang_dir, &(p->cart_dir)); p->spread_base.x = p->cart_dir.y; p->spread_base.y = p->cart_dir.z; p->spread_base.z = -p->cart_dir.x; vbap_zak_moving_control(csound,p); for (i=0;i<n;i++) { p->beg_gains[i] = p->updated_gains[i]; p->end_gains[i] = p->updated_gains[i]; } return OK; }
void lpc_export_usage(CSOUND *csound) { csound->Message(csound, Str("usage: lpc_export lpc_file cstext-file\n")); }
int vbap_zak_control(CSOUND *csound, VBAP_ZAK *p) { CART_VEC spreaddir[16]; CART_VEC spreadbase[16]; ANG_VEC atmp; int32 i,j, spreaddirnum; int n = p->n; MYFLT tmp_gains[MAXCHNLS],sum = FL(0.0); if (UNLIKELY(p->dim == 2 && fabs(*p->ele) > 0.0)) { csound->Warning(csound, Str("Warning: truncating elevation to 2-D plane\n")); *p->ele = FL(0.0); } if (*p->spread <FL(0.0)) *p->spread=FL(0.0); else if (*p->spread >FL(100.0)) *p->spread=FL(100.0); /* Current panning angles */ p->ang_dir.azi = (MYFLT) *p->azi; p->ang_dir.ele = (MYFLT) *p->ele; p->ang_dir.length = FL(1.0); angle_to_cart(p->ang_dir, &(p->cart_dir)); calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, p->updated_gains, n, p->cart_dir); /* Calculated gain factors of a spreaded virtual source */ if (*p->spread > FL(0.0)) { if (p->dim == 3) { spreaddirnum=16; /* four orthogonal dirs */ new_spread_dir(&spreaddir[0], p->cart_dir, p->spread_base, *p->azi, *p->spread); new_spread_base(spreaddir[0], p->cart_dir,*p->spread, &p->spread_base); cross_prod(p->spread_base, p->cart_dir, &spreadbase[1]); cross_prod(spreadbase[1], p->cart_dir, &spreadbase[2]); cross_prod(spreadbase[2], p->cart_dir, &spreadbase[3]); /* four between them */ vec_mean(p->spread_base, spreadbase[1], &spreadbase[4]); vec_mean(spreadbase[1], spreadbase[2], &spreadbase[5]); vec_mean(spreadbase[2], spreadbase[3], &spreadbase[6]); vec_mean(spreadbase[3], p->spread_base, &spreadbase[7]); /* four at half spreadangle */ vec_mean(p->cart_dir, p->spread_base, &spreadbase[8]); vec_mean(p->cart_dir, spreadbase[1], &spreadbase[9]); vec_mean(p->cart_dir, spreadbase[2], &spreadbase[10]); vec_mean(p->cart_dir, spreadbase[3], &spreadbase[11]); /* four at quarter spreadangle */ vec_mean(p->cart_dir, spreadbase[8], &spreadbase[12]); vec_mean(p->cart_dir, spreadbase[9], &spreadbase[13]); vec_mean(p->cart_dir, spreadbase[10], &spreadbase[14]); vec_mean(p->cart_dir, spreadbase[11], &spreadbase[15]); for (i=1;i<spreaddirnum;i++) { new_spread_dir(&spreaddir[i], p->cart_dir, spreadbase[i],*p->azi,*p->spread); calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, tmp_gains, n, spreaddir[i]); for (j=0;j<n;j++) { p->updated_gains[j] += tmp_gains[j]; } } } else if (p->dim == 2) { spreaddirnum = 6; atmp.ele = FL(0.0); atmp.azi = *p->azi - *p->spread; angle_to_cart(atmp, &spreaddir[0]); atmp.azi = *p->azi - *p->spread/2; angle_to_cart(atmp, &spreaddir[1]); atmp.azi = *p->azi - *p->spread/4; angle_to_cart(atmp, &spreaddir[2]); atmp.azi = *p->azi + *p->spread/4; angle_to_cart(atmp, &spreaddir[3]); atmp.azi = *p->azi + *p->spread/2; angle_to_cart(atmp, &spreaddir[4]); atmp.azi = *p->azi + *p->spread; angle_to_cart(atmp, &spreaddir[5]); for (i=0;i<spreaddirnum;i++) { calc_vbap_gns(p->ls_set_am, p->dim, p->ls_sets, tmp_gains, n, spreaddir[i]); for (j=0;j<n;j++) { p->updated_gains[j] += tmp_gains[j]; } } } } if (*p->spread > FL(70.0)) for (i=0;i<n ;i++) { p->updated_gains[i] +=(*p->spread - FL(70.0))/FL(30.0) * (*p->spread - FL(70.0))/FL(30.0)*FL(20.0); } /* normalization */ for (i=0;i<n;i++) { sum = sum+(p->updated_gains[i]*p->updated_gains[i]); } sum = SQRT(sum); for (i=0;i<n;i++) { p->updated_gains[i] /= sum; } return OK; }
CTSTR SettingsEncoding::GetCategory() const { static CTSTR name = Str("Settings.Encoding"); return name; }
Str copyMe() { return Str(*this); }