[CODE] >> [data audParams]=audioread('original.wav'); >> figure(); >> subplot(2,1,1);plot(data(:,1));title('left channel'); >> subplot(2,1,2);plot(data(:,2));title('right channel'); [/CODE] The above opens the file and plots the waveform ('figure1.png'). We get 'audParams' to write the output file with the same format as the input (44.1k, 16 bit wav I think). [CODE] >> data2=data./2; >> figure(); >> subplot(2,1,1);plot(data2(:,1));title('data2 - left channel') >> subplot(2,1,2);plot(data2(:,2));title('data2 - right channel') [/CODE] The above divides by 2 and plots the waveform (figure2.png). The period before the divide ('./') just means divide every sample value individually - you'll notice all the math functions I use here have this (don't worry about what '/' does *without* the period for now). Note that the waveform plot is exactly the same, the only thing that changes is that the y-axis goes from .5 to -.5 now. To give it an exponent less than 1 is a bit more complicated, since half the waveform is negative. So this is a 2-step process - we apply the exponent to the *absolute* value of the waveform (figure3.png), and then extract the sign from the original data, and re-apply it (figure4.png): [CODE] >> data3=abs(data).^(.1); >> figure(); >> subplot(2,1,1);plot(data3(:,1));title('data3 - left channel') >> subplot(2,1,2);plot(data3(:,2));title('data3 - right channel') >> dataSign=( (data<0)*(-1)+(data>0) ); >> data4=data3.*dataSign; >> figure(); >> subplot(2,1,1);plot(data4(:,1));title('data4 - left channel') >> subplot(2,1,2);plot(data4(:,2));title('data4 - right channel') >> audiowrite('compressed.wav',data4,audParams); [/CODE] I've exported this as 'compressed.wav', which you can listen to from that folder. Pretty gnarly sounding. and *loud* We can do the same with an expander. I've chosen an exponent of 3 to make life easy - we don't have to worry about sign. [CODE] data5=data.^3; >> figure() >> subplot(2,1,1);plot(data5(:,1));title('data5 - left channel') >> subplot(2,1,2);plot(data5(:,2));title('data5 - right channel') >> audiowrite('expanded.wav',data5,audParams); [/CODE] That's 'figure5.png', and you can listen to that, too. Note that these are both pretty horrible sounding, not at all what a plugin expander or compressor would sound like. A standard compressor has a 'threshold', so it doesn't do anything to the low-volume parts, and a 'linear' compression ratio (as opposed to the exponential ratio applied here). But the same effect applies - the quiter and louder bits get closer together in volume. You might try some less extreme exponents and get something a bit more pleasant, too!