diff options
| -rw-r--r-- | Makefile.am | 4 | ||||
| -rw-r--r-- | configure.in | 25 | ||||
| -rw-r--r-- | dgedit/Makefile.am | 36 | ||||
| -rw-r--r-- | dgedit/audioextractor.cc | 153 | ||||
| -rw-r--r-- | dgedit/audioextractor.h | 58 | ||||
| -rw-r--r-- | dgedit/canvas.cc | 508 | ||||
| -rw-r--r-- | dgedit/canvas.h | 105 | ||||
| -rw-r--r-- | dgedit/dgedit.cc | 39 | ||||
| -rw-r--r-- | dgedit/mainwindow.cc | 145 | ||||
| -rw-r--r-- | dgedit/mainwindow.h | 57 | ||||
| -rw-r--r-- | dgedit/selection.h | 48 | ||||
| -rw-r--r-- | src/Makefile.am | 4 | ||||
| -rw-r--r-- | src/audiofile.cc | 6 | ||||
| -rw-r--r-- | src/drumgizmo.cc | 6 | ||||
| -rw-r--r-- | src/midimapper.cc | 8 | ||||
| -rw-r--r-- | src/midiplayer.cc | 58 | ||||
| -rw-r--r-- | src/midiplayer.h | 5 | ||||
| -rwxr-xr-x | tools/MocList | 9 | 
18 files changed, 1253 insertions, 21 deletions
| diff --git a/Makefile.am b/Makefile.am index 54f5468..58820cc 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,3 +1,3 @@  AUTOMAKE_OPTIONS = gnu -SUBDIRS = src -DISTDIRS = src +SUBDIRS = src dgedit +DISTDIRS = src dgedit diff --git a/configure.in b/configure.in index ed725fa..4b35d64 100644 --- a/configure.in +++ b/configure.in @@ -26,6 +26,11 @@ fi  #AC_SUBST(MOC)  dnl ====================== +dnl Check for libsmf +dnl ====================== +PKG_CHECK_MODULES(SMF, smf >= 1.2) + +dnl ======================  dnl Check for jack  dnl ======================  PKG_CHECK_MODULES(JACK, jack >= 0.109.2) @@ -42,6 +47,23 @@ AC_CHECK_HEADER(expat.h, , AC_MSG_ERROR([*** eXpat header file not found!]))  AC_CHECK_LIB(expat, XML_ParserCreate, ,  AC_MSG_ERROR([*** eXpat library not found!]))  dnl ====================== +dnl Check for Qt +dnl ====================== +PKG_CHECK_MODULES(QT, QtCore QtGui >= 4.5) +AC_CHECK_PROGS(QT_MOC, [moc4 moc-qt4 moc], []) +AC_CHECK_PROGS(QT_RCC, [rcc4 rcc-qt4 rcc], []) +AC_CHECK_PROGS(QT_UIC, [uic4 uic-qt4 uic], []) +if (test "$QT_MOC" = ""); then +  AC_MSG_ERROR([QT4 moc is required.]) +fi +if (test "$QT_RCC" = ""); then +  AC_MSG_ERROR([QT4 rcc is required.]) +fi +if (test "$QT_UIC" = ""); then +  AC_MSG_ERROR([QT4 uic is required.]) +fi + +dnl ======================  dnl Check for getopt  dnl ======================  AC_HAVE_HEADERS(getopt.h) @@ -53,5 +75,6 @@ AC_SUBST(LDFLAGS)  AC_OUTPUT(  	Makefile -	src/Makefile) +	src/Makefile +  dgedit/Makefile) diff --git a/dgedit/Makefile.am b/dgedit/Makefile.am new file mode 100644 index 0000000..5182fd5 --- /dev/null +++ b/dgedit/Makefile.am @@ -0,0 +1,36 @@ +bin_PROGRAMS = dgedit + +dgedit_LDADD = $(SNDFILE_LIBS) $(QT_LIBS) $(shell ../tools/MocList o ) + +dgedit_CXXFLAGS = $(SNDFILE_CXXFLAGS) $(QT_CFLAGS) +CXXFLAGS += $(QT_CFLAGS) + +dgedit_SOURCES = $(shell ../tools/MocList cc ) \ +	dgedit.cc \ +	audioextractor.cc \ +	canvas.cc \ +	mainwindow.cc + +EXTRA_DIST = \ +	audioextractor.h \ +	canvas.h \ +	mainwindow.h + +dgedit_MOC = $(shell ../tools/MocList cc ) + +BUILT_SOURCES = $(dgedit_MOC) + +CLEANFILES = $(BUILT_SOURCES) + +%.moc.cc: %.h +	$(QT_MOC) -o $@ $< + +%.h: %.ui +	$(QT_UIC) -o $@ $< + +%.cc: %.ui +	$(QT_UIC) -o $@ -impl $*.h $< + +# command for creating .res file from .rc on Win32 +%.res: %.rc +	rc $< diff --git a/dgedit/audioextractor.cc b/dgedit/audioextractor.cc new file mode 100644 index 0000000..bde661a --- /dev/null +++ b/dgedit/audioextractor.cc @@ -0,0 +1,153 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            audioextractor.cc + * + *  Sat Nov 21 13:09:35 CET 2009 + *  Copyright 2009 Bent Bisballe Nyeng + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This file is part of DrumGizmo. + * + *  DrumGizmo is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  DrumGizmo is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with DrumGizmo; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. + */ +#include "audioextractor.h" + +#include <sndfile.h> + +AudioExtractor::AudioExtractor(QObject *parent) +  : QObject(parent) +{ +} + +float *AudioExtractor::load(QString file, size_t *size) +{ +  float *data; + +  SF_INFO sf_info; +	SNDFILE *fh = sf_open(file.toStdString().c_str(), SFM_READ, &sf_info); +  if(!fh) { +    printf("Load error...\n"); +    *size = 0; +    return NULL; +  } + +	*size = sf_seek(fh, 0, SEEK_END); +  data = new float[*size]; + +	sf_seek(fh, 0, SEEK_SET); +	sf_read_float(fh, data, *size);  + +	sf_close(fh); + +  return data; +} + +void AudioExtractor::exportSelection(QString name, +                                     int index, +                                     float *data, size_t size, +                                     Selection sel) +{ +  QString file = exportpath + "/" + prefix + "-" + name + "-" + QString::number(index) + ".wav"; + +  printf("Writing: %s (sz: %d, from %d to %d)\n", +         file.toStdString().c_str(), size, sel.from, sel.to); +   +  if(sel.from > (int)size || sel.to > (int)size || sel.to < 0 || sel.from < 0 || sel.to < sel.from) { +    printf("Out of bounds\n"); +    return; +  } + +  // Apply linear fadein +  for(int i = 0; i < sel.fadein; i++) { +    float val = ((float)i / (float)sel.fadein); +    data[i + sel.from] *= val; +  } + +  // Apply fadeout +  for(int i = 0; i < sel.fadeout; i++) { +    float val = ((float)i / (float)sel.fadeout); +    data[sel.to - i] *= val; +  } + +  SF_INFO sf_info; +  sf_info.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT; +  sf_info.samplerate = 44100; +  sf_info.channels = 1; + +  SNDFILE *fh = sf_open(file.toStdString().c_str(), SFM_WRITE, &sf_info); +  if(!fh) { +    printf("Open for write error...\n"); +    return; +  } +  sf_write_float(fh, data + sel.from, sel.to - sel.from);  +  sf_close(fh); +} + +void AudioExtractor::exportSelections(Selections selections) +{ +  QVector< QPair<QString, QString> >::iterator j = audiofiles.begin(); +  while(j != audiofiles.end()) { + +    QString file = j->first; +    QString name = j->second; +    size_t size; +    float *data = load(file, &size); +    if(!data) continue; + +    int index = 0; +    QMap<int, Selection>::iterator i = selections.begin(); +    while(i != selections.end()) { +      exportSelection(name, ++index, data, size, i.value()); +      i++; +    } + +    delete[] data; +     +    j++; +  } +} + +void AudioExtractor::addFile(QString file, QString name) +{ +  QPair<QString, QString> pair; +  pair.first = file; +  pair.second = name; +  audiofiles.push_back(pair); +} + +void AudioExtractor::removeFile(QString file) +{ +  QVector< QPair<QString, QString> >::iterator j = audiofiles.begin(); +  while(j != audiofiles.end()) { +    if(file == j->first) { +      audiofiles.erase(j); +      return; +    } +    j++; +  } +} + +void AudioExtractor::setOutputPrefix(QString p) +{ +  prefix = p; +} + +void AudioExtractor::setExportPath(QString path) +{ +  exportpath = path; +} + diff --git a/dgedit/audioextractor.h b/dgedit/audioextractor.h new file mode 100644 index 0000000..40fc8fd --- /dev/null +++ b/dgedit/audioextractor.h @@ -0,0 +1,58 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            audioextractor.h + * + *  Sat Nov 21 13:09:35 CET 2009 + *  Copyright 2009 Bent Bisballe Nyeng + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This file is part of DrumGizmo. + * + *  DrumGizmo is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  DrumGizmo is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with DrumGizmo; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. + */ +#ifndef __DRUMGIZMO_AUDIOEXTRACTOR_H__ +#define __DRUMGIZMO_AUDIOEXTRACTOR_H__ + +#include <QObject> +#include <QVector> +#include <QPair> +#include <QString> + +#include "selection.h" + +class AudioExtractor : public QObject { +Q_OBJECT +public: +  AudioExtractor(QObject *parent); + +  void addFile(QString file, QString name); +  void removeFile(QString file); +  void setExportPath(QString path); +  void setOutputPrefix(QString prefix); + +public slots: +  void exportSelections(Selections selections); + +private: +  float *load(QString file, size_t *size); +  void exportSelection(QString name, int index, float *data, size_t size, Selection sel); +  QVector< QPair<QString, QString> > audiofiles; +  QString exportpath; +  QString prefix; +}; + +#endif/*__DRUMGIZMO_AUDIOEXTRACTOR_H__*/ diff --git a/dgedit/canvas.cc b/dgedit/canvas.cc new file mode 100644 index 0000000..a487e27 --- /dev/null +++ b/dgedit/canvas.cc @@ -0,0 +1,508 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            canvas.cc + * + *  Tue Nov 10 08:37:37 CET 2009 + *  Copyright 2009 Bent Bisballe Nyeng + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This file is part of DrumGizmo. + * + *  DrumGizmo is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  DrumGizmo is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with DrumGizmo; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. + */ +#include "canvas.h" + +#include <sndfile.h> +#include <QMouseEvent> +#include <QPaintEvent> +#include <QPainter> +#include <QKeyEvent> + +#include <math.h> + +#define DEFYSCALE 200 +#define MIPMAPS 65536 + +Canvas::Canvas(QWidget *parent) +  : QWidget(parent) +{ +  setAttribute(Qt::WA_StaticContents); +  setMouseTracking(true); +  setFocusPolicy(Qt::ClickFocus); +  data = NULL; +  size = 0; +  xscale = 1.0; +  yscale = 1.0; +  xoffset = 0.0; +  yoffset = 0.5; + +  threshold = 0.5; +  threshold_is_moving = false; +  selection_is_moving_left = false; +  selection_is_moving_right = false; +  active_selection = NULL; + +  colBg = QColor(180, 200, 180); +  colSec = QColor(160, 180, 160); +  colWavMax = QColor(100, 100, 100); +  colWavAvg = QColor(0, 0, 0); +  colMax = QColor(127, 127, 255); +  colHalf = QColor(180, 180, 255); +  colThreshold = QColor(255, 127, 127); +  colThresholdMoving = QColor(180, 0, 0); +  colSelBg = QColor(255, 0, 0, 60); +  colSel = QColor(255, 0, 0, 160); +  colActiveSelBg = QColor(255, 255, 0, 60); +  colActiveSel = QColor(255, 255, 0, 160); + +  setCursor(Qt::ArrowCursor); +   +  wav = QImage(width(), height(), QImage::Format_RGB32); +} + +Canvas::~Canvas() +{ +  if(data) delete[] data; +} + + +#define VALL(x) (x*2) +#define VALU(x) (x*2+1) +#define POWL(x) (x*2+2) +#define POWU(x) (x*2+3) +void Canvas::load(QString file) +{ +  if(data) { +    delete[] data; +    data = NULL; +    size = 0; + +    QMap<int, float*>::iterator i = mipmaps.begin(); +    while(i != mipmaps.end()) { +      delete[] i.value(); +      i++; +    } + +  } + +  SF_INFO sf_info; +	SNDFILE *fh = sf_open(file.toStdString().c_str(), SFM_READ, &sf_info); +  if(!fh) { +    printf("Load error...\n"); +  } + +	size = sf_seek(fh, 0, SEEK_END); +  data = new float[size]; + +	sf_seek(fh, 0, SEEK_SET); +	sf_read_float(fh, data, size);  + +	sf_close(fh); + +  for(size_t dev = 2; dev <= MIPMAPS; dev*=2) { +    size_t mipmapsize = size/dev; + +    float *lookup = new float[mipmapsize * 4]; +    for(size_t i = 0; i < mipmapsize; i++) { +      lookup[VALL(i)] = 0.0; +      lookup[VALU(i)] = 0.0; +      lookup[POWL(i)] = 0.0; +      lookup[POWU(i)] = 0.0; +      for(size_t j = i * dev; j < (i + 1) * dev; j++) { +        if(data[j] > lookup[VALU(i)]) lookup[VALU(i)] = data[j]; +        if(data[j] < lookup[VALL(i)]) lookup[VALL(i)] = data[j]; +        if(data[j] > 0) lookup[POWU(i)] += data[j]; +        if(data[j] < 0) lookup[POWL(i)] += data[j]; +      } +    } + +    mipmaps[dev] = lookup; +  } +} + + +#define SCALEX ((xscale * (float)size/(float)width()) + 0.1) +#define OFFSETX (xoffset * (float)size) +float Canvas::mapX(float x) +{ +  float val = (x - OFFSETX) / SCALEX; +  return val; +} + +float Canvas::unmapX(float x) +{ +  float val = x * SCALEX + OFFSETX; +  return val; +} + +#define SCALEY ((yscale * 999.0 + 1.0 ) * (float)DEFYSCALE) +#define OFFSETY (((float)height() / 2.0) + ((yoffset * 2.0 - 1.0) * SCALEY)) +float Canvas::mapY(float y) +{ +  float val = OFFSETY + (y * SCALEY); +  return val; +} + +float Canvas::unmapY(float y) +{ +  float val = (y - OFFSETY) / SCALEY; +  return val; +} + +void Canvas::mouseMoveEvent(QMouseEvent *event) +{ +  if(threshold_is_moving) { +    float val = unmapY(event->y()); +    if(fabs(val) > 1.0) val = 1.0; +    threshold = fabs(val); +    update(); +    return; +  } + +  if(selection_is_moving_left) { +    float val = unmapX(event->x()); +    if(val > active_selection->to) val = active_selection->to - 1; +    active_selection->from = val; +    update(); +    return; +  } + +  if(selection_is_moving_right) { +    float val = unmapX(event->x()); +    if(val < active_selection->from) val = active_selection->from + 1; +    active_selection->to = val; +    update(); +    return; +  } + +  if(event->button() != Qt::LeftButton) { +    if(abs(event->y() - mapY(threshold)) < 2 || +       abs(event->y() - mapY(-threshold)) < 2 ) { +      setCursor(Qt::SplitVCursor); +    } else { +      setCursor(Qt::ArrowCursor); +    } + +    // Check if a selection is being dragged. +    QMap<int, Selection>::iterator i = _selections.begin(); +    while(i != _selections.end()) { +      if(abs(event->x() - mapX(i.value().from)) < 2 +        || abs(event->x() - mapX(i.value().to)) < 2) { +        setCursor(Qt::SplitHCursor); +      } +      i++; +    } +  } +} + +void Canvas::mousePressEvent(QMouseEvent *event) +{ +  if(event->button() == Qt::LeftButton) { + +    // Check if threshold is being dragged. +    if(abs(event->y() - mapY(threshold)) < 2 || +       abs(event->y() - mapY(-threshold)) < 2 ) { +      threshold_is_moving = true; +      update(); +      return; +    } + +    // Check if a selection is being dragged. +    QMap<int, Selection>::iterator i = _selections.begin(); +    while(i != _selections.end()) { +      if(abs(event->x() - mapX(i.value().from)) < 2) { +        active_selection = &i.value(); +        selection_is_moving_left = true; +        return; +      } + +      if(abs(event->x() - mapX(i.value().to)) < 2) { +        active_selection = &i.value(); +        selection_is_moving_right = true; +        return; +      } + +      i++; +    } + +    // Check if a selection is being selected. +    i = _selections.begin(); +    while(i != _selections.end()) { +      if(event->x() > mapX(i.value().from) && +         event->x() < mapX(i.value().to)) { +        active_selection = &i.value(); +        update(); +        return; +      } + +      i++; +    } + +    // Make new selection +    int from = unmapX(event->x()); +    _selections[from] = Selection(from, from); +    active_selection = &_selections[from]; +    selection_is_moving_right = true; +    update(); +    return; +  } +} + +void Canvas::mouseReleaseEvent(QMouseEvent *event) +{ +  if(event->button() == Qt::LeftButton) { +    if(threshold_is_moving) { +      threshold_is_moving = false; +      setCursor(Qt::ArrowCursor); +      update(); +      return; +    } +    if(selection_is_moving_left || selection_is_moving_right) { +      selection_is_moving_left = false; +      selection_is_moving_right = false; +      setCursor(Qt::ArrowCursor); +      update(); +      return; +    } +  } +} + +void Canvas::resizeEvent(QResizeEvent *) +{ +  wav = QImage(width(), height(), QImage::Format_RGB32); +  updateWav(); +  update(); +} + +void Canvas::getWavValues(int last, int lx, float *vu, float *vl, float *avgu, float *avgl) +{ +  float *lookup = data; +  int dev = 1; + +  int i = 2; +  while(i < (lx - last) && mipmaps.find(i) != mipmaps.end()) { +    lookup = mipmaps[i]; +    dev = i; +    i *= 2; +  } + +  *vu = *vl = *avgu = *avgl = 0; +  for(int i = last / dev; i < lx / dev; i++) { +    float lval; +    float uval; +    float lpow; +    float upow; +    if(dev > 1) { +      lval = -lookup[VALL(i)]; +      uval = -lookup[VALU(i)]; +      upow = -lookup[POWL(i)]; +      lpow = -lookup[POWU(i)]; +    } else { +      lpow = upow = lval = uval = -lookup[i]; +    } +    if(lpow < 0.0) *avgl += lpow; +    if(upow > 0.0) *avgu += upow; +    if(lval > *vl) *vl = lval; +    if(uval < *vu) *vu = uval; +  } +   +  if((lx - last) != 0) { +    *avgu /= (float)(lx - last); +    *avgl /= (float)(lx - last); +  } +} + +void Canvas::updateWav() +{ +  QPainter painter(&wav); + +  painter.setPen(colBg); +  painter.setBrush(colBg); +  painter.drawRect(0, 0, wav.width(), wav.height()); + +  painter.setPen(colSec); +  int step = 44100; +  for(size_t i = 0; i < size; i += step) { +    painter.drawLine(mapX(i), mapY(1.0), mapX(i), mapY(-1.0)); +  } + +  painter.setPen(colMax); +  painter.drawLine(0, mapY(1.0), wav.width(), mapY(1.0)); +  painter.drawLine(0, mapY(-1.0), wav.width(), mapY(-1.0)); + +  painter.setPen(colHalf); +  painter.drawLine(0, mapY(0.5), wav.width(), mapY(0.5)); +  painter.drawLine(0, mapY(-0.5), wav.width(), mapY(-0.5)); + +  if(data) { +    int last = unmapX(0); +    for(int x = 0; x < wav.width(); x++) { +      int lx = unmapX(x); +      if(lx > (int)size || lx < 0) break; +      float vu = 0; +      float vl = 0; +      float avgu = 0; +      float avgl = 0; + +      getWavValues(last, lx, &vu, &vl, &avgu, &avgl); +       +      int c = mapY(0.0); + +      painter.setPen(colWavMax); +      painter.drawLine(x, c, x, mapY(vu)); +      painter.drawLine(x, c, x, mapY(vl)); + +      painter.setPen(colWavAvg); +      painter.drawLine(x, c, x, mapY(avgu)); +      painter.drawLine(x, c, x, mapY(avgl)); + +      last = lx; +    } +  } +} + +void Canvas::paintEvent(QPaintEvent *event) +{ +  QPainter painter(this); + +  painter.drawImage(event->rect(),wav,event->rect()); + +  if(threshold_is_moving) painter.setPen(colThresholdMoving); +  else painter.setPen(colThreshold); +  painter.drawLine(event->rect().x(), mapY(threshold), +                   event->rect().x() + event->rect().width(), mapY(threshold)); +  painter.drawLine(event->rect().x(), mapY(-threshold), +                   event->rect().x() + event->rect().width(), mapY(-threshold)); + +  int pos = unmapX(event->rect().x()); +  int width = unmapX(event->rect().width()); +  QMap<int, Selection>::iterator i = _selections.begin(); +  while(i != _selections.end()) { +    int from = i.value().from; +    int to = i.value().to; +    int fadein = i.value().fadein; +    int fadeout = i.value().fadeout; +    if(from > pos + width || to + width < pos) { i++; continue; } +    if(active_selection == &i.value()) { +      painter.setBrush(colActiveSelBg); +      painter.setPen(colActiveSel); +    } else { +      painter.setBrush(colSelBg); +      painter.setPen(colSel); +    } +    painter.drawRect(mapX(from), mapY(-1.0), mapX(to) - mapX(from), mapY(1.0) - mapY(-1.0)); +    painter.drawLine(mapX(from), mapY(0.0), mapX(from + fadein), mapY(-1.0)); +    painter.drawLine(mapX(from), mapY(0.0), mapX(from + fadein), mapY(1.0)); +    painter.drawLine(mapX(to - fadeout), mapY(-1.0), mapX(to), mapY(0.0)); +    painter.drawLine(mapX(to - fadeout), mapY(1.0), mapX(to), mapY(0.0)); +    i++; +  } +}  + +void Canvas::keyReleaseEvent(QKeyEvent *event) +{ +  if(active_selection && event->key() == Qt::Key_Delete) { +    _selections.remove(active_selection->from); +    update(); +  } +} + +void Canvas::setXScale(float scale) +{ +  scale = (pow(100.0,scale) / 100.0) - (pow(100.0, 0.0)/ 100.0); +  if(scale < 0.0) scale = 0.0; +  if(scale > 1.0) scale = 1.0; +  xscale = scale; +  updateWav(); +  update(); +} + +void Canvas::setYScale(float scale) +{  +  scale = (pow(100.0,scale) / 100.0) - (pow(100.0, 0.0)/ 100.0); +  if(scale < 0.0) scale = 0.0; +  if(scale > 1.0) scale = 1.0; +  yscale = scale; +  updateWav(); +  update(); +} + +void Canvas::setXOffset(float offset) +{ +  if(offset < 0.0) offset = 0.0; +  if(offset > 1.0) offset = 1.0; +  xoffset = offset; +  updateWav(); +  update(); +} + +void Canvas::setYOffset(float offset) +{ +  if(offset < 0.0) offset = 0.0; +  if(offset > 1.0) offset = 1.0; +  yoffset = offset; +  updateWav(); +  update(); +} + +void Canvas::autoCreateSelections() +{ +  for(size_t i = 0; i < size; i++) { +    if(fabs(data[i]) > fabs(threshold)) { +      int from = i; + +      if(data[from] > 0.0) { +        while(data[from] > data[from-1] // Falling +              && data[from-1] > 0.0 // Not crossing zero +              ) { +          from--; +        } +      } else if(data[from] < 0.0) { +        while(data[from] < data[from-1] // Rising +              && data[from-1] < 0.0 // Not crossing zero +              ) { +          from--; +        } +      } + +      int to = i; +      float runavg = fabs(data[to]); +      while(runavg > 0.001 && to < (int)size) { +        runavg = runavg * 0.99999 + fabs(data[to]) * 0.00001; +        to++; +      } +      _selections[from] = Selection(from, to, 2, (to - from) / 3); + +      i = to+1; +    } +  } +  update(); +} + +void Canvas::clearSelections() +{ +  _selections.clear(); +  selection_is_moving_left = false; +  selection_is_moving_right = false; +  setCursor(Qt::ArrowCursor); +  update(); +} + +Selections Canvas::selections() +{ +  return _selections; +} diff --git a/dgedit/canvas.h b/dgedit/canvas.h new file mode 100644 index 0000000..274e222 --- /dev/null +++ b/dgedit/canvas.h @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            canvas.h + * + *  Tue Nov 10 08:37:37 CET 2009 + *  Copyright 2009 Bent Bisballe Nyeng + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This file is part of DrumGizmo. + * + *  DrumGizmo is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  DrumGizmo is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with DrumGizmo; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. + */ +#ifndef __DRUMGIZMO_CANVAS_H__ +#define __DRUMGIZMO_CANVAS_H__ + +#include <QWidget> +#include <QColor> +#include <QImage> + +#include "selection.h" + +class Canvas : public QWidget { +Q_OBJECT +public: +  Canvas(QWidget *parent); +  ~Canvas(); + +  void load(QString file); + +  Selections selections(); + +signals: + +public slots: +  void setXScale(float scale); +  void setYScale(float scale); +  void setXOffset(float scroll); +  void setYOffset(float scroll); +  void autoCreateSelections(); +  void clearSelections(); + +protected: +  void mouseMoveEvent(QMouseEvent *event); +  void mousePressEvent(QMouseEvent *event); +  void mouseReleaseEvent(QMouseEvent *event); +  void resizeEvent(QResizeEvent *event); +  void paintEvent(QPaintEvent *event); +  void keyReleaseEvent(QKeyEvent *event); + +private: +  void updateWav(); +  void getWavValues(int last, int lx, float *vu, float *vl, float *avgu, float *avgl); +  float mapX(float x); +  float unmapX(float x); +  float mapY(float y); +  float unmapY(float y); + +  QImage wav; + +  float *data; +  QMap<int, float *> mipmaps; +  size_t size; + +  float xscale; +  float yscale; +  float xoffset; +  float yoffset; + +  float threshold; +  bool threshold_is_moving; +  bool selection_is_moving_left; +  bool selection_is_moving_right; +  Selection *active_selection; + +  QColor colBg; +  QColor colSec; +  QColor colMax; +  QColor colHalf; +  QColor colWavMax; +  QColor colWavAvg; +  QColor colThreshold; +  QColor colThresholdMoving; +  QColor colSelBg; +  QColor colSel; +  QColor colActiveSelBg; +  QColor colActiveSel; + +  Selections _selections; +}; + +#endif/*__DRUMGIZMO_CANVAS_H__*/ diff --git a/dgedit/dgedit.cc b/dgedit/dgedit.cc new file mode 100644 index 0000000..0417876 --- /dev/null +++ b/dgedit/dgedit.cc @@ -0,0 +1,39 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            editor.cc + * + *  Tue Nov 10 08:37:43 CET 2009 + *  Copyright 2009 Bent Bisballe Nyeng + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This file is part of DrumGizmo. + * + *  DrumGizmo is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  DrumGizmo is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with DrumGizmo; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. + */ +#include <QApplication> + +#include "mainwindow.h" + +int main(int argc, char *argv[]) +{ +  QApplication app(argc, argv); + +  MainWindow wnd; +  wnd.show(); + +  return app.exec(); +} diff --git a/dgedit/mainwindow.cc b/dgedit/mainwindow.cc new file mode 100644 index 0000000..db442e6 --- /dev/null +++ b/dgedit/mainwindow.cc @@ -0,0 +1,145 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            mainwindow.cc + * + *  Tue Nov 10 10:21:04 CET 2009 + *  Copyright 2009 Bent Bisballe Nyeng + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This file is part of DrumGizmo. + * + *  DrumGizmo is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  DrumGizmo is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with DrumGizmo; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. + */ +#include "mainwindow.h" + +#include <QHBoxLayout> +#include <QVBoxLayout> + +#include <QPushButton> + +#define MAXVAL 10000000L +#define SINGLESTEP MAXVAL/100000 +#define PAGESTEP MAXVAL/10000 + +MainWindow::MainWindow() +{ +  QHBoxLayout *lh = new QHBoxLayout(); +  QVBoxLayout *lv = new QVBoxLayout(); +  setLayout(lv); + +  extractor = new AudioExtractor(this); +  canvas = new Canvas(this); +  lh->addWidget(canvas); + +  yoffset = new QScrollBar(Qt::Vertical); +  yoffset->setRange(0, MAXVAL); +  yoffset->setPageStep(PAGESTEP); +  yoffset->setSingleStep(SINGLESTEP); +  connect(yoffset, SIGNAL(valueChanged(int)), this, SLOT(setYOffset(int))); + +  yscale = new QScrollBar(Qt::Vertical); +  yscale->setRange(0, MAXVAL); +  yscale->setPageStep(PAGESTEP); +  yscale->setSingleStep(SINGLESTEP); +  connect(yscale, SIGNAL(valueChanged(int)), this, SLOT(setYScale(int))); + +  xscale = new QScrollBar(Qt::Horizontal); +  xscale->setRange(0, MAXVAL); +  xscale->setPageStep(PAGESTEP); +  xscale->setSingleStep(SINGLESTEP); +  connect(xscale, SIGNAL(valueChanged(int)), this, SLOT(setXScale(int))); + +  xoffset = new QScrollBar(Qt::Horizontal); +  xoffset->setRange(0, MAXVAL); +  xoffset->setPageStep(PAGESTEP); +  xoffset->setSingleStep(SINGLESTEP); +  connect(xoffset, SIGNAL(valueChanged(int)), this, SLOT(setXOffset(int))); + +  QPushButton *autosel = new QPushButton(); +  autosel->setText("Auto"); +  connect(autosel, SIGNAL(clicked()), canvas, SLOT(clearSelections())); +  connect(autosel, SIGNAL(clicked()), canvas, SLOT(autoCreateSelections())); + +  QPushButton *clearsel = new QPushButton(); +  clearsel->setText("Clear"); +  connect(clearsel, SIGNAL(clicked()), canvas, SLOT(clearSelections())); + +  QPushButton *exportsel = new QPushButton(); +  exportsel->setText("Export"); +  connect(exportsel, SIGNAL(clicked()), this, SLOT(doExport())); + +  lh->addWidget(yscale); +  lh->addWidget(yoffset); +  lv->addLayout(lh); +  lv->addWidget(xscale); +  lv->addWidget(xoffset); +  lv->addWidget(autosel); +  lv->addWidget(clearsel); +  lv->addWidget(exportsel); + +  extractor->setExportPath("/home/deva/tmp/drumgizmoexport"); +  extractor->setOutputPrefix("china"); +  extractor->addFile("/home/deva/aasimonster/tmp/china/Amb L-20.wav", "amb-l"); +  extractor->addFile("/home/deva/aasimonster/tmp/china/Amb R-20.wav", "amb-r"); +  extractor->addFile("/home/deva/aasimonster/tmp/china/OH L-20.wav", "oh-l"); +  extractor->addFile("/home/deva/aasimonster/tmp/china/OH R-20.wav", "oh-r"); + +  canvas->load("/home/deva/aasimonster/tmp/china/OH L-20.wav"); + +  yscale->setValue(MAXVAL); +  yoffset->setValue(MAXVAL/2); +  xscale->setValue(0); +  xoffset->setValue(0); + +  resize(800, 600); +} + +void MainWindow::setXScale(int sz) +{ +  // range 0.0 - 1.0 +  float val = (float)(sz * -1 + MAXVAL)/(float)MAXVAL; +  canvas->setXScale(val); +  if(val < 0.001) val = 0.001; +  xoffset->setPageStep(PAGESTEP * 10 * val); +  xoffset->setSingleStep(SINGLESTEP * 10 * val); +} + +void MainWindow::setYScale(int sz) +{ +  // range 0.0 - 1.0 +  float val = (float)(sz * -1 + MAXVAL)/(float)MAXVAL; +  canvas->setYScale(val); +} + +void MainWindow::setXOffset(int of) +{ +  // range 0.0 - 1.0 +  float val = (float)of/(float)MAXVAL; +  canvas->setXOffset(val); +} + +void MainWindow::setYOffset(int of) +{ +  // range 0.0 - 1.0 +  float val = (float)(of * -1 + MAXVAL)/(float)MAXVAL; +  canvas->setYOffset(val); +} + +void MainWindow::doExport() +{ +  extractor->exportSelections(canvas->selections()); +} diff --git a/dgedit/mainwindow.h b/dgedit/mainwindow.h new file mode 100644 index 0000000..af17970 --- /dev/null +++ b/dgedit/mainwindow.h @@ -0,0 +1,57 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            mainwindow.h + * + *  Tue Nov 10 10:21:03 CET 2009 + *  Copyright 2009 Bent Bisballe Nyeng + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This file is part of DrumGizmo. + * + *  DrumGizmo is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  DrumGizmo is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with DrumGizmo; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. + */ +#ifndef __DRUMGIZMO_MAINWINDOW_H__ +#define __DRUMGIZMO_MAINWINDOW_H__ + +#include <QWidget> +#include <QScrollBar> + +#include "canvas.h" +#include "audioextractor.h" + +class MainWindow : public QWidget { +Q_OBJECT +public: +  MainWindow(); + +public slots: +  void setXScale(int); +  void setYScale(int); +  void setXOffset(int); +  void setYOffset(int); +  void doExport(); + +private: +  Canvas *canvas; +  AudioExtractor *extractor; +  QScrollBar *yoffset; +  QScrollBar *yscale; +  QScrollBar *xscale; +  QScrollBar *xoffset; +}; + +#endif/*__DRUMGIZMO_MAINWINDOW_H__*/ diff --git a/dgedit/selection.h b/dgedit/selection.h new file mode 100644 index 0000000..02d5163 --- /dev/null +++ b/dgedit/selection.h @@ -0,0 +1,48 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/*************************************************************************** + *            selection.h + * + *  Sat Nov 21 13:20:46 CET 2009 + *  Copyright 2009 Bent Bisballe Nyeng + *  deva@aasimon.org + ****************************************************************************/ + +/* + *  This file is part of DrumGizmo. + * + *  DrumGizmo is free software; you can redistribute it and/or modify + *  it under the terms of the GNU General Public License as published by + *  the Free Software Foundation; either version 2 of the License, or + *  (at your option) any later version. + * + *  DrumGizmo is distributed in the hope that it will be useful, + *  but WITHOUT ANY WARRANTY; without even the implied warranty of + *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the + *  GNU General Public License for more details. + * + *  You should have received a copy of the GNU General Public License + *  along with DrumGizmo; if not, write to the Free Software + *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. + */ +#ifndef __DRUMGIZMO_SELECTION_H__ +#define __DRUMGIZMO_SELECTION_H__ + +#include <QMap> + +class Selection { +public: +  Selection(int from = 0, int to = 0, int fadein = 0, int fadeout = 0) { +    this->from = from; +    this->to = to; +    this->fadein = fadein; +    this->fadeout = fadeout; +  } +  int from; +  int to; +  int fadein; +  int fadeout; +}; + +typedef QMap<int, Selection> Selections; + +#endif/*__DRUMGIZMO_SELECTION_H__*/ diff --git a/src/Makefile.am b/src/Makefile.am index 2108c43..5ec0802 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1,8 +1,8 @@  bin_PROGRAMS = drumgizmo -drumgizmo_LDADD = $(JACK_LIBS) $(SNDFILE_LIBS) +drumgizmo_LDADD = $(JACK_LIBS) $(SNDFILE_LIBS) $(SMF_LIBS) -drumgizmo_CXXFLAGS = $(JACK_CXXFLAGS) $(SNDFILE_CXXFLAGS) +drumgizmo_CXXFLAGS = $(JACK_CXXFLAGS) $(SNDFILE_CXXFLAGS) $(SMF_CFLAGS)  drumgizmo_SOURCES = \  	audiofile.cc \ diff --git a/src/audiofile.cc b/src/audiofile.cc index a556bca..9c00bed 100644 --- a/src/audiofile.cc +++ b/src/audiofile.cc @@ -41,12 +41,12 @@ AudioFile::AudioFile(std::string filename, bool preload, int min_velocity)    int num = atoi(p);    if(num < 0) num *= -1; -  printf("%s", filename.c_str()); +  //printf("%s", filename.c_str());    if(preload && num  >= min_velocity) { -    printf(" ... loading"); +    //printf(" ... loading");      load();    } -  printf("\n"); +  printf("."); fflush(stdout);  }  AudioFile::~AudioFile() diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index a4d863f..3941f17 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -136,7 +136,11 @@ int main(int argc, char *argv[])    client.activate(); -  if(midifile) MidiPlayer player(midifile); +  if(midifile) { +    MidiPlayer player(midifile); +     +    while(1) sleep(1); +  }    while(1) sleep(1); diff --git a/src/midimapper.cc b/src/midimapper.cc index 1d2c7a8..6bf38c7 100644 --- a/src/midimapper.cc +++ b/src/midimapper.cc @@ -26,7 +26,7 @@   */  #include "midimapper.h" -#define NOTE_ON 0x90 +#define NOTE_ON 0x9  MidiMapper::MidiMapper(DrumKit *drumkit)  { @@ -64,8 +64,10 @@ Sample *MidiMapper::map(jack_midi_event_t event)  {    Sample *sample = NULL; +  //  printf("m"); fflush(stdout); +    if(event.size != 3) return NULL; -  if(event.buffer[0] != NOTE_ON) return NULL; +  if(event.buffer[0] & NOTE_ON != NOTE_ON) return NULL;    int key = event.buffer[1];    int velocity = event.buffer[2]; @@ -81,7 +83,7 @@ Sample *MidiMapper::map(jack_midi_event_t event)    printf("]\n");    */    if(drumkit->instruments.find(key) == drumkit->instruments.end()) { -    printf("Unknown intrsument %d\n", key); +    printf("Unknown instrument %d\n", key);      return NULL;    } diff --git a/src/midiplayer.cc b/src/midiplayer.cc index f8c462b..b55b225 100644 --- a/src/midiplayer.cc +++ b/src/midiplayer.cc @@ -26,8 +26,6 @@   */  #include "midiplayer.h" -#define NOTE_ON 0x90 -  int _process(jack_nframes_t nframes, void *arg)  {    return ((MidiPlayer*)arg)->process(nframes); @@ -35,9 +33,16 @@ int _process(jack_nframes_t nframes, void *arg)  MidiPlayer::MidiPlayer(std::string filename)  { +  timeline = 0; +  cur_event = NULL; + +  printf("Loading MIDI file: %s\n", filename.c_str()); +  smf = smf_load(filename.c_str()); +  printf("done\n"); +  	jack_status_t status; -  jack_client_t *jack_client = jack_client_open("MidiTest", JackNullOption, &status); +  jack_client_t *jack_client = jack_client_open("MidiGizmo", JackNullOption, &status);  	port = jack_port_register(jack_client,                              "midi_out", @@ -49,8 +54,9 @@ MidiPlayer::MidiPlayer(std::string filename)  	jack_activate(jack_client); -  jack_connect(jack_client, "MidiTest:midi_out", "DrumGizmo:midi_in"); +  jack_connect(jack_client, "MidiGizmo:midi_out", "DrumGizmo:midi_in"); +  jack_connect(jack_client, "DrumGizmo:Alesis", "system:playback_1");    jack_connect(jack_client, "DrumGizmo:Kick-R", "system:playback_1");    jack_connect(jack_client, "DrumGizmo:Kick-L", "system:playback_1");    jack_connect(jack_client, "DrumGizmo:SnareTop", "system:playback_1"); @@ -63,6 +69,7 @@ MidiPlayer::MidiPlayer(std::string filename)    jack_connect(jack_client, "DrumGizmo:Ride", "system:playback_1");    //  jack_connect(jack_client, "DrumGizmo:Hihat", "system:playback_1"); +  jack_connect(jack_client, "DrumGizmo:Alesis", "system:playback_2");    jack_connect(jack_client, "DrumGizmo:Kick-R", "system:playback_2");    jack_connect(jack_client, "DrumGizmo:Kick-L", "system:playback_2");    jack_connect(jack_client, "DrumGizmo:SnareTop", "system:playback_2"); @@ -80,12 +87,15 @@ MidiPlayer::MidiPlayer(std::string filename)    jack_connect(jack_client, "DrumGizmo:Amb-R", "system:playback_1");    jack_connect(jack_client, "DrumGizmo:Amb-L", "system:playback_2"); +  /*    timer = 0;    next = 44100; +  */  }  MidiPlayer::~MidiPlayer()  { +  smf_delete(smf);  }  #if 0 // All @@ -93,12 +103,12 @@ MidiPlayer::~MidiPlayer()  static int inst[] = { 35, 36, 38, 46, 41, 43, 45, 47, 49, 57, 51 };  #endif -#if 1 // Cymbals +#if 0 // Cymbals  #define NUM_INST 3  static int inst[] = { 51, 49, 57 };  #endif -#if 0 // Toms +#if 1 // Toms  #define NUM_INST 4  static int inst[] = { 41, 43, 45, 47 };  #endif @@ -109,13 +119,42 @@ static int inst[] = { 35, 36 };  #endif  int MidiPlayer::process(jack_nframes_t nframes)  { -  return 0; -    //  if(jack_port_connected_to(test_midi_port, "DrumGizmo:midi_in")) {    void* port_buf = jack_port_get_buffer(port, nframes); +     + +  double cur_max_time = (double)(timeline + nframes) / 44100.0; +  double cur_min_time = (double)(timeline) / 44100.0; + +  printf("["); fflush(stdout); + +  if(!cur_event) cur_event = smf_get_next_event(smf); +  do { +    if(cur_event) { +      if(!smf_event_is_metadata(cur_event)) { + +        printf("p"); fflush(stdout); + +        jack_nframes_t time = (jack_nframes_t)((cur_event->time_seconds - cur_min_time) * 44100.0); +        jack_midi_event_write(port_buf, time, (jack_midi_data_t*)cur_event->midi_buffer, +                              cur_event->midi_buffer_length); +      } +    } else { +      smf_rewind(smf); +    } +    cur_event = smf_get_next_event(smf); +    while(!cur_event) cur_event = smf_get_next_event(smf); +  } while(cur_event->time_seconds < cur_max_time && cur_event->time_seconds >= cur_min_time); + +  timeline += nframes; + +  printf("]\n"); fflush(stdout); + + +  /*    if(timer > next) { // activate every second (44100 samples) -    //    printf("ding\n"); +      jack_nframes_t time = (jack_nframes_t)(((float)rand() / (float)RAND_MAX) * nframes);      size_t size = 3; @@ -127,6 +166,7 @@ int MidiPlayer::process(jack_nframes_t nframes)    }    timer += nframes; +  */    return 0;  } diff --git a/src/midiplayer.h b/src/midiplayer.h index 3694939..e41c73a 100644 --- a/src/midiplayer.h +++ b/src/midiplayer.h @@ -30,6 +30,7 @@  #include <jack/jack.h>  #include <jack/midiport.h>  #include <string> +#include <smf.h>  class MidiPlayer {  public: @@ -44,6 +45,10 @@ private:    size_t timer;    size_t next; + +  smf_t *smf; +  smf_event_t *cur_event; +  unsigned int timeline;  };  #endif/*__DRUMGIZMO_MIDIPLAYER_H__*/ diff --git a/tools/MocList b/tools/MocList new file mode 100755 index 0000000..639b668 --- /dev/null +++ b/tools/MocList @@ -0,0 +1,9 @@ +# -*- mode: shell-script; sh-shell: bash; sh-indentation: 2 -*- +if [ "$1" = "cc" ]; then +	grep "Q_OBJECT" *.h | cut -d: -f1 | sed -e 's/^//g;s/\.h/\.moc.cc/g'| xargs echo; +elif [ "$1" = "o" ]; then +	grep "Q_OBJECT" *.h | cut -d: -f1 | sed -e 's/^//g;s/\.h/\.moc.o/g'| xargs echo; +elif [ "$1" = "h" ]; then +	grep "Q_OBJECT" *.h | cut -d: -f1 | cut -d'/' -f3 | xargs echo; +fi + | 
