Create MIDI files from Lilypond snippet - midi

This is not a duplicate question on how to create a MIDI file from Lilypond. I have done that many times.
I have created some lilypond snippets, and I want to extract MIDI from them. Normally I would do that in the \score block like this:
\score {
\music
\layout { }
\midi { }
}
But, my snippet does not contain a \score block; it is written like this:
\version "2.18.2"
\include "lilypond-book-preamble.ly"
\paper {
indent = 2\mm
line-width = 210\mm
}
\layout {
indent = #0
\context {
\Score
\remove "Bar_number_engraver"
}
}
\relative c'
{
\tempo 4 = 60
\clef treble \key d \major g8^\markup { C } g8 b4 b8 b8 d4 cis8 cis8 e4 b8 b8 d4
}
This code creates a perfect PDF snippet. But I don't know where to put the \midi { } block to create a MIDI file.

I think the easiest solution is to assign your music to a variable and create a \score block. Is there a reason why you are avoiding to use a \score block in your example? For instance, the code below generates both MIDI and pdf files:
\version "2.18.2"
\include "lilypond-book-preamble.ly"
\paper {
indent = 2\mm
line-width = 210\mm
}
\layout {
indent = #0
\context {
\Score
\remove "Bar_number_engraver"
}
}
music = \relative c'
{
\tempo 4 = 60
\clef treble \key d \major g8^\markup { C } g8 b4 b8 b8 d4 cis8 cis8 e4 b8 b8 d4
}
\score{
\music
\layout{}
\midi{}
}

Related

After assigning a value in my settler, checking with debugger I am getting null?

I have this dart/flutter provider
class Cars with ChangeNotifier {
List<Car> _items = [];
Car _selectedCar;
final Auth auth;
Cars(this.auth, this._items);
List<Car> get items {
return [..._items];
}
Car get getCar {
return _selectedCar;
}
void setSelectedCar(Car car) {
_items.add(car);
_selectedCar = car; // here I am getting null from _selectedCar
notifyListeners();
}
}
Checking with the debugger using Android Studio 3.5.1 I can check that I have in my car variable a real car:
car = {Car} _listeners = {ObserverList} () id = 156 shasi =
"FDGFGFDGDFGFD" brand = "Renault" model = "Talisman E1 & E2"
nomer = "FGBFDFG"
But when debugger go to line 78 and I see the _selectedCar value is null
I've noticed that sometimes, the debugger is actually several lines behind the line highlighted by the IDE. So in your example, line 77 may have not been executed yet, even though line 78 is highlighted.
I don't know exactly why this happens - it's a bit quirky and over time you will get to learn which are the lines that the debugger is never accurate about, and which lines are always accurate. For example, a breakpoint on if (true) { will never be hit. For those reasons, I would recommend avoiding manually stepping over/into once a breakpoint is hit. Instead, click to set breakpoints on all the different lines that you are interested in, and resume running.
For your use case I would suggest putting breakpoints on lines 78 and 79. Closing brackets such as line 79 are always hit.
Looks like
selected car = car
is an variable inside a class.
Do you have any async method running in the background?
Maybe someone is changing the value, while you look at it.

Fantom fwt Combo widget seems to fire modify event on construction

I have written this Fantom class
using gfx
using fwt
class Test {
Window window := Window {
size = Size( 400, 320 )
SashPane {
Combo {
items = Month.vals
onModify.add( |e| { echo( "items.size is ${e->widget->items->size}" ) } )
},
},
}
Void main() {
window.open
}
}
when I run it, it produces this output:
items.size is 12
items.size is 12
which means that the modify event is being triggered twice. It occurs at the same time the window pops up on the screen, without me having any chance to modify anything on the Combo widget. Why?
This is causing issues in a real class that uses multiple Combo widgets, some of them related and causing a cascade of events that produces unexpected results.
Is there any way this can be prevented, please?
I can confirm that this is an issue.
Looking at the Java source code for the FWT Combo, it's pretty small and doesn't seem to do anything wrong, which leads me to believe that it's a issue with the SWT Combo Widget.
That doesn't help you any, so I had a quick play with the example and found this work around...
...add the onModify event listener after the window has been opened, and the widgets constructed. Do this by using the Window.onOpen() event:
using gfx
using fwt
class Testy {
Void main() {
Window {
size = Size( 400, 320 )
combo := null as Combo
onOpen.add {
combo.onModify.add { echo("Hello Mum!") }
}
SashPane {
combo = Combo { items = Month.vals },
},
}.open
}
}
Now you should only get a Hello Mum! when the combo is actually modified.

NetBeans IDE - How do i make indent lines, where i have largest and longest if while for brakets, can not find start and end now

I have my Java/C code running in NetBeans IDE. Where i have some mess algorithms which is like largest/longest something like following:
if () {
while() {
for() {
}
}
} elseif( ) {
for() {
while() {
for() {
}
}
}
} elseif( ) {
do {
for () {
if() {
} else {
}
}
} while() ;
} elseif( ) {
switch() {
if(a.starsWith()) {
for() {
do {
for() {
if() {
} elseif() {
} else {
switch() { }
}
}
} while();
}
}
}
} elseif( ) {
} elseif( ) {
} elseif( ) {
}
Therefore, to find out how do i get this following type of indent highlighted lines?
The vertical lines you see in Notepad++ are not available in NetBeans. But I didn't try the new NetBeans 7.2 beta yet...
From version of Netbeans 8.0 indent lines are available out of the box.
In netbeans 8.1 tools>options>Fonts&Colors>Category>Indent Guide Lines then change Forground to your likeing.
Not sure what your question is, and the image you attached is too small:-(
Anyways, you can specify the type of indent you want NetBeans to use for your code in Preferences -> Editor -> Formatting. You can choose the indents to be tabs, or (recommended) spaces. There is a box where you type in the number of spaces you want per tab.
Also, you can make NetBeans format the code automatically for you, under Source -> Format.
Hope this helps!
Are you looking to highlight lines or just indent your code correctly?
If it is the latter, select all your code, then from the menu bar select Source -> Format.
That should resolve the issue.

ZXing problem when find qr code that does not know

I have a question ...
I am using ZXing lib to recognize two types of QRCode (for
iphone application)
everything works fine ....
I use this method to analyze the results:
- (void)zxingController:(ZXingWidgetController*)controller didScanResult:(NSString *)result {
if([result isEqualToString:#QRCODERESULT_TYPPE_01])
{
...CASE 01
}
else if([result isEqualToString:#QRCODERESULT_TYPPE_02])
{
... CASE 02
}
}
This code works fine if I find a QRCode type 01 or 02 but when I try with another QRCode not know the controller is still some green squares ...
how can I reset the controller when it reads a QRCode I do not care?
txy
Dismiss the qr scanning controller regardless of whether the scanned QR code is the one you want or not.
- (void)zxingController:(ZXingWidgetController*)controller
didScanResult:(NSString *)result {
// always dismiss the qr controller
[self dismissModalViewControllerAnimated:NO];
if (qr code is of type 1) {
// do something if qr 1
}
else if (qr code is of type 2) {
// do something with qr 2
}
}

How do I inspect and interact with trails in KRL?

I have a trail that I'm using to track app history in KRL. I'm looking for an easy way to debug the trail, including seeing what is currently on the trail and clearing it.
Is there an easy way to do that in KRL?
The easiest way, for me, to see what is on the trail is to output it's contents to the browser console.
rule inspect_data_on_trail {
select when pageview ".*"
pre {
visitedDomains = ent:visitedDomains;
}
{
emit <|
console.log(visitedDomains);
|>;
}
}
firebug output after running ruleset several times:
To clear entity variables including trails, I usually just write a rule that selects on a domain that isn't part of my app's experience and clear the varaibles when the app is run on that domain.
rule clear_everything {
select when pageview "yahoo\.com"
{
notify("Cleared",":)") with sticky = true;
}
fired {
clear ent:visitedDomains;
}
}
Full example app:
ruleset a60x458 {
meta {
name "trail-debugging"
description <<
trail-debugging
>>
author "Mike Grace"
logging on
}
rule put_data_onto_trail {
select when pageview ".*"
pre {
domain = page:url("domain");
}
{
notify("Thanks for visiting #{domain}","You visit has been recorded") with sticky = true;
}
fired {
mark ent:visitedDomains with domain;
}
}
rule inspect_data_on_trail {
select when pageview ".*"
pre {
visitedDomains = ent:visitedDomains;
}
{
emit <|
console.log(visitedDomains);
|>;
}
}
rule clear_everything {
select when pageview "yahoo\.com"
{
notify("Cleared",":)") with sticky = true;
}
fired {
clear ent:visitedDomains;
}
}
}