Showing posts with label boost. Show all posts
Showing posts with label boost. Show all posts

Monday, 15 February 2016

Boost Smart Pointers

Nowadays, we have the luxury of having Garbage Collectors in C#, Java, Python, etc. But we don't have that luxury in C++. Nobody can deny that managing pointers is a good to have skill, however, things had changed, the technology evolved as well and we might as well delegate the handling of pointers to someone else. Enter Boost Library. This is a superb library with lots of tools. The smart pointers on Boost library can greatly reduce the risk of memory leaks. Let's see the following samples run on Visual Studio 2015 with the memory leak detector enabled.

class ABasePerson
{
public:
    virtual void ShoutDescription() = 0;
};

class Fireman :public ABasePerson
{
public:
    void ShoutDescription()
    {
        cout << "I am a Fireman!";
    }
};


Above is a classic usage of polymorphism and we will use this as the basis of our example.
----------------------------------------------------------------------------------------------------------------
Example #1
{
ABasePerson *basePerson = new Fireman();
basePerson->ShoutDescription();
delete (basePerson);

}
This example will work well.
----------------------------------------------------------------------------------------------------------------
Example #2
{
ABasePerson *basePerson = new Fireman();
basePerson->ShoutDescription();

}
On this example, the developer forgot to delete the basePerson and now we have memory leak!
----------------------------------------------------------------------------------------------------------------
Example #3
{
boost::shared_ptr<ABasePerson> basePerson2(new Fireman());
basePerson2->ShoutDescription();
}

On this example, the basePerson2 will automatically be freed once it goes out of scope. Very convenient!
----------------------------------------------------------------------------------------------------------------
Example #4
boost::shared_ptr<ABasePerson> basePerson2(new Fireman());
basePerson2->ShoutDescription();

basePerson2 = NULL;
On this example, the basePerson2 will automatically be freed once it was set to NULL.
----------------------------------------------------------------------------------------------------------------

On this post, we saw the convenience of using Boost Smart Pointers.

Update: I am not using the Boost Smart Pointers as of the moment. Instead, I am using C++11's smart pointers since they are almost included in every compiler. (I use GCC in Linux and MSVC on Windows and they both include C++11's Smart Pointers)

Saturday, 14 November 2015

Transparent Boost Pedal

Few years back, I struggled getting a good tone. Whenever I plugged in my guitar's multi-effects (Zoom G2.1NU with Stack Amp/Cab simulation always turned on) into the front of a tube amplifer, I get bad tone most of the time (sometimes very sharp, sometimes I can't cut to the mix). Truthfully, whenever we rent a studio, we have very limited time and we would like to maximize the time by playing with our band rather than setting up/tweaking. To avoid the tube's preamp coloration, I tried to plug my multi-effects into an FX return of a tube amplifier. It sounded very good but it produced a very low volume. With this, I decided to create my own booster with the following criteria:
  • Powered by 9VDC
  • Fixed Gain (20dB)
  • Should be as transparent as possible and no tone shaping (therefore, no tone control)
  • Simple, only one knob
  • Use a good audio op-amp (OPA2134)
With the following criteria, I did the following circuit in LTSpice.


And here is the actual circuit.

 

As you can see from the picture, I reused the silent rehearsal PCB I did on my previous entry on this blog. I can design another PCB, but since I would like to cut some cost, this PCB will do for a prototype. Plus, I also did the 3D printed mini-stand for this (look for the green line at the bottom) :)

This is not really a pedal because this is an always on circuit, and it is ok because this booster was designed to be very transparent and straight to FX return of an amplifier's effects loop and will always be turned on all the time. This is very ideal for someone like me who heavily uses cab/amp simulations.