Skip to content

Commit b68610d

Browse files
committed
sender adjusts volume, readme
1 parent abf8512 commit b68610d

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,14 @@ This device is fully compatible with [ScreamRouter](https://github.com/netham45/
109109
- Enter the password
110110
- Device will connect and restart
111111

112-
4. **Access the web interface**
112+
4. **Direct Connection Mode (No WiFi Network)**
113+
- If you want to use the receiver without connecting it to a WiFi network:
114+
- The receiver will remain in AP mode with IP address 192.168.4.1
115+
- Connect your sender device to the "ESP32-Scream" AP network
116+
- Configure the sender to use destination IP 192.168.4.1 and port 4010
117+
- Audio streaming will work directly between the devices
118+
119+
5. **Access the web interface**
113120
- Find the device's IP on your network
114121
- Or reconnect to "ESP32-Scream"
115122
- Open the IP address in a browser

main/scream_sender.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@ static esp_err_t uac_device_output_cb(uint8_t *buf, size_t len, void *arg)
5353

5454
// Process the data in chunks
5555
while (s_data_in_head >= CHUNK_SIZE) {
56+
// Get volume from config manager
57+
app_config_t *config = config_manager_get_config();
58+
float volume = config->volume;
59+
60+
if (volume < 1.0f) {
61+
// Apply volume scaling for 16-bit PCM audio
62+
int16_t *samples = (int16_t*)s_data_in;
63+
int num_samples = CHUNK_SIZE / 2; // 2 bytes per sample for 16-bit audio
64+
65+
for (int i = 0; i < num_samples; i++) {
66+
samples[i] = (int16_t)(samples[i] * volume);
67+
}
68+
}
69+
5670
memcpy(s_data_out + HEADER_SIZE, s_data_in, CHUNK_SIZE);
5771

5872
// Send with retry logic
@@ -112,6 +126,16 @@ static void uac_device_set_volume_cb(uint32_t volume, void *arg)
112126
}
113127

114128
ESP_LOGI(TAG, "Mapped volume: %"PRIu32"", s_volume);
129+
130+
// Update config manager's volume (convert from 0-100 to 0.0-1.0 scale)
131+
float config_volume = (float)s_volume / 100.0f;
132+
app_config_t *config = config_manager_get_config();
133+
config->volume = config_volume;
134+
135+
// Save the new volume setting to NVS
136+
config_manager_save_setting("volume", &config_volume, sizeof(float));
137+
138+
ESP_LOGI(TAG, "Config volume updated to %.2f", config_volume);
115139
}
116140

117141
esp_err_t scream_sender_init(void)

0 commit comments

Comments
 (0)