QFilter::QFilter(QObject *parent, int size, const int ftype, const int wtype) : QObject(parent) , set(Settings::instance()) , m_streamMode(true) , m_size(size) , m_ftype(ftype) , m_wtype(wtype) , m_samplerate(set->getSampleRate()) , m_filter_lo(-3050.0f) , m_filter_hi(-150.0f) { InitCPX(ovlp, m_size, 0.0f); InitCPX(tmp, m_size, 0.0f); InitCPX(res, m_size, 0.0f); InitCPX(filter, m_size * 2, 0.0f); InitCPX(tmp0, m_size * 2, 0.0f); InitCPX(tmp1, m_size * 2, 0.0f); InitCPX(tmp2, m_size * 2, 0.0f); InitCPX(tmpfilt0, m_size * 2, 0.0f); InitCPX(tmpfilt1, m_size * 2, 0.0f); ovlpfft = new QFFT(m_size * 2); filtfft = new QFFT(m_size * 2); MakeFilter(m_filter_lo, m_filter_hi, m_ftype, m_wtype); }
void MainWnd_OnExport(HWND hwnd) { OPENFILENAMEW ofn = {0}; WCHAR szFile[MAX_PATH] = L""; WCHAR szExportTitle[MAX_STRING]; WCHAR szCannotExport[MAX_STRING]; WCHAR szExportFilter[MAX_STRING]; LoadStringW(g_hInstance, IDS_EXPORT, szExportTitle, _countof(szExportTitle)); LoadStringW(g_hInstance, IDS_CANTEXPORT, szCannotExport, _countof(szCannotExport)); LoadStringW(g_hInstance, IDS_OUTFILTER, szExportFilter, _countof(szExportFilter)); MakeFilter(szExportFilter); ofn.lStructSize = OPENFILENAME_SIZE_VERSION_400; ofn.hwndOwner = hwnd; ofn.lpstrFilter = szExportFilter; ofn.lpstrFile = szFile; ofn.nMaxFile = _countof(szFile); ofn.lpstrTitle = szExportTitle; ofn.Flags = OFN_DONTADDTORECENT | OFN_ENABLESIZING | OFN_EXPLORER | OFN_HIDEREADONLY | OFN_LONGNAMES | OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT; ofn.lpstrDefExt = L"reg"; if (GetSaveFileNameW(&ofn)) { if (!DoExport(hwnd, szFile)) { MessageBoxW(hwnd, szCannotExport, g_szTitle, MB_ICONERROR); } } }
void QFilter::setFilterHi(const float value) { if (value != m_filter_hi) { m_filter_hi = value; MakeFilter(m_filter_lo, m_filter_hi, m_ftype, m_wtype); } }
void QFilter::setSampleRate(QObject *sender, int value) { Q_UNUSED(sender) m_samplerate = (float)value; //FILTER_DEBUG << "set sample rate to " << m_samplerate; MakeFilter(m_filter_lo, m_filter_hi, m_ftype, m_wtype); }
void QFilter::setFilter(const float loval, const float hival) { if (m_filter_lo != loval || m_filter_hi != hival) { m_filter_lo = loval; m_filter_hi = hival; MakeFilter(m_filter_lo, m_filter_hi, m_ftype, m_wtype); } }
// Adds a file to the database BOOL CDriveIndex::Add(DWORDLONG Index, wstring *szName, DWORDLONG ParentIndex, DWORDLONG Filter) { IndexedFile i; i.Index = Index; if(!Filter) Filter = MakeFilter(szName); i.Filter = Filter; rgFiles.insert(rgFiles.end(), i); return(TRUE); }
// Adds a directory to the database BOOL CDriveIndex::AddDir(DWORDLONG Index, wstring *szName, DWORDLONG ParentIndex, DWORDLONG Filter) { IndexedDirectory i; i.Index = Index; if(!Filter) Filter = MakeFilter(szName); i.Filter = Filter; i.nFiles = 0; rgDirectories.insert(rgDirectories.end(), i); return(TRUE); }
BOOL GetFName( HINSTANCE hinst ) { OPENFILENAME ofn; const int max_len = 2*1024; char fname[max_len+1]; fname[0] = 0; setlocale( LC_ALL, ".ACP" ); //vc9 bag ZeroMemory( &ofn, sizeof(ofn) ); ofn.hInstance = hinst; ofn.Flags = OFN_EXPLORER | OFN_FILEMUSTEXIST |OFN_ALLOWMULTISELECT; ofn.lpstrFile = fname; ofn.nMaxFile = max_len; std::string filter = MakeFilter(); ofn.lpstrFilter = filter.c_str(); ofn.lStructSize = sizeof(ofn); ofn.lpstrInitialDir=NULL; BOOL res = GetOpenFileName( &ofn ); ::fname = fname; return res; }
bool EFS_Utils::GetSaveName(LPCSTR initial, string_path& buffer, LPCSTR offset, int start_flt_ext) { // unsigned int dwVersion = GetVersion(); // unsigned int dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); FS_Path& P = *FS.get_path(initial); string1024 flt; LPCSTR def_ext = P.m_DefExt; if (false)//&& dwWindowsMajorVersion == 6 ) { if (strstr(P.m_DefExt, "*.")) def_ext = strstr(P.m_DefExt, "*.") + 2; } MakeFilter(flt, P.m_FilterCaption ? P.m_FilterCaption : "", def_ext); OPENFILENAME ofn; Memory.mem_fill(&ofn, 0, sizeof(ofn)); if (xr_strlen(buffer)) { string_path dr; if (!(buffer[0] == '\\' && buffer[1] == '\\')) // if !network { _splitpath(buffer, dr, 0, 0, 0); if (0 == dr[0]) P._update(buffer, buffer); } } ofn.hwndOwner = GetForegroundWindow(); ofn.lpstrDefExt = def_ext; ofn.lpstrFile = buffer; ofn.lpstrFilter = flt; ofn.lStructSize = sizeof(ofn); ofn.nMaxFile = sizeof(buffer); ofn.nFilterIndex = start_flt_ext + 2; ofn.lpstrTitle = "Save a File"; string512 path; xr_strcpy(path, (offset&&offset[0]) ? offset : P.m_Path); ofn.lpstrInitialDir = path; ofn.Flags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT | OFN_NOCHANGEDIR; ofn.FlagsEx = OFN_EX_NOPLACESBAR; /* if ( dwWindowsMajorVersion == 6 ) { ofn.Flags |= OFN_ENABLEHOOK; ofn.lpfnHook = OFNHookProcOldStyle; } */ bool bRes = !!GetSaveFileName(&ofn); if (!bRes) { u32 err = CommDlgExtendedError(); switch (err) { case FNERR_BUFFERTOOSMALL: Log("Too many file selected."); break; } } strlwr(buffer); return bRes; }
bool EFS_Utils::GetOpenNameInternal(LPCSTR initial, LPSTR buffer, int sz_buf, bool bMulti, LPCSTR offset, int start_flt_ext) { VERIFY(buffer && (sz_buf > 0)); FS_Path& P = *FS.get_path(initial); string1024 flt; MakeFilter(flt, P.m_FilterCaption ? P.m_FilterCaption : "", P.m_DefExt); OPENFILENAME ofn; Memory.mem_fill(&ofn, 0, sizeof(ofn)); if (xr_strlen(buffer)) { string_path dr; if (!(buffer[0] == '\\' && buffer[1] == '\\')) // if !network { _splitpath(buffer, dr, 0, 0, 0); if (0 == dr[0]) { string_path bb; P._update(bb, buffer); xr_strcpy(buffer, sz_buf, bb); } } } ofn.lStructSize = sizeof(OPENFILENAME); ofn.hwndOwner = GetForegroundWindow(); ofn.lpstrDefExt = P.m_DefExt; ofn.lpstrFile = buffer; ofn.nMaxFile = sz_buf; ofn.lpstrFilter = flt; ofn.nFilterIndex = start_flt_ext + 2; ofn.lpstrTitle = "Open a File"; string512 path; xr_strcpy(path, (offset&&offset[0]) ? offset : P.m_Path); ofn.lpstrInitialDir = path; ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST | OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_NOCHANGEDIR | (bMulti ? OFN_ALLOWMULTISELECT | OFN_EXPLORER : 0); ofn.FlagsEx = OFN_EX_NOPLACESBAR; /* unsigned int dwVersion = GetVersion(); unsigned int dwWindowsMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion))); if ( dwWindowsMajorVersion == 6 ) { ofn.Flags |= OFN_ENABLEHOOK; ofn.lpfnHook = OFNHookProcOldStyle; } */ bool bRes = !!GetOpenFileName(&ofn); if (!bRes) { u32 err = CommDlgExtendedError(); switch (err) { case FNERR_BUFFERTOOSMALL: Log("Too many files selected."); break; } } if (bRes && bMulti) { Log("buff=", buffer); int cnt = _GetItemCount(buffer, 0x0); if (cnt > 1) { char dir[255 * 255]; char buf[255 * 255]; char fns[255 * 255]; xr_strcpy(dir, buffer); xr_strcpy(fns, dir); xr_strcat(fns, "\\"); xr_strcat(fns, _GetItem(buffer, 1, buf, 0x0)); for (int i = 2; i < cnt; i++) { xr_strcat(fns, ","); xr_strcat(fns, dir); xr_strcat(fns, "\\"); xr_strcat(fns, _GetItem(buffer, i, buf, 0x0)); } xr_strcpy(buffer, sz_buf, fns); } } strlwr(buffer); return bRes; }
// Internal function for searching in the database. // For projects in C++ which use this project it might be preferable to use this function // to skip the wrapper. // Returns: number of results, -1 if maxResults != -1 and not all results were found int CDriveIndex::Find(wstring *strQuery, wstring *strQueryPath, vector<SearchResultFile> *rgsrfResults, BOOL bSort, BOOL bEnhancedSearch, int maxResults) { //These variables are used to control the flow of execution in this function. //Indicates where results should be searched unsigned int SearchWhere = IN_FILES; //Offset for vector marked by SearchWhere unsigned int iOffset = 0; //Used to skip the search when the previous two properties should be carried over to the next search without actually using them now. BOOL bSkipSearch = false; //Number of results in this search. -1 if more than maximum number of results. int nResults = 0; //No query, just ignore this call if(strQuery->length() == 0) { // Store this query LastResult.Query = wstring(TEXT("")); LastResult.Results = vector<SearchResultFile>(); return nResults; } if(strQueryPath != NULL) { //Check if the path actually matches the drive of this index WCHAR szDrive[_MAX_DRIVE]; _wsplitpath(strQueryPath->c_str(), szDrive, NULL, NULL, NULL); for(unsigned int j = 0; j != _MAX_DRIVE; j++) szDrive[j] = toupper(szDrive[j]); if(wstring(szDrive).compare(wstring(1,toupper(m_cDrive))) == 0) return 0; } //Create lower query string for case-insensitive search wstring strQueryLower(*strQuery); for(unsigned int j = 0; j != strQueryLower.length(); j++) strQueryLower[j] = tolower(strQueryLower[j]); const WCHAR *szQueryLower = strQueryLower.c_str(); //Create lower query path string for case-insensitive search wstring strQueryPathLower(strQueryPath != NULL ? *strQueryPath : TEXT("")); for(unsigned int j = 0; j != strQueryPathLower.length(); j++) strQueryPathLower[j] = tolower((*strQueryPath)[j]); wstring* pstrQueryPathLower = strQueryPath != NULL && strQueryPathLower.length() > 0 ? &strQueryPathLower : NULL; //If the query path is different from the last query so that the results are not valid anymore, the last query needs to be dropped if(!(strQueryPath != NULL && (LastResult.maxResults == -1 || LastResult.iOffset == 0) && (LastResult.SearchPath.length() == 0 || strQueryPathLower.find(LastResult.SearchPath) == 0))) LastResult = SearchResult(); //Calculate Filter value and length of the current query which are compared with the cached ones to skip many of them DWORDLONG QueryFilter = MakeFilter(&strQueryLower); DWORDLONG QueryLength = (QueryFilter & 0xE000000000000000ui64) >> 61ui64; //Bits 61-63 for storing lengths up to 8 QueryFilter = QueryFilter & 0x1FFFFFFFFFFFFFFFui64; //All but the last 3 bits //If the same query string as in the last query was used if(strQueryLower.compare(LastResult.Query) == 0 && LastResult.Results.size() > 0 && (LastResult.SearchEndedWhere == NO_WHERE && iOffset != 1)) // need proper condition here to skip { //Keep the position of the last result SearchWhere = LastResult.SearchEndedWhere; iOffset = LastResult.iOffset; bSkipSearch = true; for(int i = 0; i != LastResult.Results.size(); i++) { BOOL bFound = true; if(pstrQueryPathLower != NULL) { wstring strPathLower(LastResult.Results[i].Path); for(unsigned int j = 0; j != strPathLower.length(); j++) strPathLower[j] = tolower(LastResult.Results[i].Path[j]); bFound = strPathLower.find(strQueryPathLower) != -1; } if(bFound) { nResults++; //If the result limit has decreased and we have found all (shouldn't happen in common scenarios) if(maxResults != -1 && nResults > maxResults) { nResults = -1; //If we get here, the next incremental should start fresh, but only if it requires more results than this one. //To accomplish this we make this result contain no information about the origin of these results. SearchWhere = NO_WHERE; iOffset = 1; break; } rgsrfResults->insert(rgsrfResults->end(), LastResult.Results[i]); } } //if the last search was limited and didn't finish because it found enough files and we don't have the maximum number of results yet //we need to continue the search where the last one stopped. if(LastResult.maxResults != -1 && LastResult.SearchEndedWhere != NO_WHERE && (maxResults == -1 || nResults < maxResults)) bSkipSearch = false; } //If this query is more specific than the previous one, it can use the results from the previous query else if(strQueryLower.find(LastResult.Query) != -1 && LastResult.Results.size() > 0) { bSkipSearch = true; //Keep the position of the last result SearchWhere = LastResult.SearchEndedWhere; iOffset = LastResult.iOffset; FindInPreviousResults(*strQuery, szQueryLower, QueryFilter, QueryLength, pstrQueryPathLower, *rgsrfResults, 0, bEnhancedSearch, maxResults, nResults); //if the last search was limited and didn't finish because it found enough files and we don't have the maximum number of results yet //we need to continue the search where the last one stopped. if(LastResult.maxResults != -1 && LastResult.SearchEndedWhere != NO_WHERE && (maxResults == -1 || nResults < maxResults)) bSkipSearch = false; } DWORDLONG FRNPath; long long nFilesInDir = -1; if(strQueryPath != NULL && strQueryPath->length()) { FRNPath = PathToFRN(strQueryPath); wstring strPath2; GetDir(FRNPath, &strPath2); int iOffset = (int) FindDirOffsetByIndex(FRNPath); if(iOffset != -1) nFilesInDir = rgDirectories[iOffset].nFiles; } if(SearchWhere == IN_FILES && iOffset == 0 && nFilesInDir != -1 && nFilesInDir < 10000 && !bSkipSearch) { FindRecursively(*strQuery, szQueryLower, QueryFilter, QueryLength, strQueryPath, *rgsrfResults, bEnhancedSearch, maxResults, nResults); SearchWhere = NO_WHERE; } else if(SearchWhere == IN_FILES && !bSkipSearch) { //Find in file index FindInJournal(*strQuery, szQueryLower, QueryFilter, QueryLength, (strQueryPath != NULL ? &strQueryPathLower : NULL), rgFiles, *rgsrfResults, iOffset, bEnhancedSearch, maxResults, nResults); //If we found the maximum number of results in the file index we stop here if(maxResults != -1 && nResults == -1) iOffset++; //Start with next entry on the next incremental search else //Search isn't limited or not all results found yet, continue in directory index { SearchWhere = IN_DIRECTORIES; iOffset = 0; } } if(SearchWhere == IN_DIRECTORIES && !bSkipSearch) { //Find in directory index FindInJournal(*strQuery, szQueryLower, QueryFilter, QueryLength, pstrQueryPathLower, rgDirectories, *rgsrfResults, iOffset, bEnhancedSearch, maxResults, nResults); //If we found the maximum number of results in the directory index we stop here if(maxResults != -1 && nResults == -1) iOffset++; //Start with next entry on the next incremental search else //Search isn't limited or less than the maximum number of results found { SearchWhere = NO_WHERE; iOffset = 0; } } //Sort by match quality and name if(bSort) sort(rgsrfResults->begin(), rgsrfResults->end()); // Store this query LastResult.Query = wstring(strQueryLower); // Store search path LastResult.SearchPath = strQueryPathLower; //Clear old results, they will be replaced with the current ones LastResult.Results = vector<SearchResultFile>(); //Store number of results (Needed for incremental search) LastResult.iOffset = iOffset; //Store if this search was limited LastResult.maxResults = maxResults; //Store where the current search ended due to file limit (or if it didn't); LastResult.SearchEndedWhere = SearchWhere; //Update last results for(unsigned int i = 0; i != rgsrfResults->size(); i++) LastResult.Results.insert(LastResult.Results.end(), (*rgsrfResults)[i]); return nResults; }