<commit_before>require 'ffi'

require 'paula/system_constants/path_max'

module Paula
  module UADE
    extend FFI::Library
    ffi_lib 'uade'

    UADE_CHANNELS = 2
    UADE_BYTES_PER_SAMPLE = 2
    UADE_BYTES_PER_FRAME = UADE_CHANNELS * UADE_BYTES_PER_SAMPLE

    class UadeFile < FFI::Struct
      layout :name, :char,
             :data, :char,
             :size, :size_t
    end

    class UadeSubsongInfo < FFI::Struct
      layout :cur, :int,
             :min, :int,
             :def, :int,
             :max, :int
    end

    UADE_MAX_EXT_LEN = 16

    class UadeDetectionInfo < FFI::Struct
      layout :custom, :int,
             :content, :int,
             :ext, [:char, UADE_MAX_EXT_LEN],
             :ep, :pointer
    end

    class UadeSongInfo < FFI::Struct
      layout :subsongs, UadeSubsongInfo,
             :detectioninfo, UadeDetectionInfo,
             :modulebytes, :size_t,
             :modulemd5, [:char, 33],
             :duration, :double,
             :subsongbytes, :int64_t,
             :songbytes, :int64_t,
             :modulefname, [:char, Paula::SystemConstants::PATH_MAX],
             :playerfname, [:char, Paula::SystemConstants::PATH_MAX],
             :formatname, [:char, 256],
             :modulename, [:char, 256],
             :playername, [:char, 256]
    end

    enum :uade_song_info_type, [
      :module_info, 0,
      :hex_dump_info,
      :number_of_infos
    ]

    RMC_MAGIC = "rmc\x00\xfb\x13\xf6\x1f\xa2"
    RMC_MAGIC_LEN = 9

    enum :uade_seek_mode, [
      :not_seeking, 0,
      :song_relative,
      :subsong_relative,
      :position_relative
    ]

    enum :uade_option, [
      :uc_no_option, 0x1000,
      :base_dir,
      :content_detection,
      :disable_timeouts,
      :enable_timeouts,
      :eagleplayer_option,
      :filter_type,
      :force_led_off,
      :force_led_on,
      :force_led,
      :frequency,
      :gain,
      :headphones,
      :headphones2,
      :ignore_player_check,
      :no_filter,
      :no_headphones,
      :no_panning,
      :no_postprocessing,
      :no_ep_end,
      :ntsc,
      :one_subsong,
      :pal,
      :panning_value,
      :player_file,
      :resampler,
      :score_file,
      :silence_timeout_value,
      :speed_hack,
      :subsong_timeout_value,
      :timeout_value,
      :uadecore_file,
      :uae_config_file,
      :use_text_scope,
      :verbose
    ]

    enum :uade_effect_t, [
      :allow, 1,
      :gain,
      :headphones,
      :headphones2,
      :pan
    ]

    enum :uade_notification_type, [
      :message, 1,
      :song_end
    ]

    class UadeNotificationSongEnd < FFI::Struct
      layout :happy, :int,
             :stopnow, :int,
             :subsong, :int,
             :subsongbytes, :int64_t,
             :reason, :char
    end

    class UadeNotification < FFI::Struct
      layout :type, :uade_notification_type,
             :union, Class.new do
               layout :msg, :pointer,
                      :song_end, UadeNotificationSongEnd
             end
    end

    attach_function :uade_cleanup_state, [ :pointer ], :void

    # Configuration functions; these first few take uade_config structs
    # as their pointers, such as the one returned from uade_get_effective_config
    attach_function :uade_config_set_defaults, [ :pointer ], :void
    attach_function :uade_config_set_option, 
                      [ :pointer, :uade_option, :string ], :void
    attach_function :uade_config_toggle_boolean,
                      [ :pointer, :uade_option ], :int
    # These next few configuration functions are based on the song state,
    # and their pointer is to a uade_state instead
    attach_function :uade_effect_disable,
                      [ :pointer, :uade_effect_t ], :void
    attach_function :uade_effect_enable,
                      [ :pointer, :uade_effect_t ], :void
    attach_function :uade_effect_is_enabled,
                      [ :pointer, :uade_effect_t ], :int<commit_msg>Revert "UADE: don't assign constant to UadeNotification union"<commit_after>require 'ffi'

require 'paula/system_constants/path_max'

module Paula
  module UADE
    extend FFI::Library
    ffi_lib 'uade'

    UADE_CHANNELS = 2
    UADE_BYTES_PER_SAMPLE = 2
    UADE_BYTES_PER_FRAME = UADE_CHANNELS * UADE_BYTES_PER_SAMPLE

    class UadeFile < FFI::Struct
      layout :name, :char,
             :data, :char,
             :size, :size_t
    end

    class UadeSubsongInfo < FFI::Struct
      layout :cur, :int,
             :min, :int,
             :def, :int,
             :max, :int
    end

    UADE_MAX_EXT_LEN = 16

    class UadeDetectionInfo < FFI::Struct
      layout :custom, :int,
             :content, :int,
             :ext, [:char, UADE_MAX_EXT_LEN],
             :ep, :pointer
    end

    class UadeSongInfo < FFI::Struct
      layout :subsongs, UadeSubsongInfo,
             :detectioninfo, UadeDetectionInfo,
             :modulebytes, :size_t,
             :modulemd5, [:char, 33],
             :duration, :double,
             :subsongbytes, :int64_t,
             :songbytes, :int64_t,
             :modulefname, [:char, Paula::SystemConstants::PATH_MAX],
             :playerfname, [:char, Paula::SystemConstants::PATH_MAX],
             :formatname, [:char, 256],
             :modulename, [:char, 256],
             :playername, [:char, 256]
    end

    enum :uade_song_info_type, [
      :module_info, 0,
      :hex_dump_info,
      :number_of_infos
    ]

    RMC_MAGIC = "rmc\x00\xfb\x13\xf6\x1f\xa2"
    RMC_MAGIC_LEN = 9

    enum :uade_seek_mode, [
      :not_seeking, 0,
      :song_relative,
      :subsong_relative,
      :position_relative
    ]

    enum :uade_option, [
      :uc_no_option, 0x1000,
      :base_dir,
      :content_detection,
      :disable_timeouts,
      :enable_timeouts,
      :eagleplayer_option,
      :filter_type,
      :force_led_off,
      :force_led_on,
      :force_led,
      :frequency,
      :gain,
      :headphones,
      :headphones2,
      :ignore_player_check,
      :no_filter,
      :no_headphones,
      :no_panning,
      :no_postprocessing,
      :no_ep_end,
      :ntsc,
      :one_subsong,
      :pal,
      :panning_value,
      :player_file,
      :resampler,
      :score_file,
      :silence_timeout_value,
      :speed_hack,
      :subsong_timeout_value,
      :timeout_value,
      :uadecore_file,
      :uae_config_file,
      :use_text_scope,
      :verbose
    ]

    enum :uade_effect_t, [
      :allow, 1,
      :gain,
      :headphones,
      :headphones2,
      :pan
    ]

    enum :uade_notification_type, [
      :message, 1,
      :song_end
    ]

    class UadeNotificationSongEnd < FFI::Struct
      layout :happy, :int,
             :stopnow, :int,
             :subsong, :int,
             :subsongbytes, :int64_t,
             :reason, :char
    end

    class UadeNotificationUnion < FFI::Struct
      layout :msg, :char,
             :song_end, UadeNotificationSongEnd
    end

    class UadeNotification < FFI::Struct
      layout :type, :uade_notification_type,
             :union, UadeNotificationUnion
    end

    attach_function :uade_cleanup_state, [ :pointer ], :void

    # Configuration functions; these first few take uade_config structs
    # as their pointers, such as the one returned from uade_get_effective_config
    attach_function :uade_config_set_defaults, [ :pointer ], :void
    attach_function :uade_config_set_option, 
                      [ :pointer, :uade_option, :string ], :void
    attach_function :uade_config_toggle_boolean,
                      [ :pointer, :uade_option ], :int
    # These next few configuration functions are based on the song state,
    # and their pointer is to a uade_state instead
    attach_function :uade_effect_disable,
                      [ :pointer, :uade_effect_t ], :void
    attach_function :uade_effect_enable,
                      [ :pointer, :uade_effect_t ], :void
    attach_function :uade_effect_is_enabled,
                      [ :pointer, :uade_effect_t ], :int
{'fraction_non_alphanumeric': 0.09534506427056035, 'fraction_numerical': 0.010233370772494695, 'mean_word_length': 2.096599690880989, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6782676', 'n_tokens_mistral': 2812, 'n_tokens_neox': 2640, 'n_words': 536}