I have note like
<note default-x="106.96" default-y="-25.00">
<pitch>
<step>A</step>
<octave>3</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>eighth</type>
<stem>up</stem>
<staff>1</staff>
<beam number="1">begin</beam>
</note>
How can i find what time spend to play it (in second) if tempo = 120bpm ?
Create a table like this:
durationHashTable = {
{ "whole", 4.0 },
{ "half", 2.0 },
{ "quarter", 1.0 },
{ "eighth", 0.5 },
{ "16th", 0.25 } }
Then, the formula is:
noteDurationSeconds = ( 60.0 / beatsPerMinute ) * durationHashTable["eighth"];
This is for the special, simple case where
notes are not dotted
the time signature has <beat-type>4</beat-type>
you are not required to support tuplets.
Things can become significantly more complex, but I would recommend working with this special case first.
Related
I am developing a portal with Blazor. The website will show some timeseries data in a chart.
For the charts I use Blazorise.Charts (1.0.5).
I want the chart to show the full date at the start of a day and between the days only hours (in a 24h format) and minutes. However it seems the Blazorise LineChartOptions do not accept my input.
My data model:
public class point
{
public double Value;
public DateTime ReceivedOn;
}
The options I use
public LineChartOptions _LineChartOptions { get; set; } = new LineChartOptions()
{
Parsing = new ChartParsing
{
XAxisKey = "ReceivedOn",
YAxisKey = "Value",
},
Scales = new ChartScales()
{
X = new ChartAxis()
{
Display = true,
Type = "timeseries",
Title = new ChartScaleTitle
{
Display = true,
Text = "Date"
},
Ticks = new ChartAxisTicks
{
StepSize = 1,
Major = new ChartAxisMajorTick
{
Enabled = true
},
},
}
}
}
I also tried adding the Time = new ChartAxisTime, but that option does not seem to work if you use Ticks.
The result I get when using these settings is:
Chart
Like you can see, it seems almost what I want, however the labels need to be in the HH:mm format and the date needs to be in the yyyy-MM-dd format.
What do I need to change to get this result?
I ran into the same issue. Honestly, after reading the Chart.js documentation, I just stopped trying to feed DateTime objects directly into the blazorise chart. According to the Chart.js documentation, it must be converted somewhere in blazorise, because the dates are fed into Chart.js as strings anyway. So I converted my DateTime[] to a string[] with DateTime pattern "O" (o Format Specifier de-DE Culture 2008-10-31T17:04:32.0000000) and everything went fine.
Furthermore, try time first instead of timeseries as the x scale type. Type timeseries behaves strangely on non-equidistant data.
My LineChartOptions:
public static LineChartOptions CreateLineChartOptions()
{
return new LineChartOptions()
{
Scales = new ChartScales()
{
X = new ChartAxis()
{
Type = "time",
Time = new ChartAxisTime()
{
Unit = "minute",
MinUnit = "minute"
}
}
}
};
}
My labels are wrongly formatted like yours; I'm still working on that.
My Razor Call:
<LineChart #ref="lineChart" TItem="double" Options="#LineChartOptions" />
For a minimum example, you can even leave the ChartAxisTime() object. It should run without it.
My minimal result:
In Tone.js I have made a class that creates a synth instance where .play() is called in a sequencer function, thereby playing a sound. In the class below there are absolutely no problems when this.synth in updateSynthType is a monophonic Tone.Synth, but the whole thing breaks when it is Tone.Polysynth and I receive the following error when trying to call updateSynthType.
Uncaught Error: Synth was already disposed
at ti (Tone.js:1)
at ra._scheduleEvent (Tone.js:21)
at Object.callback (Tone.js:21)
at Gi._timeoutLoop (Tone.js:21)
at Gi.emit (Tone.js:7)
I don't understand why this never happens with a regular Tone.Synth but when I try to change a Tone.PolySynth an error appears. I am trying to update the settings to change between the type of polysynth (e.g. Synth, AMSynth, MetalSyth etc). How can I stop this problem? Why does this class only work for a regular Tone.Synth? Is there a better way of updating the PolySynth type in this class?
Here is the class in question:
class PolyInstrument {
constructor(){
this.synth = null
this.gain = new Tone.Gain()
this.gain.toDestination()
}
play(note = null, beat, time = null){
if (this.synth){
if (note === null){
time ? this.synth.triggerAttackRelease(beat, time) : this.synth.triggerAttackRelease(beat)
} else {
time ? this.synth.triggerAttackRelease(note, beat, time) : this.synth.triggerAttackRelease(note, beat)
}
} else {
alert('error: no synth')
}
}
get defaultSettings(){
return {
Synth: {
oscillator: {
type: 'triangle'
},
envelope: {
attack: 0.005,
decay: 0.1,
sustain: 0.3,
release: 1
}
},
AMSynth: {
harmonicity: 3 ,
detune: 0 ,
oscillator: {
type: 'sine'
},
envelope: {
attack: 0.01 ,
decay: 0.01 ,
sustain: 1 ,
release: 0.5
},
modulation: {
type: 'square'
},
modulationEnvelope: {
attack: 0.5 ,
decay: 0 ,
sustain: 1 ,
release: 0.5
}
}
}
}
updateSynthType(synthType){
if (this.synth){
this.synth.disconnect(this.gain)
this.synth.dispose()
}
let settings = this.defaultSettings[synthType] || {}
this.synth = new Tone.PolySynth(Tone[synthType], settings)
this.synth.connect(this.gain)
this.play()
}
}
Thanks for reading.
Instead of using synth.dispose(), call synth.releaseAll().
https://tonejs.github.io/docs/14.7.77/PolySynth#releaseAll says:
Trigger the release portion of all the currently active voices immediately. Useful for silencing the synth.
I was able to fix this by clearing out the context timeline before disposing:
synth.context._timeouts.cancel(0);
synth.dispose();
I would like to send simultaneous requests through gatlings for some duration
below is the snippet of my code where I am crafting the requests.
JSON file contents function which is used for crafting the json. its been used in the main request
the TestDevice_dev.csv has list of devices till 30 after 30 I will reuse it.
TestDevice1
TestDevice2
TestDevice3
.
.
.
val dFeeder = csv("TestDevice_dev.csv").circular
val trip_dte_tunnel_1 = scenario("TripSimulation")
.feed(dFeeder)
.exec(session => {
val key = conf.getString("config.env.sign_key")
var bodyTrip = CannedRequests.jsonFileContents("${deviceID}")
//deviceId comes from the feeder
session.set("trip_sign", SignatureGeneration.getSignature(key, bodyTrip))
session.set("tripBody",bodyTrip)
})
.exec(http("trip")
.post(trip_url)
.headers(trip_Headers_withsign)
.body(StringBody("${tripBody}")).asJSON.check(status.is(201)))
.exec(flushSessionCookies)
the scenario is started as below
val scn_trip = scenario("trip simulation")
.repeat{1} {
exec(DataExchange.trip_dte_tunnel_1)
}
setUp(scn_trip.inject(constantUsersPerSec(5) during (5 seconds))) ```
it runs fine if there is 1 user for 5 seconds but not simulatenous users.
the json request which is crafted looks like the below
"events":[
{
"deviceDetailsDataModel":{
"deviceId":"<deviceID>"
},
"eventDateTime":"<timeStamp>",
"tripInfoDataModel":{
"ignitionStatus":"ON",
"ignitionONTime":"<onTimeStamp>"
}
},
{
"deviceDetailsDataModel":{
"deviceId":"<deviceID>"
},
"eventDateTime":"<timeStamp>",
"tripInfoDataModel":{
"ignitionStatus":"ON",
"ignitionONTime":"<onTimeStamp>"
}
},
{
"deviceDetailsDataModel":{
"deviceId":"<deviceID>"
},
"eventDateTime":"<timeStamp>",
"tripInfoDataModel":{
"ignitionOFFTime":"<onTimeStamp>",
"ignitionStatus":"OFF"
}
}
]
}`
`def jsonFileContents(deviceId: String): String= {
val fileName = "trip-data.json"
var stringBuilder=""
var timeStamp1:Long = ZonedDateTime.now(ZoneId.of("America/Chicago")).toInstant().toEpochMilli().toLong - 10000.toLong
for (line <- (Source fromFile fileName).getLines) {
if (line.contains("eventDateTime")) {
var lineReplace=line.replaceAll("<timeStamp>", timeStamp1.toString())
stringBuilder=stringBuilder+lineReplace
timeStamp1 = timeStamp1+1000.toLong
}
else if (line.contains("onTimeStamp")) {
var lineReplace1=line.replaceAll("<onTimeStamp>", timeStamp1.toString)
stringBuilder=stringBuilder+lineReplace1
}
else if (line.contains("deviceID")){
var lineReplace2=line.replace("<deviceID>", deviceId)
stringBuilder=stringBuilder+lineReplace2
}
else {
stringBuilder =stringBuilder+line
}
}
stringBuilder
}
`
Best guess: your feeder contains one single entry and you're using the default queue strategy. Either add more entries in your feeder file to match the number of users, or use a different strategy.
This really is explained in the documentation, including the tutorials. I recommend you take some time to read the documentation before rushing into the code, you'll save lots of time in the end.
You don't need to do your own parameter substitution of values in the json file - Gatling supports passing en ELFileBody as the body where you can have a json file with gatling EL expressions like ${deviceId}.
Interesting behavior in FlipClock library (http://flipclockjs.com/)
The following code works fine:
clock1 = $('.clock1').FlipClock( {
clockFace: 'TwentyFourHourClock'
});
However, if you include an adjustment for timezone, then it starts incrementing seconds by 2:
clock1 = $('.clock1').FlipClock(3600 * 3, {
clockFace: 'TwentyFourHourClock'
});
Any help on this would be appreciated!
Why isn't my score recording on the playerprefs ? is there GetFloat method? Can anyone help me to post the least score of my game it just like the most least seconds will get the best time record ever
var myTimer: float = 0;
var GUITimer: GUIText;
function Start() {
}
function Update() {
GUITimer.text = "Time: " + myTimer;
if (myTimer > -1) {
myTimer += Time.deltaTime;
}
}
function OnTriggerEnter(other: Collider) {
if (other.tag == "FinishLine") {
SaveTime();
}
}
function OnGUI() {
GUI.Label(Rect(10, 10, 500, 200), myTimer.ToString());
}
function SaveTime() {
if (myTimer < PlayerPrefs.GetInt("JeepneyScore3")) {
PlayerPrefs.SetInt("JeepneyScore3", myTimer);
}
Application.LoadLevel("Levels");
}
I see three problems:
First, you're tracking a float, but calling GetInt() and SetInt(). Keep your data types consistent. You should either round/floor/etc, or call GetFloat() and SetFloat().
Second, you're not calling Save(), which means your changes will never write to disk. You might consider something like this:
PlayerPrefs.SetFloat("JeepneyScore3", myTimer);
PlayerPrefs.Save();
Third, you're not handling the case where no data exists. You could check for existing data with HasKey(), but in this case it's simpler to rely on the second form of GetFloat(). The default form, which you're calling, returns zero if the requested key isn't set:
//returns value of "foo", or zero if no such value
var prevBest = PlayerPrefs.GetFloat("foo");
If you're looking for a time below the player's previous best, but the default "best" is already 0.0, you're going to have a hard time beating that time.
You can instead provide your own default value:
//returns value of "foo", or ten thousand if no such value
var prevBest = PlayerPrefs.GetFloat("foo", 10000.0);
Finally, you should make sure that SaveTime() is actually being called at the appropriate time. You could add a simple debug line, like this:
Debug.Log("SaveTime was called");
And then make sure that's showing up. If not, you need to fix your collision check.