-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
30 changed files
with
1,069 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#============================================================================= | ||
# MuseScore | ||
# Music Composition & Notation | ||
# $Id:$ | ||
# | ||
# Copyright (C) 2011 Werner Schweer | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 2 | ||
# as published by the Free Software Foundation and appearing in | ||
# the file LICENSE.GPL | ||
#============================================================================= | ||
|
||
set(TARGET tst_sfzcomments) | ||
|
||
include(${PROJECT_SOURCE_DIR}/mtest/cmake.inc) | ||
|
||
include_directories( | ||
${SNDFILE_INCDIR} | ||
) | ||
|
||
target_link_libraries(tst_sfzcomments zerberus synthesizer audiofile ${SNDFILE_LIB}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<group> | ||
sample=../sample.wav | ||
pitch_keycenter=40 | ||
// <region> line comment | ||
//<region> line comment with spaces at the beginning | ||
<region> lokey=60 hikey=70 // <region> line comment with opcodes at the beginning | ||
<region> lokey=23 /* lokey=45 */ hikey=42 /* hikey=58*/ // block in line | ||
/* block multiline | ||
<region> | ||
<region> | ||
*/ <region> lokey=42 /* new block after block */ hikey=23 /* | ||
<region> some more | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
|
||
//============================================================================= | ||
// MuseScore | ||
// Music Composition & Notation | ||
// $Id:$ | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License version 2 | ||
// as published by the Free Software Foundation and appearing in | ||
// the file LICENCE.GPL | ||
//============================================================================= | ||
|
||
#include <QtTest/QtTest> | ||
|
||
#include "mtest/testutils.h" | ||
|
||
#include "zerberus/instrument.h" | ||
#include "zerberus/zerberus.h" | ||
#include "zerberus/zone.h" | ||
#include "mscore/preferences.h" | ||
|
||
using namespace Ms; | ||
|
||
//--------------------------------------------------------- | ||
// TestSfzComments | ||
//--------------------------------------------------------- | ||
|
||
class TestSfzComments : public QObject, public MTest | ||
{ | ||
Q_OBJECT | ||
|
||
private slots: | ||
void initTestCase(); | ||
void testcomments(); | ||
}; | ||
|
||
//--------------------------------------------------------- | ||
// initTestCase | ||
//--------------------------------------------------------- | ||
|
||
void TestSfzComments::initTestCase() | ||
{ | ||
initMTest(); | ||
} | ||
|
||
//--------------------------------------------------------- | ||
// testcomments | ||
//--------------------------------------------------------- | ||
|
||
void TestSfzComments::testcomments() | ||
{ | ||
Zerberus* synth = new Zerberus(); | ||
Ms::preferences.mySoundfontsPath += ";" + root; | ||
synth->loadInstrument("commentTest.sfz"); | ||
|
||
QCOMPARE(synth->instrument(0)->zones().size(), (unsigned long) 3); | ||
|
||
std::list<Zone *>::iterator curZone = synth->instrument(0)->zones().begin(); | ||
QCOMPARE((*curZone)->keyLo, (char) 60); | ||
QCOMPARE((*curZone)->keyHi, (char) 70); | ||
QCOMPARE((*curZone)->keyBase, (char) 40); | ||
curZone++; | ||
QCOMPARE((*curZone)->keyLo, (char) 23); | ||
QCOMPARE((*curZone)->keyHi, (char) 42); | ||
QCOMPARE((*curZone)->keyBase, (char) 40); | ||
curZone++; | ||
QCOMPARE((*curZone)->keyLo, (char) 42); | ||
QCOMPARE((*curZone)->keyHi, (char) 23); | ||
QCOMPARE((*curZone)->keyBase, (char) 40); | ||
} | ||
|
||
QTEST_MAIN(TestSfzComments) | ||
|
||
#include "tst_sfzcomments.moc" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#============================================================================= | ||
# MuseScore | ||
# Music Composition & Notation | ||
# $Id:$ | ||
# | ||
# Copyright (C) 2011 Werner Schweer | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 2 | ||
# as published by the Free Software Foundation and appearing in | ||
# the file LICENSE.GPL | ||
#============================================================================= | ||
|
||
set(TARGET tst_sfzenvelopes) | ||
|
||
include(${PROJECT_SOURCE_DIR}/mtest/cmake.inc) | ||
|
||
include_directories( | ||
${SNDFILE_INCDIR} | ||
) | ||
|
||
target_link_libraries(tst_sfzenvelopes zerberus synthesizer audiofile ${SNDFILE_LIB}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<global> | ||
sample=../Ones.wav// a file containing 200 Samples with Value 1.0 | ||
volume=0 | ||
<group> | ||
loop_mode=loop_continuous | ||
loop_start=50 | ||
loop_end=150 | ||
<region> ampeg_delay=0.01 ampeg_start=20 ampeg_attack=0.01 ampeg_hold=0.01 ampeg_decay=0.01 ampeg_sustain=50 ampeg_release=0.01 |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
|
||
//============================================================================= | ||
// MuseScore | ||
// Music Composition & Notation | ||
// $Id:$ | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License version 2 | ||
// as published by the Free Software Foundation and appearing in | ||
// the file LICENCE.GPL | ||
//============================================================================= | ||
|
||
#include <QtTest/QtTest> | ||
|
||
#include "mtest/testutils.h" | ||
|
||
#include "zerberus/instrument.h" | ||
#include "zerberus/zerberus.h" | ||
#include "zerberus/zone.h" | ||
#include "mscore/preferences.h" | ||
#include "synthesizer/event.h" | ||
#include <sndfile.h> | ||
|
||
using namespace Ms; | ||
|
||
//--------------------------------------------------------- | ||
// TestSfzEnvelopes | ||
//--------------------------------------------------------- | ||
|
||
class TestSfzEnvelopes : public QObject, public MTest | ||
{ | ||
Q_OBJECT | ||
float samplerate = 44100; | ||
Zerberus* synth; | ||
|
||
private slots: | ||
void initTestCase(); | ||
void testEnvelopesParsing(); | ||
void testEnvelopesAudio(); | ||
public: | ||
~TestSfzEnvelopes(); | ||
}; | ||
|
||
//--------------------------------------------------------- | ||
// initTestCase | ||
//--------------------------------------------------------- | ||
|
||
void TestSfzEnvelopes::initTestCase() | ||
{ | ||
initMTest(); | ||
synth = new Zerberus(); | ||
synth->init(samplerate); | ||
Ms::preferences.mySoundfontsPath += ";" + root; | ||
synth->loadInstrument("envelopesTest.sfz"); | ||
} | ||
|
||
//--------------------------------------------------------- | ||
// testglobal | ||
//--------------------------------------------------------- | ||
|
||
void TestSfzEnvelopes::testEnvelopesParsing() | ||
{ | ||
QCOMPARE(synth->instrument(0)->zones().size(), (unsigned long) 1); | ||
QCOMPARE(synth->instrument(0)->zones().front()->ampegDelay, 0.01f * 1000.0f); | ||
QCOMPARE(synth->instrument(0)->zones().front()->ampegStart, 20.0f / 100.0f); // 20 percent | ||
QCOMPARE(synth->instrument(0)->zones().front()->ampegAttack, 0.01f * 1000.0f); | ||
QCOMPARE(synth->instrument(0)->zones().front()->ampegHold, 0.01f * 1000.0f); | ||
QCOMPARE(synth->instrument(0)->zones().front()->ampegDecay, 0.01f * 1000.0f); | ||
QCOMPARE(synth->instrument(0)->zones().front()->ampegSustain, 50.0f / 100.0f); // 50 percent | ||
QCOMPARE(synth->instrument(0)->zones().front()->ampegRelease, 0.01f * 1000.0f); | ||
} | ||
|
||
void TestSfzEnvelopes::testEnvelopesAudio() | ||
{ | ||
synth->play(Ms::PlayEvent(ME_PROGRAM, 0, 0, 0)); | ||
float data[6 * 441 * 2]; // 6 envelope stages with duration of 441 Samples and 2 Channels | ||
memset(data, 0, sizeof(data)); | ||
synth->play(Ms::PlayEvent(ME_NOTEON, 0, 60, 127)); // play a note | ||
synth->process(5*441 , data, nullptr, nullptr); // process until end of sustain stage | ||
synth->play(Ms::PlayEvent(ME_NOTEON, 0, 60, 0)); // send note off | ||
synth->process(441 , data + (5*441*2), nullptr, nullptr); // process until end of sustain stage | ||
|
||
/* To generate wav file | ||
SF_INFO sf_info; | ||
sf_info.channels = 2; | ||
sf_info.format = SF_FORMAT_WAV | SF_FORMAT_FLOAT; | ||
sf_info.frames = 6 *441; | ||
sf_info.samplerate = samplerate; | ||
SNDFILE* sf = sf_open("result.wav", SFM_WRITE, &sf_info); | ||
sf_writef_float(sf, data, 441*6); | ||
sf_close(sf); */ | ||
|
||
// read wav file | ||
QString filename = root + "/zerberus/envelopes/result.wav"; | ||
SF_INFO sf_info; | ||
SNDFILE *sf = sf_open(filename.toLocal8Bit().constData(), SFM_READ, &sf_info); | ||
float compare_data[6 * 441 * 2]; | ||
sf_readf_float(sf, compare_data, 6 * 441); | ||
sf_close(sf); | ||
|
||
for (int i = 0; i < 6 * 441 * 2; i++) | ||
QCOMPARE(data[i], compare_data[i]); | ||
|
||
} | ||
|
||
TestSfzEnvelopes::~TestSfzEnvelopes() | ||
{ | ||
delete synth; | ||
} | ||
|
||
QTEST_MAIN(TestSfzEnvelopes) | ||
|
||
#include "tst_sfzenvelopes.moc" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#============================================================================= | ||
# MuseScore | ||
# Music Composition & Notation | ||
# $Id:$ | ||
# | ||
# Copyright (C) 2011 Werner Schweer | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 2 | ||
# as published by the Free Software Foundation and appearing in | ||
# the file LICENSE.GPL | ||
#============================================================================= | ||
|
||
set(TARGET tst_sfzglobal) | ||
|
||
include(${PROJECT_SOURCE_DIR}/mtest/cmake.inc) | ||
|
||
include_directories( | ||
${SNDFILE_INCDIR} | ||
) | ||
|
||
target_link_libraries(tst_sfzglobal zerberus synthesizer audiofile ${SNDFILE_LIB}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<global> | ||
sample=../sample.wav | ||
<group> | ||
lokey=40 | ||
hikey=50 | ||
pitch_keycenter=40 | ||
<region> | ||
<region> lokey=60 hikey=70 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
|
||
//============================================================================= | ||
// MuseScore | ||
// Music Composition & Notation | ||
// $Id:$ | ||
// | ||
// This program is free software; you can redistribute it and/or modify | ||
// it under the terms of the GNU General Public License version 2 | ||
// as published by the Free Software Foundation and appearing in | ||
// the file LICENCE.GPL | ||
//============================================================================= | ||
|
||
#include <QtTest/QtTest> | ||
|
||
#include "mtest/testutils.h" | ||
|
||
#include "zerberus/instrument.h" | ||
#include "zerberus/zerberus.h" | ||
#include "zerberus/zone.h" | ||
#include "mscore/preferences.h" | ||
|
||
using namespace Ms; | ||
|
||
//--------------------------------------------------------- | ||
// TestSfzGlobal | ||
//--------------------------------------------------------- | ||
|
||
class TestSfzGlobal : public QObject, public MTest | ||
{ | ||
Q_OBJECT | ||
|
||
private slots: | ||
void initTestCase(); | ||
void testglobal(); | ||
}; | ||
|
||
//--------------------------------------------------------- | ||
// initTestCase | ||
//--------------------------------------------------------- | ||
|
||
void TestSfzGlobal::initTestCase() | ||
{ | ||
initMTest(); | ||
} | ||
|
||
//--------------------------------------------------------- | ||
// testglobal | ||
//--------------------------------------------------------- | ||
|
||
void TestSfzGlobal::testglobal() | ||
{ | ||
Zerberus* synth = new Zerberus(); | ||
Ms::preferences.mySoundfontsPath += ";" + root; | ||
synth->loadInstrument("globalTest.sfz"); | ||
QCOMPARE(synth->instrument(0)->zones().size(), (unsigned long) 2); | ||
QCOMPARE(synth->instrument(0)->zones().front()->keyLo, (char) 40); | ||
QCOMPARE(synth->instrument(0)->zones().front()->keyHi, (char) 50); | ||
QCOMPARE(synth->instrument(0)->zones().front()->keyBase, (char) 40); | ||
QCOMPARE(synth->instrument(0)->zones().back()->keyLo, (char) 60); | ||
QCOMPARE(synth->instrument(0)->zones().back()->keyHi, (char) 70); | ||
QCOMPARE(synth->instrument(0)->zones().back()->keyBase, (char) 40); | ||
} | ||
|
||
QTEST_MAIN(TestSfzGlobal) | ||
|
||
#include "tst_sfzglobal.moc" | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#============================================================================= | ||
# MuseScore | ||
# Music Composition & Notation | ||
# $Id:$ | ||
# | ||
# Copyright (C) 2011 Werner Schweer | ||
# | ||
# This program is free software; you can redistribute it and/or modify | ||
# it under the terms of the GNU General Public License version 2 | ||
# as published by the Free Software Foundation and appearing in | ||
# the file LICENSE.GPL | ||
#============================================================================= | ||
|
||
set(TARGET tst_sfzincludes) | ||
|
||
include(${PROJECT_SOURCE_DIR}/mtest/cmake.inc) | ||
|
||
include_directories( | ||
${SNDFILE_INCDIR} | ||
) | ||
|
||
target_link_libraries(tst_sfzincludes zerberus synthesizer audiofile ${SNDFILE_LIB}) |
Oops, something went wrong.