summaryrefslogtreecommitdiff
path: root/src/drumgizmo.cc
blob: 5e141793747e515e7de491082e0d526be177b578 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/***************************************************************************
 *            drumgizmo.cc
 *
 *  Thu Sep 16 10:24:40 CEST 2010
 *  Copyright 2010 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 "drumgizmo.h"

#include <math.h>
#include <stdio.h>

#include <event.h>
#include <audiotypes.h>

#include <string.h>

#include <hugin.hpp>

#include "drumkitparser.h"
#include "audioinputenginemidi.h"
#include "configuration.h"

DrumGizmo::DrumGizmo(AudioOutputEngine *o, AudioInputEngine *i)
  : MessageReceiver(MSGRCV_ENGINE),
    loader(this), oe(o), ie(i)
{
  loader.run(); // Start drumkit loader thread.
}

DrumGizmo::~DrumGizmo()
{
  /*
  AudioFiles::iterator i = audiofiles.begin();
  while(i != audiofiles.end()) {
    AudioFile *audiofile = i->second;
    delete audiofile;
    i++;
  }
  */
  loader.stop();
}

std::string DrumGizmo::drumkitfile()
{
  return kitfile;
}

bool DrumGizmo::loadkit(std::string file)
{
  if(file == this->kitfile) return 1;
  if(file == "") return 1;

  this->kitfile = file;

  DEBUG(drumgizmo, "loadkit(%s)\n", kitfile.c_str());

  loader.skip();

  kit.clear();

  DrumKitParser parser(kitfile, kit);
  if(parser.parse()) {
    ERR(drumgizmo, "Drumkit parser failed: %s\n", kitfile.c_str());
    return false;
  }

  loader.loadKit(&kit);

  DEBUG(loadkit, "loadkit: Success\n");

  return true;
}

bool DrumGizmo::init(bool preload)
{
  if(preload) {
    /*
    AudioFiles::iterator i = audiofiles.begin();
    while(i != audiofiles.end()) {
      AudioFile *audiofile = i->second;
      audiofile->load();
      i++;
    }
    */
  }

  if(!ie->init(kit.instruments)) return false;
  if(!oe->init(kit.channels)) return false;

  return true;
}

void DrumGizmo::handleMessage(Message *msg)
{
  DEBUG(msg, "got message.");
  switch(msg->type()) {
  case Message::RegisterUIMessage:
    {
      DEBUG(msg, "got RegisterUIMessage message.");
      RegisterUIMessage *m = (RegisterUIMessage*)msg;
      ui = m->messagehandler;
    }
    break;
  case Message::LoadDrumKit:
    {
      DEBUG(msg, "got LoadDrumKitMessage message.");
      LoadDrumKitMessage *m = (LoadDrumKitMessage*)msg;
      loadkit(m->drumkitfile);
      //init(true);
    }
    break;
  case Message::LoadMidimap:
    DEBUG(msg, "got LoadMidimapMessage message.");
    if(!ie->isMidiEngine()) break;
    {
      AudioInputEngineMidi *aim = (AudioInputEngineMidi*)ie;
      LoadMidimapMessage *m = (LoadMidimapMessage*)msg;
      bool ret = aim->loadMidiMap(m->midimapfile, kit.instruments);
      
      LoadStatusMessageMidimap *ls = new LoadStatusMessageMidimap();
      ls->success = ret;
      msghandler.sendMessage(MSGRCV_UI, ls);
    }
    break;
  case Message::EngineSettingsMessage:
    {
      DEBUG(msg, "--------------- Send: EngineSettingsMessage ------------ \n");
      
      bool mmap_loaded = false;
      std::string mmapfile;
      if(ie->isMidiEngine()) {
        AudioInputEngineMidi *aim = (AudioInputEngineMidi*)ie;
        mmapfile = aim->midimapFile();
        mmap_loaded = aim->isValid();
      }
      
      EngineSettingsMessage *msg = new EngineSettingsMessage();
      msg->midimapfile = mmapfile;
      msg->midimap_loaded = mmap_loaded;
      msg->drumkitfile = drumkitfile();
      msg->drumkit_loaded = loader.isDone();
      msg->enable_velocity_modifier = Conf::enable_velocity_modifier;
      msg->velocity_modifier_falloff = Conf::velocity_modifier_falloff;
      msg->velocity_modifier_weight = Conf::velocity_modifier_weight;
      msg->enable_velocity_randomiser = Conf::enable_velocity_randomiser;
      msg->velocity_randomiser_weight = Conf::velocity_randomiser_weight;
      msghandler.sendMessage(MSGRCV_UI, msg);
    }
    break;
  case Message::ChangeSettingMessage:
    {
      ChangeSettingMessage *ch = (ChangeSettingMessage*)msg;
      switch(ch->name) {
      case ChangeSettingMessage::enable_velocity_modifier:
        Conf::enable_velocity_modifier = ch->value;
        break;
      case ChangeSettingMessage::velocity_modifier_weight:
        Conf::velocity_modifier_weight = ch->value;
        break;
      case ChangeSettingMessage::velocity_modifier_falloff:
        Conf::velocity_modifier_falloff = ch->value;
        break;
      }
    }
    break;
  default:
    break;
  }
}

bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples)
{
  // Handle engine messages, at most one in each iteration:
  handleMessages(1);

  ie->pre();
  oe->pre(nsamples);

  //
  // Read new events
  //

  //DEBUG(engine, "Number of active events: %d\n", activeevents[0].size());

  size_t nev;
  event_t *evs = ie->run(pos, nsamples, &nev);

  for(size_t e = 0; e < nev; e++) {
    if(evs[e].type == TYPE_ONSET) {
      Instrument *i = NULL;
      int d = evs[e].instrument;
      /*
        Instruments::iterator it = kit.instruments.begin();
        while(d-- && it != kit.instruments.end()) {
        i = &(it->second);
        it++;
        }
      */
      
      if(!kit.isValid()) continue;

      if(d < (int)kit.instruments.size()) {
        i = kit.instruments[d];
      }

      if(i == NULL || !i->isValid()) {
        ERR(drumgizmo, "Missing Instrument %d.\n", evs[e].instrument);
        continue;
      }

      if(i->group() != "") {
        // Add event to ramp down all existing events with the same groupname.
        Channels::iterator j = kit.channels.begin();
        while(j != kit.channels.end()) {
          Channel &ch = *j;
          std::list< Event* >::iterator evs = activeevents[ch.num].begin();
          while(evs != activeevents[ch.num].end()) {
            Event *ev = *evs;
            if(ev->type() == Event::sample) {
              EventSample *sev = (EventSample*)ev;
              if(sev->group == i->group() && sev->instrument != i) {
                sev->rampdown = 3000; // Ramp down 3000 samples
                // TODO: This must be configurable at some point...
                // ... perhaps even by instrument (ie. in the xml file)
                sev->ramp_start = sev->rampdown;
              }
            }
            evs++;
          }
          j++;
        }
      }

      Sample *s = i->sample(evs[e].velocity, evs[e].offset + pos);
      
      if(s == NULL) {
        ERR(drumgizmo, "Missing Sample.\n");
        continue;
      }
      
      Channels::iterator j = kit.channels.begin();
      while(j != kit.channels.end()) {
        Channel &ch = *j;
        AudioFile *af = s->getAudioFile(&ch);
        if(af) {
          // LAZYLOAD:
          // DEBUG(drumgizmo,"Requesting preparing of audio file\n");
          // loader.prepare(af);
        }
        if(af == NULL || !af->isValid()) {
          //DEBUG(drumgizmo,"Missing AudioFile.\n");
        } else {
          //DEBUG(drumgizmo, "Adding event %d.\n", evs[e].offset);
          Event *evt = new EventSample(ch.num, 1.0, af, i->group(), i);
          evt->offset = evs[e].offset + pos;
          activeevents[ch.num].push_back(evt);
        }
        j++;
      }
    }
    
    if(evs[e].type == TYPE_STOP) {
      return false;
    }
    
  }
    
  free(evs);
  
  
  //
  // Write audio
  //
  for(size_t c = 0; c < kit.channels.size(); c++) {
    sample_t *buf = samples;
    bool internal = false;
    if(oe->getBuffer(c)) {
      buf = oe->getBuffer(c);
      internal = true;
    }
    if(buf) {
      memset(buf, 0, nsamples * sizeof(sample_t));
      
      getSamples(c, pos, buf, nsamples);
      if(!internal) oe->run(c, samples, nsamples);
    }
  }
  
  ie->post();
  oe->post(nsamples);
  
  pos += nsamples;

  return true;
}

void DrumGizmo::run()
{
  ie->start();
  oe->start();

  size_t pos = 0;
  size_t nsamples = 1024;
  sample_t samples[nsamples];

  while(run(pos, samples, nsamples) == true) {
    pos += nsamples;
  }

  ie->stop();
  oe->stop();
}

#ifdef SSE
#define N 8
typedef float vNsf __attribute__ ((vector_size(sizeof(float)*N)));
#endif/*SSE*/

void DrumGizmo::getSamples(int ch, int pos, sample_t *s, size_t sz)
{
  std::list< Event* >::iterator i = activeevents[ch].begin();
  while(i != activeevents[ch].end()) {
    bool removeevent = false;

    Event *event = *i;

    Event::type_t type = event->type();
    switch(type) {
    case Event::sample:
      {
        EventSample *evt = (EventSample *)event;
        AudioFile *af = evt->file;

        if(!af->isLoaded() || !af->isValid() || s == NULL) {
          removeevent = true;
          break;
        }

        {
        MutexAutolock l(af->mutex);

        size_t n = 0;
        if(evt->offset > (size_t)pos) n = evt->offset - pos;
        size_t end = sz;
        if(evt->t + end - n > af->size) end = af->size - evt->t + n;

        if(evt->rampdown == NO_RAMPDOWN) {
#ifdef SSE
//          DEBUG(drumgizmo,"%d\n", evt->t); fflush(stdout);
         size_t optend = ((end - n) / N) * N + n;
         for(; n < optend; n += N) {
            *(vNsf*)&(s[n]) += *(vNsf*)&(af->data[evt->t]);
            evt->t += N;
          }
#endif
          for(; n < end; n++) {
            s[n] += af->data[evt->t];
            evt->t++;
          }
        } else { // Ramp down in progress.
          for(; n < end && evt->rampdown; n++) {
            float scale = (float)evt->rampdown/(float)evt->ramp_start;
            s[n] += af->data[evt->t] * scale;
            evt->t++;
            evt->rampdown--;
          }
          
        }

        if(evt->t >= af->size) { 
          removeevent = true;
//        LAZYLOAD:
//          loader.reset(af);
        }

        }
      }
      break;
    }

    if(removeevent) {
      delete event;
      i = activeevents[ch].erase(i);
      continue;
    }
    i++;
  }
}

void DrumGizmo::stop()
{
  // engine.stop();
}

std::string float2str(float a)
{
  char buf[256];
  sprintf(buf, "%f", a);
  return buf;
}

std::string bool2str(bool a)
{
  return a?"true":"false";
}

float str2float(std::string a)
{
  if(a == "") return 0.0;
  return atof(a.c_str());
}

std::string DrumGizmo::configString()
{
  std::string mmapfile;
  if(ie->isMidiEngine()) {
    AudioInputEngineMidi *aim = (AudioInputEngineMidi*)ie;
    mmapfile = aim->midimapFile();
  }

  return
    "<config>\n"
    "  <value name=\"drumkitfile\">" + kitfile + "</value>\n"
    "  <value name=\"midimapfile\">" + mmapfile + "</value>\n"
    "  <value name=\"enable_velocity_modifier\">" +
    bool2str(Conf::enable_velocity_modifier) + "</value>\n"
    "  <value name=\"velocity_modifier_falloff\">" +
    float2str(Conf::velocity_modifier_falloff) + "</value>\n"
    "  <value name=\"velocity_modifier_weight\">" +
    float2str(Conf::velocity_modifier_weight) + "</value>\n"
    "  <value name=\"enable_velocity_randomiser\">" +
    bool2str(Conf::enable_velocity_randomiser) + "</value>\n"
    "  <value name=\"velocity_randomiser_weight\">" +
    float2str(Conf::velocity_randomiser_weight) + "</value>\n"
    "</config>";
}

#include "saxparser.h"

class ConfigParser : public SAXParser {
public:
  ConfigParser()
  {
    str = NULL;
  }

  void characterData(std::string &data)
  {
    if(str) str->append(data);
  }

  void startTag(std::string name, attr_t attr)
  {
    if(name == "value" && attr.find("name") != attr.end()) {
      values[attr["name"]] = "";
      str = &values[attr["name"]];
    }
  }

  void endTag(std::string name)
  {
    if(name == "value") str = NULL;
  }

  std::string value(std::string name, std::string def = "")
  {
    if(values.find(name) == values.end()) return def;
    return values[name];
  }

  void parseError(char *buf, size_t len, std::string error, int lineno)
  {
    std::string buffer;
    buffer.append(buf, len);
    ERR(configparser, "sax parser error '%s' at line %d. "
        "Buffer: [%d bytes]<%s>\n",
        error.c_str(), lineno, len, buffer.c_str());
  }

  std::map<std::string, std::string> values;
  std::string *str;
};

bool DrumGizmo::setConfigString(std::string cfg)
{
  DEBUG(config, "Load config: %s\n", cfg.c_str());

  std::string dkf;
  ConfigParser p;
  if(p.parse(cfg)) {
    ERR(drumgizmo, "Config parse error.\n");
    return false;
  }

  if(p.value("enable_velocity_modifier") != "") {
    Conf::enable_velocity_modifier =
      p.value("enable_velocity_modifier") == "true";
  }

  if(p.value("velocity_modifier_falloff") != "") {
    Conf::velocity_modifier_falloff =
      str2float(p.value("velocity_modifier_falloff"));
  }

  if(p.value("velocity_modifier_weight") != "") {
    Conf::velocity_modifier_weight =
      str2float(p.value("velocity_modifier_weight"));
  }

  if(p.value("enable_velocity_randomiser") != "") {
    Conf::enable_velocity_randomiser =
      p.value("enable_velocity_randomiser") == "true";
  }

  if(p.value("velocity_randomiser_weight") != "") {
    Conf::velocity_randomiser_weight =
      str2float(p.value("velocity_randomiser_weight"));
  }

  std::string newkit = p.value("drumkitfile");
  if(newkit != "" && drumkitfile() != newkit) {
    /*
    if(!loadkit(p.values["drumkitfile"])) return false;
    init(true);
    */
    LoadDrumKitMessage *msg = new LoadDrumKitMessage();
    msg->drumkitfile = newkit;
    msghandler.sendMessage(MSGRCV_ENGINE, msg);
  }

  std::string newmidimap = p.value("midimapfile");
  if(newmidimap != "") {
    //midimapfile = newmidimap;
    LoadMidimapMessage *msg = new LoadMidimapMessage();
    msg->midimapfile = newmidimap;
    msghandler.sendMessage(MSGRCV_ENGINE, msg);
  }

  return true;
}

#ifdef TEST_DRUMGIZMO
//deps: instrument.cc sample.cc channel.cc audiofile.cc drumkit.cc drumkitparser.cc configuration.cc saxparser.cc instrumentparser.cc path.cc
//cflags: $(SNDFILE_CFLAGS) $(EXPAT_CFLAGS) -I../include -DSSE -msse -msse2 -msse3
//libs: $(SNDFILE_LIBS) $(EXPAT_LIBS)
#include "test.h"

static float f(size_t x)
{
  return x + 1.0;
}

class AITest : public AudioInputEngine {
public:
  bool init(Instruments &instruments) { return true; }
  void setParm(std::string parm, std::string value) {}
  bool start() { return true; }
  void stop() {}
  void pre() {}
  event_t *run(size_t pos, size_t len, size_t *nevents)
  {
    event_t *e = NULL;
    *nevents = 0;

    if(pos <= offset && offset < pos + len) {
      e = new event_t;

      e->type = TYPE_ONSET;
      e->instrument = 0;
      e->velocity = 1.0;
      e->offset = offset - pos;

      *nevents = 1;
    }
    return e;
  }
  void post() {}
  size_t offset;
};

class AOTest : public AudioOutputEngine {
public:
  bool init(Channels channels) { return true; }
  void setParm(std::string parm, std::string value) {}
  bool start() { return true; }
  void stop() {}
  void pre(size_t nsamples) {}
  void run(int ch, sample_t *samples, size_t nsamples)
  {
  }
  void post(size_t nsamples) {}
};

const char xml_kit[] =
  "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
  "<drumkit name=\"test\" description=\"\">\n"
  "  <channels>\n"
  "    <channel name=\"ch1\"/>\n"
  "  </channels>\n"
  "  <instruments>\n"
  "    <instrument name=\"instr1\" file=\"instr1.xml\">\n"
  "      <channelmap in=\"ch1\" out=\"ch1\"/>\n"
  "		</instrument>\n"
  "	</instruments>\n"
  "</drumkit>";

const char xml_instr[] =
  "<?xml version='1.0' encoding='UTF-8'?>\n"
  "<instrument name=\"instr1\">\n"
  " <samples>\n"
  "  <sample name=\"sample1\">\n"
  "   <audiofile channel=\"ch1\" file=\"instr1.wav\"/>\n"
  "  </sample>\n"
  " </samples>\n"
  " <velocities>\n"
  "  <velocity lower=\"0\" upper=\"1.0\">\n"
  "   <sampleref name=\"sample1\"/>\n"
  "  </velocity>\n"
  " </velocities>\n"
  "</instrument>";

#define PCM_SIZE 100

void createTestKit()
{
  FILE *fp;
  fp = fopen("/tmp/kit.xml", "w");
  fwrite(xml_kit, strlen(xml_kit), 1, fp);
  fclose(fp);

  fp = fopen("/tmp/instr1.xml", "w");
  fwrite(xml_instr, strlen(xml_instr), 1, fp);
  fclose(fp);

  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("/tmp/instr1.wav", SFM_WRITE, &sf_info);
  if(!fh) {
    printf("Error: %s\n", sf_strerror(fh));
  }

  size_t size = PCM_SIZE;
  sample_t samples[size];

  for(size_t i = 0; i < size; i++) {
    samples[i] = f(i);//(float)i / (float)size;
  }

  sf_write_float(fh, samples, size); 
  sf_close(fh);
}

void deleteTestKit()
{
  unlink("/tmp/kit.xml");
  unlink("/tmp/instr1.xml");
  unlink("/tmp/instr1.wav");
}

TEST_BEGIN;

createTestKit();

size_t size = PCM_SIZE;
//for(size_t chunksz = 1; chunksz < size + 1; chunksz++) {
size_t chunksz = 16; {
  sample_t samples[chunksz];

  for(size_t offset = 0; offset < chunksz + size + 1; offset++) {
    //size_t offset = 5; {
    for(size_t padding = 0; padding < chunksz + size + offset + 1; padding++) {
      //size_t padding = 2; {
      TEST_MSG("Values (offset %d, padding %d, chunksz %d)",
               offset, padding, chunksz);
      
      AOTest ao;
      AITest ai; ai.offset = offset;
      DrumGizmo dg(&ao, &ai);
      dg.loadkit("/tmp/kit.xml");
      
      size_t pos = 0;
      //      sample_t samples[chunksz];
      while(pos < offset + size + padding) {
        dg.run(pos, samples, chunksz);
        
        float err = 0;
        size_t errcnt = 0;
        for(size_t i = 0; i < chunksz && pos < offset + size + padding; i++) {
          float val = 0.0;
          if(pos >= offset && pos < (offset + size)) val = f(pos - offset);
          float diff = samples[i] - val;
          /*
          if(diff != 0.0) {
            TEST_EQUAL_FLOAT(samples[i], val,
                           "samples[%d] ?= val, pos %d", i, pos);
          }
          */
          if(diff != 0.0) errcnt++;

          err += fabs(diff);
          pos++;
        }

        TEST_EQUAL_FLOAT(err, 0.0,
                         "Compare error (offset %d, padding %d, chunksz %d)",
                         offset, padding, chunksz);
        TEST_EQUAL_INT(errcnt, 0,
                       "Compare count (offset %d, padding %d, chunksz %d)",
                       offset, padding, chunksz);
      }

    }
  }
}

deleteTestKit();

TEST_END;

#endif/*TEST_DRUMGIZMO*/