Welcome to Mobile Tech Tracker. Our mission is to help technically-minded people to become better versions of themselves and to help ordinary people to use modern smart technologies to their own advantage. If you want to support us, please consider visiting the pages of our advertisers.
Building .NET Core sound application - part 3
This is the third and final part of the tutorial on building a platform-independent audio app on .NET Core. In the first part of this tutorial, we talked about setting up the general project structure and enabling audio playback capabilities on Windows. The second part of the tutorial spoke about adding the ability to play audio on Linux, while also enabling the library to pull the specific code, based on the operating system the software is running on. Today, we will talk about enabling audio capabilities on Mac.
As it has been mentioned before, .NET Core is a great platform-independent technology to build software with. However, due to its platform-independent nature, it lacks some of the most basic capabilities, which were too different in implementation on different operating systems. One of these is the ability to natively play audio.
Although there are reliable ways of enabling audio playback on .NET Core, those require a large number of dependencies.
The goal of this three-part tutorial is to build our own library that will enable us to use basic playback capabilities without any additional third-party dependencies whatsoever.
Building .NET Core sound application - part 2
This is the second part in our series of tutorials on building audio capabilities into .NET Core, which the platform doesn't have out of the box. In the first tutorial of this series, we have set up a basic project structure and have added a class that enabled us to play audio on Windows.
However, .NET Core wasn't created for Windows alone. Therefore, in this tutorial, we will add Linux playback capabilities to our application.
Although there is already a reliable way of playing audio on .NET Core in a cross-platform fashion, it relies on a number of dependencies and inter-operability with Node.js, which is achieved by NodeServices. The solution presented in this series of tutorials, however, doesn't rely on any third party dependencies at all. It doesn't even require any additional standard libraries from .NET Core or ASP.NET Core.
Building .NET Core audio application - part 1
As great as .NET Core is for writing software for multiple platforms, it lacks some basic capabilities. This applies to those functionalities that would work radically differently on different platforms under the hood, especially the ones that weren't the priority for the authors of .NET Core. One of these is the ability to play sound.
With it's predecessor, .NET Framework, you could play sound easily by using classes like SoundPlayer from the standard class library of the framework itself. Likewise, NuGet packages such as NAudio added many extra audio-processing capabilities.
Unfortunately, NAudio is not fully compatible with .NET Framework yet. Although there is a pre-release version that is available in .NET Standard and is compatible with .NET Core, the bulk of its functionality is still only available on Windows.
There is, of course, a reliable way to play sound on .NET Core on any platform, but it requires quite a few additional dependencies. You will have to load ASP.NET Core components, Node.js and use NodeServices to get this solution to work.
Therefore, if you would want to be able to play audio on .NET Core in the most efficient way without loading too many additional components, you can write your own library to do so. Fortunately, the process is not prohibitively difficult.
Building .NET Core desktop application
.NET Core is great for cross-platform app development. Unfortunately, the compatibility with multiple platforms was achieved primarily by excluding any components that are specific to Windows OS that it's predecessor, .NET Framework was built for. This is why, out of the box, .NET Core can only be used to build command line applications with no GUI and, with addition of ASP.NET packages, web application with nothing more than a standard functionality.
So, how can one build a .NET Core desktop application with GUI? Fortunately, the framework is extendable and the extendability goes above and beyond simply relying on NuGet packages.
Any common software functionality that isn't yet available in .NET Core is available via a more mature cross-platform software-building technology: Node.js. And the good news is that two frameworks can inter-operate easily.
In my previous article, I talked about how to play audio in .NET Core by using one of its standard libraries, NodeServices. In this article, I will talk about utilising Node.js from within a .NET Core app to build a desktop application with GUI. However, this time, the methodology is somewhat different.
How to play sound on .NET Core
How do you play sound in .NET Core apps? Is there a version of NAudio NuGet package for .NET Core or it's equivalent? Sadly, playing sound is nowhere near as straight forward on .NET Core as it is on .NET Framework. And there isn't a simple NuGet-based solution either. However, there is a way.
.NET Core certainly came a long way since Visual Studio 2017 was first released. It is now at the stage where the framework itself and the technologies that support it are mature enough to be used in production. However, although .NET Core can be deployed on any of the most widely-used operating systems and any CPU architecture that supports those, the framework is still pretty bare-bone compared to it's predecessor, .NET Framework.
Many things that .NET Framework can do are very Windows-specific with no platform-independent equivalent, therefore .NET Core does not natively support those. One of such functionalities is the ability to play sound from the code. With .NET Framework, you have native classes that support it, such as SoundPlayer from System.Media namespace and third-party NuGet packages, such as NAudio. Neither of these are available in .NET Core and, if you browse NuGet repository for sound libraries compatible with .NET Core, you'll soon realise that there is nothing that will enable you to play sound from the code in a straight-forward manner. At best, you can download some library that acts as a wrapper around some other assembly that needs to be compiled specifically for a particular operating system or a specific CPU architecture. As well as potentially not being available for a particular type of a machine, most of such libraries have a strictly enforced paid-for license.
Despite all this, there is a reliable and simple way of playing sound in .NET Core without having to splash out for an expensive software license. But first, let's see why NAudio, one of the most popular NuGet packages for audio processing, cannot live up to this task.
How to protect your website from spammers
If you own a website and have given its users the ability to post content, such as comments or articles, you are bound to clash with malicious spammers at some point. They will come when you least expect them.
So, imagine that you woke up one day after posting an amazing article that you've put a lot of effort into. And you see that people are obviously interested in what you had to say, as it attracted over hundred comments. At first, it makes you happy. However, your happiness doesn't last, as you discover that all of the comments are about Viagra.
The bad news is that this kind of thing is extremely common. The good news is, however, that it is extremely easy to protect your website against spammers. This is why you rarely, if ever, see these kind of comments on reputable websites.
Proven way to make programming fun
Software development can be a very interesting and financially rewarding career. With abundance of free online tutorials, learning how to program today is easier than ever. However, there is one major hurdle that everyone who has ever tried coding is familiar with: the process of writing software can, sometimes, be tedious and boring.
This is especially true for online tutorials. Getting to know a new programming language can be tremendously useful for one's career. However, most of the tutorials available online are extremely dry. Nothing saps motivation for learning new technology as much as seeing the code for yet another "Hello world!" app.
However, the good news is that learning how to code doesn't have to be boring. Perhaps, for learning the very basics of a given language, going through some of the boring tutorial steps is unavoidable. However, once you know the basics, there is a great and exciting way of practicing your programming skills. This is how you can do it.
Why you should care about functional programming
While releasing version 15.7 update to Visual Studio IDE, Microsoft has announced that its main functional language, F#, has been given a whole new set of cutting edge features and tooling, far better than anything available in any other of its popular languages. This has got the software development community excited and the official Visual Studio Magazine article where the announcement was made soon became one of the most visited pages on the magazine's website. This is yet another proof that there is an interest in functional programming.
However, there are some very good and pragmatic reasons why functional languages are worth learning. Let's dive into them.
What the heck is WebAssembly
Desktop apps are not dead. Here is why
Many people entering a software development career are often told to focus on web applications over desktop ones. Apparently, many believe that desktop apps are a dying technology. While it is true that certain business functionality that was, in the past, performed by desktop apps is now commonly performed by hosted browser-based web apps, there are still many use cases for desktop apps and none of them are going away any time soon.
It is extremely difficult to imagine your life without desktop apps. Anything that is actually installed on a full-sized computer is one of them. Yes, web apps can do many things, but the browser that is needed to access them is, itself, a desktop app. Any integrated development environment (IDE) that programmers use to build software is a desktop app, even when it's only ever used to write code for the web. There are countless of other examples that you can find if you'll think about it.
Of course, web apps do have distinct advantages over desktop apps in some areas. However, it is the other way round in some other areas. So, if you are undecided which way to take your programming career, let's have a look at the pros and cons of both technologies.
More from Tech Thoughts
Biggest misconceptions about full stack developers
It's not Capitalism that's the problem
The most important skill for 21st century
How to think like a hacker
One human trait that slows down humanity's progress
See everything that Facebook and Google know about you
How society conditions you for mediocrity
Why you shouldn't always trust scientists
Dark side of software development
I cannot wait for AI to take over
© Mobile Tech Tracker. All rights reserved. Unauthorised copying of any of this website's content is prohibited under international law.
For any queries, comments or suggestions, please write to email@example.com.