From fbc7f271077db99bfdd9721974ecefbc30c5096b Mon Sep 17 00:00:00 2001 From: Samuel Janas Date: Sat, 11 Nov 2023 13:23:07 +0100 Subject: [PATCH] code syntax highlighting, example section for Vis --- docs/assets/pianoroll.png | Bin 0 -> 19929 bytes docs/examples/visualizations.md | 36 ++++++++++++++++++++++++++++++++ mkdocs.yml | 13 ++++++++++++ 3 files changed, 49 insertions(+) create mode 100644 docs/assets/pianoroll.png create mode 100644 docs/examples/visualizations.md diff --git a/docs/assets/pianoroll.png b/docs/assets/pianoroll.png new file mode 100644 index 0000000000000000000000000000000000000000..577a9846808eaa95e002d39fbedd660153133deb GIT binary patch literal 19929 zcmeIa1yq%3+cvxr#Y6^C5h*1F6qH6vk&sqWkP<<E577OLt31cjx}j z8^?KO-g)AkdEamS|G(BhYdvf8xc9!}y3aU{<28ekIi9X}oegW74?*VO=3d zr{~XOT(6#xxsQb_cNPol$RW}0jbD64zpw08)cWJU3=It43Efi5w6K$sd_AUl#@DvV zvFWXdygXbB3U$l^-}vakU%#9N@&f43oPRH>Hc4 zB*hb}ma$WkjltbQek`n9I+}!%jm=|WZmKlwp4a7r4QlNGM= z>#Goi)i-iq#&ayLm^+2m$tY-_J3M1{`0u7j7uIPDdioyQLRf<7(tx3@T z1z!V+BBYGryl2tzw481i9T^#+qM;G?_4CtSoos=ZQFMbB|NfPMV(TFHa}0G~2-UAD zs+he>Q!DNLqK|z2iYn)kUhT(KZ+(K)>_l;JFH*${zw#Jvr;?jKbF9 zXT0&91$5B*T%UNRTB%lNni2)Y@__Y_sFPD!{Tgzhdv@1dR9Q_1d4hRtvm_$3US3dezG#M#h{HI{)zxyg`#!s2 z_oXJDmA95NopZC~>O8&|LQNlOGI^)D8itTCfApZy(KTik@e$jc*p}xJwn)PMYuDe@oHK)}QBcxN>A0MPfPl4e& zqaq+rP4S$G9Jxr&FVD?eYJ4cESy*JBG`u(K-ErWHysA=guQ$(#A%I@qH(oplr^LC| zm%6pYcI96D!Ga`LKXy@Vj}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>9`gR$(9q7kP$CPE9;q@DUqcgZZEfwKn(P67_9kv++ncqtqSO0y@F0O~o(byz`)Q=q98# z>{Aa%NCaXicrh4jx83w2CWd05%n?zu*@i#X0XJz!Y9P7&>_>0QfPS)?rlzhYevAsa z%`g^1xbpNn#E`!+;}FOxaAQ0~fnQ*>JPjsbTIND9<04HK0k;V2 z?o5AJ6LD=v1$NmZr47&#dDcQAOR1He8#D_?*m!>+#z0|2>@1)L=_BMJB{k!OUR#f+ z0tixq&=L}$V+ylg12YlAS^%k(f_B-nmf*`BZEkLE`RV2H5O42aauSASZmy+;1Jsrj z7jK)K)SZJig1O99!IM29Aqf~RQB|E<wX*?Kd|{HySIicNZy(%me0*W}$OeeT zGaZWR>4?ule zq}GE962tkN!ZSQfwA2KjB~ryTP0R@u>S%E2bs5>N8(l-c{lErG_Ee8@{hb(?Rm zqS(Vtg4~8=ql+@ccHl=*+Cad((`s3!O5N3A(Zox*%J|+(HVO-6sstAXkHG^r*FtIE z9NLGONDXGk86)kqJw=-g0+U?YgZs!DT1^T=3JrgTU6*)D#qi^b~-7O<)eG#tgw+ zD<-8Cba|zZnqO=k`;%o8>i}D5?eA{2g5IrEYL{DCU9G<81RJ;s5KC;i2C_pMG(rq& z-L7;QG@bC3rajMgj(FLD?=bn^>Sn*uc>j^AzU!`CBY~S zQK^|>JM>U#14umapjODhX0l%bu}~VPe;fG!<7au0neczZ#r#(y84j4Xh`~y7({rwA Sm&ij-ASxs!m?5C?{Qm$0Lb2!o literal 0 HcmV?d00001 diff --git a/docs/examples/visualizations.md b/docs/examples/visualizations.md new file mode 100644 index 0000000..ad4e6f4 --- /dev/null +++ b/docs/examples/visualizations.md @@ -0,0 +1,36 @@ +# Example usage of Fortepyan + +As a first example, we will create a random midi piece and display it as a piano roll. + +``` py title="Getting started" +import pandas as pd +import numpy as np + +import fortepyan as ff + +from matplotlib import pyplot as plt +from fortepyan.view.pianoroll.main import draw_pianoroll_with_velocities + +np.random.seed(42) # Fix the seed for reproducibility + +# Create a dataframe with random values +random_df = pd.DataFrame( + { + "start": [i for i in range(0, 100)], + "duration": [np.random.uniform(0.5, 1.5) for i in range(0, 100)], + "pitch": [np.random.randint(45, 90) for i in range(0, 100)], + "velocity": [np.random.randint(45, 90) for i in range(0, 100)], + } +) +random_midi = ff.MidiPiece(random_df) # Create a MidiPiece object + +# Let's assume we're interested in notes 5-24 +interesting_part = random_midi.trim(5, 24, slice_type="index") +fig = draw_pianoroll_with_velocities(interesting_part) + +plt.show() + +``` + +The outcome you should expect is: +![Piano roll](../assets/pianoroll.png) diff --git a/mkdocs.yml b/mkdocs.yml index 411d5ba..0d03346 100644 --- a/mkdocs.yml +++ b/mkdocs.yml @@ -36,13 +36,26 @@ theme: - search.suggest - search.highlight - content.action.edit + - content.code.copy nav: - Home: - Welcome to Fortepyan: index.md - Documentation: - Midi Dataclass: documentation/midi_classes.md + - Examples: + - Visualizations: examples/visualizations.md + plugins: - search - mkdocstrings + +markdown_extensions: + - pymdownx.highlight: + anchor_linenums: true + line_spans: __span + pygments_lang_class: true + - pymdownx.inlinehilite + - pymdownx.snippets + - pymdownx.superfences