cpipkin Posted July 26, 2017 Report Share Posted July 26, 2017 (edited) Hello, I am working on code that will read a waveform of a sound pressure measurement and calculate the octave band levels. I would be incredibly grateful if someone could take a glance at my code to see what I have wired incorrectly... The issue I think I'm having: The output of the "Basic Averaged DC-RMS" output wont index when I put it into the for loop. I tried to get around this problem by building arrays for each RMS output and then indexing into the for loop. Doing this doesn't allow me to graph the output... Any ideas as to why the "Basic Averaged DC-RMS" wont index directly? The code (inspired by new NXG example) is attached, both VI's must be downloaded in order to run the "Octave Band Levels" VI. Also, I'm aware that LV has a toolkit for sound analysis & octave band analysis... but I do not have access to this toolkit, which is why i'm trying to write my own VI. Thanks in advance! Octave Band Levels.vi Waveform Butterworth Filter.vi Edited July 26, 2017 by cpipkin trying to be more specific with problem... Quote Link to comment
hooovahh Posted July 26, 2017 Report Share Posted July 26, 2017 Well did you read the description of the error, or look at the data types of the terminals and indicators? Your output is a 2D array of a cluster, and in that cluster is a 1D array of doubles. The Waveform graph can accept multiple data types, but not this. If you read the help on the waveform graph you'll see for a single plot you can either provide a waveform data type, or a cluster with the x0, deltaX, and Y values. You can also have multiple plots by providing a 1D array of these values. But honestly after all of this descriptions of what is what, the simple fix is to right click the for loop tunnel and select Tunnel Mode >> Concatenating. This makes sure the 1D array going in, doesn't get indexed into a 2D array but instead concatenates them. This can be wired to the graph on its own. Also there is a bunch of inefficiencies in that code that can be fixed with some for loops. Is this is how it is presented in the NXG example? Like that for loop will only ever run once. Quote Link to comment
hooovahh Posted July 26, 2017 Report Share Posted July 26, 2017 Attached is an updated version that I think does the same work but in a less Rube Goldberg kind of way, but I think this can be improved more. 1 Quote Link to comment
cpipkin Posted July 26, 2017 Author Report Share Posted July 26, 2017 Nice. Thanks, Hooovahh. This certainly simplifies the code & makes it easier to look at. It also solved the graphing issue i was having. Now that the graphing problem is fixed, I'm finding that this still isn't working... Perhaps it's because i'm bundling the band center frequencies instead of creating an XY? I will work on it. Octave Band Levels_Simplified.vi Waveform Butterworth Filter.vi Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.