Only one SCNAudioPlayer node plays positionally - swift

I would really like an answer to this strangeness as I've been trying to squash it all night yesterday and not wanting to go for another sleepless night.
I have an SCNScene with camera, nodes etc properly placed and added 3 audio players to 3 of the nodes in the scene. They are loaded exactly the same way but only one is positional while the two others stay static like ambient sounds.
Let me explain further:
I load every node with a node.position = SCNVector3(x,y,z)
I have a directional keyDown event listener that changes directions of the audio listener node + or - in the scene.
The audio players load with volume 1.0 looping = true and positional = true.
3 different source files are loaded, .mp3 .wav and .aiff (this latter is a dynamic to pcm render of NSSpeechSynthesis)
All three sounds load and can be heard, though only one changes position (the pcm format).
I shuffled sound source files around with the nodes and I get weird results such as nothing loading, or loading but not being positional anymore.
This is not behaviour you would expect and is totally random (or so it seems).
Can anyone please help me figure why I can only have 1 positional node in the scene?
Thanks,

Ok, after fiddling more I found the issue.
It seems as though files must be in .pcm format to be loaded to the audioEngine buffer.
It works with as many audio sources as I want but I would like to be able to load any file format and have them run properly.

Related

How to assign hardware output to a variable in codesys?

I'm actually using the Ecostruxure skin on codesys, trying to attach the output of a Modicon encoder to determine the speed a motor should go.
However, I can't figure out how to grab the variable that would correspond to that data. Any help appreciated.
The screenshots below indicate where I'm stuck. I need to create a variable of type ENC_REF_M262 however double clicking on the device does not take me to a screen I can map it with like what I've seen on a number of other devices. Obviously something I'm missing. The linking between this physical device and actually getting data from it is the part I'm struggling with.
edit: The system seems to have now correctly accepted the settings when before the reference to the variable Incremental Encoder would not be found. Seems to take a while to catch up.

ROBLOX Studio ScreenGui score display

How do I make a TextLabel's text update to a variable?
I have tried setting the text to "score: ", _G.score
but it won't update with the variable, and yes I do set the text after the variable has updated.
Code:
script.Parent.mouseClick:connect(function()
_G.score = _G.score + 1
game.StarterGui.ScreenGui.TextLabel.Text = _G.score
end)
game.StarterGui is actually a template GUI, and every time a player joins the game, a copy of it is made and given to the new player. Thus, if you try to modify it, you will not be actually modifying the copies of it that were given to all the players.
There are two solutions to this problem:
Only use relative paths—that being, only use paths to GUI objects that begin with "script." just like you said script.Parent.mouseClick:connect(…).
Iterate through all the copies that have been given out to the players. This can be found under each Player object's .PlayerGui.
You should almost never do the latter. Here's how you can decide:
If you have code that is found within the StarterGui (rather than in the Workspace or something), then you should use the former. This is because when the StarterGui gets copied into a new player's GUI (called a PlayerGui), that script will get copied along with it since it was inside of the StarterGui. Thus, a relative path like script.Parent.Something.SomethingElse.Text = "hi" will be valid; it will affect that PlayerGui.
If you have some code that is not within the StarterGui (like if it's in the Workspace), then you must use the latter. This is because such a script will not get copied into each player's PlayerGui. As a result, you must go through each player's PlayerGui in a for loop or something similar. This scenario is very rarely the case, and if it ever is, consider trying to make it not the case if possible because this is a very hairy situation to try to deal with; you have to account for special circumstances like the possibility that a player hasn't gotten a copy of the StarterGui yet.
Please let me know if this explanation was in any way confusing; I'll try my best to explain it better.
You can find some visuals to go along with this explanation and some further reading on the official ROBLOX Wiki's explanation of this topic here: "Player vs. Starter GUIs".

MIDI Note On Event Without Off Event [duplicate]

This question already has an answer here:
Synthesia plays well midi file without any note off event?
(1 answer)
Closed 5 years ago.
I made a system that takes MIDI files and creates a graphical representation of the music.
Every NoteOnEvent is when a single note starts, and every NoteOffEventwith the same note code is when it ends.
This works well for most MIDI files.
However, I am now encountering files that do not have NoteOffEvent events at all, and so I keep playing them.
What is the correct behavior when seeing for example:
midi.NoteOnEvent(tick=0, channel=0, data=[65, 127])
midi.NoteOnEvent(tick=240, channel=0, data=[65, 0])
I think if a note "on" event happens on the same note it should be like a toggle event, but I am not sure what if it is justified, or does this even happen for every midi file or just a subset that act like this?
EDIT:
I don't think this matters, but I am using python-midi to extract the tracks from midi files
It is common for a note on with 0 velocity to be interpreted as note off. I am not sure if it's part of the standard or not.

Queuing and looping buffers in OpenAL

I have question about queueing buffers in OpenAL.
I have two wave files, let's say for an engine. The first is the sound of the engine starting and the second is the engine running.
What I'm looking for is a way to create a source that plays sound 1 once and then loops sound 2 until alSourceStop() is called.
Is something like this even possible?
Thanks for your help :)
Hans
Here is come code where I stream audio using OpenAL ... the salient line is
alSourcei(streaming_source[ii], AL_BUFFER, 0);
its written for linux so OSX may require a tweak to header file locations :
https://github.com/scottstensland/render-audio-openal
let me know if your need anything explained ... enjoy

Using GPX route or track for testing in Xcode 4.2

Has anyone had any success using a GPX route or track to test location aware apps that depend on movement in Xcode 4.2? I have been able to get it to use a single waypoint in a GPX file or even get it to iterate over a series of waypoints, but I have not been able to have it follow a track in a way that would give speed and course information. I have tried with recorded tracks from driving, hand made routes and tracks, and routes made with Trailrunner.
It may be that this functionality just is not available, but Apple does provide a freeway drive in the simulator. I want to be able to do something similar on device and in a location that I can specify. Anybody have any thoughts?
The best way is to create your own simulator class to read the file and generate CLLocation events, which gives you complete control. GPX files don't contain speed and heading, so you'll have to calculate them yourself. The basic simulation loop I've used is:
Simulate{
if (!eof) {
Read the next waypoint
Calculate distance, dt (delta time), bearing and speed (distance/dt) from the previous waypoint
Generate a CLLocation object and call the didUpdateToLocation delegate method
Peek at the next waypoint and calculate next_dt
Scale next_dt // as desired for faster playback (e.g. dt/2 would be 2x)
Start an NSTimer with next_dt as the duration
}
}
When the timer fires, call Simulate again
Note: Until recently, synthesizing CLLocations was somewhat problematic since CLLocation is immutable and the init method had no way to set speed and heading. This was remedied in iOS 4.2.
The Freeway Drive appears to be defined by a 1.6 MB file in /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk/System/Library/Frameworks/CoreLocation.framework/Support/SimulationScenarios/Freeway Drive.plist. It's a dictionary with two keys, Options and Locations. Options itself is a dictionary with two keys and can probably be reverse engineered. Locations, on the other hand, is a large array (2240 items) of NSData, each one about 724 bytes. The first eight bytes decode to "bplist00", so each of these is a plist. I wrote one to disk, but Xcode's property list editor claims it is corrupted.
The directory where that file is is also where the other canned locations and routes live. I duplicated one of the files and restarted the simulator, and the new file showed up in the Debug menu.
The biggest issue with adding your own files is that a future Xcode update might erase them, but that's not such a big deal if you keep the originals somewhere.
You can plot complex routes using Google Maps and then convert them to a compatible GPX file using https://mapstogpx.com/mobiledev.php