Skip to content

Commit

Permalink
Merge pull request #2 from mmitang/master
Browse files Browse the repository at this point in the history
* add labe.bundle for mac platform
  • Loading branch information
3wz authored Jan 26, 2018
2 parents 75591fc + b80c4b9 commit 77c8cd9
Show file tree
Hide file tree
Showing 16 changed files with 1,686 additions and 48 deletions.
102 changes: 54 additions & 48 deletions Assets/Lame/LibMp3Lame.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,30 +321,30 @@ void setter<T>(setFunc<T> f, T value, string name = null)

/// <summary>Number of samples (optional)</summary>
public UInt64 NumSamples
{
get { return NativeMethods.lame_get_num_samples(context); }
set { setter(NativeMethods.lame_set_num_samples, value); }
{
get { return NativeMethods.lame_get_num_samples(context); }
set { setter(NativeMethods.lame_set_num_samples, value); }
}

/// <summary>Input sample rate</summary>
public int InputSampleRate
{
get { return NativeMethods.lame_get_in_samplerate(context); }
set { setter(NativeMethods.lame_set_in_samplerate, value); }
{
get { return NativeMethods.lame_get_in_samplerate(context); }
set { setter(NativeMethods.lame_set_in_samplerate, value); }
}

/// <summary>Number of channels</summary>
public int NumChannels
{
get { return NativeMethods.lame_get_num_channels(context); }
set { setter(NativeMethods.lame_set_num_channels, value); }
{
get { return NativeMethods.lame_get_num_channels(context); }
set { setter(NativeMethods.lame_set_num_channels, value); }
}

/// <summary>Global amplification factor</summary>
public float Scale
{
get { return NativeMethods.lame_get_scale(context); }
set { setter(NativeMethods.lame_set_scale, value); }
{
get { return NativeMethods.lame_get_scale(context); }
set { setter(NativeMethods.lame_set_scale, value); }
}

/// <summary>Left channel amplification</summary>
Expand Down Expand Up @@ -453,14 +453,14 @@ public int NoGapCurrentIndex
public int BitRate
{
get { return NativeMethods.lame_get_brate(context); }
set { setter(NativeMethods.lame_set_brate, value); }
set { setter(NativeMethods.lame_set_brate, value); }
}

/// <summary>Output compression ratio</summary>
public float CompressionRatio
{
get { return NativeMethods.lame_get_compression_ratio(context); }
set { setter(NativeMethods.lame_set_compression_ratio, value); }
set { setter(NativeMethods.lame_set_compression_ratio, value); }
}

/// <summary>Set compression preset</summary>
Expand All @@ -484,36 +484,36 @@ public bool SetOptimization(ASMOptimizations opt, bool enabled)
/// <summary>Set output Copyright flag</summary>
public bool Copyright
{
get { return NativeMethods.lame_get_copyright(context); }
set { setter(NativeMethods.lame_set_copyright, value); }
get { return NativeMethods.lame_get_copyright(context); }
set { setter(NativeMethods.lame_set_copyright, value); }
}

/// <summary>Set output Original flag</summary>
public bool Original
{
get { return NativeMethods.lame_get_original(context); }
set { setter(NativeMethods.lame_set_original, value); }
{
get { return NativeMethods.lame_get_original(context); }
set { setter(NativeMethods.lame_set_original, value); }
}

/// <summary>Set error protection. Uses 2 bytes from each frame for CRC checksum</summary>
public bool ErrorProtection
{
get { return NativeMethods.lame_get_error_protection(context); }
set { setter(NativeMethods.lame_set_error_protection, value); }
{
get { return NativeMethods.lame_get_error_protection(context); }
set { setter(NativeMethods.lame_set_error_protection, value); }
}

/// <summary>MP3 'private extension' bit. Meaningless.</summary>
public bool Extension
{
get { return NativeMethods.lame_get_extension(context); }
set { setter(NativeMethods.lame_set_extension, value); }
{
get { return NativeMethods.lame_get_extension(context); }
set { setter(NativeMethods.lame_set_extension, value); }
}

/// <summary>Enforce strict ISO compliance.</summary>
public bool StrictISO
{
get { return NativeMethods.lame_get_strict_ISO(context); }
set { setter(NativeMethods.lame_set_strict_ISO, value); }
{
get { return NativeMethods.lame_get_strict_ISO(context); }
set { setter(NativeMethods.lame_set_strict_ISO, value); }
}

#endregion
Expand Down Expand Up @@ -567,25 +567,25 @@ public bool StrictISO
public int VBRMaxBitrateKbps { get { return NativeMethods.lame_get_VBR_max_bitrate_kbps(context); } set { setter(NativeMethods.lame_set_VBR_max_bitrate_kbps, value); } }

/// <summary>Strictly enforce minimum bitrate. Normall it will be violated for analog silence.</summary>
public bool VBRHardMin { get { return NativeMethods.lame_get_VBR_hard_min(context); } set { setter(NativeMethods.lame_set_VBR_hard_min, value); } }

public bool VBRHardMin { get { return NativeMethods.lame_get_VBR_hard_min(context); } set { setter(NativeMethods.lame_set_VBR_hard_min, value); } }

#endregion


#region Filtering control


#pragma warning disable 1591
public int LowPassFreq { get { return NativeMethods.lame_get_lowpassfreq(context); } set { setter(NativeMethods.lame_set_lowpassfreq, value); } }

public int LowPassWidth { get { return NativeMethods.lame_get_lowpasswidth(context); } set { setter(NativeMethods.lame_set_lowpasswidth, value); } }

public int HighPassFreq { get { return NativeMethods.lame_get_highpassfreq(context); } set { setter(NativeMethods.lame_set_highpassfreq, value); } }

public int HighPassWidth { get { return NativeMethods.lame_get_highpasswidth(context); } set { setter(NativeMethods.lame_set_highpasswidth, value); } }
public int HighPassWidth { get { return NativeMethods.lame_get_highpasswidth(context); } set { setter(NativeMethods.lame_set_highpasswidth, value); } }
#pragma warning restore 1591
#endregion


#region Internal state variables, read only


#pragma warning disable 1591
public MPEGVersion Version { get { return NativeMethods.lame_get_version(context); } }

Expand All @@ -609,14 +609,14 @@ public bool StrictISO

public int NoClipGainChange { get { return NativeMethods.lame_get_noclipGainChange(context); } }

public float NoClipScale { get { return NativeMethods.lame_get_noclipScale(context); } }
public float NoClipScale { get { return NativeMethods.lame_get_noclipScale(context); } }
#pragma warning restore 1591
#endregion


#endregion


#region Methods


/// <summary>Initialize encoder with parameters</summary>
/// <returns>Success/fail</returns>
public bool InitParams()
Expand Down Expand Up @@ -676,27 +676,33 @@ public int Flush(byte[] output, int outputSize)
#endregion

internal static class NativeMethods
{
{
#if UNITY_EDITOR
const string libname = @"libmp3lame.dll";

#if UNITY_EDITOR_OSX
const string libname = @"__Internal";
#else
const string libname = @"libmp3lame.dll";
#endif

#elif UNITY_IOS
const string libname = @"__Internal";
#elif UNITY_ANDROID
const string libname = @"map3lame";
#endif

// typedef void (*lame_report_function)(const char *format, va_list ap);


// typedef void (*lame_report_function)(const char *format, va_list ap);

#region Startup/Shutdown


/*
* REQUIRED:
* initialize the encoder. sets default for all encoder parameters,
* returns NULL if some malloc()'s failed
* otherwise returns pointer to structure needed for all future
* API calls.
*/
// lame_global_flags * CDECL lame_init(void);
*/
// lame_global_flags * CDECL lame_init(void);
[DllImport(libname, CallingConvention = CallingConvention.Cdecl)]
internal static extern IntPtr lame_init();

Expand Down Expand Up @@ -1761,7 +1767,7 @@ int mp3buf_size

#region Reporting callbacks

[UnmanagedFunctionPointer(CallingConvention.Cdecl, SetLastError = true, CharSet = CharSet.Ansi)]
[UnmanagedFunctionPointer(CallingConvention.Cdecl, SetLastError = true, CharSet = CharSet.Ansi)]
internal delegate void delReportFunction(string fmt, IntPtr args);

[DllImport(libname, CallingConvention = CallingConvention.Cdecl)]
Expand Down
9 changes: 9 additions & 0 deletions Assets/Plugins/lame.bundle/Contents.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions Assets/Plugins/lame.bundle/Contents/Headers.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 77c8cd9

Please sign in to comment.