void MainWindow::updateAllResponses() { // clear responses for (int i = 0; i < defaultFilterCount; ++i) { for (int j = 0; j < defaultPlotSampleCount; ++j) { m_magnitudes[i][j] = 0.0; m_phases[i][j] = 0.0; } } // Update frequency and phase response for (size_t i = 0; i < cr_filter_count(m_cornrow); ++i) { double *magnitudes = m_magnitudes[i]; double *phases = m_phases[i]; cr_filter_response(m_cornrow, i, defaultPlotSampleCount, m_frequencies, magnitudes, phases); // Update magnitude plot QVector<double> xM(defaultPlotSampleCount); qCopy(m_frequencies, m_frequencies+defaultPlotSampleCount, xM.begin()); QVector<double> yM(defaultPlotSampleCount); qCopy(magnitudes, magnitudes+defaultPlotSampleCount, yM.begin()); ui->magnitudePlot->graph(i)->setData(xM, yM); ui->magnitudePlot->graph(i)->setVisible(cr_filter_type(m_cornrow, i) != FilterType::None); // Update phase plot QVector<double> xP(defaultPlotSampleCount); qCopy(m_frequencies, m_frequencies+defaultPlotSampleCount, xP.begin()); QVector<double> yP(defaultPlotSampleCount); qCopy(phases, phases+defaultPlotSampleCount, yP.begin()); ui->phasePlot->graph(i)->setData(xP, yP); ui->phasePlot->graph(i)->setVisible(cr_filter_type(m_cornrow, i) != FilterType::None); } }
void PreferencesWidget::updateAllResponses() { // clear responses for (int i = 0; i < defaultFilterCount; ++i) { for (int j = 0; j < defaultPlotSampleCount; ++j) { m_magnitudes[i][j] = 0.0; m_phases[i][j] = 0.0; } } // Update frequency and phase response size_t i = 0; for (const Filter& filter : m_filterManager.filters()) { double *magnitudes = m_magnitudes[i]; double *phases = m_phases[i]; m_filterManager.filterResponse(i, defaultPlotSampleCount, m_frequencies, magnitudes, phases); // Update magnitude plot QVector<double> xM(defaultPlotSampleCount); qCopy(m_frequencies, m_frequencies+defaultPlotSampleCount, xM.begin()); QVector<double> yM(defaultPlotSampleCount); qCopy(magnitudes, magnitudes+defaultPlotSampleCount, yM.begin()); ui->magnitudePlot->graph(i)->setData(xM, yM); ui->magnitudePlot->graph(i)->setVisible(filter.type() != FilterType::None); // Update phase plot QVector<double> xP(defaultPlotSampleCount); qCopy(m_frequencies, m_frequencies+defaultPlotSampleCount, xP.begin()); QVector<double> yP(defaultPlotSampleCount); qCopy(phases, phases+defaultPlotSampleCount, yP.begin()); ui->phasePlot->graph(i)->setData(xP, yP); ui->phasePlot->graph(i)->setVisible(filter.type() != FilterType::None); ++i; } }
void MainWindow::updateCurrentFilter() { size_t index = ui->filterComboBox->currentIndex(); // Update frequency and phase response double *magnitudes = m_magnitudes[index]; double *phases = m_phases[index]; cr_filter_response(m_cornrow, index, defaultPlotSampleCount, m_frequencies, magnitudes, phases); // Update magnitude plot QVector<double> xM(defaultPlotSampleCount); qCopy(m_frequencies, m_frequencies+defaultPlotSampleCount, xM.begin()); QVector<double> yM(defaultPlotSampleCount); qCopy(magnitudes, magnitudes+defaultPlotSampleCount, yM.begin()); ui->magnitudePlot->graph(index)->setData(xM, yM); ui->magnitudePlot->graph(index)->setVisible(cr_filter_type(m_cornrow,index) != FilterType::None); // Update phase plot QVector<double> xP(defaultPlotSampleCount); qCopy(m_frequencies, m_frequencies+defaultPlotSampleCount, xP.begin()); QVector<double> yP(defaultPlotSampleCount); qCopy(phases, phases+defaultPlotSampleCount, yP.begin()); ui->phasePlot->graph(index)->setData(xP, yP); ui->phasePlot->graph(index)->setVisible(cr_filter_type(m_cornrow,index) != FilterType::None); // Update cascade frequency and phase responses double magnitudeSum[defaultPlotSampleCount]; double phaseSum[defaultPlotSampleCount]; for (int j = 0; j < defaultPlotSampleCount; ++j) { magnitudeSum[j] = m_magnitudeSumExceptCurrent[j] + m_magnitudes[index][j]; phaseSum[j] = m_phaseSumExceptCurrent[j] + m_phases[index][j]; } QVector<double> xMS(defaultPlotSampleCount); qCopy(m_frequencies, m_frequencies+defaultPlotSampleCount, xMS.begin()); QVector<double> yMS(defaultPlotSampleCount); qCopy(magnitudeSum, magnitudeSum+defaultPlotSampleCount, yMS.begin()); m_magnitudeSumGraph->setData(xMS, yMS); QVector<double> xPS(defaultPlotSampleCount); qCopy(m_frequencies, m_frequencies+defaultPlotSampleCount, xPS.begin()); QVector<double> yPS(defaultPlotSampleCount); qCopy(phaseSum, phaseSum+defaultPlotSampleCount, yPS.begin()); m_phaseSumGraph->setData(xPS, yPS); }
int main(int argc, char *argv[]) { struct option longopts[] = { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, 'V' }, // { "long", no_argument, NULL, 'l' }, // { "delete", required_argument, NULL, 'd' }, // { "print", required_argument, NULL, 'p' }, // { "dump", required_argument, NULL, 'o' }, // { "write", required_argument, NULL, 'w' }, // { "follow-symlinks", no_argument, NULL, 'L' }, // { "create", no_argument, NULL, 'C' }, // { "replace", no_argument, NULL, 'R' }, // { "nosecurity", no_argument, NULL, 'S' }, // 10.6 only? // { "nodefault", no_argument, NULL, 'D' }, // 10.6 only? // { "show-compression", no_argument, NULL, 'Z' }, // 10.6 only? // { "cols", required_argument, NULL, 'c' }, { NULL, 0, NULL, 0 } }; int c; char *attr = NULL; char *value = NULL; // todo: -s <> and -S options to get XA sizes? // todo: -w <> -f <> ? // todo: -e attr exists? while ((c = getopt_long(argc, argv, "hV" "ld:o:p:w:" "c:x" "LCRSDZ", longopts, NULL)) != EOF) { switch (c) { case 'l': case 'o': case 'p': case 'd': case 'w': if (action != '\0') { warnx("You may not specify more than one `-dopw' option"); fprintf(stderr, "Try `%s --help' for more information.\n", argv[0]); return 2; } else { action = c; if (action != 'l') { size_t l = strlen(optarg) + 1; attr = xmalloc(l); memcpy(attr, optarg, l); if ((action == 'w') && (optind < argc)) { char *val = argv[optind]; optind += 1; l = strlen(val) + 1; value = xmalloc(l); memcpy(value, val, l); } } } break; case 'L': options ^= XATTR_NOFOLLOW; break; case 'C': options ^= XATTR_CREATE; break; case 'R': options ^= XATTR_REPLACE; break; case 'S': options ^= XATTR_NOSECURITY; break; case 'D': options ^= XATTR_NODEFAULT; break; case 'Z': options ^= XATTR_SHOWCOMPRESSION; break; case 'x': hex ^= 1; break; case 'c': { unsigned long acols = strtoul(optarg, NULL, 0); if (acols > 0 && errno == 0) gCols = acols; else err(1, NULL); } break; case 'h': printf("usage: %s [<action>] [<options>] <file>...\n" "ACTIONS\n" " (default)\t" "List names of xattrs\n" " -p <name>\t" "Print data for given xattr\n" " -d <name>\t" "Delete given xattr\n" " -w <name> <value>\t" "Write xattr\n" "OPTIONS\n" " -L\t" "Follow symlinks.\n" " -C\t" "Fail if xattr exists (create)\n" " -R\t" "Fail if xattr doesn't exist (replace)\n" " -D\t" "Bypass the default extended attribute file (dot-underscore file)\n" " -Z\t" "Show HFS compression attributes\n" , argv[0]); return 0; case 'V': PRINT_VERSION; return 0; // case '?': default: // fprintf(stderr, "Usage: %s [-LRC] ACTION [ARG] <file>...\n", argv[0]); goto bad_cmd; } } if ((argc -= optind) == 0) { warnx("No files to act on"); bad_cmd: fprintf(stderr, "Try `%s --help' for more information.\n", argv[0]); return 2; } argv += optind; switch (action) { case '\0': if (argc == 1) x(argv[0]); else { printf("%s:\n", argv[0]); x(argv[0]); argv += 1; do { printf("\n%s:\n", argv[0]); x(argv[0]); } while (++argv, --argc); } break; case 'o': if (strcmp("-", attr) != 0) { if (argc == 1) xo(argv[0], attr); else { printf("%s:\n", argv[0]); xo(argv[0], attr); argv += 1; argc -= 1; do { printf("\n%s:\n", argv[0]); xo(argv[0], attr); } while (++argv, --argc); } } else { size_t n; char **list = readList(&n); // check goto oloopInit; oloop: putchar('\n'); oloopInit: printf("%s:\n", argv[0]); for (size_t i = 0; i < n; i++) { printf("%s:\n", list[i]); xo(argv[0], list[i]); } argv += 1; argc -= 1; if (argc) goto oloop; // fixme: ? leaking each list item free(list); } break; case 'p': if (strcmp("-", attr) != 0) { if (argc == 1) xp(argv[0], attr); else { printf("%s:\n", argv[0]); xp(argv[0], attr); argv += 1; argc -= 1; do { printf("\n%s:\n", argv[0]); xp(argv[0], attr); } while (++argv, --argc); } } else { size_t n; char **list = readList(&n); // check goto ploopInit; ploop: putchar('\n'); ploopInit: printf("%s:\n", argv[0]); for (size_t i = 0; i < n; i++) { printf("%s:\n", list[i]); xp(argv[0], list[i]); } argv += 1; argc -= 1; if (argc) goto ploop; // fixme: ? leaking each list item free(list); } break; case 'l': if (argc == 1) xP(argv[0]); else { printf("%s:\n", argv[0]); xP(argv[0]); argv += 1; argc -= 1; do { printf("\n%s:\n", argv[0]); xP(argv[0]); } while (++argv, --argc); } break; case 'w': { // write xattr // Read data from stdin // 4096 bytes is max size for all xattrs except resource fork size_t totalSize; if (value == NULL) { value = malloc(4096); size_t lastReadSize = 0; unsigned int n = 0; // Accumulate data into buffer, expanding as needed while (value && (lastReadSize = fread(value + (n*4096), 1, 4096, stdin)) == 4096) value = realloc(value, (++n + 1)*4096); if (value == NULL) err(1, NULL); totalSize = (n*4096)+lastReadSize; } else { totalSize = strlen(value); } do { if (setxattr(argv[0], attr, value, totalSize, 0, options) != 0) warn("%s", argv[0]); } while (++argv, --argc); free(value); } break; case 'd': // delete xattrs if (strcmp("-", attr) != 0) { do { xd(argv[0], attr); } while (++argv, --argc); } else { size_t n; char **list = readList(&n); // check do { for (size_t i = 0; i < n; i++) xd(argv[0], list[i]); } while (++argv, --argc); // fixme: ? leaking each list item free(list); } break; } free(attr); return (errno != 0); }