Skip to content

Instantly share code, notes, and snippets.

View ArcticEcho's full-sized avatar
👋
I'll get round to it, eventually.

Sam ArcticEcho

👋
I'll get round to it, eventually.
View GitHub Profile
<A class=\"signature user-227577\" href=\"/users/227577/sam\">\r\n<DIV style=\"DISPLAY: none\" class=tiny-signature
jQuery17106276336429219909=\"318\">\r\n<DIV class=\"avatar avatar-16\"><IMG title=Sam alt=Sam src=\"http://i.stack.imgur.com/Y22En.png?s=128&amp;g=1&amp;g&amp;s=16\"
width=16 height=16></DIV>\r\n<DIV class=\"username owner\">Sam</DIV></DIV>\r\n<DIV style=\"DISPLAY: block\" class=\"avatar avatar-32 clear-both\"
jQuery17106276336429219909=\"57\"><IMG title=Sam alt=Sam src=\"http://i.stack.imgur.com/Y22En.png?s=128&amp;g=1&amp;g&amp;s=32\" width=32 height=32>\r
\n<DIV></DIV></DIV>\r\n<DIV style=\"DISPLAY: block\" class=\"username owner\" jQuery17106276336429219909=\"56\">Sam</DIV>\r\n<DIV class=flair title=125
vector<WavFileRead> VSSEnvironment::GetChannels(string directory)
{
vector<WavFileRead> files;
if (DirectoryTools::FileExists(directory + ChannelsFunctions::GetFriendlyName(FrontLeft) + ".wav"))
{
files.push_back(WavFileRead(directory + ChannelsFunctions::GetFriendlyName(FrontLeft) + ".wav"));
}
if (DirectoryTools::FileExists(directory + ChannelsFunctions::GetFriendlyName(FrontRight) + ".wav"))
private static IEnumerable<WavFileRead> GetChannels(string directory)
{
var files = Enum.GetValues(typeof(Channels)).Cast<Channels>().Where(channel => channel != Channels.Custom && channel != Channels.Mono).Select(channel => Path.Combine(directory, channel.GetFriendlyName() + ".wav")).Where(File.Exists).Select(path => new WavFileRead(path)).ToList();
files.AddRange(Directory.EnumerateFiles(directory).Where(fileName => fileName.Contains(Channels.Mono.GetFriendlyName()) || fileName.Contains(Channels.Custom.GetFriendlyName())).Select(file => new WavFileRead(file)));
return files;
}
// Copyright (C) 2014 S.Kamber.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// Copyright (C) 2014 S.Kamber.
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// any later version.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// Read32BitSamples is called first.
private float[] Read32BitSamples(FileStream stream, int sampleStartIndex, int sampleEndIndex)
{
var bytesLength = 0;
var allocation = ReadBytes(stream, sampleStartIndex, sampleEndIndex, out bytesLength);
var bytes = (byte*)allocation.Allocation;
var samples = new float[bytesLength / 4];
@ArcticEcho
ArcticEcho / Benchmark
Last active August 29, 2015 14:02
Run in release config, without optimizations, without debugger & ignore results from first build. (And obviously don't have anything running in the background).
using System;
using System.Globalization;
using System.Diagnostics;
using System.Runtime.InteropServices;
using System.Threading;
// WARNING: For the code below to exacute properly (without getting a SOE) this program must be
// a full-trust app; see, project properties > security > enable "ClickOnce security setting"
// Mark's method.
public unsafe static void TestMethod2()
{
var ptr = Marshal.AllocHGlobal(50000000);
try
{
float* x = (float*)ptr;
// PFM's method.
public static unsafe void TestMethod1()
{
float* samples = stackalloc float[12500];
for (var i = 0; i < 100; i++)
{
for (var ii = 0; ii < 12500; ii++)
{
@ArcticEcho
ArcticEcho / Stack vs Heap Benchmark
Last active August 29, 2015 14:02
Updated M1 vs updated M2.
// M1 is 108% faster than M2.
public static unsafe void TestMethod1()
{
float* samples = stackalloc float[12500];
for (var i = 0; i < 4000; i++)
{
for (var ii = 0; ii < 12500; ii++)
{