Get the tempos of a parsed MusicXML file - music21

In MusicXML, there can be direction tags that have <sound> tags, which sets the BPM. For example,
<direction placement="above">
<direction-type>
<words>Molto vivace</words>
</direction-type>
<staff>1</staff>
<sound tempo="260"/>
</direction>
Is it possible to get the tempo markings located by their offset in a Measure?
Edit: I used a piece downloaded from MuseScore. I have currently found a solution that requires preprocessing the XML file before parsing it. The XML file I used had <direction> elements that had the <sound> element but did not have a <metronome> element. So what I did was after every <direction> element that had a <sound> element, I added a new <direction> element that has a <metronome> element, this seems to be the only way music21 will actually parse the <sound> element, where it is then usable with Stream.metronomeMarkBoundaries. Example:
<direction placement="above">
<direction-type>
<metronome parentheses="no" default-y="40.00" relative-x="-39.33" relative-y="3.81">
<beat-unit>half</beat-unit>
<per-minute>128</per-minute>
</metronome>
</direction-type>
<staff>1</staff>
<sound tempo="256"/>
</direction>

Related

Selenium chrome error using wild cards in SwitchTo().Frame("xxx*yy")

Hi I am challenged by this error using Wildcard(*) in a string to locate a frame !
When i write the complete name of the iFrame in the statement, it has no issues finding the Frame .
Your thoughts are appreciated!
driver.SwitchTo().Frame("*_ifr")
OpenQA.Selenium.NoSuchFrameException: 'No frame element found with name or id *_ifr'
When I enter the entire frames name like below, it works just fine
driver.SwitchTo().Frame("txt-client-instructions_ifr")
I expect the wildcard will find the following iframes
1st txt-client-instructions_ifr
2nd 107314_100323_ifr
3rd 107341_100324_ifr
4th 100321_macrotext_ifr
SwitchTo().Frame() is the method to give you access to switch frames and windows. The argument type is of String. As an example:
driver.SwitchTo().Frame("FrameName");
String doesn't support wildcards where as By.CssSelector or By.XPath supports wildcards.
Hence,
driver.SwitchTo().Frame("txt-client-instructions_ifr")
is successful, where as:
driver.SwitchTo().Frame("*_ifr")
raises OpenQA.Selenium.NoSuchFrameException.

Document each element of an array using spring-restdocs

I'm having a response which is an json array. Each element has it's meaning and I would be able to describe it.
My array:
["1525032694","300","true"]
I've found an example in the documentation that describes an array and each element which is the same:
https://docs.spring.io/spring-restdocs/docs/current/reference/html5/#documenting-your-api-request-response-payloads-fields-reusing-field-descriptors
But I would like to know how I can describe each of it as:
current timestamp, seconds to next measurement, should perform fota
My current test:
webTestClient.post().uri("/api//measurement/${SampleData.deviceId}")
.syncBody(SampleData.sampleMeasurement())
.exchange()
.expectStatus()
.isOk
.expectBody()
.consumeWith(document("add-measurement", responseFields(
fieldWithPath("[]")
.description("An array of device settings"))
))
Ok, it turns that be fairly easy:
responseFields(
fieldWithPath("[0]").description("Current timestamp"),
fieldWithPath("[1]").description("Device mode"),
fieldWithPath("[2]").description("Device parameter")
),

How to get the XML elements using AngularJS

I am retrieving some XML files from the server and I want to get elements by some tags. But It shows me an error to catch the element by tag. Can somebody help me to get the element by tag(tag name also contains dots)?
XML File
<org.openmrs.module.Module>
<name>OpenHMIS Inventory Module</name>
<moduleId>openhmis.inventory</moduleId>
<author>OpenHMIS</author>
<version>2.3.4</version>
</org.openmrs.module.Module>
My AngularJS Code,
function(data){
$scope.name=data.['org.openmrs.module.Module'].name;
}

Import timeseries via loop (pot. generic)

Solved, now working example!
I have a set of time series that is populated in a folder structure as follows:
TimeSeriesData\Config_000000\seed_001\Aggregate_Quantity.txt
…
TimeSeriesData\Config_000058\seed_010\Aggregate_Quantity.txt
And in each file there is a first line containing a character, followed by lines containing the data. E.g.
share
-21.75
-20.75
…
Now, I would like to import all those files (at best, without specifying ex post the number of configs and seeds, at worst with supplying it) into single time series of the like: “AggQuant_config_seed” where config relates to the config ID and seed to the seed id.
I tried the following (using the non-preferred way), but “parsing” the “path” does not work / I do not know how to do it.
string base = "TimeSeriesData/Config_"
string middle = "/seed_"
string endd = "/Aggregate_Quantity.txt"
string path = ""
loop for (i=0;i<=58;i+=1)
loop for (j=1;j<=10;j+=1)
path = ""
sprintf path "%s%06d%s%03d%s",base,i,middle,j,endd
append #path #will be named share
rename share Agg_Q_$i_$j #rename
endloop
endloop
To sum up the problem, the following does not work:
string path="somwhere/a_file.txt" #string holding path
#wrong: append $path #use append on string
append #path #works!
And if possible, a way to search recursively through a set of folders, using the folder information together with file-information for the variable name, would be nice. Is that possible within gretl?
I realize that in many cases I would like to refer to a specific “help” section like those for functions and commands, but for operators instead (like “$”, which is obviously wrong here).

camel: split the message into multiple processing paths

My input message:
<file>
<node1>
...
</node1>
.....
<node10>
.....
</node10>
</file>
I want to:
Process the whole file using stylesheet and output to Dest A
For a few elements in the file (say, node1, node3 and node7) I want to extract them and output the content of each individually to Dest B
I know how to process the file using stylesheet but I'm at a loss how to do the other, let alone combine them together.
I'm looking for something like:
from(direct:start).magic_split(
to("xslt:mysheet").to("destA"),
setBody(xpath("//node1").to("destB"),
setBody(xpath("//node3").to("destB"),
setBody(xpath("//node7").to("destB"),
).transform(constant(responseOK);
if you can split the XML, then each node is put in it's own exchange, if you can identify the node after it is split, then you can use a Content Based Router to route the exchange to the appropriate destination. This might require a custom splitter bean, or you might be able to do it from xpath if the nodes are named nodeX where X is a number.
Use the Wire Tap pattern. This pattern allows you to route messages to a separate location while they are being forwarded to the ultimate destination:
from("cxf:bean:submitOrder")
.wireTap("direct:tap")
.beanRef("customBean2");
from("direct:tap")
.to("xslt:my.xsl")
.beanRef("customBean1);
For what I needed, custom beans did the job well. The only thing I had to figure out was how to restore the message to the original content. I guess there is a more elegant way of doing it but works fine:
from("cxf:bean:submitOrder")
.setProperty("originalData", simple("${in.body}")) //save original input msg
.to("xslt:my.xsl").beanRef("customBean1)
.setBody(simple("${property.originalData}")) //restore original message
.beanRef("customBean2");

Resources