How to quickly trim audio files

I can’t take credit for this post. Yes, I am the one writing the post, but the software I downloaded is just so incredibly powerful and easy to use that I feel guilty telling anyone how to use it. Still, I am about to shave a few minutes off your setup time so here goes…

1. Download SoX for your platform. I am going to use Windows for this “How To”
Here’s a link: http://sox.sourceforge.net/
2. Open the folder you installed SoX to. I chose D:\tools\sox because I like to put all of my favorite command line tools in one place.
3. Right click the example batch file and choose edit.  This will open Notepad and you can replace all of the text with the following:
cd %~dp0
mkdir "sox output"
FOR %%A IN (%*) DO sox %%A "sox output/%%~nxA" fade 0 10 .5 rate -v 48000
pause

5. Save and close the batch file
4. Now just drag and drop any number of audio files onto the batch file and it will create a folder called “sox output” and save the first 10 seconds of each file to the new folder. The files will fade out quickly at the end so that you won’t hear any annoying clicks/pops that you would if you had just trimmed the file.

The full documentation for SoX comes with the installer as a PDF and includes lots of examples.

Have fun!

Review of Rhino 5 3D CAD Software

I am looking for a 3D CAD software that is simple to learn and affordable. Three things I am looking for in particular are: able to work in quad-view (top, front, side, 3d), able to enter dimensions using the keyboard, and able to snap to grid and objects during object creation and editing.

Rhino 5 https://www.rhino3d.com/ is a very full featured CAD software. I was able to quickly get started creating boxes and editing dimensions. I had to search the forums for help on getting objects to snap to each other but it was frustrating because I had to explicitly type the command to use each time I wanted to move or resize an object. It was also difficult because the only way to begin the snap operation was to press the left mouse button, which had to be pressed each time a different snap location was selected. This made editing a very slow process.

Retail pricing at the time this was written (Oct 27, 2017) was a little on the high side and also weird. Windows version was priced at $995 USD while the Mac version was priced at $695.00 USD. There was no mention of a different feature set so this was a very steep cost to run on Windows.

One last thing, when I was ready to remove the evaluation copy of this software I found that I had to uninstall 5 separate packages on Windows. This is not unheard of, but it could have been better.

Overall I would recommend trying Rhino 5. It is worth the time to evaluate and, like I said, is very fully featured. Unfortunately, it just did not meet my needs.

Moving Visual Studio Projects with Qt Integration

If you get an error like this:

The system cannot find the path specified.

or like this:

error MSB6006: "cmd.exe" exited with code 3.

Then you may need to just change your Qt Version under Qt Project Settings. The trick is that you must change from one valid Qt Version to another valid Qt Version. For example, if your current version is set to $(DefaultQtVersion) then you should change it to the explicit version entry. Make sure you actually apply the changed setting because otherwise nothing will happen. Once you have changed and applied the new setting, you can change it back and it may fix the problem.

Good luck!

How to compare strings using QString and Qt::MatchFlags for Qt5 and up

The Qt QString class is missing a really great opportunity to use the same Qt::MatchFlags that are used elsewhere in Qt. In the interest of making it super easy to add this functionality to my existing code and yours, just copy the following code into one of your commonly used header files. Make sure to actually include the required headers as shown in the comments. Then you can match your strings using Qt::MatchFlags.


/** determine if the pattern matches the string using Qt::MatchFlags
    \param str the string
    \param pattern the pattern to find
    \param flags any combination of the follow Qt flags
                - Qt::MatchFixedString
                - Qt::MatchContains
                - Qt::MatchStartsWith
                - Qt::MatchEndsWith
                - Qt::MatchRegExp (overrides all flags above)
                - Qt::MatchCaseSensitive
    \returns true if the pattern is found in the string

    requires:
    #include <QString>
    #include <QRegularExpression>
    #include <QRegularExpressionMatch>

    Thank you for visiting sirspot.com
    This code is not guaranteed to work.
    Use at your own risk.
*/
static bool QString_Matches(
    const QString& str,
    const QString& pattern,
    const Qt::MatchFlags& flags = (Qt::MatchCaseSensitive | Qt::MatchFixedString))
{
    if(flags.testFlag(Qt::MatchRegExp) == true)
    {
        QRegularExpression::PatternOptions options = QRegularExpression::NoPatternOption;
        if(flags.testFlag(Qt::MatchCaseSensitive) == false)
        {
            options = QRegularExpression::CaseInsensitiveOption;
        }
        QRegularExpression regex(pattern, options);
        return regex.match(str).hasMatch();
    }
    else
    {
        Qt::CaseSensitivity cs = Qt::CaseSensitive;
        if(flags.testFlag(Qt::MatchCaseSensitive) == false)
        {
            cs = Qt::CaseInsensitive;
        }
        if(flags.testFlag(Qt::MatchContains) == true)
        {
            return str.contains(pattern, cs);
        }
        else
        {
            if(flags.testFlag(Qt::MatchStartsWith) == true)
            {
                if(str.startsWith(pattern, cs) == true)
                {
                    return true;
                }
            }
            if(flags.testFlag(Qt::MatchEndsWith) == true)
            {
                if(str.endsWith(pattern, cs) == true)
                {
                    return true;
                }
            }
            if(flags.testFlag(Qt::MatchFixedString) == true)
            {
                return (str.compare(pattern, cs) == 0);
            }
        }
    }
    return false;
};

Happy String Matching!

VLC Media Player with Telnet (TCP) Control

This post is going to take some time to develop properly.  Here is what to do for those who understand how:

  1. open a command prompt with administrative privileges
  2. change directory to where your VLC exe is found
  3. execute the following command
    vlc -I ntservice --ntservice-install --ntservice-extraintf=telnet --telnet-host=131.185.1.1:4212 --telnet-password=12345
  4. Note: set the ip address to your IP or try 0.0.0.0 if you want to work with all interfaces.  Also, the password is required to make the telnet server work so either keep it as 12345 or select your own.
  5. open a telnet client and connect to TCP port 4212

What is missing?  You may need to enter some firewall rules.  You may need to set some additional configuration options such as which IP to bind to, the port to use, etc.  I’ll try to provide more detailed configuration steps sometime in the future.

Good luck!

 

Is Climate Change and Global Warming Fake News?

It’s really not fake news. The global average temperature is definitely on the rise. What could be considered fake news is how much humans have contributed to the rise in temperature. This is difficult, but not impossible to determine. I think the correlation of the data charted on these two sites is very telling.

https://climate.nasa.gov/climate_resources/24/

https://climate.nasa.gov/vital-signs/global-temperature/

So Yes, global warming is real and humans are responsible.  The next question is, “will it stop or can it be stopped?”  That’s a much harder question to answer!

How to fix Git for Windows login error via HTTPS

There are a lot of ways to login to a Git server, which means there are a lot of ways to also fail. I have a suggestion for you if, after trying everything else, you are still getting this error:

remote: invalid username or password. if you log in via a third party service you must ensure you have an account password set in your account profile.

Open a command prompt as administrator and enter the following commands:

git config –global –unset credential.helper

git config –system –unset credential.helper

Make sure you do both.

Now attempt to pull from the server again. This time you should be asked for your user name and password. Make sure you use the username that is in the URL of your request. For example, in this URL: https://gituser@sirspot.com the user name is gituser.

I hope this helped!

 

Hour of Code

Last year I went to 3 schools for Hour of Code.  This year I have already been to 3 schools and am schedule to visit 2 more schools before the end of the week.  The students range in age from 6 years old to 13 years old.  I tailor my presentation to each class based on how responsive the students are.  It is a lot of fun!  If you don’t know what Hour of Code is, you can visit the official site here: https://code.org/learn but basically it is just a week out of the year when we try to get students interested in computer programming.  Have a great week and give the Hour of Code a try!

Qt 5.7 Designer Hangs and Causes VS2013 to Hang

Apparently designer.exe hangs if the new webengine dlls are present.  The dlls can be removed, but then, what if you need them?  The easiest way around this problem for me was to use the mingw Qt 5.7 binaries for designer.exe (without including webengine) and leave the vs2013 binaries alone.  I’m sure Qt will be fixed soon, but this will get you rolling in the mean time.  Happy Coding!