Calculating a Web Audio API filter's response at a specific frequency and Q-factor - math

I'm using the Web Audio API to make a graphic EQ with four BiQuad filters; a highpass, two bandpass and a low pass:
You can see each node representing each filter's frequency. It's working nicely but I'd like to draw the shape of the filter's roll-off you'd usually find in other graphic EQ's.
I have the Q-factor of each filter and the central frequency. What I would like to do is get a formula that allows me to get the frequency of the roll-off at a specific db value. For example what is the frequency of the roll-off at -200db?
It's been a while since I've done any heavy mathematical stuff and so any help would be greatly appreciated.

Have you looked at the getFrequencyResponse method of BiquadFilterNode? https://dvcs.w3.org/hg/audio/raw-file/tip/webaudio/specification.html#Methods.
This demo from my IO2012 Web Audio talk uses it: http://webaudio-io2012.appspot.com/frames/frequency-response.html. You'll have to calculate the responses of multiple filters stacked together from there, of course.

Related

setDataCleaningThreshold for Area Range Series

I saw in version 3.00 there is something called setDataCleaningThreshold , Can you tell its benefits , I think it's for faster loading of progressive charts.
const dcThreshold = xVal - 100;
lineSeries.setDataCleaningThreshold(dcThreshold);
AreaRangeSeries.setDataCleaningThreshold(dcThreshold); // not working
But it's not working for Area range series.
Also there is setMaxPointCount in Area range Series , what is the difference between both ?
My charts are progressive and I want to clear the charts that are out of view and make the charts faster.What is the best way ? Can I use Dispose method ?
Also , can we drag the chart by left click + mouse drag. . I saw something like API for Axis mouse and touch events is released.Can you tell what can be achieved with this.
(right now its right click + drag).
it's not working for Area range series.
setDataCleaningThreshold is new API that will be slowly introduced to existing series. With v3.0 it is only introduced for LineSeries and its derivatives (like PointLineSeries).
To prevent confusion, please refer to official API documentation to see if some method is supported - for example if we look at AreaSeries, it is not part of the API.
Also there is setMaxPointCount in Area range Series , what is the
difference between both ?
setMaxPointCount and setDataCleaningThreshold exist for the same purpose, and effectively achieve the same things, but they are based on slightly different ideas.
setMaxPointCount configures automatic data cleaning by specifying amount of data points to retain at the "head" of data.
setDataCleaningThreshold configures automatic data cleaning by specifying a coordinate on progressive axis. All data points that are "behind" this coordinate can be cleaned whenever convenient. This configuration is slightly preferred over "max points count" as it is more convenient for the rendering engine, and it also behaves slightly more logically - if you apply the fit() operation by dragging to top-left in chartXY with left mouse click, the axis will stop at data cleaning threshold, instead of showing all data including the data behind cleaning threshold.
Both of these methods will be supported for the time being and there should not be major differences between using either, so I recommend use whichever you feel more comfortable with.
Eventually the data cleaning configuration will settle down to a simpler API, but now we're still feeling how different users are using the library, and how we can optimize the performance best - so the API is a bit messy (as in, there are 2 methods for same purpose).
My charts are progressive and I want to clear the charts that are out
of view and make the charts faster.What is the best way ?
For AreaSeries setMaxPointCount is the only automatic option.
Please see the updated documentation on the method to learn more.
You can also implement manual data cleaning using dispose method, as you suggested.
However, please see if automatic data cleaning works for you first.

Does JMeter have "User-Defined Data Point Graphs" like LoadRunner?

I am looking for a feature in Apache JMeter. I need the equivalent feature that I use with MicroFocus LoadRunner called "User-Defined Data Point Graphs".
From LR User Guide
The User-Defined Data Point graphs display the values of user-defined data points. You define a
data point in your Vuser script by inserting an lr_user_data_point function at the appropriate place
In pratice I want to use "JSR223 PostProcessor" and via code add values to a time serie. This time serie will be plotted on time based graph. In LR with line of code
lr_user_data_point ("data_point_1",1);
The UI shows a new data serie on plot that can be used as additional report (generate plot, median, table, etc...).
Thanks
Vincenzo
No there is no such feature in JMeter.
You can request an enhancement but ensure you explain:
What is the aim of this feature ?
What benefits it brings
See:
https://jmeter.apache.org/issues.html
Edit on 3 august 2018:
In upcoming JMeter 5.0, it will be possible to graph over time custom variables. See https://bz.apache.org/bugzilla/show_bug.cgi?id=62166
at this point there are three possible solution:
Open a new feature request as suggested by #UBIKLOADPACK
Develop a JMeter plugins using TestBean framework as described into link
Export a time-series to Grafana (or similar) using BackEnd Listener
Regards

How to Quickstart Graphhopper with my own multimodal graph

I would like to implement my own routing web service in play framework (due to the fact that it's java and it's a rapid prototyping framework). I also would like to use graphhopper as the routing engine.
My Basic requirements are:
The routing should be based on our own multimodal graph database (consisting of EDGES/LINKS and NODES and also different properties to derive weights from
I want to be able to select different properties for edge weighting during runtime (i.e. an emergency vehicle can take routes, normal cardrivers aren allowedto use)
The graph spreads over half the size of austria (approx. 800.000 edges).
At the moment I have a lot of questions, and don't really know where to begin:
Is the transport vehicle type defined with EncodingManager only, or is it possible to change it during a route? (without rebuilding the graph while runtime)
Whats exactly the difference between RAMDataAccess and MMapDataAccess? Does the latter mean, that the graph is (partly) stored on disc? Does the first mean the graph is only stored in Memory?
I dont understand the NextA and NextB Properties of the EDGE object...what about crossings with 3 or more EDGEs? Which one is NextB from each of the other ones?
Does "...where nodeA is always smaller than nodeB..." mean that the ID has always to be smaller? What about graph direction (i.e. an EDGE pointing to the other direction)?
More questions to come up....
What I did so far:
I was going through the graphhopper docs starting with the developer snippets and the low level API but on th page it says that this is outdated?!?! (What does that mean?)
I also checked the web subfolder of the graphhopper github repository, but there is only a ready-to-use graphhopper webservice based on OSM data built in there.
Unfortunately I could not find any more comprehensive example including building a graph with MMapDataAccess (edit thanks for the tip to look into the unit tests, I think I'll find mor there)
I'd be very grateful to anybody here, who could please give me some examples how to build up my own graph and use (or rebuild it?) when weighting parameters change.
EDIT: tried to make my points clearer
select different properties for edge weighting during runtime out of our database
If you want to select the weighting at runtime you should avoid triggering an external database. It will slowdown everything. Instead feed the weights you have into the GraphHopperStorage itself. Every edge is a row in a big table. Just add one more column per weight you need:
E_CUSTOM_WEIGHT = nextEdgeEntryIndex();
The graph spreads over half the size of austria (approx. 800.000 edges)
Not sure what you mean with multimodal graph (also timedependent?). If normal road network 800k is not much. Whole germany is ten times large and fits into under 1gb
Regarding quickstart. Just the wiki for the low level API is outdated. Have a look into the unit tests of LocationIndexTree for the current usage. (maybe you can update the wiki afterwards :))
Unfortunately I could not find any more comprehensive example including building a graph with MMapDataAccess.
you just change the config or if you prefer low level API:
graph = new GraphHopperStorage(new MMapDirectory(), encodingManager)
Anybody here can give me some examples how to build up my own graph and rebuild it,when weighting parameters change.
have a look into the unit tests. Lots of examples how to build a graph. With 'rebuilding' - what do you mean? Do you mean the CH preparation? CH preparation is not possible if you want to calculate weight at runtime.

GTFS/NextBus/Google Maps - transit distance traveled

I am trying to get the distance traveled on a transit route -- particularly San Francisco MUNI, but the standards NextBus, GTFS, and Google Maps API appear to be universal. I'm comfortable using any of these APIs, I'm just not sure how to go about this problem.
The easy way - ask Google Maps (this using webservices, but there is also the javascript API):
http://maps.googleapis.com/maps/api/directions/json?origin=37.7954199,-122.397&destination=37.7873299,-122.44691&sensor=false&mode=transit&departure_time=1348109609&alternatives=true
this JSON includes distance traveled, but there are two issues:
Google does not allow you to use this data unless you're displaying a map, which I don't want to do
I would need to ensure that the distance returned is for the correct route/line, since it can/will give multiple routing options. This is probably doable but would require more logic.
EDIT: using alternatives=true (or provideRouteAlternatives: true using the javascript API) only returns a maximum of 3 routes, which here in SF often doesn't include the route I'm looking for (other transit agencies, multiple lines on the same route, etc). So this isn't such a great option.
NextBus:
example route config:
http://webservices.nextbus.com/service/publicXMLFeed?command=routeConfig&a=sf-muni&r=1
The coordinates for each stop are given, but connecting the dots on those is not the same as the route taken -- it will cut corners, etc, and I need this to be accurate. The actual route taken is given under <path>/<point>, but I don't see any obvious correlation between stop and path coordinates. Plus, NextBus says in their documentation (p.10 near the bottom) that you should NOT connect points between <path> segments, they're only meant for drawing on a map and can overlap.
GTFS:
The GTFS data also separates stop and "shape" coordinates (like NextBus paths). Unfortunately, the coordinates are slightly different for the same stops between NextBus and GTFS (rounding), though the stop ID/tags are the same. Also, the data files are in the megabytes, and I need to use this for a mobile app. I suppose I could put all the data in a database and query that, but that still leaves figuring out how to correlate the stops with the shape. The "shapes_distance_traveled" column in the shapes.txt file is especially promising. MUNI chooses to leave the optional "shapes_distance_traveled" field out of stop_times.txt, though.
Any advice would be appreciated, I understand this seems like an epic task to get a simple value. Maybe I'll just throw a map in to legitimately use the distance :)
Instead of using Google Maps, I would look into the un-encumbered licensing of OpenStreetMap. There are multiple
routing engines that can use OSM data. Personally, I would use routing in PostGIS or SQLite, but depending on your skillset you might choose another.
You've clearly done your research, (+1), and as you said, the easy way is to ask Google. If it is worth for you then you might want to look into purchasing a business licence to use the Google Maps API, and negotiate with them about the requirement of displaying a map. That's the only legal way I can think of with the Google API. Alternatively, you can try building you own routing engine with data from the TIGER data set, which is freely available from the US Census Bureau, but again, as you said, it may seem like an epic task. :-)

Create directions on a map based on custom data

So what I'm trying to do is the following:
Have a map (such as Google Maps or questMaps). It doesn't matter at all which API I need to use.
On that map have an overlay on the streets. So say (for example) the street has bad lightning at night, it will be colored red. If it has good lightning it will have a green overlay.
Based on the overlay the map creates a custom route (for example the user only wants to walk on the green/well lit streets).
I have no idea how to accomplish this (especially step 3).
First, you'll have to decide what data you need. How do you categorize certain streets as lit or unlit? What if some parts of a street are well lit and some have no lights? Do you need to know the location of every streetlight in your area? What if lights burn out?
After figuring out what data you need, you need to build your dataset. I'd be VERY surprised if this data already exists, so you will probably need to gather it yourself. Either go around town and take notes, or crowdsource the project, or figure out some other way.
Once you have gathered your data, learn the drawing API of whatever mapping tool you wish to use. They all should have functions in their API for drawing colored lines (for streets) or points (for streetlights) on top of an existing map.
Finally, learn the navigational API of the mapping tool you chose. You're right, this is a hard step. I know Google Maps lets you specify certain waypoints when requesting directions; maybe your app can calculate well-lit waypoints and feed them to Google Maps' Directions service to influence the route it generates.
Good luck!
For custom routing, you need to read up on "Graph Theory". This ignores the geography of the street map, and considers it as a set of junctions (nodes or vertices in the graph theory jargon) connected by edges. You can assign weights to edges - these could be lengths, travel times, ones and zeroes etc. Anything. They can have no relation to the position on the map.
So for your application, you'd assign a large weight to unlit streets, and a small weight to lit streets, then use a standard minimum-weight algorithm to get a route from one node to another.

Resources