I have IBS and I struggle with this sometimes. Less lately.
Sometimes it’s really okay to just let it go in the studio. Nobody will be upset with you. Just get it over with and don’t make a fuss about it.
If I have to pass gas a second time I get up and go take care of it in the bathroom.
If I’m really gassy I’ll just leave, because I don’t want to be a disruption to everyone. Once in a class is fine, but not everyone will be able to concentrate with someone like that three feet away.