Lilypond snippet for a separate coda - lilypond

I'm hoping to Lilypond something not at all uncommon in pop sheet music but missing from the snippet repository and eluding my search phrases. It's basically an inline block of coda set apart from the bars preceding it. (My attempts at the code are not match for an uploaded visual example.)
I'm guessing the ingredients are 'ragged-right', some whitespace, and a separate score {} block for the coda music itself, but is there a way to end one system and start another without a line break? (Hard to think this hasn't been done before—and even more so to imagine it couldn't be done.)
Update (March 8, 2012): I've gotten close to what I want, with the following:
\stopStaff s1 \startStaff \bar ""
\mark \markup { \musicglyph #"scripts.coda" }
\override Score.Clef #'space-alist = #'(
(cue-clef extra-space . 2.0)
(staff-bar extra-space . 0.0)
(key-cancellation minimum-space . 3.5)
(key-signature minimum-space . 3.5)
(time-signature minimum-space . 4.2)
(first-note minimum-fixed-space . 5.0)
(next-note extra-space . 1.0)
(right-edge extra-space . 0.5)
)
\override Staff.Clef #'full-size-change = ##t
\set Staff.forceClef = ##t
\clef "treble_8"
\key \default
The only thing missing from the coda is the systemStartBracket. Can anyone figure out how to insert one in the middle of a system?
Thanks.

I'd try a different approach: use a simultaneous staff as described in http://lilypond.org/doc/v2.14/Documentation/notation/modifying-single-staves#ossia-staves and vertically align it to the terminated staff.

Related

Beaming to rests in the staff in Lilypond

How do I beam from a series of notes to a rest at the same vertical position as a rest in a way that looks appealing? Relevent snippet:
\version "2.20.0"
\new Staff {
c'16[ c' \override Rest.staff-position = #1 r ]
}
What it looks like.
I think the property you are looking for is Staff.Beam.positions, which takes a pair of numbers and sets the beam anchor points, left and right, respectively. The property Stem.length only works for non-beamed stems. I personally like to change Stem.stemlet-length to a value larger than zero when beaming from/over/to a rest, as shown in my example below. Just delete that line if that's not to your liking and lower the Beam.positions to taste.
\version "2.20.0"
\new Staff {
\override Staff.Beam.positions = #'(3.5 . 3.5)
\override Staff.Stem.stemlet-length = #0.75
c'16[
c'
\override Rest.staff-position = #1
r ]
}
Result:

Parts of code skipped when calling functions in a function

I'm working on a online tutorial on Python 2.7 and on exercice is to make a basic text
game. I'm very new to programming, and still working on the basics. I wish to make "move"-function I can call in all the "rooms" in the game, and deside the movement with args. The rooms in the game will be other functions i will call in the "move"-function.
In the example below i want to make it possible to choose for 4 directions using inputs n,e,s,w but only one will take the player to the next "room"-function called room_1 (not shown in the code here).
My problem is that it does not ask for input, but jumps straight to my room_1 function. It's not even printing the print "where do you wanna go? \n"
def move(north, dest_n, east, dest_e, south, dest_s, west, dest_w):
while True:
print "Where do you wanna go? \n"
movement = raw_input()
if movement in "n":
print north
dest_n
elif movement in "e":
print east
dest_e
elif movement in "s":
print south
dest_s
elif movement in "w":
print west
dest_w
else:
print "Not a valid direction. \n"
print "Use n, e, s, or w to move."
move(
"the door is locked!", '',
"You are not going that way.", '',
"Wall.. nope, not that way!", '',
"You move through the corridor", room_1()
)
Sorry if im being unclear about something, as I'm new to programming:)
Thanks!

How to use single notes in music functions?

I want to create a function in Lilypond that accepts one note as input and returns the note with some markup applied. Specifically, I want to simplify something like the following:
\relative c' { d^\markup{\hspace #2 \smaller +1}-\bendAfter #+1 }
to something along the lines of
\relative c' { \bend{d} }
Currently I have the following snippet:
mF = \markup{\hspace #2 \smaller +1}
bF = \bendAfter #+1
bendF = #(define-music-function (parser location note) (ly:music?)
#{ $note^\mF-\bF #}
)
\relative c' { d^\mF-\bF }
\relative c' { \bendF{d} }
\version "2.16.2"
It seems that the data type ly:music? is not the right one, or it is impossible to append the markup directly, and I end up with not very descriptive interpreter errors.
What is the best way to achieve this effect?
This may be not the solution you are looking for, but you might be able to solve your problem by using an event function with no arguments instead of a music function (thus working around the ly:music? problem). Try:
\version "2.17.95"
mF = \markup{\hspace #2 \smaller +1}
bF = \bendAfter #+1
bendF = #(define-event-function
(parser location )
( )
#{
^\mF-\bF
#}
)
\relative c' { d^\mF-\bF }
\relative c' { d\bendF }

Regular Expression: adding bookmark html tags depending on various range of numbers

I have some html pages with numbers of verses like:
verses 2-5
verses 11-15
verses 21-23
I need to add for each number a code before the word "verses"
to be
<a name="2"></a><a name="3"></a><a name="4"></a><a name="5"></a>verses 2-5
etc.
So it takes the range of the numbers given, and before the beginning it adds:
<a name=""></a>
for each number in the range..
I use notepad++ to search and replace.
You're going to need a script to do this. I whipped up a simple Ruby script to do it. Used it on your sample text, got your output. Just download Ruby, paste this into a file in the directory of that text, and replace the verses.txt line with whatever your file name is. Then run it from the command line like: ruby ./script.rb
d = File.read('./verses.txt')
c = d[0..d.length]
c.scan(/(verses\s+\d+-\d+)/) do |n|
n.each do |a|
a.scan(/(\d+-\d+)/) do |nums|
z = nums.to_s.split(/-/)
st=''
in1 = z[0].gsub(/\["/, '').to_i
in2 = z[1].chomp("\"]").to_i
(in1..in2).each do |index|
st += "<a name=\"#{index}\"></a>"
end
b = st + a;
d.gsub!(a, b)
end
end
end
puts d
f = File.new('verses2.txt', "w")
f.write(d)
Per your request, here is a modification that will overwrite the opened file and run on all files in a directory. For ease, I won't do directory entry, so place the script in the directory of all the files to run it. Here goes:
Dir.entries('.').each do |entry|
entry.scan(/.*.html/) do
|fn|
d = File.read('./' + fn.to_s)
c = d[0..d.length]
c.scan(/(verses\s+\d+-\d+)/) do |n|
n.each do |a|
a.scan(/(\d+-\d+)/) do |nums|
z = nums.to_s.split(/-/)
st=''
in1 = z[0].gsub(/\["/, '').to_i
in2 = z[1].chomp("\"]").to_i
(in1..in2).each do |index|
st += "<a name=\"#{index}\"></a>"
end
b = st + a;
d.gsub!(a, b)
end
end
end
puts d
f = File.new('./' + fn.to_s, "w")
f.write(d)
end
end
I'll think about how to do the arabic encodings. This will run on all text files, if they have different extensions or have a similar name, let me know and I'll update the script.
This should fully work, just tested it. Let me know if there are issues.
You can do it for 2-digit verses 10 to 99 like this:
Search: verses (\d)(\d)-
Replace: <a name="$1">verses $1$2-</a>
For 3+ digit numbers, add another group for the extra digit(s) and treat similarly.
This extra complication is required because notepad++ doesn't support look-aheads AFAIK.

How to control indentation after an open parenthesis in Emacs

When I use emacs python-mode, if the last character of a line is an open parenthesis it indents the next line just one step in from the indentation of the previous line.
call_some_function(
some_very_long_argument_that_I_want_to_put_on_its_own_line)
I like that. Now in ecmascript-mode (which I am using for actionscript 3), it always indents to the level of the previous parenthesis.
call_some_function(
this_is_not_really_saving_me_any_horizontal_space);
How can I make ecmascript-mode indent like python-mode in this respect?
Since ecmascript-mode is based on cc-mode, you can use c-set-offset which allows you to customize any syntactic symbol's offset with the preferred value.
In your case, go to the point which is indented in the wrong level, hit C-c C-o (or type M-x c-set-offset), accept the suggested symbol (arglist-intro), and set it a new value (e.g. +, the default offset).
You can also do it programmatically in your dotemacs, for instance, with:
(add-hook 'ecmascript-mode-hook
(lambda ()
(c-set-offset 'arglist-intro '+)
(c-set-offset 'arglist-close 0)))
ecmascript-mode seems to be based on cc-mode. If you set the indentation style for cc-mode,
it will also work for ecmascript-mode. I have the following code in my .emacs. When I use
ecmascript-mode it indents as desired:
;;{{{ c/c++ indent style variables
(require 'cc-mode)
(defconst my-c-style
'(
(c-electric-pound-behavior . 'alignleft)
(c-tab-always-indent . t)
(c-hanging-braces-alist . ((block-open)
(brace-list-open)
(substatement-open)
(defun-open before after)
(defun-close before after)
))
(c-hanging-colons-alist . ((member-init-intro before)
(inher-intro)
(case-label)
(access-label after)
(label after)
(access-key after)))
(c-cleanup-list . (scope-operator
empty-defun-braces
defun-close-semi))
(c-offsets-alist . ((arglist-close . c-lineup-arglist)
(case-label . 4)
(statement-case-intro . 4)
(access-label . -4)
(label . -)
(substatement-open . 0)
(block-open . 0)
(knr-argdecl-intro . -)))
)
"My C++/C Programming Style")
; Customizations for both c-mode and c++-mode
(defun my-c-mode-common-hook ()
; set up for my perferred indentation style, but only do it once
(c-add-style "My" my-c-style 'set-this-style)
; we like auto-newline and hungry-delete
(c-toggle-auto-hungry-state 1)
; keybindings for both C and C++. We can put these in c-mode-map
; because c++-mode-map inherits it
(define-key c-mode-map "\C-m" 'newline-and-indent)
; insert 8 tabs
(setq tab-width 8)
)
;;}}}
Thank you Török Gábor, in my case I prefered to set
(add-hook 'XXX-mode-hook
(lambda ()
(c-set-offset 'arglist-cont-nonempty '+)))
I was looking for something like this :
veryLongFunctionName (bar,
bar,
bar)
For a more exhaustive list of variables : read emacs documentation