Breaking News
Comments
Newest First | Oldest First | Threaded View
<<   <   Page 3 / 3
Max The Magnificent
User Rank
Blogger
Re: Here's a few other "pointers"
Max The Magnificent   4/23/2014 10:19:40 AM
NO RATINGS
@JeffL: Is the processing just going to send any and all filtered data to the display (more or less "peak-reading") or will there be peak-holding or even sample averaging? (There's a popular type of display that holds and illuminates peaks WHILE the instantaneous values dance beneath them, that actually has some utility as well.)

I was planning with the "any and all" approach to start off with. But then start playing with some more interesting effects like holding and illuminating the peaks -- and then having them gradually fall -- with the instantaneous values "dancing" below. (I wouldn't know "sample averaging" if it crawled up my leg and bit me in an unfortunate place).

Check out my earlier blogs on this BADASS Display tracing my thoughts (including some videos I saw on YouTube) and you will see just how little of a clue I have (Part 1, Part 2, Part3, and Part 4).

Max The Magnificent
User Rank
Blogger
Re: Here's a few other "pointers"
Max The Magnificent   4/23/2014 10:09:21 AM
NO RATINGS
@JeffL: I guess this will just be the monophonic combination of left and right?

I'm intending to drive this from my iPad. I plan on feeding the stereo signal in. I plan on having several modes. One will be mono (I was thinking of sampling both channels, adding them together, and dividing by two) -- in which case the entire horizontal axis could be used to display the spectrum data from this mono channel.

I would also like to play with stereo displays. One way would be to split the horizontal axis into two 8-channel bands. Another way would be to keep the 16 bands, but display the left channel "growing up from the bottom" (to a max of 8 pixels tall) and the right channel "growing down from the top)" (to a max of 8 pixels).

Max The Magnificent
User Rank
Blogger
Re: Here's a few other "pointers"
Max The Magnificent   4/23/2014 10:03:37 AM
NO RATINGS
@JeffL: If you divide it into 16 bands then I suppose they could be 2/3-octave wide each, of course you CAN do it that way (and digital filters can be created that are just that wide) but it kind of guarantees that the display won't be terribly "relevant" or meaningful (not that it has to be).

I'm not so worried about the display being "relevant" as "looking pretty" -- what I really need is for someone who knows what they are talking about to say something like "OK Max, it's obvious you don't have a clue -- let's say the bottom frequency 'bucket' includes 50Hz and below, the top 'bucket' encompases 16KHz and above, and this is the way you should partition the rest of the spectrum into your remaining 14 'buckets'"

Max The Magnificent
User Rank
Blogger
Re: Here's a few other "pointers"
Max The Magnificent   4/23/2014 9:59:48 AM
NO RATINGS
@JeffL: Regarding the general direction of the project, it looks as if you're trying to display the audio frequency spectrum by dividing it into 16 equal bands.

First let me remind you that if you go back to the beginning of this project, I did say that I don't really have a clue what I'm doing on the audio side -- I'm learning (or making it up) as I go along.

One of my early questions was whether the frequency spectrum (think horizontal axis) should be divided in a linear (equal bands) or logarithmic manner.

Max The Magnificent
User Rank
Blogger
Re: An object, not a function
Max The Magnificent   4/23/2014 9:55:31 AM
NO RATINGS
@DrMark: Consider the following code...

I can barely wrap by brain around C, let alone C++, but I think I see what you are doing. I will try writing something based on thsi and see if it compiles.

stwomey0
User Rank
Rookie
Goertzel verses FFT
stwomey0   4/23/2014 9:08:32 AM
NO RATINGS
If you are still pondering about frequency detection you might conceder using the Goertzel algorithm to detect the energy in the 16 bins.  The algorithm is more efficient then an FFT when measuring the energy at specific frequencies.

djohns
User Rank
Rookie
Addresses and objects
djohns   4/23/2014 7:59:34 AM
NO RATINGS
Perhaps an analogy might help with the pointer mystery:


Consider two ways you could get a package delivered to your house.  The normal way: you give UPS your address and they send a cheerful driver in a brown truck to plunk the package down on your porch.


To save your poor driver some time, you could instead make a duplicate of your house, hire a house mover to move the house to the local UPS office where they put the package on the porch and have the mover bring the house back to you.  The mover demolishes your original house and replaces it with the house that has your package which you open only to discover it's the wrong color and you have to ship it back....


Passing pointers instead of the whole object is more efficient.  Of course there are some down sides to this.  Giving your address to some hoodlums who come over and have a huge party and trash the place is not good.  In that case, making a duplicate of the house that they can do what they want to with is a good option.  You could also lock up certain parts of the house and post big signs that say "PRIVATE KEEP OUT" in those critical areas. Let them do what they want in the tornado shelter, just keep them out of the room with all the expensive antiques.


Pointer to a function? Same idea except now the memory pointed to contains code instead of data.  It's like the address of your lawn mower.  So you tell your son to work on his homework and every time he finishes one assignment to start the mower and mow one section of the lawn.  You also tell him where the mower is in case he forgot. You sit in the garage watching the mower and every time you see it start up you know that another assignment was finished.

 

JVISOSKY000
User Rank
Rookie
Re: An object, not a function
JVISOSKY000   4/23/2014 12:21:42 AM
NO RATINGS
Mark,

In your code, the line:

    strip[i] = Adafruit_NeoPixel(16, i);

is making use of an implicitly defined assignment operator, which I believe will only do a shallow copy.  (There is a temporary Adafruit_NeoPixel created on the stack, which is then copied into the Adafruit_NeoPixel at strip[i].)

I'm assuming that the Adafruit_NeoPixel is the one defined here:

https://github.com/adafruit/Adafruit_NeoPixel/blob/master/Adafruit_NeoPixel.h

which may have problems with shallow copies because the class includes a couple of pointers (like 'pixels').

Better would be to declare the strip array as pointers, and use the 'new' operator:

Adafruit_NeoPixel* strip[16];

for (int i=0; i < 16; i++) {
    strip[i] = new Adafruit_NeoPixel(16, i);
}

Then just use the pointers in the loop:

for (int i=0; i < 16; i++) {
    light_strip(strip[i], value);
}

My C++ may be a little rusty, but I believe the above is correct.

JV



JeffL_2
User Rank
CEO
Here's a few other "pointers"
JeffL_2   4/22/2014 11:20:57 PM
NO RATINGS
Max,

Regarding the general direction of the project, it looks as if you're trying to display the audio frequency spectrum by dividing it into 16 equal bands. Actually that's kind of a bizarre selection, it's typically looked on as 30 or 31 1/3-octave bands, or 10 one-octave bands. If you divide it into 16 bands then I suppose they could be 2/3-octave wide each, of course you CAN do it that way (and digital filters can be created that are just that wide) but it kind of guarantees that the display won't be terribly "relevant" or meaningful (not that it has to be). And I guess this will just be the monophonic combination of left and right? Is the processing just going to send any and all filtered data to the display (more or less "peak-reading") or will there be peak-holding or even sample averaging? (There's a popular type of display that holds and illuminates peaks WHILE the instantaneous values dance beneath them, that actually has some utility as well.) Also I imagine you'll want to make this display logarithmic, with each LED representing 2 or 3 decibels higher level, and maybe even make the lower LEDs represent larger values (so the display comes closer to handling the much larger dynamic range that the ear responds to than just 32 or 48 decibels)? Will there be a provision to "calibrate" this so it can read actual sound levels? How about a "master level" channel to one side to show the unfiltered level? (You ought to think about whether you keep the lowest position always "on" as a kind of visual "anchor", it's commonly done that way anyway.) How is color going to be applied, there's a convention that "acceptable" levels at the bottom are green, levels above that are yellow, even higher are red, will you "go conventional" or do something out of the ordinary? These are all the kind of decisions you ought to think about before taking this to the next stage. (Then again maybe I'm just a LITTLE obsessive about this stuff since I used to design audio gear for sale to pros, back in another lifetime and maybe another universe, I can't really recall right now...)

DrMark0
User Rank
Rookie
An object, not a function
DrMark0   4/22/2014 6:42:41 PM
NO RATINGS
Hi Max,

In C (and in C++) it is important to always keep straight the difference between an object and a pointer to an object.  Consider the following code:

Adafruit_NeoPixel strip = Adafruit_NeoPixel(16,1); /* creates an OBJECT */
Adafruit_NeoPixel* strip_pointer = &strip; /* creates a POINTER to the object */

Now, you need to decide if you want to have an array of OBJECTS or an array of POINTERS to objects.  Let's assume you want to have an array of OBJECTS:

Adafruit_NeoPixel strip[16];

We need to initialize the objects by calling Adafruit_NeoPixel():

for (int i=0; i < 16; i++) {
    strip[i] = Adafruit_NeoPixel(16, i);
}

Now, you can define your lightStrip() function to be passed a POINTER to the strip you want it to light:

void lightStrip(Adafruit_NeoPixel* strip, int value) {
    strip->setPixelColir(value, R, G, B); /* use -> not . because strip is a POINTER */
    strip->show();
}

You would call lightStrip() using the & operator to turn your strip OBJECT into a POINTER so that you can pass it to lightStrip():

for (int i=0; i < 16; i++) {
    light_strip(&(strip[i]), value);
}

Because I don't have access to the Adafruit library, I can't compile the above code, so there might be a typo in there, but hopefully it will give you the hint you need to get going on this problem.

Good Luck!

--Mark

<<   <   Page 3 / 3


EE Life
Frankenstein's Fix, Teardowns, Sideshows, Design Contests, Reader Content & More
Max Maxfield

Creating a Vetinari Clock Using Antique Analog Meters
Max Maxfield
58 comments
As you may recall, the Mighty Hamster (a.k.a. Mike Field) graced my humble office with a visit a couple of weeks ago. (See All Hail the Mighty Hamster.) While he was here, Hamster noticed ...

EDN Staff

11 Summer Vacation Spots for Engineers
EDN Staff
11 comments
This collection of places from technology history, museums, and modern marvels is a roadmap for an engineering adventure that will take you around the world. Here are just a few spots ...

Glen Chenier

Engineers Solve Analog/Digital Problem, Invent Creative Expletives
Glen Chenier
11 comments
- An analog engineer and a digital engineer join forces, use their respective skills, and pull a few bunnies out of a hat to troubleshoot a system with which they are completely ...

Larry Desjardin

Engineers Should Study Finance: 5 Reasons Why
Larry Desjardin
45 comments
I'm a big proponent of engineers learning financial basics. Why? Because engineers are making decisions all the time, in multiple ways. Having a good financial understanding guides these ...

Flash Poll
Top Comments of the Week
Like Us on Facebook
EE Times on Twitter
EE Times Twitter Feed

Datasheets.com Parts Search

185 million searchable parts
(please enter a part number or hit search to begin)