19 changed files with 660 additions and 44 deletions
@ -0,0 +1,153 @@
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright (C) 2020 Alexandros Theodotou <alex at zrythm dot org> |
||||
* |
||||
* This file is part of Zrythm |
||||
* |
||||
* Zrythm is free software: you can redistribute it and/or modify |
||||
* it under the terms of the GNU Affero General Public License as published by |
||||
* the Free Software Foundation, either version 3 of the License, or |
||||
* (at your option) any later version. |
||||
* |
||||
* Zrythm 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 Affero General Public License for more details. |
||||
* |
||||
* You should have received a copy of the GNU Affero General Public License |
||||
* along with Zrythm. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/ |
||||
|
||||
#include "actions/arranger_selections.h" |
||||
#include "actions/undoable_action.h" |
||||
#include "audio/audio_region.h" |
||||
#include "audio/automation_region.h" |
||||
#include "audio/chord_region.h" |
||||
#include "audio/master_track.h" |
||||
#include "audio/midi_note.h" |
||||
#include "audio/region.h" |
||||
#include "project.h" |
||||
#include "utils/flags.h" |
||||
#include "zrythm.h" |
||||
|
||||
#include "tests/helpers/project.h" |
||||
|
||||
#include <glib.h> |
||||
|
||||
/**
|
||||
* Bootstraps the test with test data. |
||||
*/ |
||||
static void |
||||
rebootstrap (void) |
||||
{ |
||||
char path_str[6000]; |
||||
sprintf ( |
||||
path_str, "file://%s/%s/", |
||||
TESTS_BUILDDIR, "test-instrument.lv2"); |
||||
g_message ("path is %s", path_str); |
||||
|
||||
plugin_manager_init (PLUGIN_MANAGER); |
||||
LilvNode * path = |
||||
lilv_new_uri (LILV_WORLD, path_str); |
||||
lilv_world_load_bundle ( |
||||
LILV_WORLD, path); |
||||
lilv_node_free (path); |
||||
|
||||
plugin_manager_scan_plugins ( |
||||
PLUGIN_MANAGER, 1.0, NULL); |
||||
g_assert_cmpint ( |
||||
PLUGIN_MANAGER->num_plugins, ==, 1); |
||||
|
||||
/* for some reason it gets labeled as a plugin,
|
||||
* force instrument */ |
||||
PLUGIN_MANAGER->plugin_descriptors[0]->category = |
||||
PC_INSTRUMENT; |
||||
PLUGIN_MANAGER->plugin_descriptors[0]->category_str = |
||||
g_strdup ("Instrument"); |
||||
} |
||||
|
||||
static void |
||||
test_move_tracks () |
||||
{ |
||||
rebootstrap (); |
||||
|
||||
/* create a track with an instrument */ |
||||
UndoableAction * action = |
||||
create_tracks_action_new ( |
||||
TRACK_TYPE_INSTRUMENT, |
||||
PLUGIN_MANAGER->plugin_descriptors[0], NULL, |
||||
3, 1); |
||||
undo_manager_perform (UNDO_MANAGER, action); |
||||
Track * ins_track = TRACKLIST->tracks[3]; |
||||
g_assert_true ( |
||||
ins_track->type == TRACK_TYPE_INSTRUMENT); |
||||
|
||||
/* create an fx track and send to it */ |
||||
action = |
||||
create_tracks_action_new ( |
||||
TRACK_TYPE_AUDIO_BUS, NULL, NULL, |
||||
4, 1); |
||||
undo_manager_perform (UNDO_MANAGER, action); |
||||
Track * fx_track = TRACKLIST->tracks[4]; |
||||
g_assert_true ( |
||||
fx_track->type == TRACK_TYPE_AUDIO_BUS); |
||||
|
||||
ChannelSend * send = &ins_track->channel->sends[0]; |
||||
StereoPorts * stereo_in = |
||||
fx_track->processor.stereo_in; |
||||
channel_send_connect_stereo ( |
||||
send, fx_track->processor.stereo_in); |
||||
|
||||
/* check that the sends are correct */ |
||||
g_assert_true (!send->is_empty); |
||||
g_assert_true ( |
||||
port_identifier_is_equal ( |
||||
&send->dest_l_id, &stereo_in->l->id) && |
||||
port_identifier_is_equal ( |
||||
&send->dest_r_id, &stereo_in->r->id)); |
||||
|
||||
/* swap tracks */ |
||||
track_select (ins_track, true, true, false); |
||||
action = |
||||
move_tracks_action_new ( |
||||
TRACKLIST_SELECTIONS, 4); |
||||
undo_manager_perform (UNDO_MANAGER, action); |
||||
|
||||
/* check that ids are updated */ |
||||
ins_track = TRACKLIST->tracks[4]; |
||||
fx_track = TRACKLIST->tracks[3]; |
||||
g_assert_true ( |
||||
ins_track->type == TRACK_TYPE_INSTRUMENT); |
||||
g_assert_true ( |
||||
fx_track->type == TRACK_TYPE_AUDIO_BUS); |
||||
send = &ins_track->channel->sends[0]; |
||||
stereo_in = |
||||
fx_track->processor.stereo_in; |
||||
g_assert_cmpint ( |
||||
stereo_in->l->id.track_pos, ==, 3); |
||||
g_assert_cmpint ( |
||||
stereo_in->r->id.track_pos, ==, 3); |
||||
g_assert_cmpint (send->track_pos, ==, 4); |
||||
g_assert_true (!send->is_empty); |
||||
g_assert_true ( |
||||
port_identifier_is_equal ( |
||||
&send->dest_l_id, &stereo_in->l->id) && |
||||
port_identifier_is_equal ( |
||||
&send->dest_r_id, &stereo_in->r->id)); |
||||
} |
||||
|
||||
int |
||||
main (int argc, char *argv[]) |
||||
{ |
||||
g_test_init (&argc, &argv, NULL); |
||||
|
||||
test_helper_zrythm_init (); |
||||
|
||||
#define TEST_PREFIX "/actions/move_tracks/" |
||||
|
||||
g_test_add_func ( |
||||
TEST_PREFIX "test move tracks", |
||||
(GTestFunc) test_move_tracks); |
||||
|
||||
return g_test_run (); |
||||
} |
||||
|
@ -0,0 +1,10 @@
@@ -0,0 +1,10 @@
|
||||
This is not part of Zrythm, but is used with Zrythm. |
||||
|
||||
This was taken from the lv2 repository and the |
||||
following is the original README.txt. |
||||
|
||||
---- |
||||
|
||||
== Fifths == |
||||
|
||||
This plugin demonstrates simple MIDI event reading and writing. |
@ -0,0 +1,9 @@
@@ -0,0 +1,9 @@
|
||||
@prefix lv2: <http://lv2plug.in/ns/lv2core#> . |
||||
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> . |
||||
@prefix ui: <http://lv2plug.in/ns/extensions/ui#> . |
||||
|
||||
<https://lv2.zrythm.org/test-instrument> |
||||
a lv2:Plugin, |
||||
lv2:InstrumentPlugin ; |
||||
lv2:binary <test-instrument@LIB_EXT@> ; |
||||
rdfs:seeAlso <test-instrument.ttl> . |
@ -0,0 +1,43 @@
@@ -0,0 +1,43 @@
|
||||
# Copyright (C) 2020 Alexandros Theodotou <alex at zrythm dot org> |
||||
# |
||||
# This file is part of Zrythm |
||||
# |
||||
# Zrythm is free software: you can redistribute it and/or modify |
||||
# it under the terms of the GNU Affero General Public License as published by |
||||
# the Free Software Foundation, either version 3 of the License, or |
||||
# (at your option) any later version. |
||||
# |
||||
# Zrythm 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 Affero General Public License for more details. |
||||
# |
||||
# You should have received a copy of the GNU Affero General Public License |
||||
# along with Zrythm. If not, see <https://www.gnu.org/licenses/>. |
||||
|
||||
test_instrument_cdata = configuration_data () |
||||
if os_windows |
||||
test_instrument_cdata.set ('LIB_EXT', '.dll') |
||||
else |
||||
test_instrument_cdata.set ('LIB_EXT', '.so') |
||||
endif |
||||
manifest_ttl = configure_file ( |
||||
input: 'manifest.ttl.in', |
||||
output: 'manifest.ttl', |
||||
configuration: test_instrument_cdata, |
||||
) |
||||
test_instrument_ttl = configure_file ( |
||||
input: 'test-instrument.ttl', |
||||
output: 'test-instrument.ttl', |
||||
configuration: test_instrument_cdata, |
||||
) |
||||
|
||||
test_instrument_lv2 = shared_library ( |
||||
'test-instrument', |
||||
name_prefix: '', |
||||
sources: [ |
||||
'test-instrument.c', |
||||
], |
||||
dependencies: [ lv2_dep, libm ], |
||||
install: false, |
||||
) |
@ -0,0 +1,144 @@
@@ -0,0 +1,144 @@
|
||||
/*
|
||||
LV2 Fifths Example Plugin |
||||
Copyright 2014-2016 David Robillard <d@drobilla.net> |
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any |
||||
purpose with or without fee is hereby granted, provided that the above |
||||
copyright notice and this permission notice appear in all copies. |
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||||
*/ |
||||
|
||||
#include <stdint.h> |
||||
#include <stdio.h> |
||||
#include <stdlib.h> |
||||
#ifndef __cplusplus |
||||
# include <stdbool.h> |
||||
#endif |
||||
|
||||
#include "lv2/atom/atom.h" |
||||
#include "lv2/atom/util.h" |
||||
#include "lv2/core/lv2.h" |
||||
#include "lv2/core/lv2_util.h" |
||||
#include "lv2/log/log.h" |
||||
#include "lv2/log/logger.h" |
||||
#include "lv2/midi/midi.h" |
||||
#include "lv2/urid/urid.h" |
||||
|
||||
#include "./uris.h" |
||||
|
||||
enum { |
||||
FIFTHS_IN = 0, |
||||
FIFTHS_OUT = 1 |
||||
}; |
||||
|
||||
typedef struct { |
||||
// Features
|
||||
LV2_URID_Map* map; |
||||
LV2_Log_Logger logger; |
||||
|
||||
// Ports
|
||||
const LV2_Atom_Sequence* in_port; |
||||
float * out_port; |
||||
|
||||
// URIs
|
||||
FifthsURIs uris; |
||||
} Fifths; |
||||
|
||||
static void |
||||
connect_port(LV2_Handle instance, |
||||
uint32_t port, |
||||
void* data) |
||||
{ |
||||
Fifths* self = (Fifths*)instance; |
||||
switch (port) { |
||||
case FIFTHS_IN: |
||||
self->in_port = (const LV2_Atom_Sequence*)data; |
||||
break; |
||||
case FIFTHS_OUT: |
||||
self->out_port = (float *) data; |
||||
break; |
||||
default: |
||||
break; |
||||
} |
||||
} |
||||
|
||||
static LV2_Handle |
||||
instantiate(const LV2_Descriptor* descriptor, |
||||
double rate, |
||||
const char* path, |
||||
const LV2_Feature* const* features) |
||||
{ |
||||
// Allocate and initialise instance structure.
|
||||
Fifths* self = (Fifths*)calloc(1, sizeof(Fifths)); |
||||
if (!self) { |
||||
return NULL; |
||||
} |
||||
|
||||
// Scan host features for URID map
|
||||
const char* missing = lv2_features_query( |
||||
features, |
||||
LV2_LOG__log, &self->logger.log, false, |
||||
LV2_URID__map, &self->map, true, |
||||
NULL); |
||||
lv2_log_logger_set_map(&self->logger, self->map); |
||||
if (missing) { |
||||
lv2_log_error(&self->logger, "Missing feature <%s>\n", missing); |
||||
free(self); |
||||
return NULL; |
||||
} |
||||
|
||||
map_fifths_uris(self->map, &self->uris); |
||||
|
||||
return (LV2_Handle)self; |
||||
} |
||||
|
||||
static void |
||||
cleanup(LV2_Handle instance) |
||||
{ |
||||
free(instance); |
||||
} |
||||
|
||||
static void |
||||
run(LV2_Handle instance, |
||||
uint32_t sample_count) |
||||
{ |
||||
Fifths* self = (Fifths*)instance; |
||||
|
||||
memset ( |
||||
self->out_port, 0, sample_count * sizeof (float)); |
||||
} |
||||
|
||||
static const void* |
||||
extension_data(const char* uri) |
||||
{ |
||||
return NULL; |
||||
} |
||||
|
||||
static const LV2_Descriptor descriptor = { |
||||
EG_FIFTHS_URI, |
||||
instantiate, |
||||
connect_port, |
||||
NULL, // activate,
|
||||
run, |
||||
NULL, // deactivate,
|
||||
cleanup, |
||||
extension_data |
||||
}; |
||||
|
||||
LV2_SYMBOL_EXPORT |
||||
const LV2_Descriptor* lv2_descriptor(uint32_t index) |
||||
{ |
||||
switch (index) { |
||||
case 0: |
||||
return &descriptor; |
||||
default: |
||||
return NULL; |
||||
} |
||||
} |
@ -0,0 +1,38 @@
@@ -0,0 +1,38 @@
|
||||
@prefix atom: <http://lv2plug.in/ns/ext/atom#> . |
||||
@prefix doap: <http://usefulinc.com/ns/doap#> . |
||||
@prefix lv2: <http://lv2plug.in/ns/lv2core#> . |
||||
@prefix urid: <http://lv2plug.in/ns/ext/urid#> . |
||||
@prefix midi: <http://lv2plug.in/ns/ext/midi#> . |
||||
|
||||
<https://lv2.zrythm.org/test-instrument> |
||||
a lv2:Plugin, |
||||
lv2:InstrumentPlugin ; |
||||
doap:name "Test Instrument" ; |
||||
doap:license <http://opensource.org/licenses/isc> ; |
||||
lv2:project <https://lv2.zrythm.org> ; |
||||
lv2:requiredFeature urid:map ; |
||||
lv2:optionalFeature lv2:hardRTCapable ; |
||||
lv2:port [ |
||||
a lv2:InputPort , |
||||
atom:AtomPort ; |
||||
atom:bufferType atom:Sequence ; |
||||
atom:supports midi:MidiEvent ; |
||||
lv2:index 0 ; |
||||
lv2:symbol "in" ; |
||||
lv2:name "In" |
||||
] , [ |
||||
a lv2:OutputPort , |
||||
lv2:AudioPort ; |
||||
lv2:index 1 ; |
||||
lv2:symbol "mono_out" ; |
||||
lv2:name "Mono Out" |
||||
] , [ |
||||
a lv2:InputPort , |
||||
lv2:ControlPort ; |
||||
lv2:index 2 ; |
||||
lv2:symbol "test" ; |
||||
lv2:name "Test param" ; |
||||
lv2:default 0.0 ; |
||||
lv2:minimum -90.0 ; |
||||
lv2:maximum 24.0 |
||||
] . |
@ -0,0 +1,54 @@
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
LV2 Fifths Example Plugin |
||||
Copyright 2014-2015 David Robillard <d@drobilla.net> |
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any |
||||
purpose with or without fee is hereby granted, provided that the above |
||||
copyright notice and this permission notice appear in all copies. |
||||
|
||||
THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES |
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF |
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR |
||||
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES |
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN |
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF |
||||
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
||||
*/ |
||||
|
||||
#ifndef FIFTHS_URIS_H |
||||
#define FIFTHS_URIS_H |
||||
|
||||
#include "lv2/log/log.h" |
||||
#include "lv2/midi/midi.h" |
||||
#include "lv2/patch/patch.h" |
||||
#include "lv2/state/state.h" |
||||
|
||||
#define EG_FIFTHS_URI "https://lv2.zrythm.org/test-instrument"
|
||||
|
||||
typedef struct { |
||||
LV2_URID atom_Path; |
||||
LV2_URID atom_Resource; |
||||
LV2_URID atom_Sequence; |
||||
LV2_URID atom_URID; |
||||
LV2_URID atom_eventTransfer; |
||||
LV2_URID midi_Event; |
||||
LV2_URID patch_Set; |
||||
LV2_URID patch_property; |
||||
LV2_URID patch_value; |
||||
} FifthsURIs; |
||||
|
||||
static inline void |
||||
map_fifths_uris(LV2_URID_Map* map, FifthsURIs* uris) |
||||
{ |
||||
uris->atom_Path = map->map(map->handle, LV2_ATOM__Path); |
||||
uris->atom_Resource = map->map(map->handle, LV2_ATOM__Resource); |
||||
uris->atom_Sequence = map->map(map->handle, LV2_ATOM__Sequence); |
||||
uris->atom_URID = map->map(map->handle, LV2_ATOM__URID); |
||||
uris->atom_eventTransfer = map->map(map->handle, LV2_ATOM__eventTransfer); |
||||
uris->midi_Event = map->map(map->handle, LV2_MIDI__MidiEvent); |
||||
uris->patch_Set = map->map(map->handle, LV2_PATCH__Set); |
||||
uris->patch_property = map->map(map->handle, LV2_PATCH__property); |
||||
uris->patch_value = map->map(map->handle, LV2_PATCH__value); |
||||
} |
||||
|
||||
#endif /* FIFTHS_URIS_H */ |
Loading…
Reference in new issue