Browse Source

update template

master
Nils 3 years ago
parent
commit
3687d062f9
  1. 1
      template/calfbox/py/nullbox.py
  2. 6
      template/calfbox/sampler.c
  3. 6
      template/calfbox/sampler_api_example2.py
  4. 27
      template/engine/pitch.py
  5. 2
      template/qtgui/helper.py

1
template/calfbox/py/nullbox.py

@ -58,4 +58,3 @@ sys.modules["calfbox"] = sys.modules["calfbox.nullbox"]
import calfbox import calfbox
cbox = NullCalfbox("fake cbox null client") cbox = NullCalfbox("fake cbox null client")

6
template/calfbox/sampler.c

@ -344,12 +344,10 @@ static gboolean load_program_at(struct sampler_module *m, const char *cfg_sectio
return FALSE; return FALSE;
if (index != -1) if (index != -1)
{
swap_program(m, index, pgm, TRUE); swap_program(m, index, pgm, TRUE);
return TRUE; else
} sampler_register_program(m, pgm);
sampler_register_program(m, pgm);
if (ppgm) if (ppgm)
*ppgm = pgm; *ppgm = pgm;
return TRUE; return TRUE;

6
template/calfbox/sampler_api_example2.py

@ -14,6 +14,12 @@ scene.clear()
instrument = scene.add_new_instrument_layer("test_sampler", "sampler").get_instrument() instrument = scene.add_new_instrument_layer("test_sampler", "sampler").get_instrument()
pgm_no = instrument.engine.get_unused_program() pgm_no = instrument.engine.get_unused_program()
pgm = instrument.engine.load_patch_from_file(pgm_no, 'synthbass.sfz', 'SynthBass') pgm = instrument.engine.load_patch_from_file(pgm_no, 'synthbass.sfz', 'SynthBass')
# This is not needed, it's here to test for a bug where reloading a program at
# the same slot didn't return the newly loaded program object.
pgm = instrument.engine.load_patch_from_file(pgm_no, 'synthbass.sfz', 'SynthBass')
assert pgm
instrument.engine.set_patch(1, pgm_no) instrument.engine.set_patch(1, pgm_no)
print (instrument.engine.get_patches()) print (instrument.engine.get_patches())
print (instrument.get_output_slot(0)) print (instrument.get_output_slot(0))

27
template/engine/pitch.py

@ -1094,6 +1094,30 @@ for _midipitch in range(128):
_octave, _pitch = divmod(_midipitch, 12) _octave, _pitch = divmod(_midipitch, 12)
midi_notenames_german.append("{}{}".format("C Des D Es E F Fis G As A B H".split()[_pitch] ,_octave-1)) midi_notenames_german.append("{}{}".format("C Des D Es E F Fis G As A B H".split()[_pitch] ,_octave-1))
#midi and sfz note names are normal midi notes again, but this time we need a dict because both Eb and D# are in there. c4 is middle.
_alt = {
"db" : "c#",
"eb" : "d#",
"f#" : "gb",
"ab" : "g#",
"bb" : "a#",
}
midiName2midiPitch = {}
for _midipitch in range(128): #0-127 incl.
_octave, _pitch = divmod(_midipitch, 12)
_octave -= 1
notename = "c db d eb e f f# g ab a bb b".split()[_pitch]
sfz_name1 = "{}{}".format(notename ,_octave)
midiName2midiPitch[sfz_name1] = _midipitch
if notename in ("db", "eb", "f#", "ab", "bb"): #Add the other variant
sfz_name2 = "{}{}".format(_alt[notename] ,_octave)
midiName2midiPitch[sfz_name2] = _midipitch
assert midiName2midiPitch["db4"] == 61, midiName2midiPitch["db4"]
assert midiName2midiPitch["db4"] == midiName2midiPitch["c#4"], midiName2midiPitch["c#4"]
"""midi_notenames_lilypond = [] """midi_notenames_lilypond = []
for _midipitch in range(128): for _midipitch in range(128):
_octave, _pitch = divmod(_midipitch, 12) _octave, _pitch = divmod(_midipitch, 12)
@ -1176,6 +1200,3 @@ simpleNoteNames["German"] = midi_notenames_german
simpleNoteNames["English"] = midi_notenames_english simpleNoteNames["English"] = midi_notenames_english
simpleNoteNames["Lilypond"] = midi_notenames_lilypond simpleNoteNames["Lilypond"] = midi_notenames_lilypond
simpleNoteNames["Drums GM"] = midi_notenames_gm_drums simpleNoteNames["Drums GM"] = midi_notenames_gm_drums

2
template/qtgui/helper.py

@ -314,7 +314,7 @@ class ToggleSwitch(QtWidgets.QAbstractButton):
p.setPen(text_color) p.setPen(text_color)
p.setOpacity(text_opacity) p.setOpacity(text_opacity)
font = p.font() font = p.font()
font.setPixelSize(1.5 * self._thumb_radius) font.setPixelSize(int(1.5 * self._thumb_radius))
p.setFont(font) p.setFont(font)
p.drawText( p.drawText(
QtCore.QRectF( QtCore.QRectF(

Loading…
Cancel
Save