Skip to content

Commit 080caa0

Browse files
authored
Merge pull request #430 from Mindgamesnl/feature/media-inhibbitor-cross-fading
Feature/media inhibitor cross fading
2 parents 50f195e + fd115a4 commit 080caa0

File tree

12 files changed

+47
-25
lines changed

12 files changed

+47
-25
lines changed

client/public/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"buildMajor":1,"buildMinor":125,"buildRevision":240,"buildTag":"dev","buildDate":"Sun May 05 2024","build":"1.125.240 dev"}
1+
{"buildMajor":1,"buildMinor":125,"buildRevision":241,"buildTag":"dev","buildDate":"Fri May 31 2024","build":"1.125.241 dev"}

client/src/client/services/media/MediaManager.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ export const MediaManager = new class IMediaManager {
8686
const channel = chls[i];
8787
if (all) {
8888
channel.fadeChannel(0, time, () => {
89+
console.log('callback reached');
8990
this.mixer.removeChannel(channel);
9091
});
9192
matchedAndStopped = channel;

client/src/client/services/media/objects/Channel.jsx

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,31 @@
11
import { getGlobalState } from '../../../../state/store';
2-
import { debugLog } from '../../debugging/DebugService';
32

43
export class Channel {
5-
constructor(channelName) {
4+
constructor(channelName, originalVolume = 100) {
65
this.channelName = channelName;
7-
this.channelVolume = 100;
6+
this.channelVolume = originalVolume;
7+
this.originalVolume = originalVolume;
88
this.sounds = [];
99
this.mixer = null;
1010
this.targetAfterFade = 0;
1111
this.isFading = false;
1212
this.fadeTimer = [];
1313
this.tags = new Map();
1414
this.trackable = false;
15+
this.prefferedFadeTime = 2;
16+
}
17+
18+
getOriginalVolume() {
19+
return this.originalVolume;
20+
}
21+
22+
setPrefferedFadeTime(fadeTime) {
23+
console.log('Setting preffered fade time to', fadeTime);
24+
this.prefferedFadeTime = fadeTime;
25+
}
26+
27+
getPrefferedFadeTime() {
28+
return this.prefferedFadeTime || 2;
1529
}
1630

1731
setTag(name) {
@@ -65,7 +79,6 @@ export class Channel {
6579

6680
// is the fade time set to 0? then just set the volume, do callback and return
6781
if (time === 0) {
68-
debugLog('Fading channel', this.channelName, 'to', targetVolume, 'instantly');
6982
this.setChannelVolume(targetVolume);
7083
extraCallback();
7184
return;

client/src/client/services/media/objects/Mixer.jsx

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,22 @@ export class Mixer {
5757
}
5858
});
5959

60-
if (score >= 1) {
61-
channel.setMediaMuted(true);
62-
} else {
63-
channel.setMediaMuted(false);
60+
const fade = channel.getPrefferedFadeTime() > 5;
61+
62+
if (score >= 1 && !channel.mutedByScore) {
63+
channel.mutedByScore = true;
64+
if (fade) {
65+
channel.fadeChannel(0, channel.getPrefferedFadeTime());
66+
} else {
67+
channel.setChannelVolume(0);
68+
}
69+
} else if (score === 0 && channel.mutedByScore) {
70+
channel.mutedByScore = false;
71+
if (fade) {
72+
channel.fadeChannel(channel.getOriginalVolume(), channel.getPrefferedFadeTime());
73+
} else {
74+
channel.setChannelVolume(channel.getOriginalVolume());
75+
}
6476
}
6577
});
6678
}

client/src/client/services/socket/handlers/HandleCreateMedia.jsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ export async function handleCreateMedia(data) {
3030
MediaManager.destroySounds(id, false, true);
3131

3232
// register with metadata
33-
const createdChannel = new Channel(id);
33+
const createdChannel = new Channel(id, volume);
3434
createdChannel.trackable = true;
35+
createdChannel.setPrefferedFadeTime(fadeTime);
3536
const createdMedia = new Sound();
3637

3738
createdChannel.addSound(createdMedia);

client/src/metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"buildMajor":1,"buildMinor":125,"buildRevision":240,"buildTag":"dev","buildDate":"Sun May 05 2024","build":"1.125.240 dev"}
1+
{"buildMajor":1,"buildMinor":125,"buildRevision":241,"buildTag":"dev","buildDate":"Fri May 31 2024","build":"1.125.241 dev"}

dev-resources/spawn-test-spigot.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@ cp dev-resources/ops.json test-server-spigot/
1616

1717
cd test-server-spigot
1818
echo "Cleaning server..."
19-
if [ ! -f ./spigot-1.20.2.jar ]; then
20-
wget https://download.getbukkit.org/spigot/spigot-1.20.2.jar
19+
if [ ! -f ./spigot-1.20.4.jar ]; then
20+
wget https://download.getbukkit.org/spigot/spigot-1.20.4.jar
2121
echo "eula=true" > eula.txt
22-
chmod +x spigot-1.20.2.jar
22+
chmod +x spigot-1.20.4.jar
2323
fi
2424

2525
#export OA_ENVIRONMENT="DEVELOPMENT"
@@ -29,4 +29,4 @@ echo "Starting server.."
2929
rm world/session.lock
3030
rm world_the_end/session.lock
3131
rm world_nether/session.lock
32-
java -Xms3G -Xmx3G -DIReallyKnowWhatIAmDoingISwear -jar paper-1.20.6-49.jar nogui
32+
java -Xms3G -Xmx3G -DIReallyKnowWhatIAmDoingISwear -jar spigot-1.20.4.jar nogui

modules/vistas-server/dependency-reduced-pom.xml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -174,12 +174,6 @@
174174
<artifactId>junit</artifactId>
175175
<version>4.13.2</version>
176176
<scope>test</scope>
177-
<exclusions>
178-
<exclusion>
179-
<artifactId>hamcrest-core</artifactId>
180-
<groupId>org.hamcrest</groupId>
181-
</exclusion>
182-
</exclusions>
183177
</dependency>
184178
</dependencies>
185179
<properties>

plugin/src/main/bash/data.bin

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
BUILD_NUM="1433"
1+
BUILD_NUM="1438"

plugin/src/main/java/com/craftmend/openaudiomc/spigot/modules/regions/objects/RegionProperties.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ public Media getMediaForWorld(WorldRegionManager worldRegionManager) {
4545
if (loop == null) loop = true;
4646
Media media = worldRegionManager.getRegionMedia(source, volume, fadeTimeMs, loop);
4747
media.setDoPickup(this.doSync);
48+
media.setFadeTime(fadeTimeMs);
4849
return media;
4950
}
5051

0 commit comments

Comments
 (0)