sound changes, press sounds, remove pitch

This commit is contained in:
Sen 2025-03-18 12:03:56 +01:00
parent c5219ce100
commit c602585e6a
76 changed files with 231 additions and 251 deletions

View file

@ -92,11 +92,11 @@ public class AudioInterface implements Runnable {
private short generate() {
long mix = 0;
long attn = 0; // (32767 * 100) / 95);
// long attn = 0; // (32767 * 100) / 95);
for(int z = 0; z < this.channels.length; z++) {
Channel ch = this.channels[z];
if(ch.run) {
attn += (long)ch.level * (long)this.volumes[ch.type]; // (this.attn[ch.type] * 95) / 100;
// attn += (long)ch.level * (long)this.volumes[ch.type]; // (this.attn[ch.type] * 95) / 100;
mix += (long)ch.buffer[ch.pos] * (long)ch.level * (((long)this.volumes[ch.type] * (long)this.volumes[0]) / 32767);
if(++ch.pos >= ch.buffer.length) {
ch.pos = 0;

View file

@ -2,32 +2,23 @@ package game.audio;
import game.init.SoundEvent;
public class PositionedSound extends Sound
{
// public PositionedSound(SoundEvent event, float pitch)
// {
// this(event, 0.25F, pitch, false, false, 0.0F, 0.0F, 0.0F);
// }
public class PositionedSound extends Sound {
public PositionedSound(SoundEvent event, Volume type) {
this(event, 1.0F, false, 0.0F, 0.0F, 0.0F);
this.type = type;
}
public PositionedSound(SoundEvent event)
{
this(event, 1.0F, false, 0.0F, 0.0F, 0.0F);
}
public PositionedSound(SoundEvent event, float volume, float xPosition, float yPosition, float zPosition) {
this(event, volume, true, xPosition, yPosition, zPosition);
}
public PositionedSound(SoundEvent event, float volume, float xPosition, float yPosition, float zPosition)
{
this(event, volume, true, xPosition, yPosition, zPosition);
}
private PositionedSound(SoundEvent event, float volume, boolean attenuationType, float xPosition, float yPosition, float zPosition)
{
super(event);
this.volume = volume;
// this.pitch = pitch;
this.xPosF = xPosition;
this.yPosF = yPosition;
this.zPosF = zPosition;
this.repeat = false;
this.attenuationType = attenuationType;
}
private PositionedSound(SoundEvent event, float volume, boolean attenuationType, float xPosition, float yPosition, float zPosition) {
super(event);
this.volume = volume;
this.xPosF = xPosition;
this.yPosF = yPosition;
this.zPosF = zPosition;
this.repeat = false;
this.attenuationType = attenuationType;
}
}

View file

@ -4,7 +4,7 @@ import game.init.SoundEvent;
public class SoundType
{
public static final SoundType SLIME = new SoundType(SoundEvent.SLIME_BIG, SoundEvent.SLIME_SMALL, 1.0F, 1.0F);
public static final SoundType SLIME = new SoundType(SoundEvent.SLIME_BIG, SoundEvent.SLIME_SMALL, 1.0F);
// {
// public Sounds getBreakSound()
// {
@ -19,7 +19,7 @@ public class SoundType
// return "mob.slime.small";
// }
// };
public static final SoundType ANVIL = new SoundType(SoundEvent.STONE, SoundEvent.ANVIL_LAND, SoundEvent.STONE, 0.3F, 1.0F);
public static final SoundType ANVIL = new SoundType(SoundEvent.STONE, SoundEvent.ANVIL_LAND, SoundEvent.STONE, 0.3F);
// {
// public Sounds getBreakSound()
// {
@ -34,7 +34,7 @@ public class SoundType
// return "dig.stone";
// }
// };
public static final SoundType LADDER = new SoundType(SoundEvent.WOOD, null, 1.0F, 1.0F);
public static final SoundType LADDER = new SoundType(SoundEvent.WOOD, null, 1.0F);
// {
// public Sounds getBreakSound()
// {
@ -45,10 +45,10 @@ public class SoundType
// return null;
// }
// };
public static final SoundType SNOW = new SoundType(SoundEvent.SNOW, 1.0F, 1.0F);
public static final SoundType SAND = new SoundType(SoundEvent.SAND, 1.0F, 1.0F);
public static final SoundType CLOTH = new SoundType(SoundEvent.CLOTH, 1.0F, 1.0F);
public static final SoundType GLASS = new SoundType(SoundEvent.GLASS, SoundEvent.STONE, SoundEvent.STONE, 1.0F, 1.0F);
public static final SoundType SNOW = new SoundType(SoundEvent.SNOW, 1.0F);
public static final SoundType SAND = new SoundType(SoundEvent.SAND, 1.0F);
public static final SoundType CLOTH = new SoundType(SoundEvent.CLOTH, 1.0F);
public static final SoundType GLASS = new SoundType(SoundEvent.GLASS, SoundEvent.STONE, SoundEvent.STONE, 1.0F);
// {
// public Sounds getBreakSound()
// {
@ -59,42 +59,40 @@ public class SoundType
// return "dig.stone";
// }
// };
public static final SoundType METAL = new SoundType(SoundEvent.STONE, 1.0F, 1.5F);
public static final SoundType PISTON = new SoundType(SoundEvent.STONE, 1.0F, 1.0F);
public static final SoundType GRASS = new SoundType(SoundEvent.GRASS /* , null */ , 1.0F, 1.0F);
public static final SoundType METAL = new SoundType(SoundEvent.STONE, 1.0F);
public static final SoundType PISTON = new SoundType(SoundEvent.STONE, 1.0F);
public static final SoundType GRASS = new SoundType(SoundEvent.GRASS /* , null */ , 1.0F);
// {
// public Sounds getStepSound()
// {
// return null;
// }
// };
public static final SoundType GRAVEL = new SoundType(SoundEvent.GRAVEL, 1.0F, 1.0F);
public static final SoundType WOOD = new SoundType(SoundEvent.WOOD, 1.0F, 1.0F);
public static final SoundType STONE = new SoundType(SoundEvent.STONE, 1.0F, 1.0F);
public static final SoundType GRAVEL = new SoundType(SoundEvent.GRAVEL, 1.0F);
public static final SoundType WOOD = new SoundType(SoundEvent.WOOD, 1.0F);
public static final SoundType STONE = new SoundType(SoundEvent.STONE, 1.0F);
private final SoundEvent breakSound;
private final SoundEvent placeSound;
private final SoundEvent stepSound;
private final float volume;
// private final float frequency;
private SoundType(SoundEvent breakSound, SoundEvent placeSound, SoundEvent stepSound, float volume, float frequency)
private SoundType(SoundEvent breakSound, SoundEvent placeSound, SoundEvent stepSound, float volume)
{
this.breakSound = breakSound;
this.placeSound = placeSound;
this.stepSound = stepSound;
this.volume = volume;
// this.frequency = frequency;
}
private SoundType(SoundEvent breakPlaceSound, SoundEvent stepSound, float volume, float frequency)
private SoundType(SoundEvent breakPlaceSound, SoundEvent stepSound, float volume)
{
this(breakPlaceSound, breakPlaceSound, stepSound, volume, frequency);
this(breakPlaceSound, breakPlaceSound, stepSound, volume);
}
private SoundType(SoundEvent sound, float volume, float frequency)
private SoundType(SoundEvent sound, float volume)
{
this(sound, sound, sound, volume, frequency);
this(sound, sound, sound, volume);
}
public SoundEvent getBreakSound()
@ -116,9 +114,4 @@ public class SoundType
{
return this.volume;
}
public float getFrequency()
{
return 1.0f; // this.frequency;
}
}
}