Archive
Cutting Your Teeth on FMOD Part 5: Real-time streaming of programmatically-generated audio
This article was inspired by David Gouveia – thanks for the suggestion!
In this article, we shall look at how to generate sounds programmatically using a function which generates each sample one by one, and how to feed these samples into the audio buffer of a playing stream in real-time.
Note: The SimpleFMOD library contains all of the source code and pre-compiled executables for the examples in this series.
SimpleFMOD 1.01 now available
SimpleFMOD 1.01 is now available. Read more…
C++ Explained: Object initialization and assignment, lvalues and rvalues, copy and move semantics and the copy-and-swap idiom
In this article I’m going to try and clear up some fundamental C++ topics which are a common source of confusion for beginning and intermediate C++ programmers, and programmers coming to C++ from other languages such as C# or Java:
- the difference between initialization and assignment, which uses of the “=” operator trigger initialization and which trigger assignment, and how to implement them correctly in your own classes
- the meaning of lvalues, rvalues and rvalue references and how to spot which is which in your programs
- an introduction to C++11 move semantics
- when copy and move constructors and assignment operators are called in your classes, and how to implement them
- reducing the amount of duplicated and error-prone code in constructor and assignment operator implementations by using the so-called copy-and-swap idiom
I won’t be dealing with other initialization or assignment topics here (eg. of in-built or POD (plain-old-data) types, and type conversions), only the initialization and assignment of class objects. It is assumed you understand the following concepts (but not necessarily how to implement them):
- constructors and copy constructors
- assignment operator overloading (&operator=)
In the examples below, I will show how to manipulate a class containing a single resource in the form of a std::unique_ptr, which is a single-ownership smart pointer which comes as part of the C++11 standard library, however you can replace this with any resource type which shouldn’t be copied in a bit-wise (shallow copy) manner, eg. any raw pointer or resource handle whose targets should only be freed once no matter how many pointers are held to the resource across object instances, or whose target should be copied if the object instance is copied.
Simple2D 1.07 now available
The latest version of my Direct2D-based graphics library Simple2D is now available.
This is mostly a bug fix release with a couple of minor enhancements.
PlayStation 4 Reveal Post-mortem: The end of gaming as we know it?
Let’s not pull any punches: while the PlayStation 3 has been successful as a games console, its development and lifecycle management has more or less been a catalogue of errors by Sony Computer Entertainment (SCE). We have seen a hardware architecture that nobody knew how to use, backed up by poor quality development tools; hardware reliability for the first years was extremely poor with a 33% return rate due to the ‘yellow light of death’ syndrome; management of the PlayStation Network (PSN) has been extremely shoddy, with one security breach leading to over a month of downtime, regular large maintenance windows which often stretch to 12 hours or more, and pricing/availability errors with each new store update every week. Regionalized versions of the PSN store (something the Xbox 360 doesn’t have) have created almost a kind of class divide between Europeans and Americans, with each complaining that the other gets better service and offers. Each region uses its own certification and QA processes, leading to non-uniform release dates for digital titles that are sometimes staggered by months. In the meanwhile, the platform has become infested with day 1 DLC, online passes, in-game micro-transactions and other ploys to milk the gamers of their hard-earned cash in as many ways as possible. Consumer confidence in PlayStation among hardcore gamers is at an all-time low. In the meanwhile, Sony as a global brand have failed to turn a profit for the last 4 years running due to poor TV sales, lack of interest in 3D (mercifully), the earthquake in Japan and unfavourable exchange rates against the Yen.
It was with a healthy dose of trepidation, therefore, that I tuned into the PlayStation 4 Reveal which took place at midnight CET on the morning of 21st February 2013. Read more…
2D Platform Games Part 11: Collision Detection Edge Cases for The Uninitiated
IMPORTANT! To run the pre-compiled EXEs in this article, you must have Windows 7 Service Pack 1 with Platform Update for Windows 7 installed, or Windows 8.
This article builds upon the demo project created in 2D Platform Games Part 10: Improved Level Management and Storage. Start with 2D Platform Games Part 1: Collision Detection for Dummies if you just stumbled upon this page at random!
Download source code and compiled EXE for the code in this article as well as the complete source code and compiled EXE for the level editor.
With the ability to create levels easily comes the ability for your colleagues to produce gameplay scenarios you hadn’t thought of, and by consequence reveal a host of tricky bugs in your code. In this article, we shall look at a variety of so-called edge cases – an engineering term meaning things which don’t happen often, or only under a very specific set of circumstances – and how to fix them so they work correctly. The included source code includes a number of levels which demonstrate each problem so you can load them into the code from Part 10 to see how the behaviour compares with the updated code from this article.
Visual Studio 2012 – Day 1 Annoyances (with an emphasis on C++)
Update 21st February 2013: added information about Update 2, the C++11 Compiler November 2012 CTP (in two sections) and Find & Replace
Update 16th April 2013: the final version of Update 2 is now released; Update 1 is no longer needed (article updated)
So this is it, huh folks? 16 years of development, and the latest incarnation of the de-facto standard Windows development tool has an interface that might as well be from 1997. The compiler is not much better either it seems, as this C++11 feature support comparison shows: Visual Studio 2012 fails to include such basic support as initializer lists*, uniform initialization*, default and deleted constructors, inherited constructors and non-static data member initializers, while just about managing to shoehorn in raw string literals in the Update 1 package. Yet strangely, Microsoft managed to find time to implement SCARY iterators, checked iterators and futures and promises. SCARY iterators were only an optional part of the ratified C++11 standard.
But, the purpose of this article is to get your life in Visual Studio 2012 running smoothly, so let’s start with the basics.
* these features and others were added in the C++11 Compiler November 2012 CTP, see below Read more…
SimpleFMOD 1.00 now available
Introducing the lazy way to use the acclaimed FMOD Sound System to get music and sound effects into your C++ games and applications – SimpleFMOD!
Initial feature list:
- Initialize FMOD, load and play a song in 4 lines of code
- Load audio from files or embedded application resources
- Basic audio playback controls: Start, stop, toggle/get/set pause, get/set volume, fade in and out
- Separate master volumes for music and sound effects
- Automatic memory management of all FMOD and audio resources. No pointers!
- Derive from a provided class to create custom audio resource types with their own behaviour
- Fetch raw pointers to the FMOD API and FMOD channels to allow audio manipulation not supported by SimpleFMOD