Skip to content

Instantly share code, notes, and snippets.

View melanchall's full-sized avatar

Maxim Dobroselsky melanchall

View GitHub Profile
@melanchall
melanchall / LyricsWithSeconds.cs
Created January 13, 2024 12:58
Get lyrics with timestamps in seconds
var midiFile = MidiFile.Read("FileWithLyrics.mid");
var tempoMap = midiFile.GetTempoMap();
var lyricsWithTimestamps = midiFile
.GetTimedEvents()
.Where(e => e.Event.EventType == MidiEventType.Lyric)
.Select(e => new
{
Text = ((LyricEvent)e.Event).Text,
TotalSecondsFromStart = e.TimeAs<MetricTimeSpan>(tempoMap).TotalSeconds
})
@melanchall
melanchall / medium_nuget_native_20.cs
Created October 5, 2022 16:50
[Medium] NuGet Native 20
namespace DualLibClassLibrary
{
public static class Class
{
public static int Bar()
{
return ApiProvider.Api.Method() * 1000;
}
}
}
@melanchall
melanchall / medium_nuget_native_19.cs
Created October 5, 2022 16:49
[Medium] NuGet Native 19
using System;
namespace DualLibClassLibrary
{
internal static class ApiProvider
{
private static readonly bool Is64Bit = IntPtr.Size == 8;
private static Api _api;
public static Api Api
@melanchall
melanchall / medium_nuget_native_18.cs
Created October 5, 2022 16:49
[Medium] NuGet Native 18
using System.Runtime.InteropServices;
namespace DualLibClassLibrary
{
internal sealed class Api64 : Api
{
[DllImport("test64")]
public static extern int Foo();
public override int Method()
@melanchall
melanchall / medium_nuget_native_17.cs
Created October 5, 2022 16:48
[Medium] NuGet Native 17
using System.Runtime.InteropServices;
namespace DualLibClassLibrary
{
internal sealed class Api32 : Api
{
[DllImport("test32")]
public static extern int Foo();
public override int Method()
@melanchall
melanchall / medium_nuget_native_16.cs
Created October 5, 2022 16:48
[Medium] NuGet Native 16
namespace DualLibClassLibrary
{
internal abstract class Api
{
public abstract int Method();
}
}
@melanchall
melanchall / medium_nuget_native_15.ps1
Created October 5, 2022 16:47
[Medium] NuGet Native 15
Write-Host "Downloading winlibs..."
Invoke-WebRequest -Uri "https://github.com/brechtsanders/winlibs_mingw/releases/download/11.1.0-12.0.0-9.0.0-r1/winlibs-i686-posix-dwarf-gcc-11.1.0-mingw-w64-9.0.0-r1.zip" -OutFile "winlibs.zip"
Write-Host "Downloaded."
Write-Host "Extracting winlibs..."
Expand-Archive -LiteralPath 'winlibs.zip' -DestinationPath "winlibs"
Write-Host "Extracted."
Write-Host "Building DLL..."
$gccPath = Get-ChildItem -Path "winlibs" -File -Filter "i686-w64-mingw32-gcc.exe" -Recurse
@melanchall
melanchall / medium_nuget_native_14.log
Created October 5, 2022 16:46
[Medium] NuGet Native 14
C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: skipping incompatible C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib\libuser32.a when searching for -luser32
...
C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/libmsvcrt.a when searching for -lmsvcrt C:/ProgramData/Chocolatey/lib/mingw/tools/install/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/ld.exe: cannot find -lmsvcrt collect2.exe: error: ld returned 1 exit status
@melanchall
melanchall / medium_nuget_native_13.xml
Created October 5, 2022 16:41
[Medium] NuGet Native 13
<ItemGroup>
<None Include="test.dll">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PackagePath>build\</PackagePath>
<Pack>true</Pack>
</None>
<None Include="test.dylib">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
<PackagePath>build\</PackagePath>
<Pack>true</Pack>
@melanchall
melanchall / medium_nuget_native_12.xml
Created October 5, 2022 16:39
[Medium] NuGet Native 12
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="$(MSBuildThisFileDirectory)test.dll">
<Link>test.dll</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Include="$(MSBuildThisFileDirectory)test.dylib">
<Link>test.dylib</Link>
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>