Comments (5)
I see what is causing this issue here. Let me clarify the parameters of the function export_midi_file
, the first parameter current_chord
is the name of the midi file you want to export as audio files using loaded soundfont files, and the name
parameter is the name of the exported audio file. Here your first parameter should be rf"{defaultPath}\generated_music.mid"
instead of piece
, and if the variable piece
is the name of the exported audio file you want, you can set name=piece
, but actually piece
is a defined class in musicpy, so it is better to use another variable name to avoid naming conflicts.
Or if you actually want to export a piece instance to a midi file, just simply use musicpy's write
function, like this:
write(piece1, name=rf"{defaultPath}\generated_music.mid")
from sf2_loader.
I see what is causing this issue here. Let me clarify the parameters of the function
export_midi_file
, the first parametercurrent_chord
is the name of the midi file you want to export as audio files using loaded soundfont files, and thename
parameter is the name of the exported audio file. Here your first parameter should berf"{defaultPath}\generated_music.mid"
instead ofpiece
, and if the variablepiece
is the name of the exported audio file you want, you can setname=piece
, but actuallypiece
is a defined class in musicpy, so it is better to use another variable name to avoid naming conflicts.
Does this mean I first have to generate an audio file, using export_piece
and then I can use export_midi_file
?
The variable piece here is the output of calling piece
from ``musicpy```, I can share a bit`more of my code:
if(musicalParsing == "random"):
# this is a musicpy chord object
musicalOutput = lmusic_parser.random_parsing(output)
piece = sf.mp.piece(
[musicalOutput], [sf2.current_preset_num], random.randint(40, 220), [0], channels=[1]
)
now = datetime.datetime.now()
now = now.strftime('%Y_%m_%d_%H_%M_%S')
sf2.export_midi_file(
piece, name=rf"{defaultPath}\generated_music_{now}.mid")
I will rename the variable, thanks for the tip
from sf2_loader.
No, you can use musicpy's write
function, which can directly output any musicpy data structures to a midi file.
The export_midi_file
function of sf2_loader is to read a midi file, and render it to an audio file using loaded soundfont files, and then export the audio file. The write
function of musicpy is to convert a musicpy data structure (such as note
, chord
, track
, piece
) to a midi file.
from sf2_loader.
No, you can use musicpy's
write
function, which can directly output any musicpy data structures to a midi file. Theexport_midi_file
function of sf2_loader is to read a midi file, and render it to an audio file using loaded soundfont files, and then export the audio file. Thewrite
function of musicpy is to convert a musicpy data structure (such asnote
,chord
,track
,piece
) to a midi file.
Thank you for the clarification! Feel free to close the issue.
from sf2_loader.
You're welcome :)
from sf2_loader.
Related Issues (16)
- Note playing ends almost instantly HOT 35
- [Help Wanted] - Generating chord progressions HOT 5
- Using export_note with mono output HOT 2
- Can't load module HOT 7
- read_sf2.py中出现了NameError:name'current_decay'is not defined,求助 HOT 4
- OSError: /lib/x86_64-linux-gnu/libwayland-server.so.0: undefined symbol: ffi_type_uint32, version LIBFFI_BASE_7.0 HOT 1
- FX not rendered
- Playing notes in rapid succession seems to break the sound.
- Export Piece fails: "AttributeError: module 'fluidsynth' has no attribute 'Synth'" HOT 16
- Installation on Linux fails when processing MIDIUtil package HOT 7
- Exporting musicpy piece fails [possibly not an issue with library, but syntax error of musicpy] HOT 4
- Is there a way to suppress fluidsynth error messages? HOT 2
- Error when calling 'change_preset' HOT 10
- 'ModuleNotFoundError: No module named fluidsynth' HOT 33
- 'piece object has no attribute 'tempo'' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sf2_loader.