Audio plugin host https://kx.studio/carla
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
4.1KB

  1. # Copyright 2013 Kaspar Emanuel <kaspar.emanuel@gmail.com>
  2. #
  3. # Permission to use, copy, modify, and/or distribute this software for any
  4. # purpose with or without fee is hereby granted, provided that the above
  5. # copyright notice and this permission notice appear in all copies.
  6. #
  7. # THIS SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  8. # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  9. # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  10. # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  11. # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  12. # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  13. # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  14. from lilv import *
  15. import unittest
  16. import os
  17. class UriTests(unittest.TestCase):
  18. def setUp(self):
  19. self.world = lilv_world_new()
  20. lilv_world_load_all(self.world)
  21. def testInvalidURI(self):
  22. self.uri = lilv_new_uri(self.world, "invalid_uri")
  23. self.assertIsNone(self.uri)
  24. def testInvalidURI2(self):
  25. self.uri = lilv_new_uri(self.world, "invalid_uri")
  26. self.assertFalse( lilv_node_is_uri(self.uri) )
  27. def testNonExistentURI(self):
  28. self.uri = lilv_new_uri(self.world, "exist:does_not")
  29. plugins = lilv_world_get_all_plugins(self.world)
  30. self.plugin = lilv_plugins_get_by_uri(plugins, self.uri)
  31. self.assertIsNone(self.plugin)
  32. def testPortTypes(self):
  33. self.uri = lilv_new_uri(self.world, LILV_URI_INPUT_PORT)
  34. self.assertIsNotNone(self.uri)
  35. def testPortTypes2(self):
  36. self.uri = lilv_new_uri(self.world, LILV_URI_OUTPUT_PORT)
  37. self.assertIsNotNone(self.uri)
  38. def testPortTypes3(self):
  39. self.uri = lilv_new_uri(self.world, LILV_URI_AUDIO_PORT)
  40. self.assertIsNotNone(self.uri)
  41. def testPortTypes4(self):
  42. self.uri = lilv_new_uri(self.world, LILV_URI_CONTROL_PORT)
  43. self.assertIsNotNone(self.uri)
  44. def tearDown(self):
  45. lilv_node_free(self.uri)
  46. lilv_world_free(self.world)
  47. class PluginTests(unittest.TestCase):
  48. def setUp(self):
  49. self.world = lilv_world_new()
  50. location = "file://" + os.getcwd() + "/bindings/bindings_test_plugin.lv2/"
  51. self.plugin_uri = lilv_new_uri(self.world, location)
  52. self.assertIsNotNone(self.plugin_uri, "Invalid URI: '" + location + "'")
  53. lilv_world_load_bundle(self.world, self.plugin_uri)
  54. self.plugins = lilv_world_get_all_plugins(self.world)
  55. self.plugin = lilv_plugins_get(self.plugins, lilv_plugins_begin(self.plugins))
  56. self.assertIsNotNone(self.plugin, msg="Test plugin not found at location: '" + location + "'")
  57. self.assertEqual(location, lilv_node_as_string(lilv_plugin_get_bundle_uri(self.plugin)))
  58. self.instance = lilv_plugin_instantiate(self.plugin, 48000, None)
  59. self.assertIsNotNone(self.instance)
  60. self.lv2_InputPort = lilv_new_uri(self.world, LILV_URI_INPUT_PORT)
  61. self.lv2_OutputPort = lilv_new_uri(self.world, LILV_URI_OUTPUT_PORT)
  62. self.lv2_AudioPort = lilv_new_uri(self.world, LILV_URI_AUDIO_PORT)
  63. self.lv2_ControlPort = lilv_new_uri(self.world, LILV_URI_CONTROL_PORT)
  64. def testPorts(self):
  65. n = lilv_plugin_get_num_ports_of_class(self.plugin, self.lv2_InputPort, self.lv2_AudioPort)
  66. self.assertEqual(n, 1)
  67. def testPorts2(self):
  68. n = lilv_plugin_get_num_ports_of_class(self.plugin, self.lv2_OutputPort, self.lv2_AudioPort)
  69. self.assertEqual(n, 1)
  70. def testPorts3(self):
  71. n = lilv_plugin_get_num_ports_of_class(self.plugin, self.lv2_OutputPort, self.lv2_ControlPort)
  72. self.assertEqual(n, 1)
  73. def testPorts4(self):
  74. n = lilv_plugin_get_num_ports_of_class(self.plugin, self.lv2_InputPort, self.lv2_ControlPort)
  75. self.assertEqual(n, 1)
  76. def tearDown(self):
  77. lilv_node_free(self.lv2_InputPort)
  78. lilv_node_free(self.lv2_OutputPort)
  79. lilv_node_free(self.lv2_AudioPort)
  80. lilv_node_free(self.plugin_uri)
  81. lilv_world_free(self.world)