    local Channeled = {
        [212084] = {'Fel Devastation',9,0,},
		[211053] = {'Fel Barrage',4,0,},
		[258926] = {'Fel Barrage',4,0,}, -- bfa spell
        [198013] = {'Eye Beam',5,0,},
    }
     
     local Instants = {
        [185245] = {'Torment',4,0,}, 
        [217832] = {'Imprison',4,0,},
        [228477] = {'Soul Cleave',3,0,},
        [203782] = {'Shear',8,0,},
        [204513] = {'Sigil of Flame',5,0,},
        [185123] = {'Throw Glaive',7,0,},
        [183752] = {'Disrupt',3,0,},
        [321068] = {'Metamorphosis',5,0,},
        [209795] = {'Fracture',4,0,},
        [189110] = {'Infernal Strike',5,0,},
        [203720] = {'Demon Spikes',6,0,},
        [198793] = {'Vengeful Retreat',3,0,},
        [188501] = {'Spectral Sight',5,0,},
        [218256] = {'Empower Wards',4,0,},
        [204021] = {'Fiery Brand',8,0,},
        [178740] = {'Immolation Aura',3,0,},
		[258920] = {'Immolation Aura',3,0,}, -- Talent for Havoc
		[207407] = {'Soul Carver',4,0,},
		[188499] = {'Blade Dance',4,0,}, 
        [217832] = {'Imprison',4,0,},
        [211881] = {'Fel Eruption',3,0,},
        [162794] = {'Chaos Strike',8,0,},
        [232893] = {'Felblade',5,0,},
        --[247938] = {'Chaos Blades',1,0,},
        [185123] = {'Throw Glaive',7,0,},
        [183752] = {'Consume Magic',3,0,},
        [191427] = {'Metamorphosis',5,0,},
        [162243] = {'Demons Bite',4,0,},
        [206491] = {'Nemesis',3,0,},
        [179057] = {'Chaos Nova',6,0,},
        [198793] = {'Vengeful Retreat',3,0,},
        [188501] = {'Spectral Sight',5,0,},
        [198589] = {'Blur',4,0,},
        [201427] = {'Annihilation',8,0,},
        [210152] = {'Death Sweep',4,0,},
        [323639] = {'The Hunt',1,0,},
        [342817] = {'Glaive Tempest',1,0,},

    }
	 
     
   local SoundPath = [[Interface\AddOns\JojoDH_DioBrando\sounds\]];
     
     local f = CreateFrame('frame');
	local rand_spell = 0;
    f:SetScript('OnEvent', function(self, event, unit, _, spellID)
		if jojodh_sound == 1 then
			if event == 'UNIT_SPELLCAST_CHANNEL_START' and Channeled[spellID] then
				if Channeled[spellID][2] ~= 1 then
					repeat
						rand_spell = math.random(1,Channeled[spellID][2]);
					until rand_spell ~= Channeled[spellID][3];
					Channeled[spellID][3] = rand_spell;
				else
					rand_spell = 1;
				end
				PlaySoundFile(SoundPath .. Channeled[spellID][1] .. '_' .. rand_spell .. '.ogg', 'SFX');
			elseif event == 'UNIT_SPELLCAST_SUCCEEDED' and Instants[spellID] then
				if Instants[spellID][2] ~= 1 then
					repeat
						rand_spell = math.random(1,Instants[spellID][2]);
					until rand_spell ~= Instants[spellID][3];
					Instants[spellID][3] = rand_spell;
					else
						rand_spell = 1;
					end
				PlaySoundFile(SoundPath .. Instants[spellID][1] .. '_' .. rand_spell .. '.ogg', 'SFX');
				
			elseif event == 'PLAYER_DEAD' then
				PlaySoundFile(SoundPath .. 'DeadSound_' .. math.random(1,3) .. '.ogg', 'SFX');
			end
		end
		
	end)

	

     
     f:RegisterUnitEvent('UNIT_SPELLCAST_CHANNEL_START', 'player');
    f:RegisterUnitEvent('UNIT_SPELLCAST_SUCCEEDED', 'player');
    f:RegisterEvent('PLAYER_DEAD');
	
	
	
	local frame = CreateFrame("FRAME");
	frame:RegisterEvent("ADDON_LOADED"); 
	frame:RegisterEvent("PLAYER_LOGOUT");

	function frame:OnEvent(event, arg1)
		if event == "ADDON_LOADED" and arg1 == "JojoDH_DioBrando" then
			if jojodh_sound == nil then
				print("Thanks for using JojoDH_Dio Brando addon ! Initialisation...");
				print("The addon is ready, enjoy ! (v 2.0.2)");
				jojodh_sound = 1;
			elseif jojodh_sound == 1 then 
				print("JojoDH_Dio Brando SFX is active.");
			elseif jojodh_sound == 0 then
				print("JojoDH_Dio Brando SFX is not active.");
			end
		end
	end
	frame:SetScript("OnEvent", frame.OnEvent);
	SLASH_JOJOSFX1 = "/jojosfx";

	function SlashCmdList.JOJOSFX(option)
		if option == "on" then
			print("JojoDH_Dio Brando SFX -> activate");
			jojodh_sound = 1;
		elseif option == "off" then
			print("JojoDH_Dio Brando SFX -> desactivate");
			jojodh_sound = 0;
		else
			print("JojoDH_Dio Brando SFX command : /jojosfx <on-off>");
		end
	end

	
	
	
	
	
	
	
	
	
	