jFugue incorrectly parsing tempo - parsing

I'm using jFugue to parse a midi file and it will always parse the tempo incorrectly(I know that the tempo is 140 and it is saying that the tempo is 720). At first I thought that it might, somehow, be multiplying the actual tempo by some number and that's not it. The number it's giving me is somehow related to the tempo, but I don't know how. This whole thing is very confusing, any help would be greatly appreciated.

Here it says that if you're using a version of JFugue before 4.0, tempo is stored as microseconds per beat, which is 60000 / BPM
http://www.jfugue.org/javadoc/org/jfugue/Tempo.html
Correction:
The conversion information on that page is incorrect.
PPQ (pulses per quarter, or microseconds per beat) = 60,000,000 / BPM

Related

SPSS gives out wrong N calculation in crosstabs

I asked SPSS to calculate a crosstab for me, but the N comes out as N=1001, when - looking at the numbers - it should be N=1002?
How could this be possible?
Thank you for your help!
picture of reverenced crosstab
As I haven't seen yor data structure I am not sure if this is what the problem is caused by, but this problem has been reported by IBM before for string variables. In case you have stored the data as a string varaible (eg. "35 bis 54 Jahre", I would recommed recoding it either numerically or into shorter strings (max. 8 characters).
Here is the Link to IBMs page: https://www.ibm.com/support/pages/crosstabs-display-wrong-count-and-totals-large-dataset-and-long-string-variable-table

Nested iif statement to round to nickels! Will it work? AKA Penny Rounding

I have searched the web over, and have found very little dealing with this. I wanted to know if there are any deeper issues that I am unware of getting the results this way. the [total] variable represents the calculated total owing. PayAmt represents what the customer will pay when paying cash only.
PayAmt: FormatCurrency(
IIf(Right(Str(Round([total],2)),1)="1",[total]-1,
IIf(Right(Str([total]),1)="2",[total]-2,
IIf(Right(Str([total]),1)="3",[total]+2,
IIf(Right(Str([total]),1)="4",[total]+1,
IIf(Right(Str([total]),1)="6",[total]-1,
IIf(Right(Str([total]),1)="7",[total]-2,
IIf(Right(Str([total]),1)="8",[total]+2,
IIf(Right(Str([total]),1)="9",[total]+1,[total])))))))))/100
This does on its face give the results as expected, I am just not sure IF I should approach this issue this way?
0.98 - 1.02 = 1.00
1.03 - 1.07 = 1.05
Having not seen anything like this, I suspect it can't be this easy. I just don't know why.
Thanks for any help!
Never use string handling for numbers.
Here is an article about serious rounding including all necessary code for any value and data type of VBA:
Rounding values up, down, by 4/5, or to significant figures

Convert MusicTimeStamp (AudioToolbox) to Milliseconds

I am using the MIKMIDI framework and this is using the AudioToolbox type MusicTimeStamp
How can i convert this timestamp to milliseconds?
The MusicTimeStamp is a raw beat count, you need to know the tempo (and tempo map, tempo isn't an invariant) of the music you're working with in order to convert this into milliseconds.
Outside of a MusicSequence a MTS can't be mapped to a wall time.
Edit: A CoreMedia CMTime can be converted to wall times if that helps.
There's new API for this in MIKMIDI. It's in a branch (1.8) as I write this, but should be merged soon, and released in the 1.8 release. It makes it much easier to do the conversion you're asking about.
In the context of a sequence, do:
let seconds = sequence.timeInSeconds(forMusicTimeStamp: musicTimeStamp)
There's also a method to convert in the opposite direction. MIKMIDISequencer has very similar, but more sophisticated (to account for looping, tempo override, etc.) methods to do the same kinds of conversions.
Without this new API in MIKMIDI, you can still use MusicSequenceGetSecondsForBeats(). You can get the underlying MusicSequence for an MIKMIDISequence using its musicSequence property:
var timeInSeconds = Float64(0)
MusicSequenceGetSecondsForBeats(sequence, musicTimeStamp, &timeInSeconds)
As far as I know this doesn't take into account looping even if you're doing it with the MusicPlayer API, and certainly not an overridden tempo if one is set on MIKMIDISequencer, so you should prefer MIKMIDI's API above if possible.

sqlite query for range search having text for ios app

I have a table with columns as LowerFrequency, HigherFrequency and ID. The frequencies entered have a suffix of khz or mhz. I want to search a specific frequency by checking the range it falls in i.e between the lower and higher frequencies and fetch the respective ID.
The query I implemented was as below but it returns a wrong output:
select tablename.ID where "100 khz" between tablename.LowerFrequency and tablename.HigherFrequency;
I know the reason is because of the khz that follows the integer. But I need some suggestions to handle this as I am not in a situation of changing the whole DB file because it is time consuming.
I will be integrating this DB with my iPhone app. So any solutions in Objective C would also be appreciated. I mean some kind of conversion.

iOS: Sound generation on iPad given Hz parameter?

Is there an API in one of the iOS layers that I can use to generate a tone by just specifying its Hertz. What I´m looking to do is generate a DTMF tone. This link explains how DTMF tones consists of 2 tones:
http://en.wikipedia.org/wiki/Telephone_keypad
Which basically means that I should need playback of 2 tones at the same time...
So, does something like this exist:
SomeCleverPlayerAPI(697, 1336);
If spent the whole morning searching for this, and have found a number of ways to playback a sound file, but nothing on how to generate a specific tone. Does anyone know, please...
Check out the AU (AudioUnit) API. It's pretty low-level, but it can do what you want. A good intro (that probably already gives you what you need) can be found here:
http://cocoawithlove.com/2010/10/ios-tone-generator-introduction-to.html
There is no iOS API to do this audio synthesis for you.
But you can use the Audio Queue or Audio Unit RemoteIO APIs to play raw audio samples, generate an array of samples of 2 sine waves summed (say 44100 samples for 1 seconds worth), and then copy the results in the audio callback (1024 samples, or whatever the callback requests, at a time).
See Apple's aurioTouch and SpeakHere sample apps for how to use these audio APIs.
The samples can be generated by something as simple as:
sample[i] = (short int)(v1*sinf(2.0*pi*i*f1/sr) + v2*sinf(2.0*pi*i*f2/sr));
where sr is the sample rate, f1 and f1 are the 2 frequencies, and v1 + v2 sum to less than 32767.0. You can add rounding or noise dithering to this for cleaner results.
Beware of clicking if your generated waveforms don't taper to zero at the ends.

Resources