Re: The problem of Lilypond changing instrument and the issue of .ly converting to MIDI with a custom setting

2022-08-15 Thread Jacques Menu
Hello Angie,

> Le 4 août 2022 à 04:48, 柊希里子  > a écrit :
> 
> My workflow is needed to be an automation script, cause I want to create a 
> tool to generate the annotation of each note automatically. The process is 
> like the below:
> 
> Turn the .xml file into .ly,
> Ideally, I want to eliminate all the decorations, like accent, staccato, any 
> kind of ornament, and tempo-related expression.
> Such as --nd, do not convert directions (^, _ or -) for articulations, 
> dynamics, etc.
> Command example: musicxml2ly -v --nd --midi --output="1_Bach_Prelude1.ly 
> " ./1_Bach_Prelude1.xml
> In the .ly file, convert the instrument into Violin or Cello, no matter what 
> kind of instrument the score was originally made for, because the String 
> instrument will get a more stable note duration of MIDI file than the 
> Woodwind or Piano.
> 
> In the .ly file, eliminate all the tempo expressions, and set the tempo to 
> BPM=60.
> For the same reason as 2nd step, this step aims to get a more stable note 
> duration.
> 
> The steps 2 and 3 I wrote a python code to replace the tempo and want to 
> change the instrument clef, see the attachment “replace_tempo.py”.
> Command example: `python replace_tempo.py --path ./1_Bach_Prelude1.ly 
> `, then output the file named just add the 
> `_replace` afterward, like: `1_Bach_Prelude1_replace.ly 
> `

Automatising such steps thru options is what xml2ly, a part of the MusicFormats 
library, is about, maybe it can help you.

The user doc is at 
https://github.com/jacques-menu/musicformats/blob/master/documentation/MusicFormatsUserGuide/MusicFormatsUserGuide.pdf
 

 .

HTH!

JM



Re: The problem of Lilypond changing instrument and the issue of .ly converting to MIDI with a custom setting

2022-08-03 Thread 柊希里子
My workflow is needed to be an automation script, cause I want to create a
tool to generate the annotation of each note automatically. The process is
like the below:


   1.

   Turn the .xml file into .ly,
   1.

  Ideally, I want to eliminate all the decorations, like accent,
  staccato, any kind of ornament, and tempo-related expression.
  2.

  Such as --nd, do not convert directions (^, _ or -) for
  articulations, dynamics, etc.

Command example: musicxml2ly -v --nd --midi --output="1_Bach_Prelude1.ly"
./1_Bach_Prelude1.xml

   1.

   In the .ly file, convert the instrument into Violin or Cello, no matter
   what kind of instrument the score was originally made for, because the
   String instrument will get a more stable note duration of MIDI file than
   the Woodwind or Piano.



   1.

   In the .ly file, eliminate all the tempo expressions, and set the tempo
   to BPM=60.

For the same reason as 2nd step, this step aims to get a more stable note
duration.

The steps 2 and 3 I wrote a python code to replace the tempo and want to
change the instrument clef, see the attachment “replace_tempo.py”.

Command example: `python replace_tempo.py --path ./1_Bach_Prelude1.ly`,
then output the file named just add the `_replace` afterward, like:
`1_Bach_Prelude1_replace.ly`


   1.

   Then use the lilypond command “lilypond -dmidi-extension=mid MyFile.ly”
   to convert the .ly file into a .mid file.

The output file has 2 formats PDF and MIDI, the filename called:
`1_Bach_Prelude1_replace.mid` and `1_Bach_Prelude1_replace.pdf`


   1.

   Using the MIDI and original XML file, I can use my python script to get
   each note’s information, specifically, the attribute I want is listed
   below: ['Onset', 'Offset', 'MIDI number', 'Pitch name', 'Duration',
   'Staff', 'Measure', 'Beat in Measure']


I've done the few annotations by manually going through steps 1~4, now I
want to automate the full workflow, the target annotation example is put in
the directory, ./ideal_piano_example.

For a better explanation of my tiny example, I create a Git repository,
https://github.com/snowmint/Note_annotation, if my description has any
unclear parts please let me know I’ll try to explain each step more clearly
as possible.

Sincerely,

Angie Wei.


Carl Sorensen  於 2022年8月3日 週三 晚上10:05寫道:

> Welcome to lilypond, Angie!
>
> On Wed, Aug 3, 2022 at 7:16 AM 柊希里子  wrote:
>
>> Hello, everyone on the mail list, I'm new to lilypond.
>>
>> I have a list of questions below which I haven’t been able to solve
>> despite my best effort searching on the internet.
>>
>> 1. How do I convert the piano clef to violin and cello clef?
>>
>
> You need to change the PianoStaff to a StaffGroup.  And then you will need
> to set the instrumentName for each staff appropriately.
>
>
>> I've tried to modify the \set section, but converting it into MIDI and
>> then opening it still didn't change the instrument:
>>
>> = Original score ===
>> \new StaffGroup \with { systemStartDelimiter =
>> #'SystemStartBrace }
>> <<
>> \new PianoStaff
>> <<
>> \set PianoStaff.instrumentName = "Piano"
>> \set PianoStaff.midiInstrument = #"acoustic grand"
>> \context Staff = "1" <<
>> \mergeDifferentlyDottedOn\mergeDifferentlyHeadedOn
>> \context Voice = "PartPOneVoiceOne" {
>>  \PartPOneVoiceOne }
>> >> \context Staff = "2" <<
>> \mergeDifferentlyDottedOn\mergeDifferentlyHeadedOn
>> \context Voice = "PartPOneVoiceThree" {  \voiceOne
>> \PartPOneVoiceThree }
>> \context Voice = "PartPOneVoiceTwo" {  \voiceTwo
>> \PartPOneVoiceTwo }
>> \context Voice = "PartPOneVoiceFour" {  \voiceThree
>> \PartPOneVoiceFour }
>> >>
>> >>
>> >>
>> = Turn into below ==
>> \new StaffGroup \with { systemStartDelimiter =
>> #'SystemStartBrace }
>> <<
>> \new Staff
>> <<
>> \set Staff.instrumentName = "Violin"
>> \set Staff.midiInstrument = #"violin"
>>
>> \context Staff = "1" <<
>> \mergeDifferentlyDottedOn\mergeDifferentlyHeadedOn
>> \context Voice = "PartPOneVoiceOne" {
>>  \PartPOneVoiceOne }
>> >> \context Staff = "2" <<
>> \mergeDifferentlyDottedOn\mergeDifferentlyHeadedOn
>> \context Voice = "PartPOneVoiceThree" {  \voiceOne
>> \PartPOneVoiceThree }
>> \context Voice = "PartPOneVoiceTwo" {  \voiceTwo
>> \PartPOneVoiceTwo }
>> \context Voice = "PartPOneVoiceFour" {  \voiceThree
>> \PartPOneVoiceFour }
>> >>
>> >>
>> >>
>> 

Re: The problem of Lilypond changing instrument and the issue of .ly converting to MIDI with a custom setting

2022-08-03 Thread H. S. Teoh
On Wed, Aug 03, 2022 at 09:15:12PM +0800, 柊希里子 wrote:
>Hello, everyone on the mail list, I'm new to lilypond.
> 
>I have a list of questions below which I haven’t been able to solve
>despite my best effort searching on the internet. 
> 
>1. How do I convert the piano clef to violin and cello clef?

\clef treble
\clef bass


T

-- 
Who told you to swim in Crocodile Lake without life insurance??



Re: The problem of Lilypond changing instrument and the issue of .ly converting to MIDI with a custom setting

2022-08-03 Thread Eef Weenink
I think the fastest way to learn this, is to study the templates available: 
https://lilypond.org/doc/v2.22/Documentation/snippets/templates

Choose one what looks like you want, copy paste it into your .ly
and then change small things % in front of a line, so you see what happens.

and keep what you want. Eef

Op 3 aug. 2022, om 15:15 heeft 柊希里子 
mailto:starlitnight0...@gmail.com>> het volgende 
geschreven:

\new StaffGroup \with { systemStartDelimiter =
#'SystemStartBrace }
<<
\new Staff
<<
\set Staff.instrumentName = "Violin"
\set Staff.midiInstrument = #"violin"

\context Staff = "1" <<
\mergeDifferentlyDottedOn\mergeDifferentlyHeadedOn
\context Voice = "PartPOneVoiceOne" {  \PartPOneVoiceOne }
>> \context Staff = "2" <<
\mergeDifferentlyDottedOn\mergeDifferentlyHeadedOn
\context Voice = "PartPOneVoiceThree" {  \voiceOne 
\PartPOneVoiceThree }
\context Voice = "PartPOneVoiceTwo" {  \voiceTwo 
\PartPOneVoiceTwo }
\context Voice = "PartPOneVoiceFour" {  \voiceThree 
\PartPOneVoiceFour }
>>
>>
>>



The problem of Lilypond changing instrument and the issue of .ly converting to MIDI with a custom setting

2022-08-03 Thread 柊希里子
Hello, everyone on the mail list, I'm new to lilypond.

I have a list of questions below which I haven’t been able to solve despite
my best effort searching on the internet.

1. How do I convert the piano clef to violin and cello clef?

I've tried to modify the \set section, but converting it into MIDI and then
opening it still didn't change the instrument:

= Original score ===
\new StaffGroup \with { systemStartDelimiter =
#'SystemStartBrace }
<<
\new PianoStaff
<<
\set PianoStaff.instrumentName = "Piano"
\set PianoStaff.midiInstrument = #"acoustic grand"
\context Staff = "1" <<
\mergeDifferentlyDottedOn\mergeDifferentlyHeadedOn
\context Voice = "PartPOneVoiceOne" {
 \PartPOneVoiceOne }
>> \context Staff = "2" <<
\mergeDifferentlyDottedOn\mergeDifferentlyHeadedOn
\context Voice = "PartPOneVoiceThree" {  \voiceOne
\PartPOneVoiceThree }
\context Voice = "PartPOneVoiceTwo" {  \voiceTwo
\PartPOneVoiceTwo }
\context Voice = "PartPOneVoiceFour" {  \voiceThree
\PartPOneVoiceFour }
>>
>>
>>
= Turn into below ==
\new StaffGroup \with { systemStartDelimiter =
#'SystemStartBrace }
<<
\new Staff
<<
\set Staff.instrumentName = "Violin"
\set Staff.midiInstrument = #"violin"

\context Staff = "1" <<
\mergeDifferentlyDottedOn\mergeDifferentlyHeadedOn
\context Voice = "PartPOneVoiceOne" {
 \PartPOneVoiceOne }
>> \context Staff = "2" <<
\mergeDifferentlyDottedOn\mergeDifferentlyHeadedOn
\context Voice = "PartPOneVoiceThree" {  \voiceOne
\PartPOneVoiceThree }
\context Voice = "PartPOneVoiceTwo" {  \voiceTwo
\PartPOneVoiceTwo }
\context Voice = "PartPOneVoiceFour" {  \voiceThree
\PartPOneVoiceFour }
>>
>>
>>


Ideally, I’d like to convert the left image to the right image:
[image: image.png]

2. How do I delete all the tempo expressions of the music score in the .ly
file, and set the tempo to BPM=60?

I have replaced all the \tempo tag with \tempo 4=60, but after I tried the
command 'lilypond -dmidi-extension=mid MyFile.ly', the tempo of the
outputted MIDI file didn't seem to be changed.

the \midi section of .ly file: \midi { \tempo 4=60 }

3. I wonder if the "-dmidi-extension" command is still being maintained.
Since I try to convert the .ly file into a .mid file with BPM=60, and
changed the piano into violin and cello timbre, but that didn't work. Are
there any other approaches to convert .ly into .mid?

Thanks for reading my questions. Any help or input from you will be greatly
appreciated.

Sincerely,
Angie Wei