dubreuia / visual_midi Goto Github PK
View Code? Open in Web Editor NEWConverts a pretty midi sequence to a bokeh plot.
License: MIT License
Converts a pretty midi sequence to a bokeh plot.
License: MIT License
Using chapter_03_example_03.py.tf2.py
polyphony_rnn_polyphony_2020-06-06_102507.zip
Using the __version__
var convention
Hey!
I wanted to check out the notebook example-01.ipynb
with one of my midi files yet I've already run into error:
Cell In[5], line 7
5 plotter = Plotter(preset, plot_max_length_bar=4)
6 pm = PrettyMIDI("data/ghostbusters.mid")
----> 7 plotter.show_notebook(pm)
File (...)/python3.10/site-packages/Visual_MIDI-1.1.0-py3.10.egg/visual_midi/visual_midi.py:436
429 def show_notebook(self, pm: PrettyMIDI):
430 """
431 Shows the pretty midi object as a plot file in the notebook.
432
433 :param pm: the PrettyMIDI instance to plot
434 :return: the bokeh plot layout
435 """
--> 436 plot = self.plot(pm)
437 output_notebook()
438 show(plot)
File (...)/python3.10/site-packages/Visual_MIDI-1.1.0-py3.10.egg/visual_midi/visual_midi.py:223
214 box = BoxAnnotation(bottom=pitch,
215 top=pitch + 1,
216 fill_color="gray",
(...)
220 line_width=1,
...
365 if not matches:
366 matches, text = sorted(properties), "possible"
--> 368 raise AttributeError(f"unexpected attribute {name!r} to {self.__class__.__name__}, {text} attributes are {nice_join(matches)}")
AttributeError: unexpected attribute 'render_mode' to Label, possible attributes are angle, angle_units, background_fill_alpha, background_fill_color, border_line_alpha, border_line_cap, border_line_color, border_line_dash, border_line_dash_offset, border_line_join, border_line_width, coordinates, group, js_event_callbacks, js_property_callbacks, level, name, propagate_hover, subscribed_events, syncable, tags, text, text_align, text_alpha, text_baseline, text_color, text_font, text_font_size, text_font_style, text_line_height, text_outline_color, visible, x, x_offset, x_range_name, x_units, y, y_offset, y_range_name or y_units
It might be a package versioning issue (?). I hope it helps, I would love to play around with your package.
When running this bit of code from your chapter 2 notebook:
from visual_midi import Plotter
# Write the resulting midi file to the output directory
midi_file = os.path.join("output", "out.mid")
mm.midi_io.note_sequence_to_midi_file(sequence, midi_file)
print("Generated midi file: " + str(os.path.abspath(midi_file)))
# Write the resulting plot file to the output directory
plot_file = os.path.join("output", "out.html")
print("Generated plot file: " + str(os.path.abspath(plot_file)))
pretty_midi = mm.midi_io.note_sequence_to_pretty_midi(sequence)
plotter = Plotter()
plotter.show(pretty_midi, plot_file)
I get the following stack:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-8-a86b0a44e9cc> in <module>
11 pretty_midi = mm.midi_io.note_sequence_to_pretty_midi(sequence)
12 plotter = Plotter()
---> 13 plotter.show(pretty_midi, plot_file)
c:\anaconda3\envs\magenta\lib\site-packages\visual_midi\visual_midi.py in show(self, pm, filepath)
402 :return: the bokeh plot layout
403 """
--> 404 plot = self.plot(pm)
405 if self._live_reload:
406 html = file_html(plot, CDN)
c:\anaconda3\envs\magenta\lib\site-packages\visual_midi\visual_midi.py in plot(self, pm)
123 plot = bokeh.plotting.figure(
124 tools="reset,hover,previewsave,wheel_zoom,pan",
--> 125 toolbar_location=preset.toolbar_location)
126
127 # Setup the hover and the data dict for bokeh,
c:\anaconda3\envs\magenta\lib\site-packages\bokeh\plotting\figure.py in figure(**kwargs)
1362
1363 def figure(**kwargs):
-> 1364 return Figure(**kwargs)
1365 figure.__doc__ = Figure.__doc__
1366
c:\anaconda3\envs\magenta\lib\site-packages\bokeh\plotting\figure.py in __init__(self, *arg, **kw)
164 process_axis_and_grid(self, opts.y_axis_type, opts.y_axis_location, opts.y_minor_ticks, opts.y_axis_label, self.y_range, 1)
165
--> 166 tool_objs, tool_map = process_tools_arg(self, opts.tools, opts.tooltips)
167 self.add_tools(*tool_objs)
168 process_active_tools(self.toolbar, tool_map, opts.active_drag, opts.active_inspect, opts.active_scroll, opts.active_tap)
c:\anaconda3\envs\magenta\lib\site-packages\bokeh\plotting\_tools.py in process_tools_arg(plot, tools, tooltips)
126 list of Tools objects added to plot, map of supplied string names to tools
127 """
--> 128 tool_objs, tool_map = _resolve_tools(tools)
129
130 repeated_tools = [ str(obj) for obj in _collect_repeated_tools(tool_objs) ]
c:\anaconda3\envs\magenta\lib\site-packages\bokeh\plotting\_tools.py in _resolve_tools(tools)
166 continue
167
--> 168 tool_obj = Tool.from_string(tool)
169 tool_objs.append(tool_obj)
170 tool_map[tool] = tool_obj
c:\anaconda3\envs\magenta\lib\site-packages\bokeh\models\tools.py in from_string(cls, name)
156 if not matches:
157 matches, text = known_names, "possible"
--> 158 raise ValueError(f"unexpected tool name '{name}', {text} tools are {nice_join(matches)}")
159
160 @classmethod
ValueError: unexpected tool name 'previewsave', possible tools are pan, xpan, ypan, xwheel_pan, ywheel_pan, wheel_zoom, xwheel_zoom, ywheel_zoom, zoom_in, xzoom_in, yzoom_in, zoom_out, xzoom_out, yzoom_out, click, tap, crosshair, box_select, xbox_select, ybox_select, poly_select, lasso_select, box_zoom, xbox_zoom, ybox_zoom, save, undo, redo, reset, help, box_edit, point_draw, poly_draw, poly_edit or hover
Would have prevented #1
Hello!
The plot currently shows pitch (y-axis) against time (x-axis). May I ask how the axes can be switched? (ie. time against pitch instead).
Thank you!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.